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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8dd6a32e4ca88d6bab0df8f1fd32541faef46719 | 206 | py | Python | src/router.py | atnanasi/depression | 2271c2fe4f386f760b094e2d816427db91713185 | [
"MIT"
] | null | null | null | src/router.py | atnanasi/depression | 2271c2fe4f386f760b094e2d816427db91713185 | [
"MIT"
] | null | null | null | src/router.py | atnanasi/depression | 2271c2fe4f386f760b094e2d816427db91713185 | [
"MIT"
] | null | null | null | from flask import Flask, render_template, request, redirect, url_for
app = Flask("depression")
@app.route('/')
def index():
return render_template('index.html')
def run():
app.run(host='0.0.0.0') | 20.6 | 68 | 0.684466 | 31 | 206 | 4.451613 | 0.612903 | 0.043478 | 0.043478 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.022599 | 0.140777 | 206 | 10 | 69 | 20.6 | 0.757062 | 0 | 0 | 0 | 0 | 0 | 0.135266 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.142857 | 0.142857 | 0.571429 | 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 | 0 | 1 | 0 | 0 | 0 | 2 |
8deaef168523c2d4d964ee170407215214338d7a | 348 | py | Python | tinifycli/function_call_trace.py | aheadlead/tinify-cli | 37d1008d306d3f6459e4f6d72297c335a942cc1b | [
"MIT"
] | 8 | 2016-12-07T01:56:03.000Z | 2021-01-04T16:14:54.000Z | tinifycli/function_call_trace.py | aheadlead/tinify-cli | 37d1008d306d3f6459e4f6d72297c335a942cc1b | [
"MIT"
] | null | null | null | tinifycli/function_call_trace.py | aheadlead/tinify-cli | 37d1008d306d3f6459e4f6d72297c335a942cc1b | [
"MIT"
] | 3 | 2016-03-25T15:07:38.000Z | 2020-01-30T19:39:06.000Z | # coding=utf-8
import logging
LOGGER = logging.getLogger('tinify-cli')
def tracecall(func):
''' 在日志上打出函数呼叫和返回的情况 '''
def new_func(*args, **kwargs):
''' 待返回的函数 '''
LOGGER.debug(u'进入 ' + func.__name__)
ret = func(*args, **kwargs)
LOGGER.debug(u'离开 ' + func.__name__)
return ret
return new_func
| 20.470588 | 44 | 0.58908 | 41 | 348 | 4.756098 | 0.585366 | 0.071795 | 0.14359 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003876 | 0.258621 | 348 | 16 | 45 | 21.75 | 0.751938 | 0.112069 | 0 | 0 | 0 | 0 | 0.054237 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.111111 | 0 | 0.555556 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
8dfa8859a51a4de20dcd90321d772e72693bb123 | 60 | py | Python | python/mpl_defaults.py | willettk/rgz-analysis | 11c34b1b2d0eb8b9c1c71757e6e2f771c169e993 | [
"MIT"
] | 3 | 2016-02-23T01:24:38.000Z | 2017-07-09T03:34:29.000Z | python/mpl_defaults.py | willettk/rgz-analysis | 11c34b1b2d0eb8b9c1c71757e6e2f771c169e993 | [
"MIT"
] | 30 | 2015-02-24T03:05:54.000Z | 2016-06-27T19:36:36.000Z | python/mpl_defaults.py | willettk/rgz-analysis | 11c34b1b2d0eb8b9c1c71757e6e2f771c169e993 | [
"MIT"
] | 3 | 2016-03-02T02:45:51.000Z | 2021-02-23T02:01:34.000Z | # Colors
blue = '#377EB8'
red = '#E41A1C'
green = '#4DAF4A'
| 12 | 17 | 0.6 | 7 | 60 | 5.142857 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.183673 | 0.183333 | 60 | 4 | 18 | 15 | 0.55102 | 0.1 | 0 | 0 | 0 | 0 | 0.403846 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
8dfc4eaebc9268bc03ee0eddaba2d84aa241fb39 | 449 | py | Python | experiments/skipping_scheduling.py | probablytom/bpi_13_python | ef042674d3d40857237511af1fbca59ede97e75e | [
"MIT"
] | null | null | null | experiments/skipping_scheduling.py | probablytom/bpi_13_python | ef042674d3d40857237511af1fbca59ede97e75e | [
"MIT"
] | null | null | null | experiments/skipping_scheduling.py | probablytom/bpi_13_python | ef042674d3d40857237511af1fbca59ede97e75e | [
"MIT"
] | null | null | null | from run_model import run_model
from domain_model import set_skip_log as skip_current_action
class SkipLogAdvice(object):
def should_skip(self, attr):
'''
Skip all scheduling actions.
:return: Bool indicating whether to activate.
'''
return 'schedule' in attr.func_name
def prelude(self, attr, _):
if self.should_skip(attr):
skip_current_action(True)
run_model(SkipLogAdvice)
| 24.944444 | 60 | 0.67706 | 57 | 449 | 5.087719 | 0.596491 | 0.082759 | 0.117241 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.249443 | 449 | 17 | 61 | 26.411765 | 0.860534 | 0.167038 | 0 | 0 | 0 | 0 | 0.023392 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.222222 | 0 | 0.666667 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
5c06a766369a9b4593eba13da25ccdd1a477a841 | 286 | py | Python | src/models/arch2/train.py | josh-gree/poly2poly | 174dc02c57b66bb8fad8918206d3dfd4eca4c2bc | [
"MIT"
] | null | null | null | src/models/arch2/train.py | josh-gree/poly2poly | 174dc02c57b66bb8fad8918206d3dfd4eca4c2bc | [
"MIT"
] | null | null | null | src/models/arch2/train.py | josh-gree/poly2poly | 174dc02c57b66bb8fad8918206d3dfd4eca4c2bc | [
"MIT"
] | null | null | null | import tensorflow as tf
import numpy as np
from model import poly2poly
sess = tf.Session()
model = poly2poly(sess, 'archpoly2poly', '../../../data/processed/train/',
'../../../data/processed/test/',
'../../../data/processed/val/')
model.train(10)
| 23.833333 | 74 | 0.58042 | 31 | 286 | 5.354839 | 0.580645 | 0.23494 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.022321 | 0.216783 | 286 | 11 | 75 | 26 | 0.71875 | 0 | 0 | 0 | 0 | 0 | 0.34965 | 0.304196 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.375 | 0 | 0.375 | 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 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
5c0f62b897a10ee36da406f7f8b1e3f0ed2bfb94 | 1,220 | py | Python | configuration.py | Berdugo1994/Tweeter-Search-Engine | ff80707d64b792288b877814d79e39c5b5ceb7ad | [
"MIT"
] | null | null | null | configuration.py | Berdugo1994/Tweeter-Search-Engine | ff80707d64b792288b877814d79e39c5b5ceb7ad | [
"MIT"
] | null | null | null | configuration.py | Berdugo1994/Tweeter-Search-Engine | ff80707d64b792288b877814d79e39c5b5ceb7ad | [
"MIT"
] | null | null | null | class ConfigClass:
def __init__(self):
# link to a zip file in google drive with your pretrained model
self._model_url = "https://drive.google.com/file/d/14VduVhV12k1mgLJMJ0WMhtRlFqwqMKtN/view?usp=sharing"
# False/True flag indicating whether the testing system will download
# and overwrite the existing model files. In other words, keep this as
# False until you update the model, submit with True to download
# the updated model (with a valid model_url), then turn back to False
# in subsequent submissions to avoid the slow downloading of the large
# model file with every submission.
self._download_model = True
self.corpusPath = ''
self.savedFileMainFolder = ''
self.saveFilesWithStem = self.savedFileMainFolder + "/WithStem"
self.saveFilesWithoutStem = self.savedFileMainFolder + "/WithoutStem"
self.toStem = False
print('Project was created successfully..')
def get__corpusPath(self):
return self.corpusPath
def get_model_url(self):
return self._model_url
def get_download_model(self):
return self._download_model
| 42.068966 | 111 | 0.672131 | 143 | 1,220 | 5.601399 | 0.531469 | 0.03995 | 0.052434 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006682 | 0.263934 | 1,220 | 28 | 112 | 43.571429 | 0.885301 | 0.358197 | 0 | 0 | 0 | 0 | 0.1834 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0.1875 | 0.5 | 0.0625 | 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 | 0 | 1 | 0 | 0 | 0 | 2 |
5c1fa4a08fb70af9f3ab28162fed8ed3ef080492 | 968 | py | Python | SmartImplicitHub/Blocks/ValueMapping.py | destman0/Smart-Implicit-Hub | ff95d9e297602b71338654f726590e56b70c55a2 | [
"BSD-3-Clause"
] | 2 | 2020-02-04T08:58:25.000Z | 2020-02-04T08:58:27.000Z | SmartImplicitHub/Blocks/ValueMapping.py | agentff6600/Smart-Implicit-Hub | 54af115cba391b6341a43194bc3fc7720010a4a8 | [
"BSD-3-Clause"
] | 1 | 2019-12-11T08:15:35.000Z | 2019-12-11T08:15:35.000Z | SmartImplicitHub/Blocks/ValueMapping.py | agentff6600/Smart-Implicit-Hub | 54af115cba391b6341a43194bc3fc7720010a4a8 | [
"BSD-3-Clause"
] | 2 | 2019-12-07T14:17:38.000Z | 2019-12-25T12:53:38.000Z | __copyright__ = "Copyright 2019, RISE Research Institutes of Sweden"
__author__ = "Naveed Anwar Bhatti and Martina Brachmann"
def maprange(a, b, s):
'''
Maps an input value to an ouput value depending on a sensors' and actuators's range
Parameters
----------
a : tupel (float, float)
the sensors' known/given range (from, to)
b : tupel (float, float)
the actuators' known/given range (from, to)
s : float
current input value
Returns
-------
float : the mapped value
'''
(a1, a2), (b1, b2) = a, b
return b1 + ((s - a1) * (b2 - b1) / (a2 - a1))
def maprange_by_factor(a, b, s, fac):
return maprange(a, b, s * fac)
def maprange_by_hop_factor(a, b, s, h_f):
(hops, factor) = h_f
fac = 1
for hop in range(1, hops+1):
factor = factor / hop
fac = fac + factor
return maprange_by_factor(a, b, s, fac)
def maprange_by_neighbor(a, b, s, neighbor):
pass | 24.2 | 87 | 0.595041 | 143 | 968 | 3.895105 | 0.398601 | 0.025135 | 0.032316 | 0.048474 | 0.211849 | 0.136445 | 0.136445 | 0 | 0 | 0 | 0 | 0.024355 | 0.278926 | 968 | 40 | 88 | 24.2 | 0.773639 | 0.336777 | 0 | 0 | 0 | 0 | 0.156089 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0.0625 | 0 | 0.0625 | 0.4375 | 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 | 0 | 0 | 0 | 0 | 2 |
5c2f60231e7ea47b2e273713c720d4f68643d075 | 2,450 | py | Python | Python/Card Game(Blackjack)/Card.py | bajwa10/Projects-Assignments | 4f57dbb8d31765488e0c6689bcb343192aa7bf85 | [
"Apache-2.0"
] | null | null | null | Python/Card Game(Blackjack)/Card.py | bajwa10/Projects-Assignments | 4f57dbb8d31765488e0c6689bcb343192aa7bf85 | [
"Apache-2.0"
] | null | null | null | Python/Card Game(Blackjack)/Card.py | bajwa10/Projects-Assignments | 4f57dbb8d31765488e0c6689bcb343192aa7bf85 | [
"Apache-2.0"
] | null | null | null | class Card:
def __init__(self,rank,suit): # instance recevies two parameters rank and suit
self.rank = rank
self.suit = suit
self.rank_list = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'] # a list contains all ranks
self.suit_list = ['H', 'C', 'D', 'S'] # a list containing all suits
assert self.rank.upper() in self.rank_list, 'Invalid Rank' # checks if the rank is in the list, not case sensitive
assert self.suit.upper() in self.suit_list, 'Invalid Suit' # checks if the suit is in the list, not case sensitive
def get(self): # returns rank and the suit
return self.rank+self.suit
def get_rank(self): # returns rank
return self.rank
def get_suit(self): # returns suit
return self.suit
def __gt__(self,other): # checks if the rank of the passed card is smaller
for i in range(len(self.rank_list)): # ranks are ordered in increasing order in self.rank_list, so higher the rank, higher the index
if self.rank_list[i] == self.rank: # checks for the rank in the list and stores the index
rank = i
if self.rank_list[i] == other.rank:
rank_other = i
return rank > rank_other # compares the index to determines if the passed card's rank is smaller or greater
def __lt__(self,other): # checks if the rank of the passed card is greater
for i in range(len(self.rank_list)): # ranks are ordered in increasing order in self.rank_list, so higher the rank, higher the index
if self.rank_list[i] == self.rank: # checks for the rank in the list and stores the index
rank = i
if self.rank_list[i] == other.rank:
rank_other = i
return rank < rank_other # compares the index to determines if the passed card's rank is smaller or greater
def __eq__(self,other):
return self.rank == other.rank # returns if the rank of the passed card is equal
def __str__(self): # converts card object to a printable form
return self.rank + self.suit
def convert_rank(self,rank): # converts rank accordding to its positon in the list, adds two to the index as the index counting starts from 0 in python and the ranks start from 2
for i in range(len(self.rank_list)):
if self.rank_list[i] == rank:
return i+2
| 53.26087 | 182 | 0.62898 | 387 | 2,450 | 3.875969 | 0.235142 | 0.117333 | 0.096 | 0.046667 | 0.559333 | 0.549333 | 0.516 | 0.48 | 0.445333 | 0.445333 | 0 | 0.006275 | 0.28449 | 2,450 | 45 | 183 | 54.444444 | 0.849401 | 0.42898 | 0 | 0.361111 | 0 | 0 | 0.029732 | 0 | 0 | 0 | 0 | 0 | 0.055556 | 1 | 0.25 | false | 0 | 0 | 0.138889 | 0.5 | 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 | 0 | 1 | 0 | 0 | 0 | 2 |
5c3fb60345aa61b3393bc0f38716bb6c34f8243f | 140 | py | Python | Inclass Program/6310545566_phawit_week5_ex1_hw.py | HelloYeew/helloyeew-lab-computer-programming-i | 60b05072f32f23bab4a336b506ba7f66e52c045d | [
"MIT"
] | null | null | null | Inclass Program/6310545566_phawit_week5_ex1_hw.py | HelloYeew/helloyeew-lab-computer-programming-i | 60b05072f32f23bab4a336b506ba7f66e52c045d | [
"MIT"
] | null | null | null | Inclass Program/6310545566_phawit_week5_ex1_hw.py | HelloYeew/helloyeew-lab-computer-programming-i | 60b05072f32f23bab4a336b506ba7f66e52c045d | [
"MIT"
] | null | null | null | n = 1
while True:
num = int(input(f"Enter value{n}: "))
if num == -99:
break
n += 1
print(f"You entered {n-1} numbers.") | 20 | 41 | 0.521429 | 24 | 140 | 3.041667 | 0.708333 | 0.082192 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.050505 | 0.292857 | 140 | 7 | 42 | 20 | 0.686869 | 0 | 0 | 0 | 0 | 0 | 0.297872 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.142857 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
3082ba9fb5400dbc64c596504c5c24909a6d41c8 | 1,357 | py | Python | run.py | Reself-C/- | ceea2b39d7da990bc1d4dd9fa39ff559d0738cac | [
"MIT"
] | 2 | 2021-11-12T14:36:55.000Z | 2022-01-19T16:40:35.000Z | run.py | Reself-C/ZJUI-ZJE-xingce | ceea2b39d7da990bc1d4dd9fa39ff559d0738cac | [
"MIT"
] | null | null | null | run.py | Reself-C/ZJUI-ZJE-xingce | ceea2b39d7da990bc1d4dd9fa39ff559d0738cac | [
"MIT"
] | null | null | null | from selenium import webdriver
from configs import parse_args
import time
from datetime import datetime
def run(args):
driver = webdriver.Chrome()
driver.get(args.url)
time.sleep(1)
# 姓名
driver.find_element_by_id('q1').clear()
driver.find_element_by_id('q1').send_keys(args.name)
# 学号
driver.find_element_by_id('q2').clear()
driver.find_element_by_id('q2').send_keys(args.id)
# 手机号
driver.find_element_by_id('q3').clear()
driver.find_element_by_id('q3').send_keys(args.phone)
# 单位
if args.loc == 'ZJUI':
driver.find_element_by_id('q4_1').click()
elif args.loc == 'ZJE':
driver.find_element_by_id('q4_0').click()
# 年级
if args.grade == '2018':
driver.find_element_by_id('q5_0').click()
elif args.grade == '2019':
driver.find_element_by_id('q5_1').click()
elif args.grade == '2020':
driver.find_element_by_id('q5_2').click()
elif args.grade == '2021':
driver.find_element_by_id('q5_3').click()
driver.find_element_by_id('submitbutton').click()
driver.close()
driver.quit()
if __name__ == '__main__':
args = parse_args()
print(args)
while True:
now = datetime.now()
if args.hr == now.hour and args.min == now.minute:
run(args)
time.sleep(15) | 27.14 | 58 | 0.624908 | 195 | 1,357 | 4.051282 | 0.328205 | 0.164557 | 0.279747 | 0.312658 | 0.394937 | 0.368354 | 0 | 0 | 0 | 0 | 0 | 0.035407 | 0.229919 | 1,357 | 50 | 59 | 27.14 | 0.720574 | 0.011054 | 0 | 0 | 0 | 0 | 0.059088 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.027027 | false | 0 | 0.108108 | 0 | 0.135135 | 0.027027 | 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 | 0 | 0 | 0 | 0 | 2 |
30882cc81c498dc571777faaf424632c5e28545a | 283 | py | Python | code/speedlimit.py | kkirigaya/Kattis | 29b7180aef70f51ea5b4d064204f70fc6d29d312 | [
"MIT"
] | 1 | 2021-06-05T20:52:43.000Z | 2021-06-05T20:52:43.000Z | code/speedlimit.py | kkirigaya/Kattis | 29b7180aef70f51ea5b4d064204f70fc6d29d312 | [
"MIT"
] | null | null | null | code/speedlimit.py | kkirigaya/Kattis | 29b7180aef70f51ea5b4d064204f70fc6d29d312 | [
"MIT"
] | null | null | null | while True:
n = int(input())
if n == -1:
break
last_elapsed = 0
distance = 0
for _ in range(n):
s, t = map(int, input().split())
_t = t - last_elapsed
distance += s * _t
last_elapsed = t
print(distance, "miles")
| 17.6875 | 40 | 0.480565 | 37 | 283 | 3.513514 | 0.567568 | 0.253846 | 0.184615 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017442 | 0.392226 | 283 | 15 | 41 | 18.866667 | 0.738372 | 0 | 0 | 0 | 0 | 0 | 0.017668 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.083333 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
308eeb834b8bc915f2770e0739c00aeca7e5e5fa | 1,726 | py | Python | orchestrator/tests/PythonTestDriver.py | spacebel/MAJA | 3e5d20bc9c744c610e608cfcf1f4c5c738d4de9e | [
"Apache-2.0"
] | 57 | 2020-09-30T08:51:22.000Z | 2021-12-19T20:28:30.000Z | orchestrator/tests/PythonTestDriver.py | spacebel/MAJA | 3e5d20bc9c744c610e608cfcf1f4c5c738d4de9e | [
"Apache-2.0"
] | 34 | 2020-09-29T21:27:22.000Z | 2022-02-03T09:56:45.000Z | orchestrator/tests/PythonTestDriver.py | spacebel/MAJA | 3e5d20bc9c744c610e608cfcf1f4c5c738d4de9e | [
"Apache-2.0"
] | 14 | 2020-10-11T13:17:59.000Z | 2022-03-09T15:58:19.000Z | # -*- coding: utf-8 -*-
#
# Copyright (C) 2020 Centre National d'Etudes Spatiales (CNES)
#
# 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.
#
"""
###################################################################################################
o o
oo oo oo o oo ,-.
o o o o o o o o o \_/
o o o o o o o o {|||D
o o oooooo o oooooo / \
o o o o o o o o `-^
o o o o oooo o o
###################################################################################################
orchestrator.tests.plugins.test_maja_sentinel2_l1_pimage_file_reader -- shortdesc
orchestrator.tests.plugins.test_maja_sentinel2_l1_pimage_file_reader is a description
It defines classes_and_methods
###################################################################################################
"""
import sys
from orchestrator.common.logger.maja_logging import configure_logger
LOGGER = configure_logger(__name__)
t = __import__(sys.argv[1])
argv = sys.argv[1:]
t.test(argv)
| 35.958333 | 99 | 0.497683 | 199 | 1,726 | 4.18593 | 0.507538 | 0.072029 | 0.090036 | 0.110444 | 0.176471 | 0.176471 | 0.176471 | 0.176471 | 0.176471 | 0.176471 | 0 | 0.011933 | 0.271727 | 1,726 | 47 | 100 | 36.723404 | 0.650756 | 0.8708 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 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 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
3091f6e5bea6d41446cd759bfbe8ab5d96ecdc2d | 2,775 | py | Python | Turnauswertung-py3/common/models.py | naechtner/turn-events | 2c71f8ceb5d6f8280c6c19a6467922a834ae0b02 | [
"MIT"
] | null | null | null | Turnauswertung-py3/common/models.py | naechtner/turn-events | 2c71f8ceb5d6f8280c6c19a6467922a834ae0b02 | [
"MIT"
] | 11 | 2015-06-20T11:51:10.000Z | 2017-01-09T07:09:04.000Z | Turnauswertung-py3/common/models.py | naechtner/turn-events | 2c71f8ceb5d6f8280c6c19a6467922a834ae0b02 | [
"MIT"
] | null | null | null | from django.core.urlresolvers import reverse
from django.db import models
from django.utils.text import slugify
from django.utils.translation import ugettext_lazy
class Performance(models.Model):
value = models.DecimalField(
ugettext_lazy('Value'), null=False, max_digits=5, decimal_places=3,
default=0.0
)
value_final = models.DecimalField(
ugettext_lazy('Final Value'), null=True, blank=True, max_digits=5,
decimal_places=3
)
athlete = models.ForeignKey(
'athletes.Athlete', verbose_name=ugettext_lazy('Athlete'))
discipline = models.ForeignKey(
'Discipline', verbose_name=ugettext_lazy('Discipline'))
class Meta:
unique_together = (("athlete", "discipline"), )
def __str__(self):
return "{0}, {1}".format(self.athlete, self.discipline) # old
# return "{0}, {1}: {2}".format(self.athlete, self.discipline, self.value) # noqa
class Discipline(models.Model):
name = models.CharField(ugettext_lazy('Name'), max_length=50, null=False)
slug = models.SlugField(max_length=128, blank=True)
def __str__(self):
return self.name
def save(self, *args, **kwargs):
if not self.id:
self.slug = str(slugify(str(self)))
return super(Discipline, self).save(*args, **kwargs)
def get_absolute_url(self):
return reverse('disciplines.detail', kwargs={ 'id': self.id, 'slug': self.slug })
def get_edit_url(self):
return reverse('disciplines.edit', kwargs={ 'pk': self.id, 'slug': self.slug })
def get_delete_url(self):
return reverse('disciplines.delete', kwargs={ 'pk': self.id, 'slug': self.slug })
class Address(models.Model):
contact_name = models.CharField(ugettext_lazy('Contact name'), max_length=64)
phone = models.CharField(ugettext_lazy('Contact phone'), max_length=15, null=True, blank=True)
email = models.EmailField(ugettext_lazy('Contact email'), null=True, blank=True)
street = models.CharField(ugettext_lazy('Street'), max_length=128)
city = models.CharField(ugettext_lazy('City'), max_length=128)
province = models.CharField(ugettext_lazy('Province'), max_length=128)
zip_code = models.CharField(ugettext_lazy('Zip code'), max_length=10)
@property
def address_formatted(self):
return '{0}\n{1} {2}\n{3}'.format(self.street, self.zip_code, self.city, self.province)
class StreamDisciplineJoin(models.Model):
position = models.IntegerField(null=True)
stream = models.ForeignKey('streams.Stream')
discipline = models.ForeignKey('Discipline')
class Meta:
ordering = ['position']
def __str__(self):
return "No {0}: {1} in {2}".format(self.position, self.discipline, self.stream)
| 34.259259 | 98 | 0.677117 | 349 | 2,775 | 5.237822 | 0.272206 | 0.085339 | 0.088074 | 0.103392 | 0.212254 | 0.071116 | 0.044858 | 0 | 0 | 0 | 0 | 0.016747 | 0.182342 | 2,775 | 80 | 99 | 34.6875 | 0.788894 | 0.02991 | 0 | 0.090909 | 0 | 0 | 0.107515 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.145455 | false | 0 | 0.072727 | 0.127273 | 0.763636 | 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 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
30935f77f4084126748eae6b81917428fab915f0 | 24,066 | py | Python | Bioinf_functions_original.py | maepz/Bioinformatic_algorithms_coding_challenges | 779291a024f34ec7f6b701a04beb92bc48d55726 | [
"MIT"
] | null | null | null | Bioinf_functions_original.py | maepz/Bioinformatic_algorithms_coding_challenges | 779291a024f34ec7f6b701a04beb92bc48d55726 | [
"MIT"
] | null | null | null | Bioinf_functions_original.py | maepz/Bioinformatic_algorithms_coding_challenges | 779291a024f34ec7f6b701a04beb92bc48d55726 | [
"MIT"
] | null | null | null |
# coding: utf-8
# In[1]:
'''PatternCount(Text, Pattern)
Count the frequency on a pattern(word) in a text(sequence)'''
def PatternCount(Text, Pattern):
count=0
for n in range(0,(len(Text)-len(Pattern)+1)):
if Text[n:n+len(Pattern)]== Pattern:
count += 1
print(count)
return
#PatternCount('AACTGGTCACACATC','AC')
#PatternCount('CGCGATACGTTACATACATGATAGACCGCGCGCGATCATATCGCGATTATC', 'CGCG')
# In[3]:
'''FrequentWords(Text, k)
Find all most frquent words of size k in a sequence'''
def FrequentWords(Text, k):
FrequentPattern=list()
d={}
for n in range(0,(len(Text)-(k-1))):
word=Text[n:n+k]
if word in d:
d[word] += 1
else:
d[word] = 1
maxCount= max(d.values())
max_keys = [k for k in d if d[k] == maxCount]
return(max_keys)
#FrequentWords('ACGTTGCATGTCGCATGATGCATGAGAGCT', 4)
#print ('The script took '+str(time.time()-start_time)+' s')
#FrequentWords('TAAACGTGAGAGAAACGTGCTGATTACACTTGTTCGTGTGGTAT', 3)
# In[52]:
'''FindingFrequentWordsBySorting(Text , k)'''
#------------------------------------------------
def PatternToNumber(Pattern):
d={'A':0,'C':1,'G':2,'T':3}
if Pattern == '':
return 0
symbol = Pattern[-1]
Pattern= Pattern[:-1]
return(4 * PatternToNumber(Pattern) + d[symbol])
#--
def NumberToPattern(Number, k):
d={'A':0,'C':1,'G':2,'T':3}
pattern=[]
if k==1:
#return d.keys()[d.values().index(Number)]
return (list(d.keys())[list(d.values()).index(int(Number))])
prefixIndex = Number//4
r = Number%4
PrefixPattern = NumberToPattern(prefixIndex, (k-1))
symbol = (list(d.keys())[list(d.values()).index(r)])
return (PrefixPattern+symbol)
#--
def FindingFrequentWordsBySorting(Text , k):
FrequentPatterns = list()
Index={}
Count={}
for n in range(len(Text)-(k-1)):
Pattern = Text[n:n+k]
Index[n] = int(PatternToNumber(Pattern))
Count[n] = 1
SortedIndex = sorted(Index.values())
for i in range(1,len(Text)-(k-1)):
if SortedIndex[i] == SortedIndex[i-1]:
Count[i] = (Count[i-1]) + 1
maxCount= max(Count.values())
for i in range(0,len(Text)-(k-1)):
if Count[i] == maxCount:
Pattern = NumberToPattern(SortedIndex[(i)], k)
FrequentPatterns.append(Pattern)
return FrequentPatterns
#FindingFrequentWordsBySorting('ACGTTGCATGTCGCATGATGCATGAGAGCT', 4)
#print ('The script took '+str(time.time()-start_time)+' s')
#this script was slower, but might become faster when dealing with long sequences
# In[6]:
'''ReverseComplement(sequence)
Find the reverse complement of a sequence'''
def ReverseComplement(sequence):
complement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
reverse_complement = "".join(complement.get(base, base) for base in reversed(sequence))
return(reverse_complement);
#ReverseComplement('ACGTTGCA')
#ReverseComplement('TTGTGTC')
# In[49]:
'''PatternMatch(Text,Pattern)
Finds all the positions of a pattern in a text'''
def PatternMatch(Text,Pattern):
output=list()
for n in range(0,(len(Text)-(len(Pattern)-1))):
word=Text[n:n+len(Pattern)]
if word == Pattern:
output.append(n)
print(' '.join(map(str,output)))
return;
#PatternMatch('GATATATGCATATACTT','ATAT')
# In[50]:
'''ClumpFind(Text,k,L,t)
Finds clump of at least t patterns of length k(kmers) within a window of length L from a Text(sequence)'''
def ClumpFind(Text,k,L,t):
from collections import defaultdict
kmer_dic = defaultdict(list)
suc_keys = []
for n in range(len(Text)-(k-1)):
kmer_dic[Text[n:n+k]].append(n)
for key in kmer_dic.keys():
if len(kmer_dic[key])>=t:
index_bank = []
for index in kmer_dic[key]:
index_bank.append(index)
for list_index in range(0,len(index_bank)-(t-1)):
if index_bank[list_index+t-1]+k-index_bank[list_index]<=L:
suc_keys.append(key)
break
else:
continue
else:
continue
print (' '.join(map(str,suc_keys)))
return;
#ClumpFind('CGGACTCGACAGATGTGAAGAACGACAATGTGAAGACTCGACACGACAGAGTGAAGAGAAGAGGAAACATTGTAA',5,50,4)
# In[1]:
'''PatternToNumber(Pattern)
Transform a pattern of DNA letters into an index number;
Convert k-mers into the 4^k different integers between 0 and 4^k − 1'''
#V1
def PatternToNumber1(Pattern):
d={'A':0,'C':1,'G':2,'T':3}
number=0
for i in range(0,len(Pattern)):
number += d[Pattern[i]]*(4**(len(Pattern)-1-i))
return(number);
#--------------------------------------
# V2
def PatternToNumber(Pattern):
d={'A':0,'C':1,'G':2,'T':3}
if Pattern == '':
return 0
symbol = Pattern[-1]
Pattern= Pattern[:-1]
return(4 * PatternToNumber(Pattern) + d[symbol])
#---
#PatternToNumber('ATC')
# In[6]:
''' NumberToPattern(Number, k)'''
#V2
def NumberToPattern(Number, k):
d={'A':0,'C':1,'G':2,'T':3}
pattern=[]
if k==1:
#return d.keys()[d.values().index(Number)]
return (list(d.keys())[list(d.values()).index(int(Number))])
prefixIndex = Number//4
r = Number%4
PrefixPattern = NumberToPattern(prefixIndex, (k-1))
symbol = (list(d.keys())[list(d.values()).index(r)])
return (PrefixPattern+symbol)
#print(NumberToPattern(5437, 8))
# In[17]:
'''FrequencyArray(Text , k)'''
def PatternToNumber(Pattern):
d={'A':0,'C':1,'G':2,'T':3}
number=0
for i in range(0,len(Pattern)):
number = number + d[Pattern[i]]*(4**(len(Pattern)-1-i))
return(number);
#---------------------------
def FrequencyArray(Text,k):
FrequencyArray={}
for i in range(4**k):
FrequencyArray[i]= 0
for n in range(0,len(Text)-(k-1)):
Pattern = Text[n:n+k]
j=PatternToNumber(Pattern)
FrequencyArray[j] += 1
return(FrequencyArray.values());
#print(' '.join(map(str,(FrequencyArray('ATATATAC',2)))))
# In[1]:
'''Hamming Distance(p,q)
We say that position i in k-mers p1 … pk and q1 … qk is a mismatch if pi ≠ qi.
For example, CGAAT and CGGAC have two mismatches.
The number of mismatches between strings p and q is called the Hamming distance between these strings
and is denoted HammingDistance(p, q).'''
def HammingDistance(p,q):
HamDi=int(0)
for i in range(len(p)):
if p[i]==q[i]:
continue
else:
HamDi+=+1
return(HamDi)
# In[2]:
'''ApproximatePatternCount(Text,Pattern,d)
is a modify version of PatternMatch that account for a max of d mismatch in patterns'''
'''Our goal now is to modify our previous algorithm for the Frequent Words Problem in order to find DnaA boxes
by identifying frequent k-mers, possibly with mismatches. Given strings Text and Pattern as well as an integer d,
we define Countd(Text, Pattern) as the total number of occurrences of Pattern in Text with at most d mismatches.
For example, Count1(AACAAGCTGATAAACATTTAAAGAG, AAAAA) = 4 because AAAAA appears four times in this string with at
most one mismatch: AACAA, ATAAA, AAACA, and AAAGA. Note that two of these occurrences overlap.'''
def HammingDistance(p,q):
HamDi=int(0)
for i in range(len(p)):
if p[i]==q[i]:
continue
else:
HamDi+=+1
return(HamDi)
#--
def ApproximatePatternCount(Text,Pattern,d):
count=0
for n in range(0,(len(Text)-(len(Pattern)-1))):
word=Text[n:n+len(Pattern)]
if HammingDistance(Pattern,word)<=d:
count +=+1
return(count)
# In[3]:
'''ImmediateNeighbors(Pattern)
generate the 1-neigborhood of Pattern'''
def ImmediateNeighbors(Pattern):
Neighborhood =list()
nucl='ATCG'
for i in range(0,len(Pattern)):
symbol = Pattern[i]
for n in nucl:
if Pattern[i]== n:
continue
else:
Neighbor = Pattern.replace(Pattern[i], n)
Neighborhood.append(Neighbor)
return(Neighborhood)
# In[4]:
'''Neighbors(Pattern, d)
Find all the near-patterns for which the haming distance with pattern is <= d
'''
#--------------------------------------------------
def HammingDistance(p,q):
HamDi=int(0)
for i in range(len(p)):
if p[i]==q[i]:
continue
else:
HamDi+=+1
return(HamDi)
#--
def Neighbors(Pattern, d):
if d == 0:
Neighborhood =(str(Pattern))
return Neighborhood
if len(Pattern) == 1:
Neighborhood=['A','C','G','T']
return Neighborhood
nucl=['A','C','G','T']
Neighborhood=list()
SuffixNeighbors = Neighbors((Pattern[1:]), d)
for Text in SuffixNeighbors:
if HammingDistance((Pattern[1:]), Text) < d:
for n in nucl:
Neighborhood.append(str(n + Text))
else:
Neighborhood.append(str(Pattern[0]+ Text))
return Neighborhood
# In[5]:
'''FrequentWordsWithMismatches(Text, k, d)'''
#--------------------------------------
def HammingDistance(p,q):
HamDi=int(0)
for i in range(len(p)):
if p[i]==q[i]:
continue
else:
HamDi+=+1
return(HamDi)
#--
def Neighbors(Pattern, d):
if d == 0:
Neighborhood =(str(Pattern))
return Neighborhood
if len(Pattern) == 1:
Neighborhood=['A','C','G','T']
return Neighborhood
nucl=['A','C','G','T']
Neighborhood=list()
SuffixNeighbors = Neighbors((Pattern[1:]), d)
for Text in SuffixNeighbors:
if HammingDistance((Pattern[1:]), Text) < d:
for n in nucl:
Neighborhood.append(str(n + Text))
else:
Neighborhood.append(str(Pattern[0]+ Text))
return Neighborhood
#--
def FrequentWordsWithMismatches(Text, k, d):
dico={}
for n in range(0,(len(Text)-(k-1))):
Neighborhood = Neighbors(Text[n:n+k], d)
for word in Neighborhood:
if word in dico.keys():
dico[word]+=1
else:
dico[word]= 1
max_value = max(dico.values())
max_keys = [k for k in dico if dico[k] == max_value]
return(max_keys)
# In[6]:
def HammingDistance(p,q):
HamDi=int(0)
for i in range(len(p)):
if p[i]==q[i]:
continue
else:
HamDi+=+1
return(HamDi)
#--
def ApproximatePatternMatch(Text,Pattern,d):
posi=list()
for n in range(0,(len(Text)-(len(Pattern)-1))):
word=Text[n:n+len(Pattern)]
if HammingDistance(Pattern,word)<=d:
posi.append(n)
return(posi)
# In[7]:
'''MOTIFENUMERATION(Dna, k, d)
A brute force algorithm for motif finding'''
def HammingDistance(p,q):
HamDi=int(0)
for i in range(len(p)):
if p[i]==q[i]:
continue
else:
HamDi+=+1
return(HamDi)
#--
def Neighbors(Pattern, d):
if d == 0:
Neighborhood =(str(Pattern))
return Neighborhood
if len(Pattern) == 1:
Neighborhood=['A','C','G','T']
return Neighborhood
nucl=['A','C','G','T']
Neighborhood=list()
SuffixNeighbors = Neighbors((Pattern[1:]), d)
for Text in SuffixNeighbors:
if HammingDistance((Pattern[1:]), Text) < d:
for n in nucl:
Neighborhood.append(str(n + Text))
else:
Neighborhood.append(str(Pattern[0]+ Text))
return Neighborhood
#--
def MOTIFENUMERATION(Dna, k, d):
i=1
p=list()
while i<len(lines):
list_i=list()
for n in range(len(lines[i])-k+1):
Neigh=Neighbors(lines[i][n:n+k],d)
for word in Neigh:
list_i.append(word)
p.append(list_i)
i=i+1
return(set.intersection(*map(set, p)))
# In[8]:
'''d(Pattern, Dna)
the sum of distances between Pattern and all strings in Dna'''
def HammingDistance(p,q):
HamDi=int(0)
for i in range(len(p)):
if p[i]==q[i]:
continue
else:
HamDi+=+1
return(HamDi)
#--
def d(Pattern, Dna):
score=0
k=len(Pattern)
for i in range(0,len(Dna)):
Hamdist={}
minDist={}
seq=Dna[i]
for n in range(0,len(seq)-(k-1)):
Hamdist[seq[n:n+k]]=HammingDistance(Pattern,seq[n:n+k])
minimum=int(min(Hamdist.values()))
score+=minimum
return(score)
# In[9]:
'''MEDIANSTRING(Dna, k)
A k-mer Pattern that minimizes d(Pattern, Dna) among all k-mers Pattern.'''
#--
def HammingDistance(p,q):
HamDi=int(0)
for i in range(len(p)):
if p[i]==q[i]:
continue
else:
HamDi+=+1
return(HamDi)
#--
def NumberToPattern(Number, k):
d={'A':0,'C':1,'G':2,'T':3}
pattern=[]
if k==1:
#return d.keys()[d.values().index(Number)]
return (list(d.keys())[list(d.values()).index(int(Number))])
prefixIndex = Number//4
r = Number%4
PrefixPattern = NumberToPattern(prefixIndex, (k-1))
symbol = (list(d.keys())[list(d.values()).index(r)])
return (PrefixPattern+symbol)
#--
def d(Pattern, Dna):
score=0
k=len(Pattern)
for i in range(0,len(Dna)):
Hamdist={}
minDist={}
seq=Dna[i]
for n in range(0,len(seq)-(k-1)):
Hamdist[seq[n:n+k]]=HammingDistance(Pattern,seq[n:n+k])
minimum=int(min(Hamdist.values()))
score+=minimum
return(score)
#--
def MEDIANSTRING(Dna, k):
distance= float('inf')
kmer_pattern=list()
Median=list()
for n in range(4**k):
kmer_pattern.append(NumberToPattern(n, k))
for Pattern in kmer_pattern:
#if distance > d(Pattern, Dna):
if 0 == d(Pattern, Dna):
print distance
Median.append(Pattern)
return(Median)
# In[10]:
'''Profile_most(Text,k,Profile)
Profile-most Probable k-mer:
a k-mer that was most likely to have been generated by Profile among all k-mers in Text'''
from numpy import *
#--
def PatternToNumber(seq):
d={'A':0,'C':1,'G':2,'T':3}
number=0
revseq=seq[::-1]
for i in range(len(revseq)):
number += d[revseq[i]]*(4**i)
return(number)
#--
def Profile_most(Text,k,Profile):
max_score=0
most_probable_kmer=Text[0:0+k]
for n in range(0,len(Text)-(k-1)):
kmer=Text[n:n+k]
score=1
for i in range(0,len(kmer)):
probaN=Profile[PatternToNumber(kmer[i])][i]
return probaN
score *= probaN
return score
if score>max_score:
max_score=score
most_probable_kmer=kmer
return(most_probable_kmer)
# In[11]:
'''MakeProfile(Motif_list)
Make profile matrix from a list of motifs'''
#V1: Without pseudo counts, 0 probability possible
from numpy import *
import numpy as np
def MakeProfileRaw(Motif_list):
k=len(Motif_list[0])
matrix_occ = np.zeros((4,k))
for i in range(len(Motif_list)):
for n in range(len(Motif_list[i])):
matrix_occ[(PatternToNumber(Motif_list[i][n])),n]+=1
Profile_matrix= matrix_occ / matrix_occ.sum(axis=0, dtype='float')
return Profile_matrix
##V2: With pseudo counts, get rid of 0 probability
def MakeProfile(Motif_list):
k=len(Motif_list[0])
matrix_occ = np.zeros((4,k))
matrix_occ +=1
for i in range(len(Motif_list)):
for n in range(len(Motif_list[i])):
matrix_occ[(PatternToNumber(Motif_list[i][n])),n]+=1
Profile_matrix= matrix_occ / matrix_occ.sum(axis=0, dtype='float')
#return matrix_occ.sum(axis=0, dtype='float')
return Profile_matrix
# In[12]:
'''Consensus(Profile)
output consensus sequence from a profile matrix'''
import numpy as np
def Consensus(Profile):
maxarg= list(Profile.argmax(0))
Cons=''
for posi in maxarg:
Cons+=NumberToPattern(int(posi), 1)
return Cons
# In[16]:
def HammingDistance(p,q):
HamDi=int(0)
for i in range(len(p)):
if p[i]==q[i]:
continue
else:
HamDi+=+1
return(HamDi)
#--
def NumberToPattern(Number, k):
d={'A':0,'C':1,'G':2,'T':3}
pattern=[]
if k==1:
#return d.keys()[d.values().index(Number)]
return (list(d.keys())[list(d.values()).index(int(Number))])
prefixIndex = Number//4
r = Number%4
PrefixPattern = NumberToPattern(prefixIndex, (k-1))
symbol = (list(d.keys())[list(d.values()).index(r)])
return (PrefixPattern+symbol)
#--
def PatternToNumber(Pattern):
d={'A':0,'C':1,'G':2,'T':3}
if Pattern == '':
return 0
symbol = Pattern[-1]
Pattern= Pattern[:-1]
return(4 * PatternToNumber(Pattern) + d[symbol])
def score(motifs):
# change to motifs as list of columns instead of list of rows
matrix = [[] for k in range(len(motifs[0]))]
for i in range(len(motifs[0])):
for j in range(len(motifs)):
matrix[i].append(motifs[j][i])
score = 0
for col in range(len(matrix)):
# count letters in a column, delete most common letter, sum remaining
c = Counter(matrix[col])
del c[c.most_common(1)[0][0]]
score += sum(c.values())
return score
def Pr(kmer,Profile):
score=1
for n in range(len(kmer)):
score *= Profile[n][kmer[n]]
return score
def MakeProfile(motifs):
# construct profile-matrix (each column as an dict) from count-matrix
k=len(motifs[0])
counter = [{"A":1,"C":1,"G":1,"T":1} for x in range(k)] # start with pseudocounts
for i in range(k):
for j in range(len(motifs)):
letter = motifs[j][i]
counter[i].update({letter:1+counter[i][letter]})
for d in counter:
for key in d: d[key] /= (len(motifs)+4) # +4 due to pseudocounts
return counter
#--
def Profile_most(Text,k,Profile):
max_score=0
most_probable_kmer=Text[0:0+k]
for n in range(0,len(Text)-(k-1)):
kmer=Text[n:n+k]
score=1
for i in range(0,len(kmer)):
probaN=Profile[PatternToNumber(kmer[i])][i]
score *= probaN
if score>max_score:
max_score=score
most_probable_kmer=kmer
else:
continue
return(most_probable_kmer)
#--
def Consensus(Profile):
maxarg= list(Profile.argmax(0))
Cons=''
for posi in maxarg:
Cons+=NumberToPattern(int(posi), 1)
return Cons
#--
def d(Pattern, Dna):
score=0
k=len(Pattern)
for i in range(0,len(Dna)):
Hamdist={}
minDist={}
seq=Dna[i]
for n in range(0,len(seq)-(k-1)):
Hamdist[seq[n:n+k]]=HammingDistance(Pattern,seq[n:n+k])
minimum=int(min(Hamdist.values()))
score+=minimum
return(score)
#--
def GREEDYMOTIFSEARCH(Dna,k,t):
#starting conditions:
BestMotifs_list=list()
for string in range(len(Dna)):
BestMotifs_list.append(Dna[string][0:0+k])
#list all kmers in first string
kmer_1st_string=list()
for n in range(len(Dna[0])-(k-1)):
Motif=Dna[0][n:n+k]
kmer_1st_string.append(Motif)
#-
for motif in kmer_1st_string:
Motif_list=list()
Motif_list.append(motif)
for i in range(1,len(Dna)):
Text=Dna[i]
Profile=array(MakeProfile(Motif_list))
new_motif=Profile_most(Text,k,Profile)
Motif_list.append(new_motif)
Motif_score= score(Motif_list)
if Motif_score < score(BestMotifs_list):
BestMotifs_list=Motif_list
return(BestMotifs_list)
# In[17]:
def RANDOMIZEDMOTIFSEARCH(Dna, k, t):
Motifs=list()
for n in range(len(Dna)):
rdm_posi=random.randint(0, (len(Dna[n])-(k)))
Motifs.append(Dna[n][rdm_posi:rdm_posi+k])
BestMotifs=Motifs
#print BestMotifs
while True:
Profile=MakeProfile(Motifs)
Motifs=list()
for n in range(len(Dna)):
Motifs.append(Profile_most(Dna[n],k,Profile))
Motif_score= d(Consensus(MakeProfile(Motifs)), Motifs)
if Motif_score < d(Consensus(MakeProfile(BestMotifs)), BestMotifs):
BestMotifs=Motifs
else:
return BestMotifs,Motif_score
# In[18]:
'''Random(array)
this random number generator, denoted Random(array), where array=(p1, …, pn),
models an n-sided biased die and returns integer i with probability pi'''
def Pr(kmer,Profile):
score=1
for i in range(0,len(kmer)):
probaN=Profile[PatternToNumber(kmer[i])][i]
score *= probaN
return score
def MakeProfile(Motif_list):
k=len(Motif_list[0])
matrix_occ = np.zeros((4,k))
matrix_occ +=1
for i in range(len(Motif_list)):
for n in range(len(Motif_list[i])):
matrix_occ[(PatternToNumber(Motif_list[i][n])),n]+=1
Profile_matrix= matrix_occ / matrix_occ.sum(axis=0, dtype='float')
#return matrix_occ.sum(axis=0, dtype='float')
return Profile_matrix
def PatternToNumber(Pattern):
d={'A':0,'C':1,'G':2,'T':3}
if Pattern == '':
return 0
symbol = Pattern[-1]
Pattern= Pattern[:-1]
return(4 * PatternToNumber(Pattern) + d[symbol])
def Random(Motif_list,Profile):
Array=list()
for motif in Motif_list:
Array.append(Pr(motif,Profile))
PArray=[v/sum(Array) for v in Array]
i = np.random.choice( len(PArray), p=PArray)
return i
# In[19]:
def score(motifs):
# change to motifs as list of columns instead of list of rows
matrix = [[] for k in range(len(motifs[0]))]
for i in range(len(motifs[0])):
for j in range(len(motifs)):
matrix[i].append(motifs[j][i])
score = 0
for col in range(len(matrix)):
# count letters in a column, delete most common letter, sum remaining
c = Counter(matrix[col])
del c[c.most_common(1)[0][0]]
score += sum(c.values())
return score
def Pr(kmer,Profile):
score=1
for i in range(0,len(kmer)):
probaN=Profile[PatternToNumber(kmer[i])][i]
score *= probaN
return score
def MakeProfile(Motif_list):
k=len(Motif_list[0])
matrix_occ = np.zeros((4,k))
matrix_occ +=1
for i in range(len(Motif_list)):
for n in range(len(Motif_list[i])):
matrix_occ[(PatternToNumber(Motif_list[i][n])),n]+=1
Profile_matrix= matrix_occ / matrix_occ.sum(axis=0, dtype='float')
#return matrix_occ.sum(axis=0, dtype='float')
return Profile_matrix
def PatternToNumber(Pattern):
d={'A':0,'C':1,'G':2,'T':3}
if Pattern == '':
return 0
symbol = Pattern[-1]
Pattern= Pattern[:-1]
return(4 * PatternToNumber(Pattern) + d[symbol])
def Random(Motif_list,Profile):
Array=list()
for motif in Motif_list:
Array.append(Pr(motif,Profile))
PArray=[v/sum(Array) for v in Array]
i = np.random.choice( len(PArray), p=PArray)
return i
def GIBBSSAMPLER(Dna, k, t, N):
#dic for faster indexing of kmers
dic={}
for t in range(len(Dna)):
dic[t]=list()
for n in range(0,len(Dna[t])-(k-1)):
dic[t].append(Dna[t][n:n+k])
#get first set of Motifs
Motifs=list()
for n in range(len(Dna)):
rdm_posi=random.randint(0, (len(Dna[n])-(k)))
Motifs.append(Dna[n][rdm_posi:rdm_posi+k])
BestMotifs=Motifs[:]
BestScore=score(BestMotifs)
###
x=0
while x < N:
i=(Random(Motifs,MakeProfile(Motifs)))
Motifs.remove(Motifs[i])
Profile_sans=MakeProfile(Motifs)
ii=Random(dic[i],Profile_sans)
Motifs_i= dic[i][ii]
Motifs.insert(i,Motifs_i)
sM=score(Motifs)
if sM < BestScore:
BestScore=sM
BestMotifs=Motifs[:]
#print BestMotifs, sM,BestScore, x
x+=1
else:
x+=1
#print BestMotifs, score(BestMotifs),x
return BestMotifs, score(BestMotifs)
# In[ ]:
| 26.504405 | 113 | 0.585058 | 3,334 | 24,066 | 4.182663 | 0.105579 | 0.034134 | 0.026533 | 0.024453 | 0.563786 | 0.545572 | 0.539333 | 0.528935 | 0.52664 | 0.516673 | 0 | 0.018576 | 0.255132 | 24,066 | 907 | 114 | 26.533627 | 0.75873 | 0.093701 | 0 | 0.708819 | 0 | 0 | 0.005929 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.008319 | null | null | 0.006656 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
309df072b2697876ca53234ff588a68e49d6b19e | 9,195 | py | Python | sdk/python/pulumi_proxmox/permission/user.py | meyskens/pulumi-proxmox | bf48570690350be68fa554e1cec376212eb449ab | [
"ECL-2.0",
"Apache-2.0"
] | 16 | 2021-01-11T11:26:19.000Z | 2022-01-23T02:32:34.000Z | sdk/python/pulumi_proxmox/permission/user.py | meyskens/pulumi-proxmox | bf48570690350be68fa554e1cec376212eb449ab | [
"ECL-2.0",
"Apache-2.0"
] | 2 | 2021-01-29T08:15:46.000Z | 2021-10-17T16:33:19.000Z | sdk/python/pulumi_proxmox/permission/user.py | meyskens/pulumi-proxmox | bf48570690350be68fa554e1cec376212eb449ab | [
"ECL-2.0",
"Apache-2.0"
] | 4 | 2021-04-06T00:36:05.000Z | 2021-12-16T14:25:07.000Z | # coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union
from .. import _utilities, _tables
from . import outputs
from ._inputs import *
__all__ = ['User']
class User(pulumi.CustomResource):
def __init__(__self__,
resource_name: str,
opts: Optional[pulumi.ResourceOptions] = None,
acls: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['UserAclArgs']]]]] = None,
comment: Optional[pulumi.Input[str]] = None,
email: Optional[pulumi.Input[str]] = None,
enabled: Optional[pulumi.Input[bool]] = None,
expiration_date: Optional[pulumi.Input[str]] = None,
first_name: Optional[pulumi.Input[str]] = None,
groups: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
keys: Optional[pulumi.Input[str]] = None,
last_name: Optional[pulumi.Input[str]] = None,
password: Optional[pulumi.Input[str]] = None,
user_id: Optional[pulumi.Input[str]] = None,
__props__=None,
__name__=None,
__opts__=None):
"""
Create a User resource with the given unique name, props, and options.
:param str resource_name: The name of the resource.
:param pulumi.ResourceOptions opts: Options for the resource.
:param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['UserAclArgs']]]] acls: The access control list
:param pulumi.Input[str] comment: The user comment
:param pulumi.Input[str] email: The user's email address
:param pulumi.Input[bool] enabled: Whether the user account is enabled
:param pulumi.Input[str] expiration_date: The user account's expiration date
:param pulumi.Input[str] first_name: The user's first name
:param pulumi.Input[Sequence[pulumi.Input[str]]] groups: The user's groups
:param pulumi.Input[str] keys: The user's keys
:param pulumi.Input[str] last_name: The user's last name
:param pulumi.Input[str] password: The user's password
:param pulumi.Input[str] user_id: The user id
"""
if __name__ is not None:
warnings.warn("explicit use of __name__ is deprecated", DeprecationWarning)
resource_name = __name__
if __opts__ is not None:
warnings.warn("explicit use of __opts__ is deprecated, use 'opts' instead", DeprecationWarning)
opts = __opts__
if opts is None:
opts = pulumi.ResourceOptions()
if not isinstance(opts, pulumi.ResourceOptions):
raise TypeError('Expected resource options to be a ResourceOptions instance')
if opts.version is None:
opts.version = _utilities.get_version()
if opts.id is None:
if __props__ is not None:
raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
__props__ = dict()
__props__['acls'] = acls
__props__['comment'] = comment
__props__['email'] = email
__props__['enabled'] = enabled
__props__['expiration_date'] = expiration_date
__props__['first_name'] = first_name
__props__['groups'] = groups
__props__['keys'] = keys
__props__['last_name'] = last_name
if password is None:
raise TypeError("Missing required property 'password'")
__props__['password'] = password
if user_id is None:
raise TypeError("Missing required property 'user_id'")
__props__['user_id'] = user_id
super(User, __self__).__init__(
'proxmox:Permission/user:User',
resource_name,
__props__,
opts)
@staticmethod
def get(resource_name: str,
id: pulumi.Input[str],
opts: Optional[pulumi.ResourceOptions] = None,
acls: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['UserAclArgs']]]]] = None,
comment: Optional[pulumi.Input[str]] = None,
email: Optional[pulumi.Input[str]] = None,
enabled: Optional[pulumi.Input[bool]] = None,
expiration_date: Optional[pulumi.Input[str]] = None,
first_name: Optional[pulumi.Input[str]] = None,
groups: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
keys: Optional[pulumi.Input[str]] = None,
last_name: Optional[pulumi.Input[str]] = None,
password: Optional[pulumi.Input[str]] = None,
user_id: Optional[pulumi.Input[str]] = None) -> 'User':
"""
Get an existing User resource's state with the given name, id, and optional extra
properties used to qualify the lookup.
:param str resource_name: The unique name of the resulting resource.
:param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
:param pulumi.ResourceOptions opts: Options for the resource.
:param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['UserAclArgs']]]] acls: The access control list
:param pulumi.Input[str] comment: The user comment
:param pulumi.Input[str] email: The user's email address
:param pulumi.Input[bool] enabled: Whether the user account is enabled
:param pulumi.Input[str] expiration_date: The user account's expiration date
:param pulumi.Input[str] first_name: The user's first name
:param pulumi.Input[Sequence[pulumi.Input[str]]] groups: The user's groups
:param pulumi.Input[str] keys: The user's keys
:param pulumi.Input[str] last_name: The user's last name
:param pulumi.Input[str] password: The user's password
:param pulumi.Input[str] user_id: The user id
"""
opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
__props__ = dict()
__props__["acls"] = acls
__props__["comment"] = comment
__props__["email"] = email
__props__["enabled"] = enabled
__props__["expiration_date"] = expiration_date
__props__["first_name"] = first_name
__props__["groups"] = groups
__props__["keys"] = keys
__props__["last_name"] = last_name
__props__["password"] = password
__props__["user_id"] = user_id
return User(resource_name, opts=opts, __props__=__props__)
@property
@pulumi.getter
def acls(self) -> pulumi.Output[Optional[Sequence['outputs.UserAcl']]]:
"""
The access control list
"""
return pulumi.get(self, "acls")
@property
@pulumi.getter
def comment(self) -> pulumi.Output[Optional[str]]:
"""
The user comment
"""
return pulumi.get(self, "comment")
@property
@pulumi.getter
def email(self) -> pulumi.Output[Optional[str]]:
"""
The user's email address
"""
return pulumi.get(self, "email")
@property
@pulumi.getter
def enabled(self) -> pulumi.Output[Optional[bool]]:
"""
Whether the user account is enabled
"""
return pulumi.get(self, "enabled")
@property
@pulumi.getter(name="expirationDate")
def expiration_date(self) -> pulumi.Output[Optional[str]]:
"""
The user account's expiration date
"""
return pulumi.get(self, "expiration_date")
@property
@pulumi.getter(name="firstName")
def first_name(self) -> pulumi.Output[Optional[str]]:
"""
The user's first name
"""
return pulumi.get(self, "first_name")
@property
@pulumi.getter
def groups(self) -> pulumi.Output[Optional[Sequence[str]]]:
"""
The user's groups
"""
return pulumi.get(self, "groups")
@property
@pulumi.getter
def keys(self) -> pulumi.Output[Optional[str]]:
"""
The user's keys
"""
return pulumi.get(self, "keys")
@property
@pulumi.getter(name="lastName")
def last_name(self) -> pulumi.Output[Optional[str]]:
"""
The user's last name
"""
return pulumi.get(self, "last_name")
@property
@pulumi.getter
def password(self) -> pulumi.Output[str]:
"""
The user's password
"""
return pulumi.get(self, "password")
@property
@pulumi.getter(name="userId")
def user_id(self) -> pulumi.Output[str]:
"""
The user id
"""
return pulumi.get(self, "user_id")
def translate_output_property(self, prop):
return _tables.CAMEL_TO_SNAKE_CASE_TABLE.get(prop) or prop
def translate_input_property(self, prop):
return _tables.SNAKE_TO_CAMEL_CASE_TABLE.get(prop) or prop
| 39.463519 | 134 | 0.613486 | 1,066 | 9,195 | 5.066604 | 0.136023 | 0.10998 | 0.0985 | 0.059989 | 0.617108 | 0.557675 | 0.529532 | 0.501018 | 0.475468 | 0.461026 | 0 | 0.00015 | 0.27689 | 9,195 | 232 | 135 | 39.633621 | 0.812152 | 0.25503 | 0 | 0.302158 | 1 | 0 | 0.107544 | 0.004428 | 0 | 0 | 0 | 0 | 0 | 1 | 0.107914 | false | 0.064748 | 0.05036 | 0.014388 | 0.266187 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
30b1e0908004387605a880b3d3e65a30296f4db0 | 4,789 | py | Python | FluentPython/sequence_hacking_hashing_slicing/vector.py | xu6148152/Binea_Python_Project | d943eb5f4685d08f080b372dcf1a7cbd5d63efed | [
"MIT"
] | null | null | null | FluentPython/sequence_hacking_hashing_slicing/vector.py | xu6148152/Binea_Python_Project | d943eb5f4685d08f080b372dcf1a7cbd5d63efed | [
"MIT"
] | null | null | null | FluentPython/sequence_hacking_hashing_slicing/vector.py | xu6148152/Binea_Python_Project | d943eb5f4685d08f080b372dcf1a7cbd5d63efed | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
# -*- encoding: utf-8 -*-
import numbers
import operator
from array import array
import reprlib
import math
import functools
import itertools
class Vector:
typecode = 'd'
def __init__(self, components):
self._components = array(self.typecode, components)
def __iter__(self):
return iter(self._components)
def __repr__(self):
components = reprlib.repr(self._components)
components = components[components.find('['):-1]
return 'Vector({})'.format(components)
def __str__(self):
return str(tuple(self))
def __bytes__(self):
return bytes([ord(self.typecode)]) + bytes(self._components)
def __eq__(self, other):
if isinstance(other, Vector):
return len(self) == len(other) and all(a == b for a, b in zip(self, other))
return NotImplemented
def __hash__(self):
hashes = map(hash, self._components)
return functools.reduce(operator.xor, hashes, 0)
def __abs__(self):
return math.sqrt(sum(x * x for x in self))
def __bool__(self):
return bool(abs(self))
def __len__(self):
return len(self._components)
def __getitem__(self, item):
cls = type(self)
if isinstance(item, slice):
return cls(self._components[item])
elif isinstance(item, numbers.Integral):
return self._components[item]
else:
msg = '{cls.__name__} indices must be integers'
raise TypeError(msg.format(cls=cls))
@classmethod
def frombytes(cls, octets):
typecode = chr(octets[0])
memv = memoryview(octets[1:]).cast(typecode)
return cls(memv)
shortcut_names = 'xyzt'
def __getattr__(self, name):
cls = type(self)
if len(name) == 1:
pos = cls.shortcut_names.find(name)
if 0 <= pos < len(self._components):
return self._components[pos]
msg = '{.__name__!r} object has no attribute {!r}'
raise AttributeError(msg.format(cls, name))
def __setattr__(self, name, value):
cls = type(self)
if len(name) == 1:
if name in cls.shortcut_names:
error = 'readonly attribute {attr_name!r}'
elif name.islower():
error = "can't set attributes 'a' to 'z' in {cls_name!r}"
else:
error = ''
if error:
msg = error.format(cls_name=cls.__name__, attr_name=name)
raise AttributeError(msg)
super().__setattr__(name, value)
def angle(self, n):
r = math.sqrt(sum(x * x for x in self[n:]))
a = math.atan2(r, self[n - 1])
if (n == len(self) - 1) and self[-1] < 0:
return math.pi * 2 - a
else:
return a
def angles(self):
return (self.angle(n) for n in range(1, len(self)))
def __format__(self, fmt_spec):
if fmt_spec.endswith('h'):
fmt_spec = fmt_spec[:-1]
coords = itertools.chain([abs(self), self.angles()])
outer_fmt = '<{}>'
else:
coords = self
outer_fmt = '({})'
components = (format(c, fmt_spec) for c in coords)
return outer_fmt.format(', '.join(components))
def __pos__(self):
return Vector(self)
def __add__(self, other):
try:
pairs = itertools.zip_longest(self, other, fillvalue=0.0)
return Vector(a + b for a, b in pairs)
except TypeError:
return NotImplemented
def __radd__(self, other):
return self + other
def __mul__(self, scalar):
if isinstance(scalar, numbers.Real):
return Vector(n * scalar for n in self)
return NotImplemented
def __rmul__(self, other):
return self * other
def __matmul__(self, other):
try:
return sum(a * b for a, b in zip(self, other))
except TypeError:
return NotImplemented
def __rmatmul__(self, other):
return self @ other
def __ne__(self, other):
eq_result = self == other
if eq_result is NotImplemented:
return NotImplemented
return not eq_result
def test_vector():
vector = Vector(range(10))
print(vector)
def test_vector_len():
vector = Vector(range(10))
print(len(vector))
print(vector[-1])
def test_vector_slice():
v7 = Vector(range(7))
print(v7[1:4])
print(v7[1, 2])
def test_vector_getattr():
v = Vector(range(5))
print(v.f)
def test_reduce():
print(functools.reduce(lambda a, b: a * b, range(1, 6)))
print(functools.reduce(operator.xor, range(6)))
if __name__ == '__main__':
test_reduce()
| 25.886486 | 87 | 0.577365 | 593 | 4,789 | 4.409781 | 0.252951 | 0.048184 | 0.022945 | 0.006883 | 0.131549 | 0.08413 | 0.049713 | 0.033652 | 0.033652 | 0 | 0 | 0.010798 | 0.303821 | 4,789 | 184 | 88 | 26.027174 | 0.773545 | 0.009397 | 0 | 0.147059 | 0 | 0 | 0.041122 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.220588 | false | 0 | 0.051471 | 0.080882 | 0.514706 | 0.058824 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
30b698a04928c9d0d6a7acb52ec5c668e5d79774 | 221 | py | Python | tools/yaml_config.py | brahim17/bud | 0cf3b37ca9e8e37c865c170d3b621ae6e0763672 | [
"Apache-2.0"
] | null | null | null | tools/yaml_config.py | brahim17/bud | 0cf3b37ca9e8e37c865c170d3b621ae6e0763672 | [
"Apache-2.0"
] | null | null | null | tools/yaml_config.py | brahim17/bud | 0cf3b37ca9e8e37c865c170d3b621ae6e0763672 | [
"Apache-2.0"
] | null | null | null | import confuse as cf
def configure():
config = cf.Configuration('bud', __name__)
config.set_file('./config.yaml')
return config
def get_path():
cfg = configure()
return str(cfg["directory_path"])
| 15.785714 | 46 | 0.660633 | 28 | 221 | 4.964286 | 0.678571 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.20362 | 221 | 13 | 47 | 17 | 0.789773 | 0 | 0 | 0 | 0 | 0 | 0.135747 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.125 | 0 | 0.625 | 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 | 0 | 0 | 0 | 0 | 2 |
30b774c404d4aa647c6f34fe917bdd0a3aba75cc | 151 | py | Python | supersql/constants/pg.py | rayattack/supersql | 0a592e7f303ac18b8df7bebac226b26f38f6d192 | [
"MIT"
] | 2 | 2019-11-04T00:19:30.000Z | 2020-10-04T01:24:04.000Z | supersql/constants/pg.py | tersoo/supersql | 4d20bd72a9de50e485ce79285c355a1a7ac04b55 | [
"MIT"
] | 2 | 2021-03-31T14:07:04.000Z | 2021-03-31T14:07:20.000Z | supersql/constants/pg.py | tersoo/supersql | 4d20bd72a9de50e485ce79285c355a1a7ac04b55 | [
"MIT"
] | 2 | 2021-03-30T21:40:14.000Z | 2022-03-17T20:52:25.000Z | POSTGRES_DATA_TYPES = {
"int2": "smallint",
"integer": "integer",
"uuid": "uuid",
"string": "varchar",
"timestamp": "timestamp",
}
| 18.875 | 29 | 0.556291 | 13 | 151 | 6.307692 | 0.769231 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008547 | 0.225166 | 151 | 7 | 30 | 21.571429 | 0.692308 | 0 | 0 | 0 | 0 | 0 | 0.430464 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
30ba7e16134a362402987db1362849a2eef289bd | 448 | py | Python | server/data/sql/services.py | Neoteroi/Torino | 9bac21735ed4e6bdaed6e8b20e2c6b33d76f938c | [
"MIT"
] | 7 | 2021-12-12T09:14:50.000Z | 2022-02-06T15:59:57.000Z | server/data/sql/services.py | Neoteroi/Torino | 9bac21735ed4e6bdaed6e8b20e2c6b33d76f938c | [
"MIT"
] | 5 | 2021-12-13T20:27:13.000Z | 2021-12-14T08:31:11.000Z | server/data/sql/services.py | Neoteroi/Torino | 9bac21735ed4e6bdaed6e8b20e2c6b33d76f938c | [
"MIT"
] | 1 | 2021-12-31T18:52:41.000Z | 2021-12-31T18:52:41.000Z | from rodi import Container
from domain.albums import AlbumsDataProvider
from domain.vfs import FileSystemDataProvider
from .albums import SQLAlbumsDataProvider
from .vfs import SQLFileSystemDataProvider
def register_sql_services(container: Container) -> None:
# services **MUST** be scoped here!
container.add_scoped(AlbumsDataProvider, SQLAlbumsDataProvider)
container.add_scoped(FileSystemDataProvider, SQLFileSystemDataProvider)
| 32 | 75 | 0.832589 | 44 | 448 | 8.386364 | 0.477273 | 0.054201 | 0.097561 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.113839 | 448 | 13 | 76 | 34.461538 | 0.929471 | 0.073661 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.625 | 0 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
30c4748f07e9270f04e320147d7d57f812021cf1 | 1,545 | py | Python | diabetes.py | aryanjalla/diebetesPredictor | 28539051f62eff8a3799392d0f35aa6794f8c4f6 | [
"MIT"
] | null | null | null | diabetes.py | aryanjalla/diebetesPredictor | 28539051f62eff8a3799392d0f35aa6794f8c4f6 | [
"MIT"
] | null | null | null | diabetes.py | aryanjalla/diebetesPredictor | 28539051f62eff8a3799392d0f35aa6794f8c4f6 | [
"MIT"
] | null | null | null | #lmaoo
import matplotlib.pyplot as plt
import pandas as pd
import pylab as pl
import numpy as np
import quandl
af = pd.read_csv('C://Users//Aryan Jalla//OneDrive//Documents//diabetes_csv.csv')
af.replace('tested_negative',0)
af.replace('tested_positive',1)
# af = pd.read_csv("C://Users//Aryan Jalla//OneDrive//Documents//DiabetesAtlasData.csv")
# df = quandl.get('ODA/IND_LP')
# df = af.iloc[::-1]
print(af.head())
# af.hist()
# plt.show()
# plt.scatter(cdf.FUELCONSUMPTION_COMB, cdf.CO2EMISSIONS, color='blue')
# plt.xlabel("FUELCONSUMPTION_COMB")
# plt.ylabel("Emission")
# plt.show()
# plt.scatter(cdf.ENGINESIZE, cdf.CO2EMISSIONS, color='blue')
# plt.xlabel("Engine size")
# plt.ylabel("Emission")
# plt.show()
# msk = np.random.rand(len(af)) < 0.8
# train = af[msk]
# test = af[~msk]
# # LInear regression wuhu
# from sklearn import linear_model
# pavan = linear_model.LinearRegression()
# x = np.asanyarray(train[['preg','plas','skin','insu','mass','pedi','age']])
# y = np.asanyarray(train[['CO2EMISSIONS']])
# pavan.fit (x, y)
# # The coefficients
# print ('Coefficients: ', pavan.coef_)
# y_hat= pavan.predict(test[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_COMB']])
# x = np.asanyarray(test[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_COMB']])
# y = np.asanyarray(test[['CO2EMISSIONS']])
# print("Residual sum of squares: %.2f"
# % np.mean((y_hat - y) ** 2))
# # Explained variance score: 1 is perfect prediction
# print('Variance score: %.2f' % pavan.score(x, y)) | 30.294118 | 90 | 0.664725 | 208 | 1,545 | 4.865385 | 0.471154 | 0.075099 | 0.01581 | 0.021739 | 0.315217 | 0.152174 | 0.086957 | 0.086957 | 0.086957 | 0.086957 | 0 | 0.009834 | 0.144337 | 1,545 | 51 | 91 | 30.294118 | 0.755673 | 0.744337 | 0 | 0 | 0 | 0 | 0.292605 | 0.141479 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.555556 | 0 | 0.555556 | 0.111111 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
30de6e562d96339a760e009e813fc707bb59b762 | 382 | py | Python | Computer science/Programming languages/Python/Basics/Builtins/Any and all/Heads or Tails/exercise.py | chanchanchong/PYTHON-TRACK-IN-HYPERSKILL | 462fe08ff4a2b183fd45a0235ab1ec7a788bd54c | [
"MIT"
] | null | null | null | Computer science/Programming languages/Python/Basics/Builtins/Any and all/Heads or Tails/exercise.py | chanchanchong/PYTHON-TRACK-IN-HYPERSKILL | 462fe08ff4a2b183fd45a0235ab1ec7a788bd54c | [
"MIT"
] | null | null | null | Computer science/Programming languages/Python/Basics/Builtins/Any and all/Heads or Tails/exercise.py | chanchanchong/PYTHON-TRACK-IN-HYPERSKILL | 462fe08ff4a2b183fd45a0235ab1ec7a788bd54c | [
"MIT"
] | null | null | null | # We have tossed a coin a 6 times and saved the results in a list
# called heads_or_tails. The values are integers: 1 stands for a
# head, while 0 denotes a tail.
# Add some code to find out whether the list has any heads. Do
# not print the variable check, just store the result in it.
# Fingers crossed
check = any(heads_or_tails)# are there any heads in the list heads_or_tails | 42.444444 | 75 | 0.759162 | 74 | 382 | 3.837838 | 0.662162 | 0.073944 | 0.126761 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009772 | 0.196335 | 382 | 9 | 75 | 42.444444 | 0.915309 | 0.887435 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
30e08cea449ab7acbd15ba544931ff2a1f5c9838 | 2,564 | py | Python | games/spiders/weaver.py | winkelmantanner/mmai20-dumbsophomores | bd2c88ea34cf9be83e2efd59abf2adf9a1a056fa | [
"MIT"
] | null | null | null | games/spiders/weaver.py | winkelmantanner/mmai20-dumbsophomores | bd2c88ea34cf9be83e2efd59abf2adf9a1a056fa | [
"MIT"
] | null | null | null | games/spiders/weaver.py | winkelmantanner/mmai20-dumbsophomores | bd2c88ea34cf9be83e2efd59abf2adf9a1a056fa | [
"MIT"
] | null | null | null | # Weaver: A Spiderling that can alter existing Webs by weaving to add or remove silk from the Webs, thus altering its strength.
# DO NOT MODIFY THIS FILE
# Never try to directly create an instance of this class, or modify its member variables.
# Instead, you should only be reading its variables and calling its functions.
from games.spiders.spiderling import Spiderling
# <<-- Creer-Merge: imports -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.
# you can add additional import(s) here
# <<-- /Creer-Merge: imports -->>
class Weaver(Spiderling):
"""The class representing the Weaver in the Spiders game.
A Spiderling that can alter existing Webs by weaving to add or remove silk from the Webs, thus altering its strength.
"""
def __init__(self):
"""Initializes a Weaver with basic logic as provided by the Creer code generator."""
Spiderling.__init__(self)
# private attributes to hold the properties so they appear read only
self._strengthening_web = None
self._weakening_web = None
@property
def strengthening_web(self):
"""The Web that this Weaver is strengthening. None if not strengthening.
:rtype: Web
"""
return self._strengthening_web
@property
def weakening_web(self):
"""The Web that this Weaver is weakening. None if not weakening.
:rtype: Web
"""
return self._weakening_web
def strengthen(self, web):
""" Weaves more silk into an existing Web to strengthen it.
Args:
web (Web): The web you want to strengthen. Must be connected to the Nest this Weaver is currently on.
Returns:
bool: True if the strengthen was successfully started, False otherwise.
"""
return self._run_on_server('strengthen', web=web)
def weaken(self, web):
""" Weaves more silk into an existing Web to strengthen it.
Args:
web (Web): The web you want to weaken. Must be connected to the Nest this Weaver is currently on.
Returns:
bool: True if the weaken was successfully started, False otherwise.
"""
return self._run_on_server('weaken', web=web)
# <<-- Creer-Merge: functions -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.
# if you want to add any client side logic (such as state checking functions) this is where you can add them
# <<-- /Creer-Merge: functions -->>
| 37.705882 | 135 | 0.673557 | 355 | 2,564 | 4.797183 | 0.346479 | 0.023488 | 0.028186 | 0.021139 | 0.472108 | 0.472108 | 0.472108 | 0.472108 | 0.438051 | 0.438051 | 0 | 0 | 0.25351 | 2,564 | 67 | 136 | 38.268657 | 0.88976 | 0.687988 | 0 | 0.125 | 0 | 0 | 0.025316 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3125 | false | 0 | 0.0625 | 0 | 0.6875 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
30eca20c9860c8c3a629db7ba642e1fd4d6af148 | 1,342 | py | Python | 2015/python/day25/chal49.py | astonshane/AdventOfCode | 25c7380e73eede3f79287de6a9dedc8314ab7965 | [
"MIT"
] | null | null | null | 2015/python/day25/chal49.py | astonshane/AdventOfCode | 25c7380e73eede3f79287de6a9dedc8314ab7965 | [
"MIT"
] | null | null | null | 2015/python/day25/chal49.py | astonshane/AdventOfCode | 25c7380e73eede3f79287de6a9dedc8314ab7965 | [
"MIT"
] | null | null | null | import sys
import re
'''
The voice on the other end of the phone continues with how the codes are actually generated. The first code is 20151125. After that, each code is generated by taking the previous one, multiplying it by 252533, and then keeping the remainder from dividing that value by 33554393.
'''
def increment(last_value):
inter = last_value * 252533
next_value = inter % 33554393
return next_value
def printPaper(paper):
print "#"*len(paper[0])
for line in paper:
print line
print "#"*len(paper[0]), "\n"
# ######################
if len(sys.argv) != 2:
print "need an input file"
exit(1)
f = open(sys.argv[1])
column = row = None
for line in f:
matchObj = re.match(r'To continue, please consult the code grid in the manual. Enter the code at row (\d*), column (\d*).', line, re.M | re.I)
row = int(matchObj.group(1)) - 1
column = int(matchObj.group(2)) - 1
value = None
paper = []
start = 20151125
paper.append([start])
last_value = start
while value is None:
paper.append([])
last_i = len(paper)-1
for i in range(last_i, -1, -1):
paper[i].append(increment(last_value))
j = len(paper[i])-1
last_value = paper[i][-1]
if row == i and column == j:
value = last_value
# printPaper(paper)
print "Value =", value
| 26.84 | 278 | 0.631893 | 208 | 1,342 | 4.028846 | 0.427885 | 0.064439 | 0.042959 | 0.033413 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.056311 | 0.232489 | 1,342 | 49 | 279 | 27.387755 | 0.757282 | 0.012668 | 0 | 0 | 1 | 0.028571 | 0.127345 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.057143 | null | null | 0.171429 | 0 | 0 | 0 | null | 0 | 0 | 0 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
30ed384d61ee1505b9dd584522cdaf7c6c1cf1ad | 671 | py | Python | tools/lib-alert-tree/metalk8s/__init__.py | SaintLoong/metalk8s | 06fa3a731f35ab0f9ad8d3443fd8f8c4e7037432 | [
"Apache-2.0"
] | 255 | 2018-08-03T17:32:53.000Z | 2022-03-25T21:51:00.000Z | tools/lib-alert-tree/metalk8s/__init__.py | SaintLoong/metalk8s | 06fa3a731f35ab0f9ad8d3443fd8f8c4e7037432 | [
"Apache-2.0"
] | 3,259 | 2018-08-03T00:25:56.000Z | 2022-03-31T15:23:11.000Z | tools/lib-alert-tree/metalk8s/__init__.py | SaintLoong/metalk8s | 06fa3a731f35ab0f9ad8d3443fd8f8c4e7037432 | [
"Apache-2.0"
] | 43 | 2018-08-08T01:47:22.000Z | 2022-03-12T17:49:41.000Z | """MetalK8s hierarchy of alerts."""
from lib_alert_tree.models import Relationship, severity_pair
from lib_alert_tree.prometheus import PrometheusRule
from .network import NETWORK_WARNING
from .nodes import NODE_WARNING, NODE_CRITICAL
from .platform import PLATFORM_WARNING, PLATFORM_CRITICAL
from .volumes import VOLUME_WARNING, VOLUME_CRITICAL
CLUSTER_WARNING, CLUSTER_CRITICAL = severity_pair(
name="Cluster",
summary_name="The cluster",
relationship=Relationship.ANY,
warning_children=[NETWORK_WARNING, NODE_WARNING, PLATFORM_WARNING, VOLUME_WARNING],
critical_children=[NODE_CRITICAL, PLATFORM_CRITICAL, VOLUME_CRITICAL],
duration="1m",
)
| 35.315789 | 87 | 0.813711 | 81 | 671 | 6.432099 | 0.382716 | 0.026871 | 0.046065 | 0.06142 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003361 | 0.113264 | 671 | 18 | 88 | 37.277778 | 0.872269 | 0.043219 | 0 | 0 | 0 | 0 | 0.031447 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.428571 | 0 | 0.428571 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
30ff2fcf277abf68844c22c82923de4130bde4b7 | 11,978 | py | Python | a10sdk/core/vpn/vpn_ipsec.py | deepfield/a10sdk-python | bfaa58099f51f085d5e91652d1d1a3fd5c529d5d | [
"Apache-2.0"
] | 16 | 2015-05-20T07:26:30.000Z | 2021-01-23T11:56:57.000Z | a10sdk/core/vpn/vpn_ipsec.py | deepfield/a10sdk-python | bfaa58099f51f085d5e91652d1d1a3fd5c529d5d | [
"Apache-2.0"
] | 6 | 2015-03-24T22:07:11.000Z | 2017-03-28T21:31:18.000Z | a10sdk/core/vpn/vpn_ipsec.py | deepfield/a10sdk-python | bfaa58099f51f085d5e91652d1d1a3fd5c529d5d | [
"Apache-2.0"
] | 23 | 2015-03-29T15:43:01.000Z | 2021-06-02T17:12:01.000Z | from a10sdk.common.A10BaseClass import A10BaseClass
class Bind(A10BaseClass):
"""This class does not support CRUD Operations please use parent.
:param tunnel: {"description": "Tunnel interface index", "format": "number", "maximum": 128, "minimum": 1, "type": "number", "$ref": "/axapi/v3/interface/tunnel"}
:param next_hop: {"type": "string", "description": "IPsec Next Hop IP Address", "format": "ipv4-address"}
:param DeviceProxy: The device proxy for REST operations and session handling. Refer to `common/device_proxy.py`
"""
def __init__(self, **kwargs):
self.ERROR_MSG = ""
self.b_key = "bind"
self.DeviceProxy = ""
self.tunnel = ""
self.next_hop = ""
for keys, value in kwargs.items():
setattr(self,keys, value)
class SamplingEnable(A10BaseClass):
"""This class does not support CRUD Operations please use parent.
:param counters1: {"enum": ["all", "packets-encrypted", "packets-decrypted", "anti-replay-num", "rekey-num", "packets-err-inactive", "packets-err-encryption", "packets-err-pad-check", "packets-err-pkt-sanity", "packets-err-icv-check", "packets-err-badspi", "packets-err-lifetime-lifebytes", "bytes-encrypted", "bytes-decrypted", "prefrag-success", "prefrag-error", "frags-created", "frags-reassembled", "cavium-err-enc", "cavium-err-dec"], "type": "string", "description": "'all': all; 'packets-encrypted': packets-encrypted; 'packets-decrypted': packets-decrypted; 'anti-replay-num': anti-replay-num; 'rekey-num': rekey-num; 'packets-err-inactive': packets-err-inactive; 'packets-err-encryption': packets-err-encryption; 'packets-err-pad-check': packets-err-pad-check; 'packets-err-pkt-sanity': packets-err-pkt-sanity; 'packets-err-icv-check': packets-err-icv-check; 'packets-err-badspi': packets-err-badspi; 'packets-err-lifetime-lifebytes': packets-err-lifetime-lifebytes; 'bytes-encrypted': bytes-encrypted; 'bytes-decrypted': bytes-decrypted; 'prefrag-success': prefrag-success; 'prefrag-error': prefrag-error; 'frags-created': frags-created; 'frags-reassembled': frags-reassembled; 'cavium-err-enc': cavium-err-enc; 'cavium-err-dec': cavium-err-dec; ", "format": "enum"}
:param DeviceProxy: The device proxy for REST operations and session handling. Refer to `common/device_proxy.py`
"""
def __init__(self, **kwargs):
self.ERROR_MSG = ""
self.b_key = "sampling-enable"
self.DeviceProxy = ""
self.counters1 = ""
for keys, value in kwargs.items():
setattr(self,keys, value)
class Ipv4(A10BaseClass):
"""This class does not support CRUD Operations please use parent.
:param remote: {"type": "string", "description": "IPv4 Address", "format": "ipv4-address"}
:param local_protocol: {"description": "IP Protocol Number (0-255)", "minimum": 0, "type": "number", "maximum": 255, "format": "number"}
:param local_port: {"description": "Port Number", "minimum": 0, "type": "number", "maximum": 65535, "format": "number"}
:param remote_port: {"description": "Port Number", "minimum": 0, "type": "number", "maximum": 65535, "format": "number"}
:param local_netmask: {"type": "string", "description": "IPv4 Address Network Mask", "format": "ipv4-netmask"}
:param remote_netmask: {"type": "string", "description": "IPv4 Address Network Mask", "format": "ipv4-netmask"}
:param remote_protocol: {"description": "IP Protocol Number (0-255)", "minimum": 0, "type": "number", "maximum": 255, "format": "number"}
:param local: {"type": "string", "description": "Local Traffic Selector", "format": "ipv4-address"}
:param DeviceProxy: The device proxy for REST operations and session handling. Refer to `common/device_proxy.py`
"""
def __init__(self, **kwargs):
self.ERROR_MSG = ""
self.b_key = "ipv4"
self.DeviceProxy = ""
self.remote = ""
self.local_protocol = ""
self.local_port = ""
self.remote_port = ""
self.local_netmask = ""
self.remote_netmask = ""
self.remote_protocol = ""
self.local = ""
for keys, value in kwargs.items():
setattr(self,keys, value)
class TrafficSelector(A10BaseClass):
"""This class does not support CRUD Operations please use parent.
:param DeviceProxy: The device proxy for REST operations and session handling. Refer to `common/device_proxy.py`
"""
def __init__(self, **kwargs):
self.ERROR_MSG = ""
self.b_key = "traffic-selector"
self.DeviceProxy = ""
self.ipv4 = {}
for keys, value in kwargs.items():
setattr(self,keys, value)
class EncCfg(A10BaseClass):
"""This class does not support CRUD Operations please use parent.
:param priority: {"description": "Prioritizes (1-10) security protocol, least value has highest priority", "format": "number", "default": 5, "maximum": 10, "minimum": 1, "type": "number"}
:param encryption: {"enum": ["des", "3des", "aes-128", "aes-192", "aes-256", "null"], "type": "string", "description": "'des': Data Encryption Standard algorithm; '3des': Triple Data Encryption Standard algorithm; 'aes-128': Advanced Encryption Standard algorithm (key size: 128 bits); 'aes-192': Advanced Encryption Standard algorithm (key size: 192 bits); 'aes-256': Advanced Encryption Standard algorithm (key size: 256 bits); 'null': No encryption algorithm; ", "format": "enum"}
:param hash: {"enum": ["md5", "sha1", "sha256", "null"], "type": "string", "description": "'md5': MD5 Dessage-Digest Algorithm; 'sha1': Secure Hash Algorithm 1; 'sha256': Secure Hash Algorithm 256; 'null': No hash algorithm; ", "format": "enum"}
:param DeviceProxy: The device proxy for REST operations and session handling. Refer to `common/device_proxy.py`
"""
def __init__(self, **kwargs):
self.ERROR_MSG = ""
self.b_key = "enc-cfg"
self.DeviceProxy = ""
self.priority = ""
self.encryption = ""
self.A10WW_hash = ""
for keys, value in kwargs.items():
setattr(self,keys, value)
class Ipsec(A10BaseClass):
"""Class Description::
IPsec settings.
Class ipsec supports CRUD Operations and inherits from `common/A10BaseClass`.
This class is the `"PARENT"` class for this module.`
:param lifebytes: {"description": "IPsec SA age in megabytes", "format": "number", "default": 0, "optional": true, "maximum": 8000000, "minimum": 0, "type": "number"}
:param ike_gateway: {"description": "Gateway to use for IPsec SA", "format": "string", "minLength": 1, "optional": true, "maxLength": 31, "type": "string", "$ref": "/axapi/v3/vpn/ike-gateway"}
:param name: {"description": "IPsec name", "format": "string", "minLength": 1, "optional": false, "maxLength": 31, "type": "string"}
:param dh_group: {"optional": true, "enum": ["0", "1", "2", "5", "14", "15", "16", "18"], "type": "string", "description": "'0': Diffie-Hellman group 0 (Default); '1': Diffie-Hellman group 1; '2': Diffie-Hellman group 2; '5': Diffie-Hellman group 5; '14': Diffie-Hellman group 14; '15': Diffie-Hellman group 15; '16': Diffie-Hellman group 16; '18': Diffie-Hellman group 18; ", "format": "enum"}
:param proto: {"description": "'esp': Encapsulating security protocol (Default); ", "format": "enum", "default": "esp", "type": "string", "enum": ["esp"], "optional": true}
:param up: {"default": 0, "optional": true, "type": "number", "description": "Initiates SA negotiation to bring the IPsec connection up", "format": "flag"}
:param anti_replay_window: {"optional": true, "enum": ["0", "16", "32", "64", "128", "256"], "type": "string", "description": "'0': Disable Anti-Replay Window Check; '16': Window Size of 16 bits; '32': Window Size of 32 bits; '64': Window Size of 64 bits; '128': Window Size of 128 bits; '256': Window Size of 256 bits; ", "format": "enum"}
:param sampling_enable: {"minItems": 1, "items": {"type": "object"}, "uniqueItems": true, "type": "array", "array": [{"properties": {"optional": true, "counters1": {"enum": ["all", "packets-encrypted", "packets-decrypted", "anti-replay-num", "rekey-num", "packets-err-inactive", "packets-err-encryption", "packets-err-pad-check", "packets-err-pkt-sanity", "packets-err-icv-check", "packets-err-badspi", "packets-err-lifetime-lifebytes", "bytes-encrypted", "bytes-decrypted", "prefrag-success", "prefrag-error", "frags-created", "frags-reassembled", "cavium-err-enc", "cavium-err-dec"], "type": "string", "description": "'all': all; 'packets-encrypted': packets-encrypted; 'packets-decrypted': packets-decrypted; 'anti-replay-num': anti-replay-num; 'rekey-num': rekey-num; 'packets-err-inactive': packets-err-inactive; 'packets-err-encryption': packets-err-encryption; 'packets-err-pad-check': packets-err-pad-check; 'packets-err-pkt-sanity': packets-err-pkt-sanity; 'packets-err-icv-check': packets-err-icv-check; 'packets-err-badspi': packets-err-badspi; 'packets-err-lifetime-lifebytes': packets-err-lifetime-lifebytes; 'bytes-encrypted': bytes-encrypted; 'bytes-decrypted': bytes-decrypted; 'prefrag-success': prefrag-success; 'prefrag-error': prefrag-error; 'frags-created': frags-created; 'frags-reassembled': frags-reassembled; 'cavium-err-enc': cavium-err-enc; 'cavium-err-dec': cavium-err-dec; ", "format": "enum"}}}]}
:param mode: {"description": "'tunnel': Encapsulating the packet in IPsec tunnel mode (Default); ", "format": "enum", "default": "tunnel", "type": "string", "enum": ["tunnel"], "optional": true}
:param lifetime: {"description": "IPsec SA age in seconds", "format": "number", "default": 28800, "optional": true, "maximum": 28800, "minimum": 30, "type": "number"}
:param enc_cfg: {"minItems": 1, "items": {"type": "object"}, "uniqueItems": true, "type": "array", "array": [{"properties": {"priority": {"description": "Prioritizes (1-10) security protocol, least value has highest priority", "format": "number", "default": 5, "maximum": 10, "minimum": 1, "type": "number"}, "encryption": {"enum": ["des", "3des", "aes-128", "aes-192", "aes-256", "null"], "type": "string", "description": "'des': Data Encryption Standard algorithm; '3des': Triple Data Encryption Standard algorithm; 'aes-128': Advanced Encryption Standard algorithm (key size: 128 bits); 'aes-192': Advanced Encryption Standard algorithm (key size: 192 bits); 'aes-256': Advanced Encryption Standard algorithm (key size: 256 bits); 'null': No encryption algorithm; ", "format": "enum"}, "hash": {"enum": ["md5", "sha1", "sha256", "null"], "type": "string", "description": "'md5': MD5 Dessage-Digest Algorithm; 'sha1': Secure Hash Algorithm 1; 'sha256': Secure Hash Algorithm 256; 'null': No hash algorithm; ", "format": "enum"}, "optional": true}}]}
:param uuid: {"description": "uuid of the object", "format": "string", "minLength": 1, "modify-not-allowed": 1, "optional": true, "maxLength": 64, "type": "string"}
:param DeviceProxy: The device proxy for REST operations and session handling. Refer to `common/device_proxy.py`
URL for this object::
`https://<Hostname|Ip address>//axapi/v3/vpn/ipsec/{name}`.
"""
def __init__(self, **kwargs):
self.ERROR_MSG = ""
self.required = [ "name"]
self.b_key = "ipsec"
self.a10_url="/axapi/v3/vpn/ipsec/{name}"
self.DeviceProxy = ""
self.lifebytes = ""
self.ike_gateway = ""
self.name = ""
self.dh_group = ""
self.proto = ""
self.bind = {}
self.up = ""
self.anti_replay_window = ""
self.sampling_enable = []
self.traffic_selector = {}
self.mode = ""
self.lifetime = ""
self.enc_cfg = []
self.uuid = ""
for keys, value in kwargs.items():
setattr(self,keys, value)
| 63.042105 | 1,430 | 0.646519 | 1,449 | 11,978 | 5.295376 | 0.139406 | 0.054737 | 0.035579 | 0.019549 | 0.698423 | 0.671706 | 0.671706 | 0.671706 | 0.667405 | 0.667405 | 0 | 0.028675 | 0.173151 | 11,978 | 189 | 1,431 | 63.375661 | 0.746062 | 0.768826 | 0 | 0.405405 | 0 | 0 | 0.032635 | 0.010475 | 0 | 0 | 0 | 0 | 0 | 1 | 0.081081 | false | 0 | 0.013514 | 0 | 0.175676 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
a50344fb7ee14256b74c2a6d8f9183e4ffb0b760 | 5,954 | py | Python | commons_static.py | d7d4af8/2047 | bd6781b9502c6fdbd4745be5084977f679fa3fc5 | [
"MIT"
] | 35 | 2020-09-01T00:34:50.000Z | 2022-03-29T13:14:15.000Z | commons_static.py | d7d4af8/2047 | bd6781b9502c6fdbd4745be5084977f679fa3fc5 | [
"MIT"
] | 3 | 2020-08-19T20:47:19.000Z | 2021-09-06T23:55:49.000Z | commons_static.py | d7d4af8/2047 | bd6781b9502c6fdbd4745be5084977f679fa3fc5 | [
"MIT"
] | 10 | 2020-08-07T02:20:09.000Z | 2022-01-30T06:43:45.000Z | import os, hashlib, binascii as ba
import base64, re
import time, math
from colors import *
# from functools import lru_cache
from numba import jit
from cachetools.func import *
from cachy import *
def iif(a,b,c):return b if a else c
import json
def obj2json(obj):
return json.dumps(obj, ensure_ascii=False, sort_keys=True, indent=2)
@stale_cache(ttr=1, ttl=30)
def readfile(fn, mode='rb', *a, **kw):
if 'b' not in mode:
with open(fn, mode, encoding='utf8', *a, **kw) as f:
return f.read()
else:
with open(fn, mode, *a, **kw) as f:
return f.read()
def writefile(fn, data, mode='wb', encoding='utf8', *a, **kw):
if 'b' not in mode:
with open(fn,mode, encoding=encoding, *a,**kw) as f:
f.write(data)
else:
with open(fn,mode,*a,**kw) as f:
f.write(data)
def removefile(fn):
try:
os.remove(fn)
except Exception as e:
print_err(e)
print_err('failed to remove', fn)
else:
return
import threading
def dispatch(f):
return tpe.submit(f)
# t = AppContextThreadMod(target=f, daemon=True)
# # t = threading.Thread(target=f, daemon=True)
# t.start()
def dispatch_with_retries(f):
n = 0
def wrapper():
nonlocal n
while 1:
try:
f()
except Exception as e:
print_err(e)
n+=1
time.sleep(0.5)
print_up(f'{f.__name__}() retry #{n}')
else:
print_down(f'{f.__name__}() success on attempt #{n}')
break
return tpe.submit(wrapper)
def init_directory(d):
try:
os.mkdir(d)
except FileExistsError as e:
print_err('directory {} already exists.'.format(d), e)
else:
print_info('directory {} created.'.format(d))
def key(d, k):
if k in d:
return d[k]
else:
return None
def intify(s, name=''):
try:
return int(s)
except:
if s:
# print_err('intifys',s,name)
pass
return 0
def floatify(s):
try:
return float(s)
except:
if s:
pass
return 0.
def get_environ(k):
k = k.upper()
if k in os.environ:
return os.environ[k]
else:
return None
def clip(a,b):
def _clip(c):
return min(b,max(a, c))
return _clip
clip01 = clip(0,1)
import zlib
def calculate_checksum(bin): return zlib.adler32(bin).to_bytes(4,'big')
def calculate_checksum_base64(bin):
csum = calculate_checksum(bin)
chksum_encoded = base64.b64encode(csum).decode('ascii')
return chksum_encoded
def calculate_checksum_base64_replaced(bin):
return calculate_checksum_base64(bin).replace('+','-').replace('/','_')
def calculate_etag(bin):
return calculate_checksum_base64_replaced(bin)
# pw hashing
def bytes2hexstr(b):
return ba.b2a_hex(b).decode('ascii')
def hexstr2bytes(h):
return ba.a2b_hex(h.encode('ascii'))
# https://nitratine.net/blog/post/how-to-hash-passwords-in-python/
def get_salt():
return os.urandom(32)
def get_random_hex_string(b=8):
return base64.b16encode(os.urandom(b)).decode('ascii')
def hash_pw(salt, string):
return hashlib.pbkdf2_hmac(
'sha256',
string.encode('ascii'),
salt,
100000,
)
# input string, output hash and salt
def hash_w_salt(string):
salt = get_salt()
hash = hash_pw(salt, string)
return bytes2hexstr(hash), bytes2hexstr(salt)
# input hash,salt,string, output comparison result
def check_hash_salt_pw(hashstr, saltstr, string):
chash = hash_pw(hexstr2bytes(saltstr), string)
return chash == hexstr2bytes(hashstr)
def timethis(stmt):
import re, timeit
print('timing', stmt)
broken = re.findall(f'\$([a-zA-Z][0-9a-zA-Z_\-]*)', stmt)
stmt = stmt.replace('$','')
setup = f"from __main__ import {','.join(broken)}"
exec(setup) # preheat
exec(stmt)
timeit.Timer(stmt,
setup=setup
).autorange(
lambda a,b:print(f'{a} in {b:.4f}, avg: {b/a*1000_000:.4f}us'))
# if __name__ == '__main__':
# k = time.time()
# def hello():
# if time.time() - k < 2:
# raise Exception('nah')
#
# dispatch_with_retries(hello)
# time.sleep(4)
if __name__ == '__main__':
toenc = b"r12uf-398gy309ghh123r1"*100000
timethis('calculate_checksum_base64_replaced(toenc)')
# everything time related
import datetime
dtdt = datetime.datetime
dtt = datetime.time
dtd = datetime.date
dtn = dtdt.now
dttz = datetime.timezone
dttd = datetime.timedelta
# default time parsing
def dtdt_from_stamp(stamp):
return dtdt.fromisoformat(stamp)
dfs = dtdt_from_stamp
def dfshk(stamp):
return dfs(stamp).replace(tzinfo=working_timezone)
# proper time formatting
# input: string iso timestamp
# output: string formatted time
def format_time(dtdt,s):
return dtdt.strftime(s)
# default time formatting
def format_time_iso(dtdt):
return dtdt.isoformat(timespec='seconds')[:19]
fti = format_time_iso
format_time_datetime = lambda s: format_time(dfs(s), '%Y-%m-%d %H:%M')
format_time_datetime_second = lambda s: format_time(dfs(s), '%Y-%m-%d %H:%M:%S')
format_time_dateonly = lambda s: format_time(dfs(s), '%Y-%m-%d')
format_time_timeonly = lambda s: format_time(dfs(s), '%H:%M')
def days_since(ts):
then = dfshk(ts)
now = dtn(working_timezone)
dt = now - then
return dt.days
def days_between(ts0, ts1):
return abs(days_since(ts0) - days_since(ts1))
def seconds_since(ts):
then = dfshk(ts)
now = dtn(working_timezone)
dt = now - then
return dt.total_seconds()
def cap(x, mi, ma):
return min(max(x, mi),ma)
working_timezone = dttz(dttd(hours=+8)) # Hong Kong
gmt_timezone = dttz(dttd(hours=0)) # GMT
def time_iso_now(dt=0): # dt in seconds
return format_time_iso(dtn(working_timezone) + dttd(seconds=dt))
| 23.440945 | 80 | 0.624958 | 852 | 5,954 | 4.221831 | 0.308685 | 0.033361 | 0.031971 | 0.015569 | 0.183764 | 0.122046 | 0.116208 | 0.086183 | 0.086183 | 0.066166 | 0 | 0.022522 | 0.239335 | 5,954 | 253 | 81 | 23.533597 | 0.771694 | 0.115721 | 0 | 0.215909 | 0 | 0.005682 | 0.07945 | 0.017189 | 0 | 0 | 0 | 0 | 0 | 1 | 0.204545 | false | 0.011364 | 0.073864 | 0.107955 | 0.477273 | 0.051136 | 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 | 0 | 1 | 0 | 0 | 0 | 2 |
eb4e59d1e7d292a293ad5cb2f9ad4a937399a8be | 377 | py | Python | masq/cms/api/player.py | tehdiplomat/hidden-role-games | e6fdc132700db8d12fd57f08200a499cdc5bef7d | [
"MIT"
] | null | null | null | masq/cms/api/player.py | tehdiplomat/hidden-role-games | e6fdc132700db8d12fd57f08200a499cdc5bef7d | [
"MIT"
] | null | null | null | masq/cms/api/player.py | tehdiplomat/hidden-role-games | e6fdc132700db8d12fd57f08200a499cdc5bef7d | [
"MIT"
] | null | null | null | from rest_framework import generics
from rest_framework import permissions
from cms.models.Player import Player, PlayerSerializer
class PlayerList(generics.ListCreateAPIView):
queryset = Player.objects.all()
serializer_class = PlayerSerializer
class PlayerDetail(generics.RetrieveUpdateDestroyAPIView):
queryset = Player.objects.all()
serializer_class = PlayerSerializer | 31.416667 | 58 | 0.846154 | 39 | 377 | 8.076923 | 0.487179 | 0.050794 | 0.107937 | 0.146032 | 0.349206 | 0.349206 | 0.349206 | 0 | 0 | 0 | 0 | 0 | 0.092838 | 377 | 12 | 59 | 31.416667 | 0.921053 | 0 | 0 | 0.444444 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
eb692e4110e4ef0e669c0d2da4924f938f9a1bf7 | 131 | py | Python | Meus_dessafios/Exercicios2021/ex049.py | DiegoSilvaHoffmann/Curso-de-Python | 62824bbd3ed42b256fda77acd49536ec7cf23b29 | [
"MIT"
] | null | null | null | Meus_dessafios/Exercicios2021/ex049.py | DiegoSilvaHoffmann/Curso-de-Python | 62824bbd3ed42b256fda77acd49536ec7cf23b29 | [
"MIT"
] | null | null | null | Meus_dessafios/Exercicios2021/ex049.py | DiegoSilvaHoffmann/Curso-de-Python | 62824bbd3ed42b256fda77acd49536ec7cf23b29 | [
"MIT"
] | null | null | null | n = int(input('Qual numero voce quer saber a tabuada? '))
for t in range(1, 11):
print('{} X {:2} = {}'.format(n, t, (n * t)))
| 32.75 | 57 | 0.541985 | 24 | 131 | 2.958333 | 0.833333 | 0.056338 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.038835 | 0.21374 | 131 | 3 | 58 | 43.666667 | 0.650485 | 0 | 0 | 0 | 0 | 0 | 0.40458 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
eb79b40becdf00ebe271dc98a573c69abffc8026 | 946 | py | Python | katana/compound.py | eugene-eeo/katana | a95499786c39b93edbcc1987340bcf4b9069b100 | [
"MIT"
] | null | null | null | katana/compound.py | eugene-eeo/katana | a95499786c39b93edbcc1987340bcf4b9069b100 | [
"MIT"
] | null | null | null | katana/compound.py | eugene-eeo/katana | a95499786c39b93edbcc1987340bcf4b9069b100 | [
"MIT"
] | null | null | null | from katana.utils import Node, Pair, prepare
from katana.term import null
def sequence(*terms):
def fn(pair):
for each in terms:
pair = each(pair)
return pair
return fn
def group(expr):
def fn(pair):
# we use an empty pair to 'capture' the nodes
# produced by the grouped exprs.
p2 = prepare(pair.tail)
p2 = expr(p2)
node = Node(fn, p2.nodes)
return Pair(pair.nodes + [node], p2.tail)
return fn
def repeat(expr):
def fn(pair):
while 1:
try:
pair = expr(pair)
except ValueError:
break
return pair
return fn
def option(*choices):
def fn(pair):
for item in choices:
try:
return item(pair)
except ValueError:
pass
raise ValueError
return fn
def maybe(expr):
return option(expr, null)
| 19.708333 | 53 | 0.530655 | 117 | 946 | 4.290598 | 0.393162 | 0.039841 | 0.071713 | 0.047809 | 0.083665 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010381 | 0.389006 | 946 | 47 | 54 | 20.12766 | 0.858131 | 0.078224 | 0 | 0.4 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.257143 | false | 0.028571 | 0.057143 | 0.028571 | 0.571429 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
eb7ce3c241bbd8d84f52fc55688d7c71cbb1bc35 | 1,074 | py | Python | Day 4/Puzzle 2.py | rookuu/AdventOfCode-2015 | b94e98f5711d0901412b22342395457a8185bc10 | [
"MIT"
] | null | null | null | Day 4/Puzzle 2.py | rookuu/AdventOfCode-2015 | b94e98f5711d0901412b22342395457a8185bc10 | [
"MIT"
] | null | null | null | Day 4/Puzzle 2.py | rookuu/AdventOfCode-2015 | b94e98f5711d0901412b22342395457a8185bc10 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
"""
Solution to Day 4 - Puzzle 2 of the Advent Of Code 2015 series of challenges.
--- Day 4: The Ideal Stocking Stuffer ---
Solution must generate sequences of MD5 Hashes in Hex, using the conjugation of a secret key (given in the puzzle) and
a number. The goal is to find the lowest number than generates a hash with 5 leading zeros.
--- Part Two ---
Now find one that starts with six zeroes.
-----------------------------------------
Author: Luke "rookuu" Roberts
"""
import hashlib
secretKey = "ckczppom" # Puzzle Input!
number = -1
# I want this to potentially run infinitely until it finds the solution, however it would probably be more elegant to
# just define a max value, but for completeness let's do it this way.
while True:
number += 1
hashedCode = hashlib.md5(secretKey + str(number)).hexdigest()
if hashedCode[0:6] == "000000": # 6 Zeros!
print "The lowest number that generates a hash with 6 leading 0s is " + str(number) + ", with the hash '" + \
str(hashedCode) + "'"
break
| 25.571429 | 118 | 0.659218 | 159 | 1,074 | 4.45283 | 0.641509 | 0.011299 | 0.042373 | 0.050847 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.027446 | 0.219739 | 1,074 | 41 | 119 | 26.195122 | 0.817422 | 0.212291 | 0 | 0 | 1 | 0 | 0.259053 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.1 | null | null | 0.1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
eb8e025e5893358354a8291dfa1959b4b35d1f72 | 1,055 | py | Python | tests/test_password_requirements.py | gitter-badger/passwd | 4dc3be61ae578a0ddab22744784c30bbaf4a69d9 | [
"MIT"
] | null | null | null | tests/test_password_requirements.py | gitter-badger/passwd | 4dc3be61ae578a0ddab22744784c30bbaf4a69d9 | [
"MIT"
] | null | null | null | tests/test_password_requirements.py | gitter-badger/passwd | 4dc3be61ae578a0ddab22744784c30bbaf4a69d9 | [
"MIT"
] | null | null | null | from passwd import PasswordRequirements
def test_min_length():
length_8 = PasswordRequirements(min_length=8)
assert length_8.check("abcd1234")
assert not length_8.check("abc123")
# No minimum characters requirement if not specified
assert PasswordRequirements().check("abc123")
def test_min_digits():
digits_2 = PasswordRequirements(min_digits=2)
assert not digits_2.check("abc")
assert not digits_2.check("abc1")
assert digits_2.check("abc12")
assert digits_2.check("abc123")
def test_special_characters():
special_1 = PasswordRequirements(min_special=1)
assert special_1.check("abc$")
assert special_1.check("abc$%^@*")
assert not special_1.check("abc")
assert not special_1.check("abc123")
def test_combinations():
length_6_digits_3 = PasswordRequirements(min_length=6, min_digits=3)
assert length_6_digits_3.check("abc123")
assert not length_6_digits_3.check("ab123")
assert not length_6_digits_3.check("abcd12")
assert not length_6_digits_3.check("ab12")
| 25.731707 | 72 | 0.734597 | 145 | 1,055 | 5.068966 | 0.227586 | 0.097959 | 0.088435 | 0.095238 | 0.321088 | 0.238095 | 0.2 | 0.085714 | 0.085714 | 0 | 0 | 0.064117 | 0.157346 | 1,055 | 40 | 73 | 26.375 | 0.762655 | 0.047393 | 0 | 0 | 0 | 0 | 0.079761 | 0 | 0 | 0 | 0 | 0 | 0.625 | 1 | 0.166667 | false | 0.25 | 0.041667 | 0 | 0.208333 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
eb93180d23d186f1e37210d412a68f4ac775f24a | 252 | py | Python | apps/follow_system/admin.py | coogger/coogger | 9e5e3ca172d8a14272948284a6822000b119119c | [
"MIT"
] | 48 | 2018-04-13T13:00:10.000Z | 2020-03-17T23:35:23.000Z | apps/follow_system/admin.py | coogger/coogger | 9e5e3ca172d8a14272948284a6822000b119119c | [
"MIT"
] | 77 | 2018-03-25T13:17:12.000Z | 2020-08-11T08:24:49.000Z | apps/follow_system/admin.py | coogger/coogger | 9e5e3ca172d8a14272948284a6822000b119119c | [
"MIT"
] | 35 | 2018-03-30T21:43:21.000Z | 2020-08-11T05:51:46.000Z | from django.contrib.admin import ModelAdmin, site
from .models import Follow
class FollowAdmin(ModelAdmin):
list_display = ["user"]
list_display_links = list_display
filter_horizontal = ["following"]
site.register(Follow, FollowAdmin)
| 19.384615 | 49 | 0.757937 | 29 | 252 | 6.413793 | 0.655172 | 0.177419 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.154762 | 252 | 12 | 50 | 21 | 0.873239 | 0 | 0 | 0 | 0 | 0 | 0.051587 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.285714 | 0 | 0.857143 | 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 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
eb95f1ab87d04cd0574e1b11b3c44d0c9592d55b | 2,069 | py | Python | pycspr/factory/state.py | MrKrautee/casper-python-sdk | 13e9da83de8892583da7ada91e4231e6f85e5e13 | [
"Apache-2.0"
] | 2 | 2021-10-05T07:50:20.000Z | 2021-10-06T09:58:19.000Z | pycspr/factory/state.py | MrKrautee/casper-python-sdk | 13e9da83de8892583da7ada91e4231e6f85e5e13 | [
"Apache-2.0"
] | null | null | null | pycspr/factory/state.py | MrKrautee/casper-python-sdk | 13e9da83de8892583da7ada91e4231e6f85e5e13 | [
"Apache-2.0"
] | null | null | null | from pycspr.types import CLAccessRights
from pycspr.types import UnforgeableReference
from pycspr.types import DictionaryIdentifier_AccountNamedKey
from pycspr.types import DictionaryIdentifier_ContractNamedKey
from pycspr.types import DictionaryIdentifier_SeedURef
from pycspr.types import DictionaryIdentifier_UniqueKey
def create_uref_from_string(as_string: str):
"""Returns an unforgeable reference from it's string representation.
"""
_, address_hex, access_rights = as_string.split("-")
return UnforgeableReference(bytes.fromhex(address_hex),
CLAccessRights(int(access_rights)))
# @TODO: naming! suggestion-> get_account_named_key
def create_dictionary_identifier_for_an_account_named_key(
name: str,
item_key: str,
key: str
) -> DictionaryIdentifier_AccountNamedKey:
"""Returns a dictionary item identifier for querying an account's
associated state.
"""
return DictionaryIdentifier_AccountNamedKey(
dictionary_item_key=item_key,
dictionary_name=name,
key=key,
)
# @TODO: naming! suggestion-> get_contract_named_key
def create_dictionary_identifier_for_a_contract_named_key(
) -> DictionaryIdentifier_ContractNamedKey:
"""Returns a dictionary item identifier for querying a contract's
associated state.
"""
# @TODO: key not defined!
# return DictionaryIdentifier_ContractNamedKey(key=key)
pass
# @TODO: naming! suggestion-> get_seed_uref
def create_dictionary_identifier_for_a_seed_uref(
) -> DictionaryIdentifier_SeedURef:
"""Returns a dictionary item identifier for querying a uref's
associated state.
"""
# @TODO: key not defined!
# return DictionaryIdentifier_SeedURef(key=key)
pass
# @TODO: naming! suggestion-> get_id_for_unique_key
def create_dictionary_identifier_for_a_unique_key(
key: str
) -> DictionaryIdentifier_UniqueKey:
"""Returns a dictionary item identifier for querying a uref's
associated state.
"""
return DictionaryIdentifier_UniqueKey(key=key)
| 32.328125 | 72 | 0.754954 | 233 | 2,069 | 6.424893 | 0.240343 | 0.069472 | 0.06012 | 0.084168 | 0.511022 | 0.356045 | 0.334001 | 0.183033 | 0.153641 | 0.085504 | 0 | 0 | 0.17448 | 2,069 | 63 | 73 | 32.84127 | 0.876464 | 0.351861 | 0 | 0.133333 | 0 | 0 | 0.000794 | 0 | 0 | 0 | 0 | 0.063492 | 0 | 1 | 0.166667 | false | 0.066667 | 0.2 | 0 | 0.466667 | 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 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
eb9aca23cd9eb9a3adbe7efbdbb4b5a0a2537075 | 290 | py | Python | zeekscript/error.py | zeek/zeekscript | 9f48f8912c7f157e082d3d0ddfd9d749d9bb7592 | [
"BSD-3-Clause"
] | null | null | null | zeekscript/error.py | zeek/zeekscript | 9f48f8912c7f157e082d3d0ddfd9d749d9bb7592 | [
"BSD-3-Clause"
] | 8 | 2022-03-15T00:45:03.000Z | 2022-03-29T02:54:25.000Z | zeekscript/error.py | ckreibich/zeekscript | 66eabd9b92cdfac5b615d4b1983392d184ed546b | [
"BSD-3-Clause"
] | 1 | 2022-03-15T00:24:03.000Z | 2022-03-15T00:24:03.000Z | """Exception hierarchy for the zeekscript package."""
class Error(Exception):
"""Base class for all zeekscript errors."""
class FileError(Error):
"""System errors while processing script files"""
class ParserError(Error):
"""A hard parsing error, producing no parse tree."""
| 26.363636 | 56 | 0.710345 | 35 | 290 | 5.885714 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.162069 | 290 | 10 | 57 | 29 | 0.847737 | 0.606897 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 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 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
eb9aeaeca3acf0901c1cf5d2512bfa72c4037e8b | 500 | py | Python | tests/r/test_slid.py | hajime9652/observations | 2c8b1ac31025938cb17762e540f2f592e302d5de | [
"Apache-2.0"
] | 199 | 2017-07-24T01:34:27.000Z | 2022-01-29T00:50:55.000Z | tests/r/test_slid.py | hajime9652/observations | 2c8b1ac31025938cb17762e540f2f592e302d5de | [
"Apache-2.0"
] | 46 | 2017-09-05T19:27:20.000Z | 2019-01-07T09:47:26.000Z | tests/r/test_slid.py | hajime9652/observations | 2c8b1ac31025938cb17762e540f2f592e302d5de | [
"Apache-2.0"
] | 45 | 2017-07-26T00:10:44.000Z | 2022-03-16T20:44:59.000Z | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import shutil
import sys
import tempfile
from observations.r.slid import slid
def test_slid():
"""Test module slid.py by downloading
slid.csv and testing shape of
extracted data has 7425 rows and 5 columns
"""
test_path = tempfile.mkdtemp()
x_train, metadata = slid(test_path)
try:
assert x_train.shape == (7425, 5)
except:
shutil.rmtree(test_path)
raise()
| 20.833333 | 45 | 0.746 | 72 | 500 | 4.902778 | 0.569444 | 0.084986 | 0.135977 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02457 | 0.186 | 500 | 23 | 46 | 21.73913 | 0.842752 | 0.214 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.066667 | 1 | 0.066667 | false | 0 | 0.466667 | 0 | 0.533333 | 0.066667 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
eba4ffa534e8ee8eae94ebf37eecba0c4e4ecfe1 | 422 | py | Python | core/utils/network/sms.py | vsilent/smarty-bot | 963cba05433be14494ba339343c9903ccab3c37d | [
"MIT"
] | 1 | 2016-10-08T09:01:05.000Z | 2016-10-08T09:01:05.000Z | core/utils/network/sms.py | vsilent/smarty-bot | 963cba05433be14494ba339343c9903ccab3c37d | [
"MIT"
] | 1 | 2019-09-24T09:56:52.000Z | 2019-09-24T09:56:52.000Z | core/utils/network/sms.py | vsilent/smarty-bot | 963cba05433be14494ba339343c9903ccab3c37d | [
"MIT"
] | null | null | null | from twilio.rest import TwilioRestClient
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "AC32a3c49700934481addd5ce1659f04d2"
auth_token = ""
client = TwilioRestClient(account_sid, auth_token)
message = client.sms.messages.create(body="Jenny please?! I love you <3",
to="+14159352345", # Replace with your phone number
from_="+14158141829") # Replace with your Twilio number
print message.sid
| 42.2 | 73 | 0.793839 | 56 | 422 | 5.892857 | 0.607143 | 0.090909 | 0.090909 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.12 | 0.111374 | 422 | 9 | 74 | 46.888889 | 0.76 | 0.291469 | 0 | 0 | 0 | 0 | 0.291525 | 0.115254 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.125 | null | null | 0.125 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ebc9a9ceb1bf20236162ada1c475138e3710be43 | 1,031 | py | Python | users/tests/factories/user.py | gafderks/dbase | 4089cf220740afd7fcc0ae68fcd6185829a60eae | [
"Apache-2.0"
] | null | null | null | users/tests/factories/user.py | gafderks/dbase | 4089cf220740afd7fcc0ae68fcd6185829a60eae | [
"Apache-2.0"
] | 281 | 2020-04-03T15:22:46.000Z | 2022-03-31T20:53:28.000Z | users/tests/factories/user.py | gafderks/dbase | 4089cf220740afd7fcc0ae68fcd6185829a60eae | [
"Apache-2.0"
] | null | null | null | import factory
from django.contrib.auth import get_user_model
from django.contrib.auth.hashers import make_password
from users.tests.factories import GroupFactory
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
model = get_user_model()
class Params:
email_base = factory.Faker("safe_email")
email = factory.LazyAttributeSequence(lambda o, n: f"{n}{o.email_base}")
first_name = factory.Faker("first_name")
last_name = factory.Faker("last_name")
group = factory.SubFactory(GroupFactory)
# Role
groups = factory.RelatedFactoryList(
"users.tests.factories.RoleFactory", size=1, factory_related_name="user"
)
@factory.post_generation
def password(self, create, extracted, **kwargs):
if extracted is None:
self.password = UserFactory.PASSWORD
else:
self.password = make_password(extracted)
UserFactory.PASSWORD = make_password("password")
class SuperUserFactory(UserFactory):
is_superuser = True
| 27.131579 | 80 | 0.71387 | 118 | 1,031 | 6.084746 | 0.474576 | 0.050139 | 0.047354 | 0.058496 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.0012 | 0.192047 | 1,031 | 37 | 81 | 27.864865 | 0.860744 | 0.00388 | 0 | 0 | 0 | 0 | 0.08878 | 0.032195 | 0 | 0 | 0 | 0 | 0 | 1 | 0.04 | false | 0.2 | 0.16 | 0 | 0.6 | 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 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
ebcd3ef6ba7bb0afb95e3a6a661f9340950f81a5 | 2,502 | py | Python | src/edrn/bmdb/descreport.py | EDRN/edrn.bmdb | e8cf66d45ded0ef6aacbf7c92468bbf3c9d3d6dc | [
"Apache-2.0"
] | null | null | null | src/edrn/bmdb/descreport.py | EDRN/edrn.bmdb | e8cf66d45ded0ef6aacbf7c92468bbf3c9d3d6dc | [
"Apache-2.0"
] | 5 | 2020-08-05T21:21:21.000Z | 2021-12-14T22:55:49.000Z | src/edrn/bmdb/descreport.py | EDRN/edrn.bmdb | e8cf66d45ded0ef6aacbf7c92468bbf3c9d3d6dc | [
"Apache-2.0"
] | null | null | null | # encoding: utf-8
import argparse, getpass, pymysql, sys, csv
def generateDescriptionReport(connection):
cursor = connection.cursor()
cursor.execute("SET CHARACTER_SET_RESULTS='latin1'")
cursor.execute('''SELECT biomarkers.id, biomarkers.name, biomarkers.description FROM biomarkers''')
with open('results.csv', 'w', newline='', encoding='utf-8') as f:
writer = csv.writer(f)
writer.writerow(['ID', 'Name', 'HGNC', 'Alternative Facts', 'Description'])
for biomarkerRow in cursor.fetchall():
number, name, description = biomarkerRow
# HGNC name
subCursor = connection.cursor()
subCursor.execute("SET CHARACTER_SET_RESULTS='latin1'")
subCursor.execute('''
SELECT
biomarker_names.name
FROM
biomarker_names
WHERE
biomarker_names.biomarker_id = %s AND
biomarker_names.isHgnc = 1
''', (number,))
hgnc = 'unknown' if subCursor.rowcount == 0 else subCursor.fetchall()[0][0]
# Aliases
subCursor.execute('''
SELECT
biomarker_names.name
FROM
biomarker_names
WHERE
biomarker_names.biomarker_id = %s AND
biomarker_names.isHgnc = 0
ORDER BY
biomarker_names.name
''', (number,))
aliases = [i[0] for i in subCursor.fetchall()]
writer.writerow([str(number), name, hgnc, ', '.join(sorted(list(aliases))), description])
def main():
parser = argparse.ArgumentParser(description="Make description report")
parser.add_argument('-H', '--host', default='localhost', help='MySQL host; default %(default)s')
parser.add_argument('-D', '--database', default='cbmdb', help='MySQL database, default %(default)s')
parser.add_argument('-u', '--user', default='cbmdb', help='MySQL user; default %(default)s')
parser.add_argument('-p', '--password', help='MySQL password; will be prompted if not given')
args = parser.parse_args()
user = args.user
password = args.password if args.password else getpass.getpass(u'Password for MySQL user "{}": '.format(user))
connection = pymysql.connect(host=args.host, user=user, password=password, database=args.database)
generateDescriptionReport(connection)
sys.exit(0)
| 42.40678 | 114 | 0.593125 | 258 | 2,502 | 5.674419 | 0.352713 | 0.086066 | 0.046448 | 0.043033 | 0.266393 | 0.266393 | 0.153005 | 0.153005 | 0.153005 | 0.153005 | 0 | 0.006118 | 0.281375 | 2,502 | 58 | 115 | 43.137931 | 0.80812 | 0.013189 | 0 | 0.361702 | 1 | 0 | 0.426369 | 0.073834 | 0 | 0 | 0 | 0 | 0 | 1 | 0.042553 | false | 0.085106 | 0.021277 | 0 | 0.06383 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
ebcde5c471d2e047658950f119e82a4bf8ac5818 | 32,598 | py | Python | pysnmp-with-texts/ENTERASYS-POWER-ETHERNET-EXT-MIB.py | agustinhenze/mibs.snmplabs.com | 1fc5c07860542b89212f4c8ab807057d9a9206c7 | [
"Apache-2.0"
] | 8 | 2019-05-09T17:04:00.000Z | 2021-06-09T06:50:51.000Z | pysnmp-with-texts/ENTERASYS-POWER-ETHERNET-EXT-MIB.py | agustinhenze/mibs.snmplabs.com | 1fc5c07860542b89212f4c8ab807057d9a9206c7 | [
"Apache-2.0"
] | 4 | 2019-05-31T16:42:59.000Z | 2020-01-31T21:57:17.000Z | pysnmp-with-texts/ENTERASYS-POWER-ETHERNET-EXT-MIB.py | agustinhenze/mibs.snmplabs.com | 1fc5c07860542b89212f4c8ab807057d9a9206c7 | [
"Apache-2.0"
] | 10 | 2019-04-30T05:51:36.000Z | 2022-02-16T03:33:41.000Z | #
# PySNMP MIB module ENTERASYS-POWER-ETHERNET-EXT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ENTERASYS-POWER-ETHERNET-EXT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:04:21 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint")
etsysModules, = mibBuilder.importSymbols("ENTERASYS-MIB-NAMES", "etsysModules")
entPhysicalIndex, = mibBuilder.importSymbols("ENTITY-MIB", "entPhysicalIndex")
EnabledStatus, = mibBuilder.importSymbols("P-BRIDGE-MIB", "EnabledStatus")
pethPsePortEntry, pethMainPseEntry = mibBuilder.importSymbols("POWER-ETHERNET-MIB", "pethPsePortEntry", "pethMainPseEntry")
NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup")
MibIdentifier, TimeTicks, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64, ModuleIdentity, ObjectIdentity, Unsigned32, NotificationType, Integer32, Bits, iso, IpAddress, Counter32, Bits, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "MibIdentifier", "TimeTicks", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64", "ModuleIdentity", "ObjectIdentity", "Unsigned32", "NotificationType", "Integer32", "Bits", "iso", "IpAddress", "Counter32", "Bits", "Gauge32")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
etsysPowerEthernetMibExtMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50))
etsysPowerEthernetMibExtMIB.setRevisions(('2009-08-27 20:31', '2005-01-10 16:30', '2004-08-17 22:27',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: etsysPowerEthernetMibExtMIB.setRevisionsDescriptions(('Adding objects to support IEEE Std. 802.3at functionality. Changes to etsysPsePortPowerManagementTable: - Increased max etsysPsePortPowerLimit range to 34000. - Added etsysPsePortCapability, etsysPsePortCapabilitySelect, and etsysPsePortDetectionStatus objects.', 'Added the power management functionality.', 'The initial version of this MIB module',))
if mibBuilder.loadTexts: etsysPowerEthernetMibExtMIB.setLastUpdated('200908272031Z')
if mibBuilder.loadTexts: etsysPowerEthernetMibExtMIB.setOrganization('Enterasys Networks, Inc')
if mibBuilder.loadTexts: etsysPowerEthernetMibExtMIB.setContactInfo('Postal: Enterasys Networks 50 Minuteman Rd. Andover, MA 01810-1008 USA Phone: +1 978 684 1000 E-mail: support@enterasys.com WWW: http://www.enterasys.com')
if mibBuilder.loadTexts: etsysPowerEthernetMibExtMIB.setDescription('This MIB module defines a portion of the SNMP MIB under the Enterasys Networks enterprise OID pertaining to the allocation of power in a Pse chassis.')
etsysPowerEthernetObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1))
etsysPseChassisPowerAllocation = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 1))
etsysPseSlotPowerAllocation = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 2))
etsysPseChassisPowerStatus = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 3))
etsysPseSlotPowerManagement = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 4))
etsysPsePortPowerManagement = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 5))
etsysPsePowerNotification = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 0))
etsysPseChassisPowerAllocationMode = MibScalar((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("auto", 1), ("manual", 2))).clone('auto')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: etsysPseChassisPowerAllocationMode.setStatus('current')
if mibBuilder.loadTexts: etsysPseChassisPowerAllocationMode.setDescription('In auto mode, a Pse Power Management Algorithm handles the allocation of power to all the modules. In manual mode, power is manually allocated to the modules via the etsysPseSlotPowerAllocationTable. The value of etsysPseChassisPowerAllocationAvailable is used to determine the power available for allocation in this chassis in both auto and manual mode. Maintaining the value of this object across agent reboots is REQUIRED.')
etsysPseChassisPowerSnmpNotification = MibScalar((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 1, 2), EnabledStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: etsysPseChassisPowerSnmpNotification.setStatus('current')
if mibBuilder.loadTexts: etsysPseChassisPowerSnmpNotification.setDescription('The current state of the SNMP Notification functionality for Pse. enabled (1) - The Pse will generate SNMP Notifications for potentially adverse Pse power conditions. The generation of these notifications are NOT dependant upon the state of etsysPseChassisPowerAllocationMode. disabled (2) - The SNMP Notifications defined in this MIB will NOT be generated under any conditions. Agents are not required to generate SNMP Notifications for conditions that exist when this object is set to enabled. Maintaining the value of this object across agent reboots is REQUIRED.')
etsysPseChassisPowerAvailableMaximum = MibScalar((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 1, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 100)).clone(100)).setUnits('percent').setMaxAccess("readwrite")
if mibBuilder.loadTexts: etsysPseChassisPowerAvailableMaximum.setStatus('current')
if mibBuilder.loadTexts: etsysPseChassisPowerAvailableMaximum.setDescription('The maximum percentage of power from the Pse Power Supply that this chassis can use. The default value should be 100 percent, meaning the chassis can use all the power detected from Pse Power Supply. Maintaining the value of this object across agent reboots is REQUIRED.')
etsysPseSlotPowerAllocationTable = MibTable((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 2, 1), )
if mibBuilder.loadTexts: etsysPseSlotPowerAllocationTable.setStatus('current')
if mibBuilder.loadTexts: etsysPseSlotPowerAllocationTable.setDescription('Power allocation management information for all slots.')
etsysPseSlotPowerAllocationEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 2, 1, 1), ).setIndexNames((0, "ENTITY-MIB", "entPhysicalIndex"))
if mibBuilder.loadTexts: etsysPseSlotPowerAllocationEntry.setStatus('current')
if mibBuilder.loadTexts: etsysPseSlotPowerAllocationEntry.setDescription('Power allocation management information for an entPhysicalEntry that has an entPhysicalClass of container(5) and represents a slot in the chassis that could be occupied by a Pse module.')
etsysPseSlotPowerMaximum = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 2, 1, 1, 1), Unsigned32()).setUnits('Watts').setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPseSlotPowerMaximum.setStatus('current')
if mibBuilder.loadTexts: etsysPseSlotPowerMaximum.setDescription("The maximum power that can be consumed by the module in this slot, based on the module's characteristics. For slots without Pse modules this object MUST return zero.")
etsysPseSlotPowerAssigned = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 2, 1, 1, 2), Unsigned32()).setUnits('Watts').setMaxAccess("readwrite")
if mibBuilder.loadTexts: etsysPseSlotPowerAssigned.setStatus('current')
if mibBuilder.loadTexts: etsysPseSlotPowerAssigned.setDescription('The power that will be allocated to this slot in manual mode. In auto mode, this object has no effect. Maintaining the value of this object across agent reboots is REQUIRED.')
etsysPseChassisPowerDetected = MibScalar((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 3, 1), Gauge32()).setUnits('Watts').setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPseChassisPowerDetected.setStatus('current')
if mibBuilder.loadTexts: etsysPseChassisPowerDetected.setDescription('The total power detected by the chassis from Pse Power Supply.')
etsysPseChassisPowerAvailable = MibScalar((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 3, 2), Gauge32()).setUnits('Watts').setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPseChassisPowerAvailable.setStatus('current')
if mibBuilder.loadTexts: etsysPseChassisPowerAvailable.setDescription('The total power available for this chassis. This is ( etsysPseChassisPowerDetected * ( etsysPseChassisPowerAvailableMaximum / 100 ) ).')
etsysPseChassisPowerConsumable = MibScalar((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 3, 3), Gauge32()).setUnits('Watts').setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPseChassisPowerConsumable.setStatus('current')
if mibBuilder.loadTexts: etsysPseChassisPowerConsumable.setDescription('The total power that could be consumed by all of the Pse modules in the chassis. This is the summation of the values of all of the etsysPseSlotPowerMaximum objects.')
etsysPseChassisPowerAssigned = MibScalar((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 3, 4), Unsigned32()).setUnits('Watts').setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPseChassisPowerAssigned.setStatus('current')
if mibBuilder.loadTexts: etsysPseChassisPowerAssigned.setDescription('The total power assigned to the slots in the chassis. This is the summation of the values of all of the etsysPseSlotPowerAssigned objects.')
etsysPseChassisPowerRedundancy = MibScalar((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 3, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("redundant", 1), ("notRedundant", 2), ("notSupported", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPseChassisPowerRedundancy.setStatus('current')
if mibBuilder.loadTexts: etsysPseChassisPowerRedundancy.setDescription('Denotes whether or not the Pse power system has redundant capacity.')
etsysPseModulePowerManagementTable = MibTable((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 4, 1), )
if mibBuilder.loadTexts: etsysPseModulePowerManagementTable.setStatus('current')
if mibBuilder.loadTexts: etsysPseModulePowerManagementTable.setDescription('This table augments the pethMainPseTable of the PowerEthernetMIB (rfc3621). It provides objects that are used to budget power.')
etsysPseModulePowerManagementEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 4, 1, 1), )
pethMainPseEntry.registerAugmentions(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseModulePowerManagementEntry"))
etsysPseModulePowerManagementEntry.setIndexNames(*pethMainPseEntry.getIndexNames())
if mibBuilder.loadTexts: etsysPseModulePowerManagementEntry.setStatus('current')
if mibBuilder.loadTexts: etsysPseModulePowerManagementEntry.setDescription('A set of objects that display, control, and calculate the power consumption of a PSE.')
etsysPseModulePowerMode = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 4, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("realtime", 1), ("class", 2))).clone('realtime')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: etsysPseModulePowerMode.setStatus('current')
if mibBuilder.loadTexts: etsysPseModulePowerMode.setDescription('This object controls the power management of the PSE. It also controls how etsysPseModulePowerClassBudget, etsysPseModulePowerUsage and etsysPsePortPowerLimit are utilized. In realtime mode, the power is managed based on the actual power consumption of the ports. etsysPseModulePowerClassBudget is sum of power consumed by all ports, measured in real-time. The etsysPseModulePowerUsage is ratio of pethMainPseConsumptionPower over pethMainPsePower, expressed in percents. In class mode, the power is managed based on the IEEE 802.3af definition of the class upper limit, except classes 0 & 4 for which the actual power consumption is used. etsysPseModulePowerClassBudget is sum of all ports power according to their class upper bound, except classes 0 & 4 for which the actual power consumption is accounted. The etsysPseModulePowerUsage is ratio of etsysPseModulePowerClassBudget over pethMainPsePower, expressed in percents. The effect of etsysPseModulePowerMode to etsysPsePortPowerLimit is described in etsysPsePortPowerLimit definition. Maintaining the value of this object across agent reboots is REQUIRED.')
etsysPseModulePowerClassBudget = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 4, 1, 1, 2), Gauge32()).setUnits('Watts').setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPseModulePowerClassBudget.setStatus('current')
if mibBuilder.loadTexts: etsysPseModulePowerClassBudget.setDescription('In class mode, this is sum of all ports power according to their class upper bound, except classes 0 & 4 for which the actual power consumption is accounted. In realtime mode, this is sum of power consumed by all ports, measured in real-time.')
etsysPseModulePowerUsage = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 4, 1, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 100))).setUnits('%').setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPseModulePowerUsage.setStatus('current')
if mibBuilder.loadTexts: etsysPseModulePowerUsage.setDescription('In class mode, this is ratio of etsysPseModulePowerClassBudget over pethMainPsePower, expressed in percents. In realtime mode, this is ratio of pethMainPseConsumptionPower over pethMainPsePower, expressed in percents.')
etsysPsePortPowerManagementTable = MibTable((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 5, 1), )
if mibBuilder.loadTexts: etsysPsePortPowerManagementTable.setStatus('current')
if mibBuilder.loadTexts: etsysPsePortPowerManagementTable.setDescription('This table augments the pethPsePortTable of the PowerEthernetMIB (rfc3621). It provides objects that are used to budget power.')
etsysPsePortPowerManagementEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 5, 1, 1), )
pethPsePortEntry.registerAugmentions(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePortPowerManagementEntry"))
etsysPsePortPowerManagementEntry.setIndexNames(*pethPsePortEntry.getIndexNames())
if mibBuilder.loadTexts: etsysPsePortPowerManagementEntry.setStatus('current')
if mibBuilder.loadTexts: etsysPsePortPowerManagementEntry.setDescription('A set of objects that display and control the power consumption of a PSE, at the port level.')
etsysPsePortPowerLimit = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 5, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 34000)).clone(15400)).setUnits('milliwatts').setMaxAccess("readwrite")
if mibBuilder.loadTexts: etsysPsePortPowerLimit.setStatus('current')
if mibBuilder.loadTexts: etsysPsePortPowerLimit.setDescription("This object sets the maximum power allowed on this port. If the port exceeds its power limit, it will be shut down. This object has effect only when its module is in realtime mode (specified by etsysPseModulePowerMode). In class mode, the power limit of a port is defined by port's class upper bound, according to the IEEE standard selected in etsysPsePortCapabilitySelect.")
etsysPsePortPowerUsage = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 5, 1, 1, 2), Gauge32()).setUnits('milliwatts').setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPsePortPowerUsage.setStatus('current')
if mibBuilder.loadTexts: etsysPsePortPowerUsage.setDescription('Actual power consumption measured in real-time.')
etsysPsePortPDType = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 5, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("legacy", 1), ("ieee8023af", 2), ("other", 3), ("ieee8023", 4), ("ieee8023at", 5)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPsePortPDType.setReference('IEEE Std 802.3af IEEE Std 802.3at')
if mibBuilder.loadTexts: etsysPsePortPDType.setStatus('current')
if mibBuilder.loadTexts: etsysPsePortPDType.setDescription('Describes the detected PD type on this port. A value of legacy(1) - indicates that the PD is using a capacitive signature, which is pre-IEEE standard. A value of ieee8023af(2)- indicates that the PD is using a resistive signature and is compliant with the IEEE Std 802.3af. A value of other(3) - indicates that the PD type could not be determined. A value of ieee8023(4)- indicates that the PD is using a resistive signature and is compliant with the IEEE Std 802.3af and/or IEEE Std 802.3at specifications. A value of ieee8023at(5)- indicates that the PD is using a resistive signature and is compliant with the IEEE Std 802.3at.')
etsysPsePortCapability = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 5, 1, 1, 4), Bits().clone(namedValues=NamedValues(("other", 0), ("ieee8023afCapable", 1), ("ieee8023atCapable", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPsePortCapability.setReference('IEEE Std 802.3af IEEE Std 802.3at')
if mibBuilder.loadTexts: etsysPsePortCapability.setStatus('current')
if mibBuilder.loadTexts: etsysPsePortCapability.setDescription('This object indicates the IEEE Power over Ethernet standard this port supports.')
etsysPsePortCapabilitySelect = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 5, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("ieee8023af", 1), ("ieee8023at", 2))).clone('ieee8023af')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: etsysPsePortCapabilitySelect.setReference('IEEE Std 802.3af IEEE Std 802.3at')
if mibBuilder.loadTexts: etsysPsePortCapabilitySelect.setStatus('current')
if mibBuilder.loadTexts: etsysPsePortCapabilitySelect.setDescription("This object sets the port's power management capabilities based on the IEEE standard. ieee8023af (1) : IEEE Std 802.3af ieee8023at (2) : IEEE Std 802.3at Attempting to set this value to a capability that is not supported, as indicated by etsysPsePortCapability, will result in an inconsistentValue error.")
etsysPsePortDetectionStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 5, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7))).clone(namedValues=NamedValues(("disabled", 1), ("searching", 2), ("deliveringPower", 3), ("fault", 4), ("test", 5), ("otherFault", 6), ("requestingPower", 7)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPsePortDetectionStatus.setStatus('current')
if mibBuilder.loadTexts: etsysPsePortDetectionStatus.setDescription("Describes the operational status of the port PD detection. A value of disabled(1)- indicates that the PSE State diagram is in the state DISABLED. A value of deliveringPower(3) - indicates that the PSE State diagram is in the state POWER_ON for a duration greater than tlim max. A value of fault(4) - indicates that the PSE State diagram is in the state TEST_ERROR. A value of test(5) - indicates that the PSE State diagram is in the state TEST_MODE. A value of otherFault(6) - indicates that the PSE State diagram is in the state IDLE due to the variable error_conditions. A value of searching(2)- indicates the PSE State diagram is in a state other than those listed above. A value of requestingPower(7) - indicates the PSE State diagram is in the state IDLE after transitioning from the state POWER_DENIED due to insufficient PSE power being available to satisfy the PD's requirements.")
etsysPsePowerSupplyStatusTable = MibTable((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 3, 6), )
if mibBuilder.loadTexts: etsysPsePowerSupplyStatusTable.setStatus('current')
if mibBuilder.loadTexts: etsysPsePowerSupplyStatusTable.setDescription('Status information for all of the Pse power supply modules.')
etsysPsePowerSupplyStatusEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 3, 6, 1), ).setIndexNames((0, "ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePowerSupplyModuleNumber"))
if mibBuilder.loadTexts: etsysPsePowerSupplyStatusEntry.setStatus('current')
if mibBuilder.loadTexts: etsysPsePowerSupplyStatusEntry.setDescription('Status information for an individual Pse power supply module.')
etsysPsePowerSupplyModuleNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 3, 6, 1, 1), Unsigned32())
if mibBuilder.loadTexts: etsysPsePowerSupplyModuleNumber.setStatus('current')
if mibBuilder.loadTexts: etsysPsePowerSupplyModuleNumber.setDescription("A unique number that identifies the Pse power supply and is relative to the module's physical location.")
etsysPsePowerSupplyModuleStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 3, 6, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("infoNotAvailable", 1), ("notInstalled", 2), ("installedAndOperating", 3), ("installedAndNotOperating", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: etsysPsePowerSupplyModuleStatus.setStatus('current')
if mibBuilder.loadTexts: etsysPsePowerSupplyModuleStatus.setDescription("Denotes the power supply's status.")
etsysPseChassisPowerRedundant = NotificationType((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 0, 1)).setObjects(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerDetected"))
if mibBuilder.loadTexts: etsysPseChassisPowerRedundant.setStatus('current')
if mibBuilder.loadTexts: etsysPseChassisPowerRedundant.setDescription('Pse chassis power is in redundant state. At least 500 msec must elapse between notifications being emitted by the same object instance.')
etsysPseChassisPowerNonRedundant = NotificationType((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 0, 2)).setObjects(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerDetected"))
if mibBuilder.loadTexts: etsysPseChassisPowerNonRedundant.setStatus('current')
if mibBuilder.loadTexts: etsysPseChassisPowerNonRedundant.setDescription('Pse chassis power is in non-redundant state. At least 500 msec must elapse between notifications being emitted by the same object instance.')
etsysPsePowerSupplyModuleStatusChange = NotificationType((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 1, 0, 3)).setObjects(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePowerSupplyModuleStatus"))
if mibBuilder.loadTexts: etsysPsePowerSupplyModuleStatusChange.setStatus('current')
if mibBuilder.loadTexts: etsysPsePowerSupplyModuleStatusChange.setDescription('A Pse Power Supply module has changed state. At least 500 msec must elapse between notifications being emitted by the same object instance.')
etsysPsePowerAllocationConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 2))
etsysPsePowerAllocationGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 2, 1))
etsysPsePowerAllocationCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 2, 2))
etsysPsePowerAllocationControlGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 2, 1, 1)).setObjects(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerAllocationMode"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerSnmpNotification"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerAvailableMaximum"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseSlotPowerMaximum"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseSlotPowerAssigned"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
etsysPsePowerAllocationControlGroup = etsysPsePowerAllocationControlGroup.setStatus('current')
if mibBuilder.loadTexts: etsysPsePowerAllocationControlGroup.setDescription('Power over Ethernet Power Allocation Control group.')
etsysPseChassisPowerStatusGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 2, 1, 2)).setObjects(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerDetected"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerAvailable"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerConsumable"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerAssigned"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerRedundancy"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePowerSupplyModuleStatus"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
etsysPseChassisPowerStatusGroup = etsysPseChassisPowerStatusGroup.setStatus('current')
if mibBuilder.loadTexts: etsysPseChassisPowerStatusGroup.setDescription('Power over Ethernet Power Supply group.')
etsysPsePowerNotificationGroup = NotificationGroup((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 2, 1, 3)).setObjects(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerRedundant"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerNonRedundant"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePowerSupplyModuleStatusChange"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
etsysPsePowerNotificationGroup = etsysPsePowerNotificationGroup.setStatus('current')
if mibBuilder.loadTexts: etsysPsePowerNotificationGroup.setDescription('Power over Ethernet Power Redundancy Notifications group.')
etsysPseModulePowerManagementGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 2, 1, 4)).setObjects(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseModulePowerMode"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseModulePowerClassBudget"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseModulePowerUsage"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
etsysPseModulePowerManagementGroup = etsysPseModulePowerManagementGroup.setStatus('current')
if mibBuilder.loadTexts: etsysPseModulePowerManagementGroup.setDescription('Power over Ethernet Module Power Budget Management group.')
etsysPsePortPowerManagementGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 2, 1, 5)).setObjects(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePortPowerLimit"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePortPowerUsage"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePortPDType"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
etsysPsePortPowerManagementGroup = etsysPsePortPowerManagementGroup.setStatus('deprecated')
if mibBuilder.loadTexts: etsysPsePortPowerManagementGroup.setDescription('Power over Ethernet Port Power Budget Management group.')
etsysPsePortPowerManagementGroupRev2 = ObjectGroup((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 2, 1, 6)).setObjects(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePortPowerLimit"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePortPowerUsage"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePortPDType"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePortCapability"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePortCapabilitySelect"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePortDetectionStatus"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
etsysPsePortPowerManagementGroupRev2 = etsysPsePortPowerManagementGroupRev2.setStatus('current')
if mibBuilder.loadTexts: etsysPsePortPowerManagementGroupRev2.setDescription('Power over Ethernet Port Power Budget Management group.')
etsysPsePowerAllocationCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 2, 2, 1)).setObjects(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePowerAllocationControlGroup"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerStatusGroup"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePowerNotificationGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
etsysPsePowerAllocationCompliance = etsysPsePowerAllocationCompliance.setStatus('current')
if mibBuilder.loadTexts: etsysPsePowerAllocationCompliance.setDescription('The compliance statement for devices that support manual power allocation.')
etsysPsePowerAllocationCompliance2 = ModuleCompliance((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 2, 2, 2)).setObjects(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePowerAllocationControlGroup"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerStatusGroup"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePowerNotificationGroup"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseModulePowerManagementGroup"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePortPowerManagementGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
etsysPsePowerAllocationCompliance2 = etsysPsePowerAllocationCompliance2.setStatus('deprecated')
if mibBuilder.loadTexts: etsysPsePowerAllocationCompliance2.setDescription('The compliance statement for devices that support power budgets.')
etsysPsePowerAllocationCompliance2Rev2 = ModuleCompliance((1, 3, 6, 1, 4, 1, 5624, 1, 2, 50, 2, 2, 3)).setObjects(("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePowerAllocationControlGroup"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseChassisPowerStatusGroup"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePowerNotificationGroup"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPseModulePowerManagementGroup"), ("ENTERASYS-POWER-ETHERNET-EXT-MIB", "etsysPsePortPowerManagementGroupRev2"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
etsysPsePowerAllocationCompliance2Rev2 = etsysPsePowerAllocationCompliance2Rev2.setStatus('current')
if mibBuilder.loadTexts: etsysPsePowerAllocationCompliance2Rev2.setDescription('The compliance statement for devices that support power budgets.')
mibBuilder.exportSymbols("ENTERASYS-POWER-ETHERNET-EXT-MIB", etsysPseChassisPowerAvailable=etsysPseChassisPowerAvailable, etsysPseChassisPowerRedundancy=etsysPseChassisPowerRedundancy, etsysPsePortPowerManagementTable=etsysPsePortPowerManagementTable, etsysPseSlotPowerAllocationTable=etsysPseSlotPowerAllocationTable, etsysPseSlotPowerAssigned=etsysPseSlotPowerAssigned, etsysPseModulePowerManagementGroup=etsysPseModulePowerManagementGroup, etsysPowerEthernetMibExtMIB=etsysPowerEthernetMibExtMIB, etsysPseSlotPowerManagement=etsysPseSlotPowerManagement, etsysPseSlotPowerAllocation=etsysPseSlotPowerAllocation, etsysPseModulePowerManagementTable=etsysPseModulePowerManagementTable, etsysPsePortDetectionStatus=etsysPsePortDetectionStatus, etsysPseChassisPowerAssigned=etsysPseChassisPowerAssigned, etsysPsePowerSupplyModuleStatusChange=etsysPsePowerSupplyModuleStatusChange, etsysPsePowerAllocationConformance=etsysPsePowerAllocationConformance, etsysPsePortPDType=etsysPsePortPDType, etsysPsePowerSupplyModuleStatus=etsysPsePowerSupplyModuleStatus, etsysPsePortPowerManagementGroup=etsysPsePortPowerManagementGroup, etsysPsePowerSupplyModuleNumber=etsysPsePowerSupplyModuleNumber, etsysPsePowerAllocationGroups=etsysPsePowerAllocationGroups, etsysPowerEthernetObjects=etsysPowerEthernetObjects, etsysPsePortPowerLimit=etsysPsePortPowerLimit, etsysPsePortPowerManagementEntry=etsysPsePortPowerManagementEntry, etsysPseChassisPowerAllocationMode=etsysPseChassisPowerAllocationMode, etsysPsePowerAllocationCompliance2Rev2=etsysPsePowerAllocationCompliance2Rev2, etsysPseChassisPowerConsumable=etsysPseChassisPowerConsumable, etsysPsePowerSupplyStatusEntry=etsysPsePowerSupplyStatusEntry, etsysPseChassisPowerStatus=etsysPseChassisPowerStatus, etsysPsePowerAllocationControlGroup=etsysPsePowerAllocationControlGroup, etsysPseModulePowerClassBudget=etsysPseModulePowerClassBudget, etsysPsePowerAllocationCompliance2=etsysPsePowerAllocationCompliance2, etsysPseChassisPowerAvailableMaximum=etsysPseChassisPowerAvailableMaximum, etsysPseChassisPowerDetected=etsysPseChassisPowerDetected, etsysPsePortPowerUsage=etsysPsePortPowerUsage, etsysPsePowerSupplyStatusTable=etsysPsePowerSupplyStatusTable, etsysPseChassisPowerNonRedundant=etsysPseChassisPowerNonRedundant, etsysPseChassisPowerAllocation=etsysPseChassisPowerAllocation, etsysPseModulePowerUsage=etsysPseModulePowerUsage, etsysPseSlotPowerMaximum=etsysPseSlotPowerMaximum, etsysPsePowerAllocationCompliances=etsysPsePowerAllocationCompliances, etsysPsePortCapabilitySelect=etsysPsePortCapabilitySelect, etsysPseChassisPowerStatusGroup=etsysPseChassisPowerStatusGroup, etsysPsePowerAllocationCompliance=etsysPsePowerAllocationCompliance, etsysPseModulePowerManagementEntry=etsysPseModulePowerManagementEntry, etsysPsePortCapability=etsysPsePortCapability, etsysPseSlotPowerAllocationEntry=etsysPseSlotPowerAllocationEntry, etsysPsePowerNotification=etsysPsePowerNotification, etsysPseChassisPowerRedundant=etsysPseChassisPowerRedundant, etsysPsePortPowerManagementGroupRev2=etsysPsePortPowerManagementGroupRev2, etsysPseModulePowerMode=etsysPseModulePowerMode, etsysPsePortPowerManagement=etsysPsePortPowerManagement, PYSNMP_MODULE_ID=etsysPowerEthernetMibExtMIB, etsysPseChassisPowerSnmpNotification=etsysPseChassisPowerSnmpNotification, etsysPsePowerNotificationGroup=etsysPsePowerNotificationGroup)
| 181.1 | 3,354 | 0.805111 | 3,591 | 32,598 | 7.3066 | 0.133389 | 0.037046 | 0.06483 | 0.008385 | 0.422022 | 0.298879 | 0.276507 | 0.262977 | 0.243692 | 0.218614 | 0 | 0.046967 | 0.088196 | 32,598 | 179 | 3,355 | 182.111732 | 0.835784 | 0.010982 | 0 | 0.059524 | 0 | 0.136905 | 0.404641 | 0.113493 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.059524 | 0 | 0.059524 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ebd755c6ab61a8ec21cb3e0460b0b018fae6b04c | 4,787 | py | Python | mysite/settings.py | davidefabbrico/Progetto_School | e32e345d154764725b96e2d22b441a17fae67ade | [
"MIT"
] | 1 | 2021-09-04T08:56:32.000Z | 2021-09-04T08:56:32.000Z | mysite/settings.py | davidefabbrico/Progetto_School | e32e345d154764725b96e2d22b441a17fae67ade | [
"MIT"
] | null | null | null | mysite/settings.py | davidefabbrico/Progetto_School | e32e345d154764725b96e2d22b441a17fae67ade | [
"MIT"
] | null | null | null | """
Django settings for mysite project.
Generated by 'django-admin startproject' using Django 2.0.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/ref/settings/
"""
import os
from pathlib import Path
# from django.views.generic.list import T
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
with open(os.path.join(BASE_DIR, 'secret_key.txt')) as f:
SECRET_KEY = f.read().strip()
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
'polls.apps.PollsConfig',
"verify_email.apps.VerifyEmailConfig",
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sites',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'mysite.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
CSRF_TRUSTED_ORIGINS = ['progettoschool.it']
CORS_REPLACE_HTTPS_REFERER = True
CSRF_COOKIE_DOMAIN = 'progettoschool.it'
CORS_ORIGIN_WHITELIST = (
'https://progettoschool.it'
)
WSGI_APPLICATION = 'mysite.wsgi.application'
# database server
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'database name',
'HOST': 'database host in project I use ovh',
'PORT': '35150',
'USER': 'root',
'PASSWORD': 'password',
}
}
SITE_ID = 1
# solo in locale
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = "smtp.gmail.com"
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = "email@gmail.com"
EMAIL_HOST_PASSWORD = "password"
MAILER_EMAIL_BACKEND = EMAIL_BACKEND
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/
LANGUAGE_CODE = 'it'
TIME_ZONE = 'Europe/Berlin'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'mysite/static')
# STATIC_ROOT = os.path.join(BASE_DIR, 'mysite/polls/static/polls')
# STATICFILES_DIRS = [
# os.path.join(BASE_DIR, "mysite/static/")
# ]
# # HTTPSS settings
# SESSION_COOKIE_SECURE = True
# CSRF_COOKIE_SECURE = True
# SECURE_SSL_REDIRECT = True
# # HSTS settings
# SECURE_HSTS_SECONDS = 31536000 # 1 anno
# SECURE_HSTS_PRELOAD = True
# SECURE_HSTS_INCLUDE_SUBDOMAINS = True
# for the verification of the email
LOGIN_URL = 'login'
EXPIRE_AFTER = "2h"
SUBJECT = 'Email di verifica'
DEFAULT_FROM_EMAIL = 'noreply<no_reply@google.com>'
HTML_MESSAGE_TEMPLATE = "admin/html_template.html"
VERIFICATION_SUCCESS_TEMPLATE = "admin/success.html"
VERIFICATION_FAILED_TEMPLATE = "admin/failed.html"
| 25.736559 | 91 | 0.714644 | 570 | 4,787 | 5.821053 | 0.377193 | 0.062688 | 0.035865 | 0.045208 | 0.175105 | 0.155214 | 0.100663 | 0.091923 | 0.047619 | 0 | 0 | 0.009704 | 0.160435 | 4,787 | 185 | 92 | 25.875676 | 0.815875 | 0.301233 | 0 | 0.019802 | 1 | 0 | 0.474433 | 0.339486 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.069307 | 0.019802 | 0 | 0.019802 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
ebe0126738d573de80b9e875199a6e91681b5d67 | 744 | py | Python | hackerrank/Algorithms/Grid Challenge/test.py | ATrain951/01.python-com_Qproject | c164dd093954d006538020bdf2e59e716b24d67c | [
"MIT"
] | 4 | 2020-07-24T01:59:50.000Z | 2021-07-24T15:14:08.000Z | hackerrank/Algorithms/Grid Challenge/test.py | ATrain951/01.python-com_Qproject | c164dd093954d006538020bdf2e59e716b24d67c | [
"MIT"
] | null | null | null | hackerrank/Algorithms/Grid Challenge/test.py | ATrain951/01.python-com_Qproject | c164dd093954d006538020bdf2e59e716b24d67c | [
"MIT"
] | null | null | null | import unittest
import solution
class TestQ(unittest.TestCase):
def test_case_0(self):
self.assertEqual(solution.gridChallenge([
'eabcd',
'fghij',
'olkmn',
'trpqs',
'xywuv',
]), 'YES')
def test_case_1(self):
self.assertEqual(solution.gridChallenge([
'abc',
'lmp',
'qrt',
]), 'YES')
self.assertEqual(solution.gridChallenge([
'mpxz',
'abcd',
'wlmf',
]), 'NO')
self.assertEqual(solution.gridChallenge([
'abc',
'hjk',
'mpq',
'rtv',
]), 'YES')
if __name__ == '__main__':
unittest.main()
| 20.108108 | 49 | 0.447581 | 58 | 744 | 5.534483 | 0.568966 | 0.186916 | 0.286604 | 0.448598 | 0.380062 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004545 | 0.408602 | 744 | 36 | 50 | 20.666667 | 0.725 | 0 | 0 | 0.3 | 0 | 0 | 0.103495 | 0 | 0 | 0 | 0 | 0 | 0.133333 | 1 | 0.066667 | false | 0 | 0.066667 | 0 | 0.166667 | 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 | 0 | 0 | 0 | 0 | 2 |
ebe4cd298b9e6dc16822359cf4915866e785000a | 6,653 | py | Python | test_python.py | lv43apo91/taxonomy | 4d79b0e07a95699ad5501eeb6e4339aaade05857 | [
"MIT"
] | 22 | 2019-04-30T23:56:11.000Z | 2021-12-16T09:39:25.000Z | test_python.py | lv43apo91/taxonomy | 4d79b0e07a95699ad5501eeb6e4339aaade05857 | [
"MIT"
] | 26 | 2019-05-22T15:10:21.000Z | 2021-10-20T16:16:10.000Z | test_python.py | lv43apo91/taxonomy | 4d79b0e07a95699ad5501eeb6e4339aaade05857 | [
"MIT"
] | 4 | 2019-11-13T03:29:23.000Z | 2021-09-08T13:40:49.000Z | import unittest
from taxonomy import Taxonomy, TaxonomyError
class NewickTestCase(unittest.TestCase):
def _create_tax(self):
# https://en.wikipedia.org/wiki/Newick_format#Examples
return Taxonomy.from_newick("(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F;")
def setUp(self) -> None:
self.tax = self._create_tax()
def test_root(self):
root = self.tax.root
self.assertEqual(root.id, "F")
self.assertIsNone(root.parent)
def test_find_node_by_id(self):
node = self.tax.node("A")
self.assertEqual(node.id, "A")
self.assertEqual(node.parent, "F")
node = self.tax.node("D")
self.assertEqual(node.id, "D")
self.assertEqual(node.parent, "E")
node = self.tax.node("unknown")
self.assertIsNone(node)
def test_index(self):
node = self.tax["A"]
self.assertEqual(node.id, "A")
self.assertEqual(node.parent, "F")
with self.assertRaises(TaxonomyError):
_ = self.tax["unknown"]
def test_find_by_name(self):
# They are not named so we can't find anything by name
node = self.tax.find_by_name("A")
self.assertIsNone(node)
def test_parent(self):
parent = self.tax.parent("D")
self.assertEqual(parent.id, "E")
def test_parent_with_distance(self):
parent, distance = self.tax.parent_with_distance("D")
self.assertEqual(parent.id, "E")
# Float precision issue
# 0.4 becomes 0.4000000059604645
self.assertAlmostEqual(distance, 0.4)
def test_children(self):
children = self.tax.children("E")
self.assertEqual(len(children), 2)
self.assertEqual(children[0].id, "C")
self.assertEqual(children[1].id, "D")
def test_lineage(self):
lineage = self.tax.lineage("D")
self.assertEqual(len(lineage), 3)
self.assertEqual(lineage[0].id, "D")
self.assertEqual(lineage[1].id, "E")
self.assertEqual(lineage[2].id, "F")
def test_parents(self):
lineage = self.tax.parents("D")
self.assertEqual(len(lineage), 2)
self.assertEqual(lineage[0].id, "E")
self.assertEqual(lineage[1].id, "F")
def test_lca(self):
lca = self.tax.lca("A", "D")
self.assertEqual(lca.id, "F")
def test_prune(self):
new_tax = self.tax.prune(remove=["E"])
self.assertIsNone(new_tax.node("D"))
self.assertIsNone(new_tax.node("E"))
# We removed a leaf
self.assertEqual(len(new_tax), 3)
new_tax = self.tax.prune(keep=["E", "D"])
self.assertEqual(len(new_tax), 3)
self.assertIsNotNone(new_tax.node("F"))
def test_remove(self):
tax = self._create_tax()
tax.remove_node("E")
self.assertIsNotNone(tax.node("D"))
self.assertIsNone(tax.node("E"))
self.assertEqual(len(tax), 5)
def test_add(self):
tax = self._create_tax()
tax.add_node("D", "G")
node = tax["G"]
self.assertEqual(node.parent, "D")
def test_edit_node(self):
tax = self._create_tax()
tax.edit_node("D", parent_distance=3)
node, distance = tax.parent_with_distance("D")
self.assertEqual(distance, 3)
class NCBITestCase(unittest.TestCase):
def _create_tax(self):
return Taxonomy.from_ncbi("tests/data/ncbi_subset_tax.nodes.dmp", "tests/data/ncbi_subset_tax.names.dmp")
def setUp(self) -> None:
self.tax = self._create_tax()
def test_root(self):
root = self.tax.root
self.assertEqual(root.id, "1")
self.assertIsNone(root.parent)
def test_find_node_by_id(self):
node = self.tax.node("1236")
self.assertEqual(node.id, "1236")
self.assertEqual(node.name, "Gammaproteobacteria")
self.assertEqual(node.parent, "1224")
node = self.tax.node("unknown")
self.assertIsNone(node)
def test_index(self):
node = self.tax["1236"]
self.assertEqual(node.id, "1236")
self.assertEqual(node.name, "Gammaproteobacteria")
self.assertEqual(node.parent, "1224")
with self.assertRaises(TaxonomyError):
_ = self.tax["unknown"]
def test_find_by_name(self):
node = self.tax.find_by_name("Escherichia coli")
self.assertEqual(node.id, "562")
self.assertEqual(node.name, "Escherichia coli")
self.assertEqual(node.parent, "561")
def test_parent(self):
parent = self.tax.parent("562")
self.assertEqual(parent.id, "561")
def test_parent_with_distance(self):
parent, distance = self.tax.parent_with_distance("562")
self.assertEqual(parent.id, "561")
# Float precision issue
# 0.4 becomes 0.4000000059604645
self.assertAlmostEqual(distance, 1.0)
def test_children(self):
children = self.tax.children("561")
self.assertEqual(len(children), 1)
self.assertEqual(children[0].id, "562")
def test_lineage(self):
lineage = self.tax.lineage("562")
self.assertEqual(len(lineage), 9)
self.assertEqual(lineage[0].id, "562")
self.assertEqual(lineage[1].id, "561")
self.assertEqual(lineage[-1].id, "1")
def test_parents(self):
lineage = self.tax.parents("562")
self.assertEqual(len(lineage), 8)
self.assertEqual(lineage[0].id, "561")
self.assertEqual(lineage[-1].id, "1")
def test_lca(self):
lca = self.tax.lca("562", "91347")
self.assertEqual(lca.id, "91347")
def test_prune(self):
new_tax = self.tax.prune(remove=["561"])
self.assertIsNone(new_tax.node("561"))
self.assertIsNone(new_tax.node("562"))
self.assertEqual(len(new_tax), 7)
new_tax = self.tax.prune(keep=["561"])
self.assertEqual(len(new_tax), 8)
self.assertIsNotNone(new_tax.node("561"))
@unittest.skip("tax.remove doesn't work on truncated taxonomies?")
def test_remove(self):
tax = self._create_tax()
tax.remove_node("561")
self.assertIsNotNone(tax.node("562"))
self.assertIsNone(tax.node("561"))
self.assertEqual(len(tax), 8)
def test_add(self):
tax = self._create_tax()
tax.add_node("561", "563")
node = tax["563"]
self.assertEqual(node.parent, "561")
def test_edit_node(self):
tax = self._create_tax()
tax.edit_node("562", parent_distance=3)
node, distance = tax.parent_with_distance("562")
self.assertEqual(distance, 3)
if __name__ == '__main__':
unittest.main()
| 31.530806 | 113 | 0.610852 | 864 | 6,653 | 4.570602 | 0.125 | 0.197518 | 0.081793 | 0.034439 | 0.794378 | 0.641935 | 0.544442 | 0.513041 | 0.423905 | 0.399595 | 0 | 0.04 | 0.240944 | 6,653 | 210 | 114 | 31.680952 | 0.74198 | 0.03427 | 0 | 0.471698 | 0 | 0.006289 | 0.066085 | 0.016521 | 0 | 0 | 0 | 0 | 0.446541 | 1 | 0.201258 | false | 0 | 0.012579 | 0.012579 | 0.238994 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
cce2a7d65eea02cad9dc11c2836ca48eb1917f3b | 498 | py | Python | Implementations/DivideAndConquerRunner.py | joakiti/Benchmark-SubsetSums | a875b5adf7f800d26b73516452904031c73ec29d | [
"MIT"
] | null | null | null | Implementations/DivideAndConquerRunner.py | joakiti/Benchmark-SubsetSums | a875b5adf7f800d26b73516452904031c73ec29d | [
"MIT"
] | null | null | null | Implementations/DivideAndConquerRunner.py | joakiti/Benchmark-SubsetSums | a875b5adf7f800d26b73516452904031c73ec29d | [
"MIT"
] | null | null | null | import math
from Implementations.Interfaces.IDeterministicAlgorithm import IDeterministicAlgorithm
from Implementations.helpers import Helper
from Implementations.helpers.Helper import ListToPolynomial, toNumbers, sumSet
class DivideAndConquerRunner(IDeterministicAlgorithm):
def __init__(self, label, benchmarkMode=False):
self.label = label
self.benchmarkMode = benchmarkMode
def run(cls, values, target):
return Helper.divideAndConquerSumSet(values, target)
| 31.125 | 86 | 0.797189 | 46 | 498 | 8.543478 | 0.543478 | 0.145038 | 0.132316 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.144578 | 498 | 15 | 87 | 33.2 | 0.922535 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.4 | 0.1 | 0.8 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
ccf238b87463d35c2dcd19af35e3b5a6ca0b523a | 287 | py | Python | core/faces/typing.py | weima/pytorch-study-notes | dd01f70a617042842483bc8ff1ea12aa3c46f197 | [
"MIT"
] | null | null | null | core/faces/typing.py | weima/pytorch-study-notes | dd01f70a617042842483bc8ff1ea12aa3c46f197 | [
"MIT"
] | null | null | null | core/faces/typing.py | weima/pytorch-study-notes | dd01f70a617042842483bc8ff1ea12aa3c46f197 | [
"MIT"
] | null | null | null | import dataclasses
from dataclasses import dataclass
from typing import List
import numpy as np
@dataclass
class Sample:
image: np.ndarray
landmarks: np.ndarray
def samples_to_dicts(samples: List[Sample]):
for sample in samples:
yield dataclasses.asdict(sample)
| 16.882353 | 44 | 0.752613 | 38 | 287 | 5.631579 | 0.578947 | 0.084112 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.191638 | 287 | 16 | 45 | 17.9375 | 0.922414 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0 | 0.363636 | 0 | 0.727273 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
69008a5fb11a2198868599f384214b25973a3737 | 3,130 | py | Python | comcenter/comcenter/model/coredb.py | tongpa/bantak_program | 66edfe225e8018f65c9c5a6cd7745c17ba557bd5 | [
"Apache-2.0"
] | null | null | null | comcenter/comcenter/model/coredb.py | tongpa/bantak_program | 66edfe225e8018f65c9c5a6cd7745c17ba557bd5 | [
"Apache-2.0"
] | null | null | null | comcenter/comcenter/model/coredb.py | tongpa/bantak_program | 66edfe225e8018f65c9c5a6cd7745c17ba557bd5 | [
"Apache-2.0"
] | null | null | null | import os
from datetime import datetime
import sys
try:
from hashlib import sha1
except ImportError:
sys.exit('ImportError: No module named hashlib\n'
'If you are on python2.4 this library is not part of python. '
'Please install it. Example: easy_install hashlib')
from sqlalchemy import Table, ForeignKey, Column
from sqlalchemy.types import Unicode, Integer, DateTime, String, Text
from sqlalchemy.orm import relation, synonym
from comcenter.model import DeclarativeBase, metadata, DBSession
__all__ = [ 'Division', 'Department','Section']
class Division(DeclarativeBase):
__tablename__ = 'division'
division_id = Column(Integer, autoincrement=True, primary_key=True);
description = Column(String(255), unique=True, nullable=False);
def __init__(self):
self.division_id = None;
self.description = None;
def save(self):
DBSession.add(self);
DBSession.flush() ;
def update(self):
DBSession.update(self);
def remove(self):
DBSession.delete(self);
DBSession.flush() ;
@classmethod
def getById(cls,id):
return DBSession.query(cls) .get(id);
@classmethod
def listAll(cls):
return DBSession.query(cls).all();
class Department(DeclarativeBase):
__tablename__ = 'department'
department_id = Column(Integer, autoincrement=True, primary_key=True);
description = Column(String(255), unique=True, nullable=False);
def __init__(self):
self.department_id = None;
self.description = None;
def save(self):
DBSession.add(self);
DBSession.flush() ;
def update(self):
DBSession.update(self);
def remove(self):
DBSession.delete(self);
DBSession.flush() ;
@classmethod
def getById(cls,id):
return DBSession.query(cls) .get(id);
@classmethod
def listAll(cls):
return DBSession.query(cls).all();
class Section(DeclarativeBase):
__tablename__ = 'section'
section_id = Column(Integer, autoincrement=True, primary_key=True);
description = Column(String(255), unique=True, nullable=False);
division_id = Column( Integer,ForeignKey('division.division_id'), nullable=False, index=True) ;
division = relation('Division', backref='section');
def __init__(self):
self.department_id = None;
self.description = None;
self.division_id = None;
def save(self):
DBSession.add(self);
DBSession.flush() ;
def update(self):
DBSession.update(self);
def remove(self):
DBSession.delete(self);
DBSession.flush() ;
@classmethod
def getById(cls,id):
return DBSession.query(cls) .get(id);
@classmethod
def listByDivision(cls,division):
return DBSession.query(cls).filter( cls.division_id==str(division) ).order_by(cls.section_id ).all();
@classmethod
def listAll(cls):
return DBSession.query(cls).all(); | 29.809524 | 110 | 0.632588 | 339 | 3,130 | 5.710914 | 0.265487 | 0.100723 | 0.072314 | 0.083161 | 0.579545 | 0.579545 | 0.579545 | 0.579545 | 0.579545 | 0.553719 | 0 | 0.005159 | 0.256869 | 3,130 | 105 | 111 | 29.809524 | 0.827171 | 0 | 0 | 0.674699 | 0 | 0 | 0.073778 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.228916 | false | 0 | 0.120482 | 0.084337 | 0.60241 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
6901d087c7e0ea1d3bce4ceca77ba5dcd9b32b28 | 1,182 | py | Python | fizzbuzz.py | mariusavram91/python_collection | eade5a79e1b0d28d2f90411092f9fbaa5e633d57 | [
"MIT"
] | null | null | null | fizzbuzz.py | mariusavram91/python_collection | eade5a79e1b0d28d2f90411092f9fbaa5e633d57 | [
"MIT"
] | null | null | null | fizzbuzz.py | mariusavram91/python_collection | eade5a79e1b0d28d2f90411092f9fbaa5e633d57 | [
"MIT"
] | null | null | null | #!/usr/bin/python3
import unittest
'''
Write a program that: for multiples of three returns “Fizz” instead of the
number and for the multiples of five returns “Buzz”.
For numbers which are multiples of both three and five returns “FizzBuzz”.
For the rest it returns the number.
'''
def fizzbuzz(number):
if number % 3 == 0 and number % 5 == 0:
return 'FizzBuzz'
elif number % 3 == 0:
return 'Fizz'
elif number % 5 == 0:
return 'Buzz'
else:
return str(number)
class FizzBuzzTest(unittest.TestCase):
def setup(self):
pass
def test_fizzbuzz_for_3(self):
self.assertEqual(fizzbuzz(3), 'Fizz')
def test_fizzbuzz_for_5(self):
self.assertEqual(fizzbuzz(5), 'Buzz')
def test_fizzbuzz_for_multiple_of_3(self):
self.assertEqual(fizzbuzz(9), 'Fizz')
def test_fizzbuzz_for_multiple_of_5(self):
self.assertEqual(fizzbuzz(10), 'Buzz')
def test_fizzbuzz_for_multiple_of_3_and_5(self):
self.assertEqual(fizzbuzz(15), 'FizzBuzz')
def test_fizzbuzz_for_other_number(self):
self.assertEqual(fizzbuzz(7), '7')
if __name__ == '__main__':
unittest.main()
| 24.625 | 74 | 0.667513 | 163 | 1,182 | 4.625767 | 0.325153 | 0.102122 | 0.119363 | 0.143236 | 0.343501 | 0.124668 | 0.087533 | 0.087533 | 0 | 0 | 0 | 0.026144 | 0.22335 | 1,182 | 47 | 75 | 25.148936 | 0.795207 | 0.014382 | 0 | 0 | 0 | 0 | 0.053377 | 0 | 0 | 0 | 0 | 0 | 0.222222 | 1 | 0.296296 | false | 0.037037 | 0.037037 | 0 | 0.518519 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
6906a89ef2dede9ab5512f5f08d32397ad287749 | 365 | py | Python | python/testData/paramInfo/DataclassesReplace/a.py | jnthn/intellij-community | 8fa7c8a3ace62400c838e0d5926a7be106aa8557 | [
"Apache-2.0"
] | 2 | 2019-04-28T07:48:50.000Z | 2020-12-11T14:18:08.000Z | python/testData/paramInfo/DataclassesReplace/a.py | Cyril-lamirand/intellij-community | 60ab6c61b82fc761dd68363eca7d9d69663cfa39 | [
"Apache-2.0"
] | 173 | 2018-07-05T13:59:39.000Z | 2018-08-09T01:12:03.000Z | python/testData/paramInfo/DataclassesReplace/a.py | Cyril-lamirand/intellij-community | 60ab6c61b82fc761dd68363eca7d9d69663cfa39 | [
"Apache-2.0"
] | 2 | 2020-03-15T08:57:37.000Z | 2020-04-07T04:48:14.000Z | from dataclasses import dataclass, field, InitVar, replace
@dataclass
class A:
a: int
b: str = "str"
replace(A(1), <arg1>)
@dataclass
class B:
a: int
b: str = field(default="str", init=False)
replace(B(1), <arg2>)
@dataclass
class C:
a: int
b: InitVar[str] = "str"
replace(C(1), <arg3>)
class D:
pass
replace(D(), <arg4>) | 10.428571 | 58 | 0.591781 | 54 | 365 | 4 | 0.425926 | 0.194444 | 0.069444 | 0.074074 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.025362 | 0.243836 | 365 | 35 | 59 | 10.428571 | 0.757246 | 0 | 0 | 0.315789 | 0 | 0 | 0.02459 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.052632 | 0.052632 | null | null | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
690dee641fb6a26f62680062e50b11e5a270ddf6 | 263 | py | Python | make/__main__.py | rolandgeider/OpenSlides | 331141c17cb23da26e377d4285efdb4a50753a59 | [
"MIT"
] | null | null | null | make/__main__.py | rolandgeider/OpenSlides | 331141c17cb23da26e377d4285efdb4a50753a59 | [
"MIT"
] | null | null | null | make/__main__.py | rolandgeider/OpenSlides | 331141c17cb23da26e377d4285efdb4a50753a59 | [
"MIT"
] | null | null | null | import sys
import commands # noqa
from parser import parser
if len(sys.argv) < 2:
args = parser.parse_args(['--help'])
else:
args = parser.parse_args()
# Runs the command end exits the script with the return-code of the command
exit(args.func(args))
| 18.785714 | 75 | 0.707224 | 42 | 263 | 4.380952 | 0.619048 | 0.108696 | 0.163043 | 0.206522 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004673 | 0.186312 | 263 | 13 | 76 | 20.230769 | 0.85514 | 0.296578 | 0 | 0 | 0 | 0 | 0.032967 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.375 | 0 | 0.375 | 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 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
6948849c021d860114868e9675882e3bbf15fe42 | 6,283 | py | Python | configs/config.py | Droliven/MSRGCN | 5d8d8e3365d3b23ca2ac734ace7e84135a6e3a9e | [
"MIT"
] | 28 | 2021-08-21T12:02:12.000Z | 2022-03-07T03:54:55.000Z | configs/config.py | Droliven/MSRGCN | 5d8d8e3365d3b23ca2ac734ace7e84135a6e3a9e | [
"MIT"
] | 6 | 2021-09-07T03:05:51.000Z | 2022-02-24T03:00:04.000Z | configs/config.py | Droliven/MSRGCN | 5d8d8e3365d3b23ca2ac734ace7e84135a6e3a9e | [
"MIT"
] | 6 | 2021-08-21T12:02:16.000Z | 2021-11-22T14:22:57.000Z | #!/usr/bin/env python
# encoding: utf-8
'''
@project : MSRGCN
@file : config.py
@author : Droliven
@contact : droliven@163.com
@ide : PyCharm
@time : 2021-07-27 16:56
'''
import os
import getpass
import torch
import numpy as np
class Config():
def __init__(self, exp_name="h36m", input_n=10, output_n=10, dct_n=15, device="cuda:0", num_works=0, test_manner="all"):
self.platform = getpass.getuser()
assert exp_name in ["h36m", "cmu", "3dpw"]
self.exp_name = exp_name
self.p_dropout = 0.1
self.train_batch_size = 16
self.test_batch_size = 128
self.lr = 2e-4
self.lr_decay = 0.98
self.n_epoch = 5000
self.leaky_c = 0.2
self.test_manner = test_manner
self.input_n = input_n
self.output_n = output_n
self.seq_len = input_n + output_n
self.dct_n = dct_n
if self.output_n == 25:
self.frame_ids = [1, 3, 7, 9, 13, 24]
elif self.output_n == 10:
self.frame_ids = [1, 3, 7, 9]
if exp_name == "h36m":
self.origin_noden = 32
self.final_out_noden = 22
self.dim_used_3d = [2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 17, 18, 19, 21, 22, 25, 26, 27, 29, 30]
self.dim_repeat_22 = [9, 9, 14, 16, 19, 21]
self.dim_repeat_32 = [16, 24, 20, 23, 28, 31]
self.Index2212 = [[0], [1, 2, 3], [4], [5, 6, 7], [8, 9], [10, 11], [12], [13], [14, 15, 16], [17], [18], [19, 20, 21]]
self.Index127 = [[0, 1], [2, 3], [4, 5], [6, 7], [7, 8], [9, 10], [10, 11]]
self.Index74 = [[0, 2], [1, 2], [3, 4], [5, 6]]
self.I32_plot = np.array(
[0, 1, 2, 3, 4, 0, 6, 7, 8, 9, 0, 11, 12, 13, 14, 12, 16, 17, 18, 19, 20, 19, 22, 12, 24, 25, 26, 27,
28,
27, 30])
self.J32_plot = np.array(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29,
30, 31])
self.LR32_plot = np.array(
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0])
self.I22_plot = np.array([8, 0, 1, 2, 8, 4, 5, 6, 8, 9, 10, 9, 12, 13, 14, 14, 9, 17, 18, 19, 19])
self.J22_plot = np.array([0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21])
self.LR22_plot = np.array([0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0])
self.I12_plot = np.array([4, 0, 4, 2, 4, 4, 6, 7, 4, 9, 10])
self.J12_plot = np.array([0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11])
self.LR12_plot = np.array([0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0])
self.I7_plot = np.array([2, 2, 2, 3, 2, 5])
self.J7_plot = np.array([0, 1, 3, 4, 5, 6])
self.LR7_plot = np.array([0, 1, 1, 1, 0, 0])
self.I4_plot = np.array([0, 1])
self.J4_plot = np.array([3, 2])
self.LR4_plot = np.array([0, 1])
elif exp_name == "cmu":
self.origin_noden = 38
self.final_out_noden = 25
self.dim_used_3d = [3, 4, 5, 6, 9, 10, 11, 12, 14, 15, 17, 18, 19, 21, 22, 23, 25, 26, 28, 30, 31, 32, 34, 35, 37]
self.dim_repeat_22 = [9, 9, 9, 15, 15, 21, 21]
self.dim_repeat_32 = [16, 20, 29, 24, 27, 33, 36]
self.Index2212 = [[0], [1, 2, 3], [4], [5, 6, 7], [8, 9], [10, 11, 12], [13], [14, 15], [16, 17, 18], [19], [20, 21], [22, 23, 24]] # 其实是 Index2512, 为了保持统一没改名
self.Index127 = [[0, 1], [2, 3], [4, 5], [6, 7], [7, 8], [9, 10], [10, 11]]
self.Index74 = [[0, 2], [1, 2], [3, 4], [5, 6]]
self.Index2510 = [[0], [1, 2, 3], [4], [5, 6, 7], [8, 9], [10, 11, 12], [14, 15], [16, 17, 18], [20, 21],
[22, 23, 24]]
self.Index105 = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]
self.Index53 = [[2], [0, 3], [1, 4]]
self.I32_plot = np.array(
[0, 1, 2, 3, 4, 5, 0, 7, 8, 9, 10, 11, 0, 13, 14, 15, 16, 17, 18, 16, 20, 21, 22, 23, 24, 25, 23, 27,
16, 29, 30, 31, 32, 33, 34, 32, 36])
self.J32_plot = np.array(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37])
self.LR32_plot = np.array(
[0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
1, 1, 1])
self.I22_plot = np.array([8, 0, 1, 2, 8, 4, 5, 6, 8, 9, 10, 11, 9, 13, 14, 15, 16, 15, 9, 19, 20, 21, 22, 21])
self.J22_plot = np.array([0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24])
self.LR22_plot = np.array([0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1])
self.I12_plot = np.array([4, 0, 4, 2, 4, 4, 6, 7, 4, 9, 10])
self.J12_plot = np.array([0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11])
self.LR12_plot = np.array([0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1])
self.I7_plot = np.array([2, 2, 2, 3, 2, 5])
self.J7_plot = np.array([0, 1, 3, 4, 5, 6])
self.LR7_plot = np.array([0, 1, 0, 0, 1, 1])
self.I4_plot = np.array([0, 1])
self.J4_plot = np.array([2, 3])
self.LR4_plot = np.array([0, 1])
self.device = device
self.num_works = num_works
self.ckpt_dir = os.path.join("./ckpt/", exp_name, "short_term" if self.output_n==10 else "long_term")
if not os.path.exists(os.path.join(self.ckpt_dir, "models")):
os.makedirs(os.path.join(self.ckpt_dir, "models"))
if not os.path.exists(os.path.join(self.ckpt_dir, "images")):
os.makedirs(os.path.join(self.ckpt_dir, "images"))
if self.exp_name == "h36m":
self.base_data_dir = os.path.join("F:\model_report_data\mocap_motion_prediction\data\human36mData3D\others", "h3.6m\dataset")
elif self.exp_name == "cmu":
self.base_data_dir = os.path.join("F:\model_report_data\mocap_motion_prediction", "data\cmu")
| 45.201439 | 171 | 0.464746 | 1,155 | 6,283 | 2.432035 | 0.148918 | 0.04628 | 0.052332 | 0.052688 | 0.61659 | 0.604842 | 0.550374 | 0.504094 | 0.481666 | 0.48131 | 0 | 0.256973 | 0.332325 | 6,283 | 138 | 172 | 45.528986 | 0.412634 | 0.031036 | 0 | 0.237624 | 0 | 0 | 0.036872 | 0.01893 | 0 | 0 | 0 | 0 | 0.009901 | 1 | 0.009901 | false | 0.019802 | 0.039604 | 0 | 0.059406 | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
696fe869b2a3e6bf203dc4bdbaa1342bd17b746c | 286 | py | Python | tinyurl_ga/main.py | tinyurl-ga/tinyurl-ga.py | 3fd49c59b58abeb449fe549b5b6a566d2edbd7ef | [
"MIT"
] | null | null | null | tinyurl_ga/main.py | tinyurl-ga/tinyurl-ga.py | 3fd49c59b58abeb449fe549b5b6a566d2edbd7ef | [
"MIT"
] | null | null | null | tinyurl_ga/main.py | tinyurl-ga/tinyurl-ga.py | 3fd49c59b58abeb449fe549b5b6a566d2edbd7ef | [
"MIT"
] | null | null | null | import requests
def create(url):
r = requests.post("https://tinyurl.ga/api", json = {"url": url})
return result(r.json())
class result:
def __init__(self, data):
self.data = data
@property
def url(self) -> str:
return self.data["url"]
| 20.428571 | 68 | 0.56993 | 37 | 286 | 4.297297 | 0.540541 | 0.150943 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.276224 | 286 | 13 | 69 | 22 | 0.768116 | 0 | 0 | 0 | 0 | 0 | 0.097902 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3 | false | 0 | 0.1 | 0.1 | 0.7 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
15db193eb5c1ac77701395d869f59f2883a41a43 | 411 | py | Python | Task1F.py | GODWINGZZ/IA-floodrisk-system-project | cc57b4148eabc25c4d0756d0bcb2260b236f72e3 | [
"MIT"
] | null | null | null | Task1F.py | GODWINGZZ/IA-floodrisk-system-project | cc57b4148eabc25c4d0756d0bcb2260b236f72e3 | [
"MIT"
] | null | null | null | Task1F.py | GODWINGZZ/IA-floodrisk-system-project | cc57b4148eabc25c4d0756d0bcb2260b236f72e3 | [
"MIT"
] | null | null | null |
from floodsystem.station import inconsistent_typical_range_stations
from floodsystem.stationdata import build_station_list
def run():
temp=inconsistent_typical_range_stations(build_station_list())
x=[]
for i in range(len(temp)):
x.append(temp[i].name)
x.sort()
print(x)
if __name__ == "__main__":
print("*** Task 1F: CUED Part IA Flood Warning System ***")
run()
| 21.631579 | 67 | 0.686131 | 54 | 411 | 4.888889 | 0.611111 | 0.113636 | 0.181818 | 0.242424 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00304 | 0.199513 | 411 | 18 | 68 | 22.833333 | 0.799392 | 0 | 0 | 0 | 0 | 0 | 0.141463 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.083333 | false | 0 | 0.166667 | 0 | 0.25 | 0.166667 | 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 | 0 | 0 | 0 | 0 | 2 |
15ef60595795d41ff43b512f6c61622ff5aa9a68 | 346 | py | Python | vvs_data/pimpNumbers.py | acmngmbh/metaEFA | 9f0b448647571808f0982f1b1fd364bb8d1997a0 | [
"MIT"
] | 27 | 2015-06-07T15:27:36.000Z | 2021-02-09T09:12:30.000Z | vvs_data/pimpNumbers.py | acmngmbh/metaEFA | 9f0b448647571808f0982f1b1fd364bb8d1997a0 | [
"MIT"
] | 17 | 2015-06-06T23:06:52.000Z | 2020-10-13T12:47:56.000Z | vvs_data/pimpNumbers.py | acmngmbh/metaEFA | 9f0b448647571808f0982f1b1fd364bb8d1997a0 | [
"MIT"
] | 12 | 2015-09-22T16:45:04.000Z | 2022-01-08T16:06:19.000Z | f = open("HaltestellenVVS_simplified_utf8.csv", "r")
r = open("HaltestellenVVS_simplified_utf8_stationID.csv", "w")
r.write(f.readline())
lines = f.readlines()
for line in lines:
stationID = line.split(",")[0]
newStationID = int(stationID)+5000000
outLine = str(newStationID) + line[len(stationID):]
r.write(outLine)
r.close()
f.close()
| 21.625 | 62 | 0.713873 | 47 | 346 | 5.148936 | 0.531915 | 0.157025 | 0.239669 | 0.272727 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032573 | 0.112717 | 346 | 15 | 63 | 23.066667 | 0.7557 | 0 | 0 | 0 | 0 | 0 | 0.239884 | 0.231214 | 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 | 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 | 2 |
15fecc775b5dd5739ce5cd955e567720f0753cb0 | 1,659 | py | Python | lib/extensions/add_sidebar/script.py | neurodiverseEsoteric/nimbus | a79a37d6001d84116831c9f3f99f5d9acfa7fd19 | [
"CC-BY-3.0"
] | 3 | 2015-11-04T10:48:12.000Z | 2020-07-12T06:46:27.000Z | lib/extensions/add_sidebar/script.py | esotericDisciple/nimbus | a79a37d6001d84116831c9f3f99f5d9acfa7fd19 | [
"CC-BY-3.0"
] | null | null | null | lib/extensions/add_sidebar/script.py | esotericDisciple/nimbus | a79a37d6001d84116831c9f3f99f5d9acfa7fd19 | [
"CC-BY-3.0"
] | 1 | 2021-05-05T13:56:49.000Z | 2021-05-05T13:56:49.000Z | name = QInputDialog.getText(self, "Name", "Enter the name of your sidebar here:")
if name[1]:
name = name[0]
url = QInputDialog.getText(self, "URL", "Enter the URL of your sidebar here:")
if url[1]:
url = url[0]
common.sidebar_maker_path = os.path.join(settings.extensions_folder, name.lower().replace(" ", "_") + "_sidebar")
if not os.path.exists(common.sidebar_maker_path):
os.mkdir(common.sidebar_maker_path)
common.sidebar_maker_icon_loader = WebView(None)
common.sidebar_maker_icon_loader.load(QUrl(url))
common.sidebar_maker_icon_loader.iconChanged.connect(lambda: common.sidebar_maker_icon_loader.icon().pixmap(16, 16).save(os.path.join(common.sidebar_maker_path, "icon.png")))
common.sidebar_maker_icon_loader.iconChanged.connect(common.sidebar_maker_icon_loader.deleteLater)
try: f = open(os.path.join(common.sidebar_maker_path, "script.py"), "w")
except: pass
else:
try: f.write("""name = "%(name)s"
url = "%(url)s"
clip = "%(clip)s"
ua = "Mozilla/5.0 (Linux; U; Android 2.3.5; en-us) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
style1 = os.path.join(settings.extensions_folder, self.name, "style.css")
style = style1 if os.path.isfile(style1) else None
if not self.isCheckable():
self.setCheckable(True)
self.setChecked(True)
if not self.parentWindow().hasSideBar(name):
self.parentWindow().addSideBar(name, url, clip, ua, style=style)
else:
self.parentWindow().toggleSideBar(name)""" % {"name": name, "url": url, "clip": url.split(".")[1]})
except: pass
f.close()
| 51.84375 | 182 | 0.677517 | 235 | 1,659 | 4.646809 | 0.365957 | 0.130952 | 0.181319 | 0.120879 | 0.384615 | 0.205128 | 0.142857 | 0 | 0 | 0 | 0 | 0.019579 | 0.168776 | 1,659 | 31 | 183 | 53.516129 | 0.772299 | 0 | 0 | 0.129032 | 0 | 0.064516 | 0.398433 | 0.131404 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.064516 | 0 | 0 | 0 | 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 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
c60c6adc315bdabfe47f6496bd55d19acfacb60b | 228 | py | Python | scripts/NavPy/wgs84.py | AuraUAS/aura-core | 4711521074db72ba9089213e14455d89dc5306c0 | [
"MIT",
"BSD-2-Clause-FreeBSD"
] | 8 | 2016-08-03T19:35:03.000Z | 2019-12-15T06:25:05.000Z | scripts/NavPy/wgs84.py | jarilq/aura-core | 7880ed265396bf8c89b783835853328e6d7d1589 | [
"MIT",
"BSD-2-Clause-FreeBSD"
] | 4 | 2018-09-27T15:48:56.000Z | 2018-11-05T12:38:10.000Z | scripts/NavPy/wgs84.py | jarilq/aura-core | 7880ed265396bf8c89b783835853328e6d7d1589 | [
"MIT",
"BSD-2-Clause-FreeBSD"
] | 5 | 2017-06-28T19:15:36.000Z | 2020-02-19T19:31:24.000Z | """
WGS84 constants
Reference:
Paul Groves
http://www.oosa.unvienna.org/pdf/icg/2012/template/WGS_84.pdf
"""
R0 = 6378137.0
f = 298.257223563
omega_E = 7.2921151467e-5
GM = 3.986005e14
ecc = 0.0818191908425
Rp = 6356752.314245 | 16.285714 | 61 | 0.741228 | 37 | 228 | 4.513514 | 0.945946 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.383085 | 0.118421 | 228 | 14 | 62 | 16.285714 | 0.447761 | 0.438596 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c61050d700c49239f732a45d165297820f507473 | 252 | py | Python | eetfestijn/urls.py | thaliawww/eetFestijn | 6da04cb626f66b3aef55dbea6ca690ced674dd8f | [
"CC0-1.0"
] | 1 | 2018-10-11T16:46:40.000Z | 2018-10-11T16:46:40.000Z | eetfestijn/urls.py | thaliawww/eetFestijn | 6da04cb626f66b3aef55dbea6ca690ced674dd8f | [
"CC0-1.0"
] | 47 | 2018-06-11T13:55:41.000Z | 2019-10-23T19:29:37.000Z | eetfestijn/urls.py | thaliawww/eetFestijn | 6da04cb626f66b3aef55dbea6ca690ced674dd8f | [
"CC0-1.0"
] | null | null | null | from django.conf.urls import include
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
path('wiebetaaltwat/', include('wiebetaaltwat.urls')),
path('', include('orders.urls')),
]
| 25.2 | 58 | 0.706349 | 31 | 252 | 5.741935 | 0.419355 | 0.168539 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.138889 | 252 | 9 | 59 | 28 | 0.820277 | 0 | 0 | 0 | 0 | 0 | 0.194444 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.375 | 0 | 0.375 | 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 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
c6123110a11c361c9b8b888f57e546575e2ba621 | 1,190 | py | Python | tests/python/interface_spec_parser.py | tblink-rpc/tblink-rpc-core | 4daac39138930a726014914952047708162c3451 | [
"Apache-2.0"
] | 1 | 2022-03-30T11:58:00.000Z | 2022-03-30T11:58:00.000Z | tests/python/interface_spec_parser.py | tblink-rpc/tblink-rpc-core | 4daac39138930a726014914952047708162c3451 | [
"Apache-2.0"
] | null | null | null | tests/python/interface_spec_parser.py | tblink-rpc/tblink-rpc-core | 4daac39138930a726014914952047708162c3451 | [
"Apache-2.0"
] | null | null | null | '''
Created on Oct 16, 2021
@author: mballance
'''
import yaml
from unittest.case import TestCase
from _io import StringIO
from tblink_rpc.yaml_idl_parser import YamlIDLParser
class InterfaceSpecParser(TestCase):
def test_smoke(self):
spec = """
interface-types:
- my_if1:
methods:
- a:
is-export: True
is-blocking: True
returns: uint16
parameters:
- a: uint32
- a: uint64
- b:
is-export: False
is-blocking: True
- my_if2:
methods:
- a:
is-export: True
is-blocking: True
returns: uint32
parameters:
- b:
is-export: False
is-blocking: True
"""
in_d = StringIO(spec)
YamlIDLParser().parse(in_d)
pass | 25.319149 | 52 | 0.37563 | 89 | 1,190 | 4.921348 | 0.550562 | 0.073059 | 0.127854 | 0.073059 | 0.315068 | 0.315068 | 0.315068 | 0.187215 | 0.187215 | 0 | 0 | 0.030829 | 0.563866 | 1,190 | 47 | 53 | 25.319149 | 0.813102 | 0.036134 | 0 | 0.470588 | 0 | 0 | 0.69386 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.029412 | false | 0.029412 | 0.117647 | 0 | 0.176471 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c613462b79d1e9e0120f79d43ba863f0e76dca92 | 2,081 | py | Python | tests/test_queryable_intersect.py | dlshriver/Queryable | 0975f2687213958121ea4ac7efbaee9030193917 | [
"MIT"
] | 5 | 2016-04-04T16:49:11.000Z | 2020-10-12T13:00:06.000Z | tests/test_queryable_intersect.py | dlshriver/Queryable | 0975f2687213958121ea4ac7efbaee9030193917 | [
"MIT"
] | 3 | 2016-04-08T16:13:54.000Z | 2022-02-03T15:23:48.000Z | tests/test_queryable_intersect.py | dlshriver/pinq | 0975f2687213958121ea4ac7efbaee9030193917 | [
"MIT"
] | null | null | null | import unittest
import pinq
class queryable_intersect_tests(unittest.TestCase):
def setUp(self):
self.queryable1 = pinq.as_queryable(range(1, 11))
self.queryable2 = pinq.as_queryable(range(3, 8, 2))
self.queryable3 = pinq.as_queryable(range(100, 110))
self.queryable4 = pinq.as_queryable(
list(range(3, 8, 2)) + list(range(3, 8, 2)))
def test_intersect_some(self):
self.assertEqual(
list(self.queryable1.intersect(self.queryable2)), [3, 5, 7])
self.assertEqual(
list(self.queryable2.intersect(self.queryable1)), [3, 5, 7])
def test_intersect_all(self):
self.assertEqual(
list(self.queryable2.intersect(self.queryable2)), [3, 5, 7])
def test_intersect_none(self):
self.assertEqual(
list(self.queryable1.intersect(self.queryable3)), [])
def test_intersect_multiple_values(self):
self.assertEqual(
list(self.queryable1.intersect(self.queryable4)), [3, 5, 7])
self.assertEqual(
list(self.queryable4.intersect(self.queryable1)), [3, 5, 7])
self.assertEqual(
list(self.queryable4.intersect(self.queryable4)), [3, 5, 7])
def test_intersect_some_with_key_selector(self):
self.assertEqual(
list(self.queryable1.intersect(self.queryable2, lambda x: x % 2)), [1])
self.assertEqual(
list(self.queryable2.intersect(self.queryable1, lambda x: x % 2)), [3])
def test_intersect_all_with_key_selector(self):
self.assertEqual(
list(self.queryable2.intersect(self.queryable2, lambda x: x * 2)), [3, 5, 7])
def test_intersect_none_with_key_selector(self):
self.assertEqual(
list(self.queryable1.intersect(self.queryable3, lambda x: x * 2)), [])
def test_intersect_other_type_error(self):
self.assertRaises(TypeError, self.queryable1.intersect, 1000)
def test_intersect_key_selector_type_error(self):
self.assertRaises(TypeError, self.queryable1.intersect, [1, 5], 100)
| 37.836364 | 89 | 0.654012 | 256 | 2,081 | 5.164063 | 0.175781 | 0.11649 | 0.158094 | 0.191377 | 0.723147 | 0.697428 | 0.645991 | 0.59531 | 0.461422 | 0.172466 | 0 | 0.050462 | 0.219125 | 2,081 | 54 | 90 | 38.537037 | 0.763077 | 0 | 0 | 0.261905 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.309524 | 1 | 0.238095 | false | 0 | 0.047619 | 0 | 0.309524 | 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 | 0 | 0 | 0 | 0 | 2 |
c616226388b3b622add402bfb1b5729dae3ebae0 | 8,546 | py | Python | gjobs/bjobs_fields.py | vvolhejn/gjobs | e24270ed06ee4a57d72d7fc474b92b460d85caa3 | [
"MIT"
] | null | null | null | gjobs/bjobs_fields.py | vvolhejn/gjobs | e24270ed06ee4a57d72d7fc474b92b460d85caa3 | [
"MIT"
] | 3 | 2022-03-29T11:54:31.000Z | 2022-03-29T11:54:59.000Z | gjobs/bjobs_fields.py | vvolhejn/gjobs | e24270ed06ee4a57d72d7fc474b92b460d85caa3 | [
"MIT"
] | null | null | null | # Parsed from https://www.ibm.com/docs/en/spectrum-lsf/10.1.0?topic=options-o
bjobs_fields = [
{"name": "jobid", "width": 7, "aliases": "id", "unit": None},
{"name": "jobindex", "width": 8, "aliases": None, "unit": None},
{"name": "stat", "width": 5, "aliases": None, "unit": None},
{"name": "user", "width": 7, "aliases": None, "unit": None},
{"name": "user_group", "width": 15, "aliases": "ugroup", "unit": None},
{"name": "queue", "width": 10, "aliases": None, "unit": None},
{"name": "job_name", "width": 10, "aliases": "name", "unit": None},
{"name": "job_description", "width": 17, "aliases": "description", "unit": None},
{"name": "proj_name", "width": 11, "aliases": "proj, project", "unit": None},
{"name": "application", "width": 13, "aliases": "app", "unit": None},
{"name": "service_class", "width": 13, "aliases": "sla", "unit": None},
{"name": "job_group", "width": 10, "aliases": "group", "unit": None},
{"name": "job_priority", "width": 12, "aliases": "priority", "unit": None},
{"name": "rsvid", "width": 40, "aliases": None, "unit": None},
{"name": "esub", "width": 20, "aliases": None, "unit": None},
{"name": "kill_reason", "width": 50, "aliases": None, "unit": None},
{"name": "suspend_reason", "width": 50, "aliases": None, "unit": None},
{"name": "resume_reason", "width": 50, "aliases": None, "unit": None},
{"name": "kill_issue_host", "width": 50, "aliases": None, "unit": None},
{"name": "suspend_issue_host", "width": 50, "aliases": None, "unit": None},
{"name": "resume_issue_host", "width": 50, "aliases": None, "unit": None},
{"name": "dependency", "width": 15, "aliases": None, "unit": None},
{"name": "pend_reason", "width": 11, "aliases": None, "unit": None},
{"name": "charged_saap", "width": 50, "aliases": "saap", "unit": None},
{"name": "command", "width": 15, "aliases": "cmd", "unit": None},
{"name": "pre_exec_command", "width": 16, "aliases": "pre_cmd", "unit": None},
{"name": "post_exec_command", "width": 17, "aliases": "post_cmd", "unit": None},
{
"name": "resize_notification_command",
"width": 27,
"aliases": "resize_cmd",
"unit": None,
},
{"name": "pids", "width": 20, "aliases": None, "unit": None},
{"name": "exit_code", "width": 10, "aliases": None, "unit": None},
{"name": "exit_reason", "width": 50, "aliases": None, "unit": None},
{"name": "interactive", "width": 11, "aliases": None, "unit": None},
{"name": "from_host", "width": 11, "aliases": None, "unit": None},
{"name": "first_host", "width": 11, "aliases": None, "unit": None},
{"name": "exec_host", "width": 11, "aliases": None, "unit": None},
{"name": "nexec_host", "width": 10, "aliases": None, "unit": None},
{"name": "ask_hosts", "width": 30, "aliases": None, "unit": None},
{"name": "alloc_slot", "width": 20, "aliases": None, "unit": None},
{"name": "nalloc_slot", "width": 10, "aliases": None, "unit": None},
{"name": "host_file", "width": 10, "aliases": None, "unit": None},
{"name": "exclusive", "width": 13, "aliases": None, "unit": None},
{"name": "nreq_slot", "width": 10, "aliases": None, "unit": None},
{"name": "submit_time", "width": 15, "aliases": None, "unit": "time stamp"},
{"name": "start_time", "width": 15, "aliases": None, "unit": "time stamp"},
{
"name": "estimated_start_time",
"width": 20,
"aliases": "estart_time",
"unit": "time stamp",
},
{
"name": "specified_start_time",
"width": 20,
"aliases": "sstart_time",
"unit": "time stamp",
},
{
"name": "specified_terminate_time",
"width": 24,
"aliases": "sterminate_time",
"unit": "time stamp",
},
{"name": "time_left", "width": 11, "aliases": None, "unit": "seconds"},
{"name": "finish_time", "width": 16, "aliases": None, "unit": "time stamp"},
{"name": "estimated_run_time", "width": 20, "aliases": "ertime", "unit": "seconds"},
{"name": "ru_utime", "width": 12, "aliases": None, "unit": "seconds"},
{"name": "ru_stime", "width": 12, "aliases": None, "unit": "seconds"},
{"name": "%complete", "width": 11, "aliases": None, "unit": None},
{"name": "warning_action", "width": 15, "aliases": "warn_act", "unit": None},
{"name": "action_warning_time", "width": 19, "aliases": "warn_time", "unit": None},
{"name": "pendstate", "width": 9, "aliases": None, "unit": None},
{"name": "pend_time", "width": 12, "aliases": None, "unit": "seconds"},
{"name": "ependtime", "width": 12, "aliases": None, "unit": "seconds"},
{"name": "ipendtime", "width": 12, "aliases": None, "unit": "seconds"},
{
"name": "estimated_sim_start_time",
"width": 24,
"aliases": "esstart_time",
"unit": "time stamp",
},
{"name": "effective_plimit", "width": 18, "aliases": None, "unit": "seconds"},
{"name": "plimit_remain", "width": 15, "aliases": None, "unit": "seconds"},
{"name": "effective_eplimit", "width": 19, "aliases": None, "unit": "seconds"},
{"name": "eplimit_remain", "width": 16, "aliases": None, "unit": "seconds"},
{"name": "cpu_used", "width": 10, "aliases": None, "unit": None},
{"name": "run_time", "width": 15, "aliases": None, "unit": "seconds"},
{"name": "idle_factor", "width": 11, "aliases": None, "unit": None},
{"name": "exception_status", "width": 16, "aliases": "except_stat", "unit": None},
{"name": "slots", "width": 5, "aliases": None, "unit": None},
{"name": "mem", "width": 15, "aliases": None, "unit": "LSF_UNIT_FOR_LIMITS"},
{"name": "max_mem", "width": 15, "aliases": None, "unit": "LSF_UNIT_FOR_LIMITS"},
{"name": "avg_mem", "width": 15, "aliases": None, "unit": "LSF_UNIT_FOR_LIMITS"},
{"name": "memlimit", "width": 15, "aliases": None, "unit": "LSF_UNIT_FOR_LIMITS"},
{"name": "swap", "width": 15, "aliases": None, "unit": "LSF_UNIT_FOR_LIMITS"},
{"name": "swaplimit", "width": 15, "aliases": None, "unit": "LSF_UNIT_FOR_LIMITS"},
{"name": "gpu_num", "width": 10, "aliases": "gnum", "unit": None},
{"name": "gpu_mode", "width": 20, "aliases": "gmode", "unit": None},
{"name": "j_exclusive", "width": 15, "aliases": "j_excl", "unit": None},
{"name": "gpu_alloc", "width": 30, "aliases": "galloc", "unit": None},
{"name": "nthreads", "width": 10, "aliases": None, "unit": None},
{"name": "hrusage", "width": 50, "aliases": None, "unit": None},
{"name": "min_req_proc", "width": 12, "aliases": None, "unit": None},
{"name": "max_req_proc", "width": 12, "aliases": None, "unit": None},
{"name": "effective_resreq", "width": 17, "aliases": "eresreq", "unit": None},
{"name": "combined_resreq", "width": 20, "aliases": "cresreq", "unit": None},
{"name": "network_req", "width": 15, "aliases": None, "unit": None},
{"name": "filelimit", "width": 10, "aliases": None, "unit": None},
{"name": "corelimit", "width": 15, "aliases": None, "unit": None},
{"name": "stacklimit", "width": 15, "aliases": None, "unit": None},
{"name": "processlimit", "width": 12, "aliases": None, "unit": None},
{"name": "runtimelimit", "width": 12, "aliases": None, "unit": None},
{"name": "plimit", "width": 10, "aliases": None, "unit": "seconds"},
{"name": "eplimit", "width": 10, "aliases": None, "unit": "seconds"},
{"name": "input_file", "width": 10, "aliases": None, "unit": None},
{"name": "output_file", "width": 11, "aliases": None, "unit": None},
{"name": "error_file", "width": 10, "aliases": None, "unit": None},
{"name": "output_dir", "width": 15, "aliases": None, "unit": None},
{"name": "sub_cwd", "width": 10, "aliases": None, "unit": None},
{"name": "exec_home", "width": 10, "aliases": None, "unit": None},
{"name": "exec_cwd", "width": 10, "aliases": None, "unit": None},
{"name": "licproject", "width": 20, "aliases": None, "unit": None},
{"name": "forward_cluster", "width": 15, "aliases": "fwd_cluster", "unit": None},
{"name": "forward_time", "width": 15, "aliases": "fwd_time", "unit": "time stamp"},
{"name": "srcjobid", "width": 8, "aliases": None, "unit": None},
{"name": "dstjobid", "width": 8, "aliases": None, "unit": None},
{"name": "source_cluster", "width": 15, "aliases": "srcluster", "unit": None},
{"name": "energy", "width": None, "aliases": None, "unit": "Joule"},
{"name": "gpfsio", "width": None, "aliases": None, "unit": None},
]
| 62.379562 | 88 | 0.554294 | 1,009 | 8,546 | 4.576809 | 0.179386 | 0.136856 | 0.202685 | 0.222174 | 0.601343 | 0.530966 | 0.490689 | 0.2356 | 0.132092 | 0.056518 | 0 | 0.029533 | 0.175872 | 8,546 | 136 | 89 | 62.838235 | 0.626154 | 0.008776 | 0 | 0.059259 | 0 | 0 | 0.453655 | 0.008856 | 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 | 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 | 2 |
c6205be2cfa6b29fe60a594c75286d9d4a14ee43 | 534 | py | Python | catalogo/views/empleado_view.py | lp2-20172/polleria-serve | 5383f4d1db46e4d41789b5773ee5383005687b45 | [
"MIT"
] | null | null | null | catalogo/views/empleado_view.py | lp2-20172/polleria-serve | 5383f4d1db46e4d41789b5773ee5383005687b45 | [
"MIT"
] | 2 | 2020-02-12T00:19:17.000Z | 2020-06-05T18:06:26.000Z | catalogo/views/empleado_view.py | Chapi69/Server | d726a2ca04b792bf54457da1e591afcb4ed63a2f | [
"MIT"
] | null | null | null | from ..models_raiz import Empleado
from rest_framework import serializers, viewsets
from rest_framework import permissions
from django.db.models import Q
from operator import __or__ as OR
from functools import reduce
class EmpleadoSerializer(serializers.ModelSerializer):
class Meta:
model = Empleado
fields = '__all__'
#fields = ('id', 'username', 'email', 'is_staff')
class EmpleadoViewSet(viewsets.ModelViewSet):
queryset = Empleado.objects.all()
serializer_class = EmpleadoSerializer
| 25.428571 | 57 | 0.745318 | 59 | 534 | 6.525424 | 0.59322 | 0.041558 | 0.088312 | 0.119481 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.181648 | 534 | 20 | 58 | 26.7 | 0.881007 | 0.089888 | 0 | 0 | 0 | 0 | 0.014433 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.461538 | 0 | 0.846154 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
c62c40b4b8384326bc3d93d07755839014c02a9e | 14,534 | py | Python | src/hedera_proto/custom_fees_pb2.py | HbarStudio/hedera-protobufs-python | f8a503d2c4c5b7c441ddf48607f7ee563b3f931a | [
"Apache-2.0"
] | null | null | null | src/hedera_proto/custom_fees_pb2.py | HbarStudio/hedera-protobufs-python | f8a503d2c4c5b7c441ddf48607f7ee563b3f931a | [
"Apache-2.0"
] | null | null | null | src/hedera_proto/custom_fees_pb2.py | HbarStudio/hedera-protobufs-python | f8a503d2c4c5b7c441ddf48607f7ee563b3f931a | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: custom_fees.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
import basic_types_pb2 as basic__types__pb2
DESCRIPTOR = _descriptor.FileDescriptor(
name='custom_fees.proto',
package='proto',
syntax='proto3',
serialized_options=b'\n\"com.hederahashgraph.api.proto.javaP\001',
create_key=_descriptor._internal_create_key,
serialized_pb=b'\n\x11\x63ustom_fees.proto\x12\x05proto\x1a\x11\x62\x61sic_types.proto\"\x85\x01\n\rFractionalFee\x12*\n\x11\x66ractional_amount\x18\x01 \x01(\x0b\x32\x0f.proto.Fraction\x12\x16\n\x0eminimum_amount\x18\x02 \x01(\x03\x12\x16\n\x0emaximum_amount\x18\x03 \x01(\x03\x12\x18\n\x10net_of_transfers\x18\x04 \x01(\x08\"I\n\x08\x46ixedFee\x12\x0e\n\x06\x61mount\x18\x01 \x01(\x03\x12-\n\x15\x64\x65nominating_token_id\x18\x02 \x01(\x0b\x32\x0e.proto.TokenID\"e\n\nRoyaltyFee\x12\x30\n\x17\x65xchange_value_fraction\x18\x01 \x01(\x0b\x32\x0f.proto.Fraction\x12%\n\x0c\x66\x61llback_fee\x18\x02 \x01(\x0b\x32\x0f.proto.FixedFee\"\xc6\x01\n\tCustomFee\x12$\n\tfixed_fee\x18\x01 \x01(\x0b\x32\x0f.proto.FixedFeeH\x00\x12.\n\x0e\x66ractional_fee\x18\x02 \x01(\x0b\x32\x14.proto.FractionalFeeH\x00\x12(\n\x0broyalty_fee\x18\x04 \x01(\x0b\x32\x11.proto.RoyaltyFeeH\x00\x12\x32\n\x18\x66\x65\x65_collector_account_id\x18\x03 \x01(\x0b\x32\x10.proto.AccountIDB\x05\n\x03\x66\x65\x65\"\xaf\x01\n\x11\x41ssessedCustomFee\x12\x0e\n\x06\x61mount\x18\x01 \x01(\x03\x12 \n\x08token_id\x18\x02 \x01(\x0b\x32\x0e.proto.TokenID\x12\x32\n\x18\x66\x65\x65_collector_account_id\x18\x03 \x01(\x0b\x32\x10.proto.AccountID\x12\x34\n\x1a\x65\x66\x66\x65\x63tive_payer_account_id\x18\x04 \x03(\x0b\x32\x10.proto.AccountIDB&\n\"com.hederahashgraph.api.proto.javaP\x01\x62\x06proto3'
,
dependencies=[basic__types__pb2.DESCRIPTOR,])
_FRACTIONALFEE = _descriptor.Descriptor(
name='FractionalFee',
full_name='proto.FractionalFee',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='fractional_amount', full_name='proto.FractionalFee.fractional_amount', index=0,
number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='minimum_amount', full_name='proto.FractionalFee.minimum_amount', index=1,
number=2, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='maximum_amount', full_name='proto.FractionalFee.maximum_amount', index=2,
number=3, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='net_of_transfers', full_name='proto.FractionalFee.net_of_transfers', index=3,
number=4, type=8, cpp_type=7, label=1,
has_default_value=False, default_value=False,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=48,
serialized_end=181,
)
_FIXEDFEE = _descriptor.Descriptor(
name='FixedFee',
full_name='proto.FixedFee',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='amount', full_name='proto.FixedFee.amount', index=0,
number=1, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='denominating_token_id', full_name='proto.FixedFee.denominating_token_id', index=1,
number=2, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=183,
serialized_end=256,
)
_ROYALTYFEE = _descriptor.Descriptor(
name='RoyaltyFee',
full_name='proto.RoyaltyFee',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='exchange_value_fraction', full_name='proto.RoyaltyFee.exchange_value_fraction', index=0,
number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='fallback_fee', full_name='proto.RoyaltyFee.fallback_fee', index=1,
number=2, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=258,
serialized_end=359,
)
_CUSTOMFEE = _descriptor.Descriptor(
name='CustomFee',
full_name='proto.CustomFee',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='fixed_fee', full_name='proto.CustomFee.fixed_fee', index=0,
number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='fractional_fee', full_name='proto.CustomFee.fractional_fee', index=1,
number=2, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='royalty_fee', full_name='proto.CustomFee.royalty_fee', index=2,
number=4, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='fee_collector_account_id', full_name='proto.CustomFee.fee_collector_account_id', index=3,
number=3, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
_descriptor.OneofDescriptor(
name='fee', full_name='proto.CustomFee.fee',
index=0, containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[]),
],
serialized_start=362,
serialized_end=560,
)
_ASSESSEDCUSTOMFEE = _descriptor.Descriptor(
name='AssessedCustomFee',
full_name='proto.AssessedCustomFee',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='amount', full_name='proto.AssessedCustomFee.amount', index=0,
number=1, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='token_id', full_name='proto.AssessedCustomFee.token_id', index=1,
number=2, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='fee_collector_account_id', full_name='proto.AssessedCustomFee.fee_collector_account_id', index=2,
number=3, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='effective_payer_account_id', full_name='proto.AssessedCustomFee.effective_payer_account_id', index=3,
number=4, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=563,
serialized_end=738,
)
_FRACTIONALFEE.fields_by_name['fractional_amount'].message_type = basic__types__pb2._FRACTION
_FIXEDFEE.fields_by_name['denominating_token_id'].message_type = basic__types__pb2._TOKENID
_ROYALTYFEE.fields_by_name['exchange_value_fraction'].message_type = basic__types__pb2._FRACTION
_ROYALTYFEE.fields_by_name['fallback_fee'].message_type = _FIXEDFEE
_CUSTOMFEE.fields_by_name['fixed_fee'].message_type = _FIXEDFEE
_CUSTOMFEE.fields_by_name['fractional_fee'].message_type = _FRACTIONALFEE
_CUSTOMFEE.fields_by_name['royalty_fee'].message_type = _ROYALTYFEE
_CUSTOMFEE.fields_by_name['fee_collector_account_id'].message_type = basic__types__pb2._ACCOUNTID
_CUSTOMFEE.oneofs_by_name['fee'].fields.append(
_CUSTOMFEE.fields_by_name['fixed_fee'])
_CUSTOMFEE.fields_by_name['fixed_fee'].containing_oneof = _CUSTOMFEE.oneofs_by_name['fee']
_CUSTOMFEE.oneofs_by_name['fee'].fields.append(
_CUSTOMFEE.fields_by_name['fractional_fee'])
_CUSTOMFEE.fields_by_name['fractional_fee'].containing_oneof = _CUSTOMFEE.oneofs_by_name['fee']
_CUSTOMFEE.oneofs_by_name['fee'].fields.append(
_CUSTOMFEE.fields_by_name['royalty_fee'])
_CUSTOMFEE.fields_by_name['royalty_fee'].containing_oneof = _CUSTOMFEE.oneofs_by_name['fee']
_ASSESSEDCUSTOMFEE.fields_by_name['token_id'].message_type = basic__types__pb2._TOKENID
_ASSESSEDCUSTOMFEE.fields_by_name['fee_collector_account_id'].message_type = basic__types__pb2._ACCOUNTID
_ASSESSEDCUSTOMFEE.fields_by_name['effective_payer_account_id'].message_type = basic__types__pb2._ACCOUNTID
DESCRIPTOR.message_types_by_name['FractionalFee'] = _FRACTIONALFEE
DESCRIPTOR.message_types_by_name['FixedFee'] = _FIXEDFEE
DESCRIPTOR.message_types_by_name['RoyaltyFee'] = _ROYALTYFEE
DESCRIPTOR.message_types_by_name['CustomFee'] = _CUSTOMFEE
DESCRIPTOR.message_types_by_name['AssessedCustomFee'] = _ASSESSEDCUSTOMFEE
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
FractionalFee = _reflection.GeneratedProtocolMessageType('FractionalFee', (_message.Message,), {
'DESCRIPTOR' : _FRACTIONALFEE,
'__module__' : 'custom_fees_pb2'
# @@protoc_insertion_point(class_scope:proto.FractionalFee)
})
_sym_db.RegisterMessage(FractionalFee)
FixedFee = _reflection.GeneratedProtocolMessageType('FixedFee', (_message.Message,), {
'DESCRIPTOR' : _FIXEDFEE,
'__module__' : 'custom_fees_pb2'
# @@protoc_insertion_point(class_scope:proto.FixedFee)
})
_sym_db.RegisterMessage(FixedFee)
RoyaltyFee = _reflection.GeneratedProtocolMessageType('RoyaltyFee', (_message.Message,), {
'DESCRIPTOR' : _ROYALTYFEE,
'__module__' : 'custom_fees_pb2'
# @@protoc_insertion_point(class_scope:proto.RoyaltyFee)
})
_sym_db.RegisterMessage(RoyaltyFee)
CustomFee = _reflection.GeneratedProtocolMessageType('CustomFee', (_message.Message,), {
'DESCRIPTOR' : _CUSTOMFEE,
'__module__' : 'custom_fees_pb2'
# @@protoc_insertion_point(class_scope:proto.CustomFee)
})
_sym_db.RegisterMessage(CustomFee)
AssessedCustomFee = _reflection.GeneratedProtocolMessageType('AssessedCustomFee', (_message.Message,), {
'DESCRIPTOR' : _ASSESSEDCUSTOMFEE,
'__module__' : 'custom_fees_pb2'
# @@protoc_insertion_point(class_scope:proto.AssessedCustomFee)
})
_sym_db.RegisterMessage(AssessedCustomFee)
DESCRIPTOR._options = None
# @@protoc_insertion_point(module_scope)
| 43.255952 | 1,364 | 0.769093 | 1,868 | 14,534 | 5.605996 | 0.103319 | 0.041253 | 0.061688 | 0.059301 | 0.700344 | 0.643908 | 0.600076 | 0.59788 | 0.567513 | 0.554908 | 0 | 0.037422 | 0.111944 | 14,534 | 335 | 1,365 | 43.385075 | 0.773921 | 0.033852 | 0 | 0.635452 | 1 | 0.003344 | 0.211735 | 0.154416 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.016722 | 0 | 0.016722 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c63b6d0ba024409240dd7fb35b97a9201a619ff8 | 457 | py | Python | zoonado/recipes/data_watcher.py | hulu316/zoonado | cb06102f95e7da9c0e418bb9e327045e012a1497 | [
"Apache-2.0"
] | 12 | 2016-04-14T09:55:38.000Z | 2018-01-07T13:12:47.000Z | zoonado/recipes/data_watcher.py | hulu316/zoonado | cb06102f95e7da9c0e418bb9e327045e012a1497 | [
"Apache-2.0"
] | 16 | 2016-07-21T09:45:38.000Z | 2017-09-22T19:06:14.000Z | zoonado/recipes/data_watcher.py | hulu316/zoonado | cb06102f95e7da9c0e418bb9e327045e012a1497 | [
"Apache-2.0"
] | 8 | 2016-07-21T09:06:37.000Z | 2019-07-26T05:48:00.000Z | from __future__ import unicode_literals
import logging
from tornado import gen
from zoonado import WatchEvent
from .base_watcher import BaseWatcher
log = logging.getLogger(__name__)
class DataWatcher(BaseWatcher):
watched_event = WatchEvent.DATA_CHANGED
@gen.coroutine
def fetch(self, path):
log.debug("Fetching data for %s", path)
data = yield self.client.get_data(path=path, watch=True)
raise gen.Return(data)
| 19.869565 | 64 | 0.73523 | 59 | 457 | 5.474576 | 0.644068 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.190372 | 457 | 22 | 65 | 20.772727 | 0.872973 | 0 | 0 | 0 | 0 | 0 | 0.043764 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.076923 | false | 0 | 0.384615 | 0 | 0.615385 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
c63e015822304a9a3216ed85f6d9d0fa8cb6f285 | 219 | py | Python | hackerrank/Algorithms/Simple Array Sum/test.py | ATrain951/01.python-com_Qproject | c164dd093954d006538020bdf2e59e716b24d67c | [
"MIT"
] | 4 | 2020-07-24T01:59:50.000Z | 2021-07-24T15:14:08.000Z | hackerrank/Algorithms/Simple Array Sum/test.py | ATrain951/01.python-com_Qproject | c164dd093954d006538020bdf2e59e716b24d67c | [
"MIT"
] | null | null | null | hackerrank/Algorithms/Simple Array Sum/test.py | ATrain951/01.python-com_Qproject | c164dd093954d006538020bdf2e59e716b24d67c | [
"MIT"
] | null | null | null | import unittest
import solution
class TestQ(unittest.TestCase):
def test_case_0(self):
self.assertEqual(solution.simpleArraySum([1, 2, 3, 4, 10, 11]), 31)
if __name__ == '__main__':
unittest.main()
| 16.846154 | 75 | 0.680365 | 29 | 219 | 4.793103 | 0.793103 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.061798 | 0.187215 | 219 | 12 | 76 | 18.25 | 0.719101 | 0 | 0 | 0 | 0 | 0 | 0.03653 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 1 | 0.142857 | false | 0 | 0.285714 | 0 | 0.571429 | 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 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
c641a151c12f271332bb48dd1ad7c962ba022947 | 369 | py | Python | func.py | AI0702/Among-Us-clone | e75a1410c8bc9e82b41f2ab51deec373c8486e29 | [
"Unlicense"
] | null | null | null | func.py | AI0702/Among-Us-clone | e75a1410c8bc9e82b41f2ab51deec373c8486e29 | [
"Unlicense"
] | null | null | null | func.py | AI0702/Among-Us-clone | e75a1410c8bc9e82b41f2ab51deec373c8486e29 | [
"Unlicense"
] | null | null | null | def my_func():
print("Foo")
my_other_func = lambda: print("Bar")
my_arr = [my_func, my_other_func]
for i in range (0, 2):
my_arr[i]()
# Bots Position
BOT_POS = [(5401, 1530),(3686, 1857),(3733, 2626),(2325, 1814),
(1718, 1282),(1288, 2418),(1249, 506),(2513,1286)
]
print("\n")
for (x,y) in BOT_POS:
print(x, y)
| 19.421053 | 64 | 0.542005 | 58 | 369 | 3.275862 | 0.655172 | 0.063158 | 0.115789 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.238971 | 0.262873 | 369 | 18 | 65 | 20.5 | 0.459559 | 0.03523 | 0 | 0 | 0 | 0 | 0.02381 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.083333 | false | 0 | 0 | 0 | 0.083333 | 0.333333 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c646aa1ca48a5bb4215bc89581b1b1a6564c1162 | 165 | py | Python | narcy/nlp/tenses.py | sztal/narcy | 18bfdcfb691c3505384f452479dee5fb6c93321e | [
"MIT"
] | 13 | 2019-04-17T13:44:33.000Z | 2021-03-17T23:23:15.000Z | narcy/nlp/tenses.py | sztal/narcy | 18bfdcfb691c3505384f452479dee5fb6c93321e | [
"MIT"
] | 1 | 2019-03-17T16:29:14.000Z | 2019-03-17T16:29:14.000Z | narcy/nlp/tenses.py | sztal/narcy | 18bfdcfb691c3505384f452479dee5fb6c93321e | [
"MIT"
] | 1 | 2020-01-08T11:35:03.000Z | 2020-01-08T11:35:03.000Z | """Tense analysis and detection related utilities."""
# pylint: disable=E0611
PRESENT = 'PRESENT'
PAST = 'PAST'
FUTURE = 'FUTURE'
MODAL = 'MODAL'
NORMAL = 'NORMAL'
| 18.333333 | 53 | 0.69697 | 19 | 165 | 6.052632 | 0.736842 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.028571 | 0.151515 | 165 | 8 | 54 | 20.625 | 0.792857 | 0.424242 | 0 | 0 | 0 | 0 | 0.314607 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
c6571ded22006db289757c86ac6e6239df66a71c | 4,007 | py | Python | samples/openapi3/client/petstore/python-experimental/tests_manual/test_combine_schemas.py | chanjarster/openapi-generator | f92f8f1e58c59a429295509d8c5df32b100cde22 | [
"Apache-2.0"
] | 1 | 2022-01-11T15:49:34.000Z | 2022-01-11T15:49:34.000Z | samples/openapi3/client/petstore/python-experimental/tests_manual/test_combine_schemas.py | chanjarster/openapi-generator | f92f8f1e58c59a429295509d8c5df32b100cde22 | [
"Apache-2.0"
] | 9 | 2021-11-01T08:59:31.000Z | 2022-03-31T08:31:57.000Z | samples/openapi3/client/petstore/python-experimental/tests_manual/test_combine_schemas.py | chanjarster/openapi-generator | f92f8f1e58c59a429295509d8c5df32b100cde22 | [
"Apache-2.0"
] | 1 | 2022-03-20T14:46:48.000Z | 2022-03-20T14:46:48.000Z | # coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
import sys
import unittest
import petstore_api
from petstore_api.model.date_with_validations import DateWithValidations
from petstore_api.model.date_time_with_validations import DateTimeWithValidations
from petstore_api.model.string_with_validation import StringWithValidation
from petstore_api.model.integer_enum_one_value import IntegerEnumOneValue
from petstore_api.model.integer_enum import IntegerEnum
from petstore_api.model.integer_enum_big import IntegerEnumBig
from petstore_api.model.integer_max10 import IntegerMax10
from petstore_api.model.integer_min15 import IntegerMin15
from petstore_api.model.nullable_string import NullableString
from petstore_api.schemas import AnyTypeSchema, Schema, NoneSchema, StrSchema, none_type, Singleton
class TestCombineNonObjectSchemas(unittest.TestCase):
def test_valid_enum_plus_prim(self):
class EnumPlusPrim(IntegerMax10, IntegerEnumOneValue):
pass
assert EnumPlusPrim._enum_value_to_name == {0: "POSITIVE_0"}
# order of base classes does not matter
class EnumPlusPrim(IntegerEnumOneValue, IntegerMax10):
pass
assert EnumPlusPrim._enum_value_to_name == {0: "POSITIVE_0"}
# _enum_value_to_name only contains one key
assert set(EnumPlusPrim._enum_value_to_name) == {0}
# the value is the expected enum class
enum_value_cls = EnumPlusPrim._enum_by_value[0]
assert issubclass(enum_value_cls, EnumPlusPrim)
assert issubclass(enum_value_cls, Singleton)
assert issubclass(enum_value_cls, int)
# the enum stored in that class is expected
enum_value = enum_value_cls.POSITIVE_0
assert isinstance(enum_value, EnumPlusPrim)
assert isinstance(enum_value, Singleton)
assert isinstance(enum_value, int)
# we can access this enum from our class
assert EnumPlusPrim.POSITIVE_0 == enum_value
# invalid value throws an exception
with self.assertRaises(petstore_api.ApiValueError):
EnumPlusPrim(9)
# valid value succeeds
val = EnumPlusPrim(0)
assert val == 0
assert isinstance(val, EnumPlusPrim)
assert isinstance(val, Singleton)
assert isinstance(val, int)
def test_valid_enum_plus_enum(self):
class IntegerOneEnum(IntegerEnum, IntegerEnumOneValue):
pass
assert IntegerOneEnum._enum_value_to_name == {0: "POSITIVE_0"}
# order of base classes does not matter
class IntegerOneEnum(IntegerEnumOneValue, IntegerEnum):
pass
assert IntegerOneEnum._enum_value_to_name == {0: "POSITIVE_0"}
# _enum_by_value only contains one key
assert set(IntegerOneEnum._enum_by_value) == {0}
# the value is the expected enum class
enum_value_cls = IntegerOneEnum._enum_by_value[0]
assert issubclass(enum_value_cls, IntegerOneEnum)
assert issubclass(enum_value_cls, Singleton)
assert issubclass(enum_value_cls, int)
# the enum stored in that class is expected
enum_value = enum_value_cls.POSITIVE_0
assert isinstance(enum_value, IntegerOneEnum)
assert isinstance(enum_value, Singleton)
assert isinstance(enum_value, int)
# we can access this enum from our class
assert IntegerOneEnum.POSITIVE_0 == enum_value
# accessing invalid enum throws an exception
invalid_enums = ['POSITIVE_1', 'POSITIVE_2']
for invalid_enum in invalid_enums:
with self.assertRaises(petstore_api.ApiValueError):
getattr(IntegerOneEnum, invalid_enum)
if __name__ == '__main__':
unittest.main()
| 38.161905 | 174 | 0.724233 | 483 | 4,007 | 5.747412 | 0.26294 | 0.084294 | 0.054035 | 0.064842 | 0.501801 | 0.436599 | 0.342219 | 0.342219 | 0.339337 | 0.310519 | 0 | 0.012743 | 0.216621 | 4,007 | 104 | 175 | 38.528846 | 0.871615 | 0.19441 | 0 | 0.327869 | 0 | 0 | 0.021323 | 0 | 0 | 0 | 0 | 0 | 0.42623 | 1 | 0.032787 | false | 0.065574 | 0.213115 | 0 | 0.327869 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
d65dc8217315ef0721ac201a7040b03d51c328f4 | 15,399 | py | Python | ProjectApplication/grant_management/models.py | Swiss-Polar-Institute/project-application | 2fdc12378ca3d974bd4ac20cf9f56ff544058524 | [
"MIT"
] | 5 | 2020-07-29T10:00:11.000Z | 2022-02-19T11:00:34.000Z | ProjectApplication/grant_management/models.py | Swiss-Polar-Institute/project-application | 2fdc12378ca3d974bd4ac20cf9f56ff544058524 | [
"MIT"
] | 471 | 2019-09-20T14:37:28.000Z | 2022-03-25T14:16:34.000Z | ProjectApplication/grant_management/models.py | Swiss-Polar-Institute/project-application | 2fdc12378ca3d974bd4ac20cf9f56ff544058524 | [
"MIT"
] | 5 | 2020-03-15T12:42:47.000Z | 2022-02-15T18:06:52.000Z | from django.contrib.auth.models import User
from django.db import models, transaction
# Create your models here.
# add dates of review, signed date, who signed, grant agreement - need flexibilty in types of dates that are added
from django.db.models import Sum
from django.utils.datetime_safe import datetime
from simple_history.models import HistoricalRecords
from storages.backends.s3boto3 import S3Boto3Storage
from project_core.models import CreateModifyOn, PhysicalPerson, Project
from project_core.utils.utils import management_file_validator, calculate_md5_from_file_field
def grant_agreement_file_rename(instance, filename):
return f'grant_management/GrantAgreement/Project-{instance.project.key}-{filename}'
class GrantAgreement(CreateModifyOn):
project = models.OneToOneField(Project, help_text='Project this Grant Agreement belongs to',
on_delete=models.PROTECT)
signed_date = models.DateField(help_text='Date the grant agreement was signed', null=True, blank=True)
signed_by = models.ManyToManyField(PhysicalPerson, help_text='People who signed the grant agreement', blank=True)
file = models.FileField(storage=S3Boto3Storage(), upload_to=grant_agreement_file_rename,
validators=[*management_file_validator()])
def __str__(self):
return f'{self.project}'
def signed_by_string(self):
return ', '.join(
[f'{person.first_name} {person.surname}' for person in self.signed_by.all().order_by('first_name')])
@staticmethod
def comment_object():
from comments.models import GrantAgreementComment
return GrantAgreementComment
@staticmethod
def attachment_object():
from comments.models import GrantAgreementAttachment
return GrantAgreementAttachment
def attachments(self):
return self.grantagreementattachment_set.all().order_by('created_on')
def comments(self):
return self.grantagreementcomment_set.all().order_by('created_on')
class AbstractProjectDueReceivedDate(CreateModifyOn):
project = models.ForeignKey(Project, help_text='Abstract containing dates',
on_delete=models.PROTECT)
due_date = models.DateField(help_text='Date the document is due', null=True, blank=True)
received_date = models.DateField(help_text='Date the document was received', null=True, blank=True)
class Meta:
abstract = True
def __str__(self):
return f'{self.project}'
class Installment(CreateModifyOn):
project = models.ForeignKey(Project, help_text='Project that this installment refers to', on_delete=models.PROTECT)
amount = models.DecimalField(max_digits=11, decimal_places=2, help_text='Installment amount')
def __str__(self):
return f'{self.project}-{self.amount}'
def sent_for_payment(self):
return self.invoice_set.filter(sent_for_payment_date__isnull=False).aggregate(Sum('amount'))['amount__sum']
def paid(self):
return self.invoice_set.filter(paid_date__isnull=False).aggregate(Sum('amount'))['amount__sum']
def number(self):
# This is not very efficient, but given the number of invoices and installments it's nice to not have to
# save this in the database
installments = list(Installment.objects.filter(project=self.project).order_by('id'))
return installments.index(self) + 1
def invoice_file_rename(instance, filename):
return f'grant_management/Invoice/Project-{instance.project.key}-{filename}'
class Invoice(AbstractProjectDueReceivedDate):
sent_for_payment_date = models.DateField(help_text='Date the invoice was sent for payment', null=True, blank=True)
file = models.FileField(storage=S3Boto3Storage(), upload_to=invoice_file_rename, null=True,
validators=[*management_file_validator()],
blank=True)
paid_date = models.DateField(help_text='Date the invoice was paid', null=True, blank=True)
amount = models.DecimalField(max_digits=20, decimal_places=2, help_text='Total of the invoice (CHF)', null=True,
blank=True)
installment = models.ForeignKey(Installment, help_text='Installment to which the invoice is assigned', null=True,
blank=True, on_delete=models.PROTECT)
allow_overbudget = models.BooleanField(default=False, help_text='This invoice takes a payment overbudget')
overbudget_allowed_by = models.ForeignKey(User, null=True, blank=True, help_text='User that allowed the overbudget',
on_delete=models.PROTECT)
def __str__(self):
return f'Id: {self.id} Amount: {self.amount}'
@staticmethod
def comment_object():
from comments.models import InvoiceComment
return InvoiceComment
@staticmethod
def attachment_object():
return None
def installment_number(self):
# This is not very efficient, but given the number of invoices and installments it's nice to not have to
# save this in the database
if self.installment is None:
return None
return self.installment.number()
def due_date_passed(self):
return self.due_date and self.due_date < datetime.today().date() and self.paid_date is None
def negative(self):
return self.amount and self.amount < 0
def comments(self):
return self.invoicecomment_set.all().order_by('created_on')
def attachments(self):
return None
class AbstractProjectReport(AbstractProjectDueReceivedDate):
sent_for_approval_date = models.DateField(help_text='Date the report was sent for approval', null=True, blank=True)
approval_date = models.DateField(help_text='Date the report was approved',
blank=True, null=True)
approved_by = models.ForeignKey(PhysicalPerson, help_text='Person who approved the report',
on_delete=models.PROTECT, blank=True, null=True)
class Meta:
abstract = True
def due_date_passed(self):
return self.due_date and self.due_date < datetime.today().date() and self.approval_date is None
def finance_report_file_rename(instance, filename):
return f'grant_management/FinancialReport/Project-{instance.project.key}-{filename}'
class FinancialReport(AbstractProjectReport):
file = models.FileField(storage=S3Boto3Storage(), upload_to=finance_report_file_rename,
validators=[*management_file_validator()],
blank=True, null=True)
def scientific_report_file_rename(instance, filename):
return f'grant_management/ScientificReport/Project-{instance.project.key}-{filename}'
class ScientificReport(AbstractProjectReport):
file = models.FileField(storage=S3Boto3Storage(), upload_to=scientific_report_file_rename,
validators=[*management_file_validator()],
blank=True, null=True)
class LaySummaryType(CreateModifyOn):
name = models.CharField(max_length=10,
help_text='Type of lay summary which could be used within the application to decide how the'
' summary is used',
unique=True)
description = models.CharField(max_length=100, help_text='Description of the type of lay summary')
def __str__(self):
return self.name
class LaySummary(AbstractProjectDueReceivedDate):
text = models.TextField(help_text='Lay summary text', null=True, blank=True)
lay_summary_type = models.ForeignKey(LaySummaryType, help_text='Type of the lay summary', blank=True, null=True,
on_delete=models.PROTECT)
author = models.ForeignKey(PhysicalPerson, help_text='Person who wrote the lay summary',
blank=True, null=True, on_delete=models.PROTECT)
def __str__(self):
return f'{self.text[:20]}'
class Meta:
verbose_name_plural = 'Lay Summaries'
class BlogPost(AbstractProjectDueReceivedDate):
title = models.CharField(max_length=1024, help_text='Title of the blog post', null=True, blank=True)
text = models.TextField(help_text='Blog post text', null=True, blank=True)
author = models.ForeignKey(PhysicalPerson, help_text='Person who wrote the blog post',
blank=True, null=True, on_delete=models.PROTECT)
def media_list(self):
if self.id:
return self.medium_set.all().order_by('received_date')
else:
return []
class License(CreateModifyOn):
name = models.CharField(max_length=100,
help_text='License name (e.g. Creative Commons Attribution Non Commercial Share Alike 4.0 International)',
unique=True)
spdx_identifier = models.CharField(max_length=100,
help_text='Identifier as per https://spdx.org/licenses/ CC-BY-NC-SA-4.0',
unique=True)
public_text = models.TextField(
help_text='Explanatory text for this license. Include the logo and URL to license text.',
null=True, blank=True)
def __str__(self):
return f'{self.name}'
def medium_file_rename(instance, filename):
return f'grant_management/Medium/Project-{instance.project.key}-{filename}'
class Medium(CreateModifyOn):
project = models.ForeignKey(Project, help_text='Project that this medium belongs to', on_delete=models.PROTECT)
received_date = models.DateField(help_text='Date that the medium was received')
photographer = models.ForeignKey(PhysicalPerson, help_text='Person who took the photo/video',
on_delete=models.PROTECT)
license = models.ForeignKey(License, help_text='License',
on_delete=models.PROTECT, null=True, blank=True)
copyright = models.CharField(max_length=1024,
help_text='Owner of copyright if it is not the photographer (e.g. institution)',
null=True, blank=True)
file = models.FileField(storage=S3Boto3Storage(), upload_to=medium_file_rename,
validators=[*management_file_validator()])
file_md5 = models.CharField(max_length=32, null=True, blank=True)
blog_posts = models.ManyToManyField(BlogPost, help_text='Which blog posts this image belongs to', blank=True)
descriptive_text = models.TextField(
help_text='Description of this media, if provided. Where was it taken, context, etc.', null=True, blank=True)
class Meta:
verbose_name_plural = 'Media'
def __str__(self):
return f'{self.project}-{self.photographer}'
def save(self, *args, **kwargs):
self.file_md5 = calculate_md5_from_file_field(self.file)
super().save(*args, **kwargs)
def delete(self, *args, **kwargs):
with transaction.atomic():
MediumDeleted.objects.create(**{'original_id': self.id})
delete_result = super().delete(*args, **kwargs)
return delete_result
class MediumDeleted(CreateModifyOn):
original_id = models.IntegerField(help_text='ID of the delete Medium.ID. Used to return them to the '
'SPI Media Gallery or other software',
unique=True # The same ID cannot be deleted twice
)
class Meta:
verbose_name_plural = 'MediaDeleted'
class SocialNetwork(CreateModifyOn):
name = models.CharField(max_length=100,
help_text='Social network name (e.g. Twitter, Facebook, Instagram, Blog)')
def __str__(self):
return f'{self.name}'
def icon(self):
return f'external/icons/{self.name.lower()}.png'
class ProjectSocialNetwork(CreateModifyOn):
project = models.ForeignKey(Project, help_text='Project to which this social network page is related',
on_delete=models.PROTECT)
social_network = models.ForeignKey(SocialNetwork, help_text='Social network with information about the project',
on_delete=models.PROTECT)
url = models.URLField(help_text='URL of social network (e.g. https://twitter.com/SwissPolar)', null=True,
blank=True)
def __str__(self):
return f'{self.project}-{self.social_network}'
def generate_doi_link(doi):
return f'https://doi.org/{doi}'
class Publication(CreateModifyOn):
project = models.ForeignKey(Project, help_text='Project to which the publication is related',
on_delete=models.PROTECT)
doi = models.CharField(max_length=100, help_text='Digital object identifier of publication', null=True, blank=True)
reference = models.CharField(max_length=1000, help_text='Full reference of publication', null=True, blank=True)
title = models.CharField(max_length=1000, help_text='Title of publication')
published_date = models.DateField(help_text='Date on which the resource was published', null=True, blank=True)
def __str__(self):
return '{}'.format(self.title)
def doi_link(self):
return generate_doi_link(self.doi)
class Dataset(CreateModifyOn):
project = models.ForeignKey(Project, help_text='Project to which is the dataset is related',
on_delete=models.PROTECT)
doi = models.CharField(max_length=100, help_text='Digital object identifier of dataset', null=True, blank=True)
url = models.URLField(help_text='URL of dataset if it does not have a DOI', null=True, blank=True)
title = models.CharField(max_length=1000, help_text='Title of dataset')
published_date = models.DateField(help_text='Date on which dataset was published', null=True, blank=True)
def __str__(self):
return '{}'.format(self.title)
def doi_link(self):
return generate_doi_link(self.doi)
class MilestoneCategory(CreateModifyOn):
name = models.CharField(max_length=40)
created_by = models.ForeignKey(User, help_text='User that created the category', on_delete=models.PROTECT)
def __str__(self):
return self.name
class Milestone(CreateModifyOn):
project = models.ForeignKey(Project, help_text='Project to which the milestone is related',
on_delete=models.PROTECT)
due_date = models.DateField()
category = models.ForeignKey(MilestoneCategory, help_text='Which category is this',
on_delete=models.PROTECT)
text = models.CharField(max_length=200, blank=True, null=True)
history = HistoricalRecords()
class Location(CreateModifyOn):
project = models.ForeignKey(Project, help_text='Project that the coordinate belongs to',
on_delete=models.PROTECT,
related_name='project_location')
latitude = models.DecimalField(decimal_places=2, max_digits=6) # TODO: add validator?
longitude = models.DecimalField(decimal_places=2, max_digits=7) # TODO: add validator?
name = models.CharField(max_length=100)
| 42.89415 | 134 | 0.676018 | 1,837 | 15,399 | 5.497006 | 0.170931 | 0.042781 | 0.030897 | 0.040404 | 0.530897 | 0.478313 | 0.401664 | 0.335611 | 0.264706 | 0.195187 | 0 | 0.007264 | 0.231119 | 15,399 | 358 | 135 | 43.013966 | 0.845608 | 0.030716 | 0 | 0.32 | 0 | 0.004 | 0.19516 | 0.032784 | 0 | 0 | 0 | 0.002793 | 0 | 1 | 0.164 | false | 0.008 | 0.044 | 0.132 | 0.744 | 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 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
d66ef50afcf876c59e6d1ed563e416208b94d1da | 744 | py | Python | tests/test_subscribe_http_handler.py | svilborg/samsungtv | 007d8cbf4326ae13d74ab138eb77798d11aae108 | [
"Apache-2.0"
] | 12 | 2018-05-07T10:27:15.000Z | 2021-01-03T23:39:41.000Z | tests/test_subscribe_http_handler.py | svilborg/samsungtv | 007d8cbf4326ae13d74ab138eb77798d11aae108 | [
"Apache-2.0"
] | 1 | 2020-07-12T20:51:51.000Z | 2020-07-12T20:51:51.000Z | tests/test_subscribe_http_handler.py | svilborg/samsungtv | 007d8cbf4326ae13d74ab138eb77798d11aae108 | [
"Apache-2.0"
] | 2 | 2019-08-20T00:48:10.000Z | 2020-09-20T10:09:17.000Z | import sys
from BaseHTTPServer import HTTPServer
from unittest import TestCase
from samsungtv.httpd.subscribe_handler import SubscribeHttpRequestHandler
class TestSubscribeHttpRequestHandler(TestCase):
def test__log(self):
self.skipTest("Todo")
# def test_real(self):
# host = ""
# port = 8007
#
# try:
# # SubscribeRequestHandler.protocol_version = "HTTP/1.0"
#
# httpd = HTTPServer((host, port), SubscribeHttpRequestHandler)
#
# except Exception as e:
# sys.stderr.write(str(e))
# sys.exit(-1)
#
# print "Serving on " + host + ":" + str(port) + " ... "
#
# while True:
# httpd.handle_request()
| 25.655172 | 75 | 0.586022 | 69 | 744 | 6.231884 | 0.666667 | 0.032558 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013487 | 0.302419 | 744 | 28 | 76 | 26.571429 | 0.815029 | 0.509409 | 0 | 0 | 0 | 0 | 0.011561 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.571429 | 0 | 0.857143 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
d676906a67ffc851fd1e178620a853fede08b4a4 | 873 | py | Python | snippets/views.py | kblicharski/django-rest-tutorial | 51c35a5510102d5efb8949759e66a7842a5672cb | [
"MIT"
] | null | null | null | snippets/views.py | kblicharski/django-rest-tutorial | 51c35a5510102d5efb8949759e66a7842a5672cb | [
"MIT"
] | null | null | null | snippets/views.py | kblicharski/django-rest-tutorial | 51c35a5510102d5efb8949759e66a7842a5672cb | [
"MIT"
] | null | null | null | from django.http import HttpResponse, JsonResponse
from django.views.decorators.csrf import csrf_exempt
from rest_framework.parsers import JSONParser
from rest_framework.renderers import JSONRenderer
from .models import Snippet
from .serializers import SnippetSerializer
@csrf_exempt
def snippet_list(request):
"""List all code snippets or create a new snippet."""
if request.method == 'GET':
snippets = Snippet.objects.all()
serializer = SnippetSerializer(snippets, many=True)
return JsonResponse(serializer.data, status=200)
elif request.method == 'POST':
data = JSONParser.parse(request)
serializer = SnippetSerializer(data=data)
if serializer.is_valid():
serializer.save()
return JsonResponse(serializer.data, status=201)
return JsonResponse(serializer.errors, status=400)
| 34.92 | 60 | 0.727377 | 98 | 873 | 6.418367 | 0.510204 | 0.085851 | 0.133545 | 0.101749 | 0.120827 | 0 | 0 | 0 | 0 | 0 | 0 | 0.01273 | 0.190149 | 873 | 24 | 61 | 36.375 | 0.876945 | 0.053837 | 0 | 0 | 0 | 0 | 0.008537 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.052632 | false | 0 | 0.315789 | 0 | 0.526316 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
d68032f9f6c78cdac75e39104c638a7fddf06cff | 2,830 | py | Python | contract_api/handlers/service_handlers.py | vinthedark/snet-marketplace-service | 66ed9d093b00f09d3e28ef4d86c4e4c125037d06 | [
"MIT"
] | null | null | null | contract_api/handlers/service_handlers.py | vinthedark/snet-marketplace-service | 66ed9d093b00f09d3e28ef4d86c4e4c125037d06 | [
"MIT"
] | null | null | null | contract_api/handlers/service_handlers.py | vinthedark/snet-marketplace-service | 66ed9d093b00f09d3e28ef4d86c4e4c125037d06 | [
"MIT"
] | null | null | null | import json
from contract_api.config import NETWORKS, NETWORK_ID, SLACK_HOOK
from common.repository import Repository
from common.utils import Utils, generate_lambda_response
from contract_api.registry import Registry
from common.utils import handle_exception_with_slack_notification
from common.logger import get_logger
from aws_xray_sdk.core import patch_all
patch_all()
db = Repository(net_id=NETWORK_ID, NETWORKS=NETWORKS)
obj_util = Utils()
logger = get_logger(__name__)
@handle_exception_with_slack_notification(logger=logger, NETWORK_ID=NETWORK_ID, SLACK_HOOK=SLACK_HOOK)
def get_service_get(event, context):
obj_reg = Registry(obj_repo=db)
payload_dict = event.get('queryStringParameters')
response_data = obj_reg.get_filter_attribute(
attribute=payload_dict["attribute"])
return generate_lambda_response(
200, {"status": "success", "data": response_data}, cors_enabled=True)
@handle_exception_with_slack_notification(logger=logger, NETWORK_ID=NETWORK_ID, SLACK_HOOK=SLACK_HOOK)
def get_service_post(event, context):
obj_reg = Registry(obj_repo=db)
payload_dict = json.loads(event['body'])
response_data = obj_reg.get_all_srvcs(qry_param=payload_dict)
return generate_lambda_response(
200, {"status": "success", "data": response_data}, cors_enabled=True)
@handle_exception_with_slack_notification(logger=logger, NETWORK_ID=NETWORK_ID, SLACK_HOOK=SLACK_HOOK)
def get_service_for_given_org(event, context):
obj_reg = Registry(obj_repo=db)
org_id = event['pathParameters']['orgId']
service_id = event['pathParameters']['serviceId']
response_data = obj_reg.get_service_data_by_org_id_and_service_id(
org_id=org_id, service_id=service_id)
return generate_lambda_response(
200, {"status": "success", "data": response_data}, cors_enabled=True)
@handle_exception_with_slack_notification(logger=logger, NETWORK_ID=NETWORK_ID, SLACK_HOOK=SLACK_HOOK)
def get_group_for_service(event, context):
obj_reg = Registry(obj_repo=db)
org_id = event['pathParameters']['orgId']
service_id = event['pathParameters']['serviceId']
response_data = obj_reg.get_group_info(
org_id=org_id, service_id=service_id)
return generate_lambda_response(
200, {"status": "success", "data": response_data}, cors_enabled=True)
@handle_exception_with_slack_notification(logger=logger, NETWORK_ID=NETWORK_ID, SLACK_HOOK=SLACK_HOOK)
def post_rating_for_given_service(event, context):
obj_reg = Registry(obj_repo=db)
org_id = event['pathParameters']['orgId']
service_id = event['pathParameters']['serviceId']
response_data = obj_reg.update_service_rating(org_id=org_id, service_id=service_id)
return generate_lambda_response(
200, {"status": "success", "data": response_data}, cors_enabled=True)
| 42.238806 | 102 | 0.777385 | 390 | 2,830 | 5.238462 | 0.184615 | 0.052863 | 0.041116 | 0.052863 | 0.721488 | 0.683309 | 0.683309 | 0.683309 | 0.683309 | 0.683309 | 0 | 0.006031 | 0.121201 | 2,830 | 66 | 103 | 42.878788 | 0.81544 | 0 | 0 | 0.528302 | 1 | 0 | 0.086572 | 0.00742 | 0 | 0 | 0 | 0 | 0 | 1 | 0.09434 | false | 0 | 0.150943 | 0 | 0.339623 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 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 | 2 |
d69d2ab3416fa57067cdd88719980f6249a69de7 | 351 | py | Python | baekjoon/not-classified/1630/1630.py | honux77/algorithm | 2ed8cef1fbee7ad96d8f2ae583666d52bd8892ee | [
"MIT"
] | 2 | 2019-02-08T01:23:07.000Z | 2020-11-19T12:23:52.000Z | baekjoon/not-classified/1630/1630.py | honux77/algorithm | 2ed8cef1fbee7ad96d8f2ae583666d52bd8892ee | [
"MIT"
] | null | null | null | baekjoon/not-classified/1630/1630.py | honux77/algorithm | 2ed8cef1fbee7ad96d8f2ae583666d52bd8892ee | [
"MIT"
] | null | null | null | n = input()
def gcd(m, n):
while True:
m %= n
if m == 0:
return n
n %= m
if n == 0:
return m
def lcm(m, n):
g = gcd(m ,n)
return m * n / g
def omin(n):
r = n
for i in range(2, n):
if r % i != 0:
r = lcm(r, i)
return r
print omin(n) | 15.26087 | 34 | 0.350427 | 58 | 351 | 2.12069 | 0.344828 | 0.081301 | 0.081301 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.023669 | 0.518519 | 351 | 23 | 35 | 15.26087 | 0.704142 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.052632 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d6c7df267dadd81c3a7d8388d0591ed9627f775f | 319 | py | Python | python/lists/list3.py | readingbat/readingbat-python-content | 437648be8e15ce3ce21d5f256f91d71658bbb889 | [
"Apache-2.0"
] | null | null | null | python/lists/list3.py | readingbat/readingbat-python-content | 437648be8e15ce3ce21d5f256f91d71658bbb889 | [
"Apache-2.0"
] | null | null | null | python/lists/list3.py | readingbat/readingbat-python-content | 437648be8e15ce3ce21d5f256f91d71658bbb889 | [
"Apache-2.0"
] | null | null | null | def list3(str):
result = 0
for i in str:
if i == 'a':
result += 1
return result
def main():
print(list3(['Hello', 'world', 'a']))
print(list3(['a', 'a']))
print(list3(['Computational', 'thinking']))
print(list3(['a', 'A', 'A']))
if __name__ == '__main__':
main()
| 17.722222 | 47 | 0.489028 | 40 | 319 | 3.7 | 0.475 | 0.27027 | 0.148649 | 0.162162 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.030702 | 0.285266 | 319 | 17 | 48 | 18.764706 | 0.618421 | 0 | 0 | 0 | 0 | 0 | 0.144201 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.153846 | false | 0 | 0 | 0 | 0.230769 | 0.307692 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d6d5e539107b36d6dd7a8cf69a035a5a809a4249 | 54 | py | Python | bitmerchantx/wallet/__init__.py | dalijolijo/bitmerchant-btx | c34f5a242d24ea37c5563a3d29bf521b21e70245 | [
"MIT"
] | 72 | 2015-01-28T03:50:03.000Z | 2021-06-21T11:20:15.000Z | bitmerchantx/wallet/__init__.py | dalijolijo/bitmerchant-btx | c34f5a242d24ea37c5563a3d29bf521b21e70245 | [
"MIT"
] | 19 | 2015-01-01T11:45:00.000Z | 2021-12-23T13:03:46.000Z | bitmerchantx/wallet/__init__.py | dalijolijo/bitmerchant-btx | c34f5a242d24ea37c5563a3d29bf521b21e70245 | [
"MIT"
] | 27 | 2015-01-01T11:39:48.000Z | 2022-03-31T20:15:28.000Z | from .bip32 import Wallet
__all__ = [
'Wallet'
]
| 9 | 25 | 0.62963 | 6 | 54 | 5 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.05 | 0.259259 | 54 | 5 | 26 | 10.8 | 0.7 | 0 | 0 | 0 | 0 | 0 | 0.111111 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
d6dbd17e21eed640dcdf714d13b67e7ac4942957 | 220 | py | Python | test_basic.py | thomasgruebl/mount-usb-in-sandbox | 2204e59ef71102419e593c6655783b7db24a04e8 | [
"MIT"
] | 5 | 2021-11-20T10:56:18.000Z | 2021-12-25T23:59:03.000Z | test_basic.py | thomasgruebl/mount-usb-in-sandbox | 2204e59ef71102419e593c6655783b7db24a04e8 | [
"MIT"
] | null | null | null | test_basic.py | thomasgruebl/mount-usb-in-sandbox | 2204e59ef71102419e593c6655783b7db24a04e8 | [
"MIT"
] | null | null | null | import unittest
import helpers
class BasicTest(unittest.TestCase):
def test_network_interfaces(self):
self.assertIsNotNone(helpers.get_network_interfaces())
if __name__ == '__main__':
unittest.main()
| 18.333333 | 62 | 0.75 | 24 | 220 | 6.375 | 0.666667 | 0.222222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.154545 | 220 | 11 | 63 | 20 | 0.822581 | 0 | 0 | 0 | 0 | 0 | 0.036364 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 1 | 0.142857 | false | 0 | 0.285714 | 0 | 0.571429 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d6e89d1e01f608eab7fd6b14337eb4341926d5e3 | 2,529 | py | Python | vm_network_migration/errors.py | googleinterns/vm-network-migration | 1132e44d696ab9da4d1079ebc3d32ed4382cdc28 | [
"Apache-2.0"
] | 1 | 2020-05-27T00:30:47.000Z | 2020-05-27T00:30:47.000Z | vm_network_migration/errors.py | yueMaHello/vm-network-migration | 4a6bdbb2952fb8ee8022b5c0452159329a79e953 | [
"Apache-2.0"
] | 1 | 2020-06-03T15:51:20.000Z | 2020-06-03T15:51:20.000Z | vm_network_migration/errors.py | yueMaHello/vm-network-migration | 4a6bdbb2952fb8ee8022b5c0452159329a79e953 | [
"Apache-2.0"
] | 3 | 2020-06-03T15:17:00.000Z | 2020-06-20T08:39:50.000Z | # Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Errors for the library
All exceptions defined by the library
should be defined in this file.
"""
class UnchangedInstanceNameError(IOError):
"""The new instance name is the same as the original one's"""
pass
class InvalidTargetNetworkError(IOError):
"""Migrate to a non-VPC network"""
pass
class ZoneOperationsError(Exception):
"""Zone operation's error"""
pass
class RegionOperationsError(Exception):
"""Region operation's error"""
pass
class AttributeNotExistError(KeyError):
"""An attribute doesn't exist in the googleapi's response"""
pass
class InvalidTypeError(TypeError):
"""Type error"""
pass
class MissingSubnetworkError(IOError):
"""The subnetwork is not defined"""
pass
class RollbackError(Exception):
"""The rollback procedure is failed"""
pass
class AddInstanceToInstanceGroupError(Exception):
"""Adding an instance back to the instance group is failed"""
pass
class TargetTypeError(Exception):
"""The target type is not supported"""
pass
class UnsupportedForwardingRule(Exception):
"""The type of the forwarding rule is not supported"""
pass
class UnsupportedBackendService(Exception):
"""The type of the backend service is not supported"""
pass
class MigrationFailed(Exception):
"""The migration is failed, and the rollback was called"""
pass
class InvalidSelfLink(Exception):
"""The selfLink is unable to be parsed"""
pass
class AmbiguousTargetResource(Exception):
"""The target resource can be an instance group or a single instance"""
pass
class MultipleTargetPools(Exception):
"""The instance group is serving mutliple target pools at the same time"""
pass
class SubnetworkNotExists(Exception):
"""The subnetwork doens't exist in the network"""
pass
class UnableToGenerateNewInstanceTemplate(Exception):
"""Unable to genereate a new instance template"""
pass | 25.039604 | 78 | 0.727956 | 315 | 2,529 | 5.844444 | 0.460317 | 0.083107 | 0.022814 | 0.029332 | 0.086366 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003893 | 0.187426 | 2,529 | 101 | 79 | 25.039604 | 0.891971 | 0.55516 | 0 | 0.5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.5 | 0 | 0 | 0.5 | 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 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
d6eaa4ca6144fcb381dba9eeac969018e52ca0f4 | 2,444 | py | Python | src/card_region.py | AdonisHan/postcorona_DA | 576d54c4f4ab53357535f23f3399cc4558bc3ccb | [
"Apache-2.0"
] | null | null | null | src/card_region.py | AdonisHan/postcorona_DA | 576d54c4f4ab53357535f23f3399cc4558bc3ccb | [
"Apache-2.0"
] | null | null | null | src/card_region.py | AdonisHan/postcorona_DA | 576d54c4f4ab53357535f23f3399cc4558bc3ccb | [
"Apache-2.0"
] | null | null | null | %matplotlib inline
import ipywidgets as widgets
from ipywidgets import interact, interact_manual
import plotly.graph_objects as go
import plotly.express as px
import plotly.figure_factory as ff
import plotly.io as pio
pio.renderers.default = 'notebook_connected'
import datetime as dt
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')
import csv
from sklearn.cluster import KMeans
from sklearn.metrics import silhouette_score
from sklearn.decomposition import PCA
from itertools import product
#Matplotlib 한국어 세팅
import platform
from matplotlib import font_manager, rc
plt.rcParams['axes.unicode_minus'] = False
if platform.system() == 'Darwin':
rc('font', family='AppleGothic')
elif platform.system() == 'Windows':
font_name = font_manager.FontProperties(fname='/Users/adonishan/Library/Fonts').get_name()
rc('font', family=font_name)
#palette
pal = ['#50d890', '#007944','#888888','#f3c623','#EFEFEF', '#96bb7c', '#d9bf77','#3f3f44']
def fig_cards():
card = pd.read_csv('data/card_20200717.csv')
card.columns = ['날짜', '행정동 코드', '행정동', '업종 코드', '업종', '판매건수', '판매금액']
card['날짜'] = card['날짜'].astype('str').apply(lambda x: x[:4] + '-' + x[4:6] + '-' + x[6:])
card['행정동 코드'] = card['행정동 코드'].astype('str').apply(lambda x:x [:-2]).astype('int')
region.columns = ['행정동 코드','행정동','광역시도','시군구']
region['행정동 코드'] = region['행정동 코드'].astype('int')
card = pd.merge(card, region, on=['행정동 코드'], how = 'left')
card = card[card['광역시도'] == '서울특별시']
card = card.drop(['행정동 코드', '업종 코드'],axis=1)
card = card.groupby(['날짜','업종']).sum().reset_index()
date = list(card['날짜'].unique())
category = list(card['업종'].unique())
item = [date,category]
card_temp = pd.DataFrame(product(*item), columns = ['날짜','업종'])
card_compare = card.copy()
card = pd.merge(card,card_temp,on=['날짜','업종'],how='right')
card = card.fillna(0)
card = card.groupby(['날짜','업종']).mean().reset_index()
card = card.drop(['주'],axis=1)
card['주'] = pd.to_datetime(card['날짜']).dt.week
card = card.groupby(['업종','주']).mean().reset_index()
def weekly_card_graph():
fig,ax = plt.subplots(1,2,figsize=(14,5))
ax[0].plot(card_compare[card_compare['업종'] == '인터넷종합Mall']['판매금액'])
ax[0].set_title("일별 인터넷종합Mall 판매건수", fontsize=15)
ax[0].set_xticks([])
ax[1].plot(card[card['업종'] == '인터넷종합Mall']['판매금액'])
ax[1].set_title("주별 인터넷종합Mall 판매건수", fontsize=15)
ax[1].set_xticks([])
| 29.804878 | 94 | 0.67635 | 371 | 2,444 | 4.374663 | 0.409704 | 0.049291 | 0.027726 | 0.024646 | 0.081331 | 0.02711 | 0 | 0 | 0 | 0 | 0 | 0.028797 | 0.119067 | 2,444 | 81 | 95 | 30.17284 | 0.725035 | 0.00982 | 0 | 0 | 0 | 0 | 0.163561 | 0.021532 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.310345 | null | null | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
d6eabc87a08d1d481966ecf70aabc4d6e017d1b5 | 2,760 | py | Python | telemetry/telemetry/internal/results/artifact_compatibility_wrapper.py | alekzonder/catapult | f1017f0c7bd2b766674888d5e88d42fcc61d632c | [
"BSD-3-Clause"
] | null | null | null | telemetry/telemetry/internal/results/artifact_compatibility_wrapper.py | alekzonder/catapult | f1017f0c7bd2b766674888d5e88d42fcc61d632c | [
"BSD-3-Clause"
] | 6 | 2020-07-19T21:51:44.000Z | 2022-02-13T08:22:58.000Z | telemetry/telemetry/internal/results/artifact_compatibility_wrapper.py | alekzonder/catapult | f1017f0c7bd2b766674888d5e88d42fcc61d632c | [
"BSD-3-Clause"
] | 1 | 2020-07-24T18:22:03.000Z | 2020-07-24T18:22:03.000Z | # Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Compatibility layer for using different artifact implementations through a
# single API.
# TODO(https://crbug.com/1023458): Remove this once artifact implementations are
# unified.
import logging
import os
from telemetry.internal.results import story_run
from typ import artifacts
def ArtifactCompatibilityWrapperFactory(artifact_impl):
if isinstance(artifact_impl, story_run.StoryRun):
return TelemetryArtifactCompatibilityWrapper(artifact_impl)
elif isinstance(artifact_impl, artifacts.Artifacts):
return TypArtifactCompatibilityWrapper(artifact_impl)
elif artifact_impl is None:
return LoggingArtifactCompatibilityWrapper()
raise RuntimeError('Given unsupported artifact implementation %s' %
type(artifact_impl).__name__)
class ArtifactCompatibilityWrapper(object):
def __init__(self, artifact_impl):
self._artifact_impl = artifact_impl
def CreateArtifact(self, name, data):
"""Create an artifact with the given data.
Args:
name: The name of the artifact, can include '/' to organize artifacts
within a hierarchy.
data: The data to write to the artifact.
"""
raise NotImplementedError()
class TelemetryArtifactCompatibilityWrapper(ArtifactCompatibilityWrapper):
"""Wrapper around Telemetry's story_run.StoryRun class."""
def CreateArtifact(self, name, data):
with self._artifact_impl.CreateArtifact(name) as f:
f.write(data)
class TypArtifactCompatibilityWrapper(ArtifactCompatibilityWrapper):
"""Wrapper around typ's Artifacts class"""
def CreateArtifact(self, name, data):
file_relative_path = name.replace('/', os.sep)
self._artifact_impl.CreateArtifact(name, file_relative_path, data)
class LoggingArtifactCompatibilityWrapper(ArtifactCompatibilityWrapper):
"""Wrapper that logs instead of actually creating artifacts.
This is necessary because some tests, e.g. those that inherit from
browser_test_case.BrowserTestCase, don't currently have a way of reporting
artifacts. In those cases, we can fall back to logging to stdout so that
information isn't lost. However, to prevent cluttering up stdout, we only log
the first 100 characters.
"""
def __init__(self):
super(LoggingArtifactCompatibilityWrapper, self).__init__(None)
def CreateArtifact(self, name, data):
logging.warning(
'Only logging the first 100 characters of the given artifact. To store '
'the full artifact, run the test in either a Telemetry or typ context.')
logging.info(
'Artifact with name %s: %s', name, data[:min(100, len(data))])
| 36.315789 | 80 | 0.75942 | 335 | 2,760 | 6.137313 | 0.453731 | 0.070039 | 0.031128 | 0.048638 | 0.094358 | 0.033074 | 0 | 0 | 0 | 0 | 0 | 0.008696 | 0.166667 | 2,760 | 75 | 81 | 36.8 | 0.885217 | 0.357609 | 0 | 0.114286 | 0 | 0 | 0.122079 | 0 | 0 | 0 | 0 | 0.013333 | 0 | 1 | 0.2 | false | 0 | 0.114286 | 0 | 0.514286 | 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 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
d6eed2b6b29ec80a8158c1ec3b0a24da72dc3f7e | 2,498 | py | Python | lintcode/Design/1786. Pub Sub Pattern.py | yanshengjia/algorithm | 0608d286be9c93d51768d47f21e569c6b0be9cda | [
"MIT"
] | 23 | 2019-08-02T12:02:47.000Z | 2022-03-09T15:24:16.000Z | lintcode/Design/1786. Pub Sub Pattern.py | yanshengjia/algorithm | 0608d286be9c93d51768d47f21e569c6b0be9cda | [
"MIT"
] | null | null | null | lintcode/Design/1786. Pub Sub Pattern.py | yanshengjia/algorithm | 0608d286be9c93d51768d47f21e569c6b0be9cda | [
"MIT"
] | 21 | 2019-12-22T04:47:32.000Z | 2021-09-12T14:29:35.000Z | """
Pub/Sub pattern is a wide used pattern in system design. In this problem, you need to implement a pub/sub pattern to support user subscribes on a specific channel and get notification messages from subscribed channels.
There are 3 methods you need to implement:
subscribe(channel, user_id): Subscribe the given user to the given channel.
unsubscribe(channel, user_id): Unsubscribe the given user from the given channel.
publish(channel, message): You need to publish the message to the channel so that everyone subscribed on the channel will receive this message. Call PushNotification.notify(user_id, message) to push the message to the user.
Example
subscribe("group1", 1)
publish("group1", "hello")
>> user 1 received "Hello"
subscribe("group1", 2)
publish("group1", "thank you")
>> user 1 received "thank you"
>> user 2 received "thank you"
unsubscribe("group2", 3)
>> user 3 is not in group2, do nothing
unsubscribe("group1", 1)
publish("group1", "thank you very much")
>> user 2 received "thank you very much"
publish("group2", "are you ok?")
>> # you don't need to push this message to anyone
If there are more than 1 user subscribed on the same channel, it doesn't matter the order of time users receiving the message. It's ok if you push the message to user 2 before user 1.
Solution:
模拟题,观察者模式
"""
'''
Definition of PushNotification
class PushNotification:
@classmethod
def notify(user_id, message):
'''
class PubSubPattern:
def __init__(self):
# do intialization if necessary
self.d = dict() # {"channel": sub_user_set}
"""
@param: channel: a channel name
@param: user_id: a user id
@return: nothing
"""
def subscribe(self, channel, user_id):
# write your code here
if channel not in self.d:
self.d[channel] = set()
self.d[channel].add(user_id)
"""
@param: channel: a channel name
@param: user_id: a user id
@return: nothing
"""
def unsubscribe(self, channel, user_id):
# write your code here
if channel in self.d and user_id in self.d[channel]:
self.d[channel].remove(user_id)
"""
@param: channel: a channel name
@param: message: need send message
@return: nothing
"""
def publish(self, channel, message):
# write your code here
if channel in self.d and len(self.d[channel]) > 0:
for user_id in self.d[channel]:
PushNotification.notify(user_id, message)
| 32.025641 | 223 | 0.680945 | 367 | 2,498 | 4.583106 | 0.294278 | 0.053508 | 0.042806 | 0.033888 | 0.262188 | 0.1956 | 0.171819 | 0.171819 | 0.147444 | 0.147444 | 0 | 0.011856 | 0.223379 | 2,498 | 77 | 224 | 32.441558 | 0.855155 | 0.572858 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.038961 | 0 | 1 | 0.285714 | false | 0 | 0 | 0 | 0.357143 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d6fa2c43d6c59ec3cdf013dcdd92c79d01ee9b72 | 312 | py | Python | binary_tree/tree_node.py | ahcode0919/python-ds-algorithms | 0d617b78c50b6c18da40d9fa101438749bfc82e1 | [
"MIT"
] | null | null | null | binary_tree/tree_node.py | ahcode0919/python-ds-algorithms | 0d617b78c50b6c18da40d9fa101438749bfc82e1 | [
"MIT"
] | null | null | null | binary_tree/tree_node.py | ahcode0919/python-ds-algorithms | 0d617b78c50b6c18da40d9fa101438749bfc82e1 | [
"MIT"
] | 3 | 2020-10-07T20:24:45.000Z | 2020-12-16T04:53:19.000Z | from typing import Generic, Optional, TypeVar
T = TypeVar('T')
class TreeNode(Generic[T]):
def __init__(self, val: T, left: Optional['TreeNode'] = None, right: Optional['TreeNode'] = None):
self.val = val
self.left: Optional[TreeNode] = left
self.right: Optional[TreeNode] = right
| 28.363636 | 102 | 0.653846 | 39 | 312 | 5.128205 | 0.410256 | 0.32 | 0.2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.208333 | 312 | 10 | 103 | 31.2 | 0.809717 | 0 | 0 | 0 | 0 | 0 | 0.054487 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.142857 | 0 | 0.428571 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ba30e8e927704574df74f6ca9909d3346f8f4924 | 279 | py | Python | Source/Backend/core/brand/models.py | csgn/Price-Tracker | 67507b85dac9b0b9c8c975342678ebec3be2b7c0 | [
"MIT"
] | null | null | null | Source/Backend/core/brand/models.py | csgn/Price-Tracker | 67507b85dac9b0b9c8c975342678ebec3be2b7c0 | [
"MIT"
] | 4 | 2021-12-12T10:31:23.000Z | 2021-12-12T10:33:46.000Z | Source/Backend/core/brand/models.py | csgn/Price-Tracker | 67507b85dac9b0b9c8c975342678ebec3be2b7c0 | [
"MIT"
] | null | null | null | from django.db import models
class Brand(models.Model):
brandid = models.AutoField(primary_key=True)
name = models.CharField(max_length=255)
url = models.URLField()
def __str__(self) -> str:
return self.name
class Meta:
db_table = "brand"
| 19.928571 | 48 | 0.659498 | 36 | 279 | 4.916667 | 0.722222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.014085 | 0.236559 | 279 | 13 | 49 | 21.461538 | 0.816901 | 0 | 0 | 0 | 0 | 0 | 0.017921 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.111111 | 0.111111 | 0.888889 | 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 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
ba39ad8f966c582e5538fec775f70acc648227b4 | 2,515 | py | Python | vaccination/models.py | MarioScappini/vaccination-system | ab17ab6e40c7109ac001a8bce5e0de74c4129041 | [
"Apache-2.0"
] | null | null | null | vaccination/models.py | MarioScappini/vaccination-system | ab17ab6e40c7109ac001a8bce5e0de74c4129041 | [
"Apache-2.0"
] | null | null | null | vaccination/models.py | MarioScappini/vaccination-system | ab17ab6e40c7109ac001a8bce5e0de74c4129041 | [
"Apache-2.0"
] | null | null | null | from django.db import models
class Person(models.Model):
person_ssn = models.IntegerField(primary_key=True,unique=True)
person_fname = models.CharField(max_length=20)
person_lname = models.CharField(max_length=50)
person_email = models.CharField(max_length=70)
person_phone = models.CharField(max_length=13)
person_addr = models.CharField(max_length=100)
def __str__(self):
text = str(self.person_ssn) + ' ' + str(self.person_fname) + ' ' + self.person_lname
return text
class Place(models.Model):
place_id = models.IntegerField(primary_key=True,unique=True)
place_name = models.CharField(max_length=30)
place_addr = models.CharField(max_length=50)
def __str__(self):
return self.place_name
class Vaccine(models.Model):
vaccine_id = models.IntegerField(primary_key=True, unique=True, default=123)
vaccine_name = models.CharField(max_length=25, unique=True)
vaccine_stock = models.IntegerField()
vaccine_no_of_shots = models.IntegerField()
vaccine_effectivity = models.FloatField()
def __str__(self):
return self.vaccine_name
class Medic(models.Model):
medic_ssn = models.IntegerField(primary_key=True,unique=True)
medic_type = models.CharField(max_length=25)
medic_registry_no = models.CharField(max_length=25, unique=True)
medic_fname = models.CharField(max_length=20)
medic_lname = models.CharField(max_length=50)
medic_email = models.CharField(max_length=70)
medic_phone = models.CharField(max_length=13)
medic_addr = models.CharField(max_length=100)
medic_place = models.ForeignKey(Place, on_delete=models.SET_NULL, null=True)
def __str__(self):
text = str(self.medic_ssn) + ' ' + str(self.medic_fname) + ' ' + str(self.medic_lname)
return text
class PlaceHasVaccines(models.Model):
stock = models.IntegerField()
place_id = models.ForeignKey(Place, on_delete=models.SET_NULL, null=True)
vaccine_id = models.ForeignKey(Vaccine, on_delete=models.SET_NULL, null=True)
class Appointment(models.Model):
appointment_id = models.IntegerField(primary_key=True, default=0)
shot_no = models.IntegerField()
appointment_date = models.DateTimeField()
patient_ssn = models.ForeignKey(Person,on_delete=models.CASCADE, null=True)
medic_ssn = models.ForeignKey(Medic, on_delete=models.CASCADE)
vaccine_name = models.ForeignKey(Vaccine, on_delete=models.CASCADE)
place = models.ForeignKey(Place, on_delete=models.CASCADE)
| 40.564516 | 94 | 0.741948 | 333 | 2,515 | 5.339339 | 0.186186 | 0.126547 | 0.151856 | 0.202475 | 0.561305 | 0.489314 | 0.23847 | 0.156355 | 0.056243 | 0.056243 | 0 | 0.016854 | 0.150696 | 2,515 | 61 | 95 | 41.229508 | 0.815543 | 0 | 0 | 0.12 | 0 | 0 | 0.00159 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.08 | false | 0 | 0.02 | 0.04 | 0.96 | 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 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
ba3b34526bdea107f31b357b63727eb97f92df00 | 681 | py | Python | Phase-3/Python Challenge/Day-98.py | CodedLadiesInnovateTech/python-challenges | 22ce26c68fea6c7c243ada831e47c52e27a62127 | [
"MIT"
] | 11 | 2020-05-11T08:41:21.000Z | 2022-02-27T08:21:37.000Z | Phase-3/Python Challenge/Day-98.py | CodedLadiesInnovateTech/python-challenges | 22ce26c68fea6c7c243ada831e47c52e27a62127 | [
"MIT"
] | 9 | 2020-05-12T10:46:06.000Z | 2020-05-28T17:37:19.000Z | Phase-3/Python Challenge/Day-98.py | CodedLadiesInnovateTech/python-challenges | 22ce26c68fea6c7c243ada831e47c52e27a62127 | [
"MIT"
] | 44 | 2020-05-10T20:53:32.000Z | 2021-04-25T18:47:08.000Z | '''
1. Write a Python program to find the first triangle number to have over n(given) divisors.
From Wikipedia: A triangular number is a number that is the sum of all of the natural numbers up to a certain number. For example, 10 is a triangular number because 1 + 2 + 3 + 4 = 10. The first 25 triangular numbers are: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, and 351.
A triangular number is calculated by the equation: n(n+1)/2
The factors of the first five triangle numbers:
1: 1
3: 1, 3
6: 1, 2, 3, 6
10: 1, 2, 5, 10
15: 1, 3, 5, 15
In the above list 6 is the first triangle number to have over four divisors
'''
| 45.4 | 335 | 0.693098 | 140 | 681 | 3.371429 | 0.5 | 0.067797 | 0.108051 | 0.09322 | 0.135593 | 0.135593 | 0.135593 | 0 | 0 | 0 | 0 | 0.182495 | 0.211454 | 681 | 14 | 336 | 48.642857 | 0.696462 | 0.983847 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
ba412491512590d4b2b56392a3de0dc24ed00c0c | 409 | py | Python | zstacklib/zstacklib/utils/sqlite.py | qianfei11/zstack-utility | e791bc6b6ae3a74e202f6fce84bde498c715aee8 | [
"Apache-2.0"
] | 55 | 2017-02-10T07:55:21.000Z | 2021-09-01T00:59:36.000Z | zstacklib/zstacklib/utils/sqlite.py | qianfei11/zstack-utility | e791bc6b6ae3a74e202f6fce84bde498c715aee8 | [
"Apache-2.0"
] | 106 | 2017-02-13T09:58:27.000Z | 2022-02-15T09:51:48.000Z | zstacklib/zstacklib/utils/sqlite.py | qianfei11/zstack-utility | e791bc6b6ae3a74e202f6fce84bde498c715aee8 | [
"Apache-2.0"
] | 68 | 2017-02-13T11:02:01.000Z | 2021-12-16T11:02:01.000Z | import sqlite3
class Sqlite(object):
def __init__(self, db_path):
self.db_path = db_path
def __enter__(self):
self.connect = sqlite3.connect(self.db_path)
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.connect.close()
def execute(self, *args, **kwargs):
with self.connect:
return self.connect.execute(*args, **kwargs)
| 21.526316 | 56 | 0.628362 | 53 | 409 | 4.490566 | 0.433962 | 0.10084 | 0.12605 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006601 | 0.259169 | 409 | 18 | 57 | 22.722222 | 0.778878 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.083333 | 0 | 0.666667 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
ba460ad90cc96679d1642b49c4c05abc44c6e39e | 137 | py | Python | 0263.Ugly Number/test.py | zhlinh/leetcode | 6dfa0a4df9ec07b2c746a13c8257780880ea04af | [
"Apache-2.0"
] | null | null | null | 0263.Ugly Number/test.py | zhlinh/leetcode | 6dfa0a4df9ec07b2c746a13c8257780880ea04af | [
"Apache-2.0"
] | null | null | null | 0263.Ugly Number/test.py | zhlinh/leetcode | 6dfa0a4df9ec07b2c746a13c8257780880ea04af | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from solution import Solution
num = 14
sol = Solution()
res = sol.isUgly(num)
print(res)
| 13.7 | 29 | 0.656934 | 21 | 137 | 4.285714 | 0.761905 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.026316 | 0.167883 | 137 | 9 | 30 | 15.222222 | 0.763158 | 0.306569 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 0.2 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
ba700811c1154629a20195064a5d8762f07b7209 | 567 | py | Python | rl_games/games/q_learner/tests/nac_play_many.py | RacingTadpole/rl-games | 209fb1bf4007529cb05d0070075df83a04125672 | [
"MIT"
] | null | null | null | rl_games/games/q_learner/tests/nac_play_many.py | RacingTadpole/rl-games | 209fb1bf4007529cb05d0070075df83a04125672 | [
"MIT"
] | null | null | null | rl_games/games/q_learner/tests/nac_play_many.py | RacingTadpole/rl-games | 209fb1bf4007529cb05d0070075df83a04125672 | [
"MIT"
] | null | null | null | from typing import Sequence, Dict, Any
from rl_games.q_learner.player import Player
from rl_games.core.play import play_many
from rl_games.games.nac import Nac
def nac_play_many(
players: Sequence[Player],
*args: Any,
**kwargs: Any
) -> Dict[str, float]:
"""
>>> import random
>>> from rl_games.q_learner.player import QPlayer
>>> random.seed(2)
>>> x, o = QPlayer('X'), QPlayer('O')
>>> nac_play_many([x, o], range(500))
{'X': 0.46, 'O': 0.208}
"""
game = Nac()
return play_many(game, players, *args, **kwargs)
| 24.652174 | 53 | 0.626102 | 84 | 567 | 4.083333 | 0.404762 | 0.069971 | 0.12828 | 0.069971 | 0.180758 | 0.180758 | 0.180758 | 0 | 0 | 0 | 0 | 0.024554 | 0.209877 | 567 | 22 | 54 | 25.772727 | 0.741071 | 0.328042 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0 | 0.363636 | 0 | 0.545455 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
ba75cb232d5cd41181826e2e825d7b6550ae5246 | 411 | py | Python | contests/2020_spring/1.py | clarkchen/leetcode_python | 4d26c1ddc9fc827ba12df9f4b4e768da11d7b9bd | [
"Apache-2.0"
] | null | null | null | contests/2020_spring/1.py | clarkchen/leetcode_python | 4d26c1ddc9fc827ba12df9f4b4e768da11d7b9bd | [
"Apache-2.0"
] | null | null | null | contests/2020_spring/1.py | clarkchen/leetcode_python | 4d26c1ddc9fc827ba12df9f4b4e768da11d7b9bd | [
"Apache-2.0"
] | null | null | null | from typing import List
class Solution:
def minCount(self, coins: List[int]) -> int:
res = []
for x in coins:
res.append(x//2+x%2)
return sum(res)
if __name__ == '__main__':
s = Solution()
ans = s.minCount([4,2,1])
print(ans)
ans = s.minCount([2,3,10])
print(ans)
ans = s.minCount([1])
print(ans)
ans = s.minCount([2])
print(ans) | 18.681818 | 48 | 0.530414 | 60 | 411 | 3.5 | 0.483333 | 0.07619 | 0.228571 | 0.171429 | 0.304762 | 0.209524 | 0.209524 | 0 | 0 | 0 | 0 | 0.038596 | 0.306569 | 411 | 22 | 49 | 18.681818 | 0.698246 | 0 | 0 | 0.235294 | 0 | 0 | 0.019417 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.058824 | false | 0 | 0.058824 | 0 | 0.235294 | 0.235294 | 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 | 0 | 0 | 0 | 0 | 2 |
ba7f15f1ec2fec62e15b56bd5cf33ccdafd4addf | 557 | py | Python | cogs/welcome.py | nihaals/DabbitPrimeBot | a7c0e906a9065e3de7665a5f050c43e2cc11259d | [
"MIT"
] | null | null | null | cogs/welcome.py | nihaals/DabbitPrimeBot | a7c0e906a9065e3de7665a5f050c43e2cc11259d | [
"MIT"
] | null | null | null | cogs/welcome.py | nihaals/DabbitPrimeBot | a7c0e906a9065e3de7665a5f050c43e2cc11259d | [
"MIT"
] | 1 | 2019-12-19T04:14:22.000Z | 2019-12-19T04:14:22.000Z | from discord.ext import commands
import discord
class Welcome():
def __init__(self, bot):
self.bot = bot
# welcome = False
#
# @commands.command()
# async def welcome(self, ctx, welcome):
# welcome = not welcome
# await ctx.send(self.bot.blank + "Welcome is set to {}".format(welcome))
#
# async def on_member_join(self, member):
# if welcome:
# await member.guild.default_channel.send("{0.name} joined in {0.joined_at}".format(member))
def setup(bot):
bot.add_cog(Welcome(bot)) | 27.85 | 104 | 0.62298 | 73 | 557 | 4.630137 | 0.520548 | 0.06213 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004762 | 0.245961 | 557 | 20 | 105 | 27.85 | 0.8 | 0.594255 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.285714 | 0 | 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 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
ba8a24471d327c96d6edddc78b96f71b779f0847 | 329 | py | Python | {{cookiecutter.project_name}}/wsgi.py | Anyesh/cookiecutter-flask-all-in-one | 6ae0a423e8cab23c23756f1ef610643c85b71f32 | [
"MIT"
] | 35 | 2020-11-27T09:06:44.000Z | 2022-01-31T17:08:41.000Z | {{cookiecutter.project_name}}/wsgi.py | Anyesh/cookiecutter-flask-all-in-one | 6ae0a423e8cab23c23756f1ef610643c85b71f32 | [
"MIT"
] | 1 | 2021-05-15T17:34:47.000Z | 2021-06-04T20:12:59.000Z | {{cookiecutter.project_name}}/wsgi.py | Anyesh/cookiecutter-flask-all-in-one | 6ae0a423e8cab23c23756f1ef610643c85b71f32 | [
"MIT"
] | 2 | 2020-12-03T13:55:11.000Z | 2020-12-08T10:42:03.000Z | """App entry point."""
from {{cookiecutter.app_name}} import create_app, db, models
from {{cookiecutter.app_name}}.manage import cli
app = create_app()
@app.shell_context_processor
def make_shell_context():
return {'db': db, "models": models}
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)
| 23.5 | 60 | 0.702128 | 49 | 329 | 4.387755 | 0.55102 | 0.027907 | 0.176744 | 0.213953 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.027972 | 0.130699 | 329 | 13 | 61 | 25.307692 | 0.723776 | 0 | 0 | 0 | 0 | 0 | 0.074919 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.25 | null | null | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ba8d1d6e20cb328b8ac8f400b1f860ed4788e4be | 740 | py | Python | backend/api/migrations/0002_auto_20201229_1654.py | MeRichard123/family-tree-app | 472f4aebe99811130fd1288d7cec62ac1a9f10b2 | [
"MIT"
] | 1 | 2021-11-24T04:41:47.000Z | 2021-11-24T04:41:47.000Z | backend/api/migrations/0002_auto_20201229_1654.py | MeRichard123/family-tree-app | 472f4aebe99811130fd1288d7cec62ac1a9f10b2 | [
"MIT"
] | 5 | 2021-01-07T21:11:45.000Z | 2021-03-14T10:59:51.000Z | backend/api/migrations/0002_auto_20201229_1654.py | MeRichard123/family-tree-app | 472f4aebe99811130fd1288d7cec62ac1a9f10b2 | [
"MIT"
] | null | null | null | # Generated by Django 3.1.4 on 2020-12-29 16:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='aunt',
name='spouse',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AddField(
model_name='cousin',
name='spouse',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AddField(
model_name='uncle',
name='spouse',
field=models.CharField(blank=True, max_length=100, null=True),
),
]
| 25.517241 | 74 | 0.563514 | 78 | 740 | 5.25641 | 0.5 | 0.131707 | 0.168293 | 0.197561 | 0.563415 | 0.563415 | 0.563415 | 0.563415 | 0.563415 | 0.563415 | 0 | 0.05501 | 0.312162 | 740 | 28 | 75 | 26.428571 | 0.750491 | 0.060811 | 0 | 0.545455 | 1 | 0 | 0.069264 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.045455 | 0 | 0.181818 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ba90ff316fd938f7888e365fc228063397dcc539 | 921 | py | Python | algorithms/recursion/find_uppercase.py | cakmakaf/python_coding_interview_question | 9bca1bff43b03ea747e96ad51b32040da7072aef | [
"MIT"
] | null | null | null | algorithms/recursion/find_uppercase.py | cakmakaf/python_coding_interview_question | 9bca1bff43b03ea747e96ad51b32040da7072aef | [
"MIT"
] | null | null | null | algorithms/recursion/find_uppercase.py | cakmakaf/python_coding_interview_question | 9bca1bff43b03ea747e96ad51b32040da7072aef | [
"MIT"
] | null | null | null | # Given a string, find the first uppercase character.
# Solve using both an iterative and recursive solution.
input_str_1 = "lucidProgramming"
input_str_2 = "LucidProgramming"
input_str_3 = "lucidprogramming"
def find_uppercase_iterative(input_str):
for i in range(len(input_str)):
if input_str[i].isupper():
return input_str[i]
return "No uppercase character found"
def find_uppercase_recursive(input_str, idx=0):
if input_str[idx].isupper():
return input_str[idx]
if idx == len(input_str) - 1:
return "No uppercase character found"
return find_uppercase_recursive(input_str, idx+1)
print(find_uppercase_iterative(input_str_1))
print(find_uppercase_iterative(input_str_2))
print(find_uppercase_iterative(input_str_3))
print(find_uppercase_recursive(input_str_1))
print(find_uppercase_recursive(input_str_2))
print(find_uppercase_recursive(input_str_3))
| 27.088235 | 55 | 0.764387 | 133 | 921 | 4.954887 | 0.270677 | 0.218513 | 0.163885 | 0.204856 | 0.566009 | 0.426404 | 0.109256 | 0 | 0 | 0 | 0 | 0.015287 | 0.147666 | 921 | 33 | 56 | 27.909091 | 0.824204 | 0.114007 | 0 | 0.1 | 0 | 0 | 0.128237 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0 | 0 | 0 | 0.35 | 0.3 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ba9fb8a4da40b2e207e6aac7065730689508d65b | 301 | py | Python | core/models.py | LeonardoCruzx/ListaTarefasBackend | 81f6bf5f2c64973fa703a3f96bb8cfb491c8b41b | [
"MIT"
] | 1 | 2020-08-26T23:55:33.000Z | 2020-08-26T23:55:33.000Z | core/models.py | LeonardoCruzx/ListaTarefasBackend | 81f6bf5f2c64973fa703a3f96bb8cfb491c8b41b | [
"MIT"
] | null | null | null | core/models.py | LeonardoCruzx/ListaTarefasBackend | 81f6bf5f2c64973fa703a3f96bb8cfb491c8b41b | [
"MIT"
] | null | null | null | from django.db import models
class Category(models.Model):
name = models.CharField(
max_length=30,
null=False,
unique=True
)
icon = models.CharField(
max_length=50,
null=False,
unique=True
)
class Meta:
ordering = ["-name"] | 18.8125 | 29 | 0.561462 | 33 | 301 | 5.060606 | 0.636364 | 0.179641 | 0.215569 | 0.287425 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020101 | 0.33887 | 301 | 16 | 30 | 18.8125 | 0.819095 | 0 | 0 | 0.285714 | 0 | 0 | 0.016556 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.071429 | 0 | 0.357143 | 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 | 0 | 0 | 0 | 0 | 2 |
baa8f7c752ca08985bb68e5d9981c4d3125698b1 | 159 | py | Python | easy/even_numbers.py | Amin-Abouee/code_eval | 8f0d53d2af128d7b57dd3fc8ff16616252f18a52 | [
"MIT"
] | null | null | null | easy/even_numbers.py | Amin-Abouee/code_eval | 8f0d53d2af128d7b57dd3fc8ff16616252f18a52 | [
"MIT"
] | null | null | null | easy/even_numbers.py | Amin-Abouee/code_eval | 8f0d53d2af128d7b57dd3fc8ff16616252f18a52 | [
"MIT"
] | null | null | null | import sys
with open(sys.argv[1],'r') as test_cases:
for test in test_cases:
test = test.rstrip()
if int(test[-1]) % 2 == 0:
print 1
else:
print 0 | 19.875 | 41 | 0.622642 | 30 | 159 | 3.233333 | 0.633333 | 0.185567 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.04878 | 0.226415 | 159 | 8 | 42 | 19.875 | 0.739837 | 0 | 0 | 0 | 0 | 0 | 0.00625 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.125 | null | null | 0.25 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
bac019df242c71d7cde4fc5acb6134972fe22464 | 146 | py | Python | pages/components/affix/_simple.py | AnnMarieW/dmc-docs | 5db1790b61e85209b85adb75ccf6e7462d93f231 | [
"MIT"
] | 6 | 2022-01-28T17:12:58.000Z | 2022-03-16T01:29:18.000Z | pages/components/affix/_simple.py | AnnMarieW/dmc-docs | 5db1790b61e85209b85adb75ccf6e7462d93f231 | [
"MIT"
] | 1 | 2022-01-07T21:21:07.000Z | 2022-01-22T12:07:28.000Z | pages/components/affix/_simple.py | AnnMarieW/dmc-docs | 5db1790b61e85209b85adb75ccf6e7462d93f231 | [
"MIT"
] | 1 | 2022-02-05T18:00:36.000Z | 2022-02-05T18:00:36.000Z | import dash_mantine_components as dmc
component = dmc.Affix(
dmc.Button("I'm in an Affix Component"), position={"bottom": 20, "right": 20}
)
| 24.333333 | 81 | 0.705479 | 22 | 146 | 4.590909 | 0.772727 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032258 | 0.150685 | 146 | 5 | 82 | 29.2 | 0.782258 | 0 | 0 | 0 | 0 | 0 | 0.246575 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
bac3098f4d54f2ca5a807259d083483cfa92d751 | 149 | py | Python | helita/__init__.py | jumasy/helita | 8f27cb1b7a0165a10028c11f43224a7e5b3dcc40 | [
"BSD-3-Clause"
] | null | null | null | helita/__init__.py | jumasy/helita | 8f27cb1b7a0165a10028c11f43224a7e5b3dcc40 | [
"BSD-3-Clause"
] | null | null | null | helita/__init__.py | jumasy/helita | 8f27cb1b7a0165a10028c11f43224a7e5b3dcc40 | [
"BSD-3-Clause"
] | null | null | null | """
Helita python library
"""
__all__ = ["io", "obs", "sim", "utils"]
#from . import io
#from . import obs
#from . import sim
#from . import utils
| 13.545455 | 39 | 0.61745 | 20 | 149 | 4.4 | 0.5 | 0.454545 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.194631 | 149 | 10 | 40 | 14.9 | 0.733333 | 0.610738 | 0 | 0 | 0 | 0 | 0.276596 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
bad4454cde9c84e9a297ac6f69c2ad754dde7729 | 1,012 | py | Python | migrations/versions/b823ccfc2d9b_.py | karenc/houston | 4eaaaf11d61394035e34b55bb847ea7eb4099c61 | [
"Apache-2.0"
] | 6 | 2021-04-06T19:50:52.000Z | 2022-01-19T17:42:33.000Z | migrations/versions/b823ccfc2d9b_.py | WildMeOrg/houston | 8102229421388e44234c07ee6cb73bf705b6fba0 | [
"Apache-2.0"
] | 491 | 2021-01-20T01:10:00.000Z | 2022-03-31T19:30:48.000Z | migrations/versions/b823ccfc2d9b_.py | karenc/houston | 4eaaaf11d61394035e34b55bb847ea7eb4099c61 | [
"Apache-2.0"
] | 2 | 2021-03-12T02:33:55.000Z | 2021-03-16T20:18:43.000Z | """empty message
Revision ID: b823ccfc2d9b
Revises: 2a02d5f72c3b
Create Date: 2021-08-10 05:37:19.652762
"""
# revision identifiers, used by Alembic.
revision = 'b823ccfc2d9b'
down_revision = '2a02d5f72c3b'
from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
import app
import app.extensions
def upgrade():
"""
Upgrade Semantic Description:
ENTER DESCRIPTION HERE
"""
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('collaboration', schema=None) as batch_op:
batch_op.drop_column('title')
# ### end Alembic commands ###
def downgrade():
"""
Downgrade Semantic Description:
ENTER DESCRIPTION HERE
"""
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('collaboration', schema=None) as batch_op:
batch_op.add_column(sa.Column('title', sa.VARCHAR(length=50), autoincrement=False, nullable=True))
# ### end Alembic commands ###
| 23 | 106 | 0.690711 | 120 | 1,012 | 5.725 | 0.508333 | 0.040757 | 0.069869 | 0.101892 | 0.41048 | 0.41048 | 0.41048 | 0.41048 | 0.41048 | 0.41048 | 0 | 0.056581 | 0.19664 | 1,012 | 43 | 107 | 23.534884 | 0.788438 | 0.406126 | 0 | 0.153846 | 0 | 0 | 0.114068 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.153846 | false | 0 | 0.384615 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
bad9fcbb774a307e2f2f29f4b18913a49ea23702 | 1,278 | py | Python | one_time_scripts/alter_2018-10-20.py | nilfoer/mangadb | 860d7de310002735631ea26810b4df5b6bc08d7b | [
"MIT"
] | 3 | 2021-01-14T16:22:41.000Z | 2022-02-21T03:31:22.000Z | one_time_scripts/alter_2018-10-20.py | nilfoer/mangadb | 860d7de310002735631ea26810b4df5b6bc08d7b | [
"MIT"
] | 13 | 2021-01-14T10:34:19.000Z | 2021-05-20T08:47:54.000Z | one_time_scripts/alter_2018-10-20.py | nilfoer/mangadb | 860d7de310002735631ea26810b4df5b6bc08d7b | [
"MIT"
] | 1 | 2022-02-24T03:10:04.000Z | 2022-02-24T03:10:04.000Z | import sqlite3
db_con = sqlite3.connect("./manga_db.sqlite", detect_types=sqlite3.PARSE_DECLTYPES)
db_con.row_factory = sqlite3.Row
with db_con:
c = db_con.executescript("""
PRAGMA foreign_keys=off;
BEGIN TRANSACTION;
DROP INDEX IF EXISTS id_onpage_on_site;
CREATE INDEX IF NOT EXISTS idx_id_onpage_imported_from ON
ExternalInfo (id_onpage, imported_from);
CREATE UNIQUE INDEX IF NOT EXISTS idx_artist_name ON Artist (name);
CREATE UNIQUE INDEX IF NOT EXISTS idx_category_name ON Category (name);
CREATE UNIQUE INDEX IF NOT EXISTS idx_character_name ON Character (name);
CREATE UNIQUE INDEX IF NOT EXISTS idx_collection_name ON Collection (name);
CREATE UNIQUE INDEX IF NOT EXISTS idx_groups_name ON Groups (name);
CREATE UNIQUE INDEX IF NOT EXISTS idx_list_name ON List (name);
CREATE UNIQUE INDEX IF NOT EXISTS idx_parody_name ON Parody (name);
CREATE UNIQUE INDEX IF NOT EXISTS idx_tag_name ON Tag (name);
DROP TRIGGER IF EXISTS set_last_update_ext_info;
COMMIT;
PRAGMA foreign_keys=on;
""")
| 42.6 | 91 | 0.634585 | 167 | 1,278 | 4.622754 | 0.317365 | 0.090674 | 0.11658 | 0.186529 | 0.382124 | 0.357513 | 0.357513 | 0.317358 | 0 | 0 | 0 | 0.004582 | 0.316901 | 1,278 | 29 | 92 | 44.068966 | 0.879725 | 0 | 0 | 0 | 0 | 0 | 0.869327 | 0.040689 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.136364 | 0 | 0.136364 | 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 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
bae10c8fc1289fb8fb67ea46991675a0983cce20 | 77 | py | Python | protos/__init__.py | oktoshi/OpenBazaar-Server | 605644c628db0d472e85380c4f16fafc13631991 | [
"MIT"
] | 723 | 2015-08-19T08:43:06.000Z | 2022-01-25T10:34:27.000Z | protos/__init__.py | oktoshi/OpenBazaar-Server | 605644c628db0d472e85380c4f16fafc13631991 | [
"MIT"
] | 470 | 2015-08-18T21:18:46.000Z | 2018-07-03T21:36:03.000Z | protos/__init__.py | mrudtf/OpenBazaar-Server | a3964b8337a2eb0815c29145d67782c5de1ada73 | [
"MIT"
] | 250 | 2015-08-19T03:01:02.000Z | 2022-01-23T21:05:25.000Z | __author__ = 'chris'
"""
Package for holding all of our protobuf classes
"""
| 15.4 | 47 | 0.714286 | 10 | 77 | 5.1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.168831 | 77 | 4 | 48 | 19.25 | 0.796875 | 0 | 0 | 0 | 0 | 0 | 0.227273 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
bae4690386f4d9932794ad10275725784ea3dd63 | 356 | py | Python | api/helper.py | vvatelot/ecoindex_api | 03ffe03c3e3d4e296b91e2396e90020a9ff2b33a | [
"MIT"
] | null | null | null | api/helper.py | vvatelot/ecoindex_api | 03ffe03c3e3d4e296b91e2396e90020a9ff2b33a | [
"MIT"
] | null | null | null | api/helper.py | vvatelot/ecoindex_api | 03ffe03c3e3d4e296b91e2396e90020a9ff2b33a | [
"MIT"
] | null | null | null | from api.models.responses import ExceptionResponse
def format_exception_response(exception: Exception) -> ExceptionResponse:
return ExceptionResponse(
exception=type(exception).__name__,
args=[arg for arg in exception.args if arg] if exception.args else [],
message=exception.msg if hasattr(exception, "msg") else None,
)
| 35.6 | 78 | 0.733146 | 41 | 356 | 6.219512 | 0.560976 | 0.101961 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.179775 | 356 | 9 | 79 | 39.555556 | 0.873288 | 0 | 0 | 0 | 0 | 0 | 0.008427 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.142857 | 0.142857 | 0.428571 | 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 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
baed839ee27f857c852b45297668c2d66d6970ae | 163 | py | Python | Driver.py | LeChosenOne/ClassifierToolkit | c601c212d98b949bd96f4badd08a27daeb0d283b | [
"MIT"
] | null | null | null | Driver.py | LeChosenOne/ClassifierToolkit | c601c212d98b949bd96f4badd08a27daeb0d283b | [
"MIT"
] | null | null | null | Driver.py | LeChosenOne/ClassifierToolkit | c601c212d98b949bd96f4badd08a27daeb0d283b | [
"MIT"
] | null | null | null | from ClassifierToolkit import NeuralNet
classifier = NeuralNet()
data = [[0,1], [1,1], [12,12], [10,10]]
labels = [1,2,3,4]
classifier.train(data, labels, (2,2))
| 23.285714 | 39 | 0.662577 | 26 | 163 | 4.153846 | 0.576923 | 0.037037 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.125874 | 0.122699 | 163 | 6 | 40 | 27.166667 | 0.629371 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
24087838c39f6708ba17e72353be93ed95c7cbca | 111 | py | Python | pynger/types.py | DottD/pynger | 9a24b43a2170234e5059a54ed20329e036260b0a | [
"MIT"
] | 1 | 2021-11-10T16:37:28.000Z | 2021-11-10T16:37:28.000Z | pynger/types.py | DottD/pynger | 9a24b43a2170234e5059a54ed20329e036260b0a | [
"MIT"
] | null | null | null | pynger/types.py | DottD/pynger | 9a24b43a2170234e5059a54ed20329e036260b0a | [
"MIT"
] | null | null | null | from typing import *
Field = NewType('Field', Any)
Image = NewType('Image', Any)
Mask = NewType('Mask', Any)
| 15.857143 | 29 | 0.666667 | 15 | 111 | 4.933333 | 0.533333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.162162 | 111 | 6 | 30 | 18.5 | 0.795699 | 0 | 0 | 0 | 0 | 0 | 0.126126 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
24099237d47bb52d216dc44074d5358af13639ba | 1,656 | py | Python | setup.py | maria-thom/currencycloud-python | ad02b72adc6ff46c31fadedb6575090e7c6eece6 | [
"MIT"
] | null | null | null | setup.py | maria-thom/currencycloud-python | ad02b72adc6ff46c31fadedb6575090e7c6eece6 | [
"MIT"
] | null | null | null | setup.py | maria-thom/currencycloud-python | ad02b72adc6ff46c31fadedb6575090e7c6eece6 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
from glob import glob
from os.path import basename
from os.path import splitext
from setuptools import find_packages
from setuptools import setup
setup(
name='currency_cloud',
version='4.6.0',
license='MIT',
description="Python SDK for the Currencycloud API.",
long_description='',
author='Currencycloud',
author_email='sdk@currencycloud.com',
url='https://github.com/CurrencyCloud/currencycloud-python',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
include_package_data=True,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
],
keywords=[],
install_requires=['requests', 'PyYAML', 'deprecation'],
tests_require=[
'pytest', 'mock', 'requests-mock', 'betamax', 'betamax-serializers'
],
test_suite='tests'
)
| 31.846154 | 75 | 0.628623 | 174 | 1,656 | 5.913793 | 0.5 | 0.184645 | 0.242954 | 0.151604 | 0.052478 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015516 | 0.221618 | 1,656 | 51 | 76 | 32.470588 | 0.782777 | 0.02657 | 0 | 0.047619 | 0 | 0 | 0.51118 | 0.013043 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.119048 | 0 | 0.119048 | 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 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.