hexsha
string | size
int64 | ext
string | lang
string | max_stars_repo_path
string | max_stars_repo_name
string | max_stars_repo_head_hexsha
string | max_stars_repo_licenses
list | max_stars_count
int64 | max_stars_repo_stars_event_min_datetime
string | max_stars_repo_stars_event_max_datetime
string | max_issues_repo_path
string | max_issues_repo_name
string | max_issues_repo_head_hexsha
string | max_issues_repo_licenses
list | max_issues_count
int64 | max_issues_repo_issues_event_min_datetime
string | max_issues_repo_issues_event_max_datetime
string | max_forks_repo_path
string | max_forks_repo_name
string | max_forks_repo_head_hexsha
string | max_forks_repo_licenses
list | max_forks_count
int64 | max_forks_repo_forks_event_min_datetime
string | max_forks_repo_forks_event_max_datetime
string | content
string | avg_line_length
float64 | max_line_length
int64 | alphanum_fraction
float64 | qsc_code_num_words_quality_signal
int64 | qsc_code_num_chars_quality_signal
float64 | qsc_code_mean_word_length_quality_signal
float64 | qsc_code_frac_words_unique_quality_signal
float64 | qsc_code_frac_chars_top_2grams_quality_signal
float64 | qsc_code_frac_chars_top_3grams_quality_signal
float64 | qsc_code_frac_chars_top_4grams_quality_signal
float64 | qsc_code_frac_chars_dupe_5grams_quality_signal
float64 | qsc_code_frac_chars_dupe_6grams_quality_signal
float64 | qsc_code_frac_chars_dupe_7grams_quality_signal
float64 | qsc_code_frac_chars_dupe_8grams_quality_signal
float64 | qsc_code_frac_chars_dupe_9grams_quality_signal
float64 | qsc_code_frac_chars_dupe_10grams_quality_signal
float64 | qsc_code_frac_chars_replacement_symbols_quality_signal
float64 | qsc_code_frac_chars_digital_quality_signal
float64 | qsc_code_frac_chars_whitespace_quality_signal
float64 | qsc_code_size_file_byte_quality_signal
float64 | qsc_code_num_lines_quality_signal
float64 | qsc_code_num_chars_line_max_quality_signal
float64 | qsc_code_num_chars_line_mean_quality_signal
float64 | qsc_code_frac_chars_alphabet_quality_signal
float64 | qsc_code_frac_chars_comments_quality_signal
float64 | qsc_code_cate_xml_start_quality_signal
float64 | qsc_code_frac_lines_dupe_lines_quality_signal
float64 | qsc_code_cate_autogen_quality_signal
float64 | qsc_code_frac_lines_long_string_quality_signal
float64 | qsc_code_frac_chars_string_length_quality_signal
float64 | qsc_code_frac_chars_long_word_length_quality_signal
float64 | qsc_code_frac_lines_string_concat_quality_signal
float64 | qsc_code_cate_encoded_data_quality_signal
float64 | qsc_code_frac_chars_hex_words_quality_signal
float64 | qsc_code_frac_lines_prompt_comments_quality_signal
float64 | qsc_code_frac_lines_assert_quality_signal
float64 | qsc_codepython_cate_ast_quality_signal
float64 | qsc_codepython_frac_lines_func_ratio_quality_signal
float64 | qsc_codepython_cate_var_zero_quality_signal
bool | qsc_codepython_frac_lines_pass_quality_signal
float64 | qsc_codepython_frac_lines_import_quality_signal
float64 | qsc_codepython_frac_lines_simplefunc_quality_signal
float64 | qsc_codepython_score_lines_no_logic_quality_signal
float64 | qsc_codepython_frac_lines_print_quality_signal
float64 | qsc_code_num_words
int64 | qsc_code_num_chars
int64 | qsc_code_mean_word_length
int64 | qsc_code_frac_words_unique
null | qsc_code_frac_chars_top_2grams
int64 | qsc_code_frac_chars_top_3grams
int64 | qsc_code_frac_chars_top_4grams
int64 | qsc_code_frac_chars_dupe_5grams
int64 | qsc_code_frac_chars_dupe_6grams
int64 | qsc_code_frac_chars_dupe_7grams
int64 | qsc_code_frac_chars_dupe_8grams
int64 | qsc_code_frac_chars_dupe_9grams
int64 | qsc_code_frac_chars_dupe_10grams
int64 | qsc_code_frac_chars_replacement_symbols
int64 | qsc_code_frac_chars_digital
int64 | qsc_code_frac_chars_whitespace
int64 | qsc_code_size_file_byte
int64 | qsc_code_num_lines
int64 | qsc_code_num_chars_line_max
int64 | qsc_code_num_chars_line_mean
int64 | qsc_code_frac_chars_alphabet
int64 | qsc_code_frac_chars_comments
int64 | qsc_code_cate_xml_start
int64 | qsc_code_frac_lines_dupe_lines
int64 | qsc_code_cate_autogen
int64 | qsc_code_frac_lines_long_string
int64 | qsc_code_frac_chars_string_length
int64 | qsc_code_frac_chars_long_word_length
int64 | qsc_code_frac_lines_string_concat
null | qsc_code_cate_encoded_data
int64 | qsc_code_frac_chars_hex_words
int64 | qsc_code_frac_lines_prompt_comments
int64 | qsc_code_frac_lines_assert
int64 | qsc_codepython_cate_ast
int64 | qsc_codepython_frac_lines_func_ratio
int64 | qsc_codepython_cate_var_zero
int64 | qsc_codepython_frac_lines_pass
int64 | qsc_codepython_frac_lines_import
int64 | qsc_codepython_frac_lines_simplefunc
int64 | qsc_codepython_score_lines_no_logic
int64 | qsc_codepython_frac_lines_print
int64 | effective
string | hits
int64 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9b8ba846c55faf731fcca53f747364bc53d30509
| 229
|
py
|
Python
|
taxi/timesheet/__init__.py
|
simonbru/taxi
|
3940f520b6d61b5ac7c851c38dfd05da2f65b647
|
[
"WTFPL"
] | 17
|
2016-02-02T14:10:49.000Z
|
2021-11-30T00:04:29.000Z
|
taxi/timesheet/__init__.py
|
simonbru/taxi
|
3940f520b6d61b5ac7c851c38dfd05da2f65b647
|
[
"WTFPL"
] | 70
|
2015-01-08T17:02:42.000Z
|
2021-09-21T20:08:07.000Z
|
taxi/timesheet/__init__.py
|
simonbru/taxi
|
3940f520b6d61b5ac7c851c38dfd05da2f65b647
|
[
"WTFPL"
] | 8
|
2015-08-23T12:50:36.000Z
|
2021-11-26T10:33:45.000Z
|
# flake8: noqa
from .lines import TextLine, DateLine
from .entry import Entry, EntriesCollection
from .parser import TimesheetParser, create_time_from_text, is_top_down, trim
from .timesheet import Timesheet, TimesheetCollection
| 38.166667
| 77
| 0.838428
| 29
| 229
| 6.448276
| 0.689655
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.004902
| 0.10917
| 229
| 5
| 78
| 45.8
| 0.911765
| 0.052402
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
9b8fcbdcb02b9c2a21e5919e844c57535a98a7cb
| 184
|
py
|
Python
|
spectrum_gmbh/__init__.py
|
KCL-BMEIS/spectrumdevice
|
f0eecbd1d3b58dc9a9f226c4c75d7f398b1ea551
|
[
"MIT"
] | 4
|
2022-01-10T08:35:23.000Z
|
2022-01-19T12:06:05.000Z
|
spectrum_gmbh/__init__.py
|
KCL-BMEIS/spectrumdevice
|
f0eecbd1d3b58dc9a9f226c4c75d7f398b1ea551
|
[
"MIT"
] | 8
|
2022-01-05T14:07:10.000Z
|
2022-03-17T20:03:27.000Z
|
spectrum_gmbh/__init__.py
|
KCL-BMEIS/spectrumdevice
|
f0eecbd1d3b58dc9a9f226c4c75d7f398b1ea551
|
[
"MIT"
] | null | null | null |
# Files in this module are provided free of charge by Spectrum GMBH with no restrictions on use.
# They have been included here to simplify installation of the spectrumdevice package.
| 61.333333
| 96
| 0.809783
| 29
| 184
| 5.137931
| 0.965517
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.168478
| 184
| 2
| 97
| 92
| 0.973856
| 0.972826
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
32de442571c9ca55e0be461b0cbf91b834ec71d9
| 821
|
py
|
Python
|
HaPPPy/MasterEquation/__init__.py
|
Mohammed-El-Nabulsi/single-electron-transistor
|
db1abd3627312403be83197c27d06ac4e3a61746
|
[
"BSD-2-Clause"
] | null | null | null |
HaPPPy/MasterEquation/__init__.py
|
Mohammed-El-Nabulsi/single-electron-transistor
|
db1abd3627312403be83197c27d06ac4e3a61746
|
[
"BSD-2-Clause"
] | null | null | null |
HaPPPy/MasterEquation/__init__.py
|
Mohammed-El-Nabulsi/single-electron-transistor
|
db1abd3627312403be83197c27d06ac4e3a61746
|
[
"BSD-2-Clause"
] | null | null | null |
"""
.. module:: HaPPPy.MasterEquation
:platform: Unix, Windows
:synopsis: Tackles the master equation.
A module to simulate the time development of propabilities :math:`\\vec{P}(t)`
or to find stationary solutions :math:`\\vec{P}_{stat}` for an :math:`n`-state
quantum dot transistor with two reservoirs with transition rates
:math:`\\Gamma^{L}` and :math:`\\Gamma^{R}` including the netto current
:math:`I(t)` or the sationary netto current :math:`I_{stat}` respectively.
This module contains two classes. MasterEquationSolver does all mentioned
calculations and Simulation is a special return type for simulations produced by
MasterEquationSolver to provide a simple yet convenient object to operate with.
"""
from .MasterEquationSolver import MasterEquationSolver
from .MasterEquationSolver import Simulation
| 43.210526
| 80
| 0.778319
| 110
| 821
| 5.790909
| 0.663636
| 0.021978
| 0.025118
| 0.053375
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.127893
| 821
| 18
| 81
| 45.611111
| 0.889665
| 0.861145
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
32f157ec08686fdb7e7194848a5bd3c8ded5d953
| 32
|
py
|
Python
|
pybugsnag/utils/__init__.py
|
jpetrucciani/pybugsnag
|
367e6e0842928e557e708a80d9b999ad3486b400
|
[
"MIT"
] | 3
|
2018-09-18T13:36:26.000Z
|
2020-12-07T22:38:33.000Z
|
pybugsnag/utils/__init__.py
|
jpetrucciani/pybugsnag
|
367e6e0842928e557e708a80d9b999ad3486b400
|
[
"MIT"
] | null | null | null |
pybugsnag/utils/__init__.py
|
jpetrucciani/pybugsnag
|
367e6e0842928e557e708a80d9b999ad3486b400
|
[
"MIT"
] | 1
|
2020-12-07T23:34:59.000Z
|
2020-12-07T23:34:59.000Z
|
"""
utilities for pybugsnag
"""
| 8
| 23
| 0.65625
| 3
| 32
| 7
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.15625
| 32
| 3
| 24
| 10.666667
| 0.777778
| 0.71875
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
fd25ba81163d883a65a07de03662e866968a9ede
| 57
|
py
|
Python
|
Python/Books/Learning-Programming-with-Python.Tamim-Shahriar-Subeen/chapter-005/pg-5.1-check-turtle.py
|
shihab4t/Books-Code
|
b637b6b2ad42e11faf87d29047311160fe3b2490
|
[
"Unlicense"
] | null | null | null |
Python/Books/Learning-Programming-with-Python.Tamim-Shahriar-Subeen/chapter-005/pg-5.1-check-turtle.py
|
shihab4t/Books-Code
|
b637b6b2ad42e11faf87d29047311160fe3b2490
|
[
"Unlicense"
] | null | null | null |
Python/Books/Learning-Programming-with-Python.Tamim-Shahriar-Subeen/chapter-005/pg-5.1-check-turtle.py
|
shihab4t/Books-Code
|
b637b6b2ad42e11faf87d29047311160fe3b2490
|
[
"Unlicense"
] | null | null | null |
import turtle
turtle.forward(100)
turtle.exitonclick()
| 9.5
| 20
| 0.789474
| 7
| 57
| 6.428571
| 0.714286
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.058824
| 0.105263
| 57
| 5
| 21
| 11.4
| 0.823529
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
fd2fbd9769b66b91d61965bdbfd5f752059b9a75
| 356
|
py
|
Python
|
blog/hashing.py
|
marcogrella/fastapi-blog
|
79c37cc029f3919f9d6cc5a86dc6b4c456617d58
|
[
"MIT"
] | null | null | null |
blog/hashing.py
|
marcogrella/fastapi-blog
|
79c37cc029f3919f9d6cc5a86dc6b4c456617d58
|
[
"MIT"
] | null | null | null |
blog/hashing.py
|
marcogrella/fastapi-blog
|
79c37cc029f3919f9d6cc5a86dc6b4c456617d58
|
[
"MIT"
] | null | null | null |
from passlib.context import CryptContext
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
class Hash():
def bcript(password: str):
hashedPassword = pwd_context.hash(password)
return hashedPassword
def verify(hashed_password, plain_password):
return pwd_context.verify(plain_password, hashed_password )
| 25.428571
| 67
| 0.735955
| 39
| 356
| 6.538462
| 0.538462
| 0.117647
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.174157
| 356
| 14
| 67
| 25.428571
| 0.867347
| 0
| 0
| 0
| 0
| 0
| 0.028011
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0.75
| 0.125
| 0.125
| 0.75
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
|
0
| 4
|
fd308d7dbc333d082e34f58aff0ed51ad0791375
| 439
|
py
|
Python
|
exercises/pt/test_02_02_01.py
|
tuanducdesign/spacy-course
|
f8d092c5fa2997fccb3f367d174dce8667932b3d
|
[
"MIT"
] | null | null | null |
exercises/pt/test_02_02_01.py
|
tuanducdesign/spacy-course
|
f8d092c5fa2997fccb3f367d174dce8667932b3d
|
[
"MIT"
] | null | null | null |
exercises/pt/test_02_02_01.py
|
tuanducdesign/spacy-course
|
f8d092c5fa2997fccb3f367d174dce8667932b3d
|
[
"MIT"
] | null | null | null |
def test():
assert gato_hash == nlp.vocab.strings["gato"], "Você atribuiu o código hash corretamente?"
assert 'nlp.vocab.strings["gato"]' in __solution__, "Você selecionou a string corretamente?"
assert gato_string == "gato", "Você selecionou a string corretamente?"
assert (
"nlp.vocab.strings[gato_hash]" in __solution__
), "Você obteve a string a partir do código hash?"
__msg__.good("Ótimo trabalho!")
| 43.9
| 96
| 0.697039
| 57
| 439
| 5.105263
| 0.438596
| 0.082474
| 0.154639
| 0.195876
| 0.460481
| 0.460481
| 0
| 0
| 0
| 0
| 0
| 0
| 0.182232
| 439
| 9
| 97
| 48.777778
| 0.810585
| 0
| 0
| 0
| 0
| 0
| 0.542141
| 0.120729
| 0
| 0
| 0
| 0
| 0.5
| 1
| 0.125
| true
| 0
| 0
| 0
| 0.125
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
fd6528d33d5ce332cf4a3ddb8af541cb3658aeca
| 31
|
py
|
Python
|
homeassistant/components/ilightsln/__init__.py
|
DavidLP/home-assistant
|
58f343e0ba1df54f6689547b325f24ea6df69089
|
[
"Apache-2.0"
] | null | null | null |
homeassistant/components/ilightsln/__init__.py
|
DavidLP/home-assistant
|
58f343e0ba1df54f6689547b325f24ea6df69089
|
[
"Apache-2.0"
] | null | null | null |
homeassistant/components/ilightsln/__init__.py
|
DavidLP/home-assistant
|
58f343e0ba1df54f6689547b325f24ea6df69089
|
[
"Apache-2.0"
] | 1
|
2021-06-16T09:57:31.000Z
|
2021-06-16T09:57:31.000Z
|
"""The ilightsln component."""
| 15.5
| 30
| 0.677419
| 3
| 31
| 7
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.096774
| 31
| 1
| 31
| 31
| 0.75
| 0.774194
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
b5c198ec8698c157c8ed2b3c867efa83858002eb
| 51
|
py
|
Python
|
tests/development/destination/gcs/test_create_bucket.py
|
denssk/backup
|
292d5f1b1a3765ce0ea8d3cab8bd1ae0c583f72e
|
[
"Apache-2.0"
] | 69
|
2016-06-29T16:13:55.000Z
|
2022-03-21T06:38:37.000Z
|
tests/development/destination/gcs/test_create_bucket.py
|
denssk/backup
|
292d5f1b1a3765ce0ea8d3cab8bd1ae0c583f72e
|
[
"Apache-2.0"
] | 237
|
2016-09-28T02:12:34.000Z
|
2022-03-25T13:32:23.000Z
|
tests/development/destination/gcs/test_create_bucket.py
|
denssk/backup
|
292d5f1b1a3765ce0ea8d3cab8bd1ae0c583f72e
|
[
"Apache-2.0"
] | 45
|
2017-01-04T21:20:27.000Z
|
2021-12-29T10:42:22.000Z
|
def test_create_bucket(gs):
gs.create_bucket()
| 17
| 27
| 0.745098
| 8
| 51
| 4.375
| 0.625
| 0.685714
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.137255
| 51
| 2
| 28
| 25.5
| 0.795455
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.5
| false
| 0
| 0
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
b5df59dbf126ded557f1ab3788e9af072cd7a2dd
| 130
|
py
|
Python
|
player.py
|
dunlapc4/playdio
|
8af96c4a746ba42ef1e683c7a259de9d808176c9
|
[
"MIT"
] | null | null | null |
player.py
|
dunlapc4/playdio
|
8af96c4a746ba42ef1e683c7a259de9d808176c9
|
[
"MIT"
] | null | null | null |
player.py
|
dunlapc4/playdio
|
8af96c4a746ba42ef1e683c7a259de9d808176c9
|
[
"MIT"
] | 1
|
2020-06-07T22:02:52.000Z
|
2020-06-07T22:02:52.000Z
|
import wave
from playsound import playsound
def playTrack(fileName):
track = 'audioclips/' + fileName
playsound(track)
| 14.444444
| 36
| 0.730769
| 14
| 130
| 6.785714
| 0.642857
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.192308
| 130
| 8
| 37
| 16.25
| 0.904762
| 0
| 0
| 0
| 0
| 0
| 0.085271
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0
| 0.4
| 0
| 0.6
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
bd1e29ec304452054a43ff749c73c24e280af54e
| 237
|
py
|
Python
|
indig/serializers.py
|
Paulo-Lopes-Estevao/indicativos-globais
|
7dc75f954ba03a38eb8f7529541b3cb84b40472a
|
[
"BSD-3-Clause"
] | 2
|
2021-10-02T23:10:25.000Z
|
2021-10-03T00:59:45.000Z
|
indig/serializers.py
|
Paulo-Lopes-Estevao/indicativos-globais
|
7dc75f954ba03a38eb8f7529541b3cb84b40472a
|
[
"BSD-3-Clause"
] | null | null | null |
indig/serializers.py
|
Paulo-Lopes-Estevao/indicativos-globais
|
7dc75f954ba03a38eb8f7529541b3cb84b40472a
|
[
"BSD-3-Clause"
] | null | null | null |
from rest_framework.serializers import HyperlinkedModelSerializer
from indig.models import Indicativos
class IndicativoSerializer(HyperlinkedModelSerializer):
class Meta:
model = Indicativos
fields = ['id', 'pais']
| 26.333333
| 65
| 0.763713
| 21
| 237
| 8.571429
| 0.761905
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.172996
| 237
| 8
| 66
| 29.625
| 0.918367
| 0
| 0
| 0
| 0
| 0
| 0.025316
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
bd51350bd418390e9da7bb860e1f29680d3ffcf7
| 121
|
py
|
Python
|
snippets/show-image.py
|
district10/snippet-manager
|
bebe45a601368947168e3ee6e6ab8c1fc2ee2055
|
[
"MIT"
] | 7
|
2018-08-04T09:28:19.000Z
|
2020-10-19T17:46:34.000Z
|
snippets/show-image.py
|
district10/snippet-manager
|
bebe45a601368947168e3ee6e6ab8c1fc2ee2055
|
[
"MIT"
] | null | null | null |
snippets/show-image.py
|
district10/snippet-manager
|
bebe45a601368947168e3ee6e6ab8c1fc2ee2055
|
[
"MIT"
] | 2
|
2018-07-31T04:14:55.000Z
|
2020-04-02T01:22:39.000Z
|
# python show image
from IPython.display import Image
Image("http://scikit-learn.org/dev/_static/ml_map.png", width=800)
| 30.25
| 66
| 0.77686
| 20
| 121
| 4.6
| 0.9
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.027027
| 0.082645
| 121
| 3
| 67
| 40.333333
| 0.801802
| 0.140496
| 0
| 0
| 0
| 0
| 0.45098
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
1fbd8fa727c342cfe3022ddc98542e6dfbc87ef3
| 137
|
py
|
Python
|
famplex/html/__main__.py
|
steppi/famplex
|
ed09bf583b38a46b951cf8635871272c95df7fb8
|
[
"CC0-1.0"
] | 11
|
2018-06-14T18:23:52.000Z
|
2021-12-16T14:06:59.000Z
|
famplex/html/__main__.py
|
steppi/famplex
|
ed09bf583b38a46b951cf8635871272c95df7fb8
|
[
"CC0-1.0"
] | 97
|
2018-03-29T15:15:58.000Z
|
2021-11-10T12:49:51.000Z
|
famplex/html/__main__.py
|
steppi/famplex
|
ed09bf583b38a46b951cf8635871272c95df7fb8
|
[
"CC0-1.0"
] | 12
|
2018-03-28T17:52:02.000Z
|
2022-03-29T23:16:54.000Z
|
# -*- coding: utf-8 -*-
"""CLI for exporting FamPlex as a static site."""
from .api import html
if __name__ == '__main__':
html()
| 15.222222
| 49
| 0.613139
| 19
| 137
| 4
| 0.947368
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.009259
| 0.211679
| 137
| 8
| 50
| 17.125
| 0.694444
| 0.481752
| 0
| 0
| 0
| 0
| 0.123077
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
1ffcfce8b97cdbe1c6a8e39c43186bdf85257134
| 460
|
py
|
Python
|
tamedpy/sbc.py
|
karanluthra/TamedPy
|
013bc5e465d1d3ee09bd8241a55b5ea73cfdae97
|
[
"MIT"
] | null | null | null |
tamedpy/sbc.py
|
karanluthra/TamedPy
|
013bc5e465d1d3ee09bd8241a55b5ea73cfdae97
|
[
"MIT"
] | null | null | null |
tamedpy/sbc.py
|
karanluthra/TamedPy
|
013bc5e465d1d3ee09bd8241a55b5ea73cfdae97
|
[
"MIT"
] | null | null | null |
from driver import Driver
class SandboxedContext(object):
def __init__(self, num_workers=1):
self.driver = Driver(num_workers)
self.driver.turnup()
def __enter__(self):
return self.driver
def __exit__(self, ctx_type, ctx_value, ctx_traceback):
self.driver.turndown()
def execute(self, *args, **kwargs):
return self.driver.execute(*args, **kwargs)
def close(self):
self.driver.turndown()
| 24.210526
| 59
| 0.654348
| 56
| 460
| 5.071429
| 0.446429
| 0.211268
| 0.112676
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.002825
| 0.230435
| 460
| 18
| 60
| 25.555556
| 0.799435
| 0
| 0
| 0.153846
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.384615
| false
| 0
| 0.076923
| 0.153846
| 0.692308
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
1f2e0e17d43ae50a5547b6075dfe86a6b9fb016b
| 15
|
py
|
Python
|
pyutilib/component/loader/tests/eggsrc/pkg4/package4/__init__.py
|
PyUtilib/PyUtilib
|
d99406f2af1fb62268c34453a2fbe6bd4a7348f0
|
[
"BSD-3-Clause"
] | 24
|
2016-04-02T10:00:02.000Z
|
2021-03-02T16:40:18.000Z
|
pyutilib/component/loader/tests/eggsrc/pkg4/package4/__init__.py
|
PyUtilib/PyUtilib
|
d99406f2af1fb62268c34453a2fbe6bd4a7348f0
|
[
"BSD-3-Clause"
] | 105
|
2015-10-29T03:29:58.000Z
|
2021-12-30T22:00:45.000Z
|
pyutilib/component/loader/tests/eggsrc/pkg4/package4/__init__.py
|
PyUtilib/PyUtilib
|
d99406f2af1fb62268c34453a2fbe6bd4a7348f0
|
[
"BSD-3-Clause"
] | 22
|
2016-01-21T15:35:25.000Z
|
2021-05-15T20:17:44.000Z
|
"""Package4"""
| 7.5
| 14
| 0.533333
| 1
| 15
| 8
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.071429
| 0.066667
| 15
| 1
| 15
| 15
| 0.5
| 0.533333
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
1f3a439e9e8ff246f1cc5da94a3e1c7f133c7be3
| 8,664
|
py
|
Python
|
src/main/python/utime.py
|
SmartDogHouse/SmartDogHouse-Software
|
00caf23e3fe8dae2d30c339f801d7c1a7ddca0c2
|
[
"MIT"
] | 4
|
2021-05-17T10:42:48.000Z
|
2021-08-09T15:51:28.000Z
|
src/main/python/utime.py
|
SmartDogHouse/SmartDogHouse-Software
|
00caf23e3fe8dae2d30c339f801d7c1a7ddca0c2
|
[
"MIT"
] | 148
|
2021-05-17T10:03:52.000Z
|
2021-07-25T15:44:10.000Z
|
src/main/python/utime.py
|
SmartDogHouse/SmartDogHouse-Software
|
00caf23e3fe8dae2d30c339f801d7c1a7ddca0c2
|
[
"MIT"
] | 1
|
2021-06-27T17:25:20.000Z
|
2021-06-27T17:25:20.000Z
|
# STUB: do NOT upload to the ESP, it's used to run the tests
"""Module: 'utime' on esp32 1.11.0"""
import time as dummy
# MCU: (sysname='esp32', nodename='esp32', release='1.11.0', version='v1.11-580-g973f68780 on 2019-11-17', machine='ESP32 module with ESP32')
# Stubber: 1.3.2
def localtime(secs) -> tuple:
"""
Convert a time expressed in seconds since the Epoch (see above) into an 8-tuple which contains: (year, month, mday, hour, minute, second, weekday, yearday) If secs is not provided or None, then the current time from the RTC is used.
Parameters
----------
- [secs]
year includes the century (for example 2014).
- month is 1-12
- mday is 1-31
- hour is 0-23
- minute is 0-59
- second is 0-59
- weekday is 0-6 for Mon-Sun
- yearday is 1-366
http://docs.micropython.org/en/latest/library/utime.html#utime.localtime
"""
def mktime():
"""
This is inverse function of localtime. It’s argument is a full 8-tuple which expresses a time as per localtime. It returns an integer which is the number of seconds since Jan 1, 200
http://docs.micropython.org/en/latest/library/utime.html#utime.mktime
"""
def sleep(seconds):
"""
Sleep for the given number of seconds. Some boards may accept seconds as a floating-point number to sleep for a fractional number of seconds. Note that other boards may not accept a floating-point argument, for compatibility with them use sleep_ms() and sleep_us() functions
Parameters
----------
- seconds
http://docs.micropython.org/en/latest/library/utime.html#utime.sleep
"""
def sleep_ms(ms):
"""
Delay for given number of milliseconds, should be positive or 0.
Parameters
----------
- ms
http://docs.micropython.org/en/latest/library/utime.html#utime.sleep_ms
"""
def sleep_us(us):
"""
Delay for given number of microseconds, should be positive or 0.
Parameters
----------
- us
http://docs.micropython.org/en/latest/library/utime.html#utime.sleep_us
"""
def ticks_add(ticks, delta):
"""
Offset ticks value by a given number, which can be either positive or negative. Given a ticks value, this function allows to calculate ticks value delta ticks before or after it, following modular-arithmetic definition of tick values (see ticks_ms() above). ticks parameter must be a direct result of call to ticks_ms(), ticks_us(), or ticks_cpu() functions (or from previous_sent_perc call to ticks_add()). However, delta can be an arbitrary integer number or numeric expression. ticks_add() is useful for calculating deadlines for events/tasks. (Note: you must use ticks_diff() function to work with deadlines.)
Parameters
----------
- ticks
- delta
http://docs.micropython.org/en/latest/library/utime.html#utime.ticks_add
"""
def ticks_cpu():
"""
Similar to ticks_ms() and ticks_us(), but with the highest possible resolution in the system. This is usually CPU clocks, and that’s why the function is named that way. But it doesn’t have to be a CPU clock, some other timing source available in a system (e.g. high-resolution timer) can be used instead. The exact timing unit (resolution) of this function is not specified on utime module level, but documentation for a specific port may provide more specific information. This function is intended for very fine benchmarking or very tight real-time loops. Avoid using it in portable code.
http://docs.micropython.org/en/latest/library/utime.html#utime.ticks_cpu
"""
def ticks_diff(ticks1, ticks2):
"""
Measure ticks difference between values returned from ticks_ms(), ticks_us(), or ticks_cpu() functions, as a signed value which may wrap around.
Parameters
----------
- ticks1
- ticks2
The argument order is the same as for subtraction operator, ticks_diff(ticks1, ticks2) has the same meaning as ticks1 - ticks2. However, values returned by ticks_ms(), etc. functions may wrap around, so directly using subtraction on them will produce incorrect result. That is why ticks_diff() is needed, it implements modular (or more specifically, ring) arithmetics to produce correct result even for wrap-around values (as long as they not too distant inbetween, see below). The function returns signed value in the range [-TICKS_PERIOD/2 .. TICKS_PERIOD/2-1] (that’s a typical range definition for two’s-complement signed binary integers). If the result is negative, it means that ticks1 occurred earlier in time than ticks2. Otherwise, it means that ticks1 occurred after ticks2. This holds only if ticks1 and ticks2 are apart from each other for no more than TICKS_PERIOD/2-1 ticks. If that does not hold, incorrect result will be returned. Specifically, if two tick values are apart for TICKS_PERIOD/2-1 ticks, that value will be returned by the function. However, if TICKS_PERIOD/2 of real-time ticks has ed between them, the function will return -TICKS_PERIOD/2 instead, i.e. result value will wrap around to the negative range of possible values.
Informal rationale of the constraints above: Suppose you are locked in a room with no means to monitor ing of time except a standard 12-notch clock. Then if you look at dial-plate now, and don’t look again for another 13 hours (e.g., if you fall for a long sleep), then once you finally look again, it may seem to you that only 1 hour has ed. To avoid this mistake, just look at the clock regularly. Your application should do the same. “Too long sleep” metaphor also maps directly to application behavior: don’t let your application run any single task for too long. Run tasks in steps, and do time-keeping inbetween.
http://docs.micropython.org/en/latest/library/utime.html#utime.ticks_diff
"""
def ticks_ms():
"""
Returns an increasing millisecond counter with an arbitrary reference point, that wraps around after some value.
The wrap-around value is not explicitly exposed, but we will refer to it as TICKS_MAX to simplify discussion. Period of the values is TICKS_PERIOD = TICKS_MAX + 1. TICKS_PERIOD is guaranteed to be a power of two, but otherwise may differ from port to port. The same period value is used for all of ticks_ms(), ticks_us(), ticks_cpu() functions (for simplicity). Thus, these functions will return a value in range [0 .. TICKS_MAX], inclusive, total TICKS_PERIOD values. Note that only non-negative values are used. For the most part, you should treat values returned by these functions as opaque. The only operations available for them are ticks_diff() and ticks_add() functions described below.
Note: Performing standard mathematical operations (+, -) or relational operators (<, <=, >, >=) directly on these value will lead to invalid result. Performing mathematical operations and then ing their results as arguments to ticks_diff() or ticks_add() will also lead to invalid results from the latter functions.
http://docs.micropython.org/en/latest/library/utime.html#utime.ticks_ms
"""
def ticks_us():
"""
Just like ticks_ms() above, but in microseconds.
http://docs.micropython.org/en/latest/library/utime.html#utime.ticks_us
"""
def time() -> float:
"""
Returns the number of seconds, as an integer, since the Epoch, assuming that underlying RTC is set and maintained as described above. If an RTC is not set, this function returns number of seconds since a port-specific reference point in time (for embedded boards without a battery-backed RTC, usually since power up or reset). If you want to develop portable MicroPython application, you should not rely on this function to provide higher than second precision. If you need higher precision, use ticks_ms() and ticks_us() functions, if you need calendar time, localtime() without an argument is a better choice.
Difference to CPython
---------------------
In CPython, this function returns number of seconds since Unix epoch, 1970-01-01 00:00 UTC, as a floating-point, usually having microsecond precision. With MicroPython, only Unix port uses the same Epoch, and if floating-point precision allows, returns sub-second precision. Embedded hardware usually doesn’t have floating-point precision to represent both long time ranges and subsecond precision, so they use integer value with second precision. Some embedded hardware also lacks battery-powered RTC, so returns number of seconds since last power-up or from other relative, hardware-specific point (e.g. reset).
http://docs.micropython.org/en/latest/library/utime.html#utime.time
"""
return dummy.time()
| 61.446809
| 1,260
| 0.73638
| 1,367
| 8,664
| 4.62692
| 0.287491
| 0.013913
| 0.033043
| 0.038261
| 0.156838
| 0.126957
| 0.117787
| 0.105455
| 0.09502
| 0.09502
| 0
| 0.016657
| 0.182364
| 8,664
| 140
| 1,261
| 61.885714
| 0.8762
| 0.913435
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.846154
| false
| 0
| 0.076923
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
1f59f48eae82db340f335f10f2e34e76959ba0fa
| 91
|
py
|
Python
|
backend/settings_console/forms.py
|
jnyborg/nospammail
|
1b9c41c85a9a0b3d1a0a56f50ad69b01b0cb386b
|
[
"Apache-2.0"
] | null | null | null |
backend/settings_console/forms.py
|
jnyborg/nospammail
|
1b9c41c85a9a0b3d1a0a56f50ad69b01b0cb386b
|
[
"Apache-2.0"
] | null | null | null |
backend/settings_console/forms.py
|
jnyborg/nospammail
|
1b9c41c85a9a0b3d1a0a56f50ad69b01b0cb386b
|
[
"Apache-2.0"
] | null | null | null |
from django import forms
class ToggleEmailsForm(forms.Form):
id = forms.IntegerField()
| 22.75
| 35
| 0.769231
| 11
| 91
| 6.363636
| 0.818182
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.142857
| 91
| 4
| 36
| 22.75
| 0.897436
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
1f72c208aec15507450164673c1f53160566e3ce
| 129
|
py
|
Python
|
resources/test_cases/python/PyCrypto/TestRule6.py
|
stg-tud/licma
|
b899e6e682f7716d19e79d6ce7b73c28c6efd4cf
|
[
"MIT"
] | 5
|
2021-09-13T11:24:13.000Z
|
2022-03-18T21:56:58.000Z
|
resources/test_cases/python/PyCrypto/TestRule6c.py
|
stg-tud/licma
|
b899e6e682f7716d19e79d6ce7b73c28c6efd4cf
|
[
"MIT"
] | null | null | null |
resources/test_cases/python/PyCrypto/TestRule6c.py
|
stg-tud/licma
|
b899e6e682f7716d19e79d6ce7b73c28c6efd4cf
|
[
"MIT"
] | 1
|
2021-09-13T06:02:20.000Z
|
2021-09-13T06:02:20.000Z
|
"""
PyCrypto has an own secure random function "Crypto.Random.random"
but it does not use a seed value as expected by rule 6
"""
| 25.8
| 65
| 0.744186
| 23
| 129
| 4.173913
| 0.913043
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.009434
| 0.178295
| 129
| 4
| 66
| 32.25
| 0.896226
| 0.930233
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
1f97b1a75e30e7babd9096b1d17938f466a0019f
| 85
|
py
|
Python
|
dlapp/apps.py
|
tavershimafx/E-library
|
861b8aeba82e4bf0b63f5cb1421ca8f9f9cd1d96
|
[
"Apache-2.0"
] | null | null | null |
dlapp/apps.py
|
tavershimafx/E-library
|
861b8aeba82e4bf0b63f5cb1421ca8f9f9cd1d96
|
[
"Apache-2.0"
] | null | null | null |
dlapp/apps.py
|
tavershimafx/E-library
|
861b8aeba82e4bf0b63f5cb1421ca8f9f9cd1d96
|
[
"Apache-2.0"
] | null | null | null |
from django.apps import AppConfig
class DlappConfig(AppConfig):
name = 'dlapp'
| 14.166667
| 33
| 0.741176
| 10
| 85
| 6.3
| 0.9
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.176471
| 85
| 5
| 34
| 17
| 0.9
| 0
| 0
| 0
| 0
| 0
| 0.058824
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
2f293ecb9b8e2d48fc4240c89b4e9d822cbab23a
| 399
|
py
|
Python
|
joj/horse/schemas/user_access_key.py
|
joint-online-judge/horse
|
ec08ecd0528f6a4fad3fa5f5932aef1495721437
|
[
"MIT"
] | 6
|
2020-12-28T07:05:52.000Z
|
2022-01-16T04:44:02.000Z
|
joj/horse/schemas/user_access_key.py
|
joint-online-judge/horse
|
ec08ecd0528f6a4fad3fa5f5932aef1495721437
|
[
"MIT"
] | 56
|
2021-02-02T02:21:52.000Z
|
2022-03-13T02:39:05.000Z
|
joj/horse/schemas/user_access_key.py
|
joint-online-judge/horse
|
ec08ecd0528f6a4fad3fa5f5932aef1495721437
|
[
"MIT"
] | 3
|
2021-01-28T17:52:58.000Z
|
2021-12-17T17:42:42.000Z
|
from uuid import UUID
from sqlmodel import Field
from joj.horse.schemas.base import BaseORMSchema, IDMixin, TimestampMixin
class UserAccessKey(BaseORMSchema, IDMixin):
service: str = Field(nullable=False)
access_key_id: str = Field(nullable=False)
secret_access_key: str = Field(nullable=False)
user_id: UUID
class UserAccessKeyDetail(TimestampMixin, UserAccessKey):
pass
| 22.166667
| 73
| 0.77193
| 48
| 399
| 6.3125
| 0.520833
| 0.079208
| 0.158416
| 0.207921
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.155388
| 399
| 17
| 74
| 23.470588
| 0.89911
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.1
| 0.3
| 0
| 0.9
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
2f3fa8bdc5734ed5494aeefbf43e4355caca08ae
| 87
|
py
|
Python
|
fondos/apps.py
|
joelsegoviacrespo/control_aforo_migrado
|
be90d1d45a20f735e7ef20449c4ab91ca05b5d85
|
[
"MIT"
] | null | null | null |
fondos/apps.py
|
joelsegoviacrespo/control_aforo_migrado
|
be90d1d45a20f735e7ef20449c4ab91ca05b5d85
|
[
"MIT"
] | null | null | null |
fondos/apps.py
|
joelsegoviacrespo/control_aforo_migrado
|
be90d1d45a20f735e7ef20449c4ab91ca05b5d85
|
[
"MIT"
] | null | null | null |
from django.apps import AppConfig
class FondosConfig(AppConfig):
name = 'fondos'
| 14.5
| 33
| 0.747126
| 10
| 87
| 6.5
| 0.9
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.172414
| 87
| 5
| 34
| 17.4
| 0.902778
| 0
| 0
| 0
| 0
| 0
| 0.068966
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
2f5dee36e4a0670e21f8c2029ee191f9ae61eaaa
| 56
|
py
|
Python
|
tests/__init__.py
|
synesissoftware/diagnosticism.Python
|
b3f58c5616b4f5523c339fd61ea3a883d7072724
|
[
"BSD-3-Clause"
] | 1
|
2019-08-21T23:30:41.000Z
|
2019-08-21T23:30:41.000Z
|
tests/__init__.py
|
synesissoftware/diagnosticism.Python
|
b3f58c5616b4f5523c339fd61ea3a883d7072724
|
[
"BSD-3-Clause"
] | null | null | null |
tests/__init__.py
|
synesissoftware/diagnosticism.Python
|
b3f58c5616b4f5523c339fd61ea3a883d7072724
|
[
"BSD-3-Clause"
] | null | null | null |
# This file present to deal with warnings from packager
| 28
| 55
| 0.803571
| 9
| 56
| 5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.178571
| 56
| 1
| 56
| 56
| 0.978261
| 0.946429
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
2f65cb9c69fac44f7cee628643b09f2d5f944190
| 339
|
py
|
Python
|
thundra_demo_localstack/modules/dynamodb.py
|
thundra-io/thundra-demo-localstack-python
|
ffc7deb50508b59b51d791143e6e11c249df2ad5
|
[
"Apache-2.0"
] | 1
|
2021-11-08T08:36:06.000Z
|
2021-11-08T08:36:06.000Z
|
thundra_demo_localstack/modules/dynamodb.py
|
thundra-io/thundra-demo-localstack-python
|
ffc7deb50508b59b51d791143e6e11c249df2ad5
|
[
"Apache-2.0"
] | null | null | null |
thundra_demo_localstack/modules/dynamodb.py
|
thundra-io/thundra-demo-localstack-python
|
ffc7deb50508b59b51d791143e6e11c249df2ad5
|
[
"Apache-2.0"
] | null | null | null |
import boto3
from thundra_demo_localstack.utils import Singleton
from thundra_demo_localstack.config import EnvironmentConfig
class DynamoDbClient(metaclass=Singleton):
def __init__(self):
self.dynamodbClient = boto3.client('dynamodb', endpoint_url=EnvironmentConfig.LOCALSTACK_URL, region_name=EnvironmentConfig.AWS_REGION)
| 37.666667
| 143
| 0.837758
| 38
| 339
| 7.157895
| 0.605263
| 0.080882
| 0.110294
| 0.183824
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.006536
| 0.097345
| 339
| 9
| 143
| 37.666667
| 0.882353
| 0
| 0
| 0
| 0
| 0
| 0.023529
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.166667
| false
| 0
| 0.5
| 0
| 0.833333
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
85ec07bdc5380b0f1c033787d3ef53653a6ba65f
| 1,801
|
py
|
Python
|
test/test_notification_target_api.py
|
chbndrhnns/ahoi-client
|
8bd25f541c05af17c82904fa250272514b7971f2
|
[
"MIT"
] | null | null | null |
test/test_notification_target_api.py
|
chbndrhnns/ahoi-client
|
8bd25f541c05af17c82904fa250272514b7971f2
|
[
"MIT"
] | null | null | null |
test/test_notification_target_api.py
|
chbndrhnns/ahoi-client
|
8bd25f541c05af17c82904fa250272514b7971f2
|
[
"MIT"
] | null | null | null |
# coding: utf-8
"""
[AHOI cookbook](/ahoi/docs/cookbook/index.html) [Data Privacy](/sandboxmanager/#/privacy) [Terms of Service](/sandboxmanager/#/terms) [Imprint](https://sparkassen-hub.com/impressum/) © 2016‐2017 Starfinanz - Ein Unternehmen der Finanz Informatik # noqa: E501
OpenAPI spec version: 2.1.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import unittest
import swagger_client
from swagger_client.api.notification_target_api import NotificationTargetApi # noqa: E501
from swagger_client.rest import ApiException
class TestNotificationTargetApi(unittest.TestCase):
"""NotificationTargetApi unit test stubs"""
def setUp(self):
self.api = swagger_client.api.notification_target_api.NotificationTargetApi() # noqa: E501
def tearDown(self):
pass
def test_delete_notification_target(self):
"""Test case for delete_notification_target
Delete notification target # noqa: E501
"""
pass
def test_get_notification_target(self):
"""Test case for get_notification_target
Get notification target # noqa: E501
"""
pass
def test_get_notification_targets(self):
"""Test case for get_notification_targets
List notification targets # noqa: E501
"""
pass
def test_post_notification_target(self):
"""Test case for post_notification_target
Create a new notification target # noqa: E501
"""
pass
def test_put_notification_target(self):
"""Test case for put_notification_target
Update notification target # noqa: E501
"""
pass
if __name__ == '__main__':
unittest.main()
| 25.728571
| 277
| 0.682399
| 203
| 1,801
| 5.827586
| 0.403941
| 0.213018
| 0.046492
| 0.063398
| 0.362637
| 0.321217
| 0.119189
| 0.087912
| 0.087912
| 0
| 0
| 0.025955
| 0.229872
| 1,801
| 69
| 278
| 26.101449
| 0.826965
| 0.47196
| 0
| 0.272727
| 0
| 0
| 0.00995
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.318182
| false
| 0.272727
| 0.227273
| 0
| 0.590909
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
c82dfdd0215a5fda94c02bfa47312301a6ea6715
| 202
|
py
|
Python
|
captain_console/manufacturer/urls.py
|
PalinaKG/Verklegt_2
|
7bc80d2708ec2530470527b18c2aec259dddd99c
|
[
"MIT"
] | null | null | null |
captain_console/manufacturer/urls.py
|
PalinaKG/Verklegt_2
|
7bc80d2708ec2530470527b18c2aec259dddd99c
|
[
"MIT"
] | null | null | null |
captain_console/manufacturer/urls.py
|
PalinaKG/Verklegt_2
|
7bc80d2708ec2530470527b18c2aec259dddd99c
|
[
"MIT"
] | null | null | null |
from . import views
from django.urls import path
urlpatterns = [
path('', views.index, name="manufacturer-index"),
path('<int:id>', views.get_manufacturer_by_id, name="manufacturer_details")
]
| 25.25
| 79
| 0.717822
| 26
| 202
| 5.423077
| 0.576923
| 0.22695
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.133663
| 202
| 7
| 80
| 28.857143
| 0.805714
| 0
| 0
| 0
| 0
| 0
| 0.227723
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
c837b9241a1d985ff21848907f36b25885057017
| 166
|
py
|
Python
|
problem0753.py
|
kmarcini/Project-Euler-Python
|
d644e8e1ec4fac70a9ab407ad5e1f0a75547c8d3
|
[
"BSD-3-Clause"
] | null | null | null |
problem0753.py
|
kmarcini/Project-Euler-Python
|
d644e8e1ec4fac70a9ab407ad5e1f0a75547c8d3
|
[
"BSD-3-Clause"
] | null | null | null |
problem0753.py
|
kmarcini/Project-Euler-Python
|
d644e8e1ec4fac70a9ab407ad5e1f0a75547c8d3
|
[
"BSD-3-Clause"
] | null | null | null |
###########################
#
# #753 Fermat Equation - Project Euler
# https://projecteuler.net/problem=753
#
# Code by Kevin Marciniak
#
###########################
| 18.444444
| 38
| 0.475904
| 14
| 166
| 5.642857
| 0.928571
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.040816
| 0.114458
| 166
| 8
| 39
| 20.75
| 0.496599
| 0.578313
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
c0d52f359fc5f1ac65da3b5688686c322c4dd57c
| 87
|
py
|
Python
|
PP4E-Examples-1.4/Examples/PP4E/System/Tester/Scripts/test-status-bad.py
|
AngelLiang/PP4E
|
3a7f63b366e1e4700b4d2524884696999a87ba9d
|
[
"MIT"
] | null | null | null |
PP4E-Examples-1.4/Examples/PP4E/System/Tester/Scripts/test-status-bad.py
|
AngelLiang/PP4E
|
3a7f63b366e1e4700b4d2524884696999a87ba9d
|
[
"MIT"
] | null | null | null |
PP4E-Examples-1.4/Examples/PP4E/System/Tester/Scripts/test-status-bad.py
|
AngelLiang/PP4E
|
3a7f63b366e1e4700b4d2524884696999a87ba9d
|
[
"MIT"
] | null | null | null |
# test exit status: failure codes, nonzero
import sys
print('starting')
sys.exit(42)
| 14.5
| 43
| 0.735632
| 13
| 87
| 4.923077
| 0.846154
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.027027
| 0.149425
| 87
| 5
| 44
| 17.4
| 0.837838
| 0.45977
| 0
| 0
| 0
| 0
| 0.186047
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.333333
| 0
| 0.333333
| 0.333333
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
c0dbe88adbcba5a86a12a9ee43d1c0653ac05bd4
| 7,826
|
py
|
Python
|
src/dcm/agent/tests/unit/test_system_stat.py
|
JPWKU/unix-agent
|
8f1278fc8c2768a8d4d54af642a881bace43652f
|
[
"Apache-2.0"
] | null | null | null |
src/dcm/agent/tests/unit/test_system_stat.py
|
JPWKU/unix-agent
|
8f1278fc8c2768a8d4d54af642a881bace43652f
|
[
"Apache-2.0"
] | 22
|
2015-09-15T20:52:34.000Z
|
2016-03-11T22:44:24.000Z
|
src/dcm/agent/tests/unit/test_system_stat.py
|
JPWKU/unix-agent
|
8f1278fc8c2768a8d4d54af642a881bace43652f
|
[
"Apache-2.0"
] | 3
|
2015-09-11T20:21:33.000Z
|
2016-09-30T08:30:19.000Z
|
#
# Copyright (C) 2014 Dell, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import time
import unittest
import uuid
import dcm.agent.exceptions as exceptions
import dcm.agent.systemstats as systemstats
class TestSystemStats(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
systemstats.clean_up_all()
def test_get_system_stat_not_exists(self):
self.assertRaises(
exceptions.AgentOptionValueNotSetException,
systemstats.get_stats,
"somename")
def test_stop_system_stat_not_exists(self):
self.assertRaises(
exceptions.AgentOptionValueNotSetException,
systemstats.stop_stats,
"somename")
def test_start_system_stat_bad_type(self):
name = str(uuid.uuid4())
self.assertRaises(
exceptions.AgentOptionValueException,
systemstats.start_new_system_stat,
name,
"no_good",
10,
10.0)
def test_system_stat_happy_path_cpu_idle(self):
hold_count = 10
interval = 0.1
name = str(uuid.uuid4())
systemstats.start_new_system_stat(
name,
"cpu-idle",
hold_count,
interval)
time.sleep((hold_count + 2) * interval)
stats_d = systemstats.get_stats(name)
self.assertEqual(len(stats_d['status']), hold_count)
systemstats.stop_stats(name)
def test_system_stat_two_cpu_idle(self):
hold_count1 = 10
interval1 = 0.1
name1 = str(uuid.uuid4())
hold_count2 = int(hold_count1 / 2)
interval2 = interval1 * 2
name2 = str(uuid.uuid4())
systemstats.start_new_system_stat(
name1,
"cpu-idle",
hold_count1,
interval1)
systemstats.start_new_system_stat(
name2,
"cpu-idle",
hold_count2,
interval2)
time.sleep((hold_count1 + 2) * interval1)
stats_d = systemstats.get_stats(name1)
self.assertEqual(len(stats_d['status']), hold_count1)
time.sleep((hold_count2 + 2) * interval2)
stats_d = systemstats.get_stats(name2)
self.assertEqual(len(stats_d['status']), hold_count2)
systemstats.stop_stats(name1)
systemstats.stop_stats(name2)
def test_system_stat_stop_twice(self):
hold_count = 10
interval = 0.1
name = str(uuid.uuid4())
systemstats.start_new_system_stat(
name,
"cpu-idle",
hold_count,
interval)
systemstats.stop_stats(name)
self.assertRaises(
exceptions.AgentOptionValueNotSetException,
systemstats.stop_stats,
name)
class TestAgentVerboseSystemStats(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
systemstats.clean_up_all()
def test_basic_verbose_stat(self):
hold_count1 = 10
interval1 = 0.1
name1 = str(uuid.uuid4())
systemstats.start_new_system_stat(
name1,
"system-stats",
hold_count1,
interval1)
time.sleep((hold_count1 + 2) * interval1)
stats_d = systemstats.get_stats(name1)
self.assertEqual(len(stats_d['status']), hold_count1)
ent_1 = stats_d['status'][0]
self.assertIn('cpu-load', ent_1)
self.assertIn('net-bytes-in', ent_1)
self.assertIn('net-bytes-out', ent_1)
self.assertIn('disk-read-bytes', ent_1)
self.assertIn('disk-write-bytes', ent_1)
self.assertIn('disk-read-ops', ent_1)
self.assertIn('disk-write-ops', ent_1)
self.assertIn('timestamp', ent_1)
systemstats.stop_stats(name1)
def test_basic_read_ops(self):
hold_count1 = 10
interval1 = 0.1
name1 = str(uuid.uuid4())
systemstats.start_new_system_stat(
name1,
"disk-read-ops",
hold_count1,
interval1)
time.sleep((hold_count1 + 3) * interval1)
stats_d = systemstats.get_stats(name1)
self.assertEqual(len(stats_d['status']), hold_count1)
ent_1 = stats_d['status'][0]
self.assertIn('disk-read-ops', ent_1)
self.assertIn('timestamp', ent_1)
systemstats.stop_stats(name1)
def test_basic_write_ops(self):
hold_count1 = 10
interval1 = 0.1
name1 = str(uuid.uuid4())
systemstats.start_new_system_stat(
name1,
"disk-write-ops",
hold_count1,
interval1)
time.sleep((hold_count1 + 3) * interval1)
stats_d = systemstats.get_stats(name1)
self.assertEqual(len(stats_d['status']), hold_count1)
ent_1 = stats_d['status'][0]
self.assertIn('disk-write-ops', ent_1)
self.assertIn('timestamp', ent_1)
systemstats.stop_stats(name1)
def test_basic_read_bytes(self):
hold_count1 = 10
interval1 = 0.1
name1 = str(uuid.uuid4())
systemstats.start_new_system_stat(
name1,
"disk-read-bytes",
hold_count1,
interval1)
time.sleep((hold_count1 + 3) * interval1)
stats_d = systemstats.get_stats(name1)
self.assertEqual(len(stats_d['status']), hold_count1)
ent_1 = stats_d['status'][0]
self.assertIn('disk-read-bytes', ent_1)
self.assertIn('timestamp', ent_1)
systemstats.stop_stats(name1)
def test_basic_write_bytes(self):
hold_count1 = 10
interval1 = 0.1
name1 = str(uuid.uuid4())
systemstats.start_new_system_stat(
name1,
"disk-write-bytes",
hold_count1,
interval1)
time.sleep((hold_count1 + 3) * interval1)
stats_d = systemstats.get_stats(name1)
self.assertEqual(len(stats_d['status']), hold_count1)
ent_1 = stats_d['status'][0]
self.assertIn('disk-write-bytes', ent_1)
self.assertIn('timestamp', ent_1)
systemstats.stop_stats(name1)
def test_basic_net_in(self):
hold_count1 = 10
interval1 = 0.1
name1 = str(uuid.uuid4())
systemstats.start_new_system_stat(
name1,
"net-bytes-in",
hold_count1,
interval1)
time.sleep((hold_count1 + 3) * interval1)
stats_d = systemstats.get_stats(name1)
self.assertEqual(len(stats_d['status']), hold_count1)
ent_1 = stats_d['status'][0]
self.assertIn('net-bytes-in', ent_1)
self.assertIn('timestamp', ent_1)
systemstats.stop_stats(name1)
def test_basic_net_out(self):
hold_count1 = 10
interval1 = 0.1
name1 = str(uuid.uuid4())
systemstats.start_new_system_stat(
name1,
"net-bytes-out",
hold_count1,
interval1)
time.sleep((hold_count1 + 3) * interval1)
stats_d = systemstats.get_stats(name1)
self.assertEqual(len(stats_d['status']), hold_count1)
ent_1 = stats_d['status'][0]
self.assertIn('net-bytes-out', ent_1)
self.assertIn('timestamp', ent_1)
systemstats.stop_stats(name1)
| 29.310861
| 74
| 0.603629
| 923
| 7,826
| 4.887324
| 0.152763
| 0.073155
| 0.045223
| 0.04611
| 0.743072
| 0.72556
| 0.717358
| 0.679007
| 0.679007
| 0.636888
| 0
| 0.038378
| 0.294148
| 7,826
| 266
| 75
| 29.421053
| 0.77824
| 0.070406
| 0
| 0.764706
| 0
| 0
| 0.067374
| 0
| 0
| 0
| 0
| 0
| 0.166667
| 1
| 0.083333
| false
| 0.009804
| 0.02451
| 0
| 0.117647
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
c0f12f3d1f543a513c4d5ac81578bf305a538f2a
| 459
|
py
|
Python
|
tangos/properties/pynbody/mass.py
|
TobiBu/tangos
|
decab8c892c5937fd68474a375089abef198dba2
|
[
"BSD-3-Clause"
] | 15
|
2017-12-04T18:05:32.000Z
|
2021-12-20T22:11:20.000Z
|
tangos/properties/pynbody/mass.py
|
TobiBu/tangos
|
decab8c892c5937fd68474a375089abef198dba2
|
[
"BSD-3-Clause"
] | 99
|
2017-11-09T16:47:20.000Z
|
2022-03-07T10:15:12.000Z
|
tangos/properties/pynbody/mass.py
|
TobiBu/tangos
|
decab8c892c5937fd68474a375089abef198dba2
|
[
"BSD-3-Clause"
] | 14
|
2017-11-06T18:46:17.000Z
|
2021-12-13T10:49:53.000Z
|
from . import PynbodyPropertyCalculation
class Masses(PynbodyPropertyCalculation):
names = "finder_mass"
def calculate(self, halo, existing_properties):
return halo['mass'].sum()
class MassBreakdown(PynbodyPropertyCalculation):
names = "finder_dm_mass", "finder_star_mass", "finder_gas_mass"
def calculate(self, halo, existing_properties):
return halo.dm['mass'].sum(), halo.star['mass'].sum(), halo.gas['mass'].sum()
| 30.6
| 85
| 0.71024
| 51
| 459
| 6.215686
| 0.392157
| 0.088328
| 0.233438
| 0.126183
| 0.328076
| 0.328076
| 0.328076
| 0.328076
| 0.328076
| 0
| 0
| 0
| 0.154684
| 459
| 14
| 86
| 32.785714
| 0.81701
| 0
| 0
| 0.222222
| 0
| 0
| 0.156863
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.222222
| false
| 0
| 0.111111
| 0.222222
| 1
| 0
| 0
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
23cfb0abb4cdca38fe77139cef1c52aaad92d63a
| 252
|
py
|
Python
|
src/pyclts/__init__.py
|
lingpy/clts
|
5cd1b1dc6f7bc0983ea0ff7843d046f6d761807a
|
[
"Apache-2.0"
] | 4
|
2018-11-07T14:33:39.000Z
|
2019-04-05T18:11:15.000Z
|
src/pyclts/__init__.py
|
lingpy/clts
|
5cd1b1dc6f7bc0983ea0ff7843d046f6d761807a
|
[
"Apache-2.0"
] | 104
|
2017-12-04T09:28:37.000Z
|
2019-10-22T08:05:18.000Z
|
src/pyclts/__init__.py
|
lingpy/clts
|
5cd1b1dc6f7bc0983ea0ff7843d046f6d761807a
|
[
"Apache-2.0"
] | 5
|
2017-12-04T10:06:15.000Z
|
2019-03-17T12:49:48.000Z
|
from pyclts.transcriptionsystem import TranscriptionSystem # noqa: F401
from pyclts.transcriptiondata import TranscriptionData # noqa: F401
from pyclts.soundclasses import SoundClasses # noqa: F401
from pyclts import api
__version__ = '1.3.1.dev0'
| 36
| 72
| 0.813492
| 30
| 252
| 6.7
| 0.433333
| 0.199005
| 0.179104
| 0.268657
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.059091
| 0.126984
| 252
| 6
| 73
| 42
| 0.854545
| 0.126984
| 0
| 0
| 0
| 0
| 0.046296
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.8
| 0
| 0.8
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
23f9ebadb708eaf54df592f1f505653aa101b168
| 90
|
py
|
Python
|
BuscaCotacoes/Application.py
|
vitimdt/TraderExpert
|
942efb1f726c6f74e2a3c8d4099db30d72e8474e
|
[
"Apache-2.0"
] | 1
|
2021-05-26T16:55:27.000Z
|
2021-05-26T16:55:27.000Z
|
BuscaCotacoes/Application.py
|
vitimdt/TraderExpert
|
942efb1f726c6f74e2a3c8d4099db30d72e8474e
|
[
"Apache-2.0"
] | 1
|
2021-04-29T13:04:59.000Z
|
2021-05-14T16:26:03.000Z
|
BuscaCotacoes/Application.py
|
vitimdt/TraderExpert
|
942efb1f726c6f74e2a3c8d4099db30d72e8474e
|
[
"Apache-2.0"
] | 1
|
2022-02-07T14:21:53.000Z
|
2022-02-07T14:21:53.000Z
|
from BuscaCotacoes import BuscaCotacoes
app = BuscaCotacoes()
app.iniciarColetaCotacoes()
| 22.5
| 39
| 0.844444
| 8
| 90
| 9.5
| 0.625
| 0.421053
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.088889
| 90
| 4
| 40
| 22.5
| 0.926829
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
f195ba9be0e1c86249a956bbd52733bb57c67aea
| 195
|
py
|
Python
|
codenode/cpp/nodes/block.py
|
0xf0f/codenode
|
fa36ba5e2eeb42e95c8fc33afd4f1bf131ba6d9b
|
[
"MIT"
] | 3
|
2019-06-27T04:57:37.000Z
|
2019-06-27T11:29:33.000Z
|
codenode/cpp/nodes/block.py
|
0xf0f/codenode
|
fa36ba5e2eeb42e95c8fc33afd4f1bf131ba6d9b
|
[
"MIT"
] | null | null | null |
codenode/cpp/nodes/block.py
|
0xf0f/codenode
|
fa36ba5e2eeb42e95c8fc33afd4f1bf131ba6d9b
|
[
"MIT"
] | null | null | null |
from codenode.base import CodeNode
class Block(CodeNode):
def header(self):
yield '{'
def body(self):
yield from self.children
def footer(self):
yield '}'
| 15
| 34
| 0.594872
| 23
| 195
| 5.043478
| 0.565217
| 0.232759
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.302564
| 195
| 12
| 35
| 16.25
| 0.852941
| 0
| 0
| 0
| 0
| 0
| 0.010256
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.375
| false
| 0
| 0.125
| 0
| 0.625
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
f1ab06cd976c11ed4046370ca53ef4f12bf65598
| 48
|
py
|
Python
|
model.py
|
sers-cy/blaxcy
|
f74fd69c06d75a598f8ecce33c32ca0b2816c823
|
[
"Apache-2.0"
] | null | null | null |
model.py
|
sers-cy/blaxcy
|
f74fd69c06d75a598f8ecce33c32ca0b2816c823
|
[
"Apache-2.0"
] | null | null | null |
model.py
|
sers-cy/blaxcy
|
f74fd69c06d75a598f8ecce33c32ca0b2816c823
|
[
"Apache-2.0"
] | null | null | null |
'''
Created on Oct 3, 2015
@author: bcy-3
'''
| 6.857143
| 22
| 0.5625
| 8
| 48
| 3.375
| 0.875
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.162162
| 0.229167
| 48
| 6
| 23
| 8
| 0.567568
| 0.791667
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
f1c3b125e65b2936cf448584e953c64c43c3557d
| 759
|
py
|
Python
|
django_proyects/proyecto1/sap/personas/models.py
|
JuanDuran85/ejemplos_python
|
47aa49c65384ab89654f362f3da6cd2b0ef386e5
|
[
"Apache-2.0"
] | null | null | null |
django_proyects/proyecto1/sap/personas/models.py
|
JuanDuran85/ejemplos_python
|
47aa49c65384ab89654f362f3da6cd2b0ef386e5
|
[
"Apache-2.0"
] | null | null | null |
django_proyects/proyecto1/sap/personas/models.py
|
JuanDuran85/ejemplos_python
|
47aa49c65384ab89654f362f3da6cd2b0ef386e5
|
[
"Apache-2.0"
] | null | null | null |
from django.db import models
# Create your models here.
class Domicilio(models.Model):
calle = models.CharField(max_length=50)
numero = models.IntegerField()
ciudad = models.CharField(max_length=50)
pais = models.CharField(max_length=50)
def __str__(self):
return f'{self.id}-{self.calle} {self.numero} {self.pais}'
class Persona(models.Model):
nombre = models.CharField(max_length=50)
apellido = models.CharField(max_length=50)
edad = models.IntegerField()
telefono = models.CharField(max_length=12)
email = models.EmailField(max_length=254)
domicilio = models.ForeignKey(Domicilio, on_delete=models.SET_NULL, null=True)
def __str__(self):
return f'{self.id}-{self.nombre} {self.apellido}'
| 33
| 82
| 0.710145
| 100
| 759
| 5.22
| 0.41
| 0.12069
| 0.206897
| 0.275862
| 0.35249
| 0.103448
| 0.103448
| 0.103448
| 0
| 0
| 0
| 0.023622
| 0.163373
| 759
| 23
| 83
| 33
| 0.798425
| 0.031621
| 0
| 0.117647
| 0
| 0
| 0.118529
| 0.061308
| 0
| 0
| 0
| 0
| 0
| 1
| 0.117647
| false
| 0
| 0.058824
| 0.117647
| 1
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
7b075b0059651433f0f15cf456c5036b91957e78
| 38
|
py
|
Python
|
Python/Books/Learning-Programming-with-Python.Tamim-Shahriar-Subeen/chapter-006/ph-6.16-list-with-maltiple-range.py
|
shihab4t/Books-Code
|
b637b6b2ad42e11faf87d29047311160fe3b2490
|
[
"Unlicense"
] | null | null | null |
Python/Books/Learning-Programming-with-Python.Tamim-Shahriar-Subeen/chapter-006/ph-6.16-list-with-maltiple-range.py
|
shihab4t/Books-Code
|
b637b6b2ad42e11faf87d29047311160fe3b2490
|
[
"Unlicense"
] | null | null | null |
Python/Books/Learning-Programming-with-Python.Tamim-Shahriar-Subeen/chapter-006/ph-6.16-list-with-maltiple-range.py
|
shihab4t/Books-Code
|
b637b6b2ad42e11faf87d29047311160fe3b2490
|
[
"Unlicense"
] | null | null | null |
li = list(range(2, 21, 2))
print(li)
| 9.5
| 26
| 0.578947
| 8
| 38
| 2.75
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.129032
| 0.184211
| 38
| 3
| 27
| 12.666667
| 0.580645
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.5
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
7b1caf4700618a351c711ff5944ae15fe18bc80f
| 1,499
|
py
|
Python
|
OpenGLCffi/GL/EXT/ARB/texture_compression.py
|
cydenix/OpenGLCffi
|
c78f51ae5e6b655eb2ea98f072771cf69e2197f3
|
[
"MIT"
] | null | null | null |
OpenGLCffi/GL/EXT/ARB/texture_compression.py
|
cydenix/OpenGLCffi
|
c78f51ae5e6b655eb2ea98f072771cf69e2197f3
|
[
"MIT"
] | null | null | null |
OpenGLCffi/GL/EXT/ARB/texture_compression.py
|
cydenix/OpenGLCffi
|
c78f51ae5e6b655eb2ea98f072771cf69e2197f3
|
[
"MIT"
] | null | null | null |
from OpenGLCffi.GL import params
@params(api='gl', prms=['target', 'level', 'internalformat', 'width', 'height', 'depth', 'border', 'imageSize', 'data'])
def glCompressedTexImage3DARB(target, level, internalformat, width, height, depth, border, imageSize, data):
pass
@params(api='gl', prms=['target', 'level', 'internalformat', 'width', 'height', 'border', 'imageSize', 'data'])
def glCompressedTexImage2DARB(target, level, internalformat, width, height, border, imageSize, data):
pass
@params(api='gl', prms=['target', 'level', 'internalformat', 'width', 'border', 'imageSize', 'data'])
def glCompressedTexImage1DARB(target, level, internalformat, width, border, imageSize, data):
pass
@params(api='gl', prms=['target', 'level', 'xoffset', 'yoffset', 'zoffset', 'width', 'height', 'depth', 'format', 'imageSize', 'data'])
def glCompressedTexSubImage3DARB(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data):
pass
@params(api='gl', prms=['target', 'level', 'xoffset', 'yoffset', 'width', 'height', 'format', 'imageSize', 'data'])
def glCompressedTexSubImage2DARB(target, level, xoffset, yoffset, width, height, format, imageSize, data):
pass
@params(api='gl', prms=['target', 'level', 'xoffset', 'width', 'format', 'imageSize', 'data'])
def glCompressedTexSubImage1DARB(target, level, xoffset, width, format, imageSize, data):
pass
@params(api='gl', prms=['target', 'level', 'img'])
def glGetCompressedTexImageARB(target, level, img):
pass
| 40.513514
| 135
| 0.701134
| 162
| 1,499
| 6.487654
| 0.185185
| 0.146527
| 0.073264
| 0.099905
| 0.757374
| 0.757374
| 0.757374
| 0.666032
| 0.613701
| 0.434824
| 0
| 0.004461
| 0.102735
| 1,499
| 36
| 136
| 41.638889
| 0.776952
| 0
| 0
| 0.318182
| 0
| 0
| 0.237809
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.318182
| false
| 0.318182
| 0.045455
| 0
| 0.363636
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
9e299d5027da7202be47cc78304585719ee4a5d0
| 167
|
py
|
Python
|
Techfest 2021/Buying Items.py
|
AkashSCIENTIST/CompetitiveSolutions
|
236db303a21c7195ebf721394a54ce9df70782f5
|
[
"Apache-2.0"
] | null | null | null |
Techfest 2021/Buying Items.py
|
AkashSCIENTIST/CompetitiveSolutions
|
236db303a21c7195ebf721394a54ce9df70782f5
|
[
"Apache-2.0"
] | null | null | null |
Techfest 2021/Buying Items.py
|
AkashSCIENTIST/CompetitiveSolutions
|
236db303a21c7195ebf721394a54ce9df70782f5
|
[
"Apache-2.0"
] | null | null | null |
from itertools import combinations as c
def totalWays(n, k):
# Write your code here.
arr = tuple(range(n))
arr2 = tuple(c(arr, k))
return len(arr2)+1
| 20.875
| 39
| 0.640719
| 27
| 167
| 3.962963
| 0.777778
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.023622
| 0.239521
| 167
| 7
| 40
| 23.857143
| 0.818898
| 0.125749
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.142857
| 0
| 1
| 0.2
| false
| 0
| 0.2
| 0
| 0.6
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
9e30ef5361dc1738837c166fb0f62dee3e70e3c7
| 177
|
py
|
Python
|
game/assets/powerups/powerup.py
|
Hagesjo/bomberman-server
|
fcc5fa7576227e0470bd18875de65784fd618bb6
|
[
"MIT"
] | 1
|
2017-12-22T08:01:52.000Z
|
2017-12-22T08:01:52.000Z
|
game/assets/powerups/powerup.py
|
Hagesjo/bomberman-server
|
fcc5fa7576227e0470bd18875de65784fd618bb6
|
[
"MIT"
] | 7
|
2016-12-30T23:58:52.000Z
|
2017-12-17T14:13:59.000Z
|
game/assets/powerups/powerup.py
|
Hagesjo/bomberman-server
|
fcc5fa7576227e0470bd18875de65784fd618bb6
|
[
"MIT"
] | 1
|
2018-06-06T03:34:57.000Z
|
2018-06-06T03:34:57.000Z
|
class Powerup:
def __init__(self, coord):
self.coord = coord
def use(self, player):
raise NotImplementedError
def ascii(self):
return "P"
| 16.090909
| 33
| 0.59322
| 20
| 177
| 5.05
| 0.65
| 0.178218
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.316384
| 177
| 10
| 34
| 17.7
| 0.834711
| 0
| 0
| 0
| 0
| 0
| 0.005682
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.428571
| false
| 0
| 0
| 0.142857
| 0.714286
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
9e5b94fb704df9e5961343c9543feaa0c84e3df2
| 238
|
py
|
Python
|
note31/sentence_v3.py
|
icexmoon/python-learning-notes
|
838c91d896404290b89992b6517be1b6a79df41f
|
[
"MIT"
] | null | null | null |
note31/sentence_v3.py
|
icexmoon/python-learning-notes
|
838c91d896404290b89992b6517be1b6a79df41f
|
[
"MIT"
] | null | null | null |
note31/sentence_v3.py
|
icexmoon/python-learning-notes
|
838c91d896404290b89992b6517be1b6a79df41f
|
[
"MIT"
] | null | null | null |
import re
class SentenceV3():
RE_WORD = re.compile('\w+')
def __init__(self, text) -> None:
self.text = text
self.words = SentenceV3.RE_WORD.findall(text)
def __iter__(self):
return iter(self.words)
| 19.833333
| 53
| 0.613445
| 31
| 238
| 4.387097
| 0.516129
| 0.176471
| 0.235294
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.011299
| 0.256303
| 238
| 12
| 54
| 19.833333
| 0.757062
| 0
| 0
| 0
| 0
| 0
| 0.012552
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.125
| 0.125
| 0.75
| 0
| 0
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
7b4c71dbe02787bfa41a9c7d6567206ca3dfdd6f
| 400
|
py
|
Python
|
tcontrol/__init__.py
|
DaivdZhang/tinyControl
|
4842ba473002f876790c637001e77b90ec566eb7
|
[
"BSD-3-Clause"
] | 1
|
2018-07-18T14:48:04.000Z
|
2018-07-18T14:48:04.000Z
|
tcontrol/__init__.py
|
DaivdZhang/TinyControl
|
4842ba473002f876790c637001e77b90ec566eb7
|
[
"BSD-3-Clause"
] | 2
|
2017-08-31T08:31:46.000Z
|
2017-10-03T07:01:39.000Z
|
tcontrol/__init__.py
|
akizunx/TinyControl
|
4842ba473002f876790c637001e77b90ec566eb7
|
[
"BSD-3-Clause"
] | 2
|
2017-05-28T08:58:28.000Z
|
2018-01-24T02:48:49.000Z
|
from .lti import *
from .poly import *
from .pzmap import *
from .transferfunction import *
from .time_response import *
from .rlocus import *
from .frequency import *
from . import plot_utility as plot
from .statespace import *
from .exception import *
from .discretization import *
from .model_conversion import *
from .lyapunov import *
from .tcconfig import config as tcconfig
from .fsf import *
| 25
| 40
| 0.77
| 53
| 400
| 5.754717
| 0.415094
| 0.393443
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.16
| 400
| 15
| 41
| 26.666667
| 0.907738
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
7b6607a05969dfab9a44e700a18c24e53c6919ed
| 66
|
py
|
Python
|
dimedb/app/config.py
|
KeironO/DIMEdb
|
e47b13ab17a128e7136d9e342533c4e1d5021b67
|
[
"MIT"
] | 1
|
2019-05-22T04:50:18.000Z
|
2019-05-22T04:50:18.000Z
|
dimedb/app/config.py
|
KeironO/DIMEdb
|
e47b13ab17a128e7136d9e342533c4e1d5021b67
|
[
"MIT"
] | 2
|
2017-11-20T16:17:57.000Z
|
2017-11-20T16:23:35.000Z
|
dimedb/app/config.py
|
KeironO/DIMEdb
|
e47b13ab17a128e7136d9e342533c4e1d5021b67
|
[
"MIT"
] | null | null | null |
import os, csv
class BaseConfig(object):
MAINTENANCE = False
| 13.2
| 25
| 0.727273
| 8
| 66
| 6
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.19697
| 66
| 4
| 26
| 16.5
| 0.90566
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
7b820b6a5ecffe3cd11fce5b9bc7b23d3e1eee65
| 875
|
py
|
Python
|
crescent/resources/api_gateway_v2/api/cors.py
|
mpolatcan/zepyhrus
|
2fd0b1b9b21613b5876a51fe8b5f9e3afbec1b67
|
[
"Apache-2.0"
] | 1
|
2020-03-26T19:20:03.000Z
|
2020-03-26T19:20:03.000Z
|
crescent/resources/api_gateway_v2/api/cors.py
|
mpolatcan/zepyhrus
|
2fd0b1b9b21613b5876a51fe8b5f9e3afbec1b67
|
[
"Apache-2.0"
] | null | null | null |
crescent/resources/api_gateway_v2/api/cors.py
|
mpolatcan/zepyhrus
|
2fd0b1b9b21613b5876a51fe8b5f9e3afbec1b67
|
[
"Apache-2.0"
] | null | null | null |
from crescent.core import Model
class Cors(Model):
def __int__(self):
super(Cors, self).__init__()
def AllowCredentials(self, allow_credentials: bool):
return self._set_field(self.AllowCredentials.__name__, allow_credentials)
def AllowHeaders(self, *allow_headers: str):
return self._set_field(self.AllowHeaders.__name__, list(allow_headers))
def AllowMethods(self, *allow_methods: str):
return self._set_field(self.AllowMethods.__name__, list(allow_methods))
def AllowOrigins(self, *allow_origins: str):
return self._set_field(self.AllowOrigins.__name__, list(allow_origins))
def ExposeHeaders(self, *expose_headers: str):
return self._set_field(self.ExposeHeaders.__name__, list(expose_headers))
def MaxAge(self, max_age: int):
return self._set_field(self.MaxAge.__name__, max_age)
| 36.458333
| 81
| 0.732571
| 109
| 875
| 5.366972
| 0.302752
| 0.102564
| 0.133333
| 0.184615
| 0.270085
| 0.194872
| 0.109402
| 0
| 0
| 0
| 0
| 0
| 0.163429
| 875
| 24
| 82
| 36.458333
| 0.79918
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.4375
| false
| 0
| 0.0625
| 0.375
| 0.9375
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
7bb467f4b48ad6c0f25d738a305372a27ff22d15
| 191
|
py
|
Python
|
generate_secret_key.py
|
LuisHenrique01/music-api
|
fb71c918625e61ae6ace3c14784ea1281287580f
|
[
"MIT"
] | 1
|
2021-02-02T03:58:48.000Z
|
2021-02-02T03:58:48.000Z
|
generate_secret_key.py
|
LuisHenrique01/music-api
|
fb71c918625e61ae6ace3c14784ea1281287580f
|
[
"MIT"
] | null | null | null |
generate_secret_key.py
|
LuisHenrique01/music-api
|
fb71c918625e61ae6ace3c14784ea1281287580f
|
[
"MIT"
] | null | null | null |
from django.core.management.utils import get_random_secret_key
secret_key = get_random_secret_key()
with open('.env', 'w+') as arq:
dados = 'SECRET_KEY=%s'%secret_key
arq.write(dados)
| 38.2
| 62
| 0.748691
| 31
| 191
| 4.322581
| 0.612903
| 0.335821
| 0.223881
| 0.268657
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.120419
| 191
| 5
| 63
| 38.2
| 0.797619
| 0
| 0
| 0
| 0
| 0
| 0.098958
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.2
| 0
| 0.2
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
c897bed43c483a447b8b037401fa9c22142d3776
| 1,010
|
py
|
Python
|
python-data-analysis/pandas-demo/GroupByDemo.py
|
meteor1993/python-learning
|
4ee574c9360caf6e63bb6ee2ef31fa6a9918fa40
|
[
"MIT"
] | 83
|
2019-10-15T06:54:06.000Z
|
2022-03-28T14:08:21.000Z
|
python-data-analysis/pandas-demo/GroupByDemo.py
|
wenxuefeng3930/python-learning
|
4ee574c9360caf6e63bb6ee2ef31fa6a9918fa40
|
[
"MIT"
] | 1
|
2020-04-16T08:13:19.000Z
|
2020-07-14T01:52:46.000Z
|
python-data-analysis/pandas-demo/GroupByDemo.py
|
wenxuefeng3930/python-learning
|
4ee574c9360caf6e63bb6ee2ef31fa6a9918fa40
|
[
"MIT"
] | 74
|
2019-11-02T08:10:36.000Z
|
2022-02-19T12:23:36.000Z
|
import pandas as pd
# 数据导入
epidemic_dxy = pd.read_excel("epidemic_dxy.xlsx")
print(epidemic_dxy.groupby(['continents']))
print(epidemic_dxy.groupby(['continents']).count())
# pd.set_option('display.max_columns', None)
print(epidemic_dxy.groupby(['continents']).sum())
print(epidemic_dxy.groupby(['continents'])['confirmedCount', 'suspectedCount', 'curedCount', 'deadCount'].sum())
print(epidemic_dxy.groupby(epidemic_dxy['continents'])['confirmedCount', 'suspectedCount', 'curedCount', 'deadCount'].sum())
print(epidemic_dxy.groupby([epidemic_dxy['continents'], epidemic_dxy['provinceName']])['confirmedCount', 'suspectedCount', 'curedCount', 'deadCount'].sum())
print(epidemic_dxy.groupby(epidemic_dxy['continents'])['confirmedCount', 'suspectedCount', 'curedCount', 'deadCount'].aggregate(['count', 'sum']))
new_dataframe = epidemic_dxy.groupby(epidemic_dxy['continents'])['confirmedCount', 'suspectedCount', 'curedCount', 'deadCount'].sum().reset_index()
print(new_dataframe)
| 43.913043
| 157
| 0.739604
| 106
| 1,010
| 6.849057
| 0.292453
| 0.227273
| 0.198347
| 0.221763
| 0.761708
| 0.589532
| 0.589532
| 0.589532
| 0.589532
| 0.589532
| 0
| 0
| 0.070297
| 1,010
| 23
| 158
| 43.913043
| 0.773163
| 0.046535
| 0
| 0
| 0
| 0
| 0.374867
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.090909
| 0
| 0.090909
| 0.727273
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
c8f403f78fab18f7b4e8c946a89b14371a2e6d40
| 249
|
py
|
Python
|
aiomessaging/__init__.py
|
aiomessaging/aiomessaging
|
0fe2296d5a772a9b28c3173259e7a6ace6e45624
|
[
"MIT"
] | 4
|
2018-07-08T18:49:10.000Z
|
2018-08-16T20:17:29.000Z
|
aiomessaging/__init__.py
|
aiomessaging/aiomessaging
|
0fe2296d5a772a9b28c3173259e7a6ace6e45624
|
[
"MIT"
] | 23
|
2018-07-08T18:52:42.000Z
|
2018-10-25T16:58:50.000Z
|
aiomessaging/__init__.py
|
aiomessaging/aiomessaging
|
0fe2296d5a772a9b28c3173259e7a6ace6e45624
|
[
"MIT"
] | null | null | null |
"""aiomessaging.
"""
from .app import AiomessagingApp
from .queues import QueueBackend
from .event import Event
from .message import Message, Route, Effect
__all__ = [
'QueueBackend', 'AiomessagingApp', 'Event', 'Message', 'Route', 'Effect'
]
| 20.75
| 76
| 0.722892
| 26
| 249
| 6.769231
| 0.461538
| 0.136364
| 0.204545
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.144578
| 249
| 11
| 77
| 22.636364
| 0.826291
| 0.052209
| 0
| 0
| 0
| 0
| 0.218341
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.571429
| 0
| 0.571429
| 0
| 1
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
cdb812f27a5354b16006221c0b0db90eabca92c5
| 6,390
|
py
|
Python
|
tests/test_rotations.py
|
MarceloJacinto/dsorlib
|
5208919579726b73f088605885f6e1f0bf17d297
|
[
"MIT"
] | null | null | null |
tests/test_rotations.py
|
MarceloJacinto/dsorlib
|
5208919579726b73f088605885f6e1f0bf17d297
|
[
"MIT"
] | null | null | null |
tests/test_rotations.py
|
MarceloJacinto/dsorlib
|
5208919579726b73f088605885f6e1f0bf17d297
|
[
"MIT"
] | null | null | null |
from numpy import array
from numpy.testing import assert_allclose
from dsorlib.rotations import Rot_to_quaternion, RPY_to_quaternion, quaternion_to_Rot, quaternion_to_RPY, RPY_to_RotZYX, \
RotZYX_to_RPY
"""
The following tests are conducted for the rotations module
The following URL was used to obtained the standard values to compare against
https://www.andre-gaschler.com/rotationconverter/
"""
def test1_Rot_to_quaternion():
"""
Test1 the method Rot_to_quaternion
"""
r = array([[-0.0690026, -0.9716355, 0.2261928],
[0.6932812, 0.1163334, 0.7112156],
[-0.7173561, 0.2058909, 0.6655893]])
q_obtained = Rot_to_quaternion(r)
q_expected = array([0.65439287, -0.19305097, 0.36046729, 0.63605396])
assert_allclose(q_obtained, q_expected, rtol=2e-07, verbose=True)
def test2_Rot_to_quaternion():
"""
Test2 the method Rot_to_quaternion
"""
r2 = array([[0.0516208, 0.0057865, 0.9986500],
[-0.2212602, 0.9751976, 0.0057865],
[-0.9738476, -0.2212602, 0.0516208]])
q2_obtained = Rot_to_quaternion(r2)
q2_expected = array([0.7208397, -0.0787438, 0.6840972, -0.0787438])
assert_allclose(q2_obtained, q2_expected, rtol=4e-07, verbose=True)
def test1_RPY_to_quaternion():
"""
Test1 the method RPY_to_quaternion
"""
roll: float = 0.3
pitch: float = 0.8
yaw: float = 1.67
q_obtained = RPY_to_quaternion(roll, pitch, yaw)
q_expected = array([0.65439287, -0.19305097, 0.36046729, 0.63605396])
assert_allclose(q_obtained, q_expected, rtol=2e-07, verbose=True)
def test2_RPY_to_quaternion():
"""
Test2 the method RPY_to_quaternion
"""
roll: float = 1.8
pitch: float = 1.8
yaw: float = 1.8
q_obtained = RPY_to_quaternion(roll, pitch, yaw)
q_expected = array([0.7208397, -0.0787438, 0.6840972, -0.0787438])
assert_allclose(q_obtained, q_expected, rtol=4e-07, verbose=True)
def test1_quaternion_to_Rot():
"""
Test1 the method quaternion_to_Rot
"""
q = array([0.65439287, -0.19305097, 0.36046729, 0.63605396])
rot_obtained = quaternion_to_Rot(q)
rot_expected = array([[-0.0690026, -0.9716355, 0.2261928],
[ 0.6932812, 0.1163334, 0.7112156],
[-0.7173561, 0.2058909, 0.6655893]])
assert_allclose(rot_obtained, rot_expected, rtol=2e-07, verbose=True)
def test2_quaternion_to_Rot():
"""
Test2 the method quaternion_to_Rot
"""
q = array([0.7208397, -0.0787438, 0.6840972, -0.0787438])
rot_obtained = quaternion_to_Rot(q)
rot_expected = array([[0.0516208, 0.0057865, 0.9986500],
[-0.2212602, 0.9751976, 0.0057865],
[-0.9738476, -0.2212602, 0.0516208]])
assert_allclose(rot_obtained, rot_expected, rtol=3e-06, verbose=True)
def test1_quaternion_to_RPY():
"""
Test1 the method quaternion_to_RPY
"""
q = array([0.65439287, -0.19305097, 0.36046729, 0.63605396])
roll_obtained, pitch_obtained, yaw_obtained = quaternion_to_RPY(q)
RPY_obtained = array([roll_obtained, pitch_obtained, yaw_obtained])
RPY_expected = array([0.3, 0.8, 1.67])
assert_allclose(RPY_obtained, RPY_expected, rtol=2e-07, verbose=True)
def test2_quaternion_to_RPY():
"""
Test2 the method quaternion_to_RPY
"""
q = array([0.7208397, -0.0787438, 0.6840972, -0.0787438])
roll_obtained, pitch_obtained, yaw_obtained = quaternion_to_RPY(q)
RPY_obtained = array([roll_obtained, pitch_obtained, yaw_obtained])
RPY_expected = array([-1.341592, 1.341593, -1.341592])
assert_allclose(RPY_obtained, RPY_expected, rtol=2e-07, verbose=True)
def test1_RPY_to_RotZYX():
"""
Test1 the method RPY_to_RotZYX
"""
roll: float = 0.3
pitch: float = 0.8
yaw: float = 1.67
rot_obtained = RPY_to_RotZYX(roll, pitch, yaw)
rot_expected = array([[-0.0690026, -0.9716355, 0.2261928],
[0.6932812, 0.1163334, 0.7112156],
[-0.7173561, 0.2058909, 0.6655893]])
assert_allclose(rot_obtained, rot_expected, rtol=7e-07, verbose=True)
def test2_RPY_to_RotZYX():
"""
Test2 the method RPY_to_RotZYX
"""
roll: float = 1.8
pitch: float = 1.8
yaw: float = 1.8
rot_obtained = RPY_to_RotZYX(roll, pitch, yaw)
rot_expected = array([[0.0516208, 0.0057865, 0.9986500],
[-0.2212602, 0.9751976, 0.0057865],
[-0.9738476, -0.2212602, 0.0516208]])
assert_allclose(rot_obtained, rot_expected, rtol=4e-06, verbose=True)
def test1_RotZYX_to_RPY():
"""
Test1 the method RotZYX_to_RPY
"""
r = array([[-0.0690026, -0.9716355, 0.2261928],
[0.6932812, 0.1163334, 0.7112156],
[-0.7173561, 0.2058909, 0.6655893]])
roll_obtained, pitch_obtained, yaw_obtained = RotZYX_to_RPY(r)
RPY_obtained = array([roll_obtained, pitch_obtained, yaw_obtained])
RPY_expected = array([0.3, 0.8, 1.67])
assert_allclose(RPY_obtained, RPY_expected, rtol=3e-07, verbose=True)
def test2_RotZYX_to_RPY():
"""
Test2 the method RotZYX_to_RPY
"""
r = array([[0.0516208, 0.0057865, 0.9986500],
[-0.2212602, 0.9751976, 0.0057865],
[-0.9738476, -0.2212602, 0.0516208]])
roll_obtained, pitch_obtained, yaw_obtained = RotZYX_to_RPY(r)
RPY_obtained = array([roll_obtained, pitch_obtained, yaw_obtained])
RPY_expected = array([-1.341593, 1.341593, -1.341593])
assert_allclose(RPY_obtained, RPY_expected, rtol=4e-07, verbose=True)
def main():
# Test the conversion from rotation matrix to quaternion
test1_Rot_to_quaternion()
test2_Rot_to_quaternion()
# Test the conversion from euler angles to quaternion
test1_RPY_to_quaternion()
test2_RPY_to_quaternion()
# Test the conversion from quaternion to rotation matrix
test1_quaternion_to_Rot()
test2_quaternion_to_Rot()
# Test the conversion from quaternion to euler angles
test1_quaternion_to_RPY()
test2_quaternion_to_RPY()
# Test the conversion from euler angles to rotation matrix
test1_RPY_to_RotZYX()
test2_RPY_to_RotZYX()
# Test the conversion from rotation matrix to euler angles
test1_RotZYX_to_RPY()
test2_RotZYX_to_RPY()
if __name__ == "__main__":
main()
| 32.602041
| 122
| 0.662285
| 892
| 6,390
| 4.492152
| 0.106502
| 0.059895
| 0.041927
| 0.03993
| 0.808335
| 0.755428
| 0.722236
| 0.636386
| 0.584727
| 0.584727
| 0
| 0.201037
| 0.215336
| 6,390
| 195
| 123
| 32.769231
| 0.598125
| 0.114554
| 0
| 0.560748
| 0
| 0
| 0.001516
| 0
| 0
| 0
| 0
| 0
| 0.121495
| 1
| 0.121495
| false
| 0
| 0.028037
| 0
| 0.149533
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
b51f00c284c634b91ba48c16b6b38a19669ca60e
| 101
|
py
|
Python
|
redback/get_data/fermi.py
|
nikhil-sarin/redback
|
b0023b770a3c0a25a18c4f6ff1a07339be7f83fe
|
[
"MIT"
] | 2
|
2022-03-11T10:03:33.000Z
|
2022-03-11T10:51:54.000Z
|
redback/get_data/fermi.py
|
nikhil-sarin/redback
|
b0023b770a3c0a25a18c4f6ff1a07339be7f83fe
|
[
"MIT"
] | 5
|
2022-03-03T07:59:13.000Z
|
2022-03-03T08:01:32.000Z
|
redback/get_data/fermi.py
|
nikhil-sarin/redback
|
b0023b770a3c0a25a18c4f6ff1a07339be7f83fe
|
[
"MIT"
] | 1
|
2022-03-31T12:24:59.000Z
|
2022-03-31T12:24:59.000Z
|
class FermiDataGetter(object):
def __init__(self) -> None:
raise NotImplementedError()
| 16.833333
| 35
| 0.683168
| 9
| 101
| 7.222222
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.217822
| 101
| 5
| 36
| 20.2
| 0.822785
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
b53a2ab2c21bccdba68dc75f1d5583942ad27dfc
| 163
|
py
|
Python
|
reddit2telegram/channels/r_talesfromtechsupport/app.py
|
mainyordle/reddit2telegram
|
1163e15aed3b6ff0fba65b222d3d9798f644c386
|
[
"MIT"
] | 187
|
2016-09-20T09:15:54.000Z
|
2022-03-29T12:22:33.000Z
|
reddit2telegram/channels/r_talesfromtechsupport/app.py
|
mainyordle/reddit2telegram
|
1163e15aed3b6ff0fba65b222d3d9798f644c386
|
[
"MIT"
] | 84
|
2016-09-22T14:25:07.000Z
|
2022-03-19T01:26:17.000Z
|
reddit2telegram/channels/r_talesfromtechsupport/app.py
|
mainyordle/reddit2telegram
|
1163e15aed3b6ff0fba65b222d3d9798f644c386
|
[
"MIT"
] | 172
|
2016-09-21T15:39:39.000Z
|
2022-03-16T15:15:58.000Z
|
#encoding:utf-8
subreddit = 'talesfromtechsupport'
t_channel = '@r_talesfromtechsupport'
def send_post(submission, r2t):
return r2t.send_simple(submission)
| 18.111111
| 38
| 0.779141
| 19
| 163
| 6.473684
| 0.789474
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.020833
| 0.116564
| 163
| 8
| 39
| 20.375
| 0.833333
| 0.08589
| 0
| 0
| 0
| 0
| 0.290541
| 0.155405
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0
| 0.25
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
|
0
| 4
|
b5484cbd61a58520cca92569eb7a4e4542841514
| 163
|
py
|
Python
|
SoftGeek/SoftWord/apps.py
|
enockhamuli15/SocialNetwork
|
88ca5f6908f16060df0eed6fb266f36822bad265
|
[
"MIT"
] | null | null | null |
SoftGeek/SoftWord/apps.py
|
enockhamuli15/SocialNetwork
|
88ca5f6908f16060df0eed6fb266f36822bad265
|
[
"MIT"
] | null | null | null |
SoftGeek/SoftWord/apps.py
|
enockhamuli15/SocialNetwork
|
88ca5f6908f16060df0eed6fb266f36822bad265
|
[
"MIT"
] | null | null | null |
from django.apps import AppConfig
class SoftwordConfig(AppConfig):
name = 'SoftWord'
"""def ready(self):
import SoftWord.signals"""
| 18.111111
| 34
| 0.625767
| 16
| 163
| 6.375
| 0.8125
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.269939
| 163
| 9
| 35
| 18.111111
| 0.857143
| 0
| 0
| 0
| 0
| 0
| 0.072727
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
b5808dc48fa1227a099c3a726570b31bb3bc3711
| 169,063
|
py
|
Python
|
liberator/libreapi.py
|
geejay101/libresbc
|
7e0efee56f897452d1b783a84a743137df7993f9
|
[
"MIT"
] | null | null | null |
liberator/libreapi.py
|
geejay101/libresbc
|
7e0efee56f897452d1b783a84a743137df7993f9
|
[
"MIT"
] | null | null | null |
liberator/libreapi.py
|
geejay101/libresbc
|
7e0efee56f897452d1b783a84a743137df7993f9
|
[
"MIT"
] | null | null | null |
#
# liberator:libreapi.py
#
# The Initial Developer of the Original Code is
# Minh Minh <hnimminh at[@] outlook dot[.] com>
# Portions created by the Initial Developer are Copyright (C) the Initial Developer.
# All Rights Reserved.
#
import traceback
import re
import json
import hashlib
import redis
import validators
from pydantic import BaseModel, Field, validator, root_validator, schema
from pydantic.fields import ModelField
from typing import Optional, List, Dict, Union, Any
from enum import Enum
from ipaddress import IPv4Address, IPv4Network
from fastapi import APIRouter, Request, Response, Path
from fastapi.encoders import jsonable_encoder
from configuration import (_APPLICATION, _SWVERSION, _DESCRIPTION, CHANGE_CFG_CHANNEL, SECURITY_CHANNEL,
NODEID, SWCODECS, CLUSTERS, _BUILTIN_ACLS_,
REDIS_HOST, REDIS_PORT, REDIS_DB, REDIS_PASSWORD, SCAN_COUNT)
from utilities import logify, debugy, get_request_uuid, int2bool, bool2int, redishash, jsonhash, fieldjsonify, fieldredisify, listify, stringify, getaname, removekey
from basemgr import fssocket
REDIS_CONNECTION_POOL = redis.BlockingConnectionPool(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB, password=REDIS_PASSWORD,
decode_responses=True, max_connections=10, timeout=5)
rdbconn = redis.StrictRedis(connection_pool=REDIS_CONNECTION_POOL)
# API ROUTER DECLARATION
librerouter = APIRouter()
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# PYDANTIC SCHEME HIDE FIELD
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
def field_schema(field: ModelField, **kwargs: Any) -> Any:
if field.field_info.extra.get("hidden_field", False):
raise schema.SkipField(f"{field.name} field is being hidden with fastapi/issues/1378")
else:
return original_field_schema(field, **kwargs)
original_field_schema = schema.field_schema
schema.field_schema = field_schema
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# CONSTANTS
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# PATTERN
_NAME_ = r'^[a-zA-Z][a-zA-Z0-9_]+$'
_SRNAME_ = r'^_[a-zA-Z0-9_]+$'
_REALM_ = r'^[a-z][a-z0-9_\-\.]+$'
_DIAL_ = r'^[a-zA-Z0-9_\-+#*@]*$'
# ROUTING
_QUERY = 'query'
_BLOCK = 'block'
_JUMPS = 'jumps'
_ROUTE = 'route'
# reserved for value empty string
__DEFAULT_ENTRY__ = '__DEFAULT_ENTRY__'
__EMPTY_STRING__ = ''
__COLON__ = ':'
__COMMA__ = ','
__SEMICOLON__ = ';'
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# INITIALIZE
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
try:
rdbconn.sadd('cluster:candidates', NODEID)
_clustername = rdbconn.get('cluster:name')
if _clustername: CLUSTERS['name'] = _clustername
_clustermembers = set(rdbconn.smembers('cluster:members'))
if _clustermembers: CLUSTERS['members'] = list(_clustermembers)
attributes = jsonhash(rdbconn.hgetall('cluster:attributes'))
_rtp_start_port = attributes.get('rtp_start_port')
if _rtp_start_port: CLUSTERS['rtp_start_port'] = _rtp_start_port
_rtp_end_port = attributes.get('rtp_end_port')
if _rtp_end_port: CLUSTERS['rtp_end_port'] = _rtp_end_port
_max_concurrent_calls = attributes.get('max_concurrent_calls')
if _max_concurrent_calls: CLUSTERS['max_concurrent_calls'] = _max_concurrent_calls
_max_calls_per_second = attributes.get('max_calls_per_second')
if _max_calls_per_second: CLUSTERS['max_calls_per_second'] = _max_calls_per_second
except Exception as e:
logify(f"module=liberator, space=libreapi, action=initiate, exception={e}, traceback={traceback.format_exc()}")
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# PREDEFINED INFORMATION
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
@librerouter.get("/libreapi/predefine", status_code=200)
def predefine():
return {
'application': _APPLICATION,
'swversion': _SWVERSION,
'description': _DESCRIPTION,
'nodeid': NODEID,
'candidates': rdbconn.smembers('cluster:candidates'),
#'cluster': CLUSTERS,
'codecs': SWCODECS,
}
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# CLUSTER & NODE
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
def check_member(members):
for member in members:
if not rdbconn.sismember('cluster:candidates', member):
raise ValueError('member is not in candidates')
return members
class ClusterModel(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='The name of libresbc cluster')
members: List[str] = Field(min_items=1, max_item=16, description='The member of libresbc cluster')
rtp_start_port: int = Field(default=10000, min=0, max=65535, description='start of rtp port range')
rtp_end_port: int = Field(default=60000, min=0, max=65535, description='start of rtp port range')
max_concurrent_calls: int = Field(default=6000, min=0, max=65535, description='maximun number of active (concurent) call that one cluster member can handle')
max_calls_per_second: int = Field(default=200, min=0, max=65535, description='maximun number of calls attempt in one second that one cluster member can handle')
# validation
_validmember = validator('members')(check_member)
@librerouter.put("/libreapi/cluster", status_code=200)
def update_cluster(reqbody: ClusterModel, response: Response):
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
members = set(reqbody.members)
rtp_start_port = reqbody.rtp_start_port
rtp_end_port = reqbody.rtp_end_port
max_concurrent_calls = reqbody.max_concurrent_calls
max_calls_per_second = reqbody.max_calls_per_second
_members = set(rdbconn.smembers('cluster:members'))
removed_members = _members - members
for removed_member in removed_members:
if rdbconn.scard(f'engagement:node:{removed_member}'):
response.status_code, result = 403, {'error': 'engaged node'}; return
pipe.set('cluster:name', name)
for member in members: pipe.sadd('cluster:members', member)
pipe.hmset('cluster:attributes', redishash({'rtp_start_port': rtp_start_port, 'rtp_end_port': rtp_end_port, 'max_concurrent_calls': max_concurrent_calls, 'max_calls_per_second': max_calls_per_second}))
pipe.execute()
CLUSTERS.update({
'name': name,
'members': list(members),
'rtp_start_port': rtp_start_port,
'rtp_end_port': rtp_end_port,
'max_concurrent_calls': max_concurrent_calls,
'max_calls_per_second': max_calls_per_second
})
# set cluster member to fsvar
fssocket({'commands': [f'global_setvar CLUSTERMEMBERS={stringify(members,__COMMA__)}'], 'requestid': get_request_uuid()})
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=change_cluster, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/cluster", status_code=200)
def get_cluster(response: Response):
result = None
try:
response.status_code, result = 200, CLUSTERS
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=get_cluster, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# NETWORK ALIAS
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
def netalias_agreement(addresses):
_addresses = jsonable_encoder(addresses)
if len(_addresses) != len(CLUSTERS.get('members')):
raise ValueError('The alias must be set for only/all cluster members')
for address in _addresses:
member = address['member']
if not rdbconn.sismember('cluster:candidates', member):
raise ValueError(f'{member} is invalid candidates')
return addresses
class IPSuite(BaseModel):
member: str = Field(regex=_NAME_, description='NodeID of member in cluster')
listen: IPv4Address = Field(description='the listen ip address')
advertise: IPv4Address = Field(description='the advertising ip address')
class NetworkAlias(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='name of network alias (identifier)')
desc: Optional[str] = Field(default='', max_length=64, description='description')
addresses: List[IPSuite] = Field(description='List of IP address suite for cluster members')
# validation
_validnetalias = validator('addresses')(netalias_agreement)
@librerouter.post("/libreapi/base/netalias", status_code=200)
def create_netalias(reqbody: NetworkAlias, response: Response):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
name_key = f'base:netalias:{name}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent network alias name'}; return
data = jsonable_encoder(reqbody)
pipe.hmset(name_key, redishash(data))
pipe.sadd(f'nameset:netalias', name)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_netalias, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/base/netalias/{identifier}", status_code=200)
def update_netalias(reqbody: NetworkAlias, response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
_name_key = f'base:netalias:{identifier}'
name_key = f'base:netalias:{name}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent network alias identifier'}; return
if name != identifier and rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent network alias name'}; return
data = jsonable_encoder(reqbody)
rdbconn.hmset(name_key, redishash(data))
# proactive get list who use this netalias
_engaged_key = f'engagement:{_name_key}'
engaged_key = f'engagement:{name_key}'
engagements = rdbconn.smembers(_engaged_key)
if name != identifier:
for engagement in engagements:
if rdbconn.hget(engagement, 'rtp_address') == identifier:
pipe.hset(engagement, 'rtp_address', name)
if rdbconn.hget(engagement, 'sip_address') == identifier:
pipe.hset(engagement, 'sip_address', name)
if rdbconn.exists(_engaged_key):
pipe.rename(_engaged_key, engaged_key)
pipe.delete(_name_key)
pipe.srem(f'nameset:netalias', identifier)
pipe.sadd(f'nameset:netalias', name)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event netalias change, process reload only if there is some-one use it
if engagements:
sipprofiles = [getaname(engagement) for engagement in engagements]
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'netalias', 'sipprofiles': sipprofiles, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_netalias, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/base/netalias/{identifier}", status_code=200)
def delete_netalias(response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
_name_key = f'base:netalias:{identifier}'
_engage_key = f'engagement:{_name_key}'
if rdbconn.scard(_engage_key):
response.status_code, result = 403, {'error': 'engaged network alias'}; return
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent network alias identifier'}; return
pipe.delete(_engage_key)
pipe.delete(_name_key)
pipe.srem(f'nameset:netalias', identifier)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# delete action perform only no one use it so no-one use mean no need reload as this not loaded to memory
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_acl, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/base/netalias/{identifier}", status_code=200)
def detail_netalias(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'base:netalias:{identifier}'
_engage_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent network alias identifier'}; return
result = jsonhash(rdbconn.hgetall(_name_key))
engagements = rdbconn.smembers(_engage_key)
result.update({'engagements': engagements})
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_netalias, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/base/netalias", status_code=200)
def list_netalias(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'base:netalias:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
pipe.hget(mainkey, 'desc')
descs = pipe.execute()
data = [{'name': getaname(mainkey), 'desc': desc} for mainkey, desc in zip(mainkeys, descs)]
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_netalias, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# SYSTEMWIDE FIREWALL IP WHITE/BLACK
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
@librerouter.patch("/libreapi/base/firewall/{nameset}", status_code=200)
def update_fwset(reqbody: List[IPv4Address], response: Response, nameset: str=Path(..., regex='^whiteset|blackset$')):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name_key = f'firewall:{nameset}'
ipaddrs = jsonable_encoder(reqbody)
_ipaddrs = rdbconn.smembers(name_key)
remlist = list(set(_ipaddrs) - set(ipaddrs))
addlist = list(set(ipaddrs) - set(_ipaddrs))
for ipaddr in remlist:
pipe.srem(name_key, ipaddr)
for ipaddr in addlist:
pipe.sadd(name_key, ipaddr)
pipe.execute()
if remlist: rdbconn.publish(SECURITY_CHANNEL, json.dumps({'portion': f'api:{nameset}', 'srcips': remlist, '_flag': True}))
if addlist: rdbconn.publish(SECURITY_CHANNEL, json.dumps({'portion': f'api:{nameset}', 'srcips': addlist}))
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_fwset, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/base/firewall", status_code=200)
def get_fwset(response: Response):
result = None
try:
whiteset = list(rdbconn.smembers('firewall:whiteset'))
blackset = list(rdbconn.smembers('firewall:blackset'))
result = {'whiteset': whiteset, 'blackset': blackset}
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=get_fwset, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ACL
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
class ACLActionEnum(str, Enum):
allow = 'allow'
deny = 'deny'
class ACLTypeEnum(str, Enum):
cidr = 'cidr'
domain = 'domain'
class ACLRuleModel(BaseModel):
action: ACLActionEnum = Field(default='allow', description='associate action for node')
key: ACLTypeEnum = Field(default='cidr', description='type of acl node: cidr, domain')
value: str = Field(description='acl rule value depend on type')
force: Optional[bool] = Field(description='set true if you need to add acl domain', hidden_field=True)
@root_validator()
def acl_rule_agreement(cls, rule):
key = rule.get('key')
value = rule.get('value')
if key=='cidr':
if not IPv4Network(value):
raise ValueError('for cidr key, value must be IPv4Network or IPv4Address')
else:
force = rule.get('force')
if force:
if not validators.domain(value): raise ValueError('for domain key, value must be domain')
else: raise ValueError('to add domain acl, please set force=true & do at your own risk')
rule.pop('force', None)
return rule
class ACLModel(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='name of acl (identifier)')
desc: Optional[str] = Field(default='', max_length=64, description='description')
action: ACLActionEnum = Field(default='deny', description='default action')
rules: List[ACLRuleModel] = Field(min_items=1, max_items=64, description='default action')
@librerouter.post("/libreapi/base/acl", status_code=200)
def create_acl(reqbody: ACLModel, response: Response):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
name_key = f'base:acl:{name}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent acl name'}; return
data = jsonable_encoder(reqbody)
rdbconn.hmset(name_key, redishash(data))
response.status_code, result = 200, {'passed': True}
# fire-event acl change
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'acl', 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_acl, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/base/acl/{identifier}", status_code=200)
def update_acl(reqbody: ACLModel, response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
_name_key = f'base:acl:{identifier}'
name_key = f'base:acl:{name}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent acl identifier'}; return
if name != identifier and rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent class name'}; return
data = jsonable_encoder(reqbody)
rdbconn.hmset(name_key, redishash(data))
# proactive get list who use this acl
_engaged_key = f'engagement:{_name_key}'
engaged_key = f'engagement:{name_key}'
engagements = rdbconn.smembers(_engaged_key)
if name != identifier:
for engagement in engagements:
pipe.hset(engagement, 'local_network_acl', name)
if rdbconn.exists(_engaged_key):
pipe.rename(_engaged_key, engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event acl change, process reload only if there is some-one use it
if engagements:
sipprofiles = [getaname(engagement) for engagement in engagements]
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'acl', 'sipprofiles': sipprofiles, 'name': name, '_name': identifier, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_acl, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/base/acl/{identifier}", status_code=200)
def delete_acl(response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
#
_name_key = f'base:acl:{identifier}'
_engage_key = f'engagement:{_name_key}'
if rdbconn.scard(_engage_key):
response.status_code, result = 403, {'error': 'engaged acl'}; return
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent acl identifier'}; return
pipe.delete(_engage_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# delete action perform only no one use it so no-one use it, by right this should be clean on memory
# however best practice of optimization it will be luckily clear sometime later if acl change
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'acl', 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_acl, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/base/acl/{identifier}", status_code=200)
def detail_acl(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'base:acl:{identifier}'
_engage_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent acl identifier'}; return
result = jsonhash(rdbconn.hgetall(_name_key))
engagements = rdbconn.smembers(_engage_key)
result.update({'engagements': engagements})
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_acl, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/base/acl", status_code=200)
def list_acl(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'base:acl:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
pipe.hget(mainkey, 'desc')
descs = pipe.execute()
data = [{'name': getaname(mainkey), 'desc': desc} for mainkey, desc in zip(mainkeys, descs)]
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_acl, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# SIP PROFILES
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
class ContextEnum(str, Enum):
core = "core"
carrier = "carrier"
access = "access"
class DtmfType(str, Enum):
rfc2833 = "rfc2833"
info = "info"
none = "none"
class SIPProfileModel(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='friendly name of sip profile')
desc: str = Field(default='', max_length=64, description='description')
user_agent: str = Field(default='LibreSBC', max_length=64, description='Value that will be displayed in SIP header User-Agent')
sdp_user: str = Field(default='LibreSBC', max_length=64, description='username with the o= and s= fields in SDP body')
local_network_acl: str = Field(default='rfc1918.auto', description='set the local network that refer from predefined acl')
enable_100rel: bool = Field(default=True, description='Reliability - PRACK message as defined in RFC3262')
ignore_183nosdp: bool = Field(default=True, description='Just ignore SIP 183 without SDP body')
sip_options_respond_503_on_busy: bool = Field(default=True, description='response 503 when system is in heavy load')
disable_transfer: bool = Field(default=False, description='true mean disable call transfer')
manual_redirect: bool = Field(default=False, description='how call forward handled, true mean it be controlled under libresbc contraints, false mean it be work automatically')
enable_3pcc: bool = Field(default=False, description='determines if third party call control is allowed or not')
enable_compact_headers: bool = Field(default=False, description='disable as default, true to enable compact SIP headers')
enable_timer: bool = Field(default=False, description='true to support for RFC 4028 SIP Session Timers')
session_timeout: int = Field(default=0, ge=1800, le=3600, description='call to expire after the specified seconds')
minimum_session_expires: int = Field(default=120, ge=90, le=3600, description='Value of SIP header Min-SE')
dtmf_type: DtmfType = Field(default='rfc2833', description='Dual-tone multi-frequency (DTMF) signal type')
media_timeout: int = Field(default=0, description='The number of seconds of RTP inactivity before SBC considers the call disconnected, and hangs up (recommend to use session timers instead), default value is 0 - disables the timeout.')
rtp_rewrite_timestamps: bool = Field(default=False, description='set true to regenerate and rewrite the timestamps in all the RTP streams going to an endpoint using this SIP Profile, necessary to fix audio issues when sending calls to some paranoid and not RFC-compliant gateways')
realm: Optional[str] = Field(regex=_REALM_, max_length=256, description='realm challenge key for digest auth, mainpoint to identify which directory domain that user belong to. This setting can be used with ALC (be careful to use & do at your own risk)', hidden_field=True)
context: ContextEnum = Field(description='predefined context for call control policy')
sip_port: int = Field(default=5060, ge=0, le=65535, description='Port to bind to for SIP traffic')
sip_address: str = Field(description='IP address via NetAlias use for SIP Signalling')
rtp_address: str = Field(description='IP address via NetAlias use for RTP Media')
tls: bool = Field(default=False, description='true to enable TLS')
tls_only: bool = Field(default=False, description='set True to disable listening on the unencrypted port for this connection')
sips_port: int = Field(default=5061, ge=0, le=65535, description='Port to bind to for TLS SIP traffic')
tls_version: str = Field(min_length=4, max_length=64, default='tlsv1.2', description='TLS version', hidden_field=True)
tls_cert_dir: Optional[str] = Field(min_length=4, max_length=256, description='TLS Certificate dirrectory', hidden_field=True)
# validation
@root_validator()
def sipprofile_agreement(cls, values):
_values = jsonable_encoder(values)
for key, value in _values.items():
# SIP TIMER
if key=='enable_timer' and not value :
removekey(['enable_timer', 'session_timeout', 'minimum_session_expires'], values)
# SIP TLS
if key=='sip_tls' and not value :
removekey(['sip_tls', 'sips_port', 'tls_only', 'tls_version', 'tls_cert_dir'], values)
if key=='local_network_acl':
if value not in _BUILTIN_ACLS_:
if not rdbconn.exists(f'base:acl:{value}'):
raise ValueError('nonexistent acl')
if key in ['sip_address', 'rtp_address']:
if not rdbconn.exists(f'base:netalias:{value}'):
raise ValueError('nonexistent network alias')
# remove the key's value is None
if value is None:
values.pop(key, None)
# REALM
name = values.get('name')
realm = values.get('realm')
if realm:
_profile = rdbconn.srandmember(f'engagement:base:realm:{realm}')
if _profile:
_name = getaname(_profile)
if _name != name: raise ValueError(f'realm is used by {_name}')
else:
values['realm'] = f'{name}.libresbc'
return values
@librerouter.post("/libreapi/sipprofile", status_code=200)
def create_sipprofile(reqbody: SIPProfileModel, response: Response):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
data = jsonable_encoder(reqbody)
name_key = f'sipprofile:{name}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent sip profile name'}; return
local_network_acl = data.get('local_network_acl')
sip_address = data.get('sip_address')
rtp_address = data.get('rtp_address')
realm = data.get('realm')
pipe.hmset(name_key, redishash(data))
if local_network_acl not in _BUILTIN_ACLS_: pipe.sadd(f'engagement:base:acl:{local_network_acl}', name_key)
pipe.sadd(f'engagement:base:netalias:{sip_address}', name_key)
pipe.sadd(f'engagement:base:netalias:{rtp_address}', name_key)
pipe.sadd(f'engagement:base:realm:{realm}', name_key)
pipe.sadd(f'nameset:sipprofile', name)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event sip profile create
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'sipprofile', 'action': 'create', 'sipprofile': name, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_sipprofile, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/sipprofile/{identifier}", status_code=200)
def update_sipprofile(reqbody: SIPProfileModel, response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
_name_key = f'sipprofile:{identifier}'
name_key = f'sipprofile:{name}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent sip profile identifier'}; return
if name != identifier and rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent sip profile name'}; return
_data = jsonhash(rdbconn.hgetall(_name_key))
_local_network_acl = _data.get('local_network_acl')
_sip_address = _data.get('sip_address')
_rtp_address = _data.get('rtp_address')
_realm = _data.get('realm')
data = jsonable_encoder(reqbody)
local_network_acl = data.get('local_network_acl')
sip_address = data.get('sip_address')
rtp_address = data.get('rtp_address')
realm = _data.get('realm')
if _local_network_acl not in _BUILTIN_ACLS_: pipe.srem(f'engagement:base:acl:{_local_network_acl}', _name_key)
pipe.srem(f'engagement:base:netalias:{_sip_address}', _name_key)
pipe.srem(f'engagement:base:netalias:{_rtp_address}', _name_key)
pipe.delete(f'engagement:base:realm:{_realm}')
if local_network_acl not in _BUILTIN_ACLS_: pipe.sadd(f'engagement:base:acl:{local_network_acl}', name_key)
pipe.sadd(f'engagement:base:netalias:{sip_address}', name_key)
pipe.sadd(f'engagement:base:netalias:{rtp_address}', name_key)
pipe.sadd(f'engagement:base:realm:{realm}', name_key)
pipe.hmset(name_key, redishash(data))
# remove the unintended-field
for _field in _data:
if _field not in data:
pipe.hdel(_name_key, _field)
# if name is changed
if name != identifier:
_engaged_key = f'engagement:{_name_key}'
engaged_key = f'engagement:{name_key}'
engagements = rdbconn.smembers(_engaged_key)
for engagement in engagements:
pipe.hset(f'intcon:{engagement}', 'sipprofile', name)
if rdbconn.exists(_engaged_key):
pipe.rename(_engaged_key, engaged_key)
pipe.delete(_name_key)
pipe.srem(f'nameset:sipprofile', identifier)
pipe.sadd(f'nameset:sipprofile', name)
pipe.rename(f'farendsipaddrs:in:{identifier}', f'farendsipaddrs:in:{name}')
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event sip profile update
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'sipprofile', 'action': 'update', 'sipprofile': name, '_sipprofile': identifier, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_sipprofile, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/sipprofile/{identifier}", status_code=200)
def delete_sipprofile(response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
_name_key = f'sipprofile:{identifier}'
_engage_key = f'engagement:{_name_key}'
if rdbconn.scard(_engage_key):
response.status_code, result = 403, {'error': 'engaged sipprofile'}; return
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent sipprofile'}; return
_local_network_acl = rdbconn.hget(_name_key, 'local_network_acl')
_sip_address = rdbconn.hget(_name_key, 'sip_address')
_rtp_address = rdbconn.hget(_name_key, 'rtp_address')
_realm = rdbconn.hget('realm')
if _local_network_acl not in _BUILTIN_ACLS_: pipe.srem(f'engagement:base:acl:{_local_network_acl}', _name_key)
pipe.srem(f'engagement:base:netalias:{_sip_address}', _name_key)
pipe.srem(f'engagement:base:netalias:{_rtp_address}', _name_key)
pipe.delete(f'engagement:base:realm:{_realm}')
pipe.srem(f'nameset:sipprofile', identifier)
pipe.delete(_engage_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event sip profile delete
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'sipprofile', 'action': 'delete', '_sipprofile': identifier, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_sipprofile, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/sipprofile/{identifier}", status_code=200)
def detail_sipprofile(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'sipprofile:{identifier}'
_engage_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent sip profile'}; return
result = jsonhash(rdbconn.hgetall(_name_key))
engagements = rdbconn.smembers(_engage_key)
result.update({'engagements': engagements})
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_sipprofile, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/sipprofile", status_code=200)
def list_sipprofile(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'sipprofile:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
pipe.hmget(mainkey, 'desc')
details = pipe.execute()
data = list()
for mainkey, detail in zip(mainkeys, details):
if detail:
data.append({'name': getaname(mainkey), 'desc': detail[0]})
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_sipprofile, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# PREANSWER CLASS
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
class PreAnswerTypeEnum(str, Enum):
tone = 'tone'
media = 'media'
speak = 'speak'
class PreAnswerStream(BaseModel):
type: PreAnswerTypeEnum = Field(default='tone', description='media type: tone - tone script follow ITU-T Recommendation E.180, media - filename (fullpath) of audio file, speak - text to speak')
stream: str = Field(min_length=8, max_length=511, description='stream data follow the media type')
# will do validate yet in next release
@root_validator()
def preanswer_stream_agreement(cls, stream):
streamtype = stream.get('type')
streamdata = stream.get('stream')
return stream
class PreAnswerModel(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='name of preanswer class (identifier)')
desc: Optional[str] = Field(default='', max_length=64, description='description')
streams: List[PreAnswerStream] = Field(min_items=1, max_items=8, description='List of PreAnswer Stream')
@librerouter.post("/libreapi/class/preanswer", status_code=200)
def create_preanswer_class(reqbody: PreAnswerModel, response: Response):
result = None
try:
name = reqbody.name
data = jsonable_encoder(reqbody)
name_key = f'class:preanswer:{name}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent class name'}; return
rdbconn.hmset(name_key, redishash(data))
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_preanswer_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/class/preanswer/{identifier}", status_code=200)
def update_preanswer_class(reqbody: PreAnswerModel, response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
data = jsonable_encoder(reqbody)
_name_key = f'class:preanswer:{identifier}'
name_key = f'class:preanswer:{name}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
if name != identifier and rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent class name'}; return
rdbconn.hmset(name_key, redishash(data))
if name != identifier:
_engaged_key = f'engagement:{_name_key}'
engaged_key = f'engagement:{name_key}'
engagements = rdbconn.smembers(_engaged_key)
for engagement in engagements:
pipe.hset(f'intcon:{engagement}', 'preanswer_class', name)
if rdbconn.exists(_engaged_key):
pipe.rename(_engaged_key, engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_preanswer_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/class/preanswer/{identifier}", status_code=200)
def delete_preanswer_class(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
pipe = rdbconn.pipeline()
_name_key = f'class:preanswer:{identifier}'
_engage_key = f'engagement:{_name_key}'
if rdbconn.scard(_engage_key):
response.status_code, result = 403, {'error': 'engaged class'}; return
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
pipe.delete(_engage_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_preanswer_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/class/preanswer/{identifier}", status_code=200)
def detail_preanswer_class(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'class:preanswer:{identifier}'
_engage_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
result = jsonhash(rdbconn.hgetall(_name_key))
engagements = rdbconn.smembers(_engage_key)
result.update({'engagements': engagements})
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_preanswer_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/class/preanswer", status_code=200)
def list_preanswer_class(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'class:preanswer:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
pipe.hmget(mainkey, 'desc')
details = pipe.execute()
data = list()
for mainkey, detail in zip(mainkeys, details):
if detail:
data.append({'name': getaname(mainkey), 'desc': detail[0]})
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_preanswer_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# MEDIA CLASS
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
class CodecEnum(str, Enum):
PCMA = "PCMA"
PCMU = "PCMU"
OPUS = "OPUS"
G729 = "G729"
AMR = "AMR"
AMRWB = "AMR-WB"
class NegotiationMode(str, Enum):
generous = 'generous'
greedy = 'greedy'
scrooge = 'scrooge'
class MediaModeEnum(str, Enum):
transcode = 'transcode'
proxy = 'proxy'
bypass = 'bypass'
class DtmfModeEnum(str, Enum):
rfc2833 = 'rfc2833'
info = 'info'
none = 'none'
class MediaModel(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='name of Media class (identifier)')
desc: Optional[str] = Field(default='', max_length=64, description='description')
codecs: List[CodecEnum] = Field(min_items=1, max_item=len(SWCODECS), description='sorted list of codec')
codec_negotiation: NegotiationMode = Field(default='generous', description='codec negotiation mode, generous: refer remote, greedy: refer local, scrooge: enforce local')
media_mode: MediaModeEnum = Field(default='transcode', description='media processing mode')
dtmf_mode: DtmfModeEnum = Field(default='rfc2833', description='Dual-tone multi-frequency mode')
cng: bool = Field(default=False, description='comfort noise generate')
vad: bool = Field(default=False, description='voice active detection, no transmit data when no party speaking')
@librerouter.post("/libreapi/class/media", status_code=200)
def create_media_class(reqbody: MediaModel, response: Response):
result = None
try:
name = reqbody.name
data = jsonable_encoder(reqbody)
name_key = f'class:media:{name}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent class name'}; return
rdbconn.hmset(name_key, redishash(data))
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_media_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/class/media/{identifier}", status_code=200)
def update_media_class(reqbody: MediaModel, response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
data = jsonable_encoder(reqbody)
_name_key = f'class:media:{identifier}'
name_key = f'class:media:{name}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
if name != identifier and rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent class name'}; return
rdbconn.hmset(name_key, redishash(data))
if name != identifier:
_engaged_key = f'engagement:{_name_key}'
engaged_key = f'engagement:{name_key}'
engagements = rdbconn.smembers(_engaged_key)
for engagement in engagements:
pipe.hset(f'intcon:{engagement}', 'media_class', name)
if rdbconn.exists(_engaged_key):
pipe.rename(_engaged_key, engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_media_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/class/media/{identifier}", status_code=200)
def delete_media_class(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
pipe = rdbconn.pipeline()
_name_key = f'class:media:{identifier}'
_engage_key = f'engagement:{_name_key}'
if rdbconn.scard(_engage_key):
response.status_code, result = 403, {'error': 'engaged class'}; return
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
pipe.delete(_engage_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_media_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/class/media/{identifier}", status_code=200)
def detail_media_class(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'class:media:{identifier}'
_engage_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
result = jsonhash(rdbconn.hgetall(_name_key))
engagements = rdbconn.smembers(_engage_key)
result.update({'engagements': engagements})
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_media_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/class/media", status_code=200)
def list_media_class(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'class:media:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
pipe.hmget(mainkey, 'desc')
details = pipe.execute()
data = list()
for mainkey, detail in zip(mainkeys, details):
if detail:
data.append({'name': getaname(mainkey), 'desc': detail[0]})
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_media_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# CAPACITY
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
class CapacityModel(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='name of capacity class (identifier)')
desc: Optional[str] = Field(default='', max_length=64, description='description')
cps: int = Field(default=2, ge=-1, le=len(CLUSTERS.get('members'))*2000, description='call per second')
concurentcalls: int = Field(default=10, ge=-1, le=len(CLUSTERS.get('members'))*25000, description='concurrent calls')
# validator
@root_validator()
def capacity_agreement(cls, values):
cps = values.get('cps')
if cps > len(CLUSTERS.get('members'))*(CLUSTERS.get('max_calls_per_second'))//2:
raise ValueError(f'the cps value is not valid for cluster capacity')
concurentcalls = values.get('concurentcalls')
if concurentcalls > len(CLUSTERS.get('members'))*(CLUSTERS.get('max_concurrent_calls'))//2:
raise ValueError(f'the concurentcalls value is not valid for cluster capacity')
return values
@librerouter.post("/libreapi/class/capacity", status_code=200)
def create_capacity_class(reqbody: CapacityModel, response: Response):
result = None
try:
name = reqbody.name
data = jsonable_encoder(reqbody)
name_key = f'class:capacity:{name}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent class name'}; return
rdbconn.hmset(name_key, redishash(data))
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_capacity_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/class/capacity/{identifier}", status_code=200)
def update_capacity_class(reqbody: CapacityModel, response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
data = jsonable_encoder(reqbody)
_name_key = f'class:capacity:{identifier}'
name_key = f'class:capacity:{name}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
if name != identifier and rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent class name'}; return
rdbconn.hmset(name_key, redishash(data))
if name != identifier:
_engaged_key = f'engagement:{_name_key}'
engaged_key = f'engagement:{name_key}'
engagements = rdbconn.smembers(_engaged_key)
for engagement in engagements:
pipe.hset(f'intcon:{engagement}', 'capacity_class', name)
if rdbconn.exists(_engaged_key):
pipe.rename(_engaged_key, engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_capacity_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/class/capacity/{identifier}", status_code=200)
def delete_capacity_class(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
pipe = rdbconn.pipeline()
_name_key = f'class:capacity:{identifier}'
_engaged_key = f'engagement:{_name_key}'
if rdbconn.scard(_engaged_key):
response.status_code, result = 403, {'error': 'engaged class'}; return
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
pipe.delete(_engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_capacity_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/class/capacity/{identifier}", status_code=200)
def detail_capacity_class(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'class:capacity:{identifier}'
_engaged_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
result = jsonhash(rdbconn.hgetall(_name_key))
engagements = rdbconn.smembers(_engaged_key)
result.update({'engagements': engagements})
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_capacity_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/class/capacity", status_code=200)
def list_capacity_class(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'class:capacity:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
pipe.hmget(mainkey, 'desc')
details = pipe.execute()
data = list()
for mainkey, detail in zip(mainkeys, details):
if detail:
data.append({'name': getaname(mainkey), 'desc': detail[0]})
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_capacity_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# NUMBER TRANSLATION
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
class TranslationModel(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='name of translation class')
desc: Optional[str] = Field(default='', max_length=64, description='description')
caller_number_pattern: str = Field(max_length=128, description='caller number pattern use pcre')
destination_number_pattern: str = Field(max_length=128, description='destination number pattern use pcre')
caller_number_replacement: str = Field(max_length=128, description='replacement that refer to caller number pattern use pcre')
destination_number_replacement: str = Field(max_length=128, description='replacement that refer to destination number pattern use pcre')
caller_name: Optional[str] = Field(default='_auto', max_length=128, description='set caller name, value can be any string or defined conventions: _auto, _caller_number(use caller id number as name)')
@librerouter.post("/libreapi/class/translation", status_code=200)
def create_translation_class(reqbody: TranslationModel, response: Response):
result = None
try:
name = reqbody.name
data = jsonable_encoder(reqbody)
name_key = f'class:translation:{name}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent class name'}; return
rdbconn.hmset(name_key, data)
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_translation_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/class/translation/{identifier}", status_code=200)
def update_translation_class(reqbody: TranslationModel, response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
data = jsonable_encoder(reqbody)
_name_key = f'class:translation:{identifier}'
name_key = f'class:translation:{name}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
if name != identifier and rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent class name'}; return
rdbconn.hmset(name_key, data)
if name != identifier:
_engaged_key = f'engagement:{_name_key}'
engaged_key = f'engagement:{name_key}'
engagements = rdbconn.smembers(_engaged_key)
for engagement in engagements:
_translation_rules = fieldjsonify(rdbconn.hget(f'intcon:{engagement}', 'translation_classes'))
translation_rules = [name if rule == identifier else rule for rule in _translation_rules]
pipe.hset(f'intcon:{engagement}', 'translation_classes', fieldredisify(translation_rules))
if rdbconn.exists(_engaged_key):
pipe.rename(_engaged_key, engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_translation_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/class/translation/{identifier}", status_code=200)
def delete_translation_class(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
pipe = rdbconn.pipeline()
_name_key = f'class:translation:{identifier}'
_engaged_key = f'engagement:{_name_key}'
if rdbconn.scard(_engaged_key):
response.status_code, result = 403, {'error': 'engaged class'}; return
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
pipe.delete(_engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_translation_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/class/translation/{identifier}", status_code=200)
def detail_translation_class(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'class:translation:{identifier}'
_engaged_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
result = jsonhash(rdbconn.hgetall(_name_key))
engagements = rdbconn.smembers(_engaged_key)
result.update({'engagements': engagements})
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_translation_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/class/translation", status_code=200)
def list_translation_class(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'class:translation:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
pipe.hmget(mainkey, 'desc')
details = pipe.execute()
data = list()
for mainkey, detail in zip(mainkeys, details):
if detail:
data.append({'name': getaname(mainkey), 'desc': detail[0]})
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_translation_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# MANIPULATION
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
HANGUP_PATTERN = re.compile('^[A-Z][A-Z0-9_]+$')
NUMBER_PATTERN = re.compile('^[0-9]+$')
class ConditionLogic(str, Enum):
AND = 'AND'
OR = 'OR'
class ConditionRule(BaseModel):
refervar: str = Field(min_length=2, max_length=128, description='variable name')
pattern: Optional[str] = Field(min_length=2, max_length=128, description='variable pattern with regex')
class ManiCondition(BaseModel):
logic: ConditionLogic = Field(default='AND', description='logic operation')
rules: List[ConditionRule] = Field(min_items=1, max_items=8, description='list of condition expression')
class ActionEnum(str, Enum):
set = 'set'
log = 'log'
hangup = 'hangup'
sleep = 'sleep'
class ManiAction(BaseModel):
action: ActionEnum = Field(description='action')
refervar: Optional[str] = Field(min_length=2, max_length=128, description='name of reference variable')
pattern: Optional[str] = Field(min_length=2, max_length=128, description='reference variable pattern with regex')
targetvar: Optional[str] = Field(min_length=2, max_length=128, description='name of target variable')
values: List[str] = Field(max_items=8, description='value of target variable')
# validation
@root_validator()
def maniaction_agreement(cls, maniacts):
_maniacts = jsonable_encoder(maniacts)
action = _maniacts.get('action')
values = _maniacts.get('values', [])
if action == 'set':
targetvar = _maniacts.get('targetvar')
if not targetvar:
raise ValueError(f'targetvar is require for {action} action')
if not values:
_maniacts.pop('refervar', None)
_maniacts.pop('pattern', None)
else: #{log,hangup,sleep}
_maniacts.pop('targetvar', None)
if not values:
raise ValueError(f'values must contain at least 1 item for {action} action')
else:
if action == 'hangup':
if not HANGUP_PATTERN.match(values[0]):
raise ValueError(f'hangup action require define hangup cause string with upper charaters')
else:
_maniacts['values'] = values[:1]
if action == 'sleep':
if not NUMBER_PATTERN.match(values[0]):
raise ValueError(f'sleep require value is a number')
else:
_maniacts['values'] = values[:1]
return _maniacts
class ManipulationModel(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='name of manipulation class')
desc: Optional[str] = Field(default='', max_length=64, description='description')
conditions: Optional[ManiCondition] = Field(description='combine the logic and list of checking rules')
actions: List[ManiAction] = Field(min_items=1, max_items=16, description='list of action when conditions is true')
antiactions: Optional[List[ManiAction]] = Field(min_items=1, max_items=16, description='list of action when conditions is false')
# validation
@root_validator()
def mani_agreement(cls, manis):
_manis = jsonable_encoder(manis)
if 'conditions' not in _manis:
_manis.pop('antiactions', None)
return _manis
@librerouter.post("/libreapi/class/manipulation", status_code=200)
def create_manipulation(reqbody: ManipulationModel, response: Response):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
data = jsonable_encoder(reqbody)
name_key = f'class:manipulation:{name}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent manipulation name'}; return
rdbconn.hmset(name_key, redishash(data))
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_manipulation, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/class/manipulation/{identifier}", status_code=200)
def update_manipulation_class(reqbody: ManipulationModel, response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
data = jsonable_encoder(reqbody)
_name_key = f'class:manipulation:{identifier}'
name_key = f'class:manipulation:{name}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
if name != identifier and rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent class name'}; return
_data = jsonhash(rdbconn.hgetall(_name_key))
rdbconn.hmset(name_key, redishash(data))
# remove the unintended-field
for _field in _data:
if _field not in data:
pipe.hdel(_name_key, _field)
if name != identifier:
_engaged_key = f'engagement:{_name_key}'
engaged_key = f'engagement:{name_key}'
engagements = rdbconn.smembers(_engaged_key)
for engagement in engagements:
_manipulation_rules = fieldjsonify(rdbconn.hget(f'intcon:{engagement}', 'manipulation_classes'))
manipulation_rules = [name if rule == identifier else rule for rule in _manipulation_rules]
pipe.hset(f'intcon:{engagement}', 'manipulation_classes', fieldredisify(manipulation_rules))
if rdbconn.exists(_engaged_key):
pipe.rename(_engaged_key, engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_manipulation_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/class/manipulation/{identifier}", status_code=200)
def delete_manipulation_class(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
pipe = rdbconn.pipeline()
_name_key = f'class:manipulation:{identifier}'
_engaged_key = f'engagement:{_name_key}'
if rdbconn.scard(_engaged_key):
response.status_code, result = 403, {'error': 'engaged class'}; return
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
pipe.delete(_engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_manipulation_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/class/manipulation/{identifier}", status_code=200)
def detail_manipulation_class(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'class:manipulation:{identifier}'
_engaged_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent class identifier'}; return
result = jsonhash(rdbconn.hgetall(_name_key))
engagements = rdbconn.smembers(_engaged_key)
result.update({'engagements': engagements})
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_manipulation_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/class/manipulation", status_code=200)
def list_manipulation_class(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'class:manipulation:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
pipe.hmget(mainkey, 'desc')
details = pipe.execute()
data = list()
for mainkey, detail in zip(mainkeys, details):
if detail:
data.append({'name': getaname(mainkey), 'desc': detail[0]})
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_manipulation_class, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# GATEWAY
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
class TransportEnum(str, Enum):
udp = "udp"
tcp = "tcp"
tls = "tls"
class CidTypeEnum(str, Enum):
none = 'none'
rpid = 'rpid'
pid = 'pid'
class GatewayModel(BaseModel):
name: str = Field(regex=_NAME_,min_length=2, max_length=32, description='name of translation class')
desc: Optional[str] = Field(default='', max_length=64, description='description')
username: str = Field(default='libre-user', min_length=1, max_length=128, description='username')
auth_username: Optional[str] = Field(min_length=1, max_length=128, description='auth username', hidden_field=True)
realm: Optional[str] = Field(min_length=1, max_length=256, description='auth realm, use gateway name as default')
from_user: Optional[str] = Field(min_length=1, max_length=256, description='username in from header, use username as default')
from_domain: Optional[str] = Field(min_length=1, max_length=256, description='domain in from header, use realm as default')
password: str = Field(default='libre@secret', min_length=1, max_length=128, description='auth password')
extension: Optional[str] = Field(max_length=256, description='extension for inbound calls, use username as default')
proxy: str = Field(min_length=1, max_length=256, description='farend proxy ip address or domain, use realm as default')
port: int = Field(default=5060, ge=0, le=65535, description='farend destination port')
transport: TransportEnum = Field(default='udp', description='farend transport protocol')
do_register: bool = Field(default=False, description='register to farend endpoint, false mean no register')
register_proxy: Optional[str] = Field(min_length=1, max_length=256, description='proxy address to register, use proxy as default')
register_transport: Optional[TransportEnum] = Field(description='transport to use for register')
expire_seconds: Optional[int] = Field(ge=60, le=3600, description='register expire interval in second, use 600s as default')
retry_seconds: Optional[int] = Field(ge=30, le=600, description='interval in second before a retry when a failure or timeout occurs')
caller_id_in_from: bool = Field(default=True, description='use the callerid of an inbound call in the from field on outbound calls via this gateway')
cid_type: Optional[CidTypeEnum] = Field(description='callerid header mechanism: rpid, pid, none')
contact_params: Optional[str] = Field(min_length=1, max_length=256, description='extra sip params to send in the contact')
contact_host: Optional[str] = Field(min_length=1, max_length=256, description='host part in contact header', hidden_field=True)
extension_in_contact: Optional[bool] = Field(description='put the extension in the contact')
ping: Optional[int] = Field(ge=5, le=3600, description='the period (second) to send SIP OPTION')
ping_max: Optional[int] = Field(ge=1, le=31, description='number of success pings to declaring a gateway up')
ping_min: Optional[int] = Field(ge=1, le=31,description='number of failure pings to declaring a gateway down')
contact_in_ping: Optional[str] = Field(min_length=4, max_length=256, description='contact header of ping message', hidden_field=True)
ping_user_agent: Optional[str] = Field(min_length=4, max_length=64, description='user agent of ping message', hidden_field=True)
# validation
@root_validator()
def gateway_agreement(cls, values):
_values = jsonable_encoder(values)
for key, value in _values.items():
if key == 'do_register' and not value:
removekey(['register_proxy', 'register_transport', 'expire_seconds', 'retry_seconds'], values)
if key == 'ping' and not value:
removekey(['ping_max', 'ping_min', 'contact_in_ping', 'ping_user_agent'], values)
if value is None:
values.pop(key, None)
for key, value in values.items():
if key in ['realm', 'proxy', 'from_domain', 'register_proxy']:
if not validators.ip_address.ipv4(value) and not validators.domain(value):
raise ValueError(f'{key} must be IPv4 address or Domain')
return values
@librerouter.post("/libreapi/base/gateway", status_code=200)
def create_gateway(reqbody: GatewayModel, response: Response):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
data = jsonable_encoder(reqbody)
name_key = f'base:gateway:{name}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent gateway name'}; return
rdbconn.hmset(name_key, redishash(data))
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_gateway, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/base/gateway/{identifier}", status_code=200)
def update_gateway(reqbody: GatewayModel, response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
_name_key = f'base:gateway:{identifier}'
name_key = f'base:gateway:{name}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent gateway identifier'}; return
if name != identifier and rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent gateway name'}; return
_data = jsonhash(rdbconn.hgetall(_name_key))
data = jsonable_encoder(reqbody)
rdbconn.hmset(name_key, redishash(data))
# remove the unintended-field
for _field in _data:
if _field not in data:
pipe.hdel(_name_key, _field)
# if change name
_engaged_key = f'engagement:{_name_key}'
engaged_key = f'engagement:{name_key}'
if name != identifier:
engagements = rdbconn.smembers(_engaged_key)
for engagement in engagements:
weight = rdbconn.hget(f'intcon:out:{engagement}:_gateways', identifier)
pipe.hdel(f'intcon:out:{engagement}:_gateways', identifier)
pipe.hset(f'intcon:out:{engagement}:_gateways', name, weight)
if rdbconn.exists(_engaged_key):
pipe.rename(_engaged_key, engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire event for update gateway only if gatetway in used
intconname = rdbconn.srandmember(engaged_key); sipprofile = None
if intconname:
sipprofile = rdbconn.hget(f'intcon:out:{intconname}', 'sipprofile')
if sipprofile:
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'gateway', 'action': 'update', 'gateway': name, '_gateway': identifier, 'sipprofile': sipprofile, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_gateway, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/base/gateway/{identifier}", status_code=200)
def delete_gateway(response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
_name_key = f'base:gateway:{identifier}'
_engaged_key = f'engagement:{_name_key}'
if rdbconn.scard(_engaged_key):
response.status_code, result = 403, {'error': 'engaged gateway'}; return
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent gateway identifier'}; return
pipe.delete(_engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_gateway, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/base/gateway/{identifier}", status_code=200)
def detail_gateway(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'base:gateway:{identifier}'
_engaged_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent gateway identifier'}; return
result = jsonhash(rdbconn.hgetall(_name_key))
engagements = rdbconn.smembers(_engaged_key)
result.update({'engagements': engagements})
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_gateway, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/base/gateway", status_code=200)
def list_gateway(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'base:gateway:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
pipe.hmget(mainkey, 'desc', 'proxy', 'port', 'transport')
details = pipe.execute()
data = list()
for mainkey, detail in zip(mainkeys, details):
if detail:
data.append(jsonhash({'name': getaname(mainkey), 'desc': detail[0], 'ip': detail[1], 'port': detail[2], 'transport': detail[3]}))
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_gateway, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
def check_existent_media(name):
if not rdbconn.exists(f'class:media:{name}'):
raise ValueError('nonexistent class')
return name
def check_existent_capacity(capacity):
if not rdbconn.exists(f'class:capacity:{capacity}'):
raise ValueError('nonexistent class')
return capacity
def check_existent_manipulation(manipulations):
for manipulation in manipulations:
if not rdbconn.exists(f'class:manipulation:{manipulation}'):
raise ValueError('nonexistent class')
return manipulations
def check_existent_translation(translations):
for translation in translations:
if not rdbconn.exists(f'class:translation:{translation}'):
raise ValueError('nonexistent class')
return translations
def check_existent_sipprofile(sipprofile):
if not rdbconn.exists(f'sipprofile:{sipprofile}'):
raise ValueError('nonexistent sipprofile')
return sipprofile
def check_cluster_node(nodes):
for node in nodes:
if node != '_ALL_' and node not in CLUSTERS.get('members'):
raise ValueError('nonexistent node')
return nodes
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# OUTBOUND INTERCONECTION
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
WEIGHTBASE = 'weight_based'
ROUNDROBIN = 'round_robin'
HASHCALLID = 'hash_callid'
HASHIPADDR = 'hash_src_ip'
HASHDESTNO = 'hash_destination_number'
class Distribution(str, Enum):
weight_based = WEIGHTBASE
round_robin = ROUNDROBIN
hash_callid = HASHCALLID
hash_src_ip = HASHIPADDR
hash_destination_number = HASHDESTNO
class PrivacyEnum(str, Enum):
auto = 'auto'
none = 'none'
screen = 'screen'
name = 'name'
number = 'number'
class CallerIDType(str, Enum):
auto = 'auto'
none = 'none'
rpid = 'rpid'
pid = 'pid'
class DistributedGatewayModel(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='gateway name')
weight: int = Field(default=1, ge=0, le=127, description='weight value use for distribution')
class OutboundInterconnection(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='name of outbound interconnection')
desc: Optional[str] = Field(default='', max_length=64, description='description')
sipprofile: str = Field(description='a sip profile nameid that interconnection engage to')
distribution: Distribution = Field(default='round_robin', description='The dispatcher algorithm to selects a destination from addresses set')
gateways: List[DistributedGatewayModel] = Field(min_items=1, max_item=10, description='gateways list used for this interconnection')
rtpaddrs: List[IPv4Network] = Field(min_items=0, max_item=20, description='a set of IPv4 Network that use for RTP')
media_class: str = Field(description='nameid of media class')
capacity_class: str = Field(description='nameid of capacity class')
translation_classes: List[str] = Field(default=[], min_items=0, max_item=5, description='a set of translation class')
manipulation_classes: List[str] = Field(default=[], min_items=0, max_item=5, description='a set of manipulations class')
privacy: List[PrivacyEnum] = Field(default=['auto'], min_items=1, max_item=3, description='privacy header')
cid_type: Optional[CallerIDType] = Field(default='auto', description='callerid header mechanism: rpid, pid, none')
nodes: List[str] = Field(default=['_ALL_'], min_items=1, max_item=len(CLUSTERS.get('members')), description='a set of node member that interconnection engage to')
enable: bool = Field(default=True, description='enable/disable this interconnection')
# validation
_existentmedia = validator('media_class', allow_reuse=True)(check_existent_media)
_existentcapacity = validator('capacity_class', allow_reuse=True)(check_existent_capacity)
_existenttranslation = validator('translation_classes', allow_reuse=True)(check_existent_translation)
_existentmanipulation = validator('manipulation_classes', allow_reuse=True)(check_existent_manipulation)
_existentsipprofile = validator('sipprofile', allow_reuse=True)(check_existent_sipprofile)
_clusternode = validator('nodes', allow_reuse=True)(check_cluster_node)
@root_validator()
def out_intcon_agreement(cls, values):
values = jsonable_encoder(values)
sipprofile = values.get('sipprofile')
distribution = values.get('distribution')
gateways = values.get('gateways')
for gateway in gateways:
gwname = gateway.get('name')
# check if gateways is existing
if not rdbconn.exists(f'base:gateway:{gwname}'):
raise ValueError('nonexistent gateway')
# gateway agreement with inteconnection and sipprofile
_intcon = rdbconn.srandmember(f'engagement:base:gateway:{gateway}')
if _intcon:
_scard = rdbconn.scard(f'engagement:base:gateway:{gateway}')
_sipprofile = rdbconn.hget(f'intcon:{_intcon}', 'sipprofile')
if sipprofile != _sipprofile and _scard > 1:
raise ValueError('gateway can be assigned to multiple intconnection only if they use the same sip profile')
if distribution != WEIGHTBASE:
gateway['weight'] = 1
privacy = values.get('privacy')
privacilen = len(privacy)
if 'none' in privacy and privacilen > 1: raise ValueError('none can not configured with others')
elif 'auto' in privacy:
if privacilen > 1 and ('number' in privacy or 'name' in privacy):
raise ValueError('auto can not configured with others except screen')
else: pass
return values
@librerouter.post("/libreapi/interconnection/outbound", status_code=200)
def create_outbound_interconnection(reqbody: OutboundInterconnection, response: Response):
requestid = get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
data = jsonable_encoder(reqbody)
sipprofile = data.get('sipprofile')
gateways = {gw.get('name'):gw.get('weight') for gw in data.get('gateways')}
rtpaddrs = set(data.get('rtpaddrs'))
media_class = data.get('media_class')
capacity_class = data.get('capacity_class')
translation_classes = data.get('translation_classes')
manipulation_classes = data.get('manipulation_classes')
nodes = set(data.get('nodes'))
# verification
nameid = f'out:{name}'; name_key = f'intcon:{nameid}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent outbound interconnection'}; return
# processing
data.pop('gateways'); data.update({'rtpaddrs': rtpaddrs, 'nodes': nodes })
pipe.hmset(name_key, redishash(data))
pipe.sadd(f'engagement:sipprofile:{sipprofile}', nameid)
for node in nodes: pipe.sadd(f'engagement:node:{node}', nameid)
pipe.sadd(f'engagement:class:media:{media_class}', nameid)
pipe.sadd(f'engagement:class:capacity:{capacity_class}', nameid)
for translation in translation_classes: pipe.sadd(f'engagement:class:translation:{translation}', nameid)
for manipulation in manipulation_classes: pipe.sadd(f'engagement:class:manipulation:{manipulation}', nameid)
pipe.hmset(f'intcon:{nameid}:_gateways', redishash(gateways))
for gateway in gateways: pipe.sadd(f'engagement:base:gateway:{gateway}', name)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event outbound interconnect create
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'outbound:intcon', 'action': 'create', 'intcon': name, 'sipprofile': sipprofile, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_outbound_interconnection, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/interconnection/outbound/{identifier}", status_code=200)
def update_outbound_interconnection(reqbody: OutboundInterconnection, response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid = get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
data = jsonable_encoder(reqbody)
sipprofile = data.get('sipprofile')
gateways = {gw.get('name'):gw.get('weight') for gw in data.get('gateways')}
rtpaddrs = set(data.get('rtpaddrs'))
media_class = data.get('media_class')
capacity_class = data.get('capacity_class')
translation_classes = data.get('translation_classes')
manipulation_classes = data.get('manipulation_classes')
nodes = set(data.get('nodes'))
# verification
nameid = f'out:{name}'; name_key = f'intcon:{nameid}'
_nameid = f'out:{identifier}'; _name_key = f'intcon:{_nameid}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent outbound interconnection identifier'}; return
if name != identifier and rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent outbound interconnection name'}; return
# get current data
_data = jsonhash(rdbconn.hgetall(_name_key))
_sipprofile = _data.get('sipprofile')
_nodes = _data.get('nodes')
_media_class = _data.get('media_class')
_capacity_class = _data.get('capacity_class')
_translation_classes = _data.get('translation_classes')
_manipulation_classes = _data.get('manipulation_classes')
_sipaddrs = _data.get('sipaddrs')
_gateways = jsonhash(rdbconn.hgetall(f'{_name_key}:_gateways'))
# transaction block
pipe.multi()
# processing: removing old-one
pipe.srem(f'engagement:sipprofile:{_sipprofile}', _nameid)
for node in _nodes: pipe.srem(f'engagement:node:{node}', _nameid)
pipe.srem(f'engagement:class:media:{_media_class}', _nameid)
pipe.srem(f'engagement:class:capacity:{_capacity_class}', _nameid)
for translation in _translation_classes: pipe.srem(f'engagement:class:translation:{translation}', _nameid)
for manipulation in _manipulation_classes: pipe.srem(f'engagement:class:manipulation:{manipulation}', _nameid)
# remove intcon out of the gateways engagement list, and built the map of gateway and number of intcon use this gateway
_gws = dict()
for gateway in _gateways:
gw_engaged_key = f'engagement:base:gateway:{gateway}'
_gws[gateway] = rdbconn.scard(gw_engaged_key)
pipe.srem(gw_engaged_key, identifier)
pipe.delete(f'{_name_key}:_gateways')
# processing: adding new-one
data.pop('gateways'); data.update({'rtpaddrs': rtpaddrs, 'nodes': nodes })
pipe.hmset(name_key, redishash(data))
pipe.sadd(f'engagement:sipprofile:{sipprofile}', nameid)
for node in nodes: pipe.sadd(f'engagement:node:{node}', nameid)
pipe.sadd(f'engagement:class:media:{media_class}', nameid)
pipe.sadd(f'engagement:class:capacity:{capacity_class}', nameid)
for translation in translation_classes: pipe.sadd(f'engagement:class:translation:{translation}', nameid)
for manipulation in manipulation_classes: pipe.sadd(f'engagement:class:manipulation:{manipulation}', nameid)
pipe.hmset(f'{name_key}:_gateways', redishash(gateways))
for gateway in gateways: pipe.sadd(f'engagement:base:gateway:{gateway}', name)
# remove the unintended-field
for _field in _data:
if _field not in data:
pipe.hdel(_name_key, _field)
# change identifier
if name != identifier:
_engaged_key = f'engagement:{_name_key}'
engaged_key = f'engagement:{name_key}'
engagements = rdbconn.smembers(_engaged_key)
for engagement in engagements:
if engagement.startswith('table'):
_endpoints = fieldjsonify(rdbconn.hget(f'routing:{engagement}', 'endpoints'))
if _endpoints:
endpoints = [name if endpoint == identifier else endpoint for endpoint in _endpoints]
pipe.hset(f'routing:{engagement}', 'endpoints', fieldredisify(endpoints))
if engagement.startswith('record'):
_endpoints = fieldjsonify(rdbconn.hget(f'routing:{engagement}', 'endpoints'))
_action = rdbconn.hget(f'routing:{engagement}', 'action')
if _endpoints and _action==_ROUTE:
endpoints = [name if endpoint == identifier else endpoint for endpoint in _endpoints]
pipe.hset(f'routing:{engagement}', 'endpoints', fieldredisify(endpoints))
if rdbconn.exists(_engaged_key):
pipe.rename(_engaged_key, engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event outbound interconnect update only if gateway or sipprofile change
if sipprofile != _sipprofile or set(gateways.keys()) == set(_gateways.keys()):
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'outbound:intcon', 'action': 'update', 'intcon': name, '_intcon': identifier, 'sipprofile': sipprofile, '_sipprofile': _sipprofile, 'gateways': list(gateways.keys()), '_gateways': _gws, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_outbound_interconnection, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/interconnection/outbound/{identifier}", status_code=200)
def delete_outbound_interconnection(response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid = get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
_nameid = f'out:{identifier}'; _name_key = f'intcon:{_nameid}'
_engaged_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent outbound interconnection identifier'}; return
if rdbconn.scard(_engaged_key):
response.status_code, result = 403, {'error': 'engaged outbound interconnection'}; return
# get current data
_data = jsonhash(rdbconn.hgetall(_name_key))
_sipprofile = _data.get('sipprofile')
_nodes = _data.get('nodes')
_media_class = _data.get('media_class')
_capacity_class = _data.get('capacity_class')
_translation_classes = _data.get('translation_classes')
_manipulation_classes = _data.get('manipulation_classes')
_sipaddrs = _data.get('sipaddrs')
_gateways = jsonhash(rdbconn.hgetall(f'{_name_key}:_gateways'))
# processing: removing old-one
pipe.srem(f'engagement:sipprofile:{_sipprofile}', _nameid)
for node in _nodes: pipe.srem(f'engagement:node:{node}', _nameid)
pipe.srem(f'engagement:class:media:{_media_class}', _nameid)
pipe.srem(f'engagement:class:capacity:{_capacity_class}', _nameid)
for translation in _translation_classes: pipe.srem(f'engagement:class:translation:{translation}', _nameid)
for manipulation in _manipulation_classes: pipe.srem(f'engagement:class:manipulation:{manipulation}', _nameid)
# remove intcon out of the gateways engagement list, and built the map of gateway and number of intcon use this gateway
_gws = dict()
for gateway in _gateways:
gw_engaged_key = f'engagement:base:gateway:{gateway}'
_gws[gateway] = rdbconn.scard(gw_engaged_key)
pipe.srem(gw_engaged_key, identifier)
pipe.delete(f'{_name_key}:_gateways')
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event outbound interconnect update
if _gws:
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'outbound:intcon', 'action': 'delete', '_intcon': identifier, '_sipprofile': _sipprofile, '_gateways': _gws, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_outbound_interconnection, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/interconnection/outbound/{identifier}", status_code=200)
def detail_outbound_interconnection(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
_nameid = f'out:{identifier}'
_name_key = f'intcon:{_nameid}'
_engaged_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent outbound interconnection identifier'}; return
result = jsonhash(rdbconn.hgetall(_name_key))
gateways = [{'name': k, 'weight': v} for k,v in jsonhash(rdbconn.hgetall(f'intcon:{_nameid}:_gateways')).items()]
engagements = rdbconn.smembers(_engaged_key)
result.update({'gateways': gateways, 'engagements': engagements})
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_outbound_interconnection, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
@librerouter.get("/libreapi/interconnection/outbound", status_code=200)
def list_outbound_interconnect(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = 'intcon:out:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
pipe.hmget(mainkey, 'name', 'desc', 'sipprofile')
details = pipe.execute()
data = list(); PYPATTERN = re.compile('^intcon:out:[^:]+$')
for mainkey, detail in zip(mainkeys, details):
if PYPATTERN.match(mainkey):
data.append({'name': detail[0], 'desc': detail[1], 'sipprofile': detail[2]})
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_outbound_interconnect, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# INBOUND INTERCONECTION
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
def check_existent_routing(table):
if not rdbconn.exists(f'routing:table:{table}'):
raise ValueError('nonexistent routing')
return table
def check_existent_preanswer(preanswer):
if preanswer:
if not rdbconn.exists(f'class:preanswer:{preanswer}'):
raise ValueError('nonexistent class')
return preanswer
class AuthSchemeEnum(str, Enum):
IP = 'IP'
DIGEST = 'DIGEST'
BOTH = 'BOTH'
class InboundInterconnection(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='name of inbound interconnection')
desc: Optional[str] = Field(default='', max_length=64, description='description')
sipprofile: str = Field(description='a sip profile nameid that interconnection engage to')
routing: str = Field(description='routing table that will be used by this inbound interconnection')
sipaddrs: List[IPv4Network] = Field(min_items=1, max_item=16, description='set of sip signalling addresses that use for SIP')
rtpaddrs: List[IPv4Network] = Field(min_items=0, max_item=20, description='a set of IPv4 Network that use for RTP')
ringready: bool = Field(default=False, description='response 180 ring indication')
media_class: str = Field(description='nameid of media class')
capacity_class: str = Field(description='nameid of capacity class')
translation_classes: List[str] = Field(default=[], min_items=0, max_item=5, description='a set of translation class')
manipulation_classes: List[str] = Field(default=[], min_items=0, max_item=5, description='a set of manipulations class')
preanswer_class: str = Field(default=None, description='nameid of preanswer class')
authscheme: AuthSchemeEnum = Field(default='IP', description='auth scheme for inbound, include: ip, digest, both')
secret: Optional[str] = Field(min_length=8, max_length=64, description='password of digest auth for inbound', hidden_field=True)
nodes: List[str] = Field(default=['_ALL_'], min_items=1, max_item=len(CLUSTERS.get('members')), description='a set of node member that interconnection engage to')
enable: bool = Field(default=True, description='enable/disable this interconnection')
# validation
_existenpreanswer = validator('preanswer_class', allow_reuse=True)(check_existent_preanswer)
_existentmedia = validator('media_class', allow_reuse=True)(check_existent_media)
_existentcapacity = validator('capacity_class', allow_reuse=True)(check_existent_capacity)
_existenttranslation = validator('translation_classes', allow_reuse=True)(check_existent_translation)
_existentmanipulation = validator('manipulation_classes', allow_reuse=True)(check_existent_translation)
_existentsipprofile = validator('sipprofile', allow_reuse=True)(check_existent_sipprofile)
_existentrouting = validator('routing')(check_existent_routing)
_clusternode = validator('nodes', allow_reuse=True)(check_cluster_node)
@root_validator()
def in_intcon_agreement(cls, values):
_values = jsonable_encoder(values)
authscheme = _values.get('authscheme')
secret = _values.get('secret')
if authscheme != 'IP' and not secret:
raise ValueError(f'auth scheme {authscheme} require define secret')
for key, value in values.items():
if value is None:
_values.pop(key, None)
return _values
@librerouter.post("/libreapi/interconnection/inbound", status_code=200)
def create_inbound_interconnection(reqbody: InboundInterconnection, response: Response):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
data = jsonable_encoder(reqbody)
sipprofile = data.get('sipprofile')
routing = data.get('routing')
sipaddrs = set(data.get('sipaddrs'))
rtpaddrs = set(data.get('rtpaddrs'))
media_class = data.get('media_class')
preanswer_class = data.get('preanswer_class')
capacity_class = data.get('capacity_class')
translation_classes = data.get('translation_classes')
manipulation_classes = data.get('manipulation_classes')
nodes = set(data.get('nodes'))
# verification
nameid = f'in:{name}'; name_key = f'intcon:{nameid}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent inbound interconnection'}; return
# guaranted that the address not overlap eachother
_farendsipaddrs = rdbconn.smembers(f'farendsipaddrs:in:{sipprofile}')
for sipaddr in sipaddrs:
cidr = IPv4Network(sipaddr)
for _farendsipaddr in _farendsipaddrs:
_cidr = IPv4Network(_farendsipaddr)
if _cidr.overlaps(cidr):
response.status_code, result = 403, {'error': f'These addresses {sipaddr} & {_farendsipaddr} are overlaped'}; return
# processing
data.update({'sipaddrs': sipaddrs, 'rtpaddrs': rtpaddrs, 'nodes': nodes })
pipe.hmset(name_key, redishash(data))
pipe.sadd(f'engagement:sipprofile:{sipprofile}', nameid)
pipe.sadd(f'engagement:routing:table:{routing}', nameid)
for node in nodes: pipe.sadd(f'engagement:node:{node}', nameid)
pipe.sadd(f'engagement:class:media:{media_class}', nameid)
if preanswer_class:
pipe.sadd(f'engagement:class:preanswer:{preanswer_class}', nameid)
pipe.sadd(f'engagement:class:capacity:{capacity_class}', nameid)
for translation in translation_classes: pipe.sadd(f'engagement:class:translation:{translation}', nameid)
for manipulation in manipulation_classes: pipe.sadd(f'engagement:class:manipulation:{manipulation}', nameid)
for sipaddr in sipaddrs: pipe.sadd(f'farendsipaddrs:in:{sipprofile}', sipaddr)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event inbound interconnect create
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'inbound:intcon', 'action': 'create', 'intcon': name, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_inbound_interconnection, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/interconnection/inbound/{identifier}", status_code=200)
def update_inbound_interconnection(reqbody: InboundInterconnection, response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
data = jsonable_encoder(reqbody)
sipprofile = data.get('sipprofile')
sipaddrs = set(data.get('sipaddrs'))
rtpaddrs = set(data.get('rtpaddrs'))
routing = data.get('routing')
media_class = data.get('media_class')
preanswer_class = data.get('preanswer_class')
capacity_class = data.get('capacity_class')
translation_classes = data.get('translation_classes')
manipulation_classes = data.get('manipulation_classes')
nodes = set(data.get('nodes'))
# verification
nameid = f'in:{name}'; name_key = f'intcon:{nameid}'
_nameid = f'in:{identifier}'; _name_key = f'intcon:{_nameid}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent inbound interconnection identifier'}; return
if name != identifier and rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent inbound interconnection name'}; return
# get current data
_data = jsonhash(rdbconn.hgetall(_name_key))
_sipprofile = _data.get('sipprofile')
_routing = _data.get('routing')
_nodes = set(_data.get('nodes'))
_media_class = _data.get('media_class')
_preanswer_class = _data.get('preanswer_class')
_capacity_class = _data.get('capacity_class')
_translation_classes = _data.get('translation_classes')
_manipulation_classes = _data.get('manipulation_classes')
_sipaddrs = set(_data.get('sipaddrs'))
# verification
if sipprofile == _sipprofile: newaddrs = sipaddrs - _sipaddrs
else: newaddrs = sipaddrs
if newaddrs:
_farendsipaddrs = rdbconn.smembers(f'farendsipaddrs:in:{_sipprofile}')
for newaddr in newaddrs:
cidr = IPv4Network(newaddr)
for _farendsipaddr in _farendsipaddrs:
_cidr = IPv4Network(_farendsipaddr)
if _cidr.overlaps(cidr):
response.status_code, result = 403, {'error': f'These addresses {newaddr} & {_farendsipaddr} are overlaped'}; return
# transaction block
pipe.multi()
# processing: removing old-one
pipe.srem(f'engagement:sipprofile:{_sipprofile}', _nameid)
pipe.srem(f'engagement:routing:table:{_routing}', _nameid)
for node in _nodes: pipe.srem(f'engagement:node:{node}', _nameid)
pipe.srem(f'engagement:class:media:{_media_class}', _nameid)
if _preanswer_class:
pipe.srem(f'engagement:class:preanswer:{_preanswer_class}', _nameid)
pipe.srem(f'engagement:class:capacity:{_capacity_class}', _nameid)
for translation in _translation_classes: pipe.srem(f'engagement:class:translation:{translation}', _nameid)
for manipulation in _manipulation_classes: pipe.srem(f'engagement:class:manipulation:{manipulation}', _nameid)
if sipprofile == _sipprofile:
oldaddrs = _sipaddrs - sipaddrs
for oldaddr in oldaddrs: pipe.srem(f'farendsipaddrs:in:{_sipprofile}', oldaddr)
# processing: adding new-one
data.update({'sipaddrs': sipaddrs, 'rtpaddrs': rtpaddrs, 'nodes': nodes })
pipe.hmset(name_key, redishash(data))
pipe.sadd(f'engagement:sipprofile:{sipprofile}', nameid)
pipe.sadd(f'engagement:routing:table:{routing}', nameid)
for node in nodes: pipe.sadd(f'engagement:node:{node}', nameid)
pipe.sadd(f'engagement:class:media:{media_class}', nameid)
if preanswer_class:
pipe.sadd(f'engagement:class:preanswer:{preanswer_class}', nameid)
pipe.sadd(f'engagement:class:capacity:{capacity_class}', nameid)
for translation in translation_classes: pipe.sadd(f'engagement:class:translation:{translation}', nameid)
for manipulation in manipulation_classes: pipe.sadd(f'engagement:class:manipulation:{manipulation}', nameid)
for newaddr in newaddrs: pipe.sadd(f'farendsipaddrs:in:{sipprofile}', newaddr)
# remove the unintended-field
for _field in _data:
if _field not in data:
pipe.hdel(_name_key, _field)
# change identifier
if name != identifier:
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event inbound interconnect update
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'inbound:intcon', 'action': 'update', 'intcon': name, '_intcon': identifier, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_inbound_interconnection, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/interconnection/inbound/{identifier}", status_code=200)
def delete_inbound_interconnection(response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
_nameid = f'in:{identifier}'; _name_key = f'intcon:{_nameid}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent inbound interconnection'}; return
_data = jsonhash(rdbconn.hgetall(_name_key))
_sipprofile = _data.get('sipprofile')
_nodes = _data.get('nodes')
_media_class = _data.get('media_class')
_preanswer_class = _data.get('preanswer_class')
_capacity_class = _data.get('capacity_class')
_translation_classes = _data.get('translation_classes')
_manipulation_classes = _data.get('manipulation_classes')
_sipaddrs = _data.get('sipaddrs')
pipe.srem(f'engagement:sipprofile:{_sipprofile}', _nameid)
for node in _nodes: pipe.srem(f'engagement:node:{node}', _nameid)
pipe.srem(f'engagement:class:media:{_media_class}', _nameid)
if _preanswer_class:
pipe.srem(f'engagement:class:preanswer:{_preanswer_class}', _nameid)
pipe.srem(f'engagement:class:capacity:{_capacity_class}', _nameid)
for translation in _translation_classes: pipe.srem(f'engagement:class:translation:{translation}', _nameid)
for manipulation in _manipulation_classes: pipe.srem(f'engagement:class:manipulation:{manipulation}', _nameid)
for _sipaddr in _sipaddrs: pipe.srem(f'farendsipaddrs:in:{_sipprofile}', _sipaddr)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event inbound interconnect delete
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'inbound:intcon', 'action': 'delete', '_intcon': identifier, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_inbound_interconnection, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/interconnection/inbound/{identifier}", status_code=200)
def detail_inbound_interconnection(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'intcon:in:{identifier}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent inbound interconnection identifier'}; return
result = jsonhash(rdbconn.hgetall(_name_key))
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_inbound_interconnection, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/interconnection/inbound", status_code=200)
def list_inbound_interconnect(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = 'intcon:in:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
pipe.hmget(mainkey, 'desc', 'sipprofile', 'routing')
details = pipe.execute()
data = list()
for mainkey, detail in zip(mainkeys, details):
data.append({'name': getaname(mainkey), 'desc': detail[0], 'sipprofile': detail[1], 'routing': detail[2]})
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_inbound_interconnect, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ROUTING TABLE
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
class RouteModel(BaseModel):
primary: str = Field(description='primary entity of route')
secondary: str = Field(description='secondary entity of route')
load: int = Field(ge=0, le=100, description='load sharing value for between 2 routes')
class RoutingTableActionEnum(str, Enum):
query = _QUERY
route = _ROUTE
block = _BLOCK
# request: reseved routing with http api
class RoutingVariableEnum(str, Enum):
cidnumber = 'cidnumber'
cidname = 'cidname'
dstnumber = 'dstnumber'
intconname = 'intconname'
realm = 'realm'
class RoutingTableModel(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='name of routing table')
desc: Optional[str] = Field(default='', max_length=64, description='description')
variables: Optional[List[str]] = Field(min_items=1, max_items=5, description='sip variable for routing base, eg: cidnumber, cidname, dstnumber, intconname, realm')
action: RoutingTableActionEnum = Field(default='query', description=f'routing action: {_QUERY} - find nexthop by query routing record; {_BLOCK} - block the call; {_ROUTE} - route call to outbound interconnection')
routes: Optional[RouteModel] = Field(description='route model data')
# validation
@root_validator()
def routing_table_agreement(cls, values):
values = jsonable_encoder(values)
action = values.get('action')
if action==_ROUTE:
values.pop('variables', None)
routes = values.get('routes', None)
if not routes:
raise ValueError(f'{_ROUTE} action require at routes param')
else:
primary = routes.get('primary')
secondary = routes.get('secondary')
load = routes.get('load')
for intconname in [primary, secondary]:
if not rdbconn.exists(f'intcon:out:{intconname}'):
raise ValueError('nonexistent outbound interconnect')
values['routes'] = [primary, secondary, load]
elif action==_QUERY:
values.pop('routes', None)
variables = values.get('variables')
if not variables:
raise ValueError(f'{_QUERY} action require at variables param')
else:
values['variables'] = variables[:1]
else:
values.pop('routes', None)
values.pop('variables', None)
return values
@librerouter.post("/libreapi/routing/table", status_code=200)
def create_routing_table(reqbody: RoutingTableModel, response: Response):
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
nameid = f'table:{name}'; name_key = f'routing:{nameid}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent routing table'}; return
data = jsonable_encoder(reqbody)
pipe.hmset(name_key, redishash(data))
routes = data.get('routes')
if routes:
for route in routes[:2]:
pipe.sadd(f'engagement:intcon:out:{route}', nameid)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_routing_table, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/routing/table/{identifier}", status_code=200)
def update_routing_table(reqbody: RoutingTableModel, response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
pipe = rdbconn.pipeline()
name = reqbody.name
_nameid = f'table:{identifier}'; _name_key = f'routing:{_nameid}'
nameid = f'table:{name}'; name_key = f'routing:{nameid}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent routing table identifier'}; return
if name != identifier:
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent routing table name'}; return
else:
response.status_code, result = 403, {'error': 'change name routing table is not allowed'}; return
# get current data
_data = jsonhash(rdbconn.hgetall(_name_key))
_routes = _data.get('routes')
# transaction block
pipe.multi()
if _routes:
for _route in _routes[:2]:
pipe.srem(f'engagement:intcon:out:{_route}', _nameid)
data = jsonable_encoder(reqbody)
pipe.hmset(name_key, redishash(data))
routes = data.get('routes')
if routes:
for route in _routes[:2]:
pipe.sadd(f'engagement:intcon:out:{route}', nameid)
# remove unintended field
for field in _data:
if field not in data:
pipe.hdel(name_key, field)
if name != identifier:
_engaged_key = f'engagement:{_name_key}'
engaged_key = f'engagement:{name_key}'
engagements = rdbconn.smembers(_engaged_key)
for engagement in engagements:
pipe.hset(f'intcon:{engagement}', 'routing', name)
if rdbconn.exists(_engaged_key):
pipe.rename(_engaged_key, engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_routing_table, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/routing/table/{identifier}", status_code=200)
def delete_routing_table(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
pipe = rdbconn.pipeline()
_nameid = f'table:{identifier}'; _name_key = f'routing:{_nameid}'
_engaged_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent routing table'}; return
if rdbconn.scard(_engaged_key):
response.status_code, result = 403, {'error': 'engaged routing table'}; return
# check if routing records exists in table
_ROUTING_KEY_PATTERN = f'routing:record:{identifier}:*'
next, records = rdbconn.scan(0, _ROUTING_KEY_PATTERN, SCAN_COUNT)
if records:
response.status_code, result = 400, {'error': 'routing table in used'}; return
else:
while next:
next, records = rdbconn.scan(next, _ROUTING_KEY_PATTERN, SCAN_COUNT)
if records:
response.status_code, result = 400, {'error': 'routing table in used'}; return
# get current data
_routes = fieldjsonify(rdbconn.hget(_name_key, 'routes'))
if _routes:
for _route in _routes[:2]:
pipe.srem(f'engagement:intcon:out:{_route}', _nameid)
pipe.delete(_engaged_key)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_routing_table, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/routing/table/{identifier}", status_code=200)
def detail_routing_table(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'routing:table:{identifier}'
_engaged_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent routing table identifier'}; return
data = jsonhash(rdbconn.hgetall(_name_key))
_routes = data.get('routes')
if _routes:
data['routes'] = {'primary': _routes[0], 'secondary': _routes[1], 'load': int(_routes[2])}
# get records
pipe = rdbconn.pipeline()
KEYPATTERN = f'routing:record:{identifier}:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
if mainkey.endswith(':compare:'): pipe.hgetall(mainkey)
else: pipe.get(mainkey)
details = pipe.execute()
records = list()
for mainkey, detail in zip(mainkeys, details):
_, _, _, match, value = listify(mainkey)
if value==__EMPTY_STRING__: value = __DEFAULT_ENTRY__
if match=='compare':
for hashfield, valuefield in detail.items():
compare, param = listify(hashfield)
recordvalue = listify(valuefield)
action = recordvalue[0]
record = {'matching': compare, 'value': param, 'action': action}
if action != 'block':
record.update({'routes':{'primary': recordvalue[1], 'secondary': recordvalue[2], 'load': int(recordvalue[3])}})
records.append(record)
else:
splitdetail = listify(detail)
action = splitdetail[0]
record = {'match': match, 'value': value, 'action': action}
if action != _BLOCK:
record.update({'routes': {'primary': splitdetail[1], 'secondary': splitdetail[2], 'load': int(splitdetail[3])}})
records.append(record)
engagements = rdbconn.smembers(_engaged_key)
data.update({'records': records, 'engagements': engagements})
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_routing_table, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/routing/table", status_code=200)
def list_routing_table(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'routing:table:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys: pipe.hgetall(mainkey)
details = pipe.execute()
data = list()
for mainkey, detail in zip(mainkeys, details):
detail = jsonhash(detail)
routes = detail.get('route')
if routes:
detail['routes'] = {'primary': routes[0], 'secondary': routes[1], 'load': int(routes[2])}
data.append(detail)
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_routing_table, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ROUTING RECORD
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
class MatchingEnum(str, Enum):
lpm = 'lpm'
em = 'em'
eq = 'eq'
ne = 'ne'
gt = 'gt'
lt = 'lt'
_COMPARESET = {'eq', 'ne', 'gt', 'lt'}
class RoutingRecordActionEnum(str, Enum):
route = _ROUTE
block = _BLOCK
jumps = _JUMPS
class RoutingRecordModel(BaseModel):
table: str = Field(regex=_NAME_, max_length=32, description='name of routing table')
match: MatchingEnum = Field(description='matching options, include lpm: longest prefix match, em: exact match, eq: equal, ne: not equal, gt: greater than, lt: less than',)
value: str = Field(min_length=1, max_length=128, regex=_DIAL_, description=f'value of variable that declared in routing table. {__DEFAULT_ENTRY__} is predefined value for default entry')
action: RoutingRecordActionEnum = Field(default=_ROUTE, description=f'routing action: {_JUMPS} - jumps to other routing table; {_BLOCK} - block the call; {_ROUTE} - route call to outbound interconnection')
routes: Optional[RouteModel] = Field(description='route model data')
# validation and transform data
@root_validator()
def routing_record_agreement(cls, values):
#try:
values = jsonable_encoder(values)
table = values.get('table')
action = values.pop('action')
if not rdbconn.exists(f'routing:table:{table}'):
raise ValueError('nonexistent routing table')
if action==_BLOCK:
values.pop('routes', None)
if action in [_JUMPS, _ROUTE]:
routes = values.get('routes')
if not routes:
raise ValueError(f'routes parameter is required for {action} action')
else:
primary = routes.get('primary')
secondary = routes.get('secondary')
load = routes.get('load')
if action == _ROUTE:
for intconname in [primary, secondary]:
if not rdbconn.exists(f'intcon:out:{intconname}'):
raise ValueError('nonexistent outbound interconnect')
else:
for _table in [primary, secondary]:
if _table == table:
raise ValueError(f'routing loop to itself')
if not rdbconn.exists(f'routing:table:{_table}'):
raise ValueError('nonexistent routing table')
values['routes'] = [action, primary, secondary, load]
return values
@librerouter.post("/libreapi/routing/record", status_code=200)
def create_routing_record(reqbody: RoutingRecordModel, response: Response):
result = None
try:
pipe = rdbconn.pipeline()
data = jsonable_encoder(reqbody)
table = data.get('table')
match = data.get('match')
value = data.get('value')
if value == __DEFAULT_ENTRY__: value = __EMPTY_STRING__
routes = data.get('routes')
nameid = f'record:{table}:{match}:{value}'
hashfield = None
if match in _COMPARESET:
record_key = f'routing:record:{table}:compare:'
hashfield = f'{match}:{value}'
if rdbconn.hexists(record_key, hashfield):
response.status_code, result = 403, {'error': 'existent routing record'}; return
else:
record_key = f'routing:{nameid}'
if rdbconn.exists(record_key):
response.status_code, result = 403, {'error': 'existent routing record'}; return
action = routes[0]
if action==_ROUTE:
for route in routes[1:3]:
pipe.sadd(f'engagement:intcon:out:{route}', nameid)
elif action==_JUMPS:
for route in routes[1:3]:
pipe.sadd(f'engagement:routing:table:{route}', nameid)
if hashfield: pipe.hset(record_key, hashfield, stringify(map(str, routes)))
else: pipe.set(record_key, stringify(map(str, routes)))
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_routing_record, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/routing/record", status_code=200)
def update_routing_record(reqbody: RoutingRecordModel, response: Response):
result = None
try:
pipe = rdbconn.pipeline()
data = jsonable_encoder(reqbody)
table = data.get('table')
match = data.get('match')
value = data.get('value')
if value == __DEFAULT_ENTRY__: value = __EMPTY_STRING__
nameid = f'record:{table}:{match}:{value}'
hashfield = None
if match in _COMPARESET:
record_key = f'routing:record:{table}:compare:'
hashfield = f'{match}:{value}'
if not rdbconn.hexists(record_key, hashfield):
response.status_code, result = 403, {'error': 'non existent routing record'}; return
else:
record_key = f'routing:{nameid}'
if not rdbconn.exists(record_key):
response.status_code, result = 403, {'error': 'non existent routing record'}; return
# process old data
if hashfield: _routes = listify(rdbconn.hget(record_key, hashfield))
else: _routes = listify(rdbconn.get(record_key))
_action = _routes[0]
if _action==_ROUTE:
for _route in _routes[1:3]:
pipe.srem(f'engagement:intcon:out:{_route}', nameid)
elif _action==_JUMPS:
for _route in _routes[1:3]:
pipe.srem(f'engagement:routing:table:{_route}', nameid)
else: pass
# process new data
routes = data.get('routes')
action = routes[0]
if action==_ROUTE:
for route in routes[1:3]:
pipe.sadd(f'engagement:intcon:out:{route}', nameid)
elif action==_JUMPS:
for route in routes[1:3]:
pipe.sadd(f'engagement:routing:table:{route}', nameid)
else: pass
if hashfield: pipe.hset(record_key, hashfield, stringify(map(str, routes)))
else: pipe.set(record_key, stringify(map(str, routes)))
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_routing_record, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/routing/record/{table}/{match}/{value}", status_code=200)
def delete_routing_record(response: Response, value:str=Path(..., regex=_DIAL_), table:str=Path(..., regex=_NAME_),
match:str=Path(..., regex='^(em|lpm|eq|ne|gt|lt)$')):
result = None
try:
pipe = rdbconn.pipeline()
if value == __DEFAULT_ENTRY__: value = __EMPTY_STRING__
nameid = f'record:{table}:{match}:{value}'
hashfield = None
if match in _COMPARESET:
record_key = f'routing:record:{table}:compare:'
hashfield = f'{match}:{value}'
if not rdbconn.hexists(record_key, hashfield):
response.status_code, result = 403, {'error': 'non existent routing record'}; return
else:
record_key = f'routing:{nameid}'
if not rdbconn.exists(record_key):
response.status_code, result = 403, {'error': 'non existent routing record'}; return
if hashfield: _routes = listify(rdbconn.hget(record_key, hashfield))
else: _routes = listify(rdbconn.get(record_key))
_action = _routes[0]
if _action==_ROUTE:
for _route in _routes[1:3]:
pipe.srem(f'engagement:intcon:out:{_route}', nameid)
if _action==_JUMPS:
for _route in _routes[1:3]:
pipe.srem(f'engagement:routing:table:{_route}', nameid)
if hashfield: pipe.hdel(record_key, hashfield)
else: pipe.delete(record_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_routing_record, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ACCESS SERVICE
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
class Socket(BaseModel):
transport: TransportEnum = Field(default='udp', description='transport protocol', hidden_field=True)
port: int = Field(default=5060, ge=0, le=65535, description='sip port', hidden_field=True )
ip: IPv4Address = Field(description='ip address')
force: Optional[bool] = Field(description='set true if you need to add none loopback ip', hidden_field=True)
@root_validator()
def socket_ip(cls, kvs):
kvs = jsonable_encoder(kvs)
force = kvs.pop('force', None)
if not force:
ip = kvs.get('ip')
if not IPv4Network(ip).is_loopback:
raise ValueError('ip must be loopback address only')
return kvs
class DomainPolicy(BaseModel):
domain: str = Field(regex=_REALM_, max_length=32, description='sip domain')
srcsocket: Socket = Field(description='listen socket of sip between proxy and b2bua')
dstsocket: Socket = Field(description='forward socket of sip between proxy and b2bua')
@root_validator()
def policy(cls, kvs):
kvs = jsonable_encoder(kvs)
domain = kvs.get('domain')
if not validators.domain(domain):
raise ValueError('Invalid domain name, please refer rfc1035')
src_socket = kvs.get('srcsocket')
srcsocket = f'{src_socket["transport"]}:{src_socket["ip"]}:{src_socket["port"]}'
dst_socket = kvs.get('dstsocket')
dstsocket = f'{dst_socket["transport"]}:{dst_socket["ip"]}:{dst_socket["port"]}'
if dstsocket == srcsocket:
raise ValueError('source and destination sockets are same')
kvs.update({'srcsocket': srcsocket, 'dstsocket': dstsocket})
return kvs
@librerouter.post("/libreapi/access/domain-policy", status_code=200)
def create_access_domain_policy(reqbody: DomainPolicy, response: Response):
requestid=get_request_uuid()
result = None
try:
data = jsonable_encoder(reqbody)
domain = data.pop('domain')
# verification
name_key = f'access:policy:{domain}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent access policy domain'}; return
rdbconn.hmset(name_key, data)
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_access_domain_policy, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.patch("/libreapi/access/domain-policy", status_code=200)
def update_access_domain_policy(reqbody: DomainPolicy, response: Response):
requestid=get_request_uuid()
result = None
try:
data = jsonable_encoder(reqbody)
domain = data.pop('domain')
# verification
name_key = f'access:policy:{domain}'
_engage_key = f'engagement:{name_key}'
if not rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'nonexistent access policy domain'}; return
rdbconn.hmset(name_key, data)
response.status_code, result = 200, {'passed': True}
layer = rdbconn.srandmember(_engage_key)
if layer:
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'policy:domain', 'action': 'update', 'layer': layer, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_access_domain_policy, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/access/domain-policy/{domain}", status_code=200)
def delete_access_domain_policy(response: Response, domain:str=Path(..., regex=_REALM_)):
requestid=get_request_uuid()
result = None
try:
_name_key = f'access:policy:{domain}'
_engage_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent access policy domain'}; return
if rdbconn.scard(_engage_key):
response.status_code, result = 403, {'error': 'engaged access policy domain'}; return
# check if routing records exists in table
_DIRECTORY_KEY_PATTERN = f'access:dir:*:{domain}:*'
next, records = rdbconn.scan(0, _DIRECTORY_KEY_PATTERN, SCAN_COUNT)
if records:
response.status_code, result = 400, {'error': 'domain policy in used'}; return
else:
while next:
next, records = rdbconn.scan(next, _DIRECTORY_KEY_PATTERN, SCAN_COUNT)
if records:
response.status_code, result = 400, {'error': 'domain policy in used'}; return
pipe = rdbconn.pipeline()
pipe.delete(_name_key)
pipe.delete(_engage_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_access_domain_policy, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/access/domain-policy/{domain}", status_code=200)
def detail_access_domain_policy(response: Response, domain:str=Path(..., regex=_REALM_)):
result = None
try:
_name_key = f'access:policy:{domain}'
_engage_key = f'engagement:{_name_key}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent access policy domain'}; return
data = rdbconn.hgetall(_name_key)
src_socket = listify(data.get('srcsocket'))
srcsocket = {'transport': src_socket[0], 'ip': src_socket[1], 'port': src_socket[2]}
dst_socket = listify(data.get('dstsocket'))
dstsocket = {'transport': dst_socket[0], 'ip': dst_socket[1], 'port': dst_socket[2]}
engagements = rdbconn.smembers(_engage_key)
result = {'domain': domain, 'srcsocket': srcsocket, 'dstsocket': dstsocket, 'engagements': engagements}
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_access_domain_policy, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/access/domain-policy", status_code=200)
def list_access_domain_policy(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'access:policy:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
result = [getaname(mainkey) for mainkey in mainkeys]
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_access_domain_policy, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
class AntiFlooding(BaseModel):
sampling: int = Field(default=2, ge=1, le=300, description='sampling time unit (in second)')
density: int = Field(default=20, ge=1, le=3000, description='number of request that allow in sampling time, then will be ignore within window time')
window: int = Field(default=600, ge=300, le=1200, description='evaluated window time in second')
threshold: int = Field(default=10, ge=1, le=3600, description='number of failure threshold that will be banned')
bantime: int = Field(default=600, ge=600, le=864000, description='firewall ban time in second')
class AuthFailure(BaseModel):
window: int = Field(default=600, ge=300, le=1200, description='evaluated window time in second')
threshold: int = Field(default=10, ge=1, le=3600, description='number of authentication failure threshold that will be banned')
bantime: int = Field(default=900, ge=600, le=864000, description='firewall ban time in second')
class AttackAvoid(BaseModel):
window: int = Field(default=18000, ge=3600, le=86400, description='evaluated window time in second')
threshold: int = Field(default=5, ge=1, le=3600, description='number of request threshold that will be banned')
bantime: int = Field(default=86400, ge=600, le=864000, description='firewall ban time in second')
class AccessService(BaseModel):
name: str = Field(regex=_NAME_, max_length=32, description='name of access service')
desc: Optional[str] = Field(default='access service', max_length=64, description='description')
server_header: Optional[str] = Field(max_length=64, description='Server Header')
trying_reason: str = Field(default='Trying', max_length=64, description='Trying Reason', hidden_field=True)
natping_from: str = Field(default='sip:keepalive@libre.sbc', max_length=64, description='natping from', hidden_field=True)
transports: List[TransportEnum] = Field(default=['udp', 'tcp'], min_items=1, max_items=3, description='list of bind transport protocol')
sip_address: str = Field(description='IP address via NetAlias use for SIP Signalling')
sip_port: int = Field(default=5060, ge=0, le=65535, description='sip port', hidden_field=True)
sips_port: int = Field(default=5061, ge=0, le=65535, description='sip tls port', hidden_field=True)
topology_hiding: Optional[str] = Field(description='topology hiding, you should never need to use', hidden_field=True)
antiflooding: Optional[AntiFlooding] = Field(description='antifloofing/ddos')
authfailure: AuthFailure = Field(description='authentication failure/bruteforce/intrusion detection')
attackavoid: AttackAvoid = Field(description='attack avoidance')
blackips: List[IPv4Network] = Field(default=[], max_items=1024, description='denied ip list')
whiteips: List[IPv4Network] = Field(default=[], max_items=1024 ,description='allowed ip list')
domains: List[str] = Field(min_items=1, max_items=8, description='list of policy domain')
@root_validator
def access_service_validation(cls, kvs):
kvs = jsonable_encoder(kvs)
domains = kvs.get('domains')
for domain in domains:
if not validators.domain(domain):
raise ValueError('Invalid domain name, please refer rfc1035')
if not rdbconn.exists(f'access:policy:{domain}'):
raise ValueError('Undefined domain')
sip_address = kvs.get('sip_address')
if not rdbconn.exists(f'base:netalias:{sip_address}'):
raise ValueError('nonexistent network alias')
topology_hiding = kvs.pop('topology_hiding', None)
if topology_hiding: kvs['topology_hiding'] = topology_hiding
blackips = kvs.get('blackips')
whiteips = kvs.get('whiteips')
if blackips and whiteips:
raise ValueError('only one of blackips/whiteips can be set')
return kvs
@librerouter.post("/libreapi/access/service", status_code=200)
def create_access_service(reqbody: AccessService, response: Response):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
data = jsonable_encoder(reqbody)
name = data.get('name')
domains = data.get('domains')
sip_address = data.get('sip_address')
# verification
name_key = f'access:service:{name}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent access layer'}; return
domain_engaged_prefix = 'engagement:access:policy'
for domain in domains:
if rdbconn.srandmember(f'{domain_engaged_prefix}:{domain}'):
response.status_code, result = 403, {'error': 'domain is used by other access service layer'}; return
pipe.hmset(name_key, redishash(data))
pipe.sadd('nameset:access:service', name)
for domain in domains:
pipe.sadd(f'{domain_engaged_prefix}:{domain}', name)
pipe.sadd(f'engagement:base:netalias:{sip_address}', name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event inbound interconnect create
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'access:service', 'action': 'create', 'name': name, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_access_service, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.put("/libreapi/access/service/{identifier}", status_code=200)
def update_access_service(reqbody: AccessService, response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid=get_request_uuid()
result = None
try:
pipe = rdbconn.pipeline()
data = jsonable_encoder(reqbody)
name = data.get('name')
domains = data.get('domains')
sip_address = data.get('sip_address')
# verification
name_key = f'access:service:{name}'
_name_key = f'access:service:{identifier}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent access layer'}; return
if name != identifier and rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent class name'}; return
domain_engaged_prefix = 'engagement:access:policy'
for domain in domains:
layer = rdbconn.srandmember(f'{domain_engaged_prefix}:{domain}')
if layer and layer != identifier:
response.status_code, result = 403, {'error': 'domain is used by other access service layer'}; return
_data = jsonhash(rdbconn.hgetall(_name_key))
_domains = _data.get('domains')
_sip_address = _data.get('sip_address')
for _domain in _domains:
pipe.srem(f'{domain_engaged_prefix}:{_domain}', identifier)
pipe.srem(f'engagement:base:netalias:{_sip_address}', _name_key)
pipe.srem(f'nameset:access:service', identifier)
pipe.sadd(f'nameset:access:service', name)
pipe.hmset(name_key, redishash(data))
for domain in domains:
pipe.sadd(f'{domain_engaged_prefix}:{domain}', name)
pipe.sadd(f'engagement:base:netalias:{sip_address}', name_key)
# remove the unintended-field
for _field in _data:
if _field not in data:
pipe.hdel(_name_key, _field)
if name != identifier:
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event inbound interconnect create
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'access:service', 'action': 'update', 'name': name, '_name': identifier, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_access_service, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/access/service/{identifier}", status_code=200)
def delete_access_service(response: Response, identifier: str=Path(..., regex=_NAME_)):
result = None
requestid = get_request_uuid()
try:
_name_key = f'access:service:{identifier}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent access layer'}; return
_domains = listify(rdbconn.hget(_name_key, 'domains'))
pipe = rdbconn.pipeline()
for _domain in _domains:
pipe.srem(f'engagement:access:policy:{_domain}', identifier)
_sip_address = rdbconn.hget(_name_key, 'sip_address')
pipe.srem(f'engagement:base:netalias:{_sip_address}', _name_key)
pipe.srem(f'nameset:access:service', identifier)
pipe.delete(_name_key)
pipe.execute()
response.status_code, result = 200, {'passed': True}
# fire-event inbound interconnect create
rdbconn.publish(CHANGE_CFG_CHANNEL, json.dumps({'portion': 'access:service', 'action': 'delete', '_name': identifier, 'requestid': requestid}))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_access_service, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/access/service/{identifier}", status_code=200)
def detail_access_service(response: Response, identifier: str=Path(..., regex=_NAME_)):
requestid=get_request_uuid()
result = None
try:
_name_key = f'access:service:{identifier}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent access layer'}; return
result = jsonhash(rdbconn.hgetall(_name_key))
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_access_service, requestid={requestid}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/access/service", status_code=200)
def list_access_service(response: Response):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'access:service:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
for mainkey in mainkeys:
pipe.hget(mainkey, 'desc')
descriptions = pipe.execute()
data = list()
for mainkey, description in zip(mainkeys, descriptions):
data.append({'name': getaname(mainkey), 'desc': description})
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_access_service, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
class NetDirectory(BaseModel):
domain: str = Field(description='user domain')
ip: IPv4Network = Field(description='IPv4 Address for IP auth')
port: int = Field(default=5060, ge=0, le=65535, description='farend destination port for arriving call')
transport: TransportEnum = Field(default='udp', description='farend transport protocol for arriving call')
class UserDirectory(BaseModel):
domain: str = Field(description='user domain')
id: str = Field(regex=_NAME_, max_length=16, description='user identifier')
secret: str = Field(min_length=8, max_length=32, description='password of digest auth for inbound')
@root_validator
def user_directory_validation(cls, kvs):
domain = kvs.get('domain')
if not validators.domain(domain):
raise ValueError('Invalid domain name, please refer rfc1035')
if not rdbconn.exists(f'access:policy:{domain}'):
raise ValueError('Undefined domain')
return kvs
@librerouter.post("/libreapi/access/directory/user", status_code=200)
def create_access_directory_user(reqbody: UserDirectory, response: Response):
result = None
try:
data = jsonable_encoder(reqbody)
domain = data.get('domain')
id = data.get('id')
name_key = f'access:dir:usr:{domain}:{id}'
if rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'existent user'}; return
secret = data.get('secret')
rdbconn.hmset(name_key, {'secret': secret, 'a1hash': hashlib.md5(f'{id}:{domain}:{secret}'.encode()).hexdigest()})
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=create_access_directory_user, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.patch("/libreapi/access/directory/user", status_code=200)
def update_access_directory_user(reqbody: UserDirectory, response: Response):
result = None
try:
data = jsonable_encoder(reqbody)
domain = data.get('domain')
id = data.get('id')
name_key = f'access:dir:usr:{domain}:{id}'
if not rdbconn.exists(name_key):
response.status_code, result = 403, {'error': 'nonexistent user'}; return
secret = data.get('secret')
rdbconn.hmset(name_key, {'secret': secret, 'a1hash': hashlib.md5(f'{id}:{domain}:{secret}'.encode()).hexdigest()})
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=update_access_directory_user, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.delete("/libreapi/access/directory/user/{domain}/{id}", status_code=200)
def delete_access_directory_user(response: Response, domain: str=Path(..., regex=_REALM_), id:str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'access:dir:usr:{domain}:{id}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent user'}; return
rdbconn.delete(_name_key)
response.status_code, result = 200, {'passed': True}
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=delete_access_directory_user, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/access/directory/user/{domain}/{id}", status_code=200)
def detail_access_directory_user(response: Response, domain: str=Path(..., regex=_REALM_), id:str=Path(..., regex=_NAME_)):
result = None
try:
_name_key = f'access:dir:usr:{domain}:{id}'
if not rdbconn.exists(_name_key):
response.status_code, result = 403, {'error': 'nonexistent user'}; return
result = rdbconn.hgetall(_name_key)
response.status_code = 200
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=detail_access_directory_user, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
@librerouter.get("/libreapi/access/directory/user/{domain}", status_code=200)
def list_access_directory_user(response: Response, domain: str=Path(..., regex=r'^[a-z][a-z0-9_\-\.]+$|^\*$')):
result = None
try:
pipe = rdbconn.pipeline()
KEYPATTERN = f'access:dir:usr:{domain}:*'
next, mainkeys = rdbconn.scan(0, KEYPATTERN, SCAN_COUNT)
while next:
next, tmpkeys = rdbconn.scan(next, KEYPATTERN, SCAN_COUNT)
mainkeys += tmpkeys
data = {}
for mainkey in mainkeys:
_, _, _, domain, id = listify(mainkey)
if domain in data: data[domain].append(id)
else: data[domain] = [id]
response.status_code, result = 200, data
except Exception as e:
response.status_code, result = 500, None
logify(f"module=liberator, space=libreapi, action=list_access_directory_user, requestid={get_request_uuid()}, exception={e}, traceback={traceback.format_exc()}")
finally:
return result
| 50.617665
| 285
| 0.638312
| 18,898
| 169,063
| 5.535612
| 0.0481
| 0.033075
| 0.045253
| 0.057125
| 0.785579
| 0.757848
| 0.729075
| 0.70187
| 0.669952
| 0.657898
| 0
| 0.013251
| 0.204581
| 169,063
| 3,339
| 286
| 50.632824
| 0.764672
| 0.062415
| 0
| 0.640945
| 0
| 0.03163
| 0.26247
| 0.11012
| 0
| 0
| 0
| 0
| 0
| 1
| 0.037887
| false
| 0.020507
| 0.005561
| 0.000348
| 0.199513
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
b5a6834a5076370e52af8191947d74baf0f5e8ff
| 11,475
|
py
|
Python
|
tests/test_optimizer.py
|
ar-nowaczynski/spaceopt
|
e87b26507e726ab5df027a4a850074f1fd3d0369
|
[
"MIT"
] | 46
|
2020-01-28T10:29:49.000Z
|
2021-09-04T20:18:01.000Z
|
tests/test_optimizer.py
|
ar-nowaczynski/spaceopt
|
e87b26507e726ab5df027a4a850074f1fd3d0369
|
[
"MIT"
] | 1
|
2021-04-21T09:44:15.000Z
|
2021-04-29T10:39:48.000Z
|
tests/test_optimizer.py
|
ar-nowaczynski/spaceopt
|
e87b26507e726ab5df027a4a850074f1fd3d0369
|
[
"MIT"
] | null | null | null |
import random
from typing import Dict
from spaceopt import SpaceOpt
random.seed(123456)
def search_space() -> Dict[str, list]:
return {
"a": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
"b": [-5.5, -4.4, -3.3, -2.2, -1.1, 0.0, 1.1, 2.2, 3.3, 4.4, 5.5],
"c": [128, 256, 512, 1024],
"d": ["ABC", "IJK", "XYZ"],
"e": [True, False],
"f": [10000],
}
def test_SpaceOpt__init__() -> None:
SpaceOpt(search_space=search_space(), target_name="y", objective="min")
SpaceOpt(search_space=search_space(), target_name="y", objective="max")
SpaceOpt(search_space=search_space(), target_name="score", objective="maximize")
SpaceOpt(search_space=search_space(), target_name="max", objective="minimize")
try:
SpaceOpt(search_space=search_space(), target_name=1, objective="min")
except Exception as e:
assert isinstance(e, TypeError)
assert str(e) == (
"target_name is of type <class 'int'>,"
" but it should be of type <class 'str'>."
)
try:
SpaceOpt(search_space=search_space(), target_name=None, objective="min")
except Exception as e:
assert isinstance(e, TypeError)
assert str(e) == (
"target_name is of type <class 'NoneType'>,"
" but it should be of type <class 'str'>."
)
try:
SpaceOpt(search_space=search_space(), target_name="", objective="min")
except Exception as e:
assert isinstance(e, ValueError)
assert str(e) == "target_name is empty."
try:
SpaceOpt(search_space=search_space(), target_name="y", objective="maxi")
except Exception as e:
assert isinstance(e, ValueError)
assert str(e) == (
"objective should be one of: ('maximize', 'minimize', 'max', 'min')."
)
try:
SpaceOpt(search_space=search_space(), target_name="b", objective="min")
except Exception as e:
assert isinstance(e, RuntimeError)
assert str(e) == (
"target_name='b' should not be in search space variables:"
" ['a', 'b', 'c', 'd', 'e', 'f']."
)
def test_SpaceOpt_append_evaluated_spoint() -> None:
spaceopt = SpaceOpt(search_space=search_space(), target_name="y", objective="min")
try:
spaceopt.append_evaluated_spoint(["a", "b", "c", "d", "e"])
except Exception as e:
assert isinstance(e, TypeError)
assert str(e) == (
"evaluated_spoint is of type <class 'list'>,"
" but it should be of type <class 'dict'>."
)
try:
spaceopt.append_evaluated_spoint(
{"a": 16, "b": 3.3, "c": 512, "d": "ABC", "e": False, "f": 10000}
)
except Exception as e:
assert isinstance(e, ValueError)
assert str(e) == (
"spoint={'a': 16, 'b': 3.3, 'c': 512, 'd': 'ABC', 'e': False, 'f': 10000}"
" is not evaluated, target_name='y' is not found."
)
try:
spaceopt.append_evaluated_spoint(
{"a": 16, "b": 3.3, "c": 512, "d": "ABC", "e": False, "f": 10000, "y": 1}
)
except Exception as e:
assert isinstance(e, TypeError)
assert str(e) == (
"evaluated_spoint has 'y' with value=1 of type <class 'int'>,"
" but it should be of type <class 'float'>."
)
spaceopt.append_evaluated_spoint(
{"a": 16, "b": 3.3, "c": 512, "d": "ABC", "e": False, "f": 10000, "y": 1.0}
)
def test_SpaceOpt_get_random() -> None:
spaceopt = SpaceOpt(search_space=search_space(), target_name="y", objective="min")
try:
spaceopt.get_random(num_spoints=1.0)
except Exception as e:
assert isinstance(e, TypeError)
assert str(e) == (
"num_spoints is of type <class 'float'>,"
" but it should be of type <class 'int'>."
)
try:
spaceopt.get_random(num_spoints=0)
except Exception as e:
assert isinstance(e, ValueError)
assert str(e) == "num_spoints should be greater than 0."
try:
spaceopt.get_random(sample_size=100.0)
except Exception as e:
assert isinstance(e, TypeError)
assert str(e) == (
"sample_size is of type <class 'float'>,"
" but it should be of type <class 'int'>."
)
try:
spaceopt.get_random(sample_size=0)
except Exception as e:
assert isinstance(e, ValueError)
assert str(e) == "sample_size should be greater than 0."
spoints = spaceopt.get_random(num_spoints=5, sample_size=1000)
assert isinstance(spoints, list)
assert len(spoints) == 5
spoint = spaceopt.get_random(num_spoints=1, sample_size=10)
assert isinstance(spoint, dict)
assert set(spoint.keys()) == set(spoints[-1].keys())
def test_SpaceOpt_fit_predict() -> None:
spaceopt = SpaceOpt(search_space=search_space(), target_name="y", objective="min")
try:
spaceopt.fit_predict(num_spoints=2.0)
except Exception as e:
assert isinstance(e, TypeError)
assert str(e) == (
"num_spoints is of type <class 'float'>,"
" but it should be of type <class 'int'>."
)
try:
spaceopt.fit_predict(num_spoints=0)
except Exception as e:
assert isinstance(e, ValueError)
assert str(e) == "num_spoints should be greater than 0."
try:
spaceopt.fit_predict(num_boost_round=2048.0)
except Exception as e:
assert isinstance(e, TypeError)
assert str(e) == (
"num_boost_round is of type <class 'float'>,"
" but it should be of type <class 'int'>."
)
try:
spaceopt.fit_predict(num_boost_round=0)
except Exception as e:
assert isinstance(e, ValueError)
assert str(e) == "num_boost_round should be greater than 0."
try:
spaceopt.fit_predict(sample_size=100.0)
except Exception as e:
assert isinstance(e, TypeError)
assert str(e) == (
"sample_size is of type <class 'float'>,"
" but it should be of type <class 'int'>."
)
try:
spaceopt.fit_predict(sample_size=0)
except Exception as e:
assert isinstance(e, ValueError)
assert str(e) == "sample_size should be greater than 0."
for i in range(10):
spoint = spaceopt.fit_predict(
num_spoints=1, num_boost_round=100, sample_size=100
)
assert isinstance(spoint, dict)
spoint["y"] = random.uniform(-1, 1)
spaceopt.append_evaluated_spoint(spoint)
def test_SpaceOpt__sample_random_spoints() -> None:
spaceopt = SpaceOpt(search_space=search_space(), target_name="y", objective="min")
try:
spaceopt._sample_random_spoints(sample_size=100.0)
except Exception as e:
assert isinstance(e, TypeError)
assert str(e) == (
"sample_size is of type <class 'float'>,"
" but it should be of type <class 'int'>."
)
try:
spaceopt._sample_random_spoints(sample_size=0)
except Exception as e:
assert isinstance(e, ValueError)
assert str(e) == "sample_size should be greater than 0."
spoints = spaceopt._sample_random_spoints(sample_size=10)
assert isinstance(spoints, list)
assert len(spoints) == 10
spoints = spaceopt._sample_random_spoints(sample_size=1)
assert isinstance(spoints, list)
assert len(spoints) == 1
def test_SpaceOpt__sample_unevaluated_unique_spoints() -> None:
spaceopt = SpaceOpt(search_space=search_space(), target_name="y", objective="min")
try:
spaceopt._sample_unevaluated_unique_spoints(sample_size=100.0)
except Exception as e:
assert isinstance(e, TypeError)
assert str(e) == (
"sample_size is of type <class 'float'>,"
" but it should be of type <class 'int'>."
)
try:
spaceopt._sample_unevaluated_unique_spoints(sample_size=0)
except Exception as e:
assert isinstance(e, ValueError)
assert str(e) == "sample_size should be greater than 0."
try:
spaceopt._sample_unevaluated_unique_spoints(
sample_size=100, max_num_retries=10.0
)
except Exception as e:
assert isinstance(e, TypeError)
assert str(e) == (
"max_num_retries is of type <class 'float'>,"
" but it should be of type <class 'int'>."
)
try:
spaceopt._sample_unevaluated_unique_spoints(sample_size=1, max_num_retries=0)
except Exception as e:
assert isinstance(e, ValueError)
assert str(e) == "max_num_retries should be greater than 0."
spaceopt = SpaceOpt(
search_space={"w": ["W1", "W2"], "b": [5]}, target_name="y", objective="min"
)
spaceopt.append_evaluated_spoint({"w": "W1", "b": 5, "y": 0.1})
spoints = spaceopt._sample_unevaluated_unique_spoints(
sample_size=100, max_num_retries=100
)
assert len(spoints) == 1
assert spoints[0]["w"] == "W2"
spaceopt.append_evaluated_spoint({"w": "W2", "b": 5, "y": 0.2})
try:
spaceopt._sample_unevaluated_unique_spoints(
sample_size=100, max_num_retries=100
)
except Exception as e:
assert isinstance(e, RuntimeError)
assert str(e) == (
"could not sample any new spoints -"
" search_space is fully explored or random sampling was unfortunate."
"\nsearch_space.size = 2"
"\nnum evaluated spoints = 2"
"\nnum unevaluated spoints = 0"
)
def test_SpaceOpt__str__() -> None:
spaceopt = SpaceOpt(search_space=search_space(), target_name="y", objective="min")
assert str(spaceopt) == (
"SpaceOpt(\n"
" Space(\n"
" Variable(\n"
" name='a',\n"
" values=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],\n"
" vtype=<class 'int'>,\n"
" is_categorical=False\n"
" ),\n"
" Variable(\n"
" name='b',\n"
" values=[-5.5, -4.4, -3.3, -2.2, -1.1, 0.0, 1.1, 2.2, 3.3, 4.4, 5.5],\n"
" vtype=<class 'float'>,\n"
" is_categorical=False\n"
" ),\n"
" Variable(\n"
" name='c',\n"
" values=[128, 256, 512, 1024],\n"
" vtype=<class 'int'>,\n"
" is_categorical=False\n"
" ),\n"
" Variable(\n"
" name='d',\n"
" values=['ABC', 'IJK', 'XYZ'],\n"
" vtype=<class 'str'>,\n"
" is_categorical=True\n"
" ),\n"
" Variable(\n"
" name='e',\n"
" values=[True, False],\n"
" vtype=<class 'bool'>,\n"
" is_categorical=False\n"
" ),\n"
" Variable(\n"
" name='f',\n"
" values=[10000],\n"
" vtype=<class 'int'>,\n"
" is_categorical=False\n"
" ),\n"
" size=5544\n"
" ),\n"
" target_name='y',\n"
" objective=min\n"
")"
)
| 33.651026
| 106
| 0.554684
| 1,434
| 11,475
| 4.288006
| 0.098326
| 0.060823
| 0.069117
| 0.073183
| 0.802732
| 0.76793
| 0.737356
| 0.6819
| 0.667426
| 0.625142
| 0
| 0.039095
| 0.306754
| 11,475
| 340
| 107
| 33.75
| 0.733878
| 0
| 0
| 0.531034
| 0
| 0.010345
| 0.26719
| 0.011416
| 0
| 0
| 0
| 0
| 0.213793
| 1
| 0.027586
| false
| 0
| 0.010345
| 0.003448
| 0.041379
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
a91d1630617d27d8e48231bf87e684c7e57f2179
| 809
|
py
|
Python
|
game/utils/patch.py
|
alviproject/birdstorm
|
439ff97ee40c3dd93b8fa8bfca557bdee9c036e1
|
[
"MIT"
] | null | null | null |
game/utils/patch.py
|
alviproject/birdstorm
|
439ff97ee40c3dd93b8fa8bfca557bdee9c036e1
|
[
"MIT"
] | null | null | null |
game/utils/patch.py
|
alviproject/birdstorm
|
439ff97ee40c3dd93b8fa8bfca557bdee9c036e1
|
[
"MIT"
] | null | null | null |
import rest_framework.fields
from sockjs.tornado.basehandler import BaseHandler
#TODO add a comment
from sockjs.tornado.transports.websocket import WebSocketTransport
def strip_multiple_choice_msg(_):
return ''
rest_framework.fields.strip_multiple_choice_msg = strip_multiple_choice_msg
#mitigates following exception raised when any error will occur during processing SockJS message
# > AttributeError: 'WebSocketTransport' object has no attribute 'abort_connection'
def abort_connection(*args, **kwargs):
pass
WebSocketTransport.abort_connection = abort_connection
#TODO send pull request to sockjs-tornado
def finish(self, *args, **kwargs):
"""Tornado `finish` handler"""
self._log_disconnect()
super(BaseHandler, self).finish(*args, **kwargs)
BaseHandler.finish = finish
| 24.515152
| 96
| 0.7911
| 97
| 809
| 6.412371
| 0.546392
| 0.096463
| 0.09164
| 0.106109
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.128554
| 809
| 32
| 97
| 25.28125
| 0.88227
| 0.321384
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.03125
| 0
| 1
| 0.230769
| false
| 0.076923
| 0.230769
| 0.076923
| 0.538462
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
a97d54833da6e0b0b4a6065b4b28a4a228a04f02
| 98
|
py
|
Python
|
djoser/webauthn/apps.py
|
ulgens/djoser
|
c62371e3f9a8bbad2eaf55ffd0efad6eb6c02f26
|
[
"MIT"
] | null | null | null |
djoser/webauthn/apps.py
|
ulgens/djoser
|
c62371e3f9a8bbad2eaf55ffd0efad6eb6c02f26
|
[
"MIT"
] | null | null | null |
djoser/webauthn/apps.py
|
ulgens/djoser
|
c62371e3f9a8bbad2eaf55ffd0efad6eb6c02f26
|
[
"MIT"
] | null | null | null |
from django.apps import AppConfig
class WebauthnConfig(AppConfig):
name = "djoser.webauthn"
| 16.333333
| 33
| 0.765306
| 11
| 98
| 6.818182
| 0.909091
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.153061
| 98
| 5
| 34
| 19.6
| 0.903614
| 0
| 0
| 0
| 0
| 0
| 0.153061
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
a983ef401af7d6fd90105b091fff8c3208a5624a
| 143
|
py
|
Python
|
setup.py
|
NicholasBermuda/multilevelRBF
|
23059d3bf0df99724843fb8753b42233a1a872e6
|
[
"MIT"
] | null | null | null |
setup.py
|
NicholasBermuda/multilevelRBF
|
23059d3bf0df99724843fb8753b42233a1a872e6
|
[
"MIT"
] | null | null | null |
setup.py
|
NicholasBermuda/multilevelRBF
|
23059d3bf0df99724843fb8753b42233a1a872e6
|
[
"MIT"
] | null | null | null |
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize(["rbf.pyx", "rbf.pxd", "forms.pyx"])
)
| 23.833333
| 64
| 0.72028
| 20
| 143
| 5.1
| 0.7
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.13986
| 143
| 6
| 65
| 23.833333
| 0.829268
| 0
| 0
| 0
| 0
| 0
| 0.159722
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.4
| 0
| 0.4
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
8d41601f01e9c5e17574d8fc8d65115ad27159c5
| 117
|
py
|
Python
|
suricataparser/__init__.py
|
m-chrome/py-suricataparser
|
607151674cb09601661f1d1b7bbb24f79bdd183a
|
[
"Apache-2.0"
] | 10
|
2021-03-29T21:45:37.000Z
|
2022-03-27T15:42:28.000Z
|
suricataparser/__init__.py
|
m-chrome/py-suricataparser
|
607151674cb09601661f1d1b7bbb24f79bdd183a
|
[
"Apache-2.0"
] | null | null | null |
suricataparser/__init__.py
|
m-chrome/py-suricataparser
|
607151674cb09601661f1d1b7bbb24f79bdd183a
|
[
"Apache-2.0"
] | 3
|
2021-07-22T21:28:22.000Z
|
2022-03-18T17:44:44.000Z
|
from suricataparser.parse import parse_rule, parse_file
from suricataparser.rule import Rule
__version__ = "0.0.7"
| 19.5
| 55
| 0.811966
| 17
| 117
| 5.235294
| 0.529412
| 0.404494
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.029126
| 0.119658
| 117
| 5
| 56
| 23.4
| 0.834951
| 0
| 0
| 0
| 0
| 0
| 0.042735
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.666667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
8d8c394e9c913458bb50991187417b82ec491d67
| 60,341
|
py
|
Python
|
release/stubs.min/Wms/RemotingObjects/Outbound/__init__.py
|
tranconbv/ironpython-stubs
|
a601759e6c6819beff8e6b639d18a24b7e351851
|
[
"MIT"
] | null | null | null |
release/stubs.min/Wms/RemotingObjects/Outbound/__init__.py
|
tranconbv/ironpython-stubs
|
a601759e6c6819beff8e6b639d18a24b7e351851
|
[
"MIT"
] | null | null | null |
release/stubs.min/Wms/RemotingObjects/Outbound/__init__.py
|
tranconbv/ironpython-stubs
|
a601759e6c6819beff8e6b639d18a24b7e351851
|
[
"MIT"
] | null | null | null |
# encoding: utf-8
# module Wms.RemotingObjects.Outbound calls itself Outbound
# from Wms.RemotingObjects,Version=1.23.1.0,Culture=neutral,PublicKeyToken=null
# by generator 1.145
# no doc
# no important
from System.Collections.Generic import *
from ..__init__ import *
# no functions
# classes
class AllocationProfile(object):
""" AllocationProfile() """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return AllocationProfile()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
Description=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Description(self: AllocationProfile) -> str
Set: Description(self: AllocationProfile)=value
"""
Id=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Id(self: AllocationProfile) -> int
Set: Id(self: AllocationProfile)=value
"""
Name=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Name(self: AllocationProfile) -> str
Set: Name(self: AllocationProfile)=value
"""
class AllocationProfiles(List):
""" AllocationProfiles() """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return AllocationProfiles()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def __getitem__(self,*args):
""" x.__getitem__(y) <==> x[y] """
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __iter__(self,*args):
""" __iter__(self: IEnumerable) -> object """
pass
def __reduce_ex__(self,*args):
pass
def __setitem__(self,*args):
""" x.__setitem__(i,y) <==> x[i]= """
pass
DisplayMember='Name'
ValueMember='Id'
class GetHistoryOutboundOrderCustomersArgs(object):
""" GetHistoryOutboundOrderCustomersArgs() """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return GetHistoryOutboundOrderCustomersArgs()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
CustomerNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerNumber(self: GetHistoryOutboundOrderCustomersArgs) -> str
Set: CustomerNumber(self: GetHistoryOutboundOrderCustomersArgs)=value
"""
Filter=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Filter(self: GetHistoryOutboundOrderCustomersArgs) -> str
Set: Filter(self: GetHistoryOutboundOrderCustomersArgs)=value
"""
Paging=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Paging(self: GetHistoryOutboundOrderCustomersArgs) -> PagingParams
Set: Paging(self: GetHistoryOutboundOrderCustomersArgs)=value
"""
Warehouse=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Warehouse(self: GetHistoryOutboundOrderCustomersArgs) -> str
Set: Warehouse(self: GetHistoryOutboundOrderCustomersArgs)=value
"""
class GetHistoryOutboundOrderItemArgs(object):
""" GetHistoryOutboundOrderItemArgs() """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return GetHistoryOutboundOrderItemArgs()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
CustomerNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerNumber(self: GetHistoryOutboundOrderItemArgs) -> str
Set: CustomerNumber(self: GetHistoryOutboundOrderItemArgs)=value
"""
DeliveryDate=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: DeliveryDate(self: GetHistoryOutboundOrderItemArgs) -> Nullable[DateTime]
Set: DeliveryDate(self: GetHistoryOutboundOrderItemArgs)=value
"""
ItemCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemCode(self: GetHistoryOutboundOrderItemArgs) -> str
Set: ItemCode(self: GetHistoryOutboundOrderItemArgs)=value
"""
OrderNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: OrderNumber(self: GetHistoryOutboundOrderItemArgs) -> str
Set: OrderNumber(self: GetHistoryOutboundOrderItemArgs)=value
"""
Paging=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Paging(self: GetHistoryOutboundOrderItemArgs) -> PagingParams
Set: Paging(self: GetHistoryOutboundOrderItemArgs)=value
"""
SearchText=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: SearchText(self: GetHistoryOutboundOrderItemArgs) -> str
Set: SearchText(self: GetHistoryOutboundOrderItemArgs)=value
"""
class GetHistoryOutboundOrdersArgs(object):
""" GetHistoryOutboundOrdersArgs() """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return GetHistoryOutboundOrdersArgs()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
CacheKeyOfReceipt=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CacheKeyOfReceipt(self: GetHistoryOutboundOrdersArgs) -> CacheKey
Set: CacheKeyOfReceipt(self: GetHistoryOutboundOrdersArgs)=value
"""
CustomerNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerNumber(self: GetHistoryOutboundOrdersArgs) -> str
Set: CustomerNumber(self: GetHistoryOutboundOrdersArgs)=value
"""
DecreaseQuantitiesWithActieveAdhocRma=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: DecreaseQuantitiesWithActieveAdhocRma(self: GetHistoryOutboundOrdersArgs) -> bool
Set: DecreaseQuantitiesWithActieveAdhocRma(self: GetHistoryOutboundOrdersArgs)=value
"""
Filter=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Filter(self: GetHistoryOutboundOrdersArgs) -> str
Set: Filter(self: GetHistoryOutboundOrdersArgs)=value
"""
IncludeOrdersThatCanBeReturned=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: IncludeOrdersThatCanBeReturned(self: GetHistoryOutboundOrdersArgs) -> bool
Set: IncludeOrdersThatCanBeReturned(self: GetHistoryOutboundOrdersArgs)=value
"""
ItemCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemCode(self: GetHistoryOutboundOrdersArgs) -> str
Set: ItemCode(self: GetHistoryOutboundOrdersArgs)=value
"""
OrderNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: OrderNumber(self: GetHistoryOutboundOrdersArgs) -> str
Set: OrderNumber(self: GetHistoryOutboundOrdersArgs)=value
"""
Paging=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Paging(self: GetHistoryOutboundOrdersArgs) -> PagingParams
Set: Paging(self: GetHistoryOutboundOrdersArgs)=value
"""
class GetOutboundOrdersArgs(object):
""" GetOutboundOrdersArgs() """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return GetOutboundOrdersArgs()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
OrderNumbers=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: OrderNumbers(self: GetOutboundOrdersArgs) -> List[str]
Set: OrderNumbers(self: GetOutboundOrdersArgs)=value
"""
SearchText=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: SearchText(self: GetOutboundOrdersArgs) -> str
Set: SearchText(self: GetOutboundOrdersArgs)=value
"""
class HistoryOutboundOrder(DbObject):
""" """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return HistoryOutboundOrder()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def Clone(self):
""" Clone(self: HistoryOutboundOrder) -> object """
pass
def Equals(self,obj):
""" Equals(self: HistoryOutboundOrder,obj: object) -> bool """
pass
def GetHashCode(self,orderNumber=None,dateOfDelivery=None):
"""
GetHashCode(self: HistoryOutboundOrder) -> int
GetHashCode(orderNumber: str,dateOfDelivery: DateTime) -> int
"""
pass
def GetHashCodeOfCustomer(self):
""" GetHashCodeOfCustomer(self: HistoryOutboundOrder) -> int """
pass
def __eq__(self,*args):
""" x.__eq__(y) <==> x==y """
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __ne__(self,*args):
pass
def __reduce_ex__(self,*args):
pass
AllowPartialDelivery=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: AllowPartialDelivery(self: HistoryOutboundOrder) -> PartialDeliveryTypeEnum
Set: AllowPartialDelivery(self: HistoryOutboundOrder)=value
"""
AllowPartialDeliveryAsString=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: AllowPartialDeliveryAsString(self: HistoryOutboundOrder) -> str
"""
Backorder=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Backorder(self: HistoryOutboundOrder) -> bool
Set: Backorder(self: HistoryOutboundOrder)=value
"""
CustomerAddressLine1=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerAddressLine1(self: HistoryOutboundOrder) -> str
Set: CustomerAddressLine1(self: HistoryOutboundOrder)=value
"""
CustomerAddressLine2=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerAddressLine2(self: HistoryOutboundOrder) -> str
Set: CustomerAddressLine2(self: HistoryOutboundOrder)=value
"""
CustomerAddressLine3=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerAddressLine3(self: HistoryOutboundOrder) -> str
Set: CustomerAddressLine3(self: HistoryOutboundOrder)=value
"""
CustomerCity=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerCity(self: HistoryOutboundOrder) -> str
Set: CustomerCity(self: HistoryOutboundOrder)=value
"""
CustomerContact=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerContact(self: HistoryOutboundOrder) -> str
Set: CustomerContact(self: HistoryOutboundOrder)=value
"""
CustomerContactEmail=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerContactEmail(self: HistoryOutboundOrder) -> str
Set: CustomerContactEmail(self: HistoryOutboundOrder)=value
"""
CustomerCountryCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerCountryCode(self: HistoryOutboundOrder) -> str
Set: CustomerCountryCode(self: HistoryOutboundOrder)=value
"""
CustomerCountryName=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerCountryName(self: HistoryOutboundOrder) -> str
Set: CustomerCountryName(self: HistoryOutboundOrder)=value
"""
CustomerEoriNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerEoriNumber(self: HistoryOutboundOrder) -> str
Set: CustomerEoriNumber(self: HistoryOutboundOrder)=value
"""
CustomerInvoiceAddressLine1=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceAddressLine1(self: HistoryOutboundOrder) -> str
Set: CustomerInvoiceAddressLine1(self: HistoryOutboundOrder)=value
"""
CustomerInvoiceAddressLine2=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceAddressLine2(self: HistoryOutboundOrder) -> str
Set: CustomerInvoiceAddressLine2(self: HistoryOutboundOrder)=value
"""
CustomerInvoiceAddressLine3=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceAddressLine3(self: HistoryOutboundOrder) -> str
Set: CustomerInvoiceAddressLine3(self: HistoryOutboundOrder)=value
"""
CustomerInvoiceCity=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceCity(self: HistoryOutboundOrder) -> str
Set: CustomerInvoiceCity(self: HistoryOutboundOrder)=value
"""
CustomerInvoiceContact=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceContact(self: HistoryOutboundOrder) -> str
Set: CustomerInvoiceContact(self: HistoryOutboundOrder)=value
"""
CustomerInvoiceContactEmail=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceContactEmail(self: HistoryOutboundOrder) -> str
Set: CustomerInvoiceContactEmail(self: HistoryOutboundOrder)=value
"""
CustomerInvoiceCountryCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceCountryCode(self: HistoryOutboundOrder) -> str
Set: CustomerInvoiceCountryCode(self: HistoryOutboundOrder)=value
"""
CustomerInvoiceCountryName=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceCountryName(self: HistoryOutboundOrder) -> str
Set: CustomerInvoiceCountryName(self: HistoryOutboundOrder)=value
"""
CustomerInvoiceName=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceName(self: HistoryOutboundOrder) -> str
Set: CustomerInvoiceName(self: HistoryOutboundOrder)=value
"""
CustomerInvoiceNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceNumber(self: HistoryOutboundOrder) -> str
Set: CustomerInvoiceNumber(self: HistoryOutboundOrder)=value
"""
CustomerInvoicePhoneNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoicePhoneNumber(self: HistoryOutboundOrder) -> str
Set: CustomerInvoicePhoneNumber(self: HistoryOutboundOrder)=value
"""
CustomerInvoiceState=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceState(self: HistoryOutboundOrder) -> str
Set: CustomerInvoiceState(self: HistoryOutboundOrder)=value
"""
CustomerInvoiceZipCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceZipCode(self: HistoryOutboundOrder) -> str
Set: CustomerInvoiceZipCode(self: HistoryOutboundOrder)=value
"""
CustomerName=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerName(self: HistoryOutboundOrder) -> str
Set: CustomerName(self: HistoryOutboundOrder)=value
"""
CustomerNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerNumber(self: HistoryOutboundOrder) -> str
Set: CustomerNumber(self: HistoryOutboundOrder)=value
"""
CustomerPackageSlipLayout=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerPackageSlipLayout(self: HistoryOutboundOrder) -> str
Set: CustomerPackageSlipLayout(self: HistoryOutboundOrder)=value
"""
CustomerPhoneNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerPhoneNumber(self: HistoryOutboundOrder) -> str
Set: CustomerPhoneNumber(self: HistoryOutboundOrder)=value
"""
CustomerReference=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerReference(self: HistoryOutboundOrder) -> str
Set: CustomerReference(self: HistoryOutboundOrder)=value
"""
CustomerState=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerState(self: HistoryOutboundOrder) -> str
Set: CustomerState(self: HistoryOutboundOrder)=value
"""
CustomerZipCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerZipCode(self: HistoryOutboundOrder) -> str
Set: CustomerZipCode(self: HistoryOutboundOrder)=value
"""
DateOfDelivery=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: DateOfDelivery(self: HistoryOutboundOrder) -> DateTime
Set: DateOfDelivery(self: HistoryOutboundOrder)=value
"""
DateOrdered=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: DateOrdered(self: HistoryOutboundOrder) -> DateTime
Set: DateOrdered(self: HistoryOutboundOrder)=value
"""
DbKey=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: DbKey(self: HistoryOutboundOrder) -> int
Set: DbKey(self: HistoryOutboundOrder)=value
"""
DeliveryMethod=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: DeliveryMethod(self: HistoryOutboundOrder) -> str
Set: DeliveryMethod(self: HistoryOutboundOrder)=value
"""
Description=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Description(self: HistoryOutboundOrder) -> str
Set: Description(self: HistoryOutboundOrder)=value
"""
Id=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Id(self: HistoryOutboundOrder) -> int
"""
Notes=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Notes(self: HistoryOutboundOrder) -> str
Set: Notes(self: HistoryOutboundOrder)=value
"""
Number=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Number(self: HistoryOutboundOrder) -> str
Set: Number(self: HistoryOutboundOrder)=value
"""
NumberOfItems=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: NumberOfItems(self: HistoryOutboundOrder) -> int
Set: NumberOfItems(self: HistoryOutboundOrder)=value
"""
OrderAmountDelivered=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: OrderAmountDelivered(self: HistoryOutboundOrder) -> Decimal
Set: OrderAmountDelivered(self: HistoryOutboundOrder)=value
"""
OrderAmountTotal=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: OrderAmountTotal(self: HistoryOutboundOrder) -> Decimal
Set: OrderAmountTotal(self: HistoryOutboundOrder)=value
"""
ProjectCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ProjectCode(self: HistoryOutboundOrder) -> str
Set: ProjectCode(self: HistoryOutboundOrder)=value
"""
ProjectName=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ProjectName(self: HistoryOutboundOrder) -> str
Set: ProjectName(self: HistoryOutboundOrder)=value
"""
QuantityDelivered=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: QuantityDelivered(self: HistoryOutboundOrder) -> Decimal
Set: QuantityDelivered(self: HistoryOutboundOrder)=value
"""
QuantityOrdered=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: QuantityOrdered(self: HistoryOutboundOrder) -> Decimal
Set: QuantityOrdered(self: HistoryOutboundOrder)=value
"""
RoutingCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: RoutingCode(self: HistoryOutboundOrder) -> str
Set: RoutingCode(self: HistoryOutboundOrder)=value
"""
SelectionCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: SelectionCode(self: HistoryOutboundOrder) -> str
Set: SelectionCode(self: HistoryOutboundOrder)=value
"""
SelectionCodeDescription=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: SelectionCodeDescription(self: HistoryOutboundOrder) -> str
Set: SelectionCodeDescription(self: HistoryOutboundOrder)=value
"""
Type=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Type(self: HistoryOutboundOrder) -> OutboundOrderTypeEnum
"""
Warehouse=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Warehouse(self: HistoryOutboundOrder) -> str
Set: Warehouse(self: HistoryOutboundOrder)=value
"""
class OutboundOrderLine(DbObject):
""" """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return OutboundOrderLine()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def Clone(self):
""" Clone(self: OutboundOrderLine) -> object """
pass
def GetHashCode(self):
""" GetHashCode(self: OutboundOrderLine) -> int """
pass
def IsBatchNumberItemCheck(self,checkRegistration):
"""
IsBatchNumberItemCheck(self: OutboundOrderLine,checkRegistration: bool) -> bool
Checks if the item is a batchnumber item.
checkRegistration: True if the batchnumber registration should be checked,false if just the property should be returned.
Returns: True if the check is ignored and the item is a batch item,or when the itemid registration is set to
complete (means the numers are registered throughout the
whole process).
False if the check is ignored and the item is not a batch item,or when the itemids are registered
during delivery only.
"""
pass
def IsSerialNumberItemCheck(self,checkRegistration):
"""
IsSerialNumberItemCheck(self: OutboundOrderLine,checkRegistration: bool) -> bool
Checks if the item is a serialnumber item.
checkRegistration: True if the serialnumber registration should be checked,false if just the property should be returned.
Returns: True if the check is ignored and the item is a serial item,or when the itemid registration is set to
complete (means the numers are registered throughout the
whole process).
False if the check is ignored and the item is not a serial item,or when the itemids are registered
during delivery only.
"""
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __reduce_ex__(self,*args):
pass
BatchId=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: BatchId(self: OutboundOrderLine) -> Guid
Set: BatchId(self: OutboundOrderLine)=value
"""
CustomerName=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerName(self: OutboundOrderLine) -> str
Set: CustomerName(self: OutboundOrderLine)=value
"""
CustomFields=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomFields(self: OutboundOrderLine) -> SerializableDictionary[str,object]
Set: CustomFields(self: OutboundOrderLine)=value
"""
DateOfDelivery=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: DateOfDelivery(self: OutboundOrderLine) -> DateTime
Set: DateOfDelivery(self: OutboundOrderLine)=value
"""
DefaultVendorBarcode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: DefaultVendorBarcode(self: OutboundOrderLine) -> str
Set: DefaultVendorBarcode(self: OutboundOrderLine)=value
"""
DefaultVendorItemCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: DefaultVendorItemCode(self: OutboundOrderLine) -> str
Set: DefaultVendorItemCode(self: OutboundOrderLine)=value
"""
GTINCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""The GS1 GTIN code of this item
Get: GTINCode(self: OutboundOrderLine) -> str
Set: GTINCode(self: OutboundOrderLine)=value
"""
HistoryId=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: HistoryId(self: OutboundOrderLine) -> int
Set: HistoryId(self: OutboundOrderLine)=value
"""
Id=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Id(self: OutboundOrderLine) -> int
Set: Id(self: OutboundOrderLine)=value
"""
IsBatchNumberItem=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: IsBatchNumberItem(self: OutboundOrderLine) -> bool
Set: IsBatchNumberItem(self: OutboundOrderLine)=value
"""
IsFractionAllowed=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: IsFractionAllowed(self: OutboundOrderLine) -> bool
Set: IsFractionAllowed(self: OutboundOrderLine)=value
"""
IsSerialNumberItem=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: IsSerialNumberItem(self: OutboundOrderLine) -> bool
Set: IsSerialNumberItem(self: OutboundOrderLine)=value
"""
ItemBrand=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: ItemBrand(self: OutboundOrderLine) -> str
Set: ItemBrand(self: OutboundOrderLine)=value
"""
ItemCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: ItemCode(self: OutboundOrderLine) -> str
Set: ItemCode(self: OutboundOrderLine)=value
"""
ItemDescription=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: ItemDescription(self: OutboundOrderLine) -> str
Set: ItemDescription(self: OutboundOrderLine)=value
"""
ItemDimensions=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemDimensions(self: OutboundOrderLine) -> Dimensions
Set: ItemDimensions(self: OutboundOrderLine)=value
"""
ItemIdentifierAssigned=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemIdentifierAssigned(self: OutboundOrderLine) -> bool
Set: ItemIdentifierAssigned(self: OutboundOrderLine)=value
"""
ItemIdRegistration=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemIdRegistration(self: OutboundOrderLine) -> ItemIdentificationRegistration
Set: ItemIdRegistration(self: OutboundOrderLine)=value
"""
ItemLongDescription=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemLongDescription(self: OutboundOrderLine) -> str
Set: ItemLongDescription(self: OutboundOrderLine)=value
"""
ItemPackLocations=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemPackLocations(self: OutboundOrderLine) -> ItemPackLocations
Set: ItemPackLocations(self: OutboundOrderLine)=value
"""
ItemPickLocations=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemPickLocations(self: OutboundOrderLine) -> ItemPickLocations
Set: ItemPickLocations(self: OutboundOrderLine)=value
"""
ItemPurchasePrice=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemPurchasePrice(self: OutboundOrderLine) -> Decimal
Set: ItemPurchasePrice(self: OutboundOrderLine)=value
"""
ItemSalesPrice=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemSalesPrice(self: OutboundOrderLine) -> Decimal
Set: ItemSalesPrice(self: OutboundOrderLine)=value
"""
ItemSalesPriceSingleWithVat=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemSalesPriceSingleWithVat(self: OutboundOrderLine) -> Decimal
Set: ItemSalesPriceSingleWithVat(self: OutboundOrderLine)=value
"""
ItemSalesPriceSumPickable=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemSalesPriceSumPickable(self: OutboundOrderLine) -> Decimal
"""
ItemSalesPriceSumToDeliver=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemSalesPriceSumToDeliver(self: OutboundOrderLine) -> Decimal
"""
ItemWeight=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ItemWeight(self: OutboundOrderLine) -> Decimal
Set: ItemWeight(self: OutboundOrderLine)=value
"""
LineCurrencyCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: LineCurrencyCode(self: OutboundOrderLine) -> str
Set: LineCurrencyCode(self: OutboundOrderLine)=value
"""
LineDescription=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: LineDescription(self: OutboundOrderLine) -> str
Set: LineDescription(self: OutboundOrderLine)=value
"""
LineInstruction=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: LineInstruction(self: OutboundOrderLine) -> str
Set: LineInstruction(self: OutboundOrderLine)=value
"""
LineItemIdentifier=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: LineItemIdentifier(self: OutboundOrderLine) -> str
Set: LineItemIdentifier(self: OutboundOrderLine)=value
"""
LineNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: LineNumber(self: OutboundOrderLine) -> int
Set: LineNumber(self: OutboundOrderLine)=value
"""
OrderId=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: OrderId(self: OutboundOrderLine) -> int
Set: OrderId(self: OutboundOrderLine)=value
"""
OrderNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: OrderNumber(self: OutboundOrderLine) -> str
Set: OrderNumber(self: OutboundOrderLine)=value
"""
PercentageItemSalesPriceSumPickable=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: PercentageItemSalesPriceSumPickable(self: OutboundOrderLine) -> int
"""
QuantityAllocated=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: QuantityAllocated(self: OutboundOrderLine) -> Decimal
"""
QuantityLocked=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Quantity locked by external ERP program.
This quantity is not included in stock allocation but shown in %Batchable and CheckPartialDelivery
* assigned to purchase order from Profit (wmspro-3531).
* Potential order waiting as an Afas option added here too.
These amounts are not in Wms.RemotingObjects.Outbound.OutboundOrderLine.QuantityToDeliver but are actually part of the order
and thus the order cannot be Completely Delivered.
Get: QuantityLocked(self: OutboundOrderLine) -> Decimal
Set: QuantityLocked(self: OutboundOrderLine)=value
"""
QuantityOrdered=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: QuantityOrdered(self: OutboundOrderLine) -> Decimal
Set: QuantityOrdered(self: OutboundOrderLine)=value
"""
QuantityPackable=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: QuantityPackable(self: OutboundOrderLine) -> Decimal
"""
QuantityPacked=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: QuantityPacked(self: OutboundOrderLine) -> Decimal
"""
QuantityPickable=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""The quantity that is pickable. This is calculated when the batchable salesorders are retrieved.
After that the line will be batched and the property QuantityAllocated can be used.
Get: QuantityPickable(self: OutboundOrderLine) -> Decimal
Set: QuantityPickable(self: OutboundOrderLine)=value
"""
QuantityPicked=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""The quantity left to be picked.
Get: QuantityPicked(self: OutboundOrderLine) -> Decimal
"""
QuantityProcessed=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: QuantityProcessed(self: OutboundOrderLine) -> Decimal
"""
QuantityToDeliver=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: QuantityToDeliver(self: OutboundOrderLine) -> Decimal
Set: QuantityToDeliver(self: OutboundOrderLine)=value
"""
QuantityToDeliverOriginal=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Is used by picking process to be able to revert a pick to original state.
Get: QuantityToDeliverOriginal(self: OutboundOrderLine) -> Decimal
Set: QuantityToDeliverOriginal(self: OutboundOrderLine)=value
"""
RequestedDate=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: RequestedDate(self: OutboundOrderLine) -> DateTime
Set: RequestedDate(self: OutboundOrderLine)=value
"""
ShowInBatch=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ShowInBatch(self: OutboundOrderLine) -> bool
Set: ShowInBatch(self: OutboundOrderLine)=value
"""
StockAssigned=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: StockAssigned(self: OutboundOrderLine) -> bool
Set: StockAssigned(self: OutboundOrderLine)=value
"""
Type=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Type(self: OutboundOrderLine) -> OutboundOrderTypeEnum
"""
UnitCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: UnitCode(self: OutboundOrderLine) -> str
Set: UnitCode(self: OutboundOrderLine)=value
"""
VatCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: VatCode(self: OutboundOrderLine) -> str
Set: VatCode(self: OutboundOrderLine)=value
"""
Warehouse=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Warehouse(self: OutboundOrderLine) -> str
Set: Warehouse(self: OutboundOrderLine)=value
"""
WarehouseLocation=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: WarehouseLocation(self: OutboundOrderLine) -> str
Set: WarehouseLocation(self: OutboundOrderLine)=value
"""
class HistoryOutboundOrderLine(OutboundOrderLine):
""" HistoryOutboundOrderLine() """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return HistoryOutboundOrderLine()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __reduce_ex__(self,*args):
pass
OrderId=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: OrderId(self: HistoryOutboundOrderLine) -> int
Set: OrderId(self: HistoryOutboundOrderLine)=value
"""
QuantityDelivered=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: QuantityDelivered(self: HistoryOutboundOrderLine) -> Decimal
Set: QuantityDelivered(self: HistoryOutboundOrderLine)=value
"""
ShipmentId=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ShipmentId(self: HistoryOutboundOrderLine) -> int
Set: ShipmentId(self: HistoryOutboundOrderLine)=value
"""
Type=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Type(self: HistoryOutboundOrderLine) -> OutboundOrderTypeEnum
"""
class OutboundOrderLines(FindableList):
""" OutboundOrderLines() """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return OutboundOrderLines()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def Clone(self):
""" Clone(self: OutboundOrderLines) -> object """
pass
@staticmethod
def FromIEnumerable(list):
""" FromIEnumerable(list: IEnumerable[OutboundOrderLine]) -> OutboundOrderLines """
pass
def GetHashCode(self):
""" GetHashCode(self: OutboundOrderLines) -> int """
pass
def __getitem__(self,*args):
""" x.__getitem__(y) <==> x[y] """
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __iter__(self,*args):
""" __iter__(self: IEnumerable) -> object """
pass
def __reduce_ex__(self,*args):
pass
def __setitem__(self,*args):
""" x.__setitem__(i,y) <==> x[i]= """
pass
IsDisposable=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: IsDisposable(self: OutboundOrderLines) -> bool
"""
PreserveState=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: PreserveState(self: OutboundOrderLines) -> bool
"""
DisplayMember='ItemCode'
ValueMember='Id'
class HistoryOutboundOrderLines(OutboundOrderLines):
""" HistoryOutboundOrderLines() """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return HistoryOutboundOrderLines()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def __getitem__(self,*args):
""" x.__getitem__(y) <==> x[y] """
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __iter__(self,*args):
""" __iter__(self: IEnumerable) -> object """
pass
def __reduce_ex__(self,*args):
pass
def __setitem__(self,*args):
""" x.__setitem__(i,y) <==> x[i]= """
pass
DisplayMember='ItemCode'
ValueMember='Id'
class HistoryOutboundOrders(FindableList):
""" HistoryOutboundOrders() """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return HistoryOutboundOrders()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def Add(self,*__args):
"""
Add(self: HistoryOutboundOrders,order: HistoryOutboundOrder) -> FindableList[HistoryOutboundOrder]
Add(self: HistoryOutboundOrders,order: HistoryOutboundOrder,predicate: Predicate[HistoryOutboundOrder])
"""
pass
def Clone(self):
""" Clone(self: HistoryOutboundOrders) -> object """
pass
@staticmethod
def FromIEnumerable(list):
""" FromIEnumerable(list: IEnumerable[HistoryOutboundOrder]) -> HistoryOutboundOrders """
pass
def GetHashCode(self):
""" GetHashCode(self: HistoryOutboundOrders) -> int """
pass
def __add__(self,*args):
""" x.__add__(y) <==> x+yx.__add__(y) <==> x+y """
pass
def __getitem__(self,*args):
""" x.__getitem__(y) <==> x[y] """
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __iter__(self,*args):
""" __iter__(self: IEnumerable) -> object """
pass
def __reduce_ex__(self,*args):
pass
def __setitem__(self,*args):
""" x.__setitem__(i,y) <==> x[i]= """
pass
TotalRowsMatched=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: TotalRowsMatched(self: HistoryOutboundOrders) -> Int64
Set: TotalRowsMatched(self: HistoryOutboundOrders)=value
"""
DisplayMember='Number'
ValueMember='DbKey'
class OutboundOrder(DbObject):
""" """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return OutboundOrder()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def Clone(self):
""" Clone(self: OutboundOrder) -> object """
pass
def Equals(self,obj):
""" Equals(self: OutboundOrder,obj: object) -> bool """
pass
def GetHashCode(self):
""" GetHashCode(self: OutboundOrder) -> int """
pass
def GetHashCodeOfCustomer(self):
""" GetHashCodeOfCustomer(self: OutboundOrder) -> int """
pass
def __eq__(self,*args):
""" x.__eq__(y) <==> x==y """
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __ne__(self,*args):
pass
def __reduce_ex__(self,*args):
pass
AllowPartialDelivery=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: AllowPartialDelivery(self: OutboundOrder) -> PartialDeliveryTypeEnum
Set: AllowPartialDelivery(self: OutboundOrder)=value
"""
AllowPartialDeliveryAsString=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: AllowPartialDeliveryAsString(self: OutboundOrder) -> str
"""
Backorder=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Backorder(self: OutboundOrder) -> bool
Set: Backorder(self: OutboundOrder)=value
"""
CustomerAddressLine1=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerAddressLine1(self: OutboundOrder) -> str
Set: CustomerAddressLine1(self: OutboundOrder)=value
"""
CustomerAddressLine2=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerAddressLine2(self: OutboundOrder) -> str
Set: CustomerAddressLine2(self: OutboundOrder)=value
"""
CustomerAddressLine3=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerAddressLine3(self: OutboundOrder) -> str
Set: CustomerAddressLine3(self: OutboundOrder)=value
"""
CustomerCity=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: CustomerCity(self: OutboundOrder) -> str
Set: CustomerCity(self: OutboundOrder)=value
"""
CustomerContact=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerContact(self: OutboundOrder) -> str
Set: CustomerContact(self: OutboundOrder)=value
"""
CustomerContactEmail=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerContactEmail(self: OutboundOrder) -> str
Set: CustomerContactEmail(self: OutboundOrder)=value
"""
CustomerCountryCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: CustomerCountryCode(self: OutboundOrder) -> str
Set: CustomerCountryCode(self: OutboundOrder)=value
"""
CustomerCountryName=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerCountryName(self: OutboundOrder) -> str
Set: CustomerCountryName(self: OutboundOrder)=value
"""
CustomerEoriNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerEoriNumber(self: OutboundOrder) -> str
Set: CustomerEoriNumber(self: OutboundOrder)=value
"""
CustomerInvoiceAddressLine1=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceAddressLine1(self: OutboundOrder) -> str
Set: CustomerInvoiceAddressLine1(self: OutboundOrder)=value
"""
CustomerInvoiceAddressLine2=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceAddressLine2(self: OutboundOrder) -> str
Set: CustomerInvoiceAddressLine2(self: OutboundOrder)=value
"""
CustomerInvoiceAddressLine3=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceAddressLine3(self: OutboundOrder) -> str
Set: CustomerInvoiceAddressLine3(self: OutboundOrder)=value
"""
CustomerInvoiceCity=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceCity(self: OutboundOrder) -> str
Set: CustomerInvoiceCity(self: OutboundOrder)=value
"""
CustomerInvoiceContact=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceContact(self: OutboundOrder) -> str
Set: CustomerInvoiceContact(self: OutboundOrder)=value
"""
CustomerInvoiceContactEmail=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceContactEmail(self: OutboundOrder) -> str
Set: CustomerInvoiceContactEmail(self: OutboundOrder)=value
"""
CustomerInvoiceCountryCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceCountryCode(self: OutboundOrder) -> str
Set: CustomerInvoiceCountryCode(self: OutboundOrder)=value
"""
CustomerInvoiceCountryName=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceCountryName(self: OutboundOrder) -> str
Set: CustomerInvoiceCountryName(self: OutboundOrder)=value
"""
CustomerInvoiceName=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceName(self: OutboundOrder) -> str
Set: CustomerInvoiceName(self: OutboundOrder)=value
"""
CustomerInvoiceNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceNumber(self: OutboundOrder) -> str
Set: CustomerInvoiceNumber(self: OutboundOrder)=value
"""
CustomerInvoicePhoneNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoicePhoneNumber(self: OutboundOrder) -> str
Set: CustomerInvoicePhoneNumber(self: OutboundOrder)=value
"""
CustomerInvoiceState=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceState(self: OutboundOrder) -> str
Set: CustomerInvoiceState(self: OutboundOrder)=value
"""
CustomerInvoiceZipCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerInvoiceZipCode(self: OutboundOrder) -> str
Set: CustomerInvoiceZipCode(self: OutboundOrder)=value
"""
CustomerName=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: CustomerName(self: OutboundOrder) -> str
Set: CustomerName(self: OutboundOrder)=value
"""
CustomerNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerNumber(self: OutboundOrder) -> str
Set: CustomerNumber(self: OutboundOrder)=value
"""
CustomerPackageSlipLayout=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerPackageSlipLayout(self: OutboundOrder) -> str
Set: CustomerPackageSlipLayout(self: OutboundOrder)=value
"""
CustomerPhoneNumber=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerPhoneNumber(self: OutboundOrder) -> str
Set: CustomerPhoneNumber(self: OutboundOrder)=value
"""
CustomerReference=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerReference(self: OutboundOrder) -> str
Set: CustomerReference(self: OutboundOrder)=value
"""
CustomerState=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerState(self: OutboundOrder) -> str
Set: CustomerState(self: OutboundOrder)=value
"""
CustomerZipCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomerZipCode(self: OutboundOrder) -> str
Set: CustomerZipCode(self: OutboundOrder)=value
"""
CustomFields=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: CustomFields(self: OutboundOrder) -> SerializableDictionary[str,object]
Set: CustomFields(self: OutboundOrder)=value
"""
DateOfDelivery=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: DateOfDelivery(self: OutboundOrder) -> DateTime
Set: DateOfDelivery(self: OutboundOrder)=value
"""
DateOrdered=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: DateOrdered(self: OutboundOrder) -> DateTime
Set: DateOrdered(self: OutboundOrder)=value
"""
DeliverableOrderlines=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: DeliverableOrderlines(self: OutboundOrder) -> int
Set: DeliverableOrderlines(self: OutboundOrder)=value
"""
DeliveryMethod=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: DeliveryMethod(self: OutboundOrder) -> str
Set: DeliveryMethod(self: OutboundOrder)=value
"""
Description=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Description(self: OutboundOrder) -> str
Set: Description(self: OutboundOrder)=value
"""
Id=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: Id(self: OutboundOrder) -> int
Set: Id(self: OutboundOrder)=value
"""
LineBackColor=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: LineBackColor(self: OutboundOrder) -> str
Set: LineBackColor(self: OutboundOrder)=value
"""
LineForeColor=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: LineForeColor(self: OutboundOrder) -> str
Set: LineForeColor(self: OutboundOrder)=value
"""
Notes=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Notes(self: OutboundOrder) -> str
Set: Notes(self: OutboundOrder)=value
"""
Number=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: Number(self: OutboundOrder) -> str
Set: Number(self: OutboundOrder)=value
"""
OrderAmountDeliverable=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: OrderAmountDeliverable(self: OutboundOrder) -> Decimal
Set: OrderAmountDeliverable(self: OutboundOrder)=value
"""
OrderAmountTotal=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: OrderAmountTotal(self: OutboundOrder) -> Decimal
Set: OrderAmountTotal(self: OutboundOrder)=value
"""
PendingItemCount=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: PendingItemCount(self: OutboundOrder) -> int
"""
PendingItems=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: PendingItems(self: OutboundOrder) -> Dictionary[str,Decimal]
Set: PendingItems(self: OutboundOrder)=value
"""
PendingItemUnitCount=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: PendingItemUnitCount(self: OutboundOrder) -> Decimal
"""
PendingOrderLines=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: PendingOrderLines(self: OutboundOrder) -> int
Set: PendingOrderLines(self: OutboundOrder)=value
"""
PercentageDeliverableAmount=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: PercentageDeliverableAmount(self: OutboundOrder) -> int
Set: PercentageDeliverableAmount(self: OutboundOrder)=value
"""
PercentageDeliverableLines=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: PercentageDeliverableLines(self: OutboundOrder) -> int
Set: PercentageDeliverableLines(self: OutboundOrder)=value
"""
PercentDeliverable=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Percentage of the QuantityToDeliver that is deliverable
Get: PercentDeliverable(self: OutboundOrder) -> int
Set: PercentDeliverable(self: OutboundOrder)=value
"""
ProjectCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ProjectCode(self: OutboundOrder) -> str
Set: ProjectCode(self: OutboundOrder)=value
"""
ProjectName=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: ProjectName(self: OutboundOrder) -> str
Set: ProjectName(self: OutboundOrder)=value
"""
RoutingCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: RoutingCode(self: OutboundOrder) -> str
Set: RoutingCode(self: OutboundOrder)=value
"""
SelectionCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: SelectionCode(self: OutboundOrder) -> str
Set: SelectionCode(self: OutboundOrder)=value
"""
SelectionCodeDescription=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: SelectionCodeDescription(self: OutboundOrder) -> str
Set: SelectionCodeDescription(self: OutboundOrder)=value
"""
Tag=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Tag(self: OutboundOrder) -> Tag
Set: Tag(self: OutboundOrder)=value
"""
TotalOrderlines=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: TotalOrderlines(self: OutboundOrder) -> int
Set: TotalOrderlines(self: OutboundOrder)=value
"""
Type=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: Type(self: OutboundOrder) -> OutboundOrderTypeEnum
"""
Warehouse=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Necessary for Userinterface BOXwise Mobile
Get: Warehouse(self: OutboundOrder) -> str
Set: Warehouse(self: OutboundOrder)=value
"""
class OutboundOrderLineEqualityComparer(object):
""" OutboundOrderLineEqualityComparer() """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return OutboundOrderLineEqualityComparer()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def Equals(self,*__args):
""" Equals(self: OutboundOrderLineEqualityComparer,x: OutboundOrderLine,y: OutboundOrderLine) -> bool """
pass
def GetHashCode(self,obj=None):
""" GetHashCode(self: OutboundOrderLineEqualityComparer,obj: OutboundOrderLine) -> int """
pass
def __eq__(self,*args):
""" x.__eq__(y) <==> x==y """
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __repr__(self,*args):
""" __repr__(self: object) -> str """
pass
class OutboundOrders(FindableList):
""" OutboundOrders() """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return OutboundOrders()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def Add(self,*__args):
"""
Add(self: OutboundOrders,order: OutboundOrder) -> FindableList[OutboundOrder]
Add(self: OutboundOrders,order: OutboundOrder,predicate: Predicate[OutboundOrder])
"""
pass
def Clone(self):
""" Clone(self: OutboundOrders) -> object """
pass
@staticmethod
def FromIEnumerable(list):
""" FromIEnumerable(list: IEnumerable[OutboundOrder]) -> OutboundOrders """
pass
def GetHashCode(self):
""" GetHashCode(self: OutboundOrders) -> int """
pass
def __add__(self,*args):
""" x.__add__(y) <==> x+yx.__add__(y) <==> x+y """
pass
def __getitem__(self,*args):
""" x.__getitem__(y) <==> x[y] """
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __iter__(self,*args):
""" __iter__(self: IEnumerable) -> object """
pass
def __reduce_ex__(self,*args):
pass
def __setitem__(self,*args):
""" x.__setitem__(i,y) <==> x[i]= """
pass
TotalRowsMatched=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""
Get: TotalRowsMatched(self: OutboundOrders) -> Int64
Set: TotalRowsMatched(self: OutboundOrders)=value
"""
DisplayMember='Number'
ValueMember='Id'
class OutboundOrderTypeEnum:
""" enum OutboundOrderTypeEnum,values: ReplenishmentOrder (2),RtvOrder (3),SalesOrder (1) """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return OutboundOrderTypeEnum()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def __eq__(self,*args):
""" x.__eq__(y) <==> x==yx.__eq__(y) <==> x==yx.__eq__(y) <==> x==y """
pass
def __format__(self,*args):
""" __format__(formattable: IFormattable,format: str) -> str """
pass
def __ge__(self,*args):
pass
def __gt__(self,*args):
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __le__(self,*args):
pass
def __lt__(self,*args):
pass
def __ne__(self,*args):
pass
def __reduce_ex__(self,*args):
pass
def __str__(self,*args):
pass
ReplenishmentOrder=None
RtvOrder=None
SalesOrder=None
value__=None
class PickDifferenceOptionsEnum:
""" enum PickDifferenceOptionsEnum,values: BasedOnMarkAsPicked (1),BasedOnNonePickedItems (2),None (0) """
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return PickDifferenceOptionsEnum()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def __eq__(self,*args):
""" x.__eq__(y) <==> x==yx.__eq__(y) <==> x==yx.__eq__(y) <==> x==y """
pass
def __format__(self,*args):
""" __format__(formattable: IFormattable,format: str) -> str """
pass
def __ge__(self,*args):
pass
def __gt__(self,*args):
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
def __le__(self,*args):
pass
def __lt__(self,*args):
pass
def __ne__(self,*args):
pass
def __reduce_ex__(self,*args):
pass
def __str__(self,*args):
pass
BasedOnMarkAsPicked=None
BasedOnNonePickedItems=None
None_ =None
value__=None
class ValidateItemIdentificationArgs(object):
"""
ValidateItemIdentificationArgs()
ValidateItemIdentificationArgs(itemCode: str,number: str)
"""
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return ValidateItemIdentificationArgs()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
@staticmethod
def __new__(self,itemCode=None,number=None):
"""
__new__(cls: type)
__new__(cls: type,itemCode: str,number: str)
"""
pass
ItemCode=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Get: ItemCode(self: ValidateItemIdentificationArgs) -> str
Set: ItemCode(self: ValidateItemIdentificationArgs)=value
"""
Number=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Get: Number(self: ValidateItemIdentificationArgs) -> str
Set: Number(self: ValidateItemIdentificationArgs)=value
"""
# variables with complex values
| 29.377313
| 215
| 0.710147
| 6,263
| 60,341
| 6.707488
| 0.058758
| 0.142112
| 0.085267
| 0.11369
| 0.55819
| 0.54993
| 0.541955
| 0.537432
| 0.535719
| 0.525959
| 0
| 0.001205
| 0.161201
| 60,341
| 2,053
| 216
| 29.391622
| 0.828783
| 0.127724
| 0
| 0.7431
| 0
| 0
| 0.001884
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.225053
| false
| 0.186837
| 0.004246
| 0
| 0.804671
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
8d97f752632492b528049c4794a2ba50783de40b
| 328
|
py
|
Python
|
pkg/distil_bilstm_pos_tagger/__init__.py
|
etherlabsio/ai-engine
|
e73a4419a34db42a410e2a7e7629eb946b86f2c2
|
[
"MIT"
] | null | null | null |
pkg/distil_bilstm_pos_tagger/__init__.py
|
etherlabsio/ai-engine
|
e73a4419a34db42a410e2a7e7629eb946b86f2c2
|
[
"MIT"
] | null | null | null |
pkg/distil_bilstm_pos_tagger/__init__.py
|
etherlabsio/ai-engine
|
e73a4419a34db42a410e2a7e7629eb946b86f2c2
|
[
"MIT"
] | 1
|
2020-04-19T11:07:42.000Z
|
2020-04-19T11:07:42.000Z
|
from distil_bilstm_pos_tagger.distil_bilstm_pos_tagger import DistilBiLstmPosTagger
#from .distilbert_utils.modeling_distilbert import DistilBertPreTrainedModel, DistilBertModel, DistilBertConfig
#from .distilbert_utils.tokenization_distilbert import DistilBertTokenizer
from distil_bilstm_pos_tagger.distilbert_utils import *
| 65.6
| 112
| 0.908537
| 35
| 328
| 8.114286
| 0.428571
| 0.126761
| 0.158451
| 0.221831
| 0.176056
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.057927
| 328
| 4
| 113
| 82
| 0.919094
| 0.560976
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
8da0e33d244598df780e16f383d223ea107f108c
| 47,390
|
py
|
Python
|
awx/main/tests/old/ad_hoc.py
|
doziya/ansible
|
96f7371493043e2ae596d059f2ca990bd0a28ad5
|
[
"Apache-2.0"
] | 1
|
2021-06-11T20:01:06.000Z
|
2021-06-11T20:01:06.000Z
|
awx/main/tests/old/ad_hoc.py
|
doziya/ansible
|
96f7371493043e2ae596d059f2ca990bd0a28ad5
|
[
"Apache-2.0"
] | 4
|
2020-04-29T23:03:16.000Z
|
2022-03-01T23:56:09.000Z
|
awx/main/tests/old/ad_hoc.py
|
doziya/ansible
|
96f7371493043e2ae596d059f2ca990bd0a28ad5
|
[
"Apache-2.0"
] | 1
|
2019-05-07T13:55:18.000Z
|
2019-05-07T13:55:18.000Z
|
# Copyright (c) 2015 Ansible, Inc.
# All Rights Reserved.
# Python
import glob
import os
import subprocess
import tempfile
import mock
import unittest2 as unittest
# Django
from django.conf import settings
from django.core.urlresolvers import reverse
# Django-CRUM
from crum import impersonate
# AWX
from awx.main.utils import * # noqa
from awx.main.models import * # noqa
from awx.main.tests.base import BaseJobExecutionTest
from awx.main.tests.data.ssh import (
TEST_SSH_KEY_DATA,
TEST_SSH_KEY_DATA_LOCKED,
TEST_SSH_KEY_DATA_UNLOCK,
)
__all__ = ['RunAdHocCommandTest', 'AdHocCommandApiTest']
class BaseAdHocCommandTest(BaseJobExecutionTest):
'''
Common initialization for testing ad hoc commands.
'''
def setUp(self):
with ignore_inventory_computed_fields():
super(BaseAdHocCommandTest, self).setUp()
self.setup_instances()
self.setup_users()
self.organization = self.make_organizations(self.super_django_user, 1)[0]
self.organization.admin_role.members.add(self.normal_django_user)
self.inventory = self.organization.inventories.create(name='test-inventory', description='description for test-inventory')
self.host = self.inventory.hosts.create(name='host.example.com')
self.host2 = self.inventory.hosts.create(name='host2.example.com')
self.group = self.inventory.groups.create(name='test-group')
self.group2 = self.inventory.groups.create(name='test-group2')
self.group.hosts.add(self.host)
self.group2.hosts.add(self.host, self.host2)
self.inventory2 = self.organization.inventories.create(name='test-inventory2')
self.host3 = self.inventory2.hosts.create(name='host3.example.com')
self.credential = None
settings.INTERNAL_API_URL = self.live_server_url
settings.CALLBACK_CONSUMER_PORT = ''
def create_test_credential(self, **kwargs):
self.credential = self.make_credential(**kwargs)
return self.credential
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
class RunAdHocCommandTest(BaseAdHocCommandTest):
'''
Test cases for RunAdHocCommand celery task.
'''
def create_test_ad_hoc_command(self, **kwargs):
with impersonate(self.super_django_user):
opts = {
'inventory': self.inventory,
'credential': self.credential,
'job_type': 'run',
'module_name': 'command',
'module_args': 'uptime',
}
opts.update(kwargs)
self.ad_hoc_command = AdHocCommand.objects.create(**opts)
return self.ad_hoc_command
def check_ad_hoc_command_events(self, ad_hoc_command, runner_status='ok',
hosts=None):
ad_hoc_command_events = ad_hoc_command.ad_hoc_command_events.all()
for ad_hoc_command_event in ad_hoc_command_events:
unicode(ad_hoc_command_event) # For test coverage.
should_be_failed = bool(runner_status not in ('ok', 'skipped'))
should_be_changed = bool(runner_status in ('ok', 'failed') and ad_hoc_command.job_type == 'run')
if hosts is not None:
host_pks = set([x.pk for x in hosts])
else:
host_pks = set(ad_hoc_command.inventory.hosts.values_list('pk', flat=True))
qs = ad_hoc_command_events.filter(event=('runner_on_%s' % runner_status))
self.assertEqual(qs.count(), len(host_pks))
for evt in qs:
self.assertTrue(evt.host_id in host_pks)
self.assertTrue(evt.host_name)
self.assertEqual(evt.failed, should_be_failed)
self.assertEqual(evt.changed, should_be_changed)
def test_run_ad_hoc_command(self):
ad_hoc_command = self.create_test_ad_hoc_command()
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'successful')
self.check_ad_hoc_command_events(ad_hoc_command, 'ok')
def test_check_mode_ad_hoc_command(self):
ad_hoc_command = self.create_test_ad_hoc_command(module_name='ping', module_args='', job_type='check')
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'successful')
self.check_ad_hoc_command_events(ad_hoc_command, 'ok')
def test_run_ad_hoc_command_that_fails(self):
ad_hoc_command = self.create_test_ad_hoc_command(module_args='false')
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'failed')
self.check_ad_hoc_command_events(ad_hoc_command, 'failed')
def test_check_mode_where_command_would_fail(self):
ad_hoc_command = self.create_test_ad_hoc_command(job_type='check', module_args='false')
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'successful')
self.check_ad_hoc_command_events(ad_hoc_command, 'skipped')
@mock.patch('awx.main.tasks.BaseTask.run_pexpect', return_value=('canceled', 0))
def test_cancel_ad_hoc_command(self, ignore):
ad_hoc_command = self.create_test_ad_hoc_command()
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.cancel_flag)
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
ad_hoc_command.cancel_flag = True
ad_hoc_command.save(update_fields=['cancel_flag'])
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'canceled')
self.assertTrue(ad_hoc_command.cancel_flag)
# Calling cancel afterwards just returns the cancel flag.
self.assertTrue(ad_hoc_command.cancel())
# Read attribute for test coverage.
ad_hoc_command.celery_task
ad_hoc_command.celery_task_id = ''
ad_hoc_command.save(update_fields=['celery_task_id'])
self.assertEqual(ad_hoc_command.celery_task, None)
# Unable to start ad hoc command again.
self.assertFalse(ad_hoc_command.signal_start())
@mock.patch('awx.main.tasks.BaseTask.run_pexpect', return_value=('successful', 0))
def test_ad_hoc_command_options(self, ignore):
ad_hoc_command = self.create_test_ad_hoc_command(forks=2, verbosity=2)
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'successful')
self.assertTrue('"--forks=2"' in ad_hoc_command.job_args)
self.assertTrue('"-vv"' in ad_hoc_command.job_args)
# Test with basic become privilege escalation
ad_hoc_command2 = self.create_test_ad_hoc_command(become_enabled=True)
self.assertEqual(ad_hoc_command2.status, 'new')
self.assertFalse(ad_hoc_command2.passwords_needed_to_start)
self.assertTrue(ad_hoc_command2.signal_start())
ad_hoc_command2 = AdHocCommand.objects.get(pk=ad_hoc_command2.pk)
self.check_job_result(ad_hoc_command2, ('successful', 'failed'))
self.assertTrue('"--become"' in ad_hoc_command2.job_args)
def test_limit_option(self):
# Test limit by hostname.
ad_hoc_command = self.create_test_ad_hoc_command(limit='host.example.com')
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'successful')
self.check_ad_hoc_command_events(ad_hoc_command, 'ok', hosts=[self.host])
self.assertTrue('"host.example.com"' in ad_hoc_command.job_args)
# Test limit by group name.
ad_hoc_command2 = self.create_test_ad_hoc_command(limit='test-group')
self.assertEqual(ad_hoc_command2.status, 'new')
self.assertFalse(ad_hoc_command2.passwords_needed_to_start)
self.assertTrue(ad_hoc_command2.signal_start())
ad_hoc_command2 = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command2, 'successful')
self.check_ad_hoc_command_events(ad_hoc_command2, 'ok', hosts=[self.host])
# Test limit by host not in inventory.
ad_hoc_command3 = self.create_test_ad_hoc_command(limit='bad-host')
self.assertEqual(ad_hoc_command3.status, 'new')
self.assertFalse(ad_hoc_command3.passwords_needed_to_start)
self.assertTrue(ad_hoc_command3.signal_start())
ad_hoc_command3 = AdHocCommand.objects.get(pk=ad_hoc_command3.pk)
self.check_job_result(ad_hoc_command3, 'successful')
self.check_ad_hoc_command_events(ad_hoc_command3, 'ok', hosts=[])
self.assertEqual(ad_hoc_command3.ad_hoc_command_events.count(), 0)
@mock.patch('awx.main.tasks.BaseTask.run_pexpect', return_value=('successful', 0))
def test_ssh_username_and_password(self, ignore):
self.create_test_credential(username='sshuser', password='sshpass')
ad_hoc_command = self.create_test_ad_hoc_command()
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'successful')
self.assertIn('"-u"', ad_hoc_command.job_args)
self.assertIn('"--ask-pass"', ad_hoc_command.job_args)
@mock.patch('awx.main.tasks.BaseTask.run_pexpect', return_value=('successful', 0))
def test_ssh_ask_password(self, ignore):
self.create_test_credential(password='ASK')
ad_hoc_command = self.create_test_ad_hoc_command()
self.assertEqual(ad_hoc_command.status, 'new')
self.assertTrue(ad_hoc_command.passwords_needed_to_start)
self.assertTrue('ssh_password' in ad_hoc_command.passwords_needed_to_start)
self.assertFalse(ad_hoc_command.signal_start())
self.assertTrue(ad_hoc_command.signal_start(ssh_password='sshpass'))
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'successful')
self.assertIn('"--ask-pass"', ad_hoc_command.job_args)
@mock.patch('awx.main.tasks.BaseTask.run_pexpect', return_value=('successful', 0))
def test_sudo_username_and_password(self, ignore):
self.create_test_credential(become_method="sudo",
become_username='sudouser',
become_password='sudopass')
ad_hoc_command = self.create_test_ad_hoc_command()
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, ('successful', 'failed'))
self.assertIn('"--become-method"', ad_hoc_command.job_args)
self.assertIn('"--become-user"', ad_hoc_command.job_args)
self.assertIn('"--ask-become-pass"', ad_hoc_command.job_args)
self.assertNotIn('"--become"', ad_hoc_command.job_args)
@mock.patch('awx.main.tasks.BaseTask.run_pexpect', return_value=('successful', 0))
def test_sudo_ask_password(self, ignore):
self.create_test_credential(become_password='ASK')
ad_hoc_command = self.create_test_ad_hoc_command()
self.assertEqual(ad_hoc_command.status, 'new')
self.assertTrue(ad_hoc_command.passwords_needed_to_start)
self.assertTrue('become_password' in ad_hoc_command.passwords_needed_to_start)
self.assertFalse(ad_hoc_command.signal_start())
self.assertTrue(ad_hoc_command.signal_start(become_password='sudopass'))
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, ('successful', 'failed'))
self.assertIn('"--ask-become-pass"', ad_hoc_command.job_args)
self.assertNotIn('"--become-user"', ad_hoc_command.job_args)
self.assertNotIn('"--become"', ad_hoc_command.job_args)
@mock.patch('awx.main.tasks.BaseTask.run_pexpect', return_value=('successful', 0))
def test_unlocked_ssh_key(self, ignore):
self.create_test_credential(ssh_key_data=TEST_SSH_KEY_DATA)
ad_hoc_command = self.create_test_ad_hoc_command()
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'successful')
self.assertNotIn('"--private-key=', ad_hoc_command.job_args)
self.assertIn('ssh-agent', ad_hoc_command.job_args)
def test_locked_ssh_key_with_password(self):
self.create_test_credential(ssh_key_data=TEST_SSH_KEY_DATA_LOCKED,
ssh_key_unlock=TEST_SSH_KEY_DATA_UNLOCK)
ad_hoc_command = self.create_test_ad_hoc_command()
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'successful')
self.assertIn('ssh-agent', ad_hoc_command.job_args)
self.assertNotIn('Bad passphrase', ad_hoc_command.result_stdout)
def test_locked_ssh_key_with_bad_password(self):
self.create_test_credential(ssh_key_data=TEST_SSH_KEY_DATA_LOCKED,
ssh_key_unlock='not the passphrase')
ad_hoc_command = self.create_test_ad_hoc_command()
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'failed')
self.assertIn('ssh-agent', ad_hoc_command.job_args)
self.assertIn('Bad passphrase', ad_hoc_command.result_stdout)
def test_locked_ssh_key_ask_password(self):
self.create_test_credential(ssh_key_data=TEST_SSH_KEY_DATA_LOCKED,
ssh_key_unlock='ASK')
ad_hoc_command = self.create_test_ad_hoc_command()
self.assertEqual(ad_hoc_command.status, 'new')
self.assertTrue(ad_hoc_command.passwords_needed_to_start)
self.assertTrue('ssh_key_unlock' in ad_hoc_command.passwords_needed_to_start)
self.assertFalse(ad_hoc_command.signal_start())
self.assertTrue(ad_hoc_command.signal_start(ssh_key_unlock='not it'))
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'failed')
self.assertTrue('ssh-agent' in ad_hoc_command.job_args)
self.assertTrue('Bad passphrase' in ad_hoc_command.result_stdout)
# Try again and pass correct password.
ad_hoc_command = self.create_test_ad_hoc_command()
self.assertEqual(ad_hoc_command.status, 'new')
self.assertTrue(ad_hoc_command.passwords_needed_to_start)
self.assertTrue('ssh_key_unlock' in ad_hoc_command.passwords_needed_to_start)
self.assertFalse(ad_hoc_command.signal_start())
self.assertTrue(ad_hoc_command.signal_start(ssh_key_unlock=TEST_SSH_KEY_DATA_UNLOCK))
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'successful')
self.assertIn('ssh-agent', ad_hoc_command.job_args)
self.assertNotIn('Bad passphrase', ad_hoc_command.result_stdout)
def test_run_with_bubblewrap(self):
# Only run test if bubblewrap is installed
cmd = [getattr(settings, 'AWX_PROOT_CMD', 'bwrap'), '--version']
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
proc.communicate()
has_bubblewrap = bool(proc.returncode == 0)
except (OSError, ValueError):
has_bubblewrap = False
if not has_bubblewrap:
self.skipTest('bubblewrap is not installed')
# Enable bubblewrap for this test.
settings.AWX_PROOT_ENABLED = True
# Hide local settings path.
settings.AWX_PROOT_HIDE_PATHS = [os.path.join(settings.BASE_DIR, 'settings')]
# Create list of paths that should not be visible to the command.
hidden_paths = [
os.path.join(settings.PROJECTS_ROOT, '*'),
os.path.join(settings.JOBOUTPUT_ROOT, '*'),
]
# Create a temp directory that should not be visible to the command.
temp_path = tempfile.mkdtemp()
self._temp_paths.append(temp_path)
hidden_paths.append(temp_path)
# Find a file in supervisor logs that should not be visible.
try:
supervisor_log_path = glob.glob('/var/log/supervisor/*')[0]
except IndexError:
supervisor_log_path = None
if supervisor_log_path:
hidden_paths.append(supervisor_log_path)
# Create and run ad hoc command.
module_args = ' && '.join(['echo %s && test ! -e %s' % (x, x) for x in hidden_paths])
ad_hoc_command = self.create_test_ad_hoc_command(module_name='shell', module_args=module_args, verbosity=2)
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'successful')
self.check_ad_hoc_command_events(ad_hoc_command, 'ok')
@mock.patch('awx.main.tasks.BaseTask.run_pexpect', return_value=('failed', 0))
def test_run_with_bubblewrap_not_installed(self, ignore):
# Enable bubblewrap for this test, specify invalid bubblewrap cmd.
settings.AWX_PROOT_ENABLED = True
settings.AWX_PROOT_CMD = 'PR00T'
ad_hoc_command = self.create_test_ad_hoc_command()
self.assertEqual(ad_hoc_command.status, 'new')
self.assertFalse(ad_hoc_command.passwords_needed_to_start)
self.assertTrue(ad_hoc_command.signal_start())
ad_hoc_command = AdHocCommand.objects.get(pk=ad_hoc_command.pk)
self.check_job_result(ad_hoc_command, 'error', expect_traceback=True)
def run_pexpect_mock(self, *args, **kwargs):
return 'successful', 0
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
class AdHocCommandApiTest(BaseAdHocCommandTest):
'''
Test API list/detail views for ad hoc commands.
'''
def setUp(self):
super(AdHocCommandApiTest, self).setUp()
self.create_test_credential(user=self.normal_django_user)
def run_test_ad_hoc_command(self, **kwargs):
# Post to list to start a new ad hoc command.
expect = kwargs.pop('expect', 201)
url = kwargs.pop('url', reverse('api:ad_hoc_command_list'))
data = {
'inventory': self.inventory.pk,
'credential': self.credential.pk,
'module_name': 'command',
'module_args': 'uptime',
}
data.update(kwargs)
for k,v in data.items():
if v is None:
del data[k]
return self.post(url, data, expect=expect)
@mock.patch('awx.main.tasks.BaseTask.run_pexpect', side_effect=run_pexpect_mock)
def test_ad_hoc_command_detail(self, ignore):
with self.current_user('admin'):
response1 = self.run_test_ad_hoc_command()
response2 = self.run_test_ad_hoc_command()
response3 = self.run_test_ad_hoc_command()
# Retrieve detail for ad hoc command. Only GET is supported.
with self.current_user('admin'):
url = reverse('api:ad_hoc_command_detail', args=(response1['id'],))
self.assertEqual(url, response1['url'])
response = self.get(url, expect=200)
self.assertEqual(response['credential'], self.credential.pk)
self.assertEqual(response['related']['credential'],
reverse('api:credential_detail', args=(self.credential.pk,)))
self.assertEqual(response['inventory'], self.inventory.pk)
self.assertEqual(response['related']['inventory'],
reverse('api:inventory_detail', args=(self.inventory.pk,)))
self.assertTrue(response['related']['stdout'])
self.assertTrue(response['related']['cancel'])
self.assertTrue(response['related']['relaunch'])
self.assertTrue(response['related']['events'])
self.assertTrue(response['related']['activity_stream'])
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=204)
self.delete(url, expect=404)
with self.current_user('normal'):
url = reverse('api:ad_hoc_command_detail', args=(response2['id'],))
self.assertEqual(url, response2['url'])
response = self.get(url, expect=200)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=204)
self.delete(url, expect=404)
url = reverse('api:ad_hoc_command_detail', args=(response3['id'],))
self.assertEqual(url, response3['url'])
with self.current_user('other'):
response = self.get(url, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=403)
with self.current_user('nobody'):
response = self.get(url, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=403)
with self.current_user(None):
response = self.get(url, expect=401)
self.put(url, {}, expect=401)
self.patch(url, {}, expect=401)
self.delete(url, expect=401)
# Verify that the credential and inventory are null when they have
# been deleted, can delete an ad hoc command without inventory or
# credential.
self.credential.delete()
self.inventory.delete()
with self.current_user('admin'):
response = self.get(url, expect=200)
self.assertEqual(response['credential'], None)
self.assertEqual(response['inventory'], None)
self.delete(url, expect=204)
self.delete(url, expect=404)
@mock.patch('awx.main.tasks.BaseTask.run_pexpect', side_effect=run_pexpect_mock)
def test_ad_hoc_command_cancel(self, ignore):
# Override setting so that ad hoc command isn't actually started.
with self.settings(CELERY_UNIT_TEST=False):
with self.current_user('admin'):
response = self.run_test_ad_hoc_command()
# Retrieve the cancel URL, should indicate it can be canceled.
url = reverse('api:ad_hoc_command_cancel', args=(response['id'],))
self.assertEqual(url, response['related']['cancel'])
with self.current_user('admin'):
response = self.get(url, expect=200)
self.assertEqual(response['can_cancel'], True)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('normal'):
response = self.get(url, expect=200)
self.assertEqual(response['can_cancel'], True)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('other'):
self.get(url, expect=403)
self.post(url, {}, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('nobody'):
self.get(url, expect=403)
self.post(url, {}, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user(None):
self.get(url, expect=401)
self.post(url, {}, expect=401)
self.put(url, {}, expect=401)
self.patch(url, {}, expect=401)
self.delete(url, expect=401)
# Cancel ad hoc command (before it starts) and verify the can_cancel
# flag is False and attempts to cancel again fail.
with self.current_user('normal'):
self.post(url, {}, expect=202)
response = self.get(url, expect=200)
self.assertEqual(response['can_cancel'], False)
self.post(url, {}, expect=403)
with self.current_user('admin'):
response = self.get(url, expect=200)
self.assertEqual(response['can_cancel'], False)
self.post(url, {}, expect=405)
@mock.patch('awx.main.tasks.BaseTask.run_pexpect', side_effect=run_pexpect_mock)
def test_ad_hoc_command_relaunch(self, ignore):
with self.current_user('admin'):
response = self.run_test_ad_hoc_command()
# Retrieve the relaunch URL, should indicate no passwords are needed
# and it can be relaunched. Relaunch and fetch the new command.
url = reverse('api:ad_hoc_command_relaunch', args=(response['id'],))
self.assertEqual(url, response['related']['relaunch'])
with self.current_user('admin'):
response = self.get(url, expect=200)
self.assertEqual(response['passwords_needed_to_start'], [])
response = self.post(url, {}, expect=201)
self.assertTrue(response['ad_hoc_command'])
self.get(response['url'], expect=200)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('normal'):
response = self.get(url, expect=200)
self.assertEqual(response['passwords_needed_to_start'], [])
response = self.post(url, {}, expect=201)
self.assertTrue(response['ad_hoc_command'])
self.get(response['url'], expect=200)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('other'):
self.get(url, expect=403)
self.post(url, {}, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('nobody'):
self.get(url, expect=403)
self.post(url, {}, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user(None):
self.get(url, expect=401)
self.post(url, {}, expect=401)
self.put(url, {}, expect=401)
self.patch(url, {}, expect=401)
self.delete(url, expect=401)
# Try to relaunch ad hoc command when module has been removed from
# allowed list of modules.
try:
ad_hoc_commands = settings.AD_HOC_COMMANDS
settings.AD_HOC_COMMANDS = []
with self.current_user('admin'):
response = self.get(url, expect=200)
self.assertEqual(response['passwords_needed_to_start'], [])
response = self.post(url, {}, expect=400)
finally:
settings.AD_HOC_COMMANDS = ad_hoc_commands
# Try to relaunch after the inventory has been marked inactive.
self.inventory.delete()
with self.current_user('admin'):
response = self.get(url, expect=200)
self.assertEqual(response['passwords_needed_to_start'], [])
response = self.post(url, {}, expect=400)
# Try to relaunch with expired license.
with self.current_user('admin'):
response = self.run_test_ad_hoc_command(inventory=self.inventory2.pk)
self.create_expired_license_file()
with self.current_user('admin'):
self.post(response['related']['relaunch'], {}, expect=403)
def test_ad_hoc_command_events_list(self):
# TODO: Create test events instead of relying on playbooks execution
with self.current_user('admin'):
response = self.run_test_ad_hoc_command()
response = self.run_test_ad_hoc_command()
# Check list of ad hoc command events for a specific ad hoc command.
ad_hoc_command_id = response['id']
url = reverse('api:ad_hoc_command_ad_hoc_command_events_list', args=(ad_hoc_command_id,))
self.assertEqual(url, response['related']['events'])
with self.current_user('admin'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], self.inventory.hosts.count())
for result in response['results']:
self.assertEqual(result['ad_hoc_command'], ad_hoc_command_id)
self.assertTrue(result['id'])
self.assertTrue(result['url'])
self.assertEqual(result['event'], 'runner_on_ok')
self.assertFalse(result['failed'])
self.assertTrue(result['changed'])
self.assertTrue(result['host'] in set(self.inventory.hosts.values_list('pk', flat=True)))
self.assertTrue(result['host_name'] in set(self.inventory.hosts.values_list('name', flat=True)))
self.post(url, {}, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('normal'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], self.inventory.hosts.count())
self.post(url, {}, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('other'):
self.get(url, expect=403)
self.post(url, {}, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('nobody'):
self.get(url, expect=403)
self.post(url, {}, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user(None):
self.get(url, expect=401)
self.post(url, {}, expect=401)
self.put(url, {}, expect=401)
self.patch(url, {}, expect=401)
self.delete(url, expect=401)
# Test top level ad hoc command events list.
url = reverse('api:ad_hoc_command_event_list')
with self.current_user('admin'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], 2 * self.inventory.hosts.count())
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('normal'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], 2 * self.inventory.hosts.count())
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('other'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], 0)
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('nobody'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], 0)
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user(None):
self.get(url, expect=401)
self.post(url, {}, expect=401)
self.put(url, {}, expect=401)
self.patch(url, {}, expect=401)
self.delete(url, expect=401)
def test_ad_hoc_command_event_detail(self):
# TODO: Mock pexpect. Create test events instead of relying on playbooks execution
with self.current_user('admin'):
response = self.run_test_ad_hoc_command()
# Check ad hoc command event detail view.
ad_hoc_command_event_ids = AdHocCommandEvent.objects.values_list('pk', flat=True)
with self.current_user('admin'):
for ahce_id in ad_hoc_command_event_ids:
url = reverse('api:ad_hoc_command_event_detail', args=(ahce_id,))
response = self.get(url, expect=200)
self.assertTrue(response['ad_hoc_command'])
self.assertEqual(response['id'], ahce_id)
self.assertEqual(response['url'], url)
self.assertEqual(response['event'], 'runner_on_ok')
self.assertFalse(response['failed'])
self.assertTrue(response['changed'])
self.assertTrue(response['host'] in set(self.inventory.hosts.values_list('pk', flat=True)))
self.assertTrue(response['host_name'] in set(self.inventory.hosts.values_list('name', flat=True)))
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('normal'):
for ahce_id in ad_hoc_command_event_ids:
url = reverse('api:ad_hoc_command_event_detail', args=(ahce_id,))
self.get(url, expect=200)
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('other'):
for ahce_id in ad_hoc_command_event_ids:
url = reverse('api:ad_hoc_command_event_detail', args=(ahce_id,))
self.get(url, expect=403)
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('nobody'):
for ahce_id in ad_hoc_command_event_ids:
url = reverse('api:ad_hoc_command_event_detail', args=(ahce_id,))
self.get(url, expect=403)
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user(None):
for ahce_id in ad_hoc_command_event_ids:
url = reverse('api:ad_hoc_command_event_detail', args=(ahce_id,))
self.get(url, expect=401)
self.post(url, {}, expect=401)
self.put(url, {}, expect=401)
self.patch(url, {}, expect=401)
self.delete(url, expect=401)
@mock.patch('awx.main.tasks.BaseTask.run_pexpect', side_effect=run_pexpect_mock)
def test_ad_hoc_command_activity_stream(self, ignore):
# TODO: Test non-enterprise license
self.create_test_license_file()
with self.current_user('admin'):
response = self.run_test_ad_hoc_command()
# Check activity stream for ad hoc command. There should only be one
# entry when it was created; other changes made while running should
# not show up.
url = reverse('api:ad_hoc_command_activity_stream_list', args=(response['id'],))
self.assertEqual(url, response['related']['activity_stream'])
with self.current_user('admin'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], 1)
result = response['results'][0]
self.assertTrue(result['id'])
self.assertTrue(result['url'])
self.assertEqual(result['operation'], 'create')
self.assertTrue(result['changes'])
self.assertTrue(result['timestamp'])
self.assertEqual(result['object1'], 'ad_hoc_command')
self.assertEqual(result['object2'], '')
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('normal'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], 1)
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('other'):
self.get(url, expect=403)
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('nobody'):
self.get(url, expect=403)
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user(None):
self.get(url, expect=401)
self.post(url, {}, expect=401)
self.put(url, {}, expect=401)
self.patch(url, {}, expect=401)
self.delete(url, expect=401)
def test_host_ad_hoc_commands_list(self):
# TODO: Figure out why this test needs pexpect
with self.current_user('admin'):
response = self.run_test_ad_hoc_command()
response = self.run_test_ad_hoc_command(limit=self.host2.name)
# Test the ad hoc commands list for a host. Should only return the ad
# hoc command(s) run against that host. Posting should start a new ad
# hoc command and always set the inventory and limit based on URL.
url = reverse('api:host_ad_hoc_commands_list', args=(self.host.pk,))
with self.current_user('admin'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], 1)
response = self.run_test_ad_hoc_command(url=url, inventory=None, expect=201)
self.assertEqual(response['inventory'], self.inventory.pk)
self.assertEqual(response['limit'], self.host.name)
response = self.run_test_ad_hoc_command(url=url, inventory=self.inventory2.pk, limit=self.host2.name, expect=201)
self.assertEqual(response['inventory'], self.inventory.pk)
self.assertEqual(response['limit'], self.host.name)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('normal'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], 3)
response = self.run_test_ad_hoc_command(url=url, inventory=None, expect=201)
self.assertEqual(response['inventory'], self.inventory.pk)
self.assertEqual(response['limit'], self.host.name)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('other'):
self.get(url, expect=403)
self.post(url, {}, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('nobody'):
self.get(url, expect=403)
self.post(url, {}, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user(None):
self.get(url, expect=401)
self.post(url, {}, expect=401)
self.put(url, {}, expect=401)
self.patch(url, {}, expect=401)
self.delete(url, expect=401)
# Try to run with expired license.
self.create_expired_license_file()
with self.current_user('admin'):
self.run_test_ad_hoc_command(url=url, expect=403)
with self.current_user('normal'):
self.run_test_ad_hoc_command(url=url, expect=403)
def test_group_ad_hoc_commands_list(self):
# TODO: Figure out why this test needs pexpect
with self.current_user('admin'):
response = self.run_test_ad_hoc_command() # self.host + self.host2
response = self.run_test_ad_hoc_command(limit=self.group.name) # self.host
response = self.run_test_ad_hoc_command(limit=self.host2.name) # self.host2
# Test the ad hoc commands list for a group. Should return the ad
# hoc command(s) run against any hosts in that group. Posting should
# start a new ad hoc command and always set the inventory and limit
# based on URL.
url = reverse('api:group_ad_hoc_commands_list', args=(self.group.pk,)) # only self.host
url2 = reverse('api:group_ad_hoc_commands_list', args=(self.group2.pk,)) # self.host + self.host2
with self.current_user('admin'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], 2)
response = self.get(url2, expect=200)
self.assertEqual(response['count'], 3)
response = self.run_test_ad_hoc_command(url=url, inventory=None, expect=201)
self.assertEqual(response['inventory'], self.inventory.pk)
self.assertEqual(response['limit'], self.group.name)
response = self.run_test_ad_hoc_command(url=url, inventory=self.inventory2.pk, limit=self.group2.name, expect=201)
self.assertEqual(response['inventory'], self.inventory.pk)
self.assertEqual(response['limit'], self.group.name)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('normal'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], 4)
response = self.run_test_ad_hoc_command(url=url, inventory=None, expect=201)
self.assertEqual(response['inventory'], self.inventory.pk)
self.assertEqual(response['limit'], self.group.name)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('other'):
self.get(url, expect=403)
self.post(url, {}, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('nobody'):
self.get(url, expect=403)
self.post(url, {}, expect=403)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user(None):
self.get(url, expect=401)
self.post(url, {}, expect=401)
self.put(url, {}, expect=401)
self.patch(url, {}, expect=401)
self.delete(url, expect=401)
# Try to run with expired license.
self.create_expired_license_file()
with self.current_user('admin'):
self.run_test_ad_hoc_command(url=url, expect=403)
with self.current_user('normal'):
self.run_test_ad_hoc_command(url=url, expect=403)
def test_host_ad_hoc_command_events_list(self):
# TODO: Mock run_pexpect. Create test events instead of relying on playbooks execution
with self.current_user('admin'):
response = self.run_test_ad_hoc_command()
# Test the ad hoc command events list for a host. Should return the
# events only for that particular host.
url = reverse('api:host_ad_hoc_command_events_list', args=(self.host.pk,))
with self.current_user('admin'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], 1)
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('normal'):
response = self.get(url, expect=200)
self.assertEqual(response['count'], 1)
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('other'):
self.get(url, expect=403)
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user('nobody'):
self.get(url, expect=403)
self.post(url, {}, expect=405)
self.put(url, {}, expect=405)
self.patch(url, {}, expect=405)
self.delete(url, expect=405)
with self.current_user(None):
self.get(url, expect=401)
self.post(url, {}, expect=401)
self.put(url, {}, expect=401)
self.patch(url, {}, expect=401)
self.delete(url, expect=401)
| 49.261954
| 134
| 0.635324
| 6,017
| 47,390
| 4.766495
| 0.066312
| 0.059798
| 0.127615
| 0.053556
| 0.789505
| 0.75122
| 0.715656
| 0.690516
| 0.664191
| 0.643619
| 0
| 0.025184
| 0.244229
| 47,390
| 961
| 135
| 49.313215
| 0.775575
| 0.064739
| 0
| 0.66545
| 0
| 0
| 0.080006
| 0.024972
| 0
| 0
| 0
| 0.001041
| 0.223844
| 1
| 0.040146
| false
| 0.062044
| 0.015815
| 0.001217
| 0.064477
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
8da24519f7c36ff1ac07b23daa42d050d369cb76
| 192
|
py
|
Python
|
src/ReinforcementLearning/Modules/Agents/IAgent.py
|
B-C-WANG/ReinforcementLearningInAutoPilot
|
8d3c0b81e3db2fb4be0e52e25b700c54f5e569dc
|
[
"MIT"
] | 27
|
2019-05-14T01:06:05.000Z
|
2022-03-06T03:12:40.000Z
|
src/ReinforcementLearning/Modules/Agents/IAgent.py
|
B-C-WANG/ReinforcementLearningInAutoPilot
|
8d3c0b81e3db2fb4be0e52e25b700c54f5e569dc
|
[
"MIT"
] | null | null | null |
src/ReinforcementLearning/Modules/Agents/IAgent.py
|
B-C-WANG/ReinforcementLearningInAutoPilot
|
8d3c0b81e3db2fb4be0e52e25b700c54f5e569dc
|
[
"MIT"
] | 10
|
2020-01-20T09:39:51.000Z
|
2022-03-31T18:30:53.000Z
|
# coding:utf-8
class IAgent(object):
'''
负责调用Model和env,控制训练流程
'''
def save(self):
raise NotImplementedError()
def load(self):
raise NotImplementedError()
| 16
| 35
| 0.604167
| 18
| 192
| 6.444444
| 0.777778
| 0.155172
| 0.482759
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.007194
| 0.276042
| 192
| 11
| 36
| 17.454545
| 0.827338
| 0.177083
| 0
| 0.4
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.4
| false
| 0
| 0
| 0
| 0.6
| 0
| 1
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
a5f33cc1e28d8d9b32f54456946f909ca9a920c7
| 180
|
py
|
Python
|
Dataset/Leetcode/test/46/79.py
|
kkcookies99/UAST
|
fff81885aa07901786141a71e5600a08d7cb4868
|
[
"MIT"
] | null | null | null |
Dataset/Leetcode/test/46/79.py
|
kkcookies99/UAST
|
fff81885aa07901786141a71e5600a08d7cb4868
|
[
"MIT"
] | null | null | null |
Dataset/Leetcode/test/46/79.py
|
kkcookies99/UAST
|
fff81885aa07901786141a71e5600a08d7cb4868
|
[
"MIT"
] | null | null | null |
class Solution:
def XXX(self, nums: List[int]) -> List[List[int]]:
return [[n] + sub for i, n in enumerate(nums) for sub in self.XXX(nums[:i] + nums[i+1:])] or [nums]
| 36
| 107
| 0.594444
| 32
| 180
| 3.34375
| 0.53125
| 0.130841
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.007042
| 0.211111
| 180
| 4
| 108
| 45
| 0.746479
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0
| 0.333333
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
570458c482ee369c29c283695bc0dc84fb85bc67
| 92
|
py
|
Python
|
func/__init__.py
|
pppineapple/ProximityCaculated
|
eddbf6f9e45ec1043befdfa0e30020400338ce19
|
[
"MIT"
] | null | null | null |
func/__init__.py
|
pppineapple/ProximityCaculated
|
eddbf6f9e45ec1043befdfa0e30020400338ce19
|
[
"MIT"
] | null | null | null |
func/__init__.py
|
pppineapple/ProximityCaculated
|
eddbf6f9e45ec1043befdfa0e30020400338ce19
|
[
"MIT"
] | 1
|
2021-07-17T13:20:35.000Z
|
2021-07-17T13:20:35.000Z
|
# _*_coding:utf-8_*_
# author: pineapple
# date: 2020/9/12 下午4:05
# file __init__.py.py
| 23
| 26
| 0.663043
| 15
| 92
| 3.533333
| 0.933333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.144737
| 0.173913
| 92
| 4
| 27
| 23
| 0.552632
| 0.913043
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
5715b61fa1c1114b42127a26ccb72d0b176c9116
| 435
|
py
|
Python
|
flask_app/model/declarations.py
|
AI3SW/ai_job_teacher_flask
|
13a8271df1b165e951b90e28ce495a3e44fc833f
|
[
"MIT"
] | null | null | null |
flask_app/model/declarations.py
|
AI3SW/ai_job_teacher_flask
|
13a8271df1b165e951b90e28ce495a3e44fc833f
|
[
"MIT"
] | null | null | null |
flask_app/model/declarations.py
|
AI3SW/ai_job_teacher_flask
|
13a8271df1b165e951b90e28ce495a3e44fc833f
|
[
"MIT"
] | null | null | null |
import logging
from abc import ABC, abstractmethod
class BaseModel(ABC):
def __init__(self):
self.predictor = None
@abstractmethod
def init_model(self, config):
pass
@abstractmethod
def predict(self, input_image):
pass
@abstractmethod
def format_prediction(self, prediction):
pass
@abstractmethod
def get_visualization(self, input_image, outputs):
pass
| 18.125
| 54
| 0.662069
| 46
| 435
| 6.065217
| 0.5
| 0.243728
| 0.225806
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.268966
| 435
| 23
| 55
| 18.913043
| 0.877358
| 0
| 0
| 0.470588
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.294118
| false
| 0.235294
| 0.117647
| 0
| 0.470588
| 0
| 0
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
5735d0029752af6ec52553f5673fe53b944f206a
| 21
|
py
|
Python
|
gtfstk/_version.py
|
cjer/gtfstk
|
7e1573a2fae786f4683cefc3c9d1f0310baa5367
|
[
"MIT"
] | null | null | null |
gtfstk/_version.py
|
cjer/gtfstk
|
7e1573a2fae786f4683cefc3c9d1f0310baa5367
|
[
"MIT"
] | null | null | null |
gtfstk/_version.py
|
cjer/gtfstk
|
7e1573a2fae786f4683cefc3c9d1f0310baa5367
|
[
"MIT"
] | null | null | null |
__version__ = '9.2.3'
| 21
| 21
| 0.666667
| 4
| 21
| 2.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.157895
| 0.095238
| 21
| 1
| 21
| 21
| 0.368421
| 0
| 0
| 0
| 0
| 0
| 0.227273
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
93d922f845c8f17a588751fc9ab34aa4245b8188
| 550
|
py
|
Python
|
mru_example.py
|
maanavshah/cache-policy-lru-mru
|
c882acdfd4b4cab3f131e8a364df30a69b8d39f8
|
[
"MIT"
] | null | null | null |
mru_example.py
|
maanavshah/cache-policy-lru-mru
|
c882acdfd4b4cab3f131e8a364df30a69b8d39f8
|
[
"MIT"
] | null | null | null |
mru_example.py
|
maanavshah/cache-policy-lru-mru
|
c882acdfd4b4cab3f131e8a364df30a69b8d39f8
|
[
"MIT"
] | null | null | null |
from lib.mru import MRU
mru = MRU()
mru.insert(1)
mru.get()
mru.insert(2)
mru.get()
mru.insert(3)
mru.get()
mru.insert(4)
mru.get()
mru.insert(5)
mru.get()
mru.insert(6)
mru.get()
mru.insert(4)
mru.get()
mru.insert(1)
mru.get()
mru.insert(6)
mru.get()
mru.insert(8)
mru.get()
mru.insert(5)
mru.get()
mru.insert(1)
mru.get()
mru.insert(5)
mru.get()
"""
OUTPUT ::
[1]
[1, 2]
[1, 2, 3]
[1, 2, 3, 4]
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 6]
[1, 2, 3, 4, 6]
[2, 3, 1, 4, 6]
[2, 3, 6, 1, 4]
[2, 8, 6, 1, 4]
[5, 8, 6, 1, 4]
[5, 8, 6, 4, 1]
[8, 6, 4, 5, 1]
"""
| 10.784314
| 23
| 0.534545
| 128
| 550
| 2.296875
| 0.109375
| 0.397959
| 0.367347
| 0.612245
| 0.721088
| 0.687075
| 0.687075
| 0.537415
| 0.537415
| 0
| 0
| 0.150442
| 0.178182
| 550
| 50
| 24
| 11
| 0.5
| 0
| 0
| 0.821429
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.035714
| 0
| 0.035714
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
93f2b1465f03c8570fa224d02f34e6c51d853e7d
| 25,866
|
py
|
Python
|
src-el/rcc-reasoner/graph.py
|
EulerProject/EulerX
|
49e63e6a27be97ab30832180a47d214494388e15
|
[
"MIT"
] | 15
|
2016-02-17T20:48:29.000Z
|
2021-03-05T20:38:05.000Z
|
src-el/rcc-reasoner/graph.py
|
eddy7896/EulerX
|
49e63e6a27be97ab30832180a47d214494388e15
|
[
"MIT"
] | 16
|
2015-02-05T18:38:48.000Z
|
2021-06-14T11:38:36.000Z
|
src-el/rcc-reasoner/graph.py
|
eddy7896/EulerX
|
49e63e6a27be97ab30832180a47d214494388e15
|
[
"MIT"
] | 4
|
2016-01-26T03:24:52.000Z
|
2020-01-09T07:57:15.000Z
|
#!/usr/bin/env python
#from tables import *
from rccrelations import *
import sys
def findKey(d, value):
for k,v in d.iteritems():
if v == value:
return k
comptab = [[30, 30, 31],
[30, 10, 31],
[30, 6, 30],
[30, 20, 31],
[30, 5, 31],
[30, 3, 31],
[30, 9, 31],
[30, 1, 25],
[30, 7, 31],
[30, 21, 31],
[30, 22, 31],
[30, 4, 30],
[30, 2, 30],
[30, 8, 31],
[30, 11, 31],
[30, 27, 31],
[30, 23, 31],
[30, 29, 31],
[30, 12, 31],
[30, 17, 31],
[30, 24, 31],
[30, 18, 31],
[30, 15, 31],
[30, 14, 31],
[30, 13, 31],
[30, 16, 31],
[30, 31, 31],
[30, 19, 31],
[30, 26, 31],
[30, 28, 31],
[30, 25, 31],
[10, 30, 31],
[10, 10, 31],
[10, 6, 30],
[10, 20, 27],
[10, 5, 27],
[10, 3, 31],
[10, 9, 31],
[10, 1, 25],
[10, 7, 31],
[10, 21, 27],
[10, 22, 31],
[10, 4, 10],
[10, 2, 30],
[10, 8, 31],
[10, 11, 31],
[10, 27, 31],
[10, 23, 31],
[10, 29, 31],
[10, 12, 31],
[10, 17, 27],
[10, 24, 31],
[10, 18, 31],
[10, 15, 31],
[10, 14, 31],
[10, 13, 31],
[10, 16, 27],
[10, 31, 31],
[10, 19, 31],
[10, 26, 31],
[10, 28, 31],
[10, 25, 31],
[6, 30, 31],
[6, 10, 31],
[6, 6, 6],
[6, 20, 23],
[6, 5, 7],
[6, 3, 3],
[6, 9, 31],
[6, 1, 1],
[6, 7, 7],
[6, 21, 23],
[6, 22, 23],
[6, 4, 6],
[6, 2, 2],
[6, 8, 31],
[6, 11, 31],
[6, 27, 31],
[6, 23, 23],
[6, 29, 31],
[6, 12, 31],
[6, 17, 19],
[6, 24, 31],
[6, 18, 19],
[6, 15, 31],
[6, 14, 31],
[6, 13, 31],
[6, 16, 19],
[6, 31, 31],
[6, 19, 19],
[6, 26, 31],
[6, 28, 31],
[6, 25, 31],
[20, 30, 31],
[20, 10, 27],
[20, 6, 22],
[20, 20, 31],
[20, 5, 29],
[20, 3, 27],
[20, 9, 25],
[20, 1, 25],
[20, 7, 31],
[20, 21, 31],
[20, 22, 31],
[20, 4, 20],
[20, 2, 18],
[20, 8, 25],
[20, 11, 27],
[20, 27, 31],
[20, 23, 31],
[20, 29, 31],
[20, 12, 29],
[20, 17, 31],
[20, 24, 31],
[20, 18, 31],
[20, 15, 31],
[20, 14, 31],
[20, 13, 29],
[20, 16, 31],
[20, 31, 31],
[20, 19, 31],
[20, 26, 31],
[20, 28, 31],
[20, 25, 31],
[5, 30, 31],
[5, 10, 27],
[5, 6, 23],
[5, 20, 23],
[5, 5, 31],
[5, 3, 31],
[5, 9, 31],
[5, 1, 31],
[5, 7, 31],
[5, 21, 31],
[5, 22, 23],
[5, 4, 5],
[5, 2, 19],
[5, 8, 9],
[5, 11, 31],
[5, 27, 31],
[5, 23, 31],
[5, 29, 31],
[5, 12, 13],
[5, 17, 31],
[5, 24, 27],
[5, 18, 19],
[5, 15, 31],
[5, 14, 31],
[5, 13, 31],
[5, 16, 19],
[5, 31, 31],
[5, 19, 31],
[5, 26, 27],
[5, 28, 31],
[5, 25, 31],
[3, 30, 31],
[3, 10, 31],
[3, 6, 19],
[3, 20, 19],
[3, 5, 31],
[3, 3, 31],
[3, 9, 31],
[3, 1, 31],
[3, 7, 31],
[3, 21, 31],
[3, 22, 19],
[3, 4, 3],
[3, 2, 19],
[3, 8, 31],
[3, 11, 31],
[3, 27, 31],
[3, 23, 31],
[3, 29, 31],
[3, 12, 31],
[3, 17, 31],
[3, 24, 31],
[3, 18, 19],
[3, 15, 31],
[3, 14, 31],
[3, 13, 31],
[3, 16, 19],
[3, 31, 31],
[3, 19, 31],
[3, 26, 31],
[3, 28, 31],
[3, 25, 31],
[9, 30, 31],
[9, 10, 31],
[9, 6, 31],
[9, 20, 27],
[9, 5, 31],
[9, 3, 31],
[9, 9, 31],
[9, 1, 31],
[9, 7, 31],
[9, 21, 31],
[9, 22, 31],
[9, 4, 9],
[9, 2, 31],
[9, 8, 9],
[9, 11, 31],
[9, 27, 31],
[9, 23, 31],
[9, 29, 31],
[9, 12, 9],
[9, 17, 31],
[9, 24, 27],
[9, 18, 31],
[9, 15, 31],
[9, 14, 31],
[9, 13, 31],
[9, 16, 27],
[9, 31, 31],
[9, 19, 31],
[9, 26, 31],
[9, 28, 27],
[9, 25, 31],
[1, 30, 19],
[1, 10, 19],
[1, 6, 19],
[1, 20, 19],
[1, 5, 31],
[1, 3, 31],
[1, 9, 31],
[1, 1, 31],
[1, 7, 31],
[1, 21, 31],
[1, 22, 19],
[1, 4, 1],
[1, 2, 19],
[1, 8, 1],
[1, 11, 31],
[1, 27, 31],
[1, 23, 31],
[1, 29, 31],
[1, 12, 1],
[1, 17, 31],
[1, 24, 19],
[1, 18, 19],
[1, 15, 31],
[1, 14, 19],
[1, 13, 31],
[1, 16, 19],
[1, 31, 31],
[1, 19, 31],
[1, 26, 19],
[1, 28, 19],
[1, 25, 31],
[7, 30, 31],
[7, 10, 31],
[7, 6, 23],
[7, 20, 23],
[7, 5, 31],
[7, 3, 31],
[7, 9, 31],
[7, 1, 31],
[7, 7, 31],
[7, 21, 31],
[7, 22, 23],
[7, 4, 7],
[7, 2, 19],
[7, 8, 31],
[7, 11, 31],
[7, 27, 31],
[7, 23, 31],
[7, 29, 31],
[7, 12, 31],
[7, 17, 31],
[7, 24, 31],
[7, 18, 19],
[7, 15, 31],
[7, 14, 31],
[7, 13, 31],
[7, 16, 19],
[7, 31, 31],
[7, 19, 31],
[7, 26, 31],
[7, 28, 31],
[7, 25, 31],
[21, 30, 31],
[21, 10, 27],
[21, 6, 23],
[21, 20, 31],
[21, 5, 31],
[21, 3, 31],
[21, 9, 31],
[21, 1, 31],
[21, 7, 31],
[21, 21, 31],
[21, 22, 31],
[21, 4, 21],
[21, 2, 19],
[21, 8, 25],
[21, 11, 31],
[21, 27, 31],
[21, 23, 31],
[21, 29, 31],
[21, 12, 29],
[21, 17, 31],
[21, 24, 31],
[21, 18, 31],
[21, 15, 31],
[21, 14, 31],
[21, 13, 31],
[21, 16, 31],
[21, 31, 31],
[21, 19, 31],
[21, 26, 31],
[21, 28, 31],
[21, 25, 31],
[22, 30, 31],
[22, 10, 31],
[22, 6, 22],
[22, 20, 31],
[22, 5, 31],
[22, 3, 27],
[22, 9, 31],
[22, 1, 25],
[22, 7, 31],
[22, 21, 31],
[22, 22, 31],
[22, 4, 22],
[22, 2, 18],
[22, 8, 31],
[22, 11, 31],
[22, 27, 31],
[22, 23, 31],
[22, 29, 31],
[22, 12, 31],
[22, 17, 31],
[22, 24, 31],
[22, 18, 31],
[22, 15, 31],
[22, 14, 31],
[22, 13, 31],
[22, 16, 31],
[22, 31, 31],
[22, 19, 31],
[22, 26, 31],
[22, 28, 31],
[22, 25, 31],
[4, 30, 30],
[4, 10, 10],
[4, 6, 6],
[4, 20, 20],
[4, 5, 5],
[4, 3, 3],
[4, 9, 9],
[4, 1, 1],
[4, 7, 7],
[4, 21, 21],
[4, 22, 22],
[4, 4, 4],
[4, 2, 2],
[4, 8, 8],
[4, 11, 11],
[4, 27, 27],
[4, 23, 23],
[4, 29, 29],
[4, 12, 12],
[4, 17, 17],
[4, 24, 24],
[4, 18, 18],
[4, 15, 15],
[4, 14, 14],
[4, 13, 13],
[4, 16, 16],
[4, 31, 31],
[4, 19, 19],
[4, 26, 26],
[4, 28, 28],
[4, 25, 25],
[2, 30, 31],
[2, 10, 31],
[2, 6, 2],
[2, 20, 19],
[2, 5, 3],
[2, 3, 3],
[2, 9, 31],
[2, 1, 1],
[2, 7, 3],
[2, 21, 19],
[2, 22, 19],
[2, 4, 2],
[2, 2, 2],
[2, 8, 31],
[2, 11, 31],
[2, 27, 31],
[2, 23, 19],
[2, 29, 31],
[2, 12, 31],
[2, 17, 19],
[2, 24, 31],
[2, 18, 19],
[2, 15, 31],
[2, 14, 31],
[2, 13, 31],
[2, 16, 19],
[2, 31, 31],
[2, 19, 19],
[2, 26, 31],
[2, 28, 31],
[2, 25, 31],
[8, 30, 30],
[8, 10, 30],
[8, 6, 30],
[8, 20, 24],
[8, 5, 25],
[8, 3, 31],
[8, 9, 25],
[8, 1, 25],
[8, 7, 31],
[8, 21, 25],
[8, 22, 30],
[8, 4, 8],
[8, 2, 30],
[8, 8, 8],
[8, 11, 31],
[8, 27, 31],
[8, 23, 31],
[8, 29, 25],
[8, 12, 8],
[8, 17, 25],
[8, 24, 24],
[8, 18, 30],
[8, 15, 31],
[8, 14, 30],
[8, 13, 25],
[8, 16, 24],
[8, 31, 31],
[8, 19, 31],
[8, 26, 30],
[8, 28, 24],
[8, 25, 25],
[11, 30, 31],
[11, 10, 31],
[11, 6, 31],
[11, 20, 27],
[11, 5, 31],
[11, 3, 31],
[11, 9, 31],
[11, 1, 31],
[11, 7, 31],
[11, 21, 31],
[11, 22, 31],
[11, 4, 11],
[11, 2, 31],
[11, 8, 31],
[11, 11, 31],
[11, 27, 31],
[11, 23, 31],
[11, 29, 31],
[11, 12, 31],
[11, 17, 31],
[11, 24, 31],
[11, 18, 31],
[11, 15, 31],
[11, 14, 31],
[11, 13, 31],
[11, 16, 27],
[11, 31, 31],
[11, 19, 31],
[11, 26, 31],
[11, 28, 31],
[11, 25, 31],
[27, 30, 31],
[27, 10, 31],
[27, 6, 31],
[27, 20, 31],
[27, 5, 31],
[27, 3, 31],
[27, 9, 31],
[27, 1, 31],
[27, 7, 31],
[27, 21, 31],
[27, 22, 31],
[27, 4, 27],
[27, 2, 31],
[27, 8, 31],
[27, 11, 31],
[27, 27, 31],
[27, 23, 31],
[27, 29, 31],
[27, 12, 31],
[27, 17, 31],
[27, 24, 31],
[27, 18, 31],
[27, 15, 31],
[27, 14, 31],
[27, 13, 31],
[27, 16, 31],
[27, 31, 31],
[27, 19, 31],
[27, 26, 31],
[27, 28, 31],
[27, 25, 31],
[23, 30, 31],
[23, 10, 31],
[23, 6, 23],
[23, 20, 31],
[23, 5, 31],
[23, 3, 31],
[23, 9, 31],
[23, 1, 31],
[23, 7, 31],
[23, 21, 31],
[23, 22, 31],
[23, 4, 23],
[23, 2, 19],
[23, 8, 31],
[23, 11, 31],
[23, 27, 31],
[23, 23, 31],
[23, 29, 31],
[23, 12, 31],
[23, 17, 31],
[23, 24, 31],
[23, 18, 31],
[23, 15, 31],
[23, 14, 31],
[23, 13, 31],
[23, 16, 31],
[23, 31, 31],
[23, 19, 31],
[23, 26, 31],
[23, 28, 31],
[23, 25, 31],
[29, 30, 31],
[29, 10, 31],
[29, 6, 31],
[29, 20, 31],
[29, 5, 31],
[29, 3, 31],
[29, 9, 31],
[29, 1, 31],
[29, 7, 31],
[29, 21, 31],
[29, 22, 31],
[29, 4, 29],
[29, 2, 31],
[29, 8, 25],
[29, 11, 31],
[29, 27, 31],
[29, 23, 31],
[29, 29, 31],
[29, 12, 29],
[29, 17, 31],
[29, 24, 31],
[29, 18, 31],
[29, 15, 31],
[29, 14, 31],
[29, 13, 31],
[29, 16, 31],
[29, 31, 31],
[29, 19, 31],
[29, 26, 31],
[29, 28, 31],
[29, 25, 31],
[12, 30, 30],
[12, 10, 30],
[12, 6, 30],
[12, 20, 28],
[12, 5, 29],
[12, 3, 31],
[12, 9, 25],
[12, 1, 25],
[12, 7, 31],
[12, 21, 29],
[12, 22, 30],
[12, 4, 12],
[12, 2, 30],
[12, 8, 8],
[12, 11, 31],
[12, 27, 31],
[12, 23, 31],
[12, 29, 29],
[12, 12, 12],
[12, 17, 25],
[12, 24, 24],
[12, 18, 30],
[12, 15, 31],
[12, 14, 30],
[12, 13, 29],
[12, 16, 24],
[12, 31, 31],
[12, 19, 31],
[12, 26, 30],
[12, 28, 28],
[12, 25, 25],
[17, 30, 31],
[17, 10, 27],
[17, 6, 19],
[17, 20, 31],
[17, 5, 31],
[17, 3, 31],
[17, 9, 31],
[17, 1, 31],
[17, 7, 31],
[17, 21, 31],
[17, 22, 31],
[17, 4, 17],
[17, 2, 19],
[17, 8, 25],
[17, 11, 31],
[17, 27, 31],
[17, 23, 31],
[17, 29, 31],
[17, 12, 25],
[17, 17, 31],
[17, 24, 31],
[17, 18, 31],
[17, 15, 31],
[17, 14, 27],
[17, 13, 31],
[17, 16, 31],
[17, 31, 31],
[17, 19, 31],
[17, 26, 31],
[17, 28, 31],
[17, 25, 31],
[24, 30, 31],
[24, 10, 31],
[24, 6, 30],
[24, 20, 31],
[24, 5, 25],
[24, 3, 31],
[24, 9, 25],
[24, 1, 25],
[24, 7, 31],
[24, 21, 31],
[24, 22, 31],
[24, 4, 24],
[24, 2, 30],
[24, 8, 25],
[24, 11, 31],
[24, 27, 31],
[24, 23, 31],
[24, 29, 31],
[24, 12, 25],
[24, 17, 31],
[24, 24, 31],
[24, 18, 31],
[24, 15, 31],
[24, 14, 31],
[24, 13, 25],
[24, 16, 31],
[24, 31, 31],
[24, 19, 31],
[24, 26, 31],
[24, 28, 31],
[24, 25, 31],
[18, 30, 31],
[18, 10, 31],
[18, 6, 18],
[18, 20, 31],
[18, 5, 27],
[18, 3, 27],
[18, 9, 31],
[18, 1, 25],
[18, 7, 27],
[18, 21, 31],
[18, 22, 31],
[18, 4, 18],
[18, 2, 18],
[18, 8, 31],
[18, 11, 31],
[18, 27, 31],
[18, 23, 31],
[18, 29, 31],
[18, 12, 31],
[18, 17, 31],
[18, 24, 31],
[18, 18, 31],
[18, 15, 31],
[18, 14, 31],
[18, 13, 31],
[18, 16, 31],
[18, 31, 31],
[18, 19, 31],
[18, 26, 31],
[18, 28, 31],
[18, 25, 31],
[15, 30, 31],
[15, 10, 31],
[15, 6, 31],
[15, 20, 31],
[15, 5, 31],
[15, 3, 31],
[15, 9, 31],
[15, 1, 31],
[15, 7, 31],
[15, 21, 31],
[15, 22, 31],
[15, 4, 15],
[15, 2, 31],
[15, 8, 31],
[15, 11, 31],
[15, 27, 31],
[15, 23, 31],
[15, 29, 31],
[15, 12, 31],
[15, 17, 31],
[15, 24, 31],
[15, 18, 31],
[15, 15, 31],
[15, 14, 31],
[15, 13, 31],
[15, 16, 27],
[15, 31, 31],
[15, 19, 31],
[15, 26, 31],
[15, 28, 31],
[15, 25, 31],
[14, 30, 31],
[14, 10, 31],
[14, 6, 30],
[14, 20, 31],
[14, 5, 31],
[14, 3, 31],
[14, 9, 31],
[14, 1, 25],
[14, 7, 31],
[14, 21, 31],
[14, 22, 31],
[14, 4, 14],
[14, 2, 30],
[14, 8, 31],
[14, 11, 31],
[14, 27, 31],
[14, 23, 31],
[14, 29, 31],
[14, 12, 31],
[14, 17, 27],
[14, 24, 31],
[14, 18, 31],
[14, 15, 31],
[14, 14, 31],
[14, 13, 31],
[14, 16, 27],
[14, 31, 31],
[14, 19, 31],
[14, 26, 31],
[14, 28, 31],
[14, 25, 31],
[13, 30, 31],
[13, 10, 31],
[13, 6, 31],
[13, 20, 31],
[13, 5, 31],
[13, 3, 31],
[13, 9, 31],
[13, 1, 31],
[13, 7, 31],
[13, 21, 31],
[13, 22, 31],
[13, 4, 13],
[13, 2, 31],
[13, 8, 9],
[13, 11, 31],
[13, 27, 31],
[13, 23, 31],
[13, 29, 31],
[13, 12, 13],
[13, 17, 31],
[13, 24, 27],
[13, 18, 31],
[13, 15, 31],
[13, 14, 31],
[13, 13, 31],
[13, 16, 27],
[13, 31, 31],
[13, 19, 31],
[13, 26, 31],
[13, 28, 31],
[13, 25, 31],
[16, 30, 31],
[16, 10, 27],
[16, 6, 18],
[16, 20, 31],
[16, 5, 25],
[16, 3, 27],
[16, 9, 25],
[16, 1, 25],
[16, 7, 27],
[16, 21, 31],
[16, 22, 31],
[16, 4, 16],
[16, 2, 18],
[16, 8, 25],
[16, 11, 27],
[16, 27, 31],
[16, 23, 31],
[16, 29, 31],
[16, 12, 25],
[16, 17, 31],
[16, 24, 31],
[16, 18, 31],
[16, 15, 27],
[16, 14, 27],
[16, 13, 25],
[16, 16, 31],
[16, 31, 31],
[16, 19, 31],
[16, 26, 31],
[16, 28, 31],
[16, 25, 31],
[31, 30, 31],
[31, 10, 31],
[31, 6, 31],
[31, 20, 31],
[31, 5, 31],
[31, 3, 31],
[31, 9, 31],
[31, 1, 31],
[31, 7, 31],
[31, 21, 31],
[31, 22, 31],
[31, 4, 31],
[31, 2, 31],
[31, 8, 31],
[31, 11, 31],
[31, 27, 31],
[31, 23, 31],
[31, 29, 31],
[31, 12, 31],
[31, 17, 31],
[31, 24, 31],
[31, 18, 31],
[31, 15, 31],
[31, 14, 31],
[31, 13, 31],
[31, 16, 31],
[31, 31, 31],
[31, 19, 31],
[31, 26, 31],
[31, 28, 31],
[31, 25, 31],
[19, 30, 31],
[19, 10, 31],
[19, 6, 19],
[19, 20, 31],
[19, 5, 31],
[19, 3, 31],
[19, 9, 31],
[19, 1, 31],
[19, 7, 31],
[19, 21, 31],
[19, 22, 31],
[19, 4, 19],
[19, 2, 19],
[19, 8, 31],
[19, 11, 31],
[19, 27, 31],
[19, 23, 31],
[19, 29, 31],
[19, 12, 31],
[19, 17, 31],
[19, 24, 31],
[19, 18, 31],
[19, 15, 31],
[19, 14, 31],
[19, 13, 31],
[19, 16, 31],
[19, 31, 31],
[19, 19, 31],
[19, 26, 31],
[19, 28, 31],
[19, 25, 31],
[26, 30, 31],
[26, 10, 31],
[26, 6, 30],
[26, 20, 31],
[26, 5, 27],
[26, 3, 31],
[26, 9, 31],
[26, 1, 25],
[26, 7, 31],
[26, 21, 31],
[26, 22, 31],
[26, 4, 26],
[26, 2, 30],
[26, 8, 31],
[26, 11, 31],
[26, 27, 31],
[26, 23, 31],
[26, 29, 31],
[26, 12, 31],
[26, 17, 31],
[26, 24, 31],
[26, 18, 31],
[26, 15, 31],
[26, 14, 31],
[26, 13, 31],
[26, 16, 31],
[26, 31, 31],
[26, 19, 31],
[26, 26, 31],
[26, 28, 31],
[26, 25, 31],
[28, 30, 31],
[28, 10, 31],
[28, 6, 30],
[28, 20, 31],
[28, 5, 29],
[28, 3, 31],
[28, 9, 25],
[28, 1, 25],
[28, 7, 31],
[28, 21, 31],
[28, 22, 31],
[28, 4, 28],
[28, 2, 30],
[28, 8, 25],
[28, 11, 31],
[28, 27, 31],
[28, 23, 31],
[28, 29, 31],
[28, 12, 29],
[28, 17, 31],
[28, 24, 31],
[28, 18, 31],
[28, 15, 31],
[28, 14, 31],
[28, 13, 29],
[28, 16, 31],
[28, 31, 31],
[28, 19, 31],
[28, 26, 31],
[28, 28, 31],
[28, 25, 31],
[25, 30, 31],
[25, 10, 31],
[25, 6, 31],
[25, 20, 31],
[25, 5, 31],
[25, 3, 31],
[25, 9, 31],
[25, 1, 31],
[25, 7, 31],
[25, 21, 31],
[25, 22, 31],
[25, 4, 25],
[25, 2, 31],
[25, 8, 25],
[25, 11, 31],
[25, 27, 31],
[25, 23, 31],
[25, 29, 31],
[25, 12, 25],
[25, 17, 31],
[25, 24, 31],
[25, 18, 31],
[25, 15, 31],
[25, 14, 31],
[25, 13, 31],
[25, 16, 31],
[25, 31, 31],
[25, 19, 31],
[25, 26, 31],
[25, 28, 31],
[25, 25, 31]]
f = open("out.dot", "w")
f.write("digraph {\n\nrankdir = TB\n\n")
# write the basic 32 nodes
for i in range(32):
f.write('"' + findKey(rcc, i) + '";\n')
# f.write('"' + str(i) + '";\n')
# write the composition table nodes
ctr = 1
if sys.argv[1] == "all":
for givenNode in range(32):
for comp in comptab:
if comp[2] == givenNode:
intersection = "i" + str(ctr)
f.write('"' + intersection + '" [shape=point width = 0.1];\n')
f.write('"' + findKey(rcc, comp[0]) + '" -> "' + intersection + '";\n')
f.write('"' + findKey(rcc, comp[1]) + '" -> "' + intersection + '";\n')
f.write('"' + intersection + '" -> "' + findKey(rcc, comp[2]) + '";\n')
ctr += 1
else:
givenNode = int(sys.argv[1])
for comp in comptab:
if comp[2] == givenNode:
intersection = "i" + str(ctr)
f.write('"' + intersection + '" [shape=point width = 0.1];\n')
f.write('"' + findKey(rcc, comp[0]) + '" -> "' + intersection + '";\n')
f.write('"' + findKey(rcc, comp[1]) + '" -> "' + intersection + '";\n')
f.write('"' + intersection + '" -> "' + findKey(rcc, comp[2]) + '";\n')
ctr += 1
f.write("}")
f.close()
| 25.71173
| 87
| 0.227171
| 3,066
| 25,866
| 1.916504
| 0.027723
| 0.042886
| 0.008339
| 0.013615
| 0.065691
| 0.065691
| 0.065691
| 0.065691
| 0.065691
| 0.065691
| 0
| 0.471748
| 0.574422
| 25,866
| 1,006
| 88
| 25.71173
| 0.062046
| 0.005142
| 0
| 0.016097
| 0
| 0
| 0.006841
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.001006
| false
| 0
| 0.002012
| 0
| 0.004024
| 0
| 0
| 0
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
f50ba01ce505bdbc933b36b092b869424062f669
| 374
|
py
|
Python
|
bproxypool/controller/form.py
|
littlebai3618/bproxypool
|
358cf5c14164dadbd0d9bdf7cc3932b46ec81812
|
[
"MIT"
] | 2
|
2019-12-26T02:49:59.000Z
|
2020-02-11T09:22:07.000Z
|
bproxypool/controller/form.py
|
littlebai3618/bproxypool
|
358cf5c14164dadbd0d9bdf7cc3932b46ec81812
|
[
"MIT"
] | 3
|
2021-03-31T19:33:59.000Z
|
2021-12-13T20:29:21.000Z
|
bproxypool/controller/form.py
|
littlebai3618/bproxypool
|
358cf5c14164dadbd0d9bdf7cc3932b46ec81812
|
[
"MIT"
] | 2
|
2020-01-25T12:05:47.000Z
|
2020-07-19T02:57:12.000Z
|
from wtforms import StringField, IntegerField
from bproxypool.core import BaseForm, ParamRequired
class DeleteProxyForm(BaseForm):
proxy = StringField(validators=[ParamRequired()])
source = StringField(validators=[ParamRequired()])
class CoolDownProxyForm(BaseForm):
proxy = StringField(validators=[ParamRequired()])
expire = IntegerField(default=1800)
| 26.714286
| 54
| 0.775401
| 33
| 374
| 8.787879
| 0.545455
| 0.217241
| 0.351724
| 0.234483
| 0.324138
| 0
| 0
| 0
| 0
| 0
| 0
| 0.012232
| 0.125668
| 374
| 13
| 55
| 28.769231
| 0.874618
| 0
| 0
| 0.25
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.25
| 0
| 1
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
f51e233309686910e7f0c9c88e074703c23422fc
| 247
|
py
|
Python
|
webtool/server/views/client/__init__.py
|
wodo/WebTool3
|
1582a03d619434d8a6139f705a1b5860e9b5b8b8
|
[
"BSD-2-Clause"
] | 13
|
2018-12-16T21:01:24.000Z
|
2019-07-03T06:23:41.000Z
|
webtool/server/views/client/__init__.py
|
dav-kempten/WebTool3
|
859f39df67cb0f853c7fe33cb5d08b999d8692fc
|
[
"BSD-2-Clause"
] | 26
|
2019-07-07T06:44:06.000Z
|
2021-09-07T07:28:34.000Z
|
webtool/server/views/client/__init__.py
|
dav-kempten/WebTool3
|
859f39df67cb0f853c7fe33cb5d08b999d8692fc
|
[
"BSD-2-Clause"
] | 3
|
2017-06-18T06:22:52.000Z
|
2019-07-03T06:21:05.000Z
|
# -*- coding: utf-8 -*-
from .guide import GuideViewSet
from .activity import ActivityViewSet
from .topic import TopicViewSet
from .collective import CollectiveViewSet
from .booklet import BookletViewSet
from .urls import router as client_router
| 27.444444
| 41
| 0.809717
| 30
| 247
| 6.633333
| 0.633333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.004651
| 0.129555
| 247
| 8
| 42
| 30.875
| 0.92093
| 0.08502
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
f524dfd03d8cf873461481c7fbd2062721a588e7
| 178
|
py
|
Python
|
bacli/__init__.py
|
JoeyDP/bacli
|
729a660a9a10d7b8a77d554c3fb1df08624f1620
|
[
"MIT"
] | null | null | null |
bacli/__init__.py
|
JoeyDP/bacli
|
729a660a9a10d7b8a77d554c3fb1df08624f1620
|
[
"MIT"
] | null | null | null |
bacli/__init__.py
|
JoeyDP/bacli
|
729a660a9a10d7b8a77d554c3fb1df08624f1620
|
[
"MIT"
] | null | null | null |
""" Define what is imported with `from bacli import *`. """
from .cli import cli
from .cli_legacy import command, setDescription
__all__ = ["cli", "command", "setDescription"]
| 25.428571
| 59
| 0.713483
| 22
| 178
| 5.545455
| 0.590909
| 0.114754
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.151685
| 178
| 6
| 60
| 29.666667
| 0.807947
| 0.286517
| 0
| 0
| 0
| 0
| 0.201681
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.666667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
f546b5bb3701fbd2acd5b2ba10790b3f02a95aa2
| 92
|
py
|
Python
|
src/models/__init__.py
|
charlesxjyang/DeepGeyser
|
59f54c67667800f091d7af1805c04bbc36c7624b
|
[
"Apache-2.0"
] | null | null | null |
src/models/__init__.py
|
charlesxjyang/DeepGeyser
|
59f54c67667800f091d7af1805c04bbc36c7624b
|
[
"Apache-2.0"
] | null | null | null |
src/models/__init__.py
|
charlesxjyang/DeepGeyser
|
59f54c67667800f091d7af1805c04bbc36c7624b
|
[
"Apache-2.0"
] | null | null | null |
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 8 15:20:24 2018
@author: Charles Yang
"""
| 11.5
| 35
| 0.576087
| 15
| 92
| 3.533333
| 0.933333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.166667
| 0.217391
| 92
| 7
| 36
| 13.142857
| 0.569444
| 0.880435
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
f546bea6310d7e0570fa95351b5d0ffedf9c5822
| 210
|
py
|
Python
|
urls.py
|
chkgk/otree_file_upload
|
b49f0f4b3dc5f22edd8a8af55af831dfb3c88102
|
[
"MIT"
] | 1
|
2020-04-15T12:30:02.000Z
|
2020-04-15T12:30:02.000Z
|
urls.py
|
chkgk/otree_file_upload
|
b49f0f4b3dc5f22edd8a8af55af831dfb3c88102
|
[
"MIT"
] | null | null | null |
urls.py
|
chkgk/otree_file_upload
|
b49f0f4b3dc5f22edd8a8af55af831dfb3c88102
|
[
"MIT"
] | null | null | null |
from otree.urls import urlpatterns
from django.conf.urls.static import static
import settings
# additional url pattern for media url
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
| 35
| 76
| 0.838095
| 30
| 210
| 5.766667
| 0.533333
| 0.138728
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.1
| 210
| 6
| 76
| 35
| 0.915344
| 0.171429
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.75
| 0
| 0.75
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
191decb802d99b48151eeae262423ae746ebbe1f
| 1,110
|
py
|
Python
|
DataTypes/Python/lists/circular_linked_list.py
|
shoriwe/LVaED
|
68ca38eed2b4c2b1b7a6a8304c8effbcf2f977f7
|
[
"MIT"
] | null | null | null |
DataTypes/Python/lists/circular_linked_list.py
|
shoriwe/LVaED
|
68ca38eed2b4c2b1b7a6a8304c8effbcf2f977f7
|
[
"MIT"
] | 19
|
2021-02-08T22:14:16.000Z
|
2021-03-03T15:13:07.000Z
|
DataTypes/Python/lists/circular_linked_list.py
|
shoriwe/LVaED
|
68ca38eed2b4c2b1b7a6a8304c8effbcf2f977f7
|
[
"MIT"
] | 3
|
2021-08-30T01:06:32.000Z
|
2022-02-21T03:22:28.000Z
|
import double_linked_list
from lists import list_node
class CircularLinkedList(object):
def __init__(self):
self.length = 0
self.content = double_linked_list.DoublyLinkedList()
def update(self):
if self.content.start is not None:
self.content.start.before = self.content.end
self.length = self.content.length
def clear(self):
self.content.clear()
self.update()
def append(self, obj: object):
self.content.append(obj)
self.update()
def insert(self, index: int, obj: object):
self.content.insert(index, obj)
self.update()
def remove(self, obj: object):
self.content.remove(obj)
self.update()
def remove_node(self, node: list_node.ListNode):
self.content.remove_node(node)
def index(self, obj: object) -> int:
return self.content.index(obj)
def to_list(self):
return [node.value for node in self]
def __iter__(self):
yield from self.content
def __contains__(self, item):
return item in self.content
def __setitem__(self, index, value):
self.content.__setitem__(index, value)
def __getitem__(self, index):
return self.content.__getitem__(index)
| 21.346154
| 54
| 0.730631
| 160
| 1,110
| 4.8375
| 0.275
| 0.213178
| 0.067183
| 0.077519
| 0.118863
| 0
| 0
| 0
| 0
| 0
| 0
| 0.00106
| 0.15045
| 1,110
| 51
| 55
| 21.764706
| 0.819724
| 0
| 0
| 0.111111
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.361111
| false
| 0
| 0.055556
| 0.111111
| 0.555556
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
194c792f5591a9425c4efb247e07cc690eba579a
| 1,101
|
py
|
Python
|
cloudrail/knowledge/context/azure/network/azure_subnet.py
|
my-devops-info/cloudrail-knowledge
|
b7c1bbd6fe1faeb79c105a01c0debbe24d031a0e
|
[
"MIT"
] | null | null | null |
cloudrail/knowledge/context/azure/network/azure_subnet.py
|
my-devops-info/cloudrail-knowledge
|
b7c1bbd6fe1faeb79c105a01c0debbe24d031a0e
|
[
"MIT"
] | null | null | null |
cloudrail/knowledge/context/azure/network/azure_subnet.py
|
my-devops-info/cloudrail-knowledge
|
b7c1bbd6fe1faeb79c105a01c0debbe24d031a0e
|
[
"MIT"
] | null | null | null |
from typing import List, Optional
from cloudrail.knowledge.context.azure.azure_resource import AzureResource
from cloudrail.knowledge.context.azure.constants.azure_resource_type import AzureResourceType
from cloudrail.knowledge.context.azure.network.azure_nsg import AzureNetworkSecurityGroup
class AzureSubnet(AzureResource):
"""
Attributes:
name: The name of this subnet
security_group_id: The id of the security group thats attached to this subnet
security_group: The actual security group thats attached to this subnet
"""
def __init__(self, security_group_id: Optional[str], name: str):
super().__init__(AzureResourceType.AZURERM_NETWORK_SECURITY_GROUP)
self.security_group_id: str = security_group_id
self.name: str = name
self.security_group: AzureNetworkSecurityGroup = None
def get_cloud_resource_url(self) -> Optional[str]:
pass # Requires VNET
@property
def is_tagable(self) -> bool:
return False
def get_keys(self) -> List[str]:
return [self.get_id()]
| 34.40625
| 93
| 0.722979
| 133
| 1,101
| 5.75188
| 0.390977
| 0.152941
| 0.078431
| 0.113725
| 0.23268
| 0.099346
| 0.099346
| 0
| 0
| 0
| 0
| 0
| 0.206176
| 1,101
| 31
| 94
| 35.516129
| 0.875286
| 0.198002
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.235294
| false
| 0.058824
| 0.235294
| 0.117647
| 0.647059
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
|
0
| 4
|
1994dc18ad266c62fe9ea55648d8ec65eafac0fa
| 203
|
py
|
Python
|
logger.py
|
vjdw/piper
|
80af3f6c54029dd0a514211a0ecd73399b503356
|
[
"MIT"
] | null | null | null |
logger.py
|
vjdw/piper
|
80af3f6c54029dd0a514211a0ecd73399b503356
|
[
"MIT"
] | null | null | null |
logger.py
|
vjdw/piper
|
80af3f6c54029dd0a514211a0ecd73399b503356
|
[
"MIT"
] | null | null | null |
class Logger:
def __init__(self, filepath):
self.filepath = filepath
def write(self, msg):
with open(self.filepath, "a") as logfile:
logfile.write("{}\n".format(msg))
| 25.375
| 49
| 0.596059
| 25
| 203
| 4.68
| 0.6
| 0.307692
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.261084
| 203
| 7
| 50
| 29
| 0.78
| 0
| 0
| 0
| 0
| 0
| 0.024631
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
19a1cd73d94a8e7818b17b7b066df1a134f69129
| 480
|
py
|
Python
|
数字媒体安全应用与实践/learn_flask_the_hard_way/app/auth/forms.py
|
jckling/only-python
|
9600d798889dfc38b8ecd65abd26e4ce657910d9
|
[
"MIT"
] | 1
|
2019-10-12T01:09:15.000Z
|
2019-10-12T01:09:15.000Z
|
数字媒体安全应用与实践/learn_flask_the_hard_way/app/auth/forms.py
|
jckling/only-python
|
9600d798889dfc38b8ecd65abd26e4ce657910d9
|
[
"MIT"
] | null | null | null |
数字媒体安全应用与实践/learn_flask_the_hard_way/app/auth/forms.py
|
jckling/only-python
|
9600d798889dfc38b8ecd65abd26e4ce657910d9
|
[
"MIT"
] | 1
|
2019-10-12T01:10:13.000Z
|
2019-10-12T01:10:13.000Z
|
# -*- coding: UTF-8 -*-
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField
from wtforms.validators import DataRequired, Email
class SignInForm(FlaskForm):
email = StringField('邮箱', validators=[DataRequired(), Email()])
password = PasswordField('密码', validators=[DataRequired()])
class SignUpForm(FlaskForm):
email = StringField('邮箱', validators=[DataRequired(), Email()])
password = PasswordField('密码', validators=[DataRequired()])
| 32
| 67
| 0.73125
| 47
| 480
| 7.446809
| 0.425532
| 0.251429
| 0.142857
| 0.154286
| 0.565714
| 0.565714
| 0.565714
| 0.565714
| 0.565714
| 0.565714
| 0
| 0.002387
| 0.127083
| 480
| 14
| 68
| 34.285714
| 0.832936
| 0.04375
| 0
| 0.444444
| 0
| 0
| 0.017505
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0.333333
| 0.333333
| 0
| 1
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 1
| 0
|
0
| 4
|
5fd832087cddffd8a834461600499be0e776344c
| 17
|
py
|
Python
|
files/functionMap.py
|
kronokiller/userInput
|
69377c2804b276b7bbb02fcc5adfdc9ac70bc403
|
[
"MIT"
] | null | null | null |
files/functionMap.py
|
kronokiller/userInput
|
69377c2804b276b7bbb02fcc5adfdc9ac70bc403
|
[
"MIT"
] | null | null | null |
files/functionMap.py
|
kronokiller/userInput
|
69377c2804b276b7bbb02fcc5adfdc9ac70bc403
|
[
"MIT"
] | null | null | null |
functionMap = {}
| 8.5
| 16
| 0.647059
| 1
| 17
| 11
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.176471
| 17
| 1
| 17
| 17
| 0.785714
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
5fd857e70cb92c2b1b538eaa6a1bea35b02c0cb5
| 904
|
py
|
Python
|
server/ffstore/util/LogUtil.py
|
AsherYang/ThreeLine
|
351dc8bfd1c0a536ffbf36ce8b1af953cc71f93a
|
[
"Apache-2.0"
] | 1
|
2017-05-02T10:02:28.000Z
|
2017-05-02T10:02:28.000Z
|
server/ffstore/util/LogUtil.py
|
AsherYang/ThreeLine
|
351dc8bfd1c0a536ffbf36ce8b1af953cc71f93a
|
[
"Apache-2.0"
] | null | null | null |
server/ffstore/util/LogUtil.py
|
AsherYang/ThreeLine
|
351dc8bfd1c0a536ffbf36ce8b1af953cc71f93a
|
[
"Apache-2.0"
] | null | null | null |
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Author: AsherYang
Email : ouyangfan1991@gmail.com
Date : 2018/6/23
Desc : log 输出工具,用于在linux 终端输出到指定文件
"""
import logging
default_log_file = '/work/ffstore_server/logs/ffstore.log'
class LogUtil:
"""
init log util
"""
def __init__(self, logFileName=default_log_file):
pass
# logging.basicConfig(
# level=logging.DEBUG,
# format='%(asctime)s-%(levelname)s-%(message)s',
# datefmt='%y-%m-%d %H:%M',
# filename=logFileName,
# filemode='w'
# )
# console = logging.StreamHandler()
# console.setLevel(logging.INFO)
# formatter = logging.Formatter('%(asctime)s-%(levelname)s-%(message)s')
# console.setFormatter(formatter)
# logging.getLogger('').addHandler(console)
def getLogging(self):
return logging
| 23.179487
| 80
| 0.590708
| 95
| 904
| 5.526316
| 0.663158
| 0.038095
| 0.053333
| 0.068571
| 0.099048
| 0.099048
| 0
| 0
| 0
| 0
| 0
| 0.017857
| 0.256637
| 904
| 38
| 81
| 23.789474
| 0.763393
| 0.596239
| 0
| 0
| 0
| 0
| 0.112462
| 0.112462
| 0
| 0
| 0
| 0
| 0
| 1
| 0.285714
| false
| 0.142857
| 0.142857
| 0.142857
| 0.714286
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
|
0
| 4
|
2723c5d9f4eb86cbf0817f3ab705ba086e21eac9
| 808
|
py
|
Python
|
materials/migrations/0058_auto_20190329_1018.py
|
mgovoni-devel/MatD3
|
5b68d147f886bce427f92bb560159e62cec2d4e7
|
[
"BSD-2-Clause-FreeBSD"
] | 7
|
2019-09-14T07:24:09.000Z
|
2021-06-15T16:15:05.000Z
|
materials/migrations/0058_auto_20190329_1018.py
|
mgovoni-devel/MatD3
|
5b68d147f886bce427f92bb560159e62cec2d4e7
|
[
"BSD-2-Clause-FreeBSD"
] | 14
|
2019-12-05T01:49:19.000Z
|
2021-06-23T18:34:51.000Z
|
materials/migrations/0058_auto_20190329_1018.py
|
mgovoni-devel/MatD3
|
5b68d147f886bce427f92bb560159e62cec2d4e7
|
[
"BSD-2-Clause-FreeBSD"
] | 2
|
2019-11-06T21:16:57.000Z
|
2019-11-30T10:51:44.000Z
|
# Generated by Django 2.1.7 on 2019-03-29 14:18
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('materials', '0057_auto_20190328_2245'),
]
operations = [
migrations.RemoveField(
model_name='bondangle',
name='idinfo_ptr',
),
migrations.RemoveField(
model_name='bondangle',
name='system',
),
migrations.RemoveField(
model_name='bondlength',
name='idinfo_ptr',
),
migrations.RemoveField(
model_name='bondlength',
name='system',
),
migrations.DeleteModel(
name='BondAngle',
),
migrations.DeleteModel(
name='BondLength',
),
]
| 22.444444
| 49
| 0.529703
| 66
| 808
| 6.348485
| 0.515152
| 0.200477
| 0.24821
| 0.286396
| 0.458234
| 0.458234
| 0.205251
| 0
| 0
| 0
| 0
| 0.059961
| 0.360149
| 808
| 35
| 50
| 23.085714
| 0.750484
| 0.055693
| 0
| 0.689655
| 1
| 0
| 0.159001
| 0.030223
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.034483
| 0
| 0.137931
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
272e1fa059ce06a47fee8f64720dfe01b52aa18f
| 382
|
py
|
Python
|
src/pipedown/nodes/metrics/mean_squared_error.py
|
brendanhasz/drainpype
|
a183acec7cae1ef9fde260868e2b021516a8cd7f
|
[
"MIT"
] | 2
|
2021-03-03T12:11:24.000Z
|
2021-03-18T15:09:52.000Z
|
src/pipedown/nodes/metrics/mean_squared_error.py
|
brendanhasz/pipedown
|
a183acec7cae1ef9fde260868e2b021516a8cd7f
|
[
"MIT"
] | null | null | null |
src/pipedown/nodes/metrics/mean_squared_error.py
|
brendanhasz/pipedown
|
a183acec7cae1ef9fde260868e2b021516a8cd7f
|
[
"MIT"
] | null | null | null |
import pandas as pd
from pipedown.nodes.base.metric import Metric
from pipedown.utils.urls import get_node_url
class MeanSquaredError(Metric):
CODE_URL = get_node_url("metrics/mean_squared_error.py")
def run(self, y_pred: pd.Series, y_true: pd.Series):
return ((y_pred - y_true).pow(2)).mean()
def get_metric_name(self):
return "mean_squared_error"
| 25.466667
| 60
| 0.727749
| 60
| 382
| 4.383333
| 0.55
| 0.091255
| 0.076046
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.003145
| 0.167539
| 382
| 14
| 61
| 27.285714
| 0.823899
| 0
| 0
| 0
| 0
| 0
| 0.123037
| 0.075916
| 0
| 0
| 0
| 0
| 0
| 1
| 0.222222
| false
| 0
| 0.333333
| 0.222222
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 1
| 1
| 0
|
0
| 4
|
274d5a5bd2d1c0accb8d690414f74d162c118a64
| 191
|
py
|
Python
|
baseq/rna/__init__.py
|
basedata10/baseq
|
0f1786c3392a51a6ec7cb0f32355cd28eaa5df29
|
[
"MIT"
] | 1
|
2018-08-30T20:29:17.000Z
|
2018-08-30T20:29:17.000Z
|
baseq/rna/__init__.py
|
basedata10/baseq
|
0f1786c3392a51a6ec7cb0f32355cd28eaa5df29
|
[
"MIT"
] | null | null | null |
baseq/rna/__init__.py
|
basedata10/baseq
|
0f1786c3392a51a6ec7cb0f32355cd28eaa5df29
|
[
"MIT"
] | null | null | null |
import click
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@click.group(context_settings=CONTEXT_SETTINGS)
def cli():
click.echo("Welcome to baseq-RNA")
from .cmd import *
| 23.875
| 59
| 0.732984
| 27
| 191
| 5
| 0.703704
| 0.333333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.109948
| 191
| 8
| 60
| 23.875
| 0.794118
| 0
| 0
| 0
| 0
| 0
| 0.145833
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.166667
| false
| 0
| 0.333333
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
275d86f8cfa02e340363c2b9ed6462a0c70294b3
| 61
|
py
|
Python
|
AI/pyneogame/__init__.py
|
neodev-ab/NeoGame
|
f2c0c010b2ea13d99e23ecd2f59592433fbd2385
|
[
"MIT"
] | 2
|
2019-08-29T13:52:36.000Z
|
2019-11-23T23:41:54.000Z
|
AI/pyneogame/Agent/__init__.py
|
neodev-ab/NeoGame
|
f2c0c010b2ea13d99e23ecd2f59592433fbd2385
|
[
"MIT"
] | 9
|
2019-08-30T08:01:37.000Z
|
2021-10-06T06:48:09.000Z
|
AI/pyneogame/__init__.py
|
neodev-ab/NeoGame
|
f2c0c010b2ea13d99e23ecd2f59592433fbd2385
|
[
"MIT"
] | 2
|
2019-05-12T14:41:42.000Z
|
2019-11-23T23:47:24.000Z
|
# from .game_engine import Game
# from .QAgent import QAgent
| 20.333333
| 31
| 0.770492
| 9
| 61
| 5.111111
| 0.555556
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.163934
| 61
| 2
| 32
| 30.5
| 0.901961
| 0.918033
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
276cad461ebefaabba7e0218b238eb853fb86080
| 154
|
py
|
Python
|
fempy/fem1d/tests/test_fem1d.py
|
EastMagica/fempy
|
5f16fe458a63ede5a49925a691924fbbbea767ec
|
[
"MIT"
] | null | null | null |
fempy/fem1d/tests/test_fem1d.py
|
EastMagica/fempy
|
5f16fe458a63ede5a49925a691924fbbbea767ec
|
[
"MIT"
] | null | null | null |
fempy/fem1d/tests/test_fem1d.py
|
EastMagica/fempy
|
5f16fe458a63ede5a49925a691924fbbbea767ec
|
[
"MIT"
] | null | null | null |
#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author : east
# @time : 2019/10/8 23:40
# @file : test_fem1d.py
# @project : fem
# software : PyCharm
| 17.111111
| 28
| 0.571429
| 22
| 154
| 3.954545
| 0.954545
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.108333
| 0.220779
| 154
| 8
| 29
| 19.25
| 0.616667
| 0.902597
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
2779a1da98bb4e2785711207c06cc3307b6f0e1b
| 139
|
py
|
Python
|
umu-python/app/service/tosca/vo/tgif/stream.py
|
suomitek/cubeai
|
cc4c0f5f445a552d239910da63944307c1f06e37
|
[
"Apache-2.0"
] | null | null | null |
umu-python/app/service/tosca/vo/tgif/stream.py
|
suomitek/cubeai
|
cc4c0f5f445a552d239910da63944307c1f06e37
|
[
"Apache-2.0"
] | null | null | null |
umu-python/app/service/tosca/vo/tgif/stream.py
|
suomitek/cubeai
|
cc4c0f5f445a552d239910da63944307c1f06e37
|
[
"Apache-2.0"
] | null | null | null |
class Stream(dict):
def __init__(self, subscribes, publishes):
dict.__init__(self, subscribes=subscribes, publishes=publishes)
| 34.75
| 71
| 0.741007
| 15
| 139
| 6.333333
| 0.533333
| 0.168421
| 0.378947
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.151079
| 139
| 3
| 72
| 46.333333
| 0.805085
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
278f7f2ecdb5592d2bbf19d48b18eaa9ae2e5057
| 171
|
py
|
Python
|
src/RepairManager/rules/rules_abc.py
|
RichardZhaoW/DLWorkspace
|
27d3a3a82e59305bdc67dbfd69098d493f8b3cd5
|
[
"MIT"
] | 38
|
2020-07-13T08:46:39.000Z
|
2021-02-08T01:38:44.000Z
|
src/RepairManager/rules/rules_abc.py
|
RichardZhaoW/DLWorkspace
|
27d3a3a82e59305bdc67dbfd69098d493f8b3cd5
|
[
"MIT"
] | null | null | null |
src/RepairManager/rules/rules_abc.py
|
RichardZhaoW/DLWorkspace
|
27d3a3a82e59305bdc67dbfd69098d493f8b3cd5
|
[
"MIT"
] | 20
|
2020-07-14T03:38:50.000Z
|
2021-01-08T06:24:17.000Z
|
import abc
class Rule(abc.ABC):
@abc.abstractmethod
def check_status(self):
pass
@abc.abstractmethod
def take_action(self):
pass
| 14.25
| 27
| 0.602339
| 20
| 171
| 5.05
| 0.6
| 0.118812
| 0.39604
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.315789
| 171
| 11
| 28
| 15.545455
| 0.863248
| 0
| 0
| 0.5
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0.25
| 0.125
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
27b01d66fdaae6663286afaf631f60be64fa4613
| 182
|
py
|
Python
|
oauth2_provider/tests/models.py
|
sfx/django-oauth-toolkit
|
08ce1d63bfad16905a7d9f758591c0e8c65706ec
|
[
"BSD-2-Clause-FreeBSD"
] | 1
|
2016-06-29T10:24:55.000Z
|
2016-06-29T10:24:55.000Z
|
oauth2_provider/tests/models.py
|
sfx/django-oauth-toolkit
|
08ce1d63bfad16905a7d9f758591c0e8c65706ec
|
[
"BSD-2-Clause-FreeBSD"
] | null | null | null |
oauth2_provider/tests/models.py
|
sfx/django-oauth-toolkit
|
08ce1d63bfad16905a7d9f758591c0e8c65706ec
|
[
"BSD-2-Clause-FreeBSD"
] | 1
|
2016-01-20T18:11:05.000Z
|
2016-01-20T18:11:05.000Z
|
from django.db import models
from oauth2_provider.models import AbstractApplication
class TestApplication(AbstractApplication):
custom_field = models.CharField(max_length=255)
| 26
| 54
| 0.840659
| 21
| 182
| 7.142857
| 0.761905
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.02454
| 0.104396
| 182
| 6
| 55
| 30.333333
| 0.895706
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
27b4a3e9696ac52585d4bbc54a6504e560a2c4ec
| 50
|
py
|
Python
|
template/class_imp.py
|
hax0rs/GovHack2016
|
7879afa3e0a76ae8ef51f82b94c173e161cb86c9
|
[
"MIT"
] | 1
|
2016-07-30T17:08:38.000Z
|
2016-07-30T17:08:38.000Z
|
template/class_imp.py
|
hax0rs/GovHack2016
|
7879afa3e0a76ae8ef51f82b94c173e161cb86c9
|
[
"MIT"
] | 1
|
2016-07-30T17:10:58.000Z
|
2016-07-31T03:10:30.000Z
|
template/class_imp.py
|
hax0rs/GovHack2016
|
7879afa3e0a76ae8ef51f82b94c173e161cb86c9
|
[
"MIT"
] | null | null | null |
class Demo:
def __init__(self):
print ("done")
| 12.5
| 20
| 0.66
| 7
| 50
| 4.142857
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.18
| 50
| 3
| 21
| 16.666667
| 0.707317
| 0
| 0
| 0
| 0
| 0
| 0.08
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0
| 0
| 0.666667
| 0.333333
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
27c2a6b848e12efc3b96622df5f92b4900824017
| 239
|
py
|
Python
|
src/exercises/Ex01_saying_hello/test_hello.py
|
trcooke/57-exercises-python
|
5df95d566dd6eccfb98cc32f877807e46e5ea39e
|
[
"MIT"
] | null | null | null |
src/exercises/Ex01_saying_hello/test_hello.py
|
trcooke/57-exercises-python
|
5df95d566dd6eccfb98cc32f877807e46e5ea39e
|
[
"MIT"
] | null | null | null |
src/exercises/Ex01_saying_hello/test_hello.py
|
trcooke/57-exercises-python
|
5df95d566dd6eccfb98cc32f877807e46e5ea39e
|
[
"MIT"
] | null | null | null |
import unittest
from exercises.Ex01_saying_hello import hello
class TestHello(unittest.TestCase):
def test_givenValidName_returnsExpectedString(self):
self.assertEqual(hello.sayhello('Tim'), 'Hello, Tim, nice to meet you!')
| 26.555556
| 80
| 0.774059
| 29
| 239
| 6.241379
| 0.758621
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.009662
| 0.133891
| 239
| 8
| 81
| 29.875
| 0.864734
| 0
| 0
| 0
| 0
| 0
| 0.133891
| 0
| 0
| 0
| 0
| 0
| 0.2
| 1
| 0.2
| false
| 0
| 0.4
| 0
| 0.8
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
27c6a373a24b624e21abacdd617534d9716af7d4
| 38
|
py
|
Python
|
Lists/Liststring.py
|
Anilkumar95/python-75-hackathon
|
0cc9304e46ceace826090614b46d8048a068d106
|
[
"MIT"
] | null | null | null |
Lists/Liststring.py
|
Anilkumar95/python-75-hackathon
|
0cc9304e46ceace826090614b46d8048a068d106
|
[
"MIT"
] | null | null | null |
Lists/Liststring.py
|
Anilkumar95/python-75-hackathon
|
0cc9304e46ceace826090614b46d8048a068d106
|
[
"MIT"
] | 2
|
2019-01-27T16:59:48.000Z
|
2019-01-29T13:07:40.000Z
|
List=['Yuvan','Bajjurla']
print(List)
| 12.666667
| 25
| 0.684211
| 5
| 38
| 5.2
| 0.8
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.052632
| 38
| 2
| 26
| 19
| 0.722222
| 0
| 0
| 0
| 0
| 0
| 0.342105
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.5
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
27ebabf334f7d55ba0e91a053cf35c5541787dbf
| 3,572
|
py
|
Python
|
configs/clang.py
|
pointhi/benchmarks
|
68899480c0fc8d361079a81edc6d816d5f17d58e
|
[
"UPL-1.0"
] | 7
|
2018-12-10T02:41:43.000Z
|
2020-06-18T06:13:59.000Z
|
configs/clang.py
|
pointhi/benchmarks
|
68899480c0fc8d361079a81edc6d816d5f17d58e
|
[
"UPL-1.0"
] | 23
|
2018-06-07T07:46:27.000Z
|
2018-08-06T17:57:39.000Z
|
configs/clang.py
|
pointhi/benchmarks
|
68899480c0fc8d361079a81edc6d816d5f17d58e
|
[
"UPL-1.0"
] | 2
|
2018-06-07T08:04:52.000Z
|
2018-06-07T09:06:21.000Z
|
from functools import partial
clang_kwargs = {'build_system_func': partial(build_system_executor, cc_version='--version', as_version='--version')}
harness.add_runtime('clang-O0', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O0"}, **clang_kwargs)
harness.add_runtime('clang-O1', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O1"}, **clang_kwargs)
harness.add_runtime('clang-O2', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O2"}, **clang_kwargs)
harness.add_runtime('clang-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3"}, **clang_kwargs)
harness.add_runtime('clang-lld-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3", "LDFLAGS": "-fuse-ld=lld"}, **clang_kwargs)
harness.add_runtime('clang-lld-lto-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3 -flto", "LDFLAGS": "-fuse-ld=lld -flto"}, **clang_kwargs)
harness.add_runtime('clang-gold-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3", "LDFLAGS": "-fuse-ld=gold"}, **clang_kwargs)
harness.add_runtime('clang-gold-lto-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3 -flto", "LDFLAGS": "-flto -fuse-ld=gold", "RANLAB": "/bin/true"}, **clang_kwargs)
harness.add_runtime('clang-march-native-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3 -march=native"}, **clang_kwargs)
harness.add_runtime('clang-Ofast', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -Ofast"}, **clang_kwargs)
harness.add_runtime('clang-Os', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -Os"}, **clang_kwargs)
harness.add_runtime('clang-Oz', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -Oz"}, **clang_kwargs)
harness.add_runtime('clang-fno-strict-aliasing-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3 -fno-strict-aliasing"}, **clang_kwargs)
harness.add_runtime('clang-fno-strict-overflow-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3 -fno-strict-overflow"}, **clang_kwargs)
harness.add_runtime('clang-ftrivial-auto-var-init-pattern-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3 -ftrivial-auto-var-init=pattern"}, **clang_kwargs)
harness.add_runtime('clang-fno-delete-null-pointer-checks-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3 -fno-delete-null-pointer-checks"}, **clang_kwargs)
harness.add_runtime('clang-safe-stack-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3 -fsanitize=safe-stack"}, **clang_kwargs)
harness.add_runtime('clang-lld-cfi-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3 -fsanitize=cfi -flto -fvisibility=hidden", "LDFLAGS": "-fuse-ld=lld"}, **clang_kwargs)
harness.add_runtime('clang-stack-protector-O3', {"CC": "${CLANG}", "AS": "as", "CFLAGS": "-Wno-everything -O3 -fstack-protector"}, **clang_kwargs)
harness.add_runtime('clang-nostack-protector-O3', {"CC": "${CLANG}", "AS": "as", "CFLAGS": "-Wno-everything -O3 -fno-stack-protector"}, **clang_kwargs)
harness.add_runtime('clang-stack-protector-strong-O3', {"CC": "${CLANG}", "AS": "as", "CFLAGS": "-Wno-everything -O3 -fstack-protector-strong"}, **clang_kwargs)
harness.add_runtime('clang-stack-protector-all-O3', {"CC": "${CLANG}", "AS": "as", "CFLAGS": "-Wno-everything -O3 -fstack-protector-all"}, **clang_kwargs)
harness.add_runtime('polly-O3', {"CC": "${CLANG}", "AS": "${CLANG}", "CFLAGS": "-Wno-everything -O3 -mllvm -polly"}, **clang_kwargs)
| 127.571429
| 194
| 0.645577
| 468
| 3,572
| 4.814103
| 0.136752
| 0.117177
| 0.173546
| 0.214825
| 0.839769
| 0.782512
| 0.650688
| 0.462051
| 0.380826
| 0.315135
| 0
| 0.012041
| 0.069989
| 3,572
| 27
| 195
| 132.296296
| 0.666165
| 0
| 0
| 0
| 0
| 0
| 0.529675
| 0.109742
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.04
| 0
| 0.04
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
27f11d82a515f57f578bc54c55c8823df47a9526
| 43,063
|
py
|
Python
|
tests/test_processing.py
|
oleksiyfesyk/wfdb-mod
|
18834726c00248b738d6f23c835f0d0254aeddc6
|
[
"MIT"
] | null | null | null |
tests/test_processing.py
|
oleksiyfesyk/wfdb-mod
|
18834726c00248b738d6f23c835f0d0254aeddc6
|
[
"MIT"
] | null | null | null |
tests/test_processing.py
|
oleksiyfesyk/wfdb-mod
|
18834726c00248b738d6f23c835f0d0254aeddc6
|
[
"MIT"
] | null | null | null |
import wfdb
import numpy
class test_processing():
def test_1(self):
sig, fields = wfdb.srdsamp('sampledata/100')
ann = wfdb.rdann('sampledata/100', 'atr')
fs = fields['fs']
fs_target = 50
new_sig, new_ann = wfdb.processing.resample_singlechan(sig[:, 0], ann, fs, fs_target)
expected_length = int(sig.shape[0]*fs_target/fs)
assert new_sig.shape[0] == expected_length
def test_2(self):
sig, fields = wfdb.srdsamp('sampledata/100')
ann = wfdb.rdann('sampledata/100', 'atr')
fs = fields['fs']
fs_target = 50
new_sig, new_ann = wfdb.processing.resample_multichan(sig, ann, fs, fs_target)
expected_length = int(sig.shape[0]*fs_target/fs)
assert new_sig.shape[0] == expected_length
assert new_sig.shape[1] == sig.shape[1]
def test_3(self):
sig, _ = wfdb.srdsamp('sampledata/100')
lb = -5
ub = 15
x = wfdb.processing.normalize(sig[:, 0], lb, ub)
assert x.shape[0] == sig.shape[0]
assert numpy.min(x) >= lb
assert numpy.max(x) <= ub
def test_4(self):
x = []
hp, sp = wfdb.processing.find_peaks(x)
assert hp.shape == (0,)
assert sp.shape == (0,)
def test_5(self):
x = [0, 2, 1, 0, -10, -15, -15, -15, 9, 8, 0, 0, 1, 2, 10]
hp, sp = wfdb.processing.find_peaks(x)
assert numpy.array_equal(hp, [1, 8])
assert numpy.array_equal(sp, [6, 10])
def test_6(self):
x = [1183,1168,1111,1037,974,935,917,914,922,928,934,934,935,936,933,934,934,936,936,935,934,933,935,937,938,936,933,935,935,936,937,932,932,933,931,934,935,930,927,931,932,932,934,934,930,932,933,936,937,935,934,937,936,935,935,934,934,936,937,936,935,933,929,932,934,937,936,935,933,934,937,937,934,934,932,933,936,938,939,937,932,931,935,936,936,930,928,926,928,929,927,926,925,926,926,926,925,925,922,925,925,929,929,931,929,931,938,942,943,945,943,945,950,953,951,950,950,948,950,953,952,950,950,953,956,959,959,956,955,952,955,955,953,953,951,950,951,950,950,949,949,951,952,953,953,953,949,948,947,951,951,949,948,947,947,950,948,944,942,944,947,949,948,946,942,944,945,946,946,946,944,944,946,947,946,945,945,944,944,947,946,944,944,946,948,950,950,948,943,946,946,948,948,948,946,948,948,949,948,946,942,943,945,945,947,943,943,947,950,957,959,959,955,957,959,960,960,962,962,964,966,968,967,965,963,965,966,967,966,964,961,962,962,966,969,968,964,960,956,956,950,945,940,941,939,941,942,940,939,939,938,941,942,939,936,935,937,940,942,940,937,939,939,941,940,938,937,934,930,926,920,917,913,906,901,900,913,935,959,989,1029,1077,1132,1171,1194,1195,1160,1089,1007,946,920,913,918,926,933,933,931,931,934,936,934,935,931,936,934,937,936,934,932,930,933,933,932,929,927,929,931,933,932,932,932,932,931,934,933,932,928,930,932,931,933,932,930,933,934,933,933,933,930,928,930,933,932,930,928,930,931,933,932,932,931,930,933,935,935,934,933,934,936,939,937,936,934,933,933,934,935,932,932,930,931,932,932,929,926,928,928,929,927,926,924,926,927,926,926,928,924,924,922,928,926,926,927,929,931,935,937,939,939,940,946,948,949,950,950,950,954,957,954,954,953,957,960,960,961,959,957,958,960,960,962,958,954,955,958,958,956,956,953,953,955,957,955,954,952,954,952,954,954,954,951,950,955,958,955,954,953,953,953,956,957,951,947,947,951,951,951,951,947,945,947,949,951,948,946,949,948,951,950,950,948,948,953,951,951,950,948,949,951,951,950,950,946,947,951,952,951,949,947,946,948,950,949,946,947,947,949,950,949,947,943,947,950,950,952,949,950,949,953,956,955,956,955,959,962,963,963,964,963,964,967,971,971,970,968,969,969,971,971,969,965,966,966,970,969,967,964,965,970,976,975,972,965,962,961,959,954,951,947,948,946,950,950,949,948,946,947,946,948,946,944,943,946,947,947,945,941,943,944,947,944,944,940,940,937,934,925,920,914,913,911,908,899,892,902,923,945,976,1007,1047,1101,1156,1197,1215,1206,1156,1078,996,939,920,921,926,931,935,938,937,937,934,933,934,934,936,935,933,932,932,934,934,935,934,931,933,936,937,937,936,932,933,937,936,933,934,932,932,934,935,936,933,931,933,935,936,937,935,933,936,939,938,938,935,934,938,937,939,938,937,934,934,934,937,934,936,933,935,936,937,934,933,933,936,936,940,940,938,935,935,939,939,940,940,936,937,938,939,937,935,932,933,935,937,937,934,933,933,935,937,934,933,935,933,936,938,941,939,938,942,945,948,951,951,950,950,954,956,957,955,953,955,956,958,956,957,953,956,957,960,959,957,953,958,959,959,959,959,954,957,959,960,959,957,957,956,959,959,958,957,955,953,956,955,956,953,952,951,952,953,953,951,950,951,951,953,953,952,950,950,950,952,951,951,947,947,947,949,948,946,944,944,947,947,947,946,944,943,946,948,948,946,943,945,946,947,948,948,946,949,951,951,949,949,947,947,947,951,949,948,946,947,949,952,950,948,946,946,949,951,949,952,950,953,960,962,964,964,962,962,967,970,973,969,969,970,969,970,968,965,962,963,965,967,967,965,961,961,962,964,966,965,967,971,971,966,963,959,953,951,949,948,947,947,943,944,947,947,945,944,940,942,943,944,943,942,939,940,940,944,943,941,938,938,937,933,925,916,912,906,898,898,911,935,959,986,1024,1073,1128,1168,1191,1195,1172,1122,1049,986,939,917,907,907,914,923,928,932,934,936,936,937,934,934,934,935,937,934,933,932,931,937,935,934,934,932,933,935,935,931,930,934,933,939,938,938,933,936,937,939,937,937,935,934,936,936,937,936,936,935,939,940,941,939,935,934,937,939,938,934,934,936,934,939,937,935,934,935,936,939,938,934,934,935,938,938,937,937,935,935,938,939,938,935,937,938,938,939,940,939,936,936,937,937,937,936,933,933,937,939,938,938,936,938,938,940,940,938,939,941,947,949,951,951,950,953,951,954,956,955,955,954,953,955,957,957,955,955,956,958,957,953,952,952,953,955,956,955,954,953,956,956,956,954,949,952,953,956,955,952,947,949,951,952,951,947,945,945,948,948,949,948,944,945,949,949,947,945,944,942,946,947,948,946,941,942,944,945,947,944,940,939,941,942,942,938,938,938,940,940,941,940,940,941,941,944,946,944,942,941,943,944,944,942,940,940,942,944,941,940,938,939,942,945,948,949,950,953,955,957,957,957,957,962,964,963,965,966,964,964,965,965,963,961,958,959,959,960,961,958,953,955,960,965,963,959,949,948,947,945,943,940,937,938,940,943,944,941,937,936,934,938,936,935,934,933,934,937,936,934,932,935,936,937,938,937,932,926,922,919,914,905,895,895,913,937,963,997,1045,1104,1155,1183,1182,1144,1070,995,944,920,912,914,923,931,932,933,933,934,931,932,931,930,930,930,926,927,930,931,932,931,930,928,929,931,933,929,928,932,934,936,935,935,932,933,933,931,933,928,931,931,933,933,932,929,928,930,931,933,931,934,933,934,937,938,936,935,933,933,934,936,937,933,931,933,936,936,936,936,932,933,934,938,937,933,929,929,930,932,930,931,927,926,931,932,932,929,926,924,925,927,930,927,924,924,926,929,929,931,928,933,935,939,942,943,940,940,944,949,952,952,949,952,955,959,959,956,955,952,953,953,953,951,952,953,958,957,954,955,952,953,950,956,957,957,955,954,954,956,955,952,951,952,954,954,954,951,948,949,950,950,951,951,949,948,949,950,949,946,942,944,946,951,950,949,946,947,949,951,949,945,943,943,945,946,944,944,944,943,943,946,946,945,944,942,944,947,949,945,945,945,947,948,947,948,948,948,950,948,950,948,947,944,949,951,955,953,954,954,958,961,962,963,961,961,964,969,968,967,966,967,970,970,969,969,967,966,965,967,967,967,964,964,965,966,970,970,967,964,961,960,958,952,946,945,941,945,944,945,943,941,944,943,944,943,943,942,943,944,942,940,938,939,940,943,940,941,937,935,930,924,920,915,905,899,906,926,956,985,1021,1073,1128,1173,1201,1200,1160,1089,1008,953,924,914,917,927,933,936,935,936,935,936,938,939,941,937,934,935,938,939,938,936,932,933,932,933,936,934,933,932,934,937,938,936,932,932,934,936,937,937,936,936,939,939,938,937,935,935,936,937,933,936,933,935,934,936,936,935,934,935,937,938,939,938,936,937,939,938,941,937,934,936,938,939,940,937,935,936,937,938,936,933,932,930,933,933,931,930,927,927,929,929,929,930,928,929,929,932,931,930,931,931,934,935,938,937,937,939,944,948,951,951,946,951,951,956,955,958,954,957,960,959,960,961,957,958,960,961,962,961,959,958,961,960,960,960,957,955,958,958,959,957,955,957,959,959,957,957,955,955,955,958,959,956,957,957,959,961,961,957,956,956,958,956,959,957,953,954,956,957,956,956,952,951,953,954,955,955,953,949,955,956,953,954,951,954,953,956,954,954,954,953,958,957,957,956,952,954,956,957,955,955,952,952,953,955,954,949,947,952,953,956,955,954,951,952,955,956,956,956,955,957,959,966,968,967,965,966,969,969,972,974,972,975,978,978,976,976,974,971,974,975,977,974,968,970,976,980,982,977,967,966,961,962,962,956,952,955,955,956,951,953,948,951,953,952,953,952,949,948,950,951,952,952,949,949,949,953,951,951,946,941,938,930,924,919,908,904,912,935,963,992,1023,1070,1131,1183,1221,1234,1219,1167,1078,995,942,920,924,937,946,946,944,942,940,941,943,942,941,940,937,937,939,940,939,938,937,938,939,942,941,940,938,937,938,939,938,936,936,936,938,940,939,939,937,938,937,938,939,938,937,939,940,940,940,940,936,937,938,939,937,936,935,937,937,939,939,937,935,937,935,940,939,938,936,937,940,940,940,941,938,938,938,941,939,937,934,935,936,937,936,937,935,936,936,939,939,939,938,937,942,945,945,946,947,946,948,953,956,954,955,956,960,962,964,963,958,959,960,960,963,959,959,961,960,961,961,960,958,959,960,961,962,961,958,960,958,960,960,956,954,955,957,957,956,957,955,952,955,957,955,953,950,952,953,955,953,953,951,953,953,954,953,952,948,950,951,952,951,948,948,947,950,951,952,951,949,949,950,952,953,951,950,950,952,953,954,953,949,953,953,956,956,953,951,951,954,954,954,953,951,950,954,955,955,954,952,954,959,960,965,965,962,967,968,971,974,972,971,973,976,979,978,975,971,971,971,970,973,972,969,967,969,972,979,978,974,967,964,967,964,959,955,955,957,959,960,958,954,953,952,953,952,951,949,948,949,950,950,950,945,945,947,946,946,948,946,948,947,950,948,944,939,932,924,923,916,905,901,917,946,979,1019,1071,1126,1173,1194,1176,1114,1028,954,918,919,932,941,945,941,941,942,946,947,944,939,939,941,941,943,939,939,940,940,940,942,940,939,939,942,944,945,944,942,941,943,945,947,943,942,944,943,946,946,946,944,943,945,944,944,944,940,941,944,945,944,942,942,944,944,947,945,943,941,942,943,947,946,945,943,946,947,946,945,942,941,940,943,945,944,941,938,938,940,942,940,937,939,938,939,941,941,939,939,940,943,945,944,943,939,942,945,946,947,948,949,950,953,954,955,954,952,954,958,958,961,956,953,955,958,959,959,959,955,956,959,959,959,956,951,954,954,953,951,948,948,949,952,954,953,949,948,951,949,952,951,950,950,949,951,952,952,949,950,948,948,948,949,943,944,945,947,950,948,947,943,943,945,944,943,942,943,943,944,946,947,945,942,941,944,944,946,945,941,944,944,944,944,944,940,942,941,943,947,946,945,946,949,949,948,946,945,948,948,955,957,955,957,955,959,960,960,957,955,958,962,962,964,962,961,964,966,966,963,963,962,961,963,964,960,960,961,964,967,965,958,955,948,945,944,945,940,937,935,935,936,938,939,937,935,937,939,941,939,936,935,934,937,938,939,939,935,934,935,936,930,923,915,910,905,895,890,896,910,930,950,966,986,1010,1041,1084,1127,1164,1188,1192,1162,1091,1016,957,920,906,908,918,926,929,930,927,926,928,929,930,929,928,924,923,923,927,929,927,924,924,927,930,927,925,925,925,928,928,932,932,930,929,928,929,926,926,923,924,927,928,927,928,924,925,928,929,929,930,926,929,928,930,927,928,926,927,926,926,925,924,921,921,925,927,931,929,926,925,924,925,924,922,923,922,924,923,922,919,915,916,918,918,917,914,912,915,916,917,918,916,915,914,918,919,921,924,922,926,931,933,936,936,934,939,942,944,943,942,943,944,947,947,948,946,943,944,947,948,948,948,944,945,948,951,952,947,944,944,945,948,947,946,945,945,946,948,947,945,943,944,943,945,943,943,940,942,943,944,943,940,937,939,939,942,940,939,938,938,939,944,941,939,938,937,940,941,940,939,938,937,939,939,938,937,935,935,937,939,939,936,935,936,938,939,941,937,936,937,939,940,941,937,938,937,940,941,939,939,938,937,940,940,941,940,937,938,941,946,948,947,947,949,948,954,957,957,958,957,960,963,966,964,959,959,959,960,957,958,955,955,956,955,957,959,959,960,956,955,952,948,942,940,941,942,941,938,937,937,937,937,938,937,934,932,934,937,936,935,933,933,934,934,935,935,930,931,933,935,934,935,932,930,926,920,916,911,902,896,896,911,935,961,992,1036,1092,1144,1181,1194,1172,1115,1040,972,927,910,908,913,923,925,929,927,927,926,927,930,929,926,925,924,923,926,925,924,925,925,925,929,929,926,925,926,928,928,928,926,924,924,928,929,927,928,923,927,928,931,928,926,925,926,927,927,929,926,925,924,926,928,927,925,924,927,927,929,928,927,925,924,926,927,927,925,924,925,927,929,930,927,926,928,924,927,929,926,923,925,924,925,924,920,918,919,921,923,921,921,918,919,922,923,923,923,918,920,921,926,926,925,923,926,932,935,938,938,938,943,942,946,944,945,944,946,947,949,949,948,949,949,951,951,951,951,946,949,950,951,951,950,946,948,951,951,950,946,946,946,948,950,948,947,944,945,946,947,946,945,943,942,945,946,944,943,945,943,946,948,948,947,945,945,945,945,946,944,943,944,944,945,945,944,940,943,941,946,943,943,941,941,943,945,945,943,940,942,944,947,947,945,941,942,944,947,946,946,942,942,945,943,945,942,941,942,943,944,945,944,941,942,945,946,945,947,948,951,955,960,961,961,956,956,961,962,962,960,961,961,965,966,966,967,963,963,964,964,962,959,957,959,960,962,961,961,962,968,970,967,961,956,951,951,949,947,946,939,937,939,941,942,943,941,938,938,940,941,942,941,936,938,941,942,940,939,937,938,937,939,936,931,921,914,913,910,903,896,894,905,930,959,988,1023,1070,1127,1175,1201,1210,1191,1137,1056,984,941,917,912,912,920,927,935,937,936,935,933,933,934,933,930,927,927,928,929,928,928,926,926,926,928,930,928,925,926,928,932,932,933,928,928,932,933,933,932,926,929,929,931,934,931,929,930,931,933,934,933,930,929,933,935,935,934,930,931,933,934,935,932,929,929,931,934,934,929,930,930,930,932,934,930,930,929,931,934,935,931,930,930,933,931,934,932,931,929,932,933,932,930,928,928,929,931,931,929,929,927,930,933,932,931,930,929,934,936,938,938,937,940,945,947,949,950,950,951,953,956,954,952,949,952,954,955,955,952,951,951,953,953,953,952,949,951,951,953,954,952,952,953,953,957,955,954,950,950,950,952,951,948,947,947,951,951,952,951,948,948,950,953,953,951,950,949,951,954,953,948,947,948,951,950,948,949,944,946,946,949,949,946,944,943,945,945,945,944,944,943,946,949,949,946,945,947,947,947,948,948,944,946,946,949,948,946,944,946,946,947,947,946,945,946,946,949,948,949,947,947,948,949,950,948,949,948,951,955,956,954,955,959,961,961,963,961,961,963,966,968,970,970,967,968,968,969,969,966,964,966,967,969,969,966,967,971,974,972,966,961,956,950,949,950,950,946,944,944,946,947,946,943,941,943,943,944,947,945,941,942,944,945,943,940,940,939,941,942,941,936,927,920,916,914,908,898,888,885,890,895,905,919,931,946,958,979,1014,1061,1112,1158,1186,1189,1156,1095,1017,954,924,918,923,930,933,934,934,937,938,936,934,933,933,936,937,936,934,934,936,939,939,939,933,933,938,939,936,936,934,935,937,939,940,938,937,938,937,938,938,935,934,934,937,938,939,939,937,937,941,940,938,937,935,935,936,936,936,936,936,934,937,938,939,940,936,935,940,940,940,939,937,939,942,942,940,938,936,937,935,941,938,940,937,937,938,939,939,938,935,936,936,939,936,935,932,932,935,935,937,935,933,932,937,938,937,936,935,936,941,942,946,945,945,945,948,952,951,949,946,947,953,955,955,956,952,952,952,957,956,955,952,952,953,954,954,951,950,948,949,953,952,951,950,951,953,955,954,953,949,948,951,954,953,951,949,950,951,950,950,949,947,946,948,948,949,948,946,945,946,948,949,947,943,946,945,949,946,946,942,943,944,947,946,943,943,944,945,948,948,947,946,946,947,948,945,944,943,941,945,946,946,949,946,946,948,948,947,946,942,944,946,948,947,946,948,952,954,959,958,958,958,955,962,965,967,968,968,969,971,969,970,969,964,965,967,965,964,959,959,963,967,967,962,956,950,948,946,948,948,947,942,943,945,946,946,942,938,941,940,943,943,943,943,942,943,942,941,939,939,941,941,943,943,942,939,937,935,927,920,915,908,901,903,919,948,978,1014,1065,1124,1170,1191,1175,1120,1039,969,930,915,915,923,930,933,936,936,935,935,934,935,934,936,934,932,931,935,935,934,933,931,930,932,934,933,933,931,932,936,937,936,934,933,934,935,935,935,933,933,935,936,936,933,929,931,931,933,936,936,935,935,936,936,937,936,933,931,930,929,934,935,936,934,932,934,937,937,933,932,931,932,934,933,933,931,933,933,935,931,930,928,927,926,927,928,925,921,921,923,927,928,925,923,925,925,929,932,931,931,935,938,942,941,942,942,943,948,951,951,950,950,952,953,955,955,958,955,955,957,956,957,958,955,956,957,960,958,957,954,955,958,960,958,956,955,954,957,959,956,955,952,950,956,958,956,956,953,954,952,956,957,954,952,950,952,953,954,951,949,952,950,952,952,950,948,948,950,954,954,953,952,954,954,956,955,953,951,951,952,954,952,951,949,948,949,952,953,950,948,951,954,953,953,953,950,952,954,957,955,954,953,955,959,962,962,963,963,963,967,969,971,971,972,975,976,979,976,977,975,972,976,978,975,973,974,973,972,972,976,976,975,974,970,967,963,958,955,955,953,953,952,951,951,950,954,954,953,951,949,949,952,953,953,952,948,947,949,950,947,942,935,926,923,919,908,905,915,942,972,1007,1048,1102,1151,1193,1210,1196,1139,1056,981,933,918,916,917,914,917,922,932,942,942,939,938,938,939,942,942,939,938,939,940,943,942,942,942,940,943,945,945,942,941,940,942,944,942,940,940,939,941,941,943,941,940,938,939,943,942,942,940,941,944,947,945,945,943,943,944,946,945,943,940,940,943,946,944,942,940,939,942,944,945,943,942,940,944,943,943,942,939,941,941,944,943,941,938,940,942,940,939,940,936,938,937,938,938,937,936,938,940,942,942,945,947,948,952,956,958,957,957,958,960,960,960,960,962,961,964,965,965,963,963,963,965,967,964,965,965,964,966,968,965,963,962,960,964,964,962,963,960,959,959,961,963,961,960,958,959,963,959,960,959,957,961,960,960,958,956,955,955,959,959,955,954,954,955,959,958,956,956,957,957,960,959,960,956,957,958,956,957,956,955,953,956,958,956,956,955,954,957,955,957,956,957,955,958,960,959,960,957,954,956,959,960,957,955,958,958,963,963,967,967,969,968,971,972,973,974,975,979,982,986,980,980,978,978,980,977,975,972,974,976,978,978,975,970,967,973,978,981,982,979,972,967,968,963,961,957,955,957,957,956,956,953,953,953,955,951,947,948,947,949,951,950,949,948,948,949,950,949,946,939,933,927,927,920,913,907,918,947,977,1005,1047,1097,1151,1192,1209,1196,1143,1063,980,935,923,928,937,941,943,946,946,945,944,942,941,944,945,943,943,943,943,945,948,946,943,943,942,943,945,945,943,942,943,943,946,944,943,940,939,943,944,945,945,944,944,944,947,946,945,945,944,947,947,945,945,944,944,945,946,945,944,942,942,943,946,947,945,943,942,944,948,947,946,945,945,947,947,946,944,945,944,946,947,945,943,943,940,942,945,943,942,939,940,939,944,943,943,945,943,945,947,945,944,945,945,948,951,949,950,950,949,953,958,957,955,954,957,960,963,962,961,960,960,962,963,962,965,963,964,966,967,966,965,964,963,962,962,963,964,961,958,960,963,962,960,961,956,960,961,959,958,958,957,961,961,962,960,960,960,958,960,960,958,956,958,957,957,958,956,955,954,955,958,957,955,954,954,954,957,956,956,952,953,952,955,956,954,953,954,955,957,958,955,954,953,954,957,957,957,955,953,953,954,957,956,954,952,955,959,957,955,954,956,959,963,966,971,973,969,972,974,971,971,973,974,974,979,979,976,974,974,974,975,975,974,975,973,974,975,971,971,969,969,975,982,983,977,969,964,966,964,958,955,954,951,953,956,954,952,949,950,950,952,951,949,948,947,952,952,952,952,948,946,945,949,943,934,926,920,915,910,904,911,928,957,990,1032,1087,1138,1170,1178,1155,1100,1024,962,927,920,929,940,942,939,939,938,938,942,940,936,937,935,936,939,941,939,936,933,934,938,939,938,935,936,938,941,941,938,936,935,937,941,940,936,937,935,939,940,938,938,936,937,937,939,938,936,936,935,936,939,938,938,937,937,937,938,937,937,938,939,940,943,940,938,937,935,939,942,940,937,936,935,937,938,938,936,932,929,934,936,936,936,929,932,934,936,936,934,932,930,931,934,934,931,933,932,934,937,937,938,937,938,943,943,947,947,947,946,948,950,949,950,952,951,952,955,952,954,954,953,954,954,956,953,949,948,951,954,952,950,950,948,947,950,949,946,944,945,947,952,951,949,949,947,948,947,947,946,945,944,946,948,949,947,945,941,943,946,946,943,942,941,943,944,942,946,944,943,945,945,944,943,942,942,945,945,945,944,941,941,943,946,946,944,945,943,945,945,944,941,940,938,940,941,942,942,941,943,946,949,947,946,946,946,947,948,951,950,950,950,955,957,956,956,956,957,960,963,963,964,962,959,961,962,960,959,961,960,959,960,959,958,960,963,963,960,952,945,946,941,942,943,940,937,935,933,937,939,940,937,938,933,935,938,938,937,933,934,936,938,941,935,931,934,935,934,925,917,913,909,903,896,898,909,932,959,994,1041,1094,1141,1171,1178,1150,1092,1015,952,920,910,913,922,925,926,924,926,929,928,930,928,927,928,927,930,929,930,928,927,932,933,930,930,929,927,931,933,934,932,932,931,930,932,930,927,923,924,927,928,927,928,928,927,929,931,931,930,930,929,930,930,929,929,926,928,927,929,929,926,925,925,927,928,930,926,926,926,927,930,929,927,927,924,928,929,929,928,924,923,925,927,926,920,919,918,919,921,920,916,917,916,917,919,918,918,920,922,924,929,928,929,929,931,934,936,938,940,940,939,944,947,947,947,946,949,949,950,952,950,949,950,953,955,954,954,951,951,952,953,952,950,949,949,949,952,950,948,944,944,946,948,948,949,947,947,949,951,952,950,946,947,948,949,950,946,944,943,945,948,947,946,945,943,946,946,943,944,944,943,944,945,945,943,941,942,942,944,944,944,941,942,944,947,945,944,941,943,944,947,947,946,945,944,946,947,947,945,944,944,945,944,944,942,943,943,946,946,947,947,944,948,948,955,956,958,959,960,961,962,962,962,961,963,969,968,969,970,967,965,965,967,966,962,960,962,964,967,964,961,962,966,969,972,968,960,958,954,954,953,949,947,944,938,941,945,947,943,941,942,942,944,944,942,943,941,944,945,944,943,942,943,945,945,944,943,942,940,940,941,928,920,916,915,914,905,901,906,926,955,986,1026,1074,1127,1169,1194,1199,1162,1088,1002,943,918,921,933,938,940,940,936,938,938,939,938,935,934,936,940,939,937,938,935,938,941,939,940,936,935,938,940,940,939,938,935,940,943,940,938,936,935,938,941,938,936,936,936,938,938,940,938,936,934,936,940,939,940,938,936,939,940,944,942,940,938,940,943,942,938,936,937,940,941,938,938,937,937,937,939,937,937,936,936,937,939,939,935,936,933,935,936,936,934,937,935,937,938,938,938,936,936,938,940,941,941,942,943,947,950,951,951,951,954,955,959,959,959,956,957,961,964,964,961,964,963,963,965,962,962,961,959,961,964,962,963,960,960,962,962,962,962,960,959,960,964,966,962,960,959,964,964,964,963,959,957,959,962,959,958,958,956,958,961,960,958,956,956,957,959,960,957,957,956,956,959,957,956,954,952,953,957,957,953,953,952,954,954,955,954,952,954,956,957,956,956,955,954,955,959,959,961,956,956,959,958,958,957,957,955,956,958,958,955,954,956,961,963,967,967,968,967,970,975,973,968,967,966,970,973,975,976,972,974,977,978,979,975,975,973,974,973,976,974,973,969,973,976,979,980,978,972,967,966,965,960,955,954,955,956,955,951,950,949,951,951,951,952,950,949,949,949,951,949,949,947,950,952,953,950,949,944,940,935,928,923,916,909,905,907,920,943,967,995,1034,1087,1141,1178,1194,1187,1144,1080,1004,950,925,924,933,943,946,944,942,942,946,949,947,945,941,942,944,945,947,946,943,942,946,945,946,944,939,942,945,946,944,944,943,942,945,945,946,943,944,945,945,947,946,945,943,944,947,949,947,946,943,944,946,944,943,942,944,941,943,946,947,944,942,942,946,948,950,947,945,946,949,947,946,946,945,942,945,948,944,944,944,942,942,944,942,944,941,939,941,944,943,943,941,940,943,945,946,944,941,944,946,948,949,947,948,947,951,952,955,955,955,956,958,962,962,961,959,960,963,965,965,965,964,962,965,967,967,965,962,963,963,965,966,966,963,963,965,966,963,962,960,959,960,964,961,961,959,959,960,962,961,958,956,957,959,961,960,959,958,956,959,962,961,959,958,957,955,957,957,956,955,955,955,957,957,956,953,955,954,957,958,957,956,954,957,958,957,956,955,953,955,958,957,956,954,952,953,955,956,954,955,953,955,958,959,957,957,955,958,959,959,958,958,962,966,970,971,968,964,965,970,976,977,977,977,977,978,981,980,978,978,973,975,977,976,975,970,969,970,972,975,978,979,979,984,984,978,971,965,963,962,962,960,956,955,952,953,956,956,954,952,952,951,952,949,948,947,948,949,950,949,950,949,947,951,950,947,944,936,932,929,929,920,908,903,915,935,961,988,1024,1071,1123,1163,1182,1176,1136,1073,1002,952,929,922,926,931,936,937,941,939,941,939,937,945,947,947,944,942,940,942,943,942,944,940,937,940,943,943,941,941,940,940,944,942,941,939,938,941,941,942,941,940,940,941,945,944,943,941,941,940,941,939,939,937,937,939,941,941,940,939,938,940,942,942,942,941,939,943,944,944,942,941,941,943,945,947,945,945,941,945,946,945,943,941,939,941,941,941,939,937,935,935,935,935,936,934,937,938,939,937,935,935,938,939,940,939,941,941,942,943,949,950,951,951,952,955,956,958,957,957,958,958,961,961,961,961,959,960,960,964,960,958,957,960,963,961,959,957,956,956,960,957,957,955,954,958,958,958,957,957,955,955,959,955,958,956,955,956,954,956,956,954,950,953,956,955,954,951,950,950,953,952,953,952,949,950,953,955,953,951,952,952,952,951,949,948,950,952,956,958,956,956,951,953,954,952,950,949,950,951,952,953,952,953,950,953,956,955,953,952,951,953,958,958,960,963,964,969,970,967,965,967,970,972,974,975,975,973,971,974,975,971,971,969,966,967,967,967,966,968,969,967,967,964,958,954,949,952,954,953,952,949,951,952,951,948,948,946,944,946,948,948,948,944,944,946,948,948,948,946,946,947,949,945,938,930,926,923,917,908,906,921,947,979,1012,1055,1107,1151,1179,1188,1166,1099,1022,964,932,922,925,933,939,942,938,942,945,946,944,942,939,941,942,942,941,940,939,941,942,942,942,941,938,938,939,940,939,938,937,939,939,939,937,936,937,939,940,940,941,939,938,940,941,938,940,937,937,939,939,938,938,934,936,938,943,940,937,938,937,937,940,939,937,939,940,941,942,942,938,938,936,937,939,938,933,933,930,931,931,931,930,926,927,930,931,931,931,929,929,932,931,931,929,931,929,931,934,936,937,938,941,945,946,947,951,951,952,957,959,958,955,958,959,960,962,961,960,960,957,960,961,962,960,961,960,959,960,960,959,958,957,958,963,961,958,957,956,954,958,959,959,954,954,955,958,960,955,956,954,956,959,958,956,954,952,953,955,954,953,952,950,952,956,955,953,953,953,954,956,955,953,953,953,951,953,953,952,949,951,953,954,954,953,951,950,952,953,953,953,952,952,952,957,957,953,952,951,955,957,955,952,952,952,955,963,965,967,967,967,969,971,972,976,975,973,978,978,975,973,972,973,972,973,973,971,970,968,967,969,975,977,977,970,966,966,962,958,954,953,953,953,952,950,947,947,950,950,950,949,947,945,950,952,951,950,949,949,950,951,950,943,933,924,922,920,910,905,913,935,969,1003,1044,1096,1150,1190,1221,1228,1205,1155,1098,1045,1008,980,956,937,922,910,908,920,932,941,941,939,941,943,941,940,937,937,938,940,939,939,937,937,941,943,942,941,942,942,941,944,943,940,938,937,940,943,939,938,938,939,941,942,943,940,939,938,941,943,943,942,940,939,942,944,941,944,942,942,944,946,946,943,942,939,941,943,944,942,939,940,941,943,942,944,940,941,939,943,940,939,938,936,941,940,939,940,936,939,939,939,939,938,937,935,939,941,941,941,942,944,945,950,952,952,955,955,955,958,961,959,958,957,960,963,963,962,959,958,961,960,962,960,961,959,960,962,962,961,961,959,962,963,962,960,959,959,960,961,959,959,956,956,957,957,958,956,954,955,956,957,958,957,955,955,955,957,956,955,953,954,954,956,955,952,951,950,953,953,952,951,950,949,953,954,952,951,951,951,954,955,954,955,951,952,952,953,951,952,952,951,951,954,955,953,953,952,954,957,956,957,957,957,962,966,970,968,965,965,967,970,972,973,973,972,974,973,975,976,974,972,972,973,972,971,970,969,971,972,974,976,978,971,967,965,957,958,954,950,952,953,952,951,949,948,952,952,951,951,949,948,950,948,949,949,946,947,949,948,947,941,930,923,920,917,909,905,918,941,974,1011,1057,1112,1158,1192,1211,1222,1206,1162,1100,1024,963,929,921,923,930,935,941,941,940,940,939,937,941,942,942,941,941,940,942,942,944,942,939,937,940,941,943,942,938,939,939,944,941,942,941,939,941,943,943,942,942,942,942,946,947,946,943,942,945,946,945,943,944,943,942,945,946,945,944,943,944,946,946,943,943,941,944,946,945,944,941,942,946,947,944,944,940,943,944,944,945,944,940,937,941,945,944,940,939,940,941,944,943,941,940,940,943,943,945,945,945,945,947,949,950,953,950,952,955,957,960,957,957,956,959,960,961,959,957,957,961,959,960,958,958,957,958,960,958,960,959,959,958,960,960,959,957,956,958,960,958,953,952,952,953,954,953,954,951,952,950,953,951,951,951,947,949,950,952,951,949,946,947,948,949,947,945,946,945,949,946,947,944,946,948,951,951,949,949,947,947,951,951,949,944,946,948,950,949,947,945,946,946,947,946,947,947,946,946,951,953,951,950,949,949,951,950,953,955,958,960,964,964,960,959,962,963,966,969,969,966,967,969,968,967,964,964,965,969,969,966,964,965,966,971,968,962,957,953,948,945,948,944,942,941,941,943,947,944,943,939,942,945,949,947,945,944,944,946,946,946,944,942,942,942,939,939,940,936,935,933,928,923,918,911,900,898,907,926,950,974,1008,1060,1115,1154,1177,1171,1132,1063,997,947,919,911,918,926,931,933,932,930,931,932,935,937,936,936,934,933,935,933,932,933,932,935,937,936,934,933,934,932,935,934,934,933,930,932,933,935,932,933,933,933,932,931,931,929,931,934,935,935,933,932,933,933,936,936,934,933,932,935,937,935,933,931,927,929,933,935,935,934,933,934,937,935,934,934,932,934,936,935,932,929,929,931,932,930,928,924,924,927,927,927,926,925,923,926,924,923,923,922,921,923,924,925,923,924,924,928,933,939,939,941,943,945,948,947,948,947,945,947,950,953,953,950,950,953,955,956,955,956,955,956,957,954,954,954,953,956,957,955,957,957,957,959,961,960,956,954,954,954,957,954,951,951,950,950,953,953,952,950,950,950,953,953,953,948,950,951,954,954,951,952,949,951,952,952,948,946,947,948,949,949,947,945,943,947,951,948,947,949,949,950,952,952,950,948,948,950,953,951,950,948,948,949,951,950,947,944,946,947,951,951,947,948,947,947,951,952,953,954,954,960,962,964,963,963,963,966,969,967,969,970,970,971,973,971,967,967,964,965,968,969,966,963,962,968,975,974,969,964,959,957,955,952,952,950,947,946,947,947,947,946,944,943,945,947,945,944,942,942,946,945,945,944,944,946,950,950,948,948,945,947,948,944,939,932,925,921,920,912,905,911,931,962,991,1030,1083,1134,1175,1196,1187,1139,1065,988,936,919,920,929,936,938,936,938,941,943,940,939,937,939,941,941,940,940,939,941,944,942,944,940,941,941,944,942,942,939,937,940,942,943,940,937,939,941,940,941,942,938,938,940,943,944,942,941,941,943,944,944,942,943,941,944,944,941,940,943,940,941,942,942,940,939,941,941,942,943,942,938,939,942,943,943,942,940,939,939,941,939,938,937,935,936,934,934,932,931,931,932,933,933,934,932,932,935,938,938,935,937,939,944,947,949,949,948,950,954,958,959,959,960,961,961,965,964,965,962,964,966,968,967,967,966,964,967,968,967,968,965,963,966,969,966,965,964,961,963,966,964,963,962,962,962,964,965,963,960,961,962,964,966,964,960,960,964,965,965,962,960,961,963,962,960,959,962,959,962,962,962,959,958,958,960,964,962,964,961,959,962,965,964,962,960,958,961,964,962,959,958,956,959,960,960,958,957,958,957,961,961,960,960,958,959,959,959,960,957,958,962,965,965,962,962,962,966,967,970,972,974,972,971,974,975,974,975,975,979,985,984,983,980,979,980,981,977,980,978,977,978,978,979,980,985,988,987,982,976,973,971,967,964,964,964,961,957,956,956,961,959,958,956,954,958,960,957,958,956,955,957,956,958,956,954,954,953,954,953,945,938,929,927,925,914,910,915,936,964,997,1032,1081,1137,1185,1213,1214,1172,1092,1009,950,928,931,943,950,951,948,949,952,953,950,949,949,951,952,952,949,946,946,947,949,948,950,947,948,948,950,950,947,945,944,947,951,949,947,947,946,947,949,948,948,946,947,948,949,946,946,948,948,951,954,951,951,951,949,951,950,949,949,948,947,948,951,952,952,950,949,951,953,953,951,951,951,950,953,951,952,951,950,952,955,956,952,951,949,951,952,951,950,946,946,947,951,951,950,948,948,949,952,953,953,950,949,953,957,958,960,959,960,963,965,966,966,964,965,968,969,970,971,969,968,970,972,970,971,968,966,968,971,971,971,970,967,971,973,973,970,970,968,971,972,971,969,967,966,968,968,967,966,965,964,965,967,967,965,964,963,963,964,966,966,961,962,966,968,968,966,963,965,965,966,963,963,960,962,961,964,962,962,959,960,960,963,961,962,959,957,963,962,964,962,962,962,962,965,967,965,963,962,962,964,967,965,963,963,964,965,965,963,962,960,961,964,965,964,965,964,968,972,974,976,975,976,978,980,982,985,983,985,987,988,989,987,983,981,983,983,984,983,979,978,979,985,990,989,981,975,974,976,972,968,963,961,961,962,963,962,960,957,960,963,962,962,958,956,958,962,959,957,956,955,957,959,959,956,956,955,951,947,940,935,930,922,917,925,945,969,994,1030,1080,1132,1174,1202,1218,1228,1223,1198,1157,1101,1042,988,950,931,929,933,936,945,950,952,954,953,953,952,953,953,954,954,951,951,952,953,953,950,949,948,950,950,952,951,947,946,951,952,952,953,951,949,951,952,952,952,950,950,952,954,953,952,951,948,952,954,952,954,948,947,950,953,953,953,949,950,955,955,954,953,951,953,956,958,956,953,951,952,957,956,954,951,950,950,950,951,952,953,949,948,950,952,951,948,947,947,946,948,947,946,943,945,948,952,954,952,952,952,956,959,960,962,960,957,961,963,961,963,961,962,968,966,967,965,964,967,967,966,966,965,964,961,964,966,968,965,963,964,964,966,964,962,961,960,962,960,961,959,958,957,958,959,962,960,958,956,955,957,958,957,955,957,958,959,959,957,957,957,956,958,957,955,954,952,953,955,957,956,953,953,955,957,956,954,953,953,953,955,955,954,953,953,955,954,957,957,953,953,954,954,956,953,949,951,953,955,952,954,953,955,957,961,965,965,963,963,966,968,971,971,971,971,976,978,977,974,974,973,973,972,971,970,970,971,972,969,970,972,974,972,969,966,965,960,956,950,952,950,947,946,944,947,947,948,950,948,947,948,949,949,948,945,944,945,948,950,950,949,945,944,947,947,947,944,938,935,931,929,922,909,903,911,934,963,996,1036,1084,1134,1172,1186,1167,1108,1031,964,931,920,926,934,939,935,937,937,936,938,939,938,942,941,941,940,935,933,937,939,940,938,937,937,937,939,938,938,935,934,935,938,937,938,937,938,939,940,941,941,936,935,937,939,938,936,931,932,934,935,934,933,935,934,936,938,941,939,939,935,938,938,935,935,933,935,934,936,937,936,934,932,934,936,936,934,933,930,930,929,927,929,929,927,928,929,927,926,923,922,921,923,928,925,927,927,932,936,937,940,941,940,944,948,952,952,950,950,953,956,958,959,957,954,955,957,957,957,953,954,954,956,957,956,954,953,955,958,957,956,954,954,955,956,954,953,952,949,950,952,953,950,950,948,948,951,949,948,946,946,946,950,950,949,945,948,949,953,952,950,948,947,948,949,948,948,945,946,947,949,948,948,947,945,946,945,950,948,949,948,950,952,949,947,947,946,946,949,949,949,947,945,944,948,949,949,946,947,951,957,957,961,959,960,963,963,965,966,966,966,967,969,967,965,961,963,964,967,967,966,963,962,963,963,968,967,966,961,957,955,955,949,949,948,947,946,947,946,946,944,940,943,943,943,941,940,940,940,944,941,940,939,941,943,943,942,939,934,928,922,919,914,902,895,898,911,927,945,962,978,1005,1038,1084,1133,1169,1187,1186,1150,1078,996,943,921,917,927,937,938,938,937,940,939,941,940,936,935,938,937,939,938,936,935,938,938,936,936,935,933,937,937,939,939,937,934,938,940,940,939,935,936,937,939,938,937,937,938,942,940,941,940,936,938,940,940,941,938,936,937,939,939,939,942,939,938,939,943,941,941,940,938,940,940,939,938,937,935,935,936,936,934,932,931,933,934,935,931,931,930,928,932,934,932,930,929,933,936,935,937,934,935,943,945,947,948,949,949,952,955,956,959,958,958,959,962,962,963,960,960,961,964,962,960,958,958,960,960,961,960,959,958,958,959,959,958,954,956,957,957,958,958,957,955,957,960,960,957,957,953,956,957,955,954,952,952,951,953,956,953,949,951,951,953,952,954,952,949,951,952,951,952,951,953,953,955,956,954,952,951,953,955,951,952,950,951,949,952,950,951,949,948,950,951,951,952,950,950,950,950,952,952,950,951,954,955,956,957,956,961,964,967,967,966,964,964,967,969,972,972,971,970,971,973,972,971,968,965,969,968,970,966,967,969,974,979,973,967,963,960,956,956,951,949,944,944,946,946,948,947,945,944,943,945,946,947,943,942,944,944,945,945,943,944,945,946,943,940,937,933,927,924,923,920,917,913,907,908,918,941,967,1000,1040,1088,1139,1175,1185,1168,1118,1048,982,939,927,929,937,942,943,937,939,938,940,941,939,937,935,935,935,936,939,938,936,937,937,936,936,936,934,932,936,939,939,939,938,936,937,939,940,936,937,936,935,937,937,936,934,933,936,937,938,937,937,936,936,936,935,937,937,935,936,938,939,938,936,935,937,938,940,938,937,933,936,936,936,936,935,935,937,937,939,939,936,936,934,937,936,933,933,931,934,934,935,933,933,933,933,937,937,937,938,939,942,947,949,948,948,948,953,953,953,953,951,956,958,958,957,954,955,956,956,958,958,957,955,954,955,956,956,957,953,953,955,956,954,953,953,953,952,953,952,951,950,949,951,951,951,950,947,946,946,950,950,949,947,945,945,951,950,946,946,945,947,946,946,948,946,943,946,945,944,944,941,942,943,946,947,945,942,943,948,949,947,949,948,947,950,950,950,950,948,948,947,949,948,948,947,946,951,951,953,949,952,953,957,961,963,964,962,961,966,970,970,970,966,967,969,971,970,967,964,962,965,967,967,965,962,961,967,972,971,964,955,954,954,955,950,945,946,944,946,945,944,944,941,938,939,943,940,938,939,940,942,943,944,943,939,939,941,941,940,938,929,923,917,917,907,896,894,907,928,946,956,971,989,1016,1054,1099,1136,1165,1178,1169,1122,1052,978,928,911,916,928,934,936,934,934,934,935,938,938,934,932,931,932,933,934,934,933,932,934,935,934,933,931,930,933,935,933,933,933,933,937,937,939,935,936,934,934,933,934,933,931,932,932,935,935,932,930,931,933,937,936,934,933,931,931,931,934,935,935,935,935,938,938,937,932,934,936,939,936,933,932,929,930,933,933,930,927,927,930,930,930,928,926,926,929,932,931,929,927,927,929,928,930,929,928,928,935,936,941,941,942,942,946,948,948,947,946,948,951,952,953,951,951,951,954,954,955,953,949,947,949,953,953,954,953,950,953,953,953,949,948,948,950,952,952,950,945,945,948,951,953,949,948,949,950,950,950,945,943,943,945,944,944,942,943,942,942,944,944,942,940,941,942,945,946,945,943,943,946,946,945,943,943,941,941,940,943,943,943,938,942,942,943,942,940,940,941,944,943,943,940,943,941,944,946,945,945,945,946,948,951,955,954,955,957,956,956,955,955,957,961,966,969,969,967,964,965,964,962,963,963,962,962,960,965,965,965,962,958,957,956,951,949,944,943,944,941,941,939,939,938,943,944,944,940,939,938,941,941,938,937,938,939,940,939,939,938,939,939,939,938,935,929,919,916,917,910,903,900,913,940,967,998,1043,1095,1144,1179,1190,1161,1096,1018,955,925,917,918,926,929,928,931,930,931,933,931,928,928,934,933,932,930,929,932,934,935,931,930,931,935,935,935,934,933,931,934,934,935,933,931,931,931,935,935,934,931,930,931,933,933,932,933,932,932,935,935,935,934,932,936,937,938,936,934,934,936,937,938,936,933,932,937,936,937,936,935,933,932,936,935,933,932,932,934,933,934,932,931,929,931,930,931,929,924,921,925,926,925,923,923,922,925,926,927,927,925,926,928,932,934,934,935,937,940,941,944,944,946,948,950,952,955,954,955,955,956,959,960,957,958,958,959,962,963,962,958,960,961,963,961,962,957,957,959,959,959,957,953,955,959,959,958,958,956,954,958,959,957,957,958,955,956,958,959,956,956,955,958,960,958,960,958,957,953,957,957,956,954,953,954,955,957,954,954,953,952,954,956,953,951,950,952,956,957,955,955,953,954,957,957,958,956,956,958,960,959,957,954,955,955,956,954,957,956,953,956,958,958,955,955,955,958,963,965,967,969,970,971,975,975,974,972,972,973,977,978,977,978,978,979,981,981,977,974,973,973,977,976,976,973,971,976,983,988,982,976,971,969,967,964,959,956,956,954,956,955,955,954,954,956,958,958,958,955,954,957,957,961,957,956,955,956,958,959,956,957,955,956,958,957,953,947,939,932,931,926,919,910,910,927,948,979,1011,1046,1096,1152,1192,1216,1218,1182,1112,1029,967,939,932,937,945,951,953,950,950,950,949,948,949,951,949,946,947,948,948,952,950,948,946,950,952,952,949,947,946,947,949,951,948,946,948,949,951,951,949,948,947,950,951,953,952,949,946,949,952,953,949,948,950,952,952,952,951,949,950,951,952,951,951,949,950,949,951,951,951,950,946,949,951,950,950,949,950,951,951,952,952,948,949,953,954,954,951,949,949,950,951,950,947,946,944,946,948,949,948,948,946,949,952,951,950,954,953,957,960,962,961,963,964,966,967,971,971,967,970,973,976,978,975,975,973,975,978,976,975,976,972,976,976,975,974,975,973,975,975,977,974,973,971,973,975,975,974,972,972,974,974,975,970,971,969,969,971,970,968,969,968,967,971,970,969,967,967,969,969,970,969,966,965,968,970,969,967,964,963,966,966,966,965,966,963,963,966,966,964,960,963,965,968,967,964,966,966,965,968,970,969,966,964,966,968,969,967,964,964,966,967,969,967,966,965,968,968,970,970,974,975,979,981,983,983,981,982,985,988,989,988,987,986,988,991,992,988,988,984,985,987,986,986,987,984,985,985,982,984,986,988,993,988,982,977,975,973,972,970,970,966,963,962,964,969,966,966,965,964,961,963,964,962,964,962,964,963,966,964,963,961,964,963,959,952,941,934,933,926,918,923,938,963,988,1012,1040,1081,1121,1162,1197,1215,1223,1200,1141,1051,982,944,939,943,952,957,957,956,957,956,954,953,954,954,954,953,950,950,953,954,953,956,954,951,953,955,955,955,954,954,956,958,959,958,955,954,957,959,958,959,956,956,957,958,958,958,955,956,957,955,957,957,954,955,957,957,957,956,955,955,955,957,956,957,953,953,955,957,957,956,954,954,955,958,957,954,954,952,954,958,956,956,955,954,957,955,957,955,953,953,957,956,956,953,952,952,954,956,958,956,956,957,963,964,965,964,966,966,970,973,971,971,972,973,975,976,976,974,974,974,977,977,978,974,974,974,975,978,977,975,973,973,974,975,975,974,973,972,972,974,974,974,971,970,969,971,972,972,970,968,970,972,973,970,970,968,970,971,970,972,969,969,971,970,970,970,969,969,970,972,970,968,967,966,966,967,970,967,963,963,966,966,968,967,967,966,965,969,969,967,966,966,968,971,972,970,970,968,970,971,971,970,967,968,969,970,969,971,969,969,970,972,971,971,972,973,975,981,984,982,980,982,985,989,989,992,989,991,992,993,993,990,987,986,989,990,990,989,985,983,987,993,997,992,985,980,981,981,975,970,966,962,965,967,967,967,965,963,965,965,965,964,963,963,965,966,965,964,961,960,962,963,964,964,963,961,957,950,943,938,933,922,917,921,936,960,983,1014,1065,1122,1167,1190,1187,1148,1078,1004,953,933,933,944]
expecting = [271, 580, 884, 1181, 1469, 1770, 2055, 2339, 2634, 2939, 3255, 3551, 3831, 4120, 4412, 4700, 5000, 5299, 5596, 5889, 6172, 6454, 6744, 7047, 7347, 7646, 7936, 8216, 8503, 8785, 9070, 9377, 9682]
frequency = 360.0
adcgain = 200.0
adczero = 1024
peaks = wfdb.processing.gqrs_detect(x, frequency, adcgain, adczero, threshold=1.0)
print(peaks)
print(expecting)
assert numpy.array_equal(peaks, expecting)
def test_7(self):
sig, fields = wfdb.srdsamp('sampledata/100', channels = [0, 1])
ann = wfdb.rdann('sampledata/100', 'atr')
fs = fields['fs']
min_bpm = 10
max_bpm = 350
min_gap = fs*60/min_bpm
max_gap = fs*60/max_bpm
y_idxs = wfdb.processing.correct_peaks(sig[:,0], ann.sample, min_gap, max_gap, smooth_window=150)
yz = numpy.zeros(sig.shape[0])
yz[y_idxs] = 1
yz = numpy.where(yz[:10000]==1)[0]
assert numpy.array_equal(yz, [77, 370, 663, 947, 1231, 1515, 1809, 2045, 2403, 2706, 2998, 3283, 3560, 3863, 4171, 4466, 4765, 5061, 5347, 5634, 5919, 6215, 6527, 6824, 7106, 7393, 7670, 7953, 8246, 8539, 8837, 9142, 9432, 9710, 9998])
| 525.158537
| 40,324
| 0.741054
| 10,400
| 43,063
| 3.063942
| 0.040481
| 0.012051
| 0.004802
| 0.00226
| 0.233297
| 0.072305
| 0.027773
| 0.017386
| 0.013745
| 0.012553
| 0
| 0.725157
| 0.01737
| 43,063
| 81
| 40,325
| 531.641975
| 0.027886
| 0
| 0
| 0.262295
| 0
| 0
| 0.002624
| 0
| 0
| 0
| 0
| 0
| 0.196721
| 1
| 0.114754
| false
| 0
| 0.032787
| 0
| 0.163934
| 0.032787
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
7e0500078fb4390752c854053cc576ad01bd952a
| 5,331
|
py
|
Python
|
Experiment/Experiment/temp.py
|
Crabtux/Ubuntu-Configurations
|
3dff9908a51bd97b7a2082d2fc8adcd230cb5fc4
|
[
"MIT"
] | null | null | null |
Experiment/Experiment/temp.py
|
Crabtux/Ubuntu-Configurations
|
3dff9908a51bd97b7a2082d2fc8adcd230cb5fc4
|
[
"MIT"
] | null | null | null |
Experiment/Experiment/temp.py
|
Crabtux/Ubuntu-Configurations
|
3dff9908a51bd97b7a2082d2fc8adcd230cb5fc4
|
[
"MIT"
] | null | null | null |
# -*- coding: UTF-8 –*-
import os
import sys
from Crypto.Util.number import bytes_to_long,long_to_bytes
def encrypt(m,N,e):
return pow(m,e,N)
def decrypt(c,N,d):
return pow(c,d,N)
def padding(msg):
res = msg
if len(res) < 128:
res = res + os.urandom(128-len(res))
return res
def transfer(msg):
assert len(msg) < 128
m = padding(msg)
return bytes_to_long(m)
# 扩展欧几里得求逆元
def exgcd(a, b):
if b == 0:
return 1, 0, a
else:
x, y, q = exgcd(b, a % b)
x, y = y, (x - (a // b) * y)
return x, y, q
# 扩展欧几里得求逆元
def ModReverse(a,p):
x, y, q = exgcd(a,p)
if q != 1:
raise Exception("No solution.")
else:
return (x + p) % p #防止负数
if __name__ == "__main__":
sys.setrecursionlimit(3000)
p = 98197216341757567488149177586991336976901080454854408243068885480633972200382596026756300968618883148721598031574296054706280190113587145906781375704611841087782526897314537785060868780928063942914187241017272444601926795083433477673935377466676026146695321415853502288291409333200661670651818749836420808033
q = 133639826298015917901017908376475546339925646165363264658181838203059432536492968144231040597990919971381628901127402671873954769629458944972912180415794436700950304720548263026421362847590283353425105178540468631051824814390421486132775876582962969734956410033443729557703719598998956317920674659744121941513
N = (p - 1) * (q - 1)
print(N)
e = 2199344405076718723439776106818391416986774637417452818162477025957976213477191723664184407417234793814926418366905751689789699138123658292718951547073938244835923378103264574262319868072792187129755570696127796856136279813658923777933069924139862221947627969330450735758091555899551587605175567882253565613163972396640663959048311077691045791516671857020379334217141651855658795614761069687029140601439597978203375244243343052687488606544856116827681065414187957956049947143017305483200122033343857370223678236469887421261592930549136708160041001438350227594265714800753072939126464647703962260358930477570798420877
m = 1492164290534197296766878830710549288168716657792979479408332026408553210558539364503279432780006256047888761718878241924947937039103166564146378209168719163067531460700424309878383312837345239570897122826051628153030129647363574035072755426112229160684859510640271933580581310029921376842631120847546030843821787623965614564745724229763999106839802052036834811357341644073138100679508864747009014415530176077648226083725813290110828240582884113726976794751006967153951269748482024859714451264220728184903144004573228365893961477199925864862018084224563883101101842275596219857205470076943493098825250412323522013524
d = ModReverse(e, N)
output = decrypt(m, N, e)
print(long_to_bytes(output))
# m 是明文
# p, q, N 懂得都懂
# e 是密文
# N = 13123058934861171416713230498081453101147538789122070079961388806126697916963123413431108069961369055630747412550900239402710827847917960870358653962948282381351741121884528399369764530446509936240262290248305226552117100584726616255292963971141510518678552679033220315246377746270515853987903184512948801397452104554589803725619076066339968999308910127885089547678968793196148780382182445270838659078189316664538631875879022325427220682805580410213245364855569367702919157881367085677283124732874621569379901272662162025780608669577546548333274766058755786449491277002349918598971841605936268030140638579388226573929
# p = 98197216341757567488149177586991336976901080454854408243068885480633972200382596026756300968618883148721598031574296054706280190113587145906781375704611841087782526897314537785060868780928063942914187241017272444601926795083433477673935377466676026146695321415853502288291409333200661670651818749836420808033
# q = 133639826298015917901017908376475546339925646165363264658181838203059432536492968144231040597990919971381628901127402671873954769629458944972912180415794436700950304720548263026421362847590283353425105178540468631051824814390421486132775876582962969734956410033443729557703719598998956317920674659744121941513
# e = 2199344405076718723439776106818391416986774637417452818162477025957976213477191723664184407417234793814926418366905751689789699138123658292718951547073938244835923378103264574262319868072792187129755570696127796856136279813658923777933069924139862221947627969330450735758091555899551587605175567882253565613163972396640663959048311077691045791516671857020379334217141651855658795614761069687029140601439597978203375244243343052687488606544856116827681065414187957956049947143017305483200122033343857370223678236469887421261592930549136708160041001438350227594265714800753072939126464647703962260358930477570798420877
# m = 1492164290534197296766878830710549288168716657792979479408332026408553210558539364503279432780006256047888761718878241924947937039103166564146378209168719163067531460700424309878383312837345239570897122826051628153030129647363574035072755426112229160684859510640271933580581310029921376842631120847546030843821787623965614564745724229763999106839802052036834811357341644073138100679508864747009014415530176077648226083725813290110828240582884113726976794751006967153951269748482024859714451264220728184903144004573228365893961477199925864862018084224563883101101842275596219857205470076943493098825250412323522013524
| 87.393443
| 624
| 0.90771
| 180
| 5,331
| 26.8
| 0.355556
| 0.001658
| 0.001866
| 0.003317
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.866653
| 0.061715
| 5,331
| 60
| 625
| 88.85
| 0.097561
| 0.480585
| 0
| 0.05
| 0
| 0
| 0.007257
| 0
| 0
| 1
| 0
| 0
| 0.025
| 1
| 0.15
| false
| 0
| 0.075
| 0.05
| 0.4
| 0.05
| 0
| 0
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
7e0d3edd937d8a5cd9d349983bcb2072741a9798
| 768
|
py
|
Python
|
linked_list/linked_list.py
|
MateuszMazurkiewicz/LinkedList
|
7a371f3d51079d2391242245e19d369d03181b6f
|
[
"MIT"
] | null | null | null |
linked_list/linked_list.py
|
MateuszMazurkiewicz/LinkedList
|
7a371f3d51079d2391242245e19d369d03181b6f
|
[
"MIT"
] | null | null | null |
linked_list/linked_list.py
|
MateuszMazurkiewicz/LinkedList
|
7a371f3d51079d2391242245e19d369d03181b6f
|
[
"MIT"
] | null | null | null |
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
def append_left(self, value):
pass
def append_right(self, value):
pass
def pop_left(self):
pass
def pop_right(self):
pass
def get_node_iterator(self):
pass
def __iter__(self):
def __add__(self, other):
pass
def __iadd__(self, other):
pass
def __getitem__(self, index):
pass
def __setitem__(self, index, value):
pass
def __contains__(self, value):
pass
def __reversed__(self):
pass
def insert(self):
pass
def index(self):
pass
def remove(self, value):
pass
def sort(self):
pass
| 15.058824
| 40
| 0.544271
| 89
| 768
| 4.269663
| 0.325843
| 0.257895
| 0.173684
| 0.168421
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.371094
| 768
| 51
| 41
| 15.058824
| 0.786749
| 0
| 0
| 0.428571
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0.428571
| 0
| null | null | 0
| 0
| 0
| 0
| null | 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
7e10f5f9a61551e61819b0a68c7b1329aec6ad51
| 167
|
py
|
Python
|
deep_svg_demo/demo/deepsvg/base/urls.py
|
GuardianWang/DeepAnimation
|
8c25c3c23e3060292eeb83bb432a5522213d8e73
|
[
"MIT"
] | 1
|
2021-12-10T22:42:27.000Z
|
2021-12-10T22:42:27.000Z
|
deep_svg_demo/demo/deepsvg/base/urls.py
|
GuardianWang/DeepAnimation
|
8c25c3c23e3060292eeb83bb432a5522213d8e73
|
[
"MIT"
] | null | null | null |
deep_svg_demo/demo/deepsvg/base/urls.py
|
GuardianWang/DeepAnimation
|
8c25c3c23e3060292eeb83bb432a5522213d8e73
|
[
"MIT"
] | null | null | null |
from django.urls import path
from django.urls.resolvers import URLPattern
from . import views
urlpatterns = [
path('<str:pk>/', views.getRoutes, name="routes"),
]
| 23.857143
| 54
| 0.730539
| 22
| 167
| 5.545455
| 0.636364
| 0.163934
| 0.229508
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.137725
| 167
| 7
| 55
| 23.857143
| 0.847222
| 0
| 0
| 0
| 0
| 0
| 0.089286
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
fdfcba981d8f8da0781358cfe64fa1c78074a160
| 88
|
py
|
Python
|
Core/third_party/JavaScriptCore/Scripts/builtins/__init__.py
|
InfiniteSynthesis/lynx-native
|
022e277ee6767f5b668269a17b1679072cf7c3d6
|
[
"MIT"
] | 677
|
2017-09-23T16:03:12.000Z
|
2022-03-26T08:32:10.000Z
|
Core/third_party/JavaScriptCore/Scripts/builtins/__init__.py
|
InfiniteSynthesis/lynx-native
|
022e277ee6767f5b668269a17b1679072cf7c3d6
|
[
"MIT"
] | 9
|
2020-04-18T18:47:18.000Z
|
2020-04-18T18:52:41.000Z
|
Core/third_party/JavaScriptCore/Scripts/builtins/__init__.py
|
InfiniteSynthesis/lynx-native
|
022e277ee6767f5b668269a17b1679072cf7c3d6
|
[
"MIT"
] | 92
|
2017-09-21T14:21:27.000Z
|
2022-03-25T13:29:42.000Z
|
# Required for Python to search this directory for module files
from builtins import *
| 22
| 63
| 0.795455
| 13
| 88
| 5.384615
| 0.923077
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.181818
| 88
| 3
| 64
| 29.333333
| 0.972222
| 0.693182
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
8bf9846ce988529c2c3b2856132bc74b034fcb58
| 185
|
py
|
Python
|
backend/api/serializers.py
|
NAKKA-K/2018-078-captive
|
d18ef63d64d69aed9e1607eb08e133ada0c75987
|
[
"MIT"
] | null | null | null |
backend/api/serializers.py
|
NAKKA-K/2018-078-captive
|
d18ef63d64d69aed9e1607eb08e133ada0c75987
|
[
"MIT"
] | 9
|
2018-04-15T08:28:19.000Z
|
2018-04-20T11:01:16.000Z
|
backend/api/serializers.py
|
NAKKA-K/2018-078-captive
|
d18ef63d64d69aed9e1607eb08e133ada0c75987
|
[
"MIT"
] | null | null | null |
from rest_framework import serializers
from api.models import User
class QuestionSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('age', 'gender')
| 23.125
| 54
| 0.756757
| 21
| 185
| 6.619048
| 0.761905
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.162162
| 185
| 7
| 55
| 26.428571
| 0.896774
| 0
| 0
| 0
| 0
| 0
| 0.048649
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
e328f0752d1d20d5eebb09630f027cb7ae969d70
| 199
|
py
|
Python
|
Sem2-Lab-4/lab4.py
|
BrendonPurchase2002-CS/Projects-
|
bd13533ddd16b049250a70e8f006938f84393a1a
|
[
"MIT"
] | null | null | null |
Sem2-Lab-4/lab4.py
|
BrendonPurchase2002-CS/Projects-
|
bd13533ddd16b049250a70e8f006938f84393a1a
|
[
"MIT"
] | null | null | null |
Sem2-Lab-4/lab4.py
|
BrendonPurchase2002-CS/Projects-
|
bd13533ddd16b049250a70e8f006938f84393a1a
|
[
"MIT"
] | null | null | null |
def chooseLargest(a, b):
list(map(lambda tup: max(tup[0] + tup[1]), zip(a, b)))
l1 = [1, 2, 3, 4, 5]
l2 = [2, 2, 9, 0, 9]
return list(map(lambda tup: max(tup[0] + tup[1]), zip(a, b)))
| 39.8
| 65
| 0.512563
| 41
| 199
| 2.487805
| 0.487805
| 0.058824
| 0.254902
| 0.313725
| 0.627451
| 0.627451
| 0.627451
| 0.627451
| 0.627451
| 0.627451
| 0
| 0.105263
| 0.236181
| 199
| 5
| 65
| 39.8
| 0.565789
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0
| 0
| 0
| 0.4
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
e32f3186b7ac547e284feb1f7b806acaa31441b3
| 285
|
py
|
Python
|
python/Strings/string-validators.py
|
cdrowley/hackerrank
|
cc5c925327cd3ce5b52c1614b814da75d42cca72
|
[
"MIT"
] | null | null | null |
python/Strings/string-validators.py
|
cdrowley/hackerrank
|
cc5c925327cd3ce5b52c1614b814da75d42cca72
|
[
"MIT"
] | null | null | null |
python/Strings/string-validators.py
|
cdrowley/hackerrank
|
cc5c925327cd3ce5b52c1614b814da75d42cca72
|
[
"MIT"
] | null | null | null |
# https://www.hackerrank.com/challenges/string-validators/problem
string = input()
print(any(c.isalnum() for c in string))
print(any(c.isalpha() for c in string))
print(any(c.isdigit() for c in string))
print(any(c.islower() for c in string))
print(any(c.isupper() for c in string))
| 28.5
| 65
| 0.719298
| 50
| 285
| 4.1
| 0.38
| 0.195122
| 0.219512
| 0.292683
| 0.409756
| 0.409756
| 0.409756
| 0
| 0
| 0
| 0
| 0
| 0.112281
| 285
| 9
| 66
| 31.666667
| 0.810277
| 0.221053
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.833333
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
e368f0e90a829de587609f680e3e5a9bde5017a0
| 161
|
py
|
Python
|
service/handlers/schemas/input.py
|
ran-isenberg/aws-lambda-handler-cookbook
|
adfe58dacd87315151265818869bb842c7eb4971
|
[
"MIT"
] | 61
|
2022-02-07T05:21:14.000Z
|
2022-03-27T14:11:30.000Z
|
service/handlers/schemas/input.py
|
ran-isenberg/aws-lambda-handler-cookbook
|
adfe58dacd87315151265818869bb842c7eb4971
|
[
"MIT"
] | 17
|
2022-02-26T05:25:31.000Z
|
2022-03-16T20:02:46.000Z
|
service/handlers/schemas/input.py
|
ran-isenberg/aws-lambda-handler-cookbook
|
adfe58dacd87315151265818869bb842c7eb4971
|
[
"MIT"
] | 4
|
2022-02-17T16:35:27.000Z
|
2022-03-07T03:13:07.000Z
|
from pydantic import BaseModel, PositiveInt, constr
class Input(BaseModel):
my_name: constr(min_length=1, max_length=20)
order_item_count: PositiveInt
| 23
| 51
| 0.782609
| 22
| 161
| 5.5
| 0.818182
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.021739
| 0.142857
| 161
| 6
| 52
| 26.833333
| 0.855072
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.25
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
e3847e6da453caa0f32bccd221834e7b3fdc3c83
| 381
|
py
|
Python
|
pyOpenMS/env.py
|
open-ms/all-svn-branches
|
b182ba576e0cbfbe420b8edb0dd1c42bb6c973f3
|
[
"Zlib",
"Apache-2.0"
] | 1
|
2018-05-23T03:43:10.000Z
|
2018-05-23T03:43:10.000Z
|
pyOpenMS/env.py
|
kreinert/OpenMS
|
45455356482ce5ab35e32e445609b291ec78a6d6
|
[
"Zlib",
"Apache-2.0"
] | null | null | null |
pyOpenMS/env.py
|
kreinert/OpenMS
|
45455356482ce5ab35e32e445609b291ec78a6d6
|
[
"Zlib",
"Apache-2.0"
] | null | null | null |
OPEN_MS_SRC="/home/uschmitt/Release1.10pyopenms"
OPEN_MS_BUILD_DIR="/home/uschmitt/Release1.10pyopenms"
OPEN_MS_CONTRIB_BUILD_DIRS="/home/uschmitt/Release1.10pyopenms/contrib;/opt/local;/usr/local;"
QT_HEADERS_DIR="/usr/include/qt4"
QT_LIBRARY_DIR="/usr/lib/x86_64-linux-gnu"
QT_QTCORE_INCLUDE_DIR="/usr/include/qt4/QtCore"
MSVCR90DLL=""
MSVCP90DLL=""
OPEN_MS_BUILD_TYPE="Release"
| 38.1
| 94
| 0.821522
| 59
| 381
| 4.966102
| 0.491525
| 0.081911
| 0.204778
| 0.307167
| 0.245734
| 0.245734
| 0
| 0
| 0
| 0
| 0
| 0.051075
| 0.023622
| 381
| 9
| 95
| 42.333333
| 0.736559
| 0
| 0
| 0
| 0
| 0
| 0.535433
| 0.475066
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
8b61b881bbdc6b1ac2e823cc8ca65779662d1bb3
| 689
|
py
|
Python
|
panopuppet/pano/views/__init__.py
|
propyless/panopuppet
|
6beea45ad25ea1e2ed7dbd5b60210880cd8aab2a
|
[
"Apache-2.0"
] | 60
|
2015-03-26T14:24:47.000Z
|
2016-08-09T17:48:00.000Z
|
panopuppet/pano/views/__init__.py
|
propyless/panopuppet
|
6beea45ad25ea1e2ed7dbd5b60210880cd8aab2a
|
[
"Apache-2.0"
] | 108
|
2015-04-17T12:05:46.000Z
|
2016-08-23T14:42:19.000Z
|
panopuppet/pano/views/__init__.py
|
propyless/panopuppet
|
6beea45ad25ea1e2ed7dbd5b60210880cd8aab2a
|
[
"Apache-2.0"
] | 27
|
2015-03-30T13:23:03.000Z
|
2016-10-25T20:18:27.000Z
|
__author__ = 'etaklar'
"""
You must add new views to a separate file
and then import the view here.
"""
from panopuppet.pano.views.views import *
from panopuppet.pano.views.dashboard import dashboard
from panopuppet.pano.views.nodes import nodes
from panopuppet.pano.views.analytics import analytics
from panopuppet.pano.views.event_analytics import event_analytics
from panopuppet.pano.views.filebucket import filebucket
from panopuppet.pano.views.logout import logout_view
from panopuppet.pano.views.node_facts import facts
from panopuppet.pano.views.report_events import detailed_events
from panopuppet.pano.views.splash import splash
from panopuppet.pano.views.reports import reports
| 38.277778
| 65
| 0.8418
| 99
| 689
| 5.757576
| 0.333333
| 0.270175
| 0.347368
| 0.44386
| 0.112281
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.09434
| 689
| 17
| 66
| 40.529412
| 0.913462
| 0
| 0
| 0
| 0
| 0
| 0.011494
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.916667
| 0
| 0.916667
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
8b76b8f82fd653ba64796b7e522c180bc82ca5b8
| 586
|
py
|
Python
|
learner/base.py
|
mramire8/structured
|
3eb6a61fb7659a0b2a6ea93fe321b93a351162f7
|
[
"Apache-2.0"
] | null | null | null |
learner/base.py
|
mramire8/structured
|
3eb6a61fb7659a0b2a6ea93fe321b93a351162f7
|
[
"Apache-2.0"
] | null | null | null |
learner/base.py
|
mramire8/structured
|
3eb6a61fb7659a0b2a6ea93fe321b93a351162f7
|
[
"Apache-2.0"
] | null | null | null |
class Learner(object):
"""docstring for Learner"""
def __init__(self, model, seed=None):
super(Learner, self).__init__()
self.model = model
self.seed = seed
def next(self, pool, step):
raise Exception("Undefined next function")
def fit(self, X, y):
raise Exception("Undefined fit function")
def predict(self,X):
return self.model.predict(X)
def predict_proba(self, X):
return self.model.predict_proba(X)
def _argmax_x(self, pool, step):
raise Exception("Undefined objective function")
| 26.636364
| 55
| 0.62628
| 73
| 586
| 4.863014
| 0.369863
| 0.101408
| 0.194366
| 0.095775
| 0.349296
| 0.349296
| 0
| 0
| 0
| 0
| 0
| 0
| 0.257679
| 586
| 22
| 55
| 26.636364
| 0.816092
| 0.035836
| 0
| 0
| 0
| 0
| 0.13059
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.4
| false
| 0
| 0
| 0.133333
| 0.6
| 0
| 0
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.