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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6159565e49d76016beff99d40bf7ddaaa1ef655e | 260 | py | Python | server/User/views.py | raminawahda7/servize | 9941401c72a949c8c2ad83012ab5cc4276355b6c | [
"MIT"
] | null | null | null | server/User/views.py | raminawahda7/servize | 9941401c72a949c8c2ad83012ab5cc4276355b6c | [
"MIT"
] | null | null | null | server/User/views.py | raminawahda7/servize | 9941401c72a949c8c2ad83012ab5cc4276355b6c | [
"MIT"
] | null | null | null | from django.shortcuts import render
from rest_framework import generics
from User.models import User
from User.serialize import UserSerializer
class UserList(generics.ListCreateAPIView):
queryset=User.objects.all()
serializer_class=UserSerializer
| 26 | 43 | 0.823077 | 31 | 260 | 6.83871 | 0.612903 | 0.075472 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.126923 | 260 | 9 | 44 | 28.888889 | 0.933921 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.571429 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
618507bc18d917cec07c9e6cdacd2e8516f53280 | 9,661 | py | Python | pyspark_schema_mapping.py | Eng-Dan/B3-Historical-Data-Utilities | 82b406b6d62dce692380a82d6dc37bbfa0ef7835 | [
"MIT"
] | null | null | null | pyspark_schema_mapping.py | Eng-Dan/B3-Historical-Data-Utilities | 82b406b6d62dce692380a82d6dc37bbfa0ef7835 | [
"MIT"
] | null | null | null | pyspark_schema_mapping.py | Eng-Dan/B3-Historical-Data-Utilities | 82b406b6d62dce692380a82d6dc37bbfa0ef7835 | [
"MIT"
] | null | null | null | # Code for use in Jupyter Notebook
# The dataframe schema is applied as per B3 "SeriesHistórica_Layout.pdf" instructions available in "http://www.b3.com.br/pt_br/market-data-e-indices/servicos-de-dados/market-data/historico/mercado-a-vista/cotacoes-historicas/"
pip install pyspark
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
import pyspark.sql.functions as F
import pyspark.sql.types as T
import re
# Helper function
def test_regexp(stringData, expression, insensitiveFlag):
if insensitiveFlag:
pattern = re.compile(r"" + expression, re.I)
else:
pattern = re.compile(r"" + expression)
if re.search(pattern, stringData):
return True
return False
# set functions as a pyspark UDF
udf_test_regexp = F.udf(lambda stringData, expression, insensitiveFlag: test_regexp(stringData, expression, insensitiveFlag), returnType='boolean')
# Function
def apply_b3_schema(rawDataFrame):
'''Apply a data frame schema for the B3 Time Series Stock Data.
param: rawDataFrame: the dataframe created from the raw data file.
Returns a new pyspark DataFrame'''
newDF = rawDataFrame\
.withColumn('header_and_trail_test', udf_test_regexp(F.col('value'), F.lit('(COTAHIST)'), F.lit(True)))\
.filter(F.col('header_and_trail_test') == False)\
.withColumn('tipreg', F.substring(F.col('value'), 1, 2).cast(T.IntegerType()))\
.withColumn('datpre', F.to_date(\
F.concat(F.substring(F.col('value'), 3, 4),
F.lit("-"),
F.substring(F.col('value'), 7, 2),
F.lit("-"),
F.substring(F.col('value'), 9, 2)),
'yyyy-MM-dd'))\
.withColumn('codbdi', F.substring(F.col('value'), 11, 1))\
.withColumn('codneg', F.trim(F.substring(F.col('value'), 13, 12)))\
.withColumn('tpmerc', F.substring(F.col('value'), 25, 3).cast(T.IntegerType()))\
.withColumn('nomres', F.trim(F.substring(F.col('value'), 28, 12)))\
.withColumn('especi', F.substring(F.col('value'), 40, 10))\
.withColumn('prazot', F.trim(F.substring(F.col('value'), 50, 3)))\
.withColumn('modref', F.trim(F.substring(F.col('value'), 53, 4)))\
.withColumn('preabe', F.regexp_replace(\
F.concat(\
F.substring(F.col('value'), 57, 11),
F.lit("."),
F.substring(F.col('value'), 68, 2)),
r"^[0]*", "").cast(T.DecimalType(13, 2)))\
.withColumn('premax', F.regexp_replace(\
F.concat(\
F.substring(F.col('value'), 70, 11),
F.lit("."),
F.substring(F.col('value'), 81, 2)),
r"^[0]*", "").cast(T.DecimalType(13, 2)))\
.withColumn('premin', F.regexp_replace(\
F.concat(\
F.substring(F.col('value'), 83, 11),
F.lit("."),
F.substring(F.col('value'), 94, 2)),
r"^[0]*", "").cast(T.DecimalType(13, 2)))\
.withColumn('premed', F.regexp_replace(\
F.concat(\
F.substring(F.col('value'), 96, 11),
F.lit("."),
F.substring(F.col('value'), 107, 2)),
r"^[0]*", "").cast(T.DecimalType(13, 2)))\
.withColumn('preult', F.regexp_replace(\
F.concat(\
F.substring(F.col('value'), 109, 11),
F.lit("."),
F.substring(F.col('value'), 120, 2)),
r"^[0]*", "").cast(T.DecimalType(13, 2)))\
.withColumn('preofc', F.regexp_replace(\
F.concat(\
F.substring(F.col('value'), 122, 11),
F.lit("."),
F.substring(F.col('value'), 133, 2)),
r"^[0]*", "").cast(T.DecimalType(13, 2)))\
.withColumn('preofv', F.regexp_replace(\
F.concat(\
F.substring(F.col('value'), 135, 11),
F.lit("."),
F.substring(F.col('value'), 146, 2)),
r"^[0]*", "").cast(T.DecimalType(13, 2)))\
.withColumn('totneg', F.substring(F.col('value'), 148, 5).cast(T.IntegerType()))\
.withColumn('quatot', F.substring(F.col('value'), 153, 18).cast(T.IntegerType()))\
.withColumn('voltot', F.regexp_replace(\
F.concat(\
F.substring(F.col('value'), 171, 16),
F.lit("."),
F.substring(F.col('value'), 187, 2)),
r"^[0]*", "").cast(T.DecimalType(18, 2)))\
.withColumn('preexe', F.regexp_replace(\
F.concat(\
F.substring(F.col('value'), 189, 11),
F.lit("."),
F.substring(F.col('value'), 200, 2)),
r"^[0]*", "").cast(T.DecimalType(13, 2)))\
.withColumn('indopc', F.substring(F.col('value'), 202, 1).cast(T.IntegerType()))\
.withColumn('datven', F.to_date(\
F.concat(F.substring(F.col('value'), 203, 4),
F.lit("-"),
F.substring(F.col('value'), 207, 2),
F.lit("-"),
F.substring(F.col('value'), 209, 2)),
'yyyy-MM-dd'))\
.withColumn('fatcot', F.substring(F.col('value'), 211, 7).cast(T.IntegerType()))\
.withColumn('ptoexe', F.regexp_replace(\
F.concat(\
F.substring(F.col('value'), 218, 1),
F.lit("."),
F.substring(F.col('value'), 219, 6)),
r"^[0]*", "").cast(T.DecimalType(7, 6)))\
.withColumn('codisi', F.substring(F.col('value'), 231, 12))\
.withColumn('dismes', F.substring(F.col('value'), 243, 3).cast(T.IntegerType()))\
.drop('')
newDF = newDF.drop('value', 'header_and_trail_test')
return newDF
# Path to the time series raw data file dowloaded
FILE = '.../COTAHIST.AAAA.TXT'
b3TimeSeriesDF = spark.read.text(FILE)
# Function call and schema applycation
b3TimeSeriesDF = apply_b3_schema(b3TimeSeriesDF)
b3TimeSeriesDF.show()
| 69.007143 | 226 | 0.332781 | 748 | 9,661 | 4.254011 | 0.260695 | 0.052797 | 0.115965 | 0.17599 | 0.493086 | 0.370522 | 0.364551 | 0.319925 | 0.226901 | 0.146449 | 0 | 0.045341 | 0.543422 | 9,661 | 139 | 227 | 69.503597 | 0.676037 | 0.041197 | 0 | 0.298246 | 0 | 0 | 0.060669 | 0.009249 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.035088 | null | null | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 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 | 3 |
6191c912320a5b418c4ed688d7224f99e6cdb4d9 | 3,703 | py | Python | test/v3/test_service_credential_bindings.py | krezreb/cf-python-client | b8185bf8e71d2c81354a5721fbc1512b49e46cf1 | [
"Apache-2.0"
] | null | null | null | test/v3/test_service_credential_bindings.py | krezreb/cf-python-client | b8185bf8e71d2c81354a5721fbc1512b49e46cf1 | [
"Apache-2.0"
] | null | null | null | test/v3/test_service_credential_bindings.py | krezreb/cf-python-client | b8185bf8e71d2c81354a5721fbc1512b49e46cf1 | [
"Apache-2.0"
] | null | null | null | import unittest
from http import HTTPStatus
from abstract_test_case import AbstractTestCase
from cloudfoundry_client.v3.service_credential_bindings import ServiceCredentialBinding
class TestCredentialBindings(unittest.TestCase, AbstractTestCase):
@classmethod
def setUpClass(cls):
cls.mock_client_class()
def setUp(self):
self.build_client()
def test_list(self):
self.client.get.return_value = self.mock_response(
"/v3/service_credential_bindings", HTTPStatus.OK, None, "v3", "service_credential_bindings",
"GET_response.json"
)
all_service_credential_bindings = [credential_binding for credential_binding in
self.client.v3.service_credential_bindings.list()]
self.client.get.assert_called_with(self.client.get.return_value.url)
self.assertEqual(2, len(all_service_credential_bindings))
self.assertEqual(all_service_credential_bindings[0]["name"], "some-binding-name")
for domain in all_service_credential_bindings:
self.assertIsInstance(domain, ServiceCredentialBinding)
def test_get(self):
self.client.get.return_value = self.mock_response(
"/v3/service_credential_bindings/service_credential_binding_id",
HTTPStatus.OK,
None,
"v3",
"service_credential_bindings", "GET_{id}_response.json"
)
result = self.client.v3.service_credential_bindings.get("service_credential_binding_id")
self.client.get.assert_called_with(self.client.get.return_value.url)
self.assertIsNotNone(result)
self.assertIsInstance(result, ServiceCredentialBinding)
def test_get_then_details(self):
get_service_credential_binding = self.mock_response(
"/v3/service_credential_bindings/service_credential_binding_id",
HTTPStatus.OK,
None,
"v3",
"service_credential_bindings",
"GET_{id}_response.json")
get_details = self.mock_response(
"/v3/service_credential_bindings/service_credential_binding_id/details",
HTTPStatus.OK,
None,
"v3",
"service_credential_bindings",
"GET_{id}_details_response.json",
)
self.client.get.side_effect = [get_service_credential_binding, get_details]
service_credential_binding = self.client.v3.service_credential_bindings.get("service_credential_binding_id")
details = service_credential_binding.details()
self.assertIsInstance(details, dict)
self.assertEqual("mydb://user@password:example.com", details["credentials"]["connection"])
def test_get_then_parameters(self):
get_service_credential_binding = self.mock_response(
"/v3/service_credential_bindings/service_credential_binding_id",
HTTPStatus.OK,
None, "v3",
"service_credential_bindings",
"GET_{id}_response.json")
get_parameters = self.mock_response(
"/v3/service_credential_bindings/service_credential_binding_id/parameters",
HTTPStatus.OK,
None,
"v3",
"service_credential_bindings",
"GET_{id}_parameters_response.json",
)
self.client.get.side_effect = [get_service_credential_binding, get_parameters]
service_credential_binding = self.client.v3.service_credential_bindings.get("service_credential_binding_id")
parameters = service_credential_binding.parameters()
self.assertIsInstance(parameters, dict)
self.assertEqual("bar", parameters["foo"])
| 44.083333 | 116 | 0.68377 | 386 | 3,703 | 6.199482 | 0.178756 | 0.26285 | 0.21939 | 0.191809 | 0.625992 | 0.571249 | 0.555788 | 0.555788 | 0.536565 | 0.496448 | 0 | 0.006641 | 0.227383 | 3,703 | 83 | 117 | 44.614458 | 0.82978 | 0 | 0 | 0.4 | 0 | 0 | 0.227383 | 0.206589 | 0 | 0 | 0 | 0 | 0.146667 | 1 | 0.08 | false | 0.013333 | 0.053333 | 0 | 0.146667 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
61959d6aa035279f7d95869a58ced3839f31a7bd | 517 | py | Python | Paradigmas Python/aula09/exercicio1.py | Neto002/Estacio | 0c89cefb4d68a1054aab881099c6191cf8000392 | [
"MIT"
] | null | null | null | Paradigmas Python/aula09/exercicio1.py | Neto002/Estacio | 0c89cefb4d68a1054aab881099c6191cf8000392 | [
"MIT"
] | null | null | null | Paradigmas Python/aula09/exercicio1.py | Neto002/Estacio | 0c89cefb4d68a1054aab881099c6191cf8000392 | [
"MIT"
] | null | null | null | n1 = int(input('Digite o primeiro número: '))
n2 = int(input('Digite o segundo número: '))
n3 = int(input('Digite o terceiro número: '))
n4 = int(input('Digite o quarto número: '))
n5 = int(input('Digite o quinto número: '))
n6 = int(input('Digite o sexto número: '))
n7 = int(input('Digite o sétimo número: '))
n8 = int(input('Digite o oitavo número: '))
n9 = int(input('Digite o nono número: '))
n10 = int(input('Digite o décimo número: '))
media = (n1+n2+n3+n4+n5+n6+n7+n8+n9+n10)/10
print(f'A média é: {media}') | 36.928571 | 45 | 0.655706 | 88 | 517 | 3.852273 | 0.363636 | 0.235988 | 0.412979 | 0.442478 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.05467 | 0.15087 | 517 | 14 | 46 | 36.928571 | 0.71754 | 0 | 0 | 0 | 0 | 0 | 0.501931 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.083333 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
61998028999ced69f5b9f8be85f4d6ad4f0f199e | 292 | py | Python | appbak/main/__init__.py | Linyameng/alphadata-dev | 7a48c9ddf24442a89f3f8ab1ba78e573c8844f26 | [
"Apache-2.0"
] | null | null | null | appbak/main/__init__.py | Linyameng/alphadata-dev | 7a48c9ddf24442a89f3f8ab1ba78e573c8844f26 | [
"Apache-2.0"
] | null | null | null | appbak/main/__init__.py | Linyameng/alphadata-dev | 7a48c9ddf24442a89f3f8ab1ba78e573c8844f26 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
"""
Created on 2018/5/24
@author: xing yan
"""
from flask import Blueprint
from ..models import Permission
main = Blueprint('main', __name__)
from . import views, errors
@main.app_context_processor
def inject_permissions():
return dict(Permission=Permission) | 16.222222 | 38 | 0.722603 | 38 | 292 | 5.368421 | 0.763158 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032258 | 0.150685 | 292 | 18 | 38 | 16.222222 | 0.790323 | 0.212329 | 0 | 0 | 0 | 0 | 0.017937 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.428571 | 0.142857 | 0.714286 | 0.285714 | 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 | 1 | 1 | 0 | 0 | 3 |
61b77517bc469faac2069d4959dd926f03c657dd | 150 | py | Python | 50/36.py | ElyKar/Euler | 38744b553b22565ac30ece06e2e3fbf3408068e2 | [
"MIT"
] | null | null | null | 50/36.py | ElyKar/Euler | 38744b553b22565ac30ece06e2e3fbf3408068e2 | [
"MIT"
] | null | null | null | 50/36.py | ElyKar/Euler | 38744b553b22565ac30ece06e2e3fbf3408068e2 | [
"MIT"
] | null | null | null | #!/bin/python
def pal(x): return list(x) == [i for i in reversed(x)]
print sum([x for x in range(1000000) if pal(str(x)) and pal("{0:b}".format(x))]) | 37.5 | 80 | 0.626667 | 32 | 150 | 2.9375 | 0.65625 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.062016 | 0.14 | 150 | 4 | 80 | 37.5 | 0.666667 | 0.08 | 0 | 0 | 0 | 0 | 0.036232 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.5 | 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 | 1 | 0 | 3 |
61bbbc83fc0928b033f99c3a6073ae00c83f434e | 67 | py | Python | EstruturaSequencial/Problem02.py | MatheusKlebson/solving-problems-with-programming | 2b91df076c3d3e30f12fe12b403102d35b02ac45 | [
"MIT"
] | null | null | null | EstruturaSequencial/Problem02.py | MatheusKlebson/solving-problems-with-programming | 2b91df076c3d3e30f12fe12b403102d35b02ac45 | [
"MIT"
] | null | null | null | EstruturaSequencial/Problem02.py | MatheusKlebson/solving-problems-with-programming | 2b91df076c3d3e30f12fe12b403102d35b02ac45 | [
"MIT"
] | null | null | null | num = int(input("Number: "))
print(f"the number entered was {num}") | 33.5 | 38 | 0.671642 | 11 | 67 | 4.090909 | 0.818182 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.119403 | 67 | 2 | 38 | 33.5 | 0.762712 | 0 | 0 | 0 | 0 | 0 | 0.529412 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.5 | 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 | 1 | 0 | 3 |
61bfebd4fb26ce2eaac17e68cafb0f202d83fe83 | 337 | py | Python | clase7/Tarea/herencia/paquete/listamultimedia.py | Tank3-TK3/codigo-basico-Python | 580e8d284fa8a4d70b2a264762c91bd64c89ab80 | [
"MIT"
] | 7 | 2021-04-19T01:32:49.000Z | 2021-06-04T17:38:04.000Z | clase7/Tarea/herencia/paquete/listamultimedia.py | Tank3-TK3/codigo-basico-Python | 580e8d284fa8a4d70b2a264762c91bd64c89ab80 | [
"MIT"
] | null | null | null | clase7/Tarea/herencia/paquete/listamultimedia.py | Tank3-TK3/codigo-basico-Python | 580e8d284fa8a4d70b2a264762c91bd64c89ab80 | [
"MIT"
] | null | null | null | class ListaMultimedia():
archivos = []
contar = 0
def __init__(self,archivos=[]):
self.archivos = archivos
def agregar(self,p):
self.archivos.append(p)
self.contar += 1
def mostrar(self):
for p in self.archivos:
print(p)
def cantidad(self):
return"""Total de objetos en la lista: {}""".format(self.contar) | 25.923077 | 66 | 0.655786 | 46 | 337 | 4.717391 | 0.543478 | 0.221198 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00738 | 0.195846 | 337 | 13 | 66 | 25.923077 | 0.793358 | 0 | 0 | 0 | 0 | 0 | 0.09816 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.307692 | false | 0 | 0 | 0.076923 | 0.538462 | 0.076923 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
4efbbd074d5b317b79249d546292037ebdea30c0 | 1,282 | py | Python | radiaTest-server/server/apps/celerytask/routes.py | openeuler-mirror/radiaTest | 4a067511d6ab69f76b8dc08667b8a1f8c1c73d23 | [
"MulanPSL-1.0"
] | null | null | null | radiaTest-server/server/apps/celerytask/routes.py | openeuler-mirror/radiaTest | 4a067511d6ab69f76b8dc08667b8a1f8c1c73d23 | [
"MulanPSL-1.0"
] | 1 | 2022-03-23T06:53:25.000Z | 2022-03-23T06:53:25.000Z | radiaTest-server/server/apps/celerytask/routes.py | openeuler-mirror/radiaTest | 4a067511d6ab69f76b8dc08667b8a1f8c1c73d23 | [
"MulanPSL-1.0"
] | null | null | null | # Copyright (c) [2022] Huawei Technologies Co.,Ltd.ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
####################################
# @Author :
# @email :
# @Date :
# @License : Mulan PSL v2
#####################################
from flask_restful import Resource
from flask_pydantic import validate
from server.utils.auth_util import auth
from server.utils.response_util import response_collect
from server.schema.celerytask import CeleryTaskCreateSchema, CeleryTaskQuerySchema
from .handler import CeleryTaskHandler
class CeleryTaskEvent(Resource):
@auth.login_required
@response_collect
@validate()
def get(self, query: CeleryTaskQuerySchema):
return CeleryTaskHandler.get_all(query)
@auth.login_required
@response_collect
@validate()
def post(self, body: CeleryTaskCreateSchema):
return CeleryTaskHandler.create(body) | 33.736842 | 82 | 0.710608 | 156 | 1,282 | 5.775641 | 0.621795 | 0.035516 | 0.044395 | 0.028857 | 0.09545 | 0.09545 | 0.09545 | 0 | 0 | 0 | 0 | 0.008419 | 0.166147 | 1,282 | 38 | 83 | 33.736842 | 0.834425 | 0.417317 | 0 | 0.352941 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.117647 | false | 0 | 0.352941 | 0.117647 | 0.647059 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 3 |
f60bac60c1b9635d47ad8a383340008e58827de4 | 221 | py | Python | pycoin/coins/bcash/Tx.py | jaschadub/pycoin | 1e8d0d9fe20ce0347b97847bb529cd1bd84c7442 | [
"MIT"
] | 1,210 | 2015-01-02T13:36:28.000Z | 2022-03-30T00:52:22.000Z | pycoin/coins/bcash/Tx.py | impactog/pycoin | 3db6f82afa3054d8d07caca4909e1aed3de2fceb | [
"MIT"
] | 280 | 2015-01-05T23:16:47.000Z | 2022-02-22T22:02:17.000Z | pycoin/coins/bcash/Tx.py | impactog/pycoin | 3db6f82afa3054d8d07caca4909e1aed3de2fceb | [
"MIT"
] | 459 | 2015-01-10T00:15:57.000Z | 2022-03-16T12:04:40.000Z |
from .SolutionChecker import BcashSolutionChecker
from .Solver import BcashSolver
from pycoin.coins.bitcoin.Tx import Tx as BaseTx
class Tx(BaseTx):
Solver = BcashSolver
SolutionChecker = BcashSolutionChecker
| 20.090909 | 49 | 0.800905 | 24 | 221 | 7.375 | 0.541667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.153846 | 221 | 10 | 50 | 22.1 | 0.946524 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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 | 3 |
f6449665ccee3b62654da9be0f7add3b7ad0622c | 6,771 | py | Python | Project/forms/test1_form.py | mihdenis85/psycho_test | 51bbe82043427d48e80ff36197815212c5c2a14c | [
"MIT"
] | null | null | null | Project/forms/test1_form.py | mihdenis85/psycho_test | 51bbe82043427d48e80ff36197815212c5c2a14c | [
"MIT"
] | null | null | null | Project/forms/test1_form.py | mihdenis85/psycho_test | 51bbe82043427d48e80ff36197815212c5c2a14c | [
"MIT"
] | null | null | null | from flask_wtf import FlaskForm
from wtforms import SubmitField, RadioField
from wtforms.validators import DataRequired
class Test1Form(FlaskForm):
question1 = RadioField('Label', choices=[('0', 'Инженер-технолог'), ('1', 'Инженер-конструктор')],
validators=[DataRequired(), ])
question2 = RadioField('Label', choices=[('0', 'Электрорадиотехник'), ('1', 'Врач-терапевт')],
validators=[DataRequired(), ])
question3 = RadioField('Label', choices=[('0', 'Инженер-программист'), ('1', 'Мехатроник')],
validators=[DataRequired(), ])
question4 = RadioField('Label', choices=[('0', 'Фотограф'), ('1', 'Маркетолог')],
validators=[DataRequired(), ])
question5 = RadioField('Label', choices=[('0', 'Спасатель МЧС'), ('1', 'Дизайнер')],
validators=[DataRequired(), ])
question6 = RadioField('Label', choices=[('0', 'Политолог'), ('1', 'Психиатр')],
validators=[DataRequired(), ])
question7 = RadioField('Label', choices=[('0', 'Ученый химик'), ('1', 'Бухгалтер')],
validators=[DataRequired(), ])
question8 = RadioField('Label', choices=[('0', 'Философ'), ('1', 'Предприниматель')],
validators=[DataRequired(), ])
question9 = RadioField('Label', choices=[('0', 'Лингвист'), ('1', 'Модельер')],
validators=[DataRequired(), ])
question10 = RadioField('Label', choices=[('0', 'Инспектор службы занятости населения'),
('1', 'SEO-специалист')],
validators=[DataRequired(), ])
question11 = RadioField('Label', choices=[('0', 'Социальный педагог'), ('1', 'Работник банка')],
validators=[DataRequired(), ])
question12 = RadioField('Label', choices=[('0', 'Тренер'), ('1', 'Нотариус')],
validators=[DataRequired(), ])
question13 = RadioField('Label', choices=[('0', 'Нотариус'), ('1', 'Менеджер')],
validators=[DataRequired(), ])
question14 = RadioField('Label', choices=[('0', 'Перфораторщик'), ('1', 'Художник')],
validators=[DataRequired(), ])
question15 = RadioField('Label', choices=[('0', 'Политический деятель'), ('1', 'Писатель')],
validators=[DataRequired(), ])
question16 = RadioField('Label', choices=[('0', 'Дизайнер интерфейсов'), ('1', 'Метеоролог')],
validators=[DataRequired(), ])
question17 = RadioField('Label', choices=[('0', 'Водитель'), ('1', 'Работник пресс-службы')],
validators=[DataRequired(), ])
question18 = RadioField('Label', choices=[('0', 'Проектировщик'), ('1', 'Риэлтор')],
validators=[DataRequired(), ])
question19 = RadioField('Label', choices=[('0', 'Специалист по ремонту компьютеров и оргтехники'),
('1', 'Секретарь-референт')],
validators=[DataRequired(), ])
question20 = RadioField('Label', choices=[('0', 'Микробиолог'), ('1', 'Психолог')],
validators=[DataRequired(), ])
question21 = RadioField('Label', choices=[('0', 'Видеооператор'), ('1', 'Режиссер')],
validators=[DataRequired(), ])
question22 = RadioField('Label', choices=[('0', 'Экономист'), ('1', 'Фармацевт')],
validators=[DataRequired(), ])
question23 = RadioField('Label', choices=[('0', 'Зоолог'), ('1', 'Главный инженер')],
validators=[DataRequired(), ])
question24 = RadioField('Label', choices=[('0', 'Программист'), ('1', 'Архитектор')],
validators=[DataRequired(), ])
question25 = RadioField('Label', choices=[('0', 'Работник инспекции по делам несовершеннолетних'),
('1', 'Сетевой маркетинг')],
validators=[DataRequired(), ])
question26 = RadioField('Label', choices=[('0', 'Преподаватель'), ('1', 'Банкир')],
validators=[DataRequired(), ])
question27 = RadioField('Label', choices=[('0', 'Воспитатель'), ('1', 'Декоратор')],
validators=[DataRequired(), ])
question28 = RadioField('Label', choices=[('0', 'Реставратор'), ('1', 'Зав. отделом предприятия')],
validators=[DataRequired(), ])
question29 = RadioField('Label', choices=[('0', 'Корректор'), ('1', 'Литератор и кинокритик')],
validators=[DataRequired(), ])
question30 = RadioField('Label', choices=[('0', 'Журналист'), ('1', 'Визажист')],
validators=[DataRequired(), ])
question31 = RadioField('Label', choices=[('0', 'Парикмахер'), ('1', 'Социолог')],
validators=[DataRequired(), ])
question32 = RadioField('Label', choices=[('0', 'Экспедитор'), ('1', 'Редактор')],
validators=[DataRequired(), ])
question33 = RadioField('Label', choices=[('0', 'Ветеринар'), ('1', 'Финансист')],
validators=[DataRequired(), ])
question34 = RadioField('Label', choices=[('0', 'Автомеханик'), ('1', 'Стилист')],
validators=[DataRequired(), ])
question35 = RadioField('Label', choices=[('0', 'Археолог'), ('1', 'Эксперт')],
validators=[DataRequired(), ])
question36 = RadioField('Label', choices=[('0', 'Специалист в области кибербезопасности'),
('1', 'Корреспондент')],
validators=[DataRequired(), ])
question37 = RadioField('Label', choices=[('0', 'Эколог'), ('1', 'Актер')],
validators=[DataRequired(), ])
question38 = RadioField('Label', choices=[('0', 'Логопед'), ('1', 'Контролер')],
validators=[DataRequired(), ])
question39 = RadioField('Label', choices=[('0', 'Адвокат'), ('1', 'Директор')],
validators=[DataRequired(), ])
question40 = RadioField('Label', choices=[('0', 'Налоговый инспектор'), ('1', 'Продюсер')],
validators=[DataRequired(), ])
question41 = RadioField('Label', choices=[('0', 'Поэт, писатель'), ('1', 'Продавец')],
validators=[DataRequired(), ])
question42 = RadioField('Label', choices=[('0', 'Криминалист'), ('1', 'Композитор')],
validators=[DataRequired(), ])
submit = SubmitField('Отправить') | 65.105769 | 103 | 0.517944 | 478 | 6,771 | 7.334728 | 0.34728 | 0.179692 | 0.263548 | 0.275528 | 0.035938 | 0 | 0 | 0 | 0 | 0 | 0 | 0.03314 | 0.286959 | 6,771 | 104 | 104 | 65.105769 | 0.693041 | 0 | 0 | 0.451613 | 0 | 0 | 0.199646 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.032258 | 0 | 0.505376 | 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 | 1 | 0 | 0 | 3 |
f6506ca7607945d80103a52812e6a43312dae96b | 1,544 | py | Python | BiModNeuroCNN/models/network_utils.py | cfcooney/BiModNeuroCNN | f79da6150b4186bcbc15d876394f4af8a47076d0 | [
"MIT"
] | 4 | 2020-10-31T21:20:12.000Z | 2022-01-05T16:13:07.000Z | BiModNeuroCNN/models/network_utils.py | cfcooney/BiModNeuroCNN | f79da6150b4186bcbc15d876394f4af8a47076d0 | [
"MIT"
] | null | null | null | BiModNeuroCNN/models/network_utils.py | cfcooney/BiModNeuroCNN | f79da6150b4186bcbc15d876394f4af8a47076d0 | [
"MIT"
] | null | null | null | import torch as th
def _transpose_time_to_spat(x):
return x.permute(0, 3, 2, 1)
def tensor_size(x):
print(x.size())
return x
def reshape_tensor(x):
x
return x.view(x.size(0),x.size(1)*x.size(2)*1)
def reshape_output(x):
return x.view(x.size(0),4, 1 ,1)
def reshape_4_lstm(x):
return x.view(x.size(0),1,x.size(1))
def dense_input(x):
return x.size(2)
def tensor_print(x):
print(x.data.cpu().numpy())
return x
def linear_input_shape(x):
print(x.size(1)*x.size(2))
return x.size(1)*x.size(2)
def mean_inplace(tensor_1, tensor_2):
"""
function for meaning softmax outputs from two networks,
Cuurently not able to use as inplace changes to the tensor
cause problems with backpropagation
:param tensor_1:
:param tensor_2:
:return:
"""
for i in range(len(tensor_1)):
for j in range(len(tensor_1[i])):
tensor_1[i][j] = (tensor_1[i][j] + tensor_2[i][j]) / 2
return tensor_1
def new_mean(tensor_1, tensor_2):
avg = []
for sm1, sm2 in zip(tensor_1, tensor_2):
avg.append([(a+b) / 2 for a,b in zip(sm1, sm2)])
avg = th.tensor(avg, dtype=th.float32).cuda()
return avg
# remove empty dim at end and potentially remove empty time dim
# do not just use squeeze as we never want to remove first dim
def _squeeze_final_output(x):
#print(x.shape)
assert x.size()[3] == 1
x = x[:, :, :, 0]
if x.size()[2] == 1:
x = x[:, :, 0]
return x
| 25.733333 | 67 | 0.599093 | 267 | 1,544 | 3.344569 | 0.318352 | 0.078387 | 0.044793 | 0.040314 | 0.203807 | 0.100784 | 0.06047 | 0 | 0 | 0 | 0 | 0.042832 | 0.259067 | 1,544 | 59 | 68 | 26.169492 | 0.737762 | 0.214378 | 0 | 0.078947 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.026316 | 1 | 0.289474 | false | 0 | 0.026316 | 0.105263 | 0.605263 | 0.105263 | 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 | 1 | 0 | 0 | 3 |
9ca0d0017f0036f4a1ef44435d40daf05056e011 | 124 | py | Python | notebooks/code/mysleep.py | NCAR/pangeo-tutorial-sea-2018 | b649c5914c9cd2c6ded166400ac50d6fc883b9bf | [
"CC-BY-4.0"
] | 32 | 2018-02-23T21:43:45.000Z | 2022-03-02T02:25:04.000Z | notebooks/code/mysleep.py | NCAR/pangeo-tutorial-sea-2018 | b649c5914c9cd2c6ded166400ac50d6fc883b9bf | [
"CC-BY-4.0"
] | 9 | 2018-02-23T21:45:45.000Z | 2018-11-28T00:06:55.000Z | notebooks/code/mysleep.py | NCAR/pangeo-tutorial-sea-2018 | b649c5914c9cd2c6ded166400ac50d6fc883b9bf | [
"CC-BY-4.0"
] | 9 | 2018-02-24T05:13:49.000Z | 2022-02-20T16:31:45.000Z | import time
from threading import Lock
lock = Lock()
def sleep(n):
lock.acquire()
time.sleep(n)
lock.release()
| 13.777778 | 26 | 0.66129 | 18 | 124 | 4.555556 | 0.555556 | 0.195122 | 0.243902 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.217742 | 124 | 8 | 27 | 15.5 | 0.845361 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.285714 | 0 | 0.428571 | 0 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9ca97e3bd788884e22b0ee2079fe850667436472 | 176 | py | Python | langlab/__main__.py | grnydawn/langlab | 1817b0a3798629d712ab8a0a93c59e921f3ab123 | [
"MIT"
] | null | null | null | langlab/__main__.py | grnydawn/langlab | 1817b0a3798629d712ab8a0a93c59e921f3ab123 | [
"MIT"
] | null | null | null | langlab/__main__.py | grnydawn/langlab | 1817b0a3798629d712ab8a0a93c59e921f3ab123 | [
"MIT"
] | null | null | null | """main entry for langlab command-line interface"""
def main():
from langlab import Langlab
ret, fwds = Langlab().run_command()
if __name__ == "__main__":
main()
| 19.555556 | 51 | 0.664773 | 22 | 176 | 4.909091 | 0.681818 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.198864 | 176 | 8 | 52 | 22 | 0.765957 | 0.255682 | 0 | 0 | 0 | 0 | 0.064 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | true | 0 | 0.2 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9cb9a6e4c70c5e758b7abc875412369ddcb59f32 | 2,917 | py | Python | py/orbit/aperture/ApertureLatticeRangeModifications.py | LeoRya/py-orbit | 340b14b6fd041ed8ec2cc25b0821b85742aabe0c | [
"MIT"
] | 17 | 2018-02-09T23:39:06.000Z | 2022-03-04T16:27:04.000Z | py/orbit/aperture/ApertureLatticeRangeModifications.py | LeoRya/py-orbit | 340b14b6fd041ed8ec2cc25b0821b85742aabe0c | [
"MIT"
] | 22 | 2017-05-31T19:40:14.000Z | 2021-09-24T22:07:47.000Z | py/orbit/aperture/ApertureLatticeRangeModifications.py | LeoRya/py-orbit | 340b14b6fd041ed8ec2cc25b0821b85742aabe0c | [
"MIT"
] | 37 | 2016-12-08T19:39:35.000Z | 2022-02-11T19:59:34.000Z | """
Module. Includes functions that will modify the accelerator lattice by inserting the one teapot node accelerator node.
"""
# import the auxiliary classes
from orbit.utils import orbitFinalize
# import general accelerator elements and lattice
from orbit.lattice import AccLattice, AccNode, AccActionsContainer, AccNodeBunchTracker
# import Teapot Aperture node
from aperture import Aperture
from TeapotApertureNode import TeapotApertureNode, CircleApertureNode, EllipseApertureNode, RectangleApertureNode
from ApertureLatticeModifications import addTeapotApertureNode
# import teapot drift class
from orbit.teapot import DriftTEAPOT
#This create a set of circular apertures. a is the radius of the apertures, s is the starting position, e is the ending position, and c is the x offset and d is the y offset of the apertures.
def addCircleApertureSet(a, lattice, s = 0, e = 0, c = 0, d = 0):
if e > lattice.getLength():
e = lattice.getLength()
print 'Warning, end position exceeding lattice length. Resetting to lattice length.'
position = s
for node in lattice.getNodes():
if(isinstance(node,DriftTEAPOT)):
positiont = lattice.getNodePositionsDict()[node][0]
if positiont > position and positiont < e:
position = positiont
Aperturenode = CircleApertureNode(a, c, d)
addTeapotApertureNode(lattice, position, Aperturenode)
#This create a set of eliptic apertures. a is the x radius and b is the y radius of the apertures, s is the starting position, e is the ending position, and c is the x offset and d is the y offset of the apertures.
def addEllipseApertureSet(a, b, lattice, s = 0, e = 0, c = 0, d = 0):
if e > lattice.getLength():
e = lattice.getLength()
print 'Warning, end position exceeding lattice length. Resetting to lattice length.'
position = s
for node in lattice.getNodes():
if(isinstance(node,DriftTEAPOT)):
positiont = lattice.getNodePositionsDict()[node][0]
if positiont > position and positiont < e:
position = positiont
Aperturenode = EllipseApertureNode(a, b, c, d)
addTeapotApertureNode(lattice, position, Aperturenode)
#This create a set of rectangular apertures. a is the x half width and b is the y half hight of the apertures, s is the starting position, e is the ending position, and c is the x offset and d is the y offset of the apertures.
def addRectangleApertureSet(a, b, lattice, s = 0, e = 0, c = 0, d = 0):
if e > lattice.getLength():
e = lattice.getLength()
print 'Warning, end position exceeding lattice length. Resetting to lattice length.'
position = s
for node in lattice.getNodes():
if(isinstance(node,DriftTEAPOT)):
positiont = lattice.getNodePositionsDict()[node][0]
if positiont > position and positiont < e:
position = positiont
Aperturenode = RectangleApertureNode(a, b, c, d)
addTeapotApertureNode(lattice, position, Aperturenode)
| 41.084507 | 226 | 0.741858 | 394 | 2,917 | 5.492386 | 0.213198 | 0.039279 | 0.038817 | 0.019409 | 0.661275 | 0.629852 | 0.629852 | 0.629852 | 0.604898 | 0.604898 | 0 | 0.0063 | 0.18375 | 2,917 | 70 | 227 | 41.671429 | 0.902562 | 0.260199 | 0 | 0.714286 | 0 | 0 | 0.112815 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.142857 | null | null | 0.071429 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 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 | 3 |
9cc495d303bd4d2343150b57400509e31d1d1752 | 809 | py | Python | bin/bin.symlink/import_photos.py | bencaron/dotfiles | 4f8afa32dfd4296c9ed3ebd31802fb0bd40a4981 | [
"MIT"
] | null | null | null | bin/bin.symlink/import_photos.py | bencaron/dotfiles | 4f8afa32dfd4296c9ed3ebd31802fb0bd40a4981 | [
"MIT"
] | 1 | 2015-05-19T19:43:50.000Z | 2015-05-22T01:40:49.000Z | bin/bin.symlink/import_photos.py | bencaron/dotfiles | 4f8afa32dfd4296c9ed3ebd31802fb0bd40a4981 | [
"MIT"
] | null | null | null | #!/usr/bin/python
# -*- coding: iso-8859-1 -*-
import sys, os, datetime
# Variables
# Moment de l'import
#DATE_IMPORT=`date +%F-%R:%S`
date_import = datetime.datetime.today().strftime("%F-%R:%S")
# Source des photos : FIXME: recu par l'exterieur?
PathSRC= sys.argv[1] or '/media/disk'
# Ou vont les photos
PathPhotos = os.getenv('HOME') + os.sep + 'photos'
print "date, pathsrc, pathphotos: %s, %s, %s" % (date_import, PathSRC, PathPhotos)
###########################
# L'action
##########
# on boucle pour prendre les photos trouvés sur SRC et les copiés local dans $PHOTO/tmp
# Rouler exiftool pour classer selon la date dans PathPhotos
# Symlinker vers PathPhotos/nouveaux/DATE_IMPORT pour importation par iPhotos et cie.
# Faire une copie vers BackupDest
# Supprimer les photos de la source
| 23.114286 | 87 | 0.681088 | 118 | 809 | 4.635593 | 0.601695 | 0.073126 | 0.010969 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008759 | 0.153276 | 809 | 34 | 88 | 23.794118 | 0.789781 | 0.583436 | 0 | 0 | 0 | 0 | 0.230769 | 0 | 0 | 0 | 0 | 0.029412 | 0 | 0 | null | null | 0 | 0.6 | null | null | 0.2 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
9cd043ab86199a82e8ab7597a54870bab5883388 | 8,678 | py | Python | release/stubs.min/System/Runtime/InteropServices/__init___parts/UCOMIMoniker.py | YKato521/ironpython-stubs | b1f7c580de48528490b3ee5791b04898be95a9ae | [
"MIT"
] | null | null | null | release/stubs.min/System/Runtime/InteropServices/__init___parts/UCOMIMoniker.py | YKato521/ironpython-stubs | b1f7c580de48528490b3ee5791b04898be95a9ae | [
"MIT"
] | null | null | null | release/stubs.min/System/Runtime/InteropServices/__init___parts/UCOMIMoniker.py | YKato521/ironpython-stubs | b1f7c580de48528490b3ee5791b04898be95a9ae | [
"MIT"
] | null | null | null | class UCOMIMoniker:
""" Use System.Runtime.InteropServices.ComTypes.IMoniker instead. """
def BindToObject(self, pbc, pmkToLeft, riidResult, ppvResult):
"""
BindToObject(self: UCOMIMoniker,pbc: UCOMIBindCtx,pmkToLeft: UCOMIMoniker,riidResult: Guid) -> (Guid,object)
Uses the moniker to bind to the object it identifies.
pbc: A reference to the IBindCtx interface on the bind context object used in this binding operation.
pmkToLeft: A reference to the moniker to the left of this moniker,if the moniker is part of a composite
moniker.
riidResult: The interface identifier (IID) of the interface the client intends to use to communicate with
the object that the moniker identifies.
"""
pass
def BindToStorage(self, pbc, pmkToLeft, riid, ppvObj):
"""
BindToStorage(self: UCOMIMoniker,pbc: UCOMIBindCtx,pmkToLeft: UCOMIMoniker,riid: Guid) -> (Guid,object)
Retrieves an interface pointer to the storage that contains the object identified by the moniker.
pbc: A reference to the IBindCtx interface on the bind context object used during this binding
operation.
pmkToLeft: A reference to the moniker to the left of this moniker,if the moniker is part of a composite
moniker.
riid: The interface identifier (IID) of the storage interface requested.
"""
pass
def CommonPrefixWith(self, pmkOther, ppmkPrefix):
"""
CommonPrefixWith(self: UCOMIMoniker,pmkOther: UCOMIMoniker) -> UCOMIMoniker
Creates a new moniker based on the common prefix that this moniker shares with another moniker.
pmkOther: A reference to the IMoniker interface on another moniker to compare with this for a common
prefix.
"""
pass
def ComposeWith(self, pmkRight, fOnlyIfNotGeneric, ppmkComposite):
"""
ComposeWith(self: UCOMIMoniker,pmkRight: UCOMIMoniker,fOnlyIfNotGeneric: bool) -> UCOMIMoniker
Combines the current moniker with another moniker,creating a new composite moniker.
pmkRight: A reference to the IMoniker interface on the moniker to compose onto the end of this moniker.
fOnlyIfNotGeneric: If true,the caller requires a nongeneric composition,so the operation proceeds only if
pmkRight is a moniker class that this moniker can compose with in some way other than forming a
generic composite. If false,the method can create a generic composite if necessary.
"""
pass
def Enum(self, fForward, ppenumMoniker):
"""
Enum(self: UCOMIMoniker,fForward: bool) -> UCOMIEnumMoniker
Supplies a pointer to an enumerator that can enumerate the components of a composite moniker.
fForward: If true,enumerates the monikers from left to right. If false,enumerates from right to left.
"""
pass
def GetClassID(self, pClassID):
"""
GetClassID(self: UCOMIMoniker) -> Guid
Retrieves the class identifier (CLSID) of an object.
"""
pass
def GetDisplayName(self, pbc, pmkToLeft, ppszDisplayName):
"""
GetDisplayName(self: UCOMIMoniker,pbc: UCOMIBindCtx,pmkToLeft: UCOMIMoniker) -> str
Gets the display name,which is a user-readable representation of this moniker.
pbc: A reference to the bind context to use in this operation.
pmkToLeft: A reference to the moniker to the left of this moniker,if the moniker is part of a composite
moniker.
"""
pass
def GetSizeMax(self, pcbSize):
"""
GetSizeMax(self: UCOMIMoniker) -> Int64
Returns the size in bytes of the stream needed to save the object.
"""
pass
def GetTimeOfLastChange(self, pbc, pmkToLeft, pFileTime):
"""
GetTimeOfLastChange(self: UCOMIMoniker,pbc: UCOMIBindCtx,pmkToLeft: UCOMIMoniker) -> FILETIME
Provides a number representing the time the object identified by this moniker was last changed.
pbc: A reference to the bind context to be used in this binding operation.
pmkToLeft: A reference to the moniker to the left of this moniker,if the moniker is part of a composite
moniker.
"""
pass
def Hash(self, pdwHash):
"""
Hash(self: UCOMIMoniker) -> int
Calculates a 32-bit integer using the internal state of the moniker.
"""
pass
def Inverse(self, ppmk):
"""
Inverse(self: UCOMIMoniker) -> UCOMIMoniker
Provides a moniker that,when composed to the right of this moniker or one of similar structure,
composes to nothing.
"""
pass
def IsDirty(self):
"""
IsDirty(self: UCOMIMoniker) -> int
Checks the object for changes since it was last saved.
Returns: An S_OKHRESULT value if the object has changed; otherwise,an S_FALSEHRESULT value.
"""
pass
def IsEqual(self, pmkOtherMoniker):
"""
IsEqual(self: UCOMIMoniker,pmkOtherMoniker: UCOMIMoniker)
Compares this moniker with a specified moniker and indicates whether they are identical.
pmkOtherMoniker: A reference to the moniker to be used for comparison.
"""
pass
def IsRunning(self, pbc, pmkToLeft, pmkNewlyRunning):
"""
IsRunning(self: UCOMIMoniker,pbc: UCOMIBindCtx,pmkToLeft: UCOMIMoniker,pmkNewlyRunning: UCOMIMoniker)
Determines whether the object that is identified by this moniker is currently loaded and running.
pbc: A reference to the bind context to be used in this binding operation.
pmkToLeft: A reference to the moniker to the left of this moniker if this moniker is part of a composite.
pmkNewlyRunning: A reference to the moniker most recently added to the Running Object Table.
"""
pass
def IsSystemMoniker(self, pdwMksys):
"""
IsSystemMoniker(self: UCOMIMoniker) -> int
Indicates whether this moniker is of one of the system-supplied moniker classes.
"""
pass
def Load(self, pStm):
"""
Load(self: UCOMIMoniker,pStm: UCOMIStream)
Initializes an object from the stream where it was previously saved.
pStm: Stream from which the object is loaded.
"""
pass
def ParseDisplayName(self, pbc, pmkToLeft, pszDisplayName, pchEaten, ppmkOut):
"""
ParseDisplayName(self: UCOMIMoniker,pbc: UCOMIBindCtx,pmkToLeft: UCOMIMoniker,pszDisplayName: str) -> (int,UCOMIMoniker)
Reads as many characters of the specified display name as it understands and builds a moniker
corresponding to the portion read.
pbc: A reference to the bind context to be used in this binding operation.
pmkToLeft: A reference to the moniker that has been built out of the display name up to this point.
pszDisplayName: A reference to the string containing the remaining display name to parse.
"""
pass
def Reduce(self, pbc, dwReduceHowFar, ppmkToLeft, ppmkReduced):
"""
Reduce(self: UCOMIMoniker,pbc: UCOMIBindCtx,dwReduceHowFar: int,ppmkToLeft: UCOMIMoniker) -> (UCOMIMoniker,UCOMIMoniker)
Returns a reduced moniker which is another moniker that refers to the same object as this
moniker but can be bound with equal or greater efficiency.
pbc: A reference to the IBindCtx interface on the bind context to be used in this binding operation.
dwReduceHowFar: Specifies how far this moniker should be reduced.
ppmkToLeft: A reference to the moniker to the left of this moniker.
"""
pass
def RelativePathTo(self, pmkOther, ppmkRelPath):
"""
RelativePathTo(self: UCOMIMoniker,pmkOther: UCOMIMoniker) -> UCOMIMoniker
Supplies a moniker that,when appended to this moniker (or one with a similar structure),yields
the specified moniker.
pmkOther: A reference to the moniker to which a relative path should be taken.
"""
pass
def Save(self, pStm, fClearDirty):
"""
Save(self: UCOMIMoniker,pStm: UCOMIStream,fClearDirty: bool)
Saves an object to the specified stream.
pStm: The stream into which the object is saved.
fClearDirty: Indicates whether to clear the modified flag after the save is complete.
"""
pass
def __init__(self, *args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
| 26.866873 | 153 | 0.676308 | 1,055 | 8,678 | 5.534597 | 0.25782 | 0.028258 | 0.041103 | 0.051379 | 0.29166 | 0.271451 | 0.187703 | 0.176058 | 0.16013 | 0.16013 | 0 | 0.000625 | 0.262272 | 8,678 | 322 | 154 | 26.950311 | 0.911434 | 0.738189 | 0 | 0.488372 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.488372 | false | 0.488372 | 0 | 0 | 0.511628 | 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 | 1 | 0 | 0 | 3 |
9ce94654f51097f670ab352deaaa2791280c5ada | 591 | py | Python | python/macau/test_eval_rmse_bug.py | edebrouwer/macau | 0b22d21ed954209406246e70178523102e98f922 | [
"MIT"
] | 38 | 2016-02-27T22:18:42.000Z | 2021-11-29T12:17:39.000Z | python/macau/test_eval_rmse_bug.py | edebrouwer/macau | 0b22d21ed954209406246e70178523102e98f922 | [
"MIT"
] | 11 | 2016-05-23T14:14:53.000Z | 2020-09-16T08:12:40.000Z | python/macau/test_eval_rmse_bug.py | edebrouwer/macau | 0b22d21ed954209406246e70178523102e98f922 | [
"MIT"
] | 19 | 2016-04-12T12:13:38.000Z | 2021-06-01T15:05:59.000Z | import numpy as np
import pandas as pd
import scipy.sparse
import macau
np.random.seed(1234)
Y = pd.DataFrame({
"A": np.random.randint(0, 5, 7),
"B": np.random.randint(0, 4, 7),
"C": np.random.randint(0, 3, 7),
"value": np.random.randn(7)
})
Ytest = pd.DataFrame({
"A": np.random.randint(0, 5, 5),
"B": np.random.randint(0, 4, 5),
"C": np.random.randint(0, 3, 5),
"value": np.random.randn(5)
})
results = macau.bpmf(Y, Ytest = Ytest, num_latent = 4,
verbose = False, burnin = 50, nsamples = 50,
univariate = False)
| 25.695652 | 65 | 0.571912 | 92 | 591 | 3.663043 | 0.391304 | 0.21365 | 0.267062 | 0.284866 | 0.385757 | 0.385757 | 0.172107 | 0.172107 | 0 | 0 | 0 | 0.065169 | 0.247039 | 591 | 22 | 66 | 26.863636 | 0.692135 | 0 | 0 | 0.1 | 0 | 0 | 0.027119 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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 | 3 |
9cef8326da5090a51fba04903712fe2b47332348 | 23 | py | Python | LIDAR Data Extraction/__init__.py | MarsRobotics/Experiments | 0ada1599766c8ad27fb04398b21042267895c54b | [
"BSD-3-Clause"
] | null | null | null | LIDAR Data Extraction/__init__.py | MarsRobotics/Experiments | 0ada1599766c8ad27fb04398b21042267895c54b | [
"BSD-3-Clause"
] | null | null | null | LIDAR Data Extraction/__init__.py | MarsRobotics/Experiments | 0ada1599766c8ad27fb04398b21042267895c54b | [
"BSD-3-Clause"
] | 2 | 2019-03-28T04:31:05.000Z | 2019-07-03T10:16:20.000Z | __author__ = 'Jaimiey'
| 11.5 | 22 | 0.73913 | 2 | 23 | 6.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.130435 | 23 | 1 | 23 | 23 | 0.65 | 0 | 0 | 0 | 0 | 0 | 0.304348 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9cf566a177263090fe42a7a9a4c489237c364343 | 836 | py | Python | utils/persistable_store.py | StackVista/sts-agent | f8358ea46820ffb9eb0b4b30c7d7457cc2cc987a | [
"BSD-3-Clause"
] | 4 | 2017-03-18T12:16:40.000Z | 2020-11-12T06:59:29.000Z | utils/persistable_store.py | StackVista/sts-agent | f8358ea46820ffb9eb0b4b30c7d7457cc2cc987a | [
"BSD-3-Clause"
] | 18 | 2016-09-22T08:01:02.000Z | 2020-07-15T08:30:17.000Z | utils/persistable_store.py | StackVista/sts-agent | f8358ea46820ffb9eb0b4b30c7d7457cc2cc987a | [
"BSD-3-Clause"
] | 8 | 2016-11-23T06:55:51.000Z | 2021-07-05T05:12:34.000Z |
from checks.check_status import CheckData
class PersistableStore(object):
def __init__(self, persistable_check_name, instance_id):
self.persistable_check_name = persistable_check_name
self.instance_id = instance_id
self.status = None
self.load_status()
def clear_status(self):
CheckData.remove_latest_status(self.persistable_check_name)
self.load_status()
def load_status(self):
self.status = CheckData.load_latest_status(self.persistable_check_name)
if self.status is None:
self.status = CheckData()
def commit_status(self):
self.status.persist(self.persistable_check_name)
def __setitem__(self, key, item):
self.status.data[key] = item
def __getitem__(self, key):
return self.status.data.get(key, None)
| 29.857143 | 79 | 0.696172 | 104 | 836 | 5.240385 | 0.307692 | 0.12844 | 0.220183 | 0.220183 | 0.13211 | 0.13211 | 0 | 0 | 0 | 0 | 0 | 0 | 0.2189 | 836 | 27 | 80 | 30.962963 | 0.834609 | 0 | 0 | 0.1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3 | false | 0 | 0.05 | 0.05 | 0.45 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
14115ebbf792180eb90b3349e8f1f1a7ce894b32 | 176 | py | Python | senate/tools/aws_connect.py | CliMz/senate | 19e3d53a6fc1c5df8a55eec8c2607115965c803a | [
"Apache-2.0"
] | null | null | null | senate/tools/aws_connect.py | CliMz/senate | 19e3d53a6fc1c5df8a55eec8c2607115965c803a | [
"Apache-2.0"
] | null | null | null | senate/tools/aws_connect.py | CliMz/senate | 19e3d53a6fc1c5df8a55eec8c2607115965c803a | [
"Apache-2.0"
] | null | null | null | #!/usr/in/python3
import boto3
def connect_ec2():
client = boto3.client('ec2')
return client
def connect_cloudwatch():
client = boto3.client('cloudwatch')
return client | 16 | 37 | 0.732955 | 23 | 176 | 5.521739 | 0.478261 | 0.15748 | 0.267717 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.039474 | 0.136364 | 176 | 11 | 38 | 16 | 0.796053 | 0.090909 | 0 | 0.285714 | 0 | 0 | 0.08125 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.142857 | 0 | 0.714286 | 0 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
141628236d94a908bfa4937cf00ab66b370827b1 | 189 | py | Python | app/app/trash_bin/test.py | howard5248/django-restAPI-1 | 988f9e4efe3f63481323e242f0b96c215ac440e5 | [
"MIT"
] | null | null | null | app/app/trash_bin/test.py | howard5248/django-restAPI-1 | 988f9e4efe3f63481323e242f0b96c215ac440e5 | [
"MIT"
] | null | null | null | app/app/trash_bin/test.py | howard5248/django-restAPI-1 | 988f9e4efe3f63481323e242f0b96c215ac440e5 | [
"MIT"
] | null | null | null | from django.test import TestCase
from app.calc import add
class CalcTest(TestCase):
def test_add_number(self):
"""Simple try test"""
self.assertEqual(add(3, 8), 11)
| 17.181818 | 39 | 0.666667 | 27 | 189 | 4.592593 | 0.703704 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.027211 | 0.222222 | 189 | 10 | 40 | 18.9 | 0.816327 | 0.079365 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | 1 | 0.2 | false | 0 | 0.4 | 0 | 0.8 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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 | 3 |
1428257584b2a05babf2b8393460589329536d32 | 335 | py | Python | shopipy/resources/fulfillment/schemas.py | lowercase00/pyshopify | 98fdd0ac30569725fc0ec32345a92cd84c510a6a | [
"MIT"
] | 1 | 2021-10-17T02:09:22.000Z | 2021-10-17T02:09:22.000Z | shopipy/resources/fulfillment/schemas.py | lowercase00/shopipy | 98fdd0ac30569725fc0ec32345a92cd84c510a6a | [
"MIT"
] | null | null | null | shopipy/resources/fulfillment/schemas.py | lowercase00/shopipy | 98fdd0ac30569725fc0ec32345a92cd84c510a6a | [
"MIT"
] | null | null | null | from pydantic import BaseModel
from datetime import datetime
from typing import List, Optional
class Fulfillments(BaseModel):
created_at: Optional[str]
id: Optional[str]
order_id: Optional[str]
status: Optional[str]
tracking_company: Optional[str]
tracking_number: Optional[str]
updated_at: Optional[str]
| 23.928571 | 35 | 0.749254 | 42 | 335 | 5.857143 | 0.47619 | 0.313008 | 0.105691 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.176119 | 335 | 13 | 36 | 25.769231 | 0.891304 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.272727 | 0 | 1 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
14339c364e40610f49174aa5222293b8e75cb9ac | 49 | py | Python | github_issues/__init__.py | deansx/github-issues | aba27c24a7b56d188536b538f805884d908522ff | [
"Apache-2.0"
] | 1 | 2015-10-11T21:10:07.000Z | 2015-10-11T21:10:07.000Z | github_issues/__init__.py | deansx/github-issues | aba27c24a7b56d188536b538f805884d908522ff | [
"Apache-2.0"
] | null | null | null | github_issues/__init__.py | deansx/github-issues | aba27c24a7b56d188536b538f805884d908522ff | [
"Apache-2.0"
] | null | null | null | __all__ = ["gh_shared", "gh_issues", "gh_merge"]
| 24.5 | 48 | 0.673469 | 7 | 49 | 3.714286 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.102041 | 49 | 1 | 49 | 49 | 0.590909 | 0 | 0 | 0 | 0 | 0 | 0.530612 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
14873fb377e3166fe5dcddf5a8d39d8ebc7f968b | 287 | py | Python | Numbers/factorial_of_a_number_recursion.py | jahnvisrivastava100/CompetitiveProgrammingQuestionBank | 0d72884ea5e0eb674a503b81ab65e444f5175cf4 | [
"MIT"
] | 931 | 2020-04-18T11:57:30.000Z | 2022-03-31T15:15:39.000Z | Numbers/factorial_of_a_number_recursion.py | jahnvisrivastava100/CompetitiveProgrammingQuestionBank | 0d72884ea5e0eb674a503b81ab65e444f5175cf4 | [
"MIT"
] | 661 | 2020-12-13T04:31:48.000Z | 2022-03-15T19:11:54.000Z | Numbers/factorial_of_a_number_recursion.py | Mayuri-cell/CompetitiveProgrammingQuestionBank | eca2257d7da5346f45bdd7a351cc95bde6ed5c7d | [
"MIT"
] | 351 | 2020-08-10T06:49:21.000Z | 2022-03-25T04:02:12.000Z | '''Program to find the factorial of a number using recursion'''
def factorial_of_a_number(n):
if n<=1:
return 1
else:
return n * factorial_of_a_number(n-1)
#Taking number from user and passing it to the function
n = int(input())
print(factorial_of_a_number(n)) | 23.916667 | 63 | 0.69338 | 49 | 287 | 3.877551 | 0.530612 | 0.231579 | 0.252632 | 0.378947 | 0.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013274 | 0.212544 | 287 | 12 | 64 | 23.916667 | 0.827434 | 0.390244 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0 | 0 | 0.428571 | 0.142857 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
148c8dacdf2ee8f86af37310ffcefead5237d460 | 839 | py | Python | tests/test_transform_windows.py | jsamoocha/pysweat | 127d1d473199bdbbbbe9cd6efbb03c7b80ab147a | [
"Apache-2.0"
] | 2 | 2017-10-17T08:49:48.000Z | 2018-03-10T13:40:53.000Z | tests/test_transform_windows.py | jsamoocha/pysweat | 127d1d473199bdbbbbe9cd6efbb03c7b80ab147a | [
"Apache-2.0"
] | null | null | null | tests/test_transform_windows.py | jsamoocha/pysweat | 127d1d473199bdbbbbe9cd6efbb03c7b80ab147a | [
"Apache-2.0"
] | null | null | null | import unittest
from pysweat.transformation.windows import subtract_n_minutes
class WindowsTransformTest(unittest.TestCase):
def test_subtract_5_minutes(self):
"""Should default to 5 minutes"""
self.assertEqual(subtract_n_minutes(423), 123)
def test_subtract_5_minutes_negative_result(self):
"""Should not return negative values, but default to a minimum of 0"""
self.assertEqual(subtract_n_minutes(99), 0)
def test_subtract_5_minutes_minimum_value(self):
"""Should return the provided minimum value in case of negative result"""
self.assertEqual(subtract_n_minutes(99, minimum_value=50), 50)
def test_subtract_1_minute(self):
"""Should return result for a provided amount of minutes to be subtracted"""
self.assertEqual(subtract_n_minutes(423, 1), 363)
| 39.952381 | 84 | 0.736591 | 114 | 839 | 5.184211 | 0.403509 | 0.076142 | 0.135364 | 0.162437 | 0.343486 | 0.226734 | 0 | 0 | 0 | 0 | 0 | 0.040698 | 0.179976 | 839 | 20 | 85 | 41.95 | 0.818314 | 0.275328 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.363636 | 1 | 0.363636 | false | 0 | 0.181818 | 0 | 0.636364 | 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 | 1 | 0 | 0 | 3 |
148f00b1178e7324f46d2d996f49303caf8c713f | 910 | py | Python | wagtail_graphql/types/__init__.py | yatesrates/wagtail-graphql-api | 8183c3c69340c9a48e2c352fc398e8bd255efa96 | [
"BSD-3-Clause"
] | 4 | 2019-07-19T21:17:02.000Z | 2020-08-30T05:15:07.000Z | wagtail_graphql/types/__init__.py | yatesrates/wagtail-graphql-api | 8183c3c69340c9a48e2c352fc398e8bd255efa96 | [
"BSD-3-Clause"
] | 1 | 2019-11-06T03:44:42.000Z | 2019-11-06T03:44:42.000Z | wagtail_graphql/types/__init__.py | yatesrates/wagtail-graphql-api | 8183c3c69340c9a48e2c352fc398e8bd255efa96 | [
"BSD-3-Clause"
] | 3 | 2019-07-19T21:17:06.000Z | 2019-10-31T03:34:44.000Z | from wagtail_graphql.types.base import create_model_type
from wagtail_graphql.types.collection import CollectionObjectType
from wagtail_graphql.types.documents import DocumentObjectType
from wagtail_graphql.types.images import ImageInterface, ImageObjectType
from wagtail_graphql.types.pages import PageInterface, create_page_type
from wagtail_graphql.types.scalars import PositiveInt
from wagtail_graphql.types.site import SiteObjectType
from wagtail_graphql.types.snippets import create_snippet_type
from wagtail_graphql.types.streamfields import StreamField
from wagtail_graphql.types.structures import QuerySetList
__all__ = [
'CollectionObjectType',
'DocumentObjectType',
'ImageInterface',
'ImageObjectType',
'PageInterface',
'PositiveInt',
'SiteObjectType',
'StreamField',
'QuerySetList',
'create_model_type',
'create_page_type',
'create_snippet_type',
]
| 35 | 72 | 0.815385 | 97 | 910 | 7.381443 | 0.309278 | 0.153631 | 0.251397 | 0.321229 | 0.113128 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.117582 | 910 | 25 | 73 | 36.4 | 0.891656 | 0 | 0 | 0 | 0 | 0 | 0.197802 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.416667 | 0 | 0.416667 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
14b1acce7d19d0183457b4806c85cac6fb42b870 | 1,505 | py | Python | server/world/replica/phantom_physics.py | alentoghostflame/PyLUS | d23531c81a81754bea04c1d1de335117edab1670 | [
"MIT"
] | 7 | 2019-04-18T00:46:09.000Z | 2021-12-21T04:34:44.000Z | server/world/replica/phantom_physics.py | alentoghostflame/PyLUS | d23531c81a81754bea04c1d1de335117edab1670 | [
"MIT"
] | 15 | 2021-03-08T17:29:40.000Z | 2021-04-08T18:22:52.000Z | server/world/replica/phantom_physics.py | alentoghostflame/PyLUS | d23531c81a81754bea04c1d1de335117edab1670 | [
"MIT"
] | 6 | 2018-04-01T16:33:50.000Z | 2018-05-12T15:54:21.000Z | """
PhantomPhysics component
"""
from bitstream import c_bit, c_float, c_uint32
from .component import Component
from server.structs import Vector3, Vector4
class PhantomPhysics(Component):
"""
PhantomPhysics component class
"""
def __init__(self, pos=Vector3(0, 0, 0), rot=Vector4(0, 0, 0, 0), effect=False, effect_type=0, effect_amount=0,
effect_direction=Vector3(0, 0, 0)):
super().__init__(**{k: v for k, v in locals().items() if k != 'self'})
def serialize(self, stream):
"""
Serializes the component
"""
stream.write(c_bit(True))
stream.write(c_float(self.pos.x))
stream.write(c_float(self.pos.y))
stream.write(c_float(self.pos.z))
stream.write(c_float(self.rot.x))
stream.write(c_float(self.rot.y))
stream.write(c_float(self.rot.z))
stream.write(c_float(self.rot.w))
stream.write(c_bit(True))
stream.write(c_bit(self.effect))
if self.effect:
stream.write(c_uint32(self.effect_type))
stream.write(c_float(self.effect_amount))
stream.write(c_bit(False))
stream.write(c_bit(True))
stream.write(c_float(self.effect_direction.x))
stream.write(c_float(self.effect_direction.y))
stream.write(c_float(self.effect_direction.z))
def write_construction(self, stream):
"""
Writes construction data
"""
self.serialize(stream)
| 30.714286 | 115 | 0.618605 | 202 | 1,505 | 4.425743 | 0.227723 | 0.209172 | 0.228188 | 0.209172 | 0.425056 | 0.425056 | 0.277405 | 0.124161 | 0.089485 | 0.089485 | 0 | 0.018551 | 0.247841 | 1,505 | 48 | 116 | 31.354167 | 0.771201 | 0.069767 | 0 | 0.107143 | 0 | 0 | 0.003005 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.107143 | false | 0 | 0.107143 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
14bb7a8e521e12655b00bab27448073d40e29f20 | 163 | py | Python | constants.py | GuyBukys/FoodCalculator.FoodBot | 1575c1651adb8bbfa3c855c8bfc32242f80fe133 | [
"MIT"
] | null | null | null | constants.py | GuyBukys/FoodCalculator.FoodBot | 1575c1651adb8bbfa3c855c8bfc32242f80fe133 | [
"MIT"
] | null | null | null | constants.py | GuyBukys/FoodCalculator.FoodBot | 1575c1651adb8bbfa3c855c8bfc32242f80fe133 | [
"MIT"
] | null | null | null | API_KEY = '5221852571:AAHuHsU1nVfqpvOYP1XjCUlUT5HWO46pgu0'
FOOD_API_URL = 'https://localhost:7220/'
GET_NUTRITION_DATA_REQUEST_URI = 'api/FoodApi/GetNutritionData' | 54.333333 | 63 | 0.846626 | 18 | 163 | 7.277778 | 0.888889 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.129032 | 0.04908 | 163 | 3 | 63 | 54.333333 | 0.716129 | 0 | 0 | 0 | 0 | 0 | 0.591463 | 0.45122 | 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 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
1adb8e30d9e7fcd714b7e251021ed24087cbadfc | 194 | py | Python | src/unicon/plugins/nxos/aci/n9k/__init__.py | ashojosh/unicon.plugins | b6affc3c37aae08207eb8dee787eec908b161f42 | [
"Apache-2.0"
] | 1 | 2021-02-25T19:36:56.000Z | 2021-02-25T19:36:56.000Z | src/unicon/plugins/nxos/aci/n9k/__init__.py | ashojosh/unicon.plugins | b6affc3c37aae08207eb8dee787eec908b161f42 | [
"Apache-2.0"
] | null | null | null | src/unicon/plugins/nxos/aci/n9k/__init__.py | ashojosh/unicon.plugins | b6affc3c37aae08207eb8dee787eec908b161f42 | [
"Apache-2.0"
] | null | null | null | from unicon.plugins.aci.n9k.connection import AciN9KConnection as GenericAciN9KConnection
class AciN9KConnection(GenericAciN9KConnection):
os = 'nxos'
series = 'aci'
model = 'n9k'
| 24.25 | 89 | 0.757732 | 19 | 194 | 7.736842 | 0.789474 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.03681 | 0.159794 | 194 | 7 | 90 | 27.714286 | 0.865031 | 0 | 0 | 0 | 0 | 0 | 0.051546 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
1aedd8abf3998a6d6a7972cb7badb05cba3fbf51 | 580 | py | Python | IVTp/2014/Grigoriev_A_O/task_3_2.py | YukkaSarasti/pythonintask | eadf4245abb65f4400a3bae30a4256b4658e009c | [
"Apache-2.0"
] | null | null | null | IVTp/2014/Grigoriev_A_O/task_3_2.py | YukkaSarasti/pythonintask | eadf4245abb65f4400a3bae30a4256b4658e009c | [
"Apache-2.0"
] | null | null | null | IVTp/2014/Grigoriev_A_O/task_3_2.py | YukkaSarasti/pythonintask | eadf4245abb65f4400a3bae30a4256b4658e009c | [
"Apache-2.0"
] | null | null | null | #Задача 3. Вариант 2.
#Напишите программу, которая выводит имя "Мария Луиза Чеччарелли", и запрашивает его псевдоним. Программа должна сцеплять две эти строки и выводить полученную строку, разделяя имя и псевдоним с помощью тире.
#Григорьев А.О.
#23.05.2016
print ("Герой нашей сегоднящней программы - Мария Луиза Чеччарелли")
psev=input("Под каким же именем мы знаем этого человека? Ваш ответ:")
if (psev)==("Моника Витти"):
print ("Всё верно: Мария Луиза Чеччарелли - "+psev)
else:
print ("Вы ошиблись, это не её псевдоним.")
input("нажмите Enter для выхода") | 44.615385 | 208 | 0.737931 | 84 | 580 | 5.107143 | 0.809524 | 0.06993 | 0.13986 | 0.111888 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020619 | 0.163793 | 580 | 13 | 209 | 44.615385 | 0.861856 | 0.431034 | 0 | 0 | 0 | 0 | 0.697452 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.428571 | 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 | 1 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
1af80167e28fdf7329f9562bcee7f83eec26e37f | 19 | py | Python | asyncpgw/__init__.py | furimu1234/asyncpgw | 21fd429842c9903182247572ce222b0e65096746 | [
"MIT"
] | null | null | null | asyncpgw/__init__.py | furimu1234/asyncpgw | 21fd429842c9903182247572ce222b0e65096746 | [
"MIT"
] | null | null | null | asyncpgw/__init__.py | furimu1234/asyncpgw | 21fd429842c9903182247572ce222b0e65096746 | [
"MIT"
] | null | null | null | name = "asyncpgw" | 19 | 19 | 0.631579 | 2 | 19 | 6 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.210526 | 19 | 1 | 19 | 19 | 0.8 | 0 | 0 | 0 | 0 | 0 | 0.4 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
21002a3a658f62d52911395cb71848602edd94f0 | 342 | py | Python | mayo/__init__.py | mwilliamson/mayo | ac2dfdcee34f6898e10c965a28dbe27d594228b1 | [
"BSD-2-Clause-FreeBSD"
] | 2 | 2021-06-03T13:33:19.000Z | 2021-12-17T00:44:58.000Z | mayo/__init__.py | mwilliamson/mayo | ac2dfdcee34f6898e10c965a28dbe27d594228b1 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | mayo/__init__.py | mwilliamson/mayo | ac2dfdcee34f6898e10c965a28dbe27d594228b1 | [
"BSD-2-Clause-FreeBSD"
] | 1 | 2015-11-08T21:46:33.000Z | 2015-11-08T21:46:33.000Z | from .fetcher import fetch, archive
from .repositories import find_repository, repository_at
from .errors import UnrecognisedSourceControlSystem
from .systems import is_source_control_uri
__all__ = [
"fetch",
"archive",
"find_repository",
"repository_at",
"is_source_control_uri",
"UnrecognisedSourceControlSystem"
]
| 24.428571 | 56 | 0.769006 | 35 | 342 | 7.114286 | 0.485714 | 0.096386 | 0.192771 | 0.208835 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.154971 | 342 | 13 | 57 | 26.307692 | 0.861592 | 0 | 0 | 0 | 0 | 0 | 0.269006 | 0.152047 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
211171b5f11925e666eb61604f10c5136d907913 | 1,244 | py | Python | Curso-em-video/Aula_72.py | JhonAI13/Curso_python | 27dedb0effa2c26140f46392e993b8e7a27d6eb3 | [
"MIT"
] | null | null | null | Curso-em-video/Aula_72.py | JhonAI13/Curso_python | 27dedb0effa2c26140f46392e993b8e7a27d6eb3 | [
"MIT"
] | null | null | null | Curso-em-video/Aula_72.py | JhonAI13/Curso_python | 27dedb0effa2c26140f46392e993b8e7a27d6eb3 | [
"MIT"
] | null | null | null | # #072: Crie um programa que tenha uma dupla totalmente preenchida com uma contagem por extenso, de zero até vinte.
# # Seu programa deverá ler um número pelo teclado (entre 0 e 20) e mostrá-lo por extenso.
# n = ('zero', 'um', 'dois', 'três', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove', 'dez', 'onze', 'oze', 'treze', 'quatorze', 'quinze', 'dezesseis','dezessete', 'dezoito', 'dezenove', 'vinte')
#
# c = int(input('Qual numeor voce quer que eu escreva por estenço:'))
#
# while True:
# if c >= 0 and c <= 20:
# break
# else:
# c = int(input('Qual numeor voce quer que eu escreva por estenço:'))
#
# print(f'Seu numero por extenço é:{n[c]}')
n = ('zero', 'um', 'dois', 'três', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove', 'dez', 'onze', 'doze', 'treze', 'quatorze', 'quinze', 'dezesseis','dezessete', 'dezoito', 'dezenove', 'vinte')
while True:
c = int(input('Qual numeor voce quer que eu escreva por estenço:'))
while True:
if c >= 0 and c <= 20:
break
else:
c = int(input('Qual numeor voce quer que eu escreva por estenço:'))
print(f'Seu numero por extenço é:{n[c]}')
n1 = str(input('Você quer continuar[S/N]'))
if n1 in 'Nn':
break
| 42.896552 | 197 | 0.59164 | 181 | 1,244 | 4.066298 | 0.430939 | 0.021739 | 0.048913 | 0.070652 | 0.706522 | 0.706522 | 0.706522 | 0.706522 | 0.55163 | 0.55163 | 0 | 0.014493 | 0.223473 | 1,244 | 28 | 198 | 44.428571 | 0.747412 | 0.518489 | 0 | 0.5 | 0 | 0 | 0.45283 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.083333 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 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 | 3 |
215ac4ea5da14d83ce414f9ef0375ec08b893817 | 1,052 | py | Python | OpenGLWrapper_JE/venv/Lib/site-packages/OpenGL/raw/GL/ARB/get_texture_sub_image.py | JE-Chen/je_old_repo | a8b2f1ac2eec25758bd15b71c64b59b27e0bcda5 | [
"MIT"
] | null | null | null | OpenGLWrapper_JE/venv/Lib/site-packages/OpenGL/raw/GL/ARB/get_texture_sub_image.py | JE-Chen/je_old_repo | a8b2f1ac2eec25758bd15b71c64b59b27e0bcda5 | [
"MIT"
] | null | null | null | OpenGLWrapper_JE/venv/Lib/site-packages/OpenGL/raw/GL/ARB/get_texture_sub_image.py | JE-Chen/je_old_repo | a8b2f1ac2eec25758bd15b71c64b59b27e0bcda5 | [
"MIT"
] | null | null | null | '''Autogenerated by xml_generate script, do not edit!'''
from OpenGL import platform as _p, arrays
# Code generation uses this
from OpenGL.raw.GL import _types as _cs
# End users want this...
from OpenGL.raw.GL._types import *
from OpenGL.raw.GL import _errors
from OpenGL.constant import Constant as _C
import ctypes
_EXTENSION_NAME = 'GL_ARB_get_texture_sub_image'
def _f( function ):
return _p.createFunction( function,_p.PLATFORM.GL,'GL_ARB_get_texture_sub_image',error_checker=_errors._error_checker)
@_f
@_p.types(None,_cs.GLuint,_cs.GLint,_cs.GLint,_cs.GLint,_cs.GLint,_cs.GLsizei,_cs.GLsizei,_cs.GLsizei,_cs.GLsizei,ctypes.c_void_p)
def glGetCompressedTextureSubImage(texture,level,xoffset,yoffset,zoffset,width,height,depth,bufSize,pixels):pass
@_f
@_p.types(None,_cs.GLuint,_cs.GLint,_cs.GLint,_cs.GLint,_cs.GLint,_cs.GLsizei,_cs.GLsizei,_cs.GLsizei,_cs.GLenum,_cs.GLenum,_cs.GLsizei,ctypes.c_void_p)
def glGetTextureSubImage(texture,level,xoffset,yoffset,zoffset,width,height,depth,format,type,bufSize,pixels):pass
| 50.095238 | 153 | 0.79943 | 165 | 1,052 | 4.769697 | 0.387879 | 0.071156 | 0.091487 | 0.106734 | 0.517154 | 0.434562 | 0.376112 | 0.317662 | 0.193139 | 0.193139 | 0 | 0 | 0.085551 | 1,052 | 20 | 154 | 52.6 | 0.818087 | 0.095057 | 0 | 0.133333 | 1 | 0 | 0.060541 | 0.060541 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0.133333 | 0.4 | 0.066667 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 3 |
2168a34bd59ebd24c303fbd6daefc4e777d64c95 | 1,342 | py | Python | app/forms/signup_form.py | tonyngophd/dronest | f0976c31cbbf6fb032851bd42ac566bb381608f0 | [
"MIT"
] | 13 | 2021-02-03T13:26:59.000Z | 2021-03-24T19:34:19.000Z | app/forms/signup_form.py | suasllc/dronest | f0976c31cbbf6fb032851bd42ac566bb381608f0 | [
"MIT"
] | null | null | null | app/forms/signup_form.py | suasllc/dronest | f0976c31cbbf6fb032851bd42ac566bb381608f0 | [
"MIT"
] | 1 | 2021-06-07T17:56:58.000Z | 2021-06-07T17:56:58.000Z | from flask_wtf import FlaskForm
from wtforms import StringField
from wtforms.validators import DataRequired, Email, ValidationError
from app.models import User
def user_exists(form, field):
# print("Checking if user exits", field.data)
email = field.data
user = User.query.filter(User.email == email).first()
if user:
raise ValidationError("User is already registered.")
class SignUpForm(FlaskForm):
username = StringField('username', validators=[DataRequired()])
name = StringField('name', validators=[DataRequired()])
email = StringField('email', validators=[DataRequired(), user_exists])
password = StringField('password', validators=[DataRequired()])
bio = StringField('bio', validators=[DataRequired()])
websiteUrl = StringField('websiteUrl', validators=[DataRequired()])
profilePicUrl = StringField('profilePicUrl', validators=[DataRequired()])
class UpdateProfileForm(FlaskForm):
username = StringField('username', validators=[DataRequired()])
name = StringField('name', validators=[DataRequired()])
email = StringField('email', validators=[DataRequired()])
bio = StringField('bio', validators=[DataRequired()])
websiteUrl = StringField('websiteUrl', validators=[DataRequired()])
profilePicUrl = StringField('profilePicUrl', validators=[DataRequired()])
| 43.290323 | 77 | 0.728763 | 125 | 1,342 | 7.8 | 0.312 | 0.293333 | 0.057436 | 0.073846 | 0.62359 | 0.62359 | 0.62359 | 0.62359 | 0.62359 | 0.62359 | 0 | 0 | 0.134128 | 1,342 | 30 | 78 | 44.733333 | 0.839071 | 0.032042 | 0 | 0.416667 | 0 | 0 | 0.093292 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.041667 | false | 0.041667 | 0.166667 | 0 | 0.833333 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
2169bc92b930397648496ed53fde599a9c02d44d | 1,197 | py | Python | qaoa/util/types.py | gregvw/pyQAOA | 59b5abda36d90b45913878e7ffb588a1c146bc38 | [
"BSD-3-Clause"
] | null | null | null | qaoa/util/types.py | gregvw/pyQAOA | 59b5abda36d90b45913878e7ffb588a1c146bc38 | [
"BSD-3-Clause"
] | null | null | null | qaoa/util/types.py | gregvw/pyQAOA | 59b5abda36d90b45913878e7ffb588a1c146bc38 | [
"BSD-3-Clause"
] | null | null | null | import numpy
import networkx
import numbers
def is_nparray(x):
return isinstance(x,numpy.ndarray)
def is_squarematrix(x):
if is_nparray(x):
return x.shape[0] == x.shape[1] if len(x.shape) == 2 else False
else:
return False
def is_callable(x):
return hasattr(x,'__call__')
def is_container(x):
return hasattr(x,"__getitem__")
def complex_type(rtype):
return type(1j*rtype())
def real_type(ctype):
return type(numpy.real(ctype()))
def is_float(x):
xtype = type(x)
return numbers.Real.__subclasscheck__(xtype) and not \
numbers.Integral.__subclasscheck__(xtype)
def is_integer(x):
return isinstance(x,numbers.Integral)
def is_graph(x):
if hasattr(x,'edges'):
if isinstance(x.edges,networkx.classes.reportviews.EdgeView):
return True
return False
def is_weightedgraph(x):
return all( "weight" in x[e[0]][e[1]] for e in x.edges ) if is_graph(x) else False
def is_rowvalue(x):
return all( is_integer(y[0]) for y in x ) if is_container(x) and len(x[0])==2 else False
def is_rowcolvalue(x):
return all( is_integer(y[0]) for y in x ) if is_container(x) and len(x[0])==3 else False
| 24.9375 | 92 | 0.671679 | 194 | 1,197 | 3.969072 | 0.278351 | 0.064935 | 0.051948 | 0.041558 | 0.12987 | 0.12987 | 0.12987 | 0.12987 | 0.12987 | 0.12987 | 0 | 0.012552 | 0.201337 | 1,197 | 47 | 93 | 25.468085 | 0.792887 | 0 | 0 | 0.057143 | 0 | 0 | 0.025063 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.342857 | false | 0 | 0.085714 | 0.257143 | 0.828571 | 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 | 1 | 0 | 0 | 3 |
dcc6ddfdcf6cb685af1f41661eaceb1d5e1ac4d5 | 356 | py | Python | src/decryptors/python2.7/help.py | alexwillingham/serverless-secrets | c850b4788327d3b127ce63bdb3f2ffd926f5a83e | [
"MIT"
] | null | null | null | src/decryptors/python2.7/help.py | alexwillingham/serverless-secrets | c850b4788327d3b127ce63bdb3f2ffd926f5a83e | [
"MIT"
] | null | null | null | src/decryptors/python2.7/help.py | alexwillingham/serverless-secrets | c850b4788327d3b127ce63bdb3f2ffd926f5a83e | [
"MIT"
] | null | null | null | /*
/$$ /$$ /$$$$$$$$ /$$ /$$$$$$$ /$$
| $$ | $$| $$_____/| $$ | $$__ $$| $$
| $$ | $$| $$ | $$ | $$ \ $$| $$
| $$$$$$$$| $$$$$ | $$ | $$$$$$$/| $$
| $$__ $$| $$__/ | $$ | $$____/ |__/
| $$ | $$| $$ | $$ | $$
| $$ | $$| $$$$$$$$| $$$$$$$$| $$ /$$
|__/ |__/|________/|________/|__/ |__/
*/
| 32.363636 | 44 | 0.115169 | 0 | 356 | null | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.379213 | 356 | 10 | 45 | 35.6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
dcdc340121abf8466ca803a8a5864ad09d64914e | 212 | py | Python | pytext/data/tokenizers/__init__.py | haowu666/pytext | 8455458c101683602478b93bc8d016bd49d04323 | [
"BSD-3-Clause"
] | 2 | 2019-06-27T21:32:26.000Z | 2019-10-16T06:20:25.000Z | pytext/data/tokenizers/__init__.py | haowu666/pytext | 8455458c101683602478b93bc8d016bd49d04323 | [
"BSD-3-Clause"
] | null | null | null | pytext/data/tokenizers/__init__.py | haowu666/pytext | 8455458c101683602478b93bc8d016bd49d04323 | [
"BSD-3-Clause"
] | 1 | 2019-10-16T06:20:26.000Z | 2019-10-16T06:20:26.000Z | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from .tokenizer import DoNothingTokenizer, Token, Tokenizer
__all__ = ["Token", "Tokenizer", "DoNothingTokenizer"]
| 26.5 | 70 | 0.754717 | 24 | 212 | 6.5 | 0.791667 | 0.179487 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005405 | 0.127358 | 212 | 7 | 71 | 30.285714 | 0.837838 | 0.424528 | 0 | 0 | 0 | 0 | 0.266667 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
dced6e87b68b038951bc7880d548c75ed60c6565 | 358 | py | Python | lib/utils.py | shipwreckdev/starchart | 44943e408d2da7c71a1df9eb8e8079240cc02e4d | [
"Apache-2.0"
] | null | null | null | lib/utils.py | shipwreckdev/starchart | 44943e408d2da7c71a1df9eb8e8079240cc02e4d | [
"Apache-2.0"
] | null | null | null | lib/utils.py | shipwreckdev/starchart | 44943e408d2da7c71a1df9eb8e8079240cc02e4d | [
"Apache-2.0"
] | null | null | null | # Colors.
white = '\033[97m'
green = '\033[92m'
red = '\033[91m'
yellow = '\033[93m'
# Symbols.
info = '\033[93m[!]\033[0m'
failure = '\033[91m[x]\033[0m'
success = '\033[92m[✓]\033[0m'
# Text modifiers.
def bold(t):
return str('\033[1m%s\033[0m' % t)
def italics(t):
return str('\033[3m%s\033[0m' % t)
# Remove formatting.
reset = '\033[0m'
| 14.32 | 38 | 0.581006 | 60 | 358 | 3.483333 | 0.516667 | 0.143541 | 0.095694 | 0.124402 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.226351 | 0.173184 | 358 | 24 | 39 | 14.916667 | 0.476351 | 0.142458 | 0 | 0 | 0 | 0 | 0.413907 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0 | 0.166667 | 0.333333 | 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 | 1 | 0 | 0 | 0 | 3 |
dcf60cf6d600578e41e558ac716754f550a4e381 | 199 | py | Python | setup.py | HASTE-project/haste-report-generator | 414dca65c46497f03414cf986a2bed45ce219ad8 | [
"BSD-3-Clause"
] | null | null | null | setup.py | HASTE-project/haste-report-generator | 414dca65c46497f03414cf986a2bed45ce219ad8 | [
"BSD-3-Clause"
] | null | null | null | setup.py | HASTE-project/haste-report-generator | 414dca65c46497f03414cf986a2bed45ce219ad8 | [
"BSD-3-Clause"
] | null | null | null | #!/usr/bin/env python
from distutils.core import setup
setup(name='haste_report_generator',
packages=['haste.report_generator'],
install_requires=[
'pymongo'
],
)
| 18.090909 | 42 | 0.633166 | 21 | 199 | 5.809524 | 0.809524 | 0.180328 | 0.327869 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.241206 | 199 | 10 | 43 | 19.9 | 0.807947 | 0.100503 | 0 | 0 | 0 | 0 | 0.286517 | 0.247191 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.142857 | 0 | 0.142857 | 0 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0d03286cff7b6d5f2c8996c142eb0786d3173b25 | 8,605 | py | Python | flashcardclasses.py | Slopcorn/prog-intro-project | 578b8a5c5f17305bd4cb957f2d08c2955dc5de68 | [
"Unlicense"
] | null | null | null | flashcardclasses.py | Slopcorn/prog-intro-project | 578b8a5c5f17305bd4cb957f2d08c2955dc5de68 | [
"Unlicense"
] | null | null | null | flashcardclasses.py | Slopcorn/prog-intro-project | 578b8a5c5f17305bd4cb957f2d08c2955dc5de68 | [
"Unlicense"
] | null | null | null | # LTAT.03.001 - Introduction to Computer Programming @ Tartu Univesity - Project
# 11/2018
# This file implements the classes used in the program.
import datetime as dt # Necessary classes for due dates.
class Deck(object):
# Basically should be really simple: A list of flashcards
# with a few extra methods.
def __init__(self, title):
self.cards = []
self.title = title
def set_title(self, title):
self.title = str(title)
def get_title(self):
return self.title
def sort(self):
self.cards.sort()
def get_card(self, i=0):
# in: int
# returns a card itself.
return self.cards[i]
def get_card_display(self, i=0):
# in: int
# returns a 2-tuple of card back and front
temp = self.cards[i]
return (temp.get_front(),temp.get_back())
def edit_card(self, i, performance):
# in: int, int
# updates card of given index, should sort after this.
self.cards[i].card_update(performance)
self.sort()
def count_due(self):
# out: int
self.sort()
n = 0
time = dt.datetime.now()
for card in self.cards:
if card.get_next_due() <= time:
n += 1
else:
break
return n
def add_card(self, front, back):
# in: str, str
self.cards.append(Flashcard(front, back))
self.sort()
def load_card(self, card):
# in: Flashcard
self.cards.append(card)
self.sort()
def remove_card(self, card):
# in: Flashcard
# finds all cards with same front and back text
while card in self.cards:
del self.cards[self.cards.index(card)]
self.sort()
def remove_card_i(self, i):
# in: int
# removes card by index
del self.cards[i]
def replace_card(self, i, new_card):
# bit of a nasty hack to update card in the main program
# in: index int, Flashcard
self.cards[i] = new_card
self.sort()
def __len__(self):
# how many cards total
return len(self.cards)
def __iter__(self):
return iter(self.cards)
# implement sort by due cards
def __lt__(self, other):
return self.count_due() < other.count_due()
def __gt__(self, other):
return self.count_due() > other.count_due()
def __le__(self, other):
return self.count_due() <= other.count_due()
def __ge__(self, other):
return self.count_due() >= other.count_due()
class Flashcard(object):
# We'll be implementing the SuperMemo 2 algorithm to calculate due dates.
# Hopefully this class will be extensible.
def __init__(self, front, back, ease=2.5, streak=0, next_due=dt.datetime.now()):
'''
N/A, string, string, float >= 1.3, int, datetime
Front is what is shown to user, the question, if you will.
Back is the answer.
Ease is a float, minimum 1.3. The larger this value is, the
longer the time between due dates is going to be. Default of 2.5.
Streak is self explanatory. The higher this is, the
longer the difference between due dates again. Default of 0.
Next due will be the date the flashcard is due. The default for this
is going to be basically creation date.
'''
# Assign the flashcard text.
self.front = str(front)
self.back = str(back)
self.ease = ease
self.streak = streak
self.next_due = next_due
# Setting the card text.
def get_front(self):
# in: none
# out: string
return self.front
def set_front(self, front):
# in: string
# out: none
self.front = str(front)
def get_back(self):
# in: none
# out: string
return self.back
def set_back(self, back):
# in: string
# out: none
self.back = str(back)
def get_ease(self): # used in due date calculation
# in: none
# out: float
return self.ease
def set_ease(self, ease):
# in: float/int. using later methods, input bound to be float regardless.
# out: none
if ease <= 1.3:
self.ease = 1.3
else:
self.ease = float(ease)
def get_streak(self): # used in due date calculation
# in: none
# out: int
return self.streak
def set_streak(self, streak):
# in: int
# out: none
if streak >= 0:
self.streak = int(streak)
else:
self.streak = 0
# Easy use functionality.
def reset_streak(self): # to be used on incorrect answer
self.set_streak(0)
def iter_streak(self): # to be used on correct answer
self.set_streak(self.get_streak() + 1)
def get_next_due(self):
# in: none
# out: dt.datetime
return self.next_due
def set_next_due(self, next_due): # DEBUG: keeping this one for debug purposes until no longer necessary
# in: dt.datetime
# out: none
self.next_due = next_due
def is_due(self):
# returns boolean True if the card is true, False otherwise.
return self.next_due <= dt.datetime.now()
def update_next_due(self, delta):
# in: float/int, days to push next due forward relative to answer time.
# out: none
self.next_due = dt.datetime.now() + dt.timedelta(delta)
def get_all_data(self):
# in: none
# out: returns list of all card data [str, str, float, int, datetime]
return [self.get_front(), self.get_back(), self.get_ease(), self.get_streak(), self.get_next_due()]
def card_update(self, performance):
# in: integer from 0-5. Performance value assigned by user themselves via some interface.
# out: none
# This method implements SM2 and does the heavy lifting.
# Nothing else should be necessary unless you wish to edit card data -
# for example, to change the back and front.
if performance < 3: # Failure states: 0, 1, 2
self.reset_streak()
self.update_next_due(0) # due immediately when incorrect
else: # Correct states: 3, 4, 5
self.set_ease(self.get_ease() + (-0.8 + 0.28*performance + 0.02*performance**2))
self.iter_streak()
self.update_next_due(6*self.get_ease()**(self.get_streak()-1))
def card_reset(self): # resets card data to default
self.ease = 2.5
self.streak = 0
self.next_due = dt.datetime.now()
# Now to set the class magic methods.
def __str__(self):
# Conversion into string
# What to show in the console upon print
return "Front: \"{}\" Back: \"{}\" Ease: \"{}\" Streak: \"{}\" Due: \"{}\"".format(
self.get_front(),self.get_back(),self.get_ease(),self.get_streak(),self.get_next_due())
def __repr__(self):
# Similar. Representation of the data - more or less how to recreate the card.
return "Flashcard(\"{}\",\"{}\",{},{},{})".format(
self.get_front(),self.get_back(),self.get_ease(),self.get_streak(),self.get_next_due().__repr__())
# nasty direct call to magic method
def __eq__(self, other):
# Defines equality operator ==. We can use this to find duplicate cards.
# Let's use only the front and back text for these ones.
# Takes advantage of already existing string comparisons.
return self.get_front() == other.get_front() and self.get_back() == other.get_back()
def __ne__(self, other):
# Defines inequality. Essentially inverse of previous.
return not (self.get_front() == other.get_front() and self.get_back() == other.get_back())
# more comparison operators
# These should make it compatible with standard sorting functions
# so that a list of flashcards can easily be sorted by their due dates
# with the .sort() method.
def __lt__(self, other):
return self.get_next_due() < other.get_next_due()
def __gt__(self, other):
return self.get_next_due() > other.get_next_due()
def __le__(self, other):
return self.get_next_due() <= other.get_next_due()
def __ge__(self, other):
return self.get_next_due() >= other.get_next_due()
# More card types can perhaps be added with inheritance. | 35.705394 | 110 | 0.592911 | 1,181 | 8,605 | 4.165961 | 0.225233 | 0.04126 | 0.026423 | 0.030894 | 0.254472 | 0.210366 | 0.170528 | 0.148577 | 0.148577 | 0.125407 | 0 | 0.010045 | 0.305869 | 8,605 | 241 | 111 | 35.705394 | 0.813661 | 0.355607 | 0 | 0.20155 | 0 | 0 | 0.011903 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.348837 | false | 0 | 0.007752 | 0.178295 | 0.565891 | 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 | 1 | 0 | 0 | 3 |
0d2812130ea78608c0f4a9bb7855c9feaa70760e | 4,589 | py | Python | pycrybittrex/core/bittrex11.py | namiazad/pycrybittrex | fce4dbfde112fd31b5ede0ff1432a4c3afeb3668 | [
"Apache-2.0"
] | null | null | null | pycrybittrex/core/bittrex11.py | namiazad/pycrybittrex | fce4dbfde112fd31b5ede0ff1432a4c3afeb3668 | [
"Apache-2.0"
] | null | null | null | pycrybittrex/core/bittrex11.py | namiazad/pycrybittrex | fce4dbfde112fd31b5ede0ff1432a4c3afeb3668 | [
"Apache-2.0"
] | null | null | null | import hashlib
import hmac
import time
import requests
from pycrybittrex.core import urlutils
from pycrybittrex.core.bittrexbase import BittrexBase
from pycrybittrex.definitions import Scope
class Bittrex11(BittrexBase):
def __sign(self, url):
return hmac.new(self.api_secret.encode(), url.encode(), hashlib.sha512).hexdigest()
def __query(self, path, params, scope):
if scope == Scope.PRIVATE:
params['apikey'] = self.api_key
params['nonce'] = int(round(time.time()))
full_url = '{0}{1}{2}'.format(self.base_url(), path, urlutils.url_params(params))
headers = {'apisign': self.__sign(full_url)}
else:
full_url = '{0}public/{1}{2}'.format(self.base_url(), path, urlutils.url_params(params))
headers = {}
return requests.get(full_url, headers=headers).json()
def __checked_query(self, path, params, scope):
response = self.__query(path, params, scope)
if not response["success"]:
raise RuntimeError("Request failed with message {0}".format(response["message"]))
return response["result"]
def base_url(self):
return "https://bittrex.com/api/v1.1/"
def get_markets(self):
return self.__checked_query('getmarkets', params={}, scope=Scope.PUBLIC)
def get_currencies(self):
return self.__checked_query('getcurrencies', params={}, scope=Scope.PUBLIC)
def get_ticker(self):
return self.__checked_query('getticker', params={}, scope=Scope.PUBLIC)
def get_market_summaries(self):
return self.__checked_query('getmarketsummaries', params={}, scope=Scope.PUBLIC)
def get_market_summary(self, market):
return self.__checked_query('getmarketsummary', params={'market': market}, scope=Scope.PUBLIC)
def get_order_book(self, market, order_type):
return self.__checked_query('getorderbook', params={'market': market,
'type': order_type}, scope=Scope.PUBLIC)
def get_market_history(self, market):
return self.__checked_query('getmarkethistory', params={'market': market}, scope=Scope.PUBLIC)
def buy_limit(self, market, quantity, rate):
return self.__checked_query('market/buylimit', params={'market': market,
'quantity': quantity,
'rate': rate}, scope=Scope.PRIVATE)
def sell_limit(self, market, quantity, rate):
return self.__checked_query('market/selllimit', params={'market': market,
'quantity': quantity,
'rate': rate}, scope=Scope.PRIVATE)
def cancel(self, uuid):
return self.__checked_query('market/cancel', params={'uuid': uuid}, scope=Scope.PRIVATE)
def get_open_orders(self, market):
return self.__checked_query('market/getopenorders', params={'market': market}, scope=Scope.PRIVATE)
def get_balances(self):
return self.__checked_query('account/getbalances', params={}, scope=Scope.PRIVATE)
def get_balance(self, currency):
return self.__checked_query('account/getbalance', params={'currency': currency}, scope=Scope.PRIVATE)
def get_deposit_address(self, currency):
return self.__checked_query('account/getdepositaddress', params={'currency': currency}, scope=Scope.PRIVATE)
def withdraw(self, currency, quantity, address, payment_id):
return self.__checked_query('account/withdraw', params={'currency': currency,
'quantity': quantity,
'address': address,
'paymentid': payment_id}, scope=Scope.PRIVATE)
def get_order(self, uuid):
return self.__checked_query('account/getorder', params={'uuid': uuid}, scope=Scope.PRIVATE)
def get_order_history(self, market):
return self.__checked_query('account/getorderhistory', params={'market': market}, scope=Scope.PRIVATE)
def get_withdrawal_history(self, currency):
return self.__checked_query('account/getwithdrawalhistory', params={'currency': currency}, scope=Scope.PRIVATE)
def get_deposit_history(self, currency):
return self.__checked_query('account/getdeposithistory', params={'currency': currency}, scope=Scope.PRIVATE)
| 44.125 | 119 | 0.620615 | 486 | 4,589 | 5.635802 | 0.22428 | 0.073019 | 0.117926 | 0.15261 | 0.579043 | 0.481928 | 0.379701 | 0.254107 | 0.162103 | 0.124133 | 0 | 0.004112 | 0.258008 | 4,589 | 103 | 120 | 44.553398 | 0.800294 | 0 | 0 | 0.068493 | 0 | 0 | 0.129222 | 0.022009 | 0 | 0 | 0 | 0 | 0 | 1 | 0.315068 | false | 0 | 0.09589 | 0.287671 | 0.739726 | 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 | 1 | 0 | 0 | 3 |
0d51500f012d34a07dc66adde3187cceb09b7e29 | 288 | py | Python | acaversity/test_acaversity.py | micktwomey/acaversity | a64f56aa2dac60838a84034057a687a932d68f8a | [
"MIT"
] | 1 | 2015-07-19T21:26:49.000Z | 2015-07-19T21:26:49.000Z | acaversity/test_acaversity.py | micktwomey/acaversity | a64f56aa2dac60838a84034057a687a932d68f8a | [
"MIT"
] | null | null | null | acaversity/test_acaversity.py | micktwomey/acaversity | a64f56aa2dac60838a84034057a687a932d68f8a | [
"MIT"
] | null | null | null | import json
def test_index(client):
response = client.get("/")
assert response.status_code == 200
def test_healthcheck(client):
response = client.get("/health")
assert response.status_code == 200
assert json.loads(response.content.decode('utf-8')) == {"ok": True}
| 22.153846 | 71 | 0.680556 | 37 | 288 | 5.189189 | 0.567568 | 0.072917 | 0.208333 | 0.239583 | 0.28125 | 0 | 0 | 0 | 0 | 0 | 0 | 0.029289 | 0.170139 | 288 | 12 | 72 | 24 | 0.774059 | 0 | 0 | 0.25 | 0 | 0 | 0.052083 | 0 | 0 | 0 | 0 | 0 | 0.375 | 1 | 0.25 | false | 0 | 0.125 | 0 | 0.375 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b4a4ac52ef1c64687d708763badd976672dec5e7 | 593 | py | Python | tests/outlook_client_case.py | phillipkuo/Office365-REST-Python-Client | ebbd6114ec65a23600b38db95977fc56ed95288d | [
"MIT"
] | null | null | null | tests/outlook_client_case.py | phillipkuo/Office365-REST-Python-Client | ebbd6114ec65a23600b38db95977fc56ed95288d | [
"MIT"
] | null | null | null | tests/outlook_client_case.py | phillipkuo/Office365-REST-Python-Client | ebbd6114ec65a23600b38db95977fc56ed95288d | [
"MIT"
] | 1 | 2018-03-23T14:49:04.000Z | 2018-03-23T14:49:04.000Z | from unittest import TestCase
from examples.settings import settings
from office365.outlookservices.outlook_client import OutlookClient
from office365.runtime.auth.network_credential_context import NetworkCredentialContext
class OutlookClientTestCase(TestCase):
"""SharePoint specific test case base class"""
@classmethod
def setUpClass(cls):
ctx_auth = NetworkCredentialContext(username=settings['user_credentials']['username'],
password=settings['user_credentials']['password'])
cls.client = OutlookClient(ctx_auth)
| 39.533333 | 94 | 0.740304 | 56 | 593 | 7.714286 | 0.589286 | 0.060185 | 0.106481 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012397 | 0.183811 | 593 | 14 | 95 | 42.357143 | 0.880165 | 0.067454 | 0 | 0 | 0 | 0 | 0.087751 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0.1 | 0.4 | 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 | 1 | 0 | 1 | 0 | 0 | 3 |
b4a8381cee40e51934b2101e6549150db480f9fe | 256 | py | Python | trackers/github.py | psycho-ir/autodo | 757ab7746564a8ef4f2decc99978f8f6213e69a1 | [
"MIT"
] | null | null | null | trackers/github.py | psycho-ir/autodo | 757ab7746564a8ef4f2decc99978f8f6213e69a1 | [
"MIT"
] | null | null | null | trackers/github.py | psycho-ir/autodo | 757ab7746564a8ef4f2decc99978f8f6213e69a1 | [
"MIT"
] | null | null | null | from trackers.tracker import Tracker
class GithubIssueTracker(Tracker):
def __init__(self, url):
pass
def create_issue(self, issue):
super().create_issue(issue)
def find_todo_issues(self):
super().find_todo_issues()
| 19.692308 | 36 | 0.679688 | 31 | 256 | 5.290323 | 0.548387 | 0.134146 | 0.170732 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.222656 | 256 | 12 | 37 | 21.333333 | 0.824121 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.375 | false | 0.125 | 0.125 | 0 | 0.625 | 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 | 1 | 0 | 0 | 3 |
b4b0a63d20c13aee6dcc718d7b5644a09c0d06a9 | 1,691 | py | Python | echecs_espoir/service/room/validators/basevalidator.py | obespoir/echecs | e4bb8be1d360b6c568725aee4dfe4c037a855a49 | [
"AFL-3.0"
] | 14 | 2020-03-22T14:03:51.000Z | 2022-02-21T09:28:39.000Z | echecs_espoir/service/room/validators/basevalidator.py | obespoir/echecs | e4bb8be1d360b6c568725aee4dfe4c037a855a49 | [
"AFL-3.0"
] | null | null | null | echecs_espoir/service/room/validators/basevalidator.py | obespoir/echecs | e4bb8be1d360b6c568725aee4dfe4c037a855a49 | [
"AFL-3.0"
] | 7 | 2020-03-22T13:57:43.000Z | 2022-02-21T09:30:17.000Z | # coding=utf-8
from wtforms import form
class InputWrapper(object):
def __init__(self, multi_dict):
self._wrapped = multi_dict
def __iter__(self):
return iter(self._wrapped)
def __len__(self):
return len(self._wrapped)
def __contains__(self, item):
return item in self._wrapped
def __getitem__(self, item):
return self._wrapped(item)
def __getattr__(self, item):
return self.__getitem__(item)
def getlist(self, name):
try:
return [self.to_unicode(str(self._wrapped[name]))]
except KeyError:
return []
@classmethod
def to_unicode(cls, value):
if isinstance(value, (str, type(None))):
return value
if not isinstance(value, bytes):
raise TypeError("Expected bytes, unicode or None; got %r" % type(value))
return value.encode("utf-8")
class ValidatorError(Exception):
def __init__(self, error_code):
super(ValidatorError, self).__init__(error_code)
self.error_code = error_code
class BaseValidator(form.Form):
"""
参数校验器
"""
def __init__(self, handler, obj=None, **kwargs):
self.handler = handler
super(BaseValidator, self).__init__(handler.params, obj, **kwargs)
def process(self, form_data=None, obj=None, data=None, **kwargs):
if form_data is not None and not hasattr(form_data, "getlist"):
form_data = InputWrapper(form_data)
super(BaseValidator, self).process(form_data, obj, **kwargs)
if not self.validate():
error_code = self.errors.values()[0][0]
raise ValidatorError(error_code)
| 25.621212 | 84 | 0.628622 | 202 | 1,691 | 4.935644 | 0.336634 | 0.066199 | 0.033099 | 0.036108 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003197 | 0.260201 | 1,691 | 65 | 85 | 26.015385 | 0.793765 | 0.011236 | 0 | 0 | 0 | 0 | 0.030872 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.268293 | false | 0 | 0.02439 | 0.121951 | 0.585366 | 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 | 1 | 0 | 0 | 3 |
b4bc53a0f83c3558980fcc55263ae7a5d6cff15d | 632 | py | Python | Python-Advanced/lists_as_stacks_and_queues_exercise/balanced_parentheses.py | Xamaneone/SoftUni-Intro | 985fe3249cd2adf021c2003372e840219811d989 | [
"MIT"
] | null | null | null | Python-Advanced/lists_as_stacks_and_queues_exercise/balanced_parentheses.py | Xamaneone/SoftUni-Intro | 985fe3249cd2adf021c2003372e840219811d989 | [
"MIT"
] | null | null | null | Python-Advanced/lists_as_stacks_and_queues_exercise/balanced_parentheses.py | Xamaneone/SoftUni-Intro | 985fe3249cd2adf021c2003372e840219811d989 | [
"MIT"
] | null | null | null | from _collections import deque
INPUT = input()
data = deque()
for parenthesis in INPUT:
if parenthesis == "{" or parenthesis == "[" or parenthesis == "(":
data.append(parenthesis)
if parenthesis == "}" or parenthesis == "]" or parenthesis == ")":
if len(data) == 0:
data.append("Nope")
break
if parenthesis == "}":
if data.pop() != "{":
break
elif parenthesis == "]":
if data.pop() != "[":
break
elif parenthesis == ")":
if data.pop() != "(":
break
if len(data) == 0:
print("YES")
else:
print("NO") | 21.793103 | 70 | 0.488924 | 62 | 632 | 4.967742 | 0.354839 | 0.211039 | 0.311688 | 0.194805 | 0.522727 | 0.522727 | 0.269481 | 0.269481 | 0.269481 | 0.269481 | 0 | 0.004762 | 0.335443 | 632 | 29 | 71 | 21.793103 | 0.728571 | 0 | 0 | 0.26087 | 0 | 0 | 0.033175 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.043478 | 0 | 0.043478 | 0.086957 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b4cd47535023e80644dacd1283acdb4a3d864ad7 | 119 | py | Python | P4101.py | daily-boj/SkyLightQP | 5038819b6ad31f94d84a66c7679c746a870bb857 | [
"Unlicense"
] | 6 | 2020-04-08T09:05:38.000Z | 2022-01-20T08:09:48.000Z | P4101.py | daily-boj/SkyLightQP | 5038819b6ad31f94d84a66c7679c746a870bb857 | [
"Unlicense"
] | null | null | null | P4101.py | daily-boj/SkyLightQP | 5038819b6ad31f94d84a66c7679c746a870bb857 | [
"Unlicense"
] | 1 | 2020-05-23T21:17:10.000Z | 2020-05-23T21:17:10.000Z | while True:
a, b = map(int, input().split())
if a == 0 and b == 0: break
print("Yes" if (a > b) else "No")
| 23.8 | 37 | 0.495798 | 22 | 119 | 2.681818 | 0.727273 | 0.067797 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02381 | 0.294118 | 119 | 4 | 38 | 29.75 | 0.678571 | 0 | 0 | 0 | 0 | 0 | 0.042017 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 0.25 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b4cfa925343da32b49f2ad32e9ee9354a7443171 | 592 | py | Python | steps/step07.py | choiking10/mytorch | 67140b608b14e2ec6ecca1638705af91d2d71b6b | [
"MIT"
] | null | null | null | steps/step07.py | choiking10/mytorch | 67140b608b14e2ec6ecca1638705af91d2d71b6b | [
"MIT"
] | null | null | null | steps/step07.py | choiking10/mytorch | 67140b608b14e2ec6ecca1638705af91d2d71b6b | [
"MIT"
] | null | null | null | import numpy as np
import mytorch.simple_core
from mytorch.simple_core import Variable
A = mytorch.simple_core.Square()
B = mytorch.simple_core.Exp()
C = mytorch.simple_core.Square()
# y = (e^{x^2})^2
# 계산 그래프의 연결 x -> A -> a -> B -> b -> C -> y
x = Variable(np.array(0.5))
a = A(x)
b = B(a)
y = C(b)
assert y.creator == C
assert y.creator.input == b
assert y.creator.input.creator == B
assert y.creator.input.creator.input == a
assert y.creator.input.creator.input.creator == A
assert y.creator.input.creator.input.creator.input == x
y.grad = np.array(1.0)
y.backward()
print(x.grad)
| 20.413793 | 55 | 0.682432 | 109 | 592 | 3.66055 | 0.284404 | 0.270677 | 0.210526 | 0.238095 | 0.343358 | 0.343358 | 0.195489 | 0.195489 | 0 | 0 | 0 | 0.011905 | 0.148649 | 592 | 28 | 56 | 21.142857 | 0.779762 | 0.097973 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.315789 | 1 | 0 | false | 0 | 0.157895 | 0 | 0.157895 | 0.052632 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b4d1cf15cc3375414b254c6df0cabbdf9eae442c | 2,134 | py | Python | simulations/robot_simulator/__init__.py | BrianLusina/PyCharm | 144dd4f6b2d254507237f46c8ee175c407fe053d | [
"Apache-2.0",
"MIT"
] | null | null | null | simulations/robot_simulator/__init__.py | BrianLusina/PyCharm | 144dd4f6b2d254507237f46c8ee175c407fe053d | [
"Apache-2.0",
"MIT"
] | null | null | null | simulations/robot_simulator/__init__.py | BrianLusina/PyCharm | 144dd4f6b2d254507237f46c8ee175c407fe053d | [
"Apache-2.0",
"MIT"
] | null | null | null | # initialize the compass points
NORTH, EAST, SOUTH, WEST = range(4)
class CompassPoints(object):
"""
initialize the class to have a default compass bearing of NORTH
left method subtracts a 'co-ordinate' point from the x axis
right method moves the robot +1 co-ordinate along the x-axis
"""
compass_points = [NORTH, EAST, SOUTH, WEST]
def __init__(self, c_bearing=NORTH):
self.c_bearing = c_bearing
def move_left(self):
self.c_bearing = self.compass_points[self.c_bearing - 1]
def move_right(self):
self.c_bearing = self.compass_points[(self.c_bearing + 1) % 4]
class Robot(object):
"""
Initialize the ROBOT to have a bearing of north and x,y coordinates at the origin
:compass_points is an instance(object) of the CompassPoints class
:robot_bearing finds the current bearing of the robot
:coordinates gets the current co-ordinates of the robot
:advance method moves the robot across the plane based on the robot bearing, adding and subtracting coordinates
:left_turn, right_turn moves the robot according to the input commands
"""
def __init__(self, robot_bearing=NORTH, x_cord=0, y_cord=0):
self.compass_points = CompassPoints(robot_bearing)
self.x_cord = x_cord
self.y_cord = y_cord
@property
def bearing(self):
return self.compass_points.c_bearing
@property
def coordinates(self):
return self.x_cord, self.y_cord
def advance(self):
if self.bearing == NORTH:
self.y_cord += 1
elif self.bearing == SOUTH:
self.y_cord -= 1
elif self.bearing == EAST:
self.x_cord += 1
elif self.bearing == WEST:
self.x_cord -= 1
def turn_left(self):
return self.compass_points.move_left()
def turn_right(self):
return self.compass_points.move_right()
def simulate(self, robot_commands):
instruct = {"A": self.advance, "R": self.turn_right, "L": self.turn_left}
for cmd in robot_commands:
if cmd in instruct:
instruct.get(cmd)()
| 30.927536 | 115 | 0.656982 | 302 | 2,134 | 4.47351 | 0.248344 | 0.086603 | 0.053294 | 0.046632 | 0.252406 | 0.196891 | 0.105107 | 0.068098 | 0.068098 | 0.068098 | 0 | 0.006949 | 0.258201 | 2,134 | 68 | 116 | 31.382353 | 0.846494 | 0.307404 | 0 | 0.052632 | 0 | 0 | 0.002114 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.263158 | false | 0.210526 | 0 | 0.105263 | 0.447368 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 3 |
b4f6ae707c3bf941d992ece3d193b07ff632a8b1 | 656 | py | Python | blog/blog_forms.py | JoaoTimm/MOZEN | e7fe8ff55f8e1320a9db5f6074e3827407903260 | [
"MIT"
] | null | null | null | blog/blog_forms.py | JoaoTimm/MOZEN | e7fe8ff55f8e1320a9db5f6074e3827407903260 | [
"MIT"
] | 4 | 2021-03-19T03:43:45.000Z | 2022-03-11T23:59:11.000Z | blog/blog_forms.py | JoaoTimm/MOZEN | e7fe8ff55f8e1320a9db5f6074e3827407903260 | [
"MIT"
] | null | null | null | from flask_ckeditor import CKEditorField
from flask_wtf import FlaskForm
from flask_wtf.file import FileAllowed
from wtforms import SubmitField, StringField, validators, FileField
class PostForm(FlaskForm):
title = StringField(u'Post Title', validators=[validators.DataRequired()])
post_image_file = FileField('Post head picture', validators=[FileAllowed(['jpg', 'png', 'webp'])])
body = CKEditorField('body', validators=[validators.DataRequired()])
tags = StringField(u'Tags', validators=[])
submit = SubmitField('Save Post')
class SearchForm(FlaskForm):
search = StringField(u'search', validators=[validators.DataRequired()])
| 38.588235 | 102 | 0.754573 | 71 | 656 | 6.901408 | 0.450704 | 0.055102 | 0.195918 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.121951 | 656 | 16 | 103 | 41 | 0.850694 | 0 | 0 | 0 | 0 | 0 | 0.091463 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
3720d6877b1be005e4355cf2b810650ff29e3103 | 9,934 | py | Python | tests/barriers/test_edit_wto_profile.py | felix781/market-access-python-frontend | 3b0e49feb4fdf0224816326938a46002aa4a2b1c | [
"MIT"
] | null | null | null | tests/barriers/test_edit_wto_profile.py | felix781/market-access-python-frontend | 3b0e49feb4fdf0224816326938a46002aa4a2b1c | [
"MIT"
] | null | null | null | tests/barriers/test_edit_wto_profile.py | felix781/market-access-python-frontend | 3b0e49feb4fdf0224816326938a46002aa4a2b1c | [
"MIT"
] | null | null | null | from http import HTTPStatus
from django.urls import reverse
from mock import patch
from core.tests import MarketAccessTestCase
class EditWTOProfileTestCase(MarketAccessTestCase):
@patch("utils.api.resources.APIResource.patch")
def test_bad_raised_date(self, mock_patch):
response = self.client.post(
reverse(
"barriers:edit_wto_profile", kwargs={"barrier_id": self.barrier["id"]}
),
data={
"raised_date_0": "50",
"raised_date_1": "1",
"raised_date_2": "2020",
},
)
assert response.status_code == HTTPStatus.OK
assert "form" in response.context
form = response.context["form"]
assert form.is_valid() is False
assert "raised_date" in form.errors
assert mock_patch.called is False
@patch("utils.api.resources.APIResource.patch")
def test_empty_form_success(self, mock_patch):
response = self.client.post(
reverse(
"barriers:edit_wto_profile", kwargs={"barrier_id": self.barrier["id"]}
),
data={},
)
assert response.status_code == HTTPStatus.FOUND
mock_patch.assert_called_with(
id=self.barrier["id"],
wto_profile={
"committee_notified": "",
"committee_notification_link": "",
"committee_notification_document": "",
"member_states": [],
"committee_raised_in": "",
"meeting_minutes": "",
"raised_date": None,
"case_number": "",
},
)
@patch("barriers.forms.mixins.DocumentMixin.upload_document")
@patch("utils.api.resources.APIResource.patch")
def test_full_form_success(self, mock_patch, mock_upload_document):
mock_upload_document.return_value = {
"id": "a9593a3f-1640-40ba-9c92-1a1186ca6e68",
"file": {"name": "name.jpg", "size": "5000"},
}
with open("tests/files/attachment.jpeg", "rb") as document:
response = self.client.post(
reverse(
"barriers:edit_wto_profile",
kwargs={"barrier_id": self.barrier["id"]},
),
data={
"committee_notified": "6448e88f-bf12-481f-873d-ac1199825743",
"committee_notification_link": "http://www.google.com",
"committee_notification_document": document,
"member_states": [
"a05f66a0-5d95-e211-a939-e4115bead28a",
"955f66a0-5d95-e211-a939-e4115bead28a",
],
"committee_raised_in": "0d4876ab-e125-4167-9449-9f89f843921c",
"meeting_minutes": "",
"raised_date_0": "25",
"raised_date_1": "1",
"raised_date_2": "2020",
"case_number": "ABCD1234",
},
)
assert response.status_code == HTTPStatus.FOUND
mock_patch.assert_called_with(
id=self.barrier["id"],
wto_profile={
"committee_notified": "6448e88f-bf12-481f-873d-ac1199825743",
"committee_notification_link": "http://www.google.com",
"committee_notification_document": (
"a9593a3f-1640-40ba-9c92-1a1186ca6e68"
),
"member_states": [
"a05f66a0-5d95-e211-a939-e4115bead28a",
"955f66a0-5d95-e211-a939-e4115bead28a",
],
"committee_raised_in": "0d4876ab-e125-4167-9449-9f89f843921c",
"meeting_minutes": "",
"raised_date": "2020-01-25",
"case_number": "ABCD1234",
},
)
@patch("barriers.forms.mixins.DocumentMixin.upload_document")
@patch("utils.api.resources.APIResource.patch")
def test_meeting_minutes_success(self, mock_patch, mock_upload_document):
mock_upload_document.return_value = {
"id": "a9593a3f-1640-40ba-9c92-1a1186ca6e68",
"file": {"name": "name.jpg", "size": "5000"},
}
with open("tests/files/attachment.jpeg", "rb") as document:
response = self.client.post(
reverse(
"barriers:edit_wto_profile",
kwargs={"barrier_id": self.barrier["id"]},
),
data={
"meeting_minutes": document,
"case_number": "XYZ999",
},
)
assert response.status_code == HTTPStatus.FOUND
mock_patch.assert_called_with(
id=self.barrier["id"],
wto_profile={
"committee_notified": "",
"committee_notification_link": "",
"committee_notification_document": "",
"member_states": [],
"committee_raised_in": "",
"meeting_minutes": "a9593a3f-1640-40ba-9c92-1a1186ca6e68",
"raised_date": None,
"case_number": "XYZ999",
},
)
@patch("utils.api.resources.APIResource.patch")
def test_success_with_ajax_documents(self, mock_patch):
notification_document_id = "38ab3bed-fc19-4770-9c12-9e26667efbc5"
minutes_document_id = "6448e88f-bf12-481f-873d-ac1199825743"
response = self.client.post(
reverse(
"barriers:edit_wto_profile", kwargs={"barrier_id": self.barrier["id"]}
),
data={
"committee_notification_document_id": notification_document_id,
"meeting_minutes_id": minutes_document_id,
},
)
assert response.status_code == HTTPStatus.FOUND
mock_patch.assert_called_with(
id=self.barrier["id"],
wto_profile={
"committee_notified": "",
"committee_notification_link": "",
"committee_notification_document": notification_document_id,
"member_states": [],
"committee_raised_in": "",
"meeting_minutes": minutes_document_id,
"raised_date": None,
"case_number": "",
},
)
@patch("barriers.forms.mixins.DocumentMixin.upload_document")
def test_add_document_via_ajax(self, mock_upload_document):
document_id = "38ab3bed-fc19-4770-9c12-9e26667efbc5"
mock_upload_document.return_value = {
"id": document_id,
"file": {"name": "attachment.jpeg", "size": "5000"},
}
with open("tests/files/attachment.jpeg", "rb") as document:
response = self.client.post(
reverse(
"barriers:add_wto_document",
kwargs={"barrier_id": self.barrier["id"]},
),
data={"meeting_minutes": document},
xhr=True,
)
assert response.status_code == HTTPStatus.OK
response_data = response.json()
assert response_data["documentId"] == document_id
assert "delete_url" in response_data
assert response_data["file"]["name"] == "attachment.jpeg"
session_key = f"barrier:{self.barrier['id']}:wto:meeting_minutes"
assert self.client.session[session_key]["id"] == document_id
assert mock_upload_document.called is True
def test_delete_document_via_ajax(self):
document_id = "309d9ef4-4379-4514-ae5f-3399ba7f2ca6"
barrier_id = self.barrier["id"]
session_key = f"barrier:{barrier_id}:wto:committee_notification_document"
self.update_session({session_key: {"id": document_id}})
self.client.post(
reverse(
"barriers:delete_wto_document",
kwargs={"barrier_id": self.barrier["id"], "document_id": document_id},
),
xhr=True,
)
assert self.client.session[session_key] is None
def test_delete_document_non_ajax(self):
document_id = "309d9ef4-4379-4514-ae5f-3399ba7f2ca6"
barrier_id = self.barrier["id"]
session_key = f"barrier:{barrier_id}:wto:meeting_minutes"
self.update_session({session_key: {"id": document_id}})
self.client.get(
reverse(
"barriers:delete_wto_document",
kwargs={"barrier_id": self.barrier["id"], "document_id": document_id},
),
)
assert self.client.session[session_key] is None
@patch("utils.api.resources.APIResource.patch")
def test_cancel_form(self, mock_patch):
""" Cancelling the form should clear the session and not call the API """
barrier_id = self.barrier["id"]
notification_document_id = "38ab3bed-fc19-4770-9c12-9e26667efbc5"
notification_session_key = (
f"barrier:{barrier_id}:wto:committee_notification_document"
)
self.update_session(
{notification_session_key: {"id": notification_document_id}}
)
minutes_document_id = "6448e88f-bf12-481f-873d-ac1199825743"
minutes_session_key = f"barrier:{barrier_id}:wto:meeting_minutes"
self.update_session({minutes_session_key: {"id": minutes_document_id}})
assert notification_session_key in self.client.session
assert minutes_session_key in self.client.session
self.client.get(
reverse(
"barriers:cancel_wto_documents",
kwargs={"barrier_id": self.barrier["id"]},
),
)
assert notification_session_key not in self.client.session
assert minutes_session_key not in self.client.session
assert mock_patch.called is False
| 39.110236 | 86 | 0.565633 | 962 | 9,934 | 5.568607 | 0.153846 | 0.055441 | 0.041254 | 0.044801 | 0.808102 | 0.759567 | 0.711966 | 0.696099 | 0.574015 | 0.574015 | 0 | 0.069297 | 0.318703 | 9,934 | 253 | 87 | 39.264822 | 0.722222 | 0.006543 | 0 | 0.631111 | 0 | 0 | 0.294189 | 0.196633 | 0 | 0 | 0 | 0 | 0.115556 | 1 | 0.04 | false | 0 | 0.017778 | 0 | 0.062222 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
372e290100aab769467c8f679b1d1a3236425d95 | 570 | py | Python | onadata/apps/core/admin.py | naxa-developers/mes-core | a9c0449540d37ef45f261ef21c471d3e7eba2df6 | [
"BSD-2-Clause"
] | 1 | 2019-03-10T09:25:17.000Z | 2019-03-10T09:25:17.000Z | onadata/apps/core/admin.py | naxadeve/mes-core | a9c0449540d37ef45f261ef21c471d3e7eba2df6 | [
"BSD-2-Clause"
] | 48 | 2019-03-18T09:26:31.000Z | 2019-05-27T08:12:03.000Z | onadata/apps/core/admin.py | naxa-developers/mes-core | a9c0449540d37ef45f261ef21c471d3e7eba2df6 | [
"BSD-2-Clause"
] | null | null | null | from django.contrib import admin
from onadata.apps.core.models import Project, Output, ActivityGroup, Activity, Cluster, Beneficiary, UserRole,\
ClusterAG, ClusterA, Config, District, Municipality
admin.site.register(Project)
admin.site.register(Output)
admin.site.register(ActivityGroup)
admin.site.register(Activity)
admin.site.register(Cluster)
admin.site.register(Beneficiary)
admin.site.register(UserRole)
admin.site.register(ClusterAG)
admin.site.register(ClusterA)
admin.site.register(Config)
admin.site.register(District)
admin.site.register(Municipality)
| 31.666667 | 111 | 0.822807 | 71 | 570 | 6.605634 | 0.323944 | 0.230277 | 0.434968 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.064912 | 570 | 17 | 112 | 33.529412 | 0.879925 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.133333 | 0 | 0.133333 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
2ea421e71eb2f5267a1c68df27b5f3257cb073e8 | 23 | py | Python | libbhyve/config.py | elstevi/libbhyve | 9d746073b80fc21d58d7931a21a891836d0748a6 | [
"BSD-2-Clause"
] | 1 | 2020-06-18T17:58:01.000Z | 2020-06-18T17:58:01.000Z | libbhyve/config.py | elstevi/libbhyve | 9d746073b80fc21d58d7931a21a891836d0748a6 | [
"BSD-2-Clause"
] | null | null | null | libbhyve/config.py | elstevi/libbhyve | 9d746073b80fc21d58d7931a21a891836d0748a6 | [
"BSD-2-Clause"
] | null | null | null | VM_DIR='/persist/vms/'
| 11.5 | 22 | 0.695652 | 4 | 23 | 3.75 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.043478 | 23 | 1 | 23 | 23 | 0.681818 | 0 | 0 | 0 | 0 | 0 | 0.565217 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
2ea660129898e883b860d14470c11a3ebff64d40 | 638 | py | Python | tests/functions/test_time.py | chriscardillo/ABSQL | d911a15daee46a2f4e867f09e85c582fa987e5ed | [
"MIT"
] | null | null | null | tests/functions/test_time.py | chriscardillo/ABSQL | d911a15daee46a2f4e867f09e85c582fa987e5ed | [
"MIT"
] | null | null | null | tests/functions/test_time.py | chriscardillo/ABSQL | d911a15daee46a2f4e867f09e85c582fa987e5ed | [
"MIT"
] | null | null | null | import pytest
from absql import Runner
from pendulum import now
from datetime import timedelta
@pytest.fixture
def runner():
return Runner()
@pytest.fixture
def yesterdate():
return (now(tz="utc") - timedelta(days=1)).to_date_string()
@pytest.fixture
def yesterhour():
return (
(now(tz="utc") - timedelta(hours=1, days=0))
.replace(minute=0, second=0)
.to_datetime_string()
)
def test_previous_date(runner, yesterdate):
assert runner.render("{{previous_date()}}") == yesterdate
def test_previous_hour(runner, yesterhour):
assert runner.render("{{previous_hour()}}") == yesterhour
| 19.9375 | 63 | 0.68652 | 79 | 638 | 5.417722 | 0.392405 | 0.091122 | 0.11215 | 0.065421 | 0.107477 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009488 | 0.173981 | 638 | 31 | 64 | 20.580645 | 0.802657 | 0 | 0 | 0.142857 | 0 | 0 | 0.068966 | 0 | 0 | 0 | 0 | 0 | 0.095238 | 1 | 0.238095 | false | 0 | 0.190476 | 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 | 1 | 0 | 0 | 3 |
2eae9f3336df548ad570aa579aa165db49ba8c06 | 11,572 | py | Python | ema/core/models/common_models.py | SizingLab/RoR_SAMO_paper_Benchmarking_monolythic_MDO_formulations | bc99259e1594c40c1abf048eadaa17187d4f87a0 | [
"Apache-2.0"
] | null | null | null | ema/core/models/common_models.py | SizingLab/RoR_SAMO_paper_Benchmarking_monolythic_MDO_formulations | bc99259e1594c40c1abf048eadaa17187d4f87a0 | [
"Apache-2.0"
] | null | null | null | ema/core/models/common_models.py | SizingLab/RoR_SAMO_paper_Benchmarking_monolythic_MDO_formulations | bc99259e1594c40c1abf048eadaa17187d4f87a0 | [
"Apache-2.0"
] | null | null | null | from openmdao.api import ExplicitComponent
class MotorTorque(ExplicitComponent):
"""ExplicitComponent that computes the motor torque."""
def __init__(self, derivative_method='full_analytic', **kwargs):
super(MotorTorque, self).__init__(**kwargs)
self.derivative_method = derivative_method
def setup(self):
# Attributes to count number of compute and compute_partials performed
self.num_compute = 0
self.num_compute_partials = 0
# Motor inertia
self.add_input('J_mot', val=1.)
# Max acceleration at actuator level
self.add_input('A_max', val=1.)
# Reducer reduction ratio
self.add_input('N_red', val=1.)
# Screw pitch
self.add_input('p', val=1.)
# Actuator load
self.add_input('F_ema', val=1.)
# Motor electromagnetic torque
self.add_output('T_em', val=1.)
if self.derivative_method == 'full_analytic':
self.declare_partials('*', '*', method='exact')
else:
self.declare_partials('*', '*', method='fd')
def compute(self, inputs, outputs):
"""Evaluates the equation
T_em = J_mot * A_max * N_red/p + F_ema * p/N_red"""
J_mot = inputs['J_mot']
A_max = inputs['A_max']
N_red = inputs['N_red']
p = inputs['p']
F_ema = inputs['F_ema']
outputs['T_em'] = J_mot * A_max * N_red / p + F_ema * p / N_red
self.num_compute += 1
def compute_partials(self, inputs, partials):
""" Jacobian for motor torque."""
partials['T_em', 'J_mot'] = inputs['A_max'] * \
inputs['N_red'] / inputs['p']
partials['T_em', 'A_max'] = inputs['J_mot'] * \
inputs['N_red'] / inputs['p']
partials['T_em', 'N_red'] = inputs['J_mot'] * \
inputs['A_max'] / inputs['p'] \
- inputs['F_ema'] * inputs['p'] / \
inputs[
'N_red'] ** 2.0
partials['T_em', 'p'] = -inputs['J_mot'] * \
inputs['A_max'] * \
inputs['N_red'] / inputs['p'] ** 2.0 \
+ inputs['F_ema'] / \
inputs['N_red']
partials['T_em', 'F_ema'] = inputs['p'] / inputs['N_red']
self.num_compute_partials += 1
class MotorInertia(ExplicitComponent):
"""ExplicitComponent that computes the motor inertia."""
def __init__(self, derivative_method='full_analytic', **kwargs):
super(MotorInertia, self).__init__(**kwargs)
self.derivative_method = derivative_method
def setup(self):
# Reference motor inertia
self.add_input('J_mot_ref', val=1.)
# Reference motor electromagnetic torque
self.add_input('T_em_ref', val=1.)
# Motor electromagnetic torque
self.add_input('T_em', val=1.)
# Motor inertia
self.add_output('J_mot', val=1.)
if self.derivative_method == 'full_analytic':
self.declare_partials('*', '*', method='exact')
else:
self.declare_partials('*', '*', method='fd')
def compute(self, inputs, outputs):
"""Evaluates the equation
J_mot = J_mot_ref * (T_em/T_em_ref)**(5.0/3.5)"""
J_mot_ref = inputs['J_mot_ref']
T_em_ref = inputs['T_em_ref']
T_em = inputs['T_em']
# Using abs() since COBYLA goes out of bound for HYBRID and MDF
outputs['J_mot'] = J_mot_ref * (abs(T_em) / T_em_ref) ** (5.0 / 3.5)
def compute_partials(self, inputs, partials):
""" Jacobian for motor inertia."""
partials['J_mot', 'J_mot_ref'] = (abs(inputs['T_em']) / \
inputs['T_em_ref']) ** (5.0 / 3.5)
partials['J_mot', 'T_em_ref'] = -1.42857142857143 * \
inputs['J_mot_ref'] * \
(abs(inputs['T_em']) / \
inputs['T_em_ref']) ** 1.42857142857143 / \
inputs['T_em_ref']
partials['J_mot', 'T_em'] = 1.42857142857143 * inputs['J_mot_ref'] \
* (abs(inputs['T_em']) / \
inputs['T_em_ref']) ** 1.42857142857143 / \
inputs['T_em']
class MotorSpeed(ExplicitComponent):
"""ExplicitComponent that computes the motor maximum speed."""
def __init__(self, derivative_method='full_analytic', **kwargs):
super(MotorSpeed, self).__init__(**kwargs)
self.derivative_method = derivative_method
def setup(self):
# Reference motor speed
self.add_input('W_mot_ref', val=1.)
# Reference motor electromagnetic torque
self.add_input('T_em_ref', val=1.)
# Motor electromagnetic torque
self.add_input('T_em', val=1.)
# Motor speed
self.add_output('W_mot', val=1.)
if self.derivative_method == 'full_analytic':
self.declare_partials('*', '*', method='exact')
else:
self.declare_partials('*', '*', method='fd')
def compute(self, inputs, outputs):
"""Evaluates the equation
W_mot = W_mot_ref * (T_em/T_em_ref)**(-1.0/3.5)"""
W_mot_ref = inputs['W_mot_ref']
T_em_ref = inputs['T_em_ref']
T_em = inputs['T_em']
# Using abs() since COBYLA goes out of bound for HYBRID and MDF
outputs['W_mot'] = W_mot_ref * (abs(T_em) / T_em_ref) ** (-1.0 / 3.5)
def compute_partials(self, inputs, partials):
""" Jacobian for motor speed."""
partials['W_mot', 'W_mot_ref'] = (inputs['T_em'] / inputs['T_em_ref']) ** (-1.0 / 3.5)
partials['W_mot', 'T_em_ref'] = 0.285714285714286 * inputs['W_mot_ref'] * \
(inputs['T_em'] / \
inputs['T_em_ref']) ** (-0.285714285714286) /\
inputs['T_em_ref']
partials['W_mot', 'T_em'] = -0.285714285714286 * inputs['W_mot_ref'] * \
(inputs['T_em'] / inputs['T_em_ref']) ** (-0.285714285714286) / \
inputs['T_em']
class MotorMass(ExplicitComponent):
"""ExplicitComponent that computes the motor mass."""
def __init__(self, derivative_method='full_analytic', **kwargs):
super(MotorMass, self).__init__(**kwargs)
self.derivative_method = derivative_method
def setup(self):
# Reference motor mass
self.add_input('M_mot_ref', val=1.)
# Reference motor electromagnetic torque
self.add_input('T_em_ref', val=1.)
# Motor electromagnetic torque
self.add_input('T_em', val=1.)
# Motor mass with scaler
self.add_output('M_mot', val=1., ref=100.)
if self.derivative_method == 'full_analytic':
self.declare_partials('*', '*', method='exact')
else:
self.declare_partials('*', '*', method='fd')
self.obj_hist = {}
self.num_iter = 0
# First index is one because of init
self.major_iterations = [1]
def compute(self, inputs, outputs):
"""Evaluates the equation
M_mot = M_mot_ref * (T_em/T_em_ref)**(3.0/3.5)"""
M_mot_ref = inputs['M_mot_ref']
T_em_ref = inputs['T_em_ref']
T_em = inputs['T_em']
# Using abs() since COBYLA goes out of bound for HYBRID
M_mot = M_mot_ref * (abs(T_em) / T_em_ref) ** (3.0 / 3.5)
outputs['M_mot'] = M_mot
self.obj_hist[self.num_iter] = outputs['M_mot'][0]
self.num_iter += 1
def compute_partials(self, inputs, partials):
""" Jacobian for motor inertia."""
partials['M_mot', 'M_mot_ref'] = (inputs['T_em'] / \
inputs['T_em_ref']) ** (3.0 / 3.5)
partials['M_mot', 'T_em_ref'] = -0.857142857142857 * \
inputs['M_mot_ref'] * \
(inputs['T_em'] / \
inputs['T_em_ref']) ** 0.857142857142857 /\
inputs['T_em_ref']
partials['M_mot', 'T_em'] = 0.857142857142857 * inputs['M_mot_ref'] *\
(inputs['T_em'] / inputs['T_em_ref']) ** 0.857142857142857 /\
inputs['T_em']
self.major_iterations.append(self.num_iter)
class MotorSpeedConstraint(ExplicitComponent):
"""ExplicitComponent that computes the motor speed constraint."""
def __init__(self, derivative_method='full_analytic', **kwargs):
super(MotorSpeedConstraint, self).__init__(**kwargs)
self.derivative_method = derivative_method
def setup(self):
# Motor speed
self.add_input('W_mot', val=1.)
# Max velocity at actuator level
self.add_input('V_max', val=1.)
# Reducer reduction ratio
self.add_input('N_red', val=1.)
# Lever arm
self.add_input('p', val=1.)
# Motor speed constraint
self.add_output('W_mot_constr', val=1.)
if self.derivative_method == 'full_analytic':
self.declare_partials('*', '*', method='exact')
else:
self.declare_partials('*', '*', method='fd')
def compute(self, inputs, outputs):
"""Evaluates the equation
W_mot_constr = V_max * N_red/p - W_mot"""
V_max = inputs['V_max']
N_red = inputs['N_red']
p = inputs['p']
W_mot = inputs['W_mot']
outputs['W_mot_constr'] = V_max * N_red / p - W_mot
def compute_partials(self, inputs, partials):
""" Jacobian for motor speed."""
partials['W_mot_constr', 'V_max'] = inputs['N_red'] / inputs['p']
partials['W_mot_constr', 'N_red'] = inputs['V_max'] / inputs['p']
partials['W_mot_constr', 'p'] = -inputs['V_max'] * inputs['N_red'] / (inputs['p'] ** 2.0)
partials['W_mot_constr', 'W_mot'] = -1.
class MotorInertiaConsistencyConstraint(ExplicitComponent):
"""ExplicitComponent that computes the motor inertia consistency constraint for IDF and Hybrid."""
def __init__(self, derivative_method='full_analytic', **kwargs):
super(MotorInertiaConsistencyConstraint, self).__init__(**kwargs)
self.derivative_method = derivative_method
def setup(self):
# Motor inertia consistency design variable
self.add_input('J_mot_t', val=1.)
# Motor inertia
self.add_input('J_mot', val=1.)
# Motor speed constraint
self.add_output('J_mot_c_constr', val=1.)
if self.derivative_method == 'full_analytic':
self.declare_partials('*', '*', method='exact')
else:
self.declare_partials('*', '*', method='fd')
def compute(self, inputs, outputs):
"""Evaluates the equation
J_mot_c_constr = J_mot_t - J_mot"""
J_mot_t = inputs['J_mot_t']
J_mot = inputs['J_mot']
outputs['J_mot_c_constr'] = J_mot_t - J_mot
def compute_partials(self, inputs, partials):
""" Jacobian for motor inertia consistency constraint."""
partials['J_mot_c_constr', 'J_mot_t'] = 1.
partials['J_mot_c_constr', 'J_mot'] = -1.
| 35.280488 | 102 | 0.543553 | 1,392 | 11,572 | 4.217672 | 0.08908 | 0.034747 | 0.030659 | 0.030659 | 0.826435 | 0.787941 | 0.715721 | 0.647931 | 0.612502 | 0.524102 | 0 | 0.034112 | 0.316021 | 11,572 | 327 | 103 | 35.388379 | 0.707644 | 0.160301 | 0 | 0.5 | 0 | 0 | 0.114337 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.133333 | false | 0 | 0.005556 | 0 | 0.172222 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
2c0d15bc3f6eb653b51e28e9de9f60af87fb5d91 | 749 | py | Python | pysynth/test_nokiacomposer2wav.py | nsidn98/Music-with-numbers | a2de7f7c3925218f284583b445d1198b5447ddd7 | [
"MIT"
] | 6 | 2019-02-08T19:53:53.000Z | 2020-10-31T00:32:21.000Z | pysynth/test_nokiacomposer2wav.py | nsidn98/Music-with-numbers | a2de7f7c3925218f284583b445d1198b5447ddd7 | [
"MIT"
] | 4 | 2020-03-24T16:47:00.000Z | 2021-06-01T23:27:22.000Z | Interview_Piscine/day04/ex16/piano/pysynth/test_nokiacomposer2wav.py | psprawka/Interview_Library | bcd4c0daa8040b714be407fb425b20d13ba2ae9c | [
"MIT"
] | 6 | 2019-02-03T01:41:04.000Z | 2020-06-02T19:16:03.000Z | from unittest import TestCase
from nokiacomposer2wav import parse_ringtone as p
class TestParseRingtone(TestCase):
def test_basics(self):
# Regular 1/4 C in 2nd octave
self.assertEqual(p("4c2"), [("c2", 4)])
# Sharp
self.assertEqual(p("4#c2"), [("c#2", 4)])
# Pause
self.assertEqual(p("4-"), [("r", 4)])
# Dot
self.assertEqual(p("8.c2"), [("c2", -8)])
# 1/16 and 1/32
self.assertEqual(p("16c2"), [("c2", 16)])
self.assertEqual(p("32c2"), [("c2", 32)])
# Space delimiters
self.assertEqual(p("4c2 4c2"), [("c2", 4), ("c2", 4)])
# Comma delimiters
self.assertEqual(p("4c2, 4c2"), [("c2", 4), ("c2", 4)])
| 26.75 | 63 | 0.507343 | 94 | 749 | 4.021277 | 0.414894 | 0.31746 | 0.338624 | 0.150794 | 0.201058 | 0.201058 | 0.201058 | 0.201058 | 0.201058 | 0.201058 | 0 | 0.097378 | 0.287049 | 749 | 28 | 64 | 26.75 | 0.610487 | 0.121495 | 0 | 0 | 0 | 0 | 0.086022 | 0 | 0 | 0 | 0 | 0 | 0.666667 | 1 | 0.083333 | false | 0 | 0.166667 | 0 | 0.333333 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
2c22b592738c6c06e3fc5401b6be1c62aebdbc00 | 490 | py | Python | logicmin/examples/solve4-tt.py | cfzile/logicmin | 5a1442017d8024b7b28cdeddf24dee0f7c3f54e0 | [
"MIT"
] | 15 | 2018-08-01T20:59:22.000Z | 2021-09-19T22:05:29.000Z | logicmin/examples/solve4-tt.py | cfzile/logicmin | 5a1442017d8024b7b28cdeddf24dee0f7c3f54e0 | [
"MIT"
] | 2 | 2021-02-24T09:25:07.000Z | 2021-11-21T10:01:33.000Z | logicmin/examples/solve4-tt.py | cfzile/logicmin | 5a1442017d8024b7b28cdeddf24dee0f7c3f54e0 | [
"MIT"
] | 4 | 2019-07-05T11:15:01.000Z | 2022-01-11T09:59:54.000Z | #!/usr/bin/env python
# encoding: UTF-8
import logicmin
t = logicmin.TT(4,6);
t.add("0000","--11-1")
t.add("0001","100110")
t.add("0010","101101")
t.add("0011","000010")
t.add("0100","110110")
t.add("0101","000101")
t.add("0110","1-11-1")
t.add("0111","1-10-1")
t.add("1000","1-11-1")
t.add("1001","110110")
t.add("1010","111111")
t.add("1011","110110")
t.add("1100","101111")
t.add("1101","101101")
t.add("1110","101110")
t.add("1111","011111")
sols = t.solve()
print(sols.printN())
| 16.896552 | 22 | 0.6 | 91 | 490 | 3.230769 | 0.505495 | 0.217687 | 0.068027 | 0.071429 | 0.054422 | 0 | 0 | 0 | 0 | 0 | 0 | 0.339207 | 0.073469 | 490 | 28 | 23 | 17.5 | 0.30837 | 0.073469 | 0 | 0 | 0 | 0 | 0.355556 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.05 | 0 | 0.05 | 0.05 | 0 | 0 | 0 | null | 1 | 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 | 3 |
2c246f9a7e7f8b12fdf87ae3f93fef9b42b3d09c | 417 | py | Python | quantization/imagenet/fbnet_building_blocks/layers/__init__.py | sunghern/Auto-Compression | 7c1123e5ffb63b0c34bef2db40dbfb560cb25c2e | [
"MIT"
] | 144 | 2019-05-04T08:07:54.000Z | 2022-03-04T16:04:12.000Z | fbnet_building_blocks/layers/__init__.py | pawopawo/FBNet | f201ed4d41e96a57a1b6631e9d357078e35a6b5d | [
"MIT",
"MIT-0"
] | 22 | 2019-11-26T06:48:07.000Z | 2021-12-20T12:50:16.000Z | fbnet_building_blocks/layers/__init__.py | pawopawo/FBNet | f201ed4d41e96a57a1b6631e9d357078e35a6b5d | [
"MIT",
"MIT-0"
] | 33 | 2019-05-23T17:32:31.000Z | 2021-11-09T05:00:55.000Z | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .batch_norm import FrozenBatchNorm2d
from .misc import Conv2d
from .misc import ConvTranspose2d
from .misc import BatchNorm2d
from .misc import interpolate
from .misc import _NewEmptyTensorOp
__all__ = ["Conv2d", "ConvTranspose2d", "interpolate",
"BatchNorm2d", "FrozenBatchNorm2d", "_NewEmptyTensorOp"
] | 32.076923 | 71 | 0.757794 | 44 | 417 | 7.022727 | 0.5 | 0.12945 | 0.226537 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.022923 | 0.16307 | 417 | 13 | 72 | 32.076923 | 0.862464 | 0.165468 | 0 | 0 | 0 | 0 | 0.221902 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.7 | 0 | 0.7 | 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 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
2c2995d565c5e7ca31220cb0b8b2a4e1c7ef3628 | 277 | py | Python | tests/__init__.py | lavr/celerybeat-mongo | fd8a021e1ae217df23d372cf5db9959fb2c1844f | [
"Apache-2.0"
] | 86 | 2016-07-21T22:43:59.000Z | 2022-03-04T19:44:01.000Z | tests/__init__.py | lavr/celerybeat-mongo | fd8a021e1ae217df23d372cf5db9959fb2c1844f | [
"Apache-2.0"
] | 36 | 2016-10-23T17:51:45.000Z | 2022-02-25T20:18:28.000Z | tests/__init__.py | lavr/celerybeat-mongo | fd8a021e1ae217df23d372cf5db9959fb2c1844f | [
"Apache-2.0"
] | 40 | 2016-10-26T18:36:11.000Z | 2022-03-20T08:23:38.000Z |
import unittest
from mongoengine import connect, disconnect
class BeatMongoCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
connect('mongoenginetest', host='mongomock://localhost')
@classmethod
def tearDownClass(cls):
disconnect() | 19.785714 | 64 | 0.711191 | 25 | 277 | 7.88 | 0.72 | 0.142132 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.194946 | 277 | 14 | 65 | 19.785714 | 0.883408 | 0 | 0 | 0.222222 | 0 | 0 | 0.129964 | 0.075812 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.222222 | 0 | 0.555556 | 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 | 1 | 0 | 0 | 3 |
25c9078761c77c545e4d508747fab41d35c30820 | 57,991 | py | Python | sdk/python/pulumi_azure_native/authorization/_inputs.py | pulumi-bot/pulumi-azure-native | f7b9490b5211544318e455e5cceafe47b628e12c | [
"Apache-2.0"
] | null | null | null | sdk/python/pulumi_azure_native/authorization/_inputs.py | pulumi-bot/pulumi-azure-native | f7b9490b5211544318e455e5cceafe47b628e12c | [
"Apache-2.0"
] | null | null | null | sdk/python/pulumi_azure_native/authorization/_inputs.py | pulumi-bot/pulumi-azure-native | f7b9490b5211544318e455e5cceafe47b628e12c | [
"Apache-2.0"
] | null | null | null | # coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** 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 ._enums import *
__all__ = [
'AccessReviewInstanceArgs',
'AccessReviewReviewerArgs',
'ApprovalSettingsArgs',
'ApprovalStageArgs',
'IdentityArgs',
'ManagementLockOwnerArgs',
'NonComplianceMessageArgs',
'ParameterDefinitionsValueArgs',
'ParameterDefinitionsValueMetadataArgs',
'ParameterValuesValueArgs',
'PermissionArgs',
'PolicyDefinitionGroupArgs',
'PolicyDefinitionReferenceArgs',
'PrincipalArgs',
'RoleManagementPolicyApprovalRuleArgs',
'RoleManagementPolicyAuthenticationContextRuleArgs',
'RoleManagementPolicyEnablementRuleArgs',
'RoleManagementPolicyExpirationRuleArgs',
'RoleManagementPolicyNotificationRuleArgs',
'RoleManagementPolicyRuleTargetArgs',
'SingleUserArgs',
]
@pulumi.input_type
class AccessReviewInstanceArgs:
def __init__(__self__, *,
end_date_time: Optional[pulumi.Input[str]] = None,
start_date_time: Optional[pulumi.Input[str]] = None):
"""
Access Review Instance.
:param pulumi.Input[str] end_date_time: The DateTime when the review instance is scheduled to end.
:param pulumi.Input[str] start_date_time: The DateTime when the review instance is scheduled to be start.
"""
if end_date_time is not None:
pulumi.set(__self__, "end_date_time", end_date_time)
if start_date_time is not None:
pulumi.set(__self__, "start_date_time", start_date_time)
@property
@pulumi.getter(name="endDateTime")
def end_date_time(self) -> Optional[pulumi.Input[str]]:
"""
The DateTime when the review instance is scheduled to end.
"""
return pulumi.get(self, "end_date_time")
@end_date_time.setter
def end_date_time(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "end_date_time", value)
@property
@pulumi.getter(name="startDateTime")
def start_date_time(self) -> Optional[pulumi.Input[str]]:
"""
The DateTime when the review instance is scheduled to be start.
"""
return pulumi.get(self, "start_date_time")
@start_date_time.setter
def start_date_time(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "start_date_time", value)
@pulumi.input_type
class AccessReviewReviewerArgs:
def __init__(__self__, *,
principal_id: Optional[pulumi.Input[str]] = None):
"""
Descriptor for what needs to be reviewed
:param pulumi.Input[str] principal_id: The id of the reviewer(user/servicePrincipal)
"""
if principal_id is not None:
pulumi.set(__self__, "principal_id", principal_id)
@property
@pulumi.getter(name="principalId")
def principal_id(self) -> Optional[pulumi.Input[str]]:
"""
The id of the reviewer(user/servicePrincipal)
"""
return pulumi.get(self, "principal_id")
@principal_id.setter
def principal_id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "principal_id", value)
@pulumi.input_type
class ApprovalSettingsArgs:
def __init__(__self__, *,
approval_mode: Optional[pulumi.Input[Union[str, 'ApprovalMode']]] = None,
approval_stages: Optional[pulumi.Input[Sequence[pulumi.Input['ApprovalStageArgs']]]] = None,
is_approval_required: Optional[pulumi.Input[bool]] = None,
is_approval_required_for_extension: Optional[pulumi.Input[bool]] = None,
is_requestor_justification_required: Optional[pulumi.Input[bool]] = None):
"""
The approval settings.
:param pulumi.Input[Union[str, 'ApprovalMode']] approval_mode: The type of rule
:param pulumi.Input[Sequence[pulumi.Input['ApprovalStageArgs']]] approval_stages: The approval stages of the request.
:param pulumi.Input[bool] is_approval_required: Determine whether approval is required or not.
:param pulumi.Input[bool] is_approval_required_for_extension: Determine whether approval is required for assignment extension.
:param pulumi.Input[bool] is_requestor_justification_required: Determine whether requestor justification required.
"""
if approval_mode is not None:
pulumi.set(__self__, "approval_mode", approval_mode)
if approval_stages is not None:
pulumi.set(__self__, "approval_stages", approval_stages)
if is_approval_required is not None:
pulumi.set(__self__, "is_approval_required", is_approval_required)
if is_approval_required_for_extension is not None:
pulumi.set(__self__, "is_approval_required_for_extension", is_approval_required_for_extension)
if is_requestor_justification_required is not None:
pulumi.set(__self__, "is_requestor_justification_required", is_requestor_justification_required)
@property
@pulumi.getter(name="approvalMode")
def approval_mode(self) -> Optional[pulumi.Input[Union[str, 'ApprovalMode']]]:
"""
The type of rule
"""
return pulumi.get(self, "approval_mode")
@approval_mode.setter
def approval_mode(self, value: Optional[pulumi.Input[Union[str, 'ApprovalMode']]]):
pulumi.set(self, "approval_mode", value)
@property
@pulumi.getter(name="approvalStages")
def approval_stages(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['ApprovalStageArgs']]]]:
"""
The approval stages of the request.
"""
return pulumi.get(self, "approval_stages")
@approval_stages.setter
def approval_stages(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['ApprovalStageArgs']]]]):
pulumi.set(self, "approval_stages", value)
@property
@pulumi.getter(name="isApprovalRequired")
def is_approval_required(self) -> Optional[pulumi.Input[bool]]:
"""
Determine whether approval is required or not.
"""
return pulumi.get(self, "is_approval_required")
@is_approval_required.setter
def is_approval_required(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "is_approval_required", value)
@property
@pulumi.getter(name="isApprovalRequiredForExtension")
def is_approval_required_for_extension(self) -> Optional[pulumi.Input[bool]]:
"""
Determine whether approval is required for assignment extension.
"""
return pulumi.get(self, "is_approval_required_for_extension")
@is_approval_required_for_extension.setter
def is_approval_required_for_extension(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "is_approval_required_for_extension", value)
@property
@pulumi.getter(name="isRequestorJustificationRequired")
def is_requestor_justification_required(self) -> Optional[pulumi.Input[bool]]:
"""
Determine whether requestor justification required.
"""
return pulumi.get(self, "is_requestor_justification_required")
@is_requestor_justification_required.setter
def is_requestor_justification_required(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "is_requestor_justification_required", value)
@pulumi.input_type
class ApprovalStageArgs:
def __init__(__self__, *,
approval_stage_time_out_in_days: Optional[pulumi.Input[int]] = None,
escalation_approvers: Optional[pulumi.Input[Sequence[pulumi.Input['SingleUserArgs']]]] = None,
escalation_time_in_minutes: Optional[pulumi.Input[int]] = None,
is_approver_justification_required: Optional[pulumi.Input[bool]] = None,
is_escalation_enabled: Optional[pulumi.Input[bool]] = None,
primary_approvers: Optional[pulumi.Input[Sequence[pulumi.Input['SingleUserArgs']]]] = None):
"""
The approval stage.
:param pulumi.Input[int] approval_stage_time_out_in_days: The time in days when approval request would be timed out.
:param pulumi.Input[Sequence[pulumi.Input['SingleUserArgs']]] escalation_approvers: The escalation approver of the request.
:param pulumi.Input[int] escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approves.
:param pulumi.Input[bool] is_approver_justification_required: Determine whether approver need to provide justification for his decision.
:param pulumi.Input[bool] is_escalation_enabled: The value determine whether escalation feature is enabled.
:param pulumi.Input[Sequence[pulumi.Input['SingleUserArgs']]] primary_approvers: The primary approver of the request.
"""
if approval_stage_time_out_in_days is not None:
pulumi.set(__self__, "approval_stage_time_out_in_days", approval_stage_time_out_in_days)
if escalation_approvers is not None:
pulumi.set(__self__, "escalation_approvers", escalation_approvers)
if escalation_time_in_minutes is not None:
pulumi.set(__self__, "escalation_time_in_minutes", escalation_time_in_minutes)
if is_approver_justification_required is not None:
pulumi.set(__self__, "is_approver_justification_required", is_approver_justification_required)
if is_escalation_enabled is not None:
pulumi.set(__self__, "is_escalation_enabled", is_escalation_enabled)
if primary_approvers is not None:
pulumi.set(__self__, "primary_approvers", primary_approvers)
@property
@pulumi.getter(name="approvalStageTimeOutInDays")
def approval_stage_time_out_in_days(self) -> Optional[pulumi.Input[int]]:
"""
The time in days when approval request would be timed out.
"""
return pulumi.get(self, "approval_stage_time_out_in_days")
@approval_stage_time_out_in_days.setter
def approval_stage_time_out_in_days(self, value: Optional[pulumi.Input[int]]):
pulumi.set(self, "approval_stage_time_out_in_days", value)
@property
@pulumi.getter(name="escalationApprovers")
def escalation_approvers(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['SingleUserArgs']]]]:
"""
The escalation approver of the request.
"""
return pulumi.get(self, "escalation_approvers")
@escalation_approvers.setter
def escalation_approvers(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['SingleUserArgs']]]]):
pulumi.set(self, "escalation_approvers", value)
@property
@pulumi.getter(name="escalationTimeInMinutes")
def escalation_time_in_minutes(self) -> Optional[pulumi.Input[int]]:
"""
The time in minutes when the approval request would be escalated if the primary approver does not approves.
"""
return pulumi.get(self, "escalation_time_in_minutes")
@escalation_time_in_minutes.setter
def escalation_time_in_minutes(self, value: Optional[pulumi.Input[int]]):
pulumi.set(self, "escalation_time_in_minutes", value)
@property
@pulumi.getter(name="isApproverJustificationRequired")
def is_approver_justification_required(self) -> Optional[pulumi.Input[bool]]:
"""
Determine whether approver need to provide justification for his decision.
"""
return pulumi.get(self, "is_approver_justification_required")
@is_approver_justification_required.setter
def is_approver_justification_required(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "is_approver_justification_required", value)
@property
@pulumi.getter(name="isEscalationEnabled")
def is_escalation_enabled(self) -> Optional[pulumi.Input[bool]]:
"""
The value determine whether escalation feature is enabled.
"""
return pulumi.get(self, "is_escalation_enabled")
@is_escalation_enabled.setter
def is_escalation_enabled(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "is_escalation_enabled", value)
@property
@pulumi.getter(name="primaryApprovers")
def primary_approvers(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['SingleUserArgs']]]]:
"""
The primary approver of the request.
"""
return pulumi.get(self, "primary_approvers")
@primary_approvers.setter
def primary_approvers(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['SingleUserArgs']]]]):
pulumi.set(self, "primary_approvers", value)
@pulumi.input_type
class IdentityArgs:
def __init__(__self__, *,
type: Optional[pulumi.Input['ResourceIdentityType']] = None):
"""
Identity for the resource.
:param pulumi.Input['ResourceIdentityType'] type: The identity type. This is the only required field when adding a system assigned identity to a resource.
"""
if type is not None:
pulumi.set(__self__, "type", type)
@property
@pulumi.getter
def type(self) -> Optional[pulumi.Input['ResourceIdentityType']]:
"""
The identity type. This is the only required field when adding a system assigned identity to a resource.
"""
return pulumi.get(self, "type")
@type.setter
def type(self, value: Optional[pulumi.Input['ResourceIdentityType']]):
pulumi.set(self, "type", value)
@pulumi.input_type
class ManagementLockOwnerArgs:
def __init__(__self__, *,
application_id: Optional[pulumi.Input[str]] = None):
"""
Lock owner properties.
:param pulumi.Input[str] application_id: The application ID of the lock owner.
"""
if application_id is not None:
pulumi.set(__self__, "application_id", application_id)
@property
@pulumi.getter(name="applicationId")
def application_id(self) -> Optional[pulumi.Input[str]]:
"""
The application ID of the lock owner.
"""
return pulumi.get(self, "application_id")
@application_id.setter
def application_id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "application_id", value)
@pulumi.input_type
class NonComplianceMessageArgs:
def __init__(__self__, *,
message: pulumi.Input[str],
policy_definition_reference_id: Optional[pulumi.Input[str]] = None):
"""
A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results.
:param pulumi.Input[str] message: A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results.
:param pulumi.Input[str] policy_definition_reference_id: The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment assigns a policy set definition. If this is not provided the message applies to all policies assigned by this policy assignment.
"""
pulumi.set(__self__, "message", message)
if policy_definition_reference_id is not None:
pulumi.set(__self__, "policy_definition_reference_id", policy_definition_reference_id)
@property
@pulumi.getter
def message(self) -> pulumi.Input[str]:
"""
A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results.
"""
return pulumi.get(self, "message")
@message.setter
def message(self, value: pulumi.Input[str]):
pulumi.set(self, "message", value)
@property
@pulumi.getter(name="policyDefinitionReferenceId")
def policy_definition_reference_id(self) -> Optional[pulumi.Input[str]]:
"""
The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment assigns a policy set definition. If this is not provided the message applies to all policies assigned by this policy assignment.
"""
return pulumi.get(self, "policy_definition_reference_id")
@policy_definition_reference_id.setter
def policy_definition_reference_id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "policy_definition_reference_id", value)
@pulumi.input_type
class ParameterDefinitionsValueArgs:
def __init__(__self__, *,
allowed_values: Optional[pulumi.Input[Sequence[Any]]] = None,
default_value: Optional[Any] = None,
metadata: Optional[pulumi.Input['ParameterDefinitionsValueMetadataArgs']] = None,
type: Optional[pulumi.Input[Union[str, 'ParameterType']]] = None):
"""
The definition of a parameter that can be provided to the policy.
:param pulumi.Input[Sequence[Any]] allowed_values: The allowed values for the parameter.
:param Any default_value: The default value for the parameter if no value is provided.
:param pulumi.Input['ParameterDefinitionsValueMetadataArgs'] metadata: General metadata for the parameter.
:param pulumi.Input[Union[str, 'ParameterType']] type: The data type of the parameter.
"""
if allowed_values is not None:
pulumi.set(__self__, "allowed_values", allowed_values)
if default_value is not None:
pulumi.set(__self__, "default_value", default_value)
if metadata is not None:
pulumi.set(__self__, "metadata", metadata)
if type is not None:
pulumi.set(__self__, "type", type)
@property
@pulumi.getter(name="allowedValues")
def allowed_values(self) -> Optional[pulumi.Input[Sequence[Any]]]:
"""
The allowed values for the parameter.
"""
return pulumi.get(self, "allowed_values")
@allowed_values.setter
def allowed_values(self, value: Optional[pulumi.Input[Sequence[Any]]]):
pulumi.set(self, "allowed_values", value)
@property
@pulumi.getter(name="defaultValue")
def default_value(self) -> Optional[Any]:
"""
The default value for the parameter if no value is provided.
"""
return pulumi.get(self, "default_value")
@default_value.setter
def default_value(self, value: Optional[Any]):
pulumi.set(self, "default_value", value)
@property
@pulumi.getter
def metadata(self) -> Optional[pulumi.Input['ParameterDefinitionsValueMetadataArgs']]:
"""
General metadata for the parameter.
"""
return pulumi.get(self, "metadata")
@metadata.setter
def metadata(self, value: Optional[pulumi.Input['ParameterDefinitionsValueMetadataArgs']]):
pulumi.set(self, "metadata", value)
@property
@pulumi.getter
def type(self) -> Optional[pulumi.Input[Union[str, 'ParameterType']]]:
"""
The data type of the parameter.
"""
return pulumi.get(self, "type")
@type.setter
def type(self, value: Optional[pulumi.Input[Union[str, 'ParameterType']]]):
pulumi.set(self, "type", value)
@pulumi.input_type
class ParameterDefinitionsValueMetadataArgs:
def __init__(__self__, *,
assign_permissions: Optional[pulumi.Input[bool]] = None,
description: Optional[pulumi.Input[str]] = None,
display_name: Optional[pulumi.Input[str]] = None,
strong_type: Optional[pulumi.Input[str]] = None):
"""
General metadata for the parameter.
:param pulumi.Input[bool] assign_permissions: Set to true to have Azure portal create role assignments on the resource ID or resource scope value of this parameter during policy assignment. This property is useful in case you wish to assign permissions outside the assignment scope.
:param pulumi.Input[str] description: The description of the parameter.
:param pulumi.Input[str] display_name: The display name for the parameter.
:param pulumi.Input[str] strong_type: Used when assigning the policy definition through the portal. Provides a context aware list of values for the user to choose from.
"""
if assign_permissions is not None:
pulumi.set(__self__, "assign_permissions", assign_permissions)
if description is not None:
pulumi.set(__self__, "description", description)
if display_name is not None:
pulumi.set(__self__, "display_name", display_name)
if strong_type is not None:
pulumi.set(__self__, "strong_type", strong_type)
@property
@pulumi.getter(name="assignPermissions")
def assign_permissions(self) -> Optional[pulumi.Input[bool]]:
"""
Set to true to have Azure portal create role assignments on the resource ID or resource scope value of this parameter during policy assignment. This property is useful in case you wish to assign permissions outside the assignment scope.
"""
return pulumi.get(self, "assign_permissions")
@assign_permissions.setter
def assign_permissions(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "assign_permissions", value)
@property
@pulumi.getter
def description(self) -> Optional[pulumi.Input[str]]:
"""
The description of the parameter.
"""
return pulumi.get(self, "description")
@description.setter
def description(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "description", value)
@property
@pulumi.getter(name="displayName")
def display_name(self) -> Optional[pulumi.Input[str]]:
"""
The display name for the parameter.
"""
return pulumi.get(self, "display_name")
@display_name.setter
def display_name(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "display_name", value)
@property
@pulumi.getter(name="strongType")
def strong_type(self) -> Optional[pulumi.Input[str]]:
"""
Used when assigning the policy definition through the portal. Provides a context aware list of values for the user to choose from.
"""
return pulumi.get(self, "strong_type")
@strong_type.setter
def strong_type(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "strong_type", value)
@pulumi.input_type
class ParameterValuesValueArgs:
def __init__(__self__, *,
value: Optional[Any] = None):
"""
The value of a parameter.
:param Any value: The value of the parameter.
"""
if value is not None:
pulumi.set(__self__, "value", value)
@property
@pulumi.getter
def value(self) -> Optional[Any]:
"""
The value of the parameter.
"""
return pulumi.get(self, "value")
@value.setter
def value(self, value: Optional[Any]):
pulumi.set(self, "value", value)
@pulumi.input_type
class PermissionArgs:
def __init__(__self__, *,
actions: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
data_actions: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
not_actions: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
not_data_actions: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None):
"""
Role definition permissions.
:param pulumi.Input[Sequence[pulumi.Input[str]]] actions: Allowed actions.
:param pulumi.Input[Sequence[pulumi.Input[str]]] data_actions: Allowed Data actions.
:param pulumi.Input[Sequence[pulumi.Input[str]]] not_actions: Denied actions.
:param pulumi.Input[Sequence[pulumi.Input[str]]] not_data_actions: Denied Data actions.
"""
if actions is not None:
pulumi.set(__self__, "actions", actions)
if data_actions is not None:
pulumi.set(__self__, "data_actions", data_actions)
if not_actions is not None:
pulumi.set(__self__, "not_actions", not_actions)
if not_data_actions is not None:
pulumi.set(__self__, "not_data_actions", not_data_actions)
@property
@pulumi.getter
def actions(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
"""
Allowed actions.
"""
return pulumi.get(self, "actions")
@actions.setter
def actions(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
pulumi.set(self, "actions", value)
@property
@pulumi.getter(name="dataActions")
def data_actions(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
"""
Allowed Data actions.
"""
return pulumi.get(self, "data_actions")
@data_actions.setter
def data_actions(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
pulumi.set(self, "data_actions", value)
@property
@pulumi.getter(name="notActions")
def not_actions(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
"""
Denied actions.
"""
return pulumi.get(self, "not_actions")
@not_actions.setter
def not_actions(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
pulumi.set(self, "not_actions", value)
@property
@pulumi.getter(name="notDataActions")
def not_data_actions(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
"""
Denied Data actions.
"""
return pulumi.get(self, "not_data_actions")
@not_data_actions.setter
def not_data_actions(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
pulumi.set(self, "not_data_actions", value)
@pulumi.input_type
class PolicyDefinitionGroupArgs:
def __init__(__self__, *,
name: pulumi.Input[str],
additional_metadata_id: Optional[pulumi.Input[str]] = None,
category: Optional[pulumi.Input[str]] = None,
description: Optional[pulumi.Input[str]] = None,
display_name: Optional[pulumi.Input[str]] = None):
"""
The policy definition group.
:param pulumi.Input[str] name: The name of the group.
:param pulumi.Input[str] additional_metadata_id: A resource ID of a resource that contains additional metadata about the group.
:param pulumi.Input[str] category: The group's category.
:param pulumi.Input[str] description: The group's description.
:param pulumi.Input[str] display_name: The group's display name.
"""
pulumi.set(__self__, "name", name)
if additional_metadata_id is not None:
pulumi.set(__self__, "additional_metadata_id", additional_metadata_id)
if category is not None:
pulumi.set(__self__, "category", category)
if description is not None:
pulumi.set(__self__, "description", description)
if display_name is not None:
pulumi.set(__self__, "display_name", display_name)
@property
@pulumi.getter
def name(self) -> pulumi.Input[str]:
"""
The name of the group.
"""
return pulumi.get(self, "name")
@name.setter
def name(self, value: pulumi.Input[str]):
pulumi.set(self, "name", value)
@property
@pulumi.getter(name="additionalMetadataId")
def additional_metadata_id(self) -> Optional[pulumi.Input[str]]:
"""
A resource ID of a resource that contains additional metadata about the group.
"""
return pulumi.get(self, "additional_metadata_id")
@additional_metadata_id.setter
def additional_metadata_id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "additional_metadata_id", value)
@property
@pulumi.getter
def category(self) -> Optional[pulumi.Input[str]]:
"""
The group's category.
"""
return pulumi.get(self, "category")
@category.setter
def category(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "category", value)
@property
@pulumi.getter
def description(self) -> Optional[pulumi.Input[str]]:
"""
The group's description.
"""
return pulumi.get(self, "description")
@description.setter
def description(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "description", value)
@property
@pulumi.getter(name="displayName")
def display_name(self) -> Optional[pulumi.Input[str]]:
"""
The group's display name.
"""
return pulumi.get(self, "display_name")
@display_name.setter
def display_name(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "display_name", value)
@pulumi.input_type
class PolicyDefinitionReferenceArgs:
def __init__(__self__, *,
policy_definition_id: pulumi.Input[str],
group_names: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
parameters: Optional[pulumi.Input[Mapping[str, pulumi.Input['ParameterValuesValueArgs']]]] = None,
policy_definition_reference_id: Optional[pulumi.Input[str]] = None):
"""
The policy definition reference.
:param pulumi.Input[str] policy_definition_id: The ID of the policy definition or policy set definition.
:param pulumi.Input[Sequence[pulumi.Input[str]]] group_names: The name of the groups that this policy definition reference belongs to.
:param pulumi.Input[Mapping[str, pulumi.Input['ParameterValuesValueArgs']]] parameters: The parameter values for the referenced policy rule. The keys are the parameter names.
:param pulumi.Input[str] policy_definition_reference_id: A unique id (within the policy set definition) for this policy definition reference.
"""
pulumi.set(__self__, "policy_definition_id", policy_definition_id)
if group_names is not None:
pulumi.set(__self__, "group_names", group_names)
if parameters is not None:
pulumi.set(__self__, "parameters", parameters)
if policy_definition_reference_id is not None:
pulumi.set(__self__, "policy_definition_reference_id", policy_definition_reference_id)
@property
@pulumi.getter(name="policyDefinitionId")
def policy_definition_id(self) -> pulumi.Input[str]:
"""
The ID of the policy definition or policy set definition.
"""
return pulumi.get(self, "policy_definition_id")
@policy_definition_id.setter
def policy_definition_id(self, value: pulumi.Input[str]):
pulumi.set(self, "policy_definition_id", value)
@property
@pulumi.getter(name="groupNames")
def group_names(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
"""
The name of the groups that this policy definition reference belongs to.
"""
return pulumi.get(self, "group_names")
@group_names.setter
def group_names(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
pulumi.set(self, "group_names", value)
@property
@pulumi.getter
def parameters(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input['ParameterValuesValueArgs']]]]:
"""
The parameter values for the referenced policy rule. The keys are the parameter names.
"""
return pulumi.get(self, "parameters")
@parameters.setter
def parameters(self, value: Optional[pulumi.Input[Mapping[str, pulumi.Input['ParameterValuesValueArgs']]]]):
pulumi.set(self, "parameters", value)
@property
@pulumi.getter(name="policyDefinitionReferenceId")
def policy_definition_reference_id(self) -> Optional[pulumi.Input[str]]:
"""
A unique id (within the policy set definition) for this policy definition reference.
"""
return pulumi.get(self, "policy_definition_reference_id")
@policy_definition_reference_id.setter
def policy_definition_reference_id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "policy_definition_reference_id", value)
@pulumi.input_type
class PrincipalArgs:
def __init__(__self__, *,
id: Optional[pulumi.Input[str]] = None,
type: Optional[pulumi.Input[str]] = None):
"""
Deny assignment principal.
:param pulumi.Input[str] id: Object ID of the Azure AD principal (user, group, or service principal) to which the deny assignment applies. An empty guid '00000000-0000-0000-0000-000000000000' as principal id and principal type as 'Everyone' represents all users, groups and service principals.
:param pulumi.Input[str] type: Type of object represented by principal id (user, group, or service principal). An empty guid '00000000-0000-0000-0000-000000000000' as principal id and principal type as 'Everyone' represents all users, groups and service principals.
"""
if id is not None:
pulumi.set(__self__, "id", id)
if type is not None:
pulumi.set(__self__, "type", type)
@property
@pulumi.getter
def id(self) -> Optional[pulumi.Input[str]]:
"""
Object ID of the Azure AD principal (user, group, or service principal) to which the deny assignment applies. An empty guid '00000000-0000-0000-0000-000000000000' as principal id and principal type as 'Everyone' represents all users, groups and service principals.
"""
return pulumi.get(self, "id")
@id.setter
def id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "id", value)
@property
@pulumi.getter
def type(self) -> Optional[pulumi.Input[str]]:
"""
Type of object represented by principal id (user, group, or service principal). An empty guid '00000000-0000-0000-0000-000000000000' as principal id and principal type as 'Everyone' represents all users, groups and service principals.
"""
return pulumi.get(self, "type")
@type.setter
def type(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "type", value)
@pulumi.input_type
class RoleManagementPolicyApprovalRuleArgs:
def __init__(__self__, *,
rule_type: pulumi.Input[str],
id: Optional[pulumi.Input[str]] = None,
setting: Optional[pulumi.Input['ApprovalSettingsArgs']] = None,
target: Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']] = None):
"""
The role management policy rule.
:param pulumi.Input[str] rule_type: The type of rule
Expected value is 'RoleManagementPolicyApprovalRule'.
:param pulumi.Input[str] id: The id of the rule.
:param pulumi.Input['ApprovalSettingsArgs'] setting: The approval setting
:param pulumi.Input['RoleManagementPolicyRuleTargetArgs'] target: The target of the current rule.
"""
pulumi.set(__self__, "rule_type", 'RoleManagementPolicyApprovalRule')
if id is not None:
pulumi.set(__self__, "id", id)
if setting is not None:
pulumi.set(__self__, "setting", setting)
if target is not None:
pulumi.set(__self__, "target", target)
@property
@pulumi.getter(name="ruleType")
def rule_type(self) -> pulumi.Input[str]:
"""
The type of rule
Expected value is 'RoleManagementPolicyApprovalRule'.
"""
return pulumi.get(self, "rule_type")
@rule_type.setter
def rule_type(self, value: pulumi.Input[str]):
pulumi.set(self, "rule_type", value)
@property
@pulumi.getter
def id(self) -> Optional[pulumi.Input[str]]:
"""
The id of the rule.
"""
return pulumi.get(self, "id")
@id.setter
def id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "id", value)
@property
@pulumi.getter
def setting(self) -> Optional[pulumi.Input['ApprovalSettingsArgs']]:
"""
The approval setting
"""
return pulumi.get(self, "setting")
@setting.setter
def setting(self, value: Optional[pulumi.Input['ApprovalSettingsArgs']]):
pulumi.set(self, "setting", value)
@property
@pulumi.getter
def target(self) -> Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']]:
"""
The target of the current rule.
"""
return pulumi.get(self, "target")
@target.setter
def target(self, value: Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']]):
pulumi.set(self, "target", value)
@pulumi.input_type
class RoleManagementPolicyAuthenticationContextRuleArgs:
def __init__(__self__, *,
rule_type: pulumi.Input[str],
claim_value: Optional[pulumi.Input[str]] = None,
id: Optional[pulumi.Input[str]] = None,
is_enabled: Optional[pulumi.Input[bool]] = None,
target: Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']] = None):
"""
The role management policy rule.
:param pulumi.Input[str] rule_type: The type of rule
Expected value is 'RoleManagementPolicyAuthenticationContextRule'.
:param pulumi.Input[str] claim_value: The claim value.
:param pulumi.Input[str] id: The id of the rule.
:param pulumi.Input[bool] is_enabled: The value indicating if rule is enabled.
:param pulumi.Input['RoleManagementPolicyRuleTargetArgs'] target: The target of the current rule.
"""
pulumi.set(__self__, "rule_type", 'RoleManagementPolicyAuthenticationContextRule')
if claim_value is not None:
pulumi.set(__self__, "claim_value", claim_value)
if id is not None:
pulumi.set(__self__, "id", id)
if is_enabled is not None:
pulumi.set(__self__, "is_enabled", is_enabled)
if target is not None:
pulumi.set(__self__, "target", target)
@property
@pulumi.getter(name="ruleType")
def rule_type(self) -> pulumi.Input[str]:
"""
The type of rule
Expected value is 'RoleManagementPolicyAuthenticationContextRule'.
"""
return pulumi.get(self, "rule_type")
@rule_type.setter
def rule_type(self, value: pulumi.Input[str]):
pulumi.set(self, "rule_type", value)
@property
@pulumi.getter(name="claimValue")
def claim_value(self) -> Optional[pulumi.Input[str]]:
"""
The claim value.
"""
return pulumi.get(self, "claim_value")
@claim_value.setter
def claim_value(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "claim_value", value)
@property
@pulumi.getter
def id(self) -> Optional[pulumi.Input[str]]:
"""
The id of the rule.
"""
return pulumi.get(self, "id")
@id.setter
def id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "id", value)
@property
@pulumi.getter(name="isEnabled")
def is_enabled(self) -> Optional[pulumi.Input[bool]]:
"""
The value indicating if rule is enabled.
"""
return pulumi.get(self, "is_enabled")
@is_enabled.setter
def is_enabled(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "is_enabled", value)
@property
@pulumi.getter
def target(self) -> Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']]:
"""
The target of the current rule.
"""
return pulumi.get(self, "target")
@target.setter
def target(self, value: Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']]):
pulumi.set(self, "target", value)
@pulumi.input_type
class RoleManagementPolicyEnablementRuleArgs:
def __init__(__self__, *,
rule_type: pulumi.Input[str],
enabled_rules: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
id: Optional[pulumi.Input[str]] = None,
target: Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']] = None):
"""
The role management policy rule.
:param pulumi.Input[str] rule_type: The type of rule
Expected value is 'RoleManagementPolicyEnablementRule'.
:param pulumi.Input[Sequence[pulumi.Input[str]]] enabled_rules: The list of enabled rules.
:param pulumi.Input[str] id: The id of the rule.
:param pulumi.Input['RoleManagementPolicyRuleTargetArgs'] target: The target of the current rule.
"""
pulumi.set(__self__, "rule_type", 'RoleManagementPolicyEnablementRule')
if enabled_rules is not None:
pulumi.set(__self__, "enabled_rules", enabled_rules)
if id is not None:
pulumi.set(__self__, "id", id)
if target is not None:
pulumi.set(__self__, "target", target)
@property
@pulumi.getter(name="ruleType")
def rule_type(self) -> pulumi.Input[str]:
"""
The type of rule
Expected value is 'RoleManagementPolicyEnablementRule'.
"""
return pulumi.get(self, "rule_type")
@rule_type.setter
def rule_type(self, value: pulumi.Input[str]):
pulumi.set(self, "rule_type", value)
@property
@pulumi.getter(name="enabledRules")
def enabled_rules(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
"""
The list of enabled rules.
"""
return pulumi.get(self, "enabled_rules")
@enabled_rules.setter
def enabled_rules(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
pulumi.set(self, "enabled_rules", value)
@property
@pulumi.getter
def id(self) -> Optional[pulumi.Input[str]]:
"""
The id of the rule.
"""
return pulumi.get(self, "id")
@id.setter
def id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "id", value)
@property
@pulumi.getter
def target(self) -> Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']]:
"""
The target of the current rule.
"""
return pulumi.get(self, "target")
@target.setter
def target(self, value: Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']]):
pulumi.set(self, "target", value)
@pulumi.input_type
class RoleManagementPolicyExpirationRuleArgs:
def __init__(__self__, *,
rule_type: pulumi.Input[str],
id: Optional[pulumi.Input[str]] = None,
is_expiration_required: Optional[pulumi.Input[bool]] = None,
maximum_duration: Optional[pulumi.Input[str]] = None,
target: Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']] = None):
"""
The role management policy rule.
:param pulumi.Input[str] rule_type: The type of rule
Expected value is 'RoleManagementPolicyExpirationRule'.
:param pulumi.Input[str] id: The id of the rule.
:param pulumi.Input[bool] is_expiration_required: The value indicating whether expiration is required.
:param pulumi.Input[str] maximum_duration: The maximum duration of expiration in timespan.
:param pulumi.Input['RoleManagementPolicyRuleTargetArgs'] target: The target of the current rule.
"""
pulumi.set(__self__, "rule_type", 'RoleManagementPolicyExpirationRule')
if id is not None:
pulumi.set(__self__, "id", id)
if is_expiration_required is not None:
pulumi.set(__self__, "is_expiration_required", is_expiration_required)
if maximum_duration is not None:
pulumi.set(__self__, "maximum_duration", maximum_duration)
if target is not None:
pulumi.set(__self__, "target", target)
@property
@pulumi.getter(name="ruleType")
def rule_type(self) -> pulumi.Input[str]:
"""
The type of rule
Expected value is 'RoleManagementPolicyExpirationRule'.
"""
return pulumi.get(self, "rule_type")
@rule_type.setter
def rule_type(self, value: pulumi.Input[str]):
pulumi.set(self, "rule_type", value)
@property
@pulumi.getter
def id(self) -> Optional[pulumi.Input[str]]:
"""
The id of the rule.
"""
return pulumi.get(self, "id")
@id.setter
def id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "id", value)
@property
@pulumi.getter(name="isExpirationRequired")
def is_expiration_required(self) -> Optional[pulumi.Input[bool]]:
"""
The value indicating whether expiration is required.
"""
return pulumi.get(self, "is_expiration_required")
@is_expiration_required.setter
def is_expiration_required(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "is_expiration_required", value)
@property
@pulumi.getter(name="maximumDuration")
def maximum_duration(self) -> Optional[pulumi.Input[str]]:
"""
The maximum duration of expiration in timespan.
"""
return pulumi.get(self, "maximum_duration")
@maximum_duration.setter
def maximum_duration(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "maximum_duration", value)
@property
@pulumi.getter
def target(self) -> Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']]:
"""
The target of the current rule.
"""
return pulumi.get(self, "target")
@target.setter
def target(self, value: Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']]):
pulumi.set(self, "target", value)
@pulumi.input_type
class RoleManagementPolicyNotificationRuleArgs:
def __init__(__self__, *,
rule_type: pulumi.Input[str],
id: Optional[pulumi.Input[str]] = None,
notification_level: Optional[pulumi.Input[Union[str, 'NotificationLevel']]] = None,
notification_recipients: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
notification_type: Optional[pulumi.Input[Union[str, 'NotificationDeliveryMechanism']]] = None,
recipient_type: Optional[pulumi.Input[Union[str, 'RecipientType']]] = None,
target: Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']] = None):
"""
The role management policy rule.
:param pulumi.Input[str] rule_type: The type of rule
Expected value is 'RoleManagementPolicyNotificationRule'.
:param pulumi.Input[str] id: The id of the rule.
:param pulumi.Input[Union[str, 'NotificationLevel']] notification_level: The notification level.
:param pulumi.Input[Sequence[pulumi.Input[str]]] notification_recipients: The list notification recipients.
:param pulumi.Input[Union[str, 'NotificationDeliveryMechanism']] notification_type: The type of notification.
:param pulumi.Input[Union[str, 'RecipientType']] recipient_type: The recipient type.
:param pulumi.Input['RoleManagementPolicyRuleTargetArgs'] target: The target of the current rule.
"""
pulumi.set(__self__, "rule_type", 'RoleManagementPolicyNotificationRule')
if id is not None:
pulumi.set(__self__, "id", id)
if notification_level is not None:
pulumi.set(__self__, "notification_level", notification_level)
if notification_recipients is not None:
pulumi.set(__self__, "notification_recipients", notification_recipients)
if notification_type is not None:
pulumi.set(__self__, "notification_type", notification_type)
if recipient_type is not None:
pulumi.set(__self__, "recipient_type", recipient_type)
if target is not None:
pulumi.set(__self__, "target", target)
@property
@pulumi.getter(name="ruleType")
def rule_type(self) -> pulumi.Input[str]:
"""
The type of rule
Expected value is 'RoleManagementPolicyNotificationRule'.
"""
return pulumi.get(self, "rule_type")
@rule_type.setter
def rule_type(self, value: pulumi.Input[str]):
pulumi.set(self, "rule_type", value)
@property
@pulumi.getter
def id(self) -> Optional[pulumi.Input[str]]:
"""
The id of the rule.
"""
return pulumi.get(self, "id")
@id.setter
def id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "id", value)
@property
@pulumi.getter(name="notificationLevel")
def notification_level(self) -> Optional[pulumi.Input[Union[str, 'NotificationLevel']]]:
"""
The notification level.
"""
return pulumi.get(self, "notification_level")
@notification_level.setter
def notification_level(self, value: Optional[pulumi.Input[Union[str, 'NotificationLevel']]]):
pulumi.set(self, "notification_level", value)
@property
@pulumi.getter(name="notificationRecipients")
def notification_recipients(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
"""
The list notification recipients.
"""
return pulumi.get(self, "notification_recipients")
@notification_recipients.setter
def notification_recipients(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
pulumi.set(self, "notification_recipients", value)
@property
@pulumi.getter(name="notificationType")
def notification_type(self) -> Optional[pulumi.Input[Union[str, 'NotificationDeliveryMechanism']]]:
"""
The type of notification.
"""
return pulumi.get(self, "notification_type")
@notification_type.setter
def notification_type(self, value: Optional[pulumi.Input[Union[str, 'NotificationDeliveryMechanism']]]):
pulumi.set(self, "notification_type", value)
@property
@pulumi.getter(name="recipientType")
def recipient_type(self) -> Optional[pulumi.Input[Union[str, 'RecipientType']]]:
"""
The recipient type.
"""
return pulumi.get(self, "recipient_type")
@recipient_type.setter
def recipient_type(self, value: Optional[pulumi.Input[Union[str, 'RecipientType']]]):
pulumi.set(self, "recipient_type", value)
@property
@pulumi.getter
def target(self) -> Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']]:
"""
The target of the current rule.
"""
return pulumi.get(self, "target")
@target.setter
def target(self, value: Optional[pulumi.Input['RoleManagementPolicyRuleTargetArgs']]):
pulumi.set(self, "target", value)
@pulumi.input_type
class RoleManagementPolicyRuleTargetArgs:
def __init__(__self__, *,
caller: Optional[pulumi.Input[str]] = None,
enforced_settings: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
inheritable_settings: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
level: Optional[pulumi.Input[str]] = None,
operations: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
target_objects: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None):
"""
The role management policy rule target.
:param pulumi.Input[str] caller: The caller of the setting.
:param pulumi.Input[Sequence[pulumi.Input[str]]] enforced_settings: The list of enforced settings.
:param pulumi.Input[Sequence[pulumi.Input[str]]] inheritable_settings: The list of inheritable settings.
:param pulumi.Input[str] level: The assignment level to which it is applied.
:param pulumi.Input[Sequence[pulumi.Input[str]]] operations: The type of operation.
:param pulumi.Input[Sequence[pulumi.Input[str]]] target_objects: The list of target objects.
"""
if caller is not None:
pulumi.set(__self__, "caller", caller)
if enforced_settings is not None:
pulumi.set(__self__, "enforced_settings", enforced_settings)
if inheritable_settings is not None:
pulumi.set(__self__, "inheritable_settings", inheritable_settings)
if level is not None:
pulumi.set(__self__, "level", level)
if operations is not None:
pulumi.set(__self__, "operations", operations)
if target_objects is not None:
pulumi.set(__self__, "target_objects", target_objects)
@property
@pulumi.getter
def caller(self) -> Optional[pulumi.Input[str]]:
"""
The caller of the setting.
"""
return pulumi.get(self, "caller")
@caller.setter
def caller(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "caller", value)
@property
@pulumi.getter(name="enforcedSettings")
def enforced_settings(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
"""
The list of enforced settings.
"""
return pulumi.get(self, "enforced_settings")
@enforced_settings.setter
def enforced_settings(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
pulumi.set(self, "enforced_settings", value)
@property
@pulumi.getter(name="inheritableSettings")
def inheritable_settings(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
"""
The list of inheritable settings.
"""
return pulumi.get(self, "inheritable_settings")
@inheritable_settings.setter
def inheritable_settings(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
pulumi.set(self, "inheritable_settings", value)
@property
@pulumi.getter
def level(self) -> Optional[pulumi.Input[str]]:
"""
The assignment level to which it is applied.
"""
return pulumi.get(self, "level")
@level.setter
def level(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "level", value)
@property
@pulumi.getter
def operations(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
"""
The type of operation.
"""
return pulumi.get(self, "operations")
@operations.setter
def operations(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
pulumi.set(self, "operations", value)
@property
@pulumi.getter(name="targetObjects")
def target_objects(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
"""
The list of target objects.
"""
return pulumi.get(self, "target_objects")
@target_objects.setter
def target_objects(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
pulumi.set(self, "target_objects", value)
@pulumi.input_type
class SingleUserArgs:
def __init__(__self__, *,
user_type: pulumi.Input[str],
description: Optional[pulumi.Input[str]] = None,
id: Optional[pulumi.Input[str]] = None,
is_backup: Optional[pulumi.Input[bool]] = None):
"""
The detail of a user.
:param pulumi.Input[str] user_type: The object id of the user.
Expected value is 'SingleUser'.
:param pulumi.Input[str] description: The description of the user.
:param pulumi.Input[str] id: The object id of the user.
:param pulumi.Input[bool] is_backup: The value indicating whether the user is a backup fallback approver
"""
pulumi.set(__self__, "user_type", 'SingleUser')
if description is not None:
pulumi.set(__self__, "description", description)
if id is not None:
pulumi.set(__self__, "id", id)
if is_backup is not None:
pulumi.set(__self__, "is_backup", is_backup)
@property
@pulumi.getter(name="userType")
def user_type(self) -> pulumi.Input[str]:
"""
The object id of the user.
Expected value is 'SingleUser'.
"""
return pulumi.get(self, "user_type")
@user_type.setter
def user_type(self, value: pulumi.Input[str]):
pulumi.set(self, "user_type", value)
@property
@pulumi.getter
def description(self) -> Optional[pulumi.Input[str]]:
"""
The description of the user.
"""
return pulumi.get(self, "description")
@description.setter
def description(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "description", value)
@property
@pulumi.getter
def id(self) -> Optional[pulumi.Input[str]]:
"""
The object id of the user.
"""
return pulumi.get(self, "id")
@id.setter
def id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "id", value)
@property
@pulumi.getter(name="isBackup")
def is_backup(self) -> Optional[pulumi.Input[bool]]:
"""
The value indicating whether the user is a backup fallback approver
"""
return pulumi.get(self, "is_backup")
@is_backup.setter
def is_backup(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "is_backup", value)
| 40.299514 | 337 | 0.661413 | 6,613 | 57,991 | 5.615606 | 0.048087 | 0.112855 | 0.101303 | 0.046209 | 0.807626 | 0.695013 | 0.618968 | 0.533795 | 0.47283 | 0.419647 | 0 | 0.002885 | 0.229018 | 57,991 | 1,438 | 338 | 40.327538 | 0.827712 | 0.233709 | 0 | 0.412661 | 1 | 0 | 0.135529 | 0.062146 | 0 | 0 | 0 | 0 | 0 | 1 | 0.205158 | false | 0 | 0.007034 | 0 | 0.327081 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
25cbf82d8e24defe0542ab18359903f5848dcdc1 | 538 | py | Python | flatdata-py/generator/tree/nodes/trivial/enumeration_value.py | tianchengli/flatdata | 03ccf3669254ddef171d23a287c643dcd28650d2 | [
"Apache-2.0"
] | null | null | null | flatdata-py/generator/tree/nodes/trivial/enumeration_value.py | tianchengli/flatdata | 03ccf3669254ddef171d23a287c643dcd28650d2 | [
"Apache-2.0"
] | null | null | null | flatdata-py/generator/tree/nodes/trivial/enumeration_value.py | tianchengli/flatdata | 03ccf3669254ddef171d23a287c643dcd28650d2 | [
"Apache-2.0"
] | null | null | null | from generator.tree.nodes.node import Node
class EnumerationValue(Node):
def __init__(self, name, value, properties=None):
super(EnumerationValue, self).__init__(name=name, properties=properties)
self._value = value
@staticmethod
def create(properties, value):
result = EnumerationValue(name=properties.name, properties=properties, value=value)
return result
@property
def doc(self):
return self._properties.doc
@property
def value(self):
return self._value
| 26.9 | 91 | 0.689591 | 59 | 538 | 6.101695 | 0.372881 | 0.116667 | 0.133333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.219331 | 538 | 19 | 92 | 28.315789 | 0.857143 | 0 | 0 | 0.133333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.266667 | false | 0 | 0.066667 | 0.133333 | 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 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
25e0ee526a4bc12ca2c01ca0a9a15aee02664bb6 | 250 | py | Python | cisco_config_generator.py | palazzoloc/pynet_testx | 25640c07b462c34ae92b452f7f16f0c13c420cbd | [
"Apache-2.0"
] | null | null | null | cisco_config_generator.py | palazzoloc/pynet_testx | 25640c07b462c34ae92b452f7f16f0c13c420cbd | [
"Apache-2.0"
] | null | null | null | cisco_config_generator.py | palazzoloc/pynet_testx | 25640c07b462c34ae92b452f7f16f0c13c420cbd | [
"Apache-2.0"
] | null | null | null | import json
import yaml
from ciscoconfparse import CiscoConfParse
parse_file = CiscoConfParse("kirks_config.conf")
interface_objs = parse_file.find_objects("^crypto map CRYPTO")
for obj in interface_objs:
print obj.parent
print obj.children
| 25 | 62 | 0.804 | 34 | 250 | 5.735294 | 0.647059 | 0.092308 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.132 | 250 | 9 | 63 | 27.777778 | 0.898618 | 0 | 0 | 0 | 0 | 0 | 0.14 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.375 | 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 | 1 | 0 | 0 | 0 | 0 | 3 |
25f6d2be87e5eb20984a4302ead3ac60dffe4e45 | 253 | py | Python | example/custom_filter.py | bjpop/svfilter | 8820dbb20bae699b008187d8867b62af12a68568 | [
"BSD-3-Clause"
] | null | null | null | example/custom_filter.py | bjpop/svfilter | 8820dbb20bae699b008187d8867b62af12a68568 | [
"BSD-3-Clause"
] | null | null | null | example/custom_filter.py | bjpop/svfilter | 8820dbb20bae699b008187d8867b62af12a68568 | [
"BSD-3-Clause"
] | null | null | null | def custom_filter(record):
info = record.INFO
support = info['SU'][0]
paired_end_support = info['PE'][0]
split_read_support = info['SR'][0]
if support > 10 and paired_end_support > 5 and split_read_support > 5:
yield record
| 31.625 | 74 | 0.656126 | 38 | 253 | 4.131579 | 0.5 | 0.210191 | 0.203822 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.035714 | 0.225296 | 253 | 7 | 75 | 36.142857 | 0.765306 | 0 | 0 | 0 | 0 | 0 | 0.023715 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0 | 0 | 0.142857 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
25f8b9c6932627454342667cbb25979873ba19b4 | 3,493 | py | Python | pytests/core/test_decorators.py | rosalogia/bumblebee-status | 19c3975301d8700743df745ecd5ca2c05ecf5cf0 | [
"MIT"
] | null | null | null | pytests/core/test_decorators.py | rosalogia/bumblebee-status | 19c3975301d8700743df745ecd5ca2c05ecf5cf0 | [
"MIT"
] | null | null | null | pytests/core/test_decorators.py | rosalogia/bumblebee-status | 19c3975301d8700743df745ecd5ca2c05ecf5cf0 | [
"MIT"
] | null | null | null | import pytest
import core.decorators
import core.widget
import core.module
import core.config
@pytest.fixture
def module():
class TestModule(core.module.Module):
@core.decorators.never
def __init__(self, config=None, theme=None):
config = core.config.Config([])
super().__init__(config, theme, core.widget.Widget(self.get))
self.text = ""
@core.decorators.scrollable
def get(self, widget):
return self.text
module = TestModule()
module.set("scrolling.width", 10)
return module
def test_never(module):
assert module.parameter("interval") == "never"
def test_no_text(module):
assert module.text == ""
assert module.get(module.widget()) == ""
def test_smaller(module):
module.text = "test"
assert module.parameter("scrolling.width") > len(module.text)
assert module.get(module.widget()) == module.text
def test_bigger(module):
module.text = "this is a really really long sample text"
maxwidth = module.parameter("scrolling.width")
assert maxwidth < len(module.text)
assert module.get(module.widget()) == module.text[:maxwidth]
def test_bounce(module):
module.text = "abcd"
module.set("scrolling.width", 2)
assert module.get(module.widget()) == "ab"
assert module.get(module.widget()) == "bc"
assert module.get(module.widget()) == "cd"
assert module.get(module.widget()) == "bc"
assert module.get(module.widget()) == "ab"
assert module.get(module.widget()) == "bc"
assert module.get(module.widget()) == "cd"
assert module.get(module.widget()) == "bc"
assert module.get(module.widget()) == "ab"
def test_nobounce(module):
module.set("scrolling.bounce", False)
module.set("scrolling.width", 2)
module.text = "abcd"
assert module.get(module.widget()) == "ab"
assert module.get(module.widget()) == "bc"
assert module.get(module.widget()) == "cd"
assert module.get(module.widget()) == "ab"
assert module.get(module.widget()) == "bc"
assert module.get(module.widget()) == "cd"
def test_completely_changed_data(module):
module.text = "abcd"
module.set("scrolling.width", 2)
assert module.get(module.widget()) == "ab"
assert module.get(module.widget()) == "bc"
module.text = "wxyz"
assert module.get(module.widget()) == "wx"
assert module.get(module.widget()) == "xy"
def test_slightly_changed_data(module):
module.text = "this is a sample song (0:00)"
module.set("scrolling.width", 10)
assert module.get(module.widget()) == module.text[0:10]
module.text = "this is a sample song (0:01)"
assert module.get(module.widget()) == module.text[1:11]
module.text = "this is a sample song (0:02)"
assert module.get(module.widget()) == module.text[2:12]
module.text = "this is a sample song (0:13)"
assert module.get(module.widget()) == module.text[3:13]
module.text = "this is a different song (0:13)"
assert module.get(module.widget()) == module.text[0:10]
def test_n_plus_one(module):
module.text = "10 letters"
module.set("scrolling.width", 9)
assert module.get(module.widget()) == module.text[0:9]
assert module.get(module.widget()) == module.text[1:10]
assert module.get(module.widget()) == module.text[0:9]
assert module.get(module.widget()) == module.text[1:10]
assert module.get(module.widget()) == module.text[0:9]
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
| 33.586538 | 73 | 0.654452 | 472 | 3,493 | 4.792373 | 0.165254 | 0.185676 | 0.212202 | 0.297082 | 0.629973 | 0.557029 | 0.544209 | 0.511494 | 0.44695 | 0.427056 | 0 | 0.019204 | 0.180074 | 3,493 | 103 | 74 | 33.912621 | 0.770601 | 0.014601 | 0 | 0.385542 | 0 | 0 | 0.116279 | 0 | 0 | 0 | 0 | 0 | 0.433735 | 1 | 0.144578 | false | 0 | 0.060241 | 0.012048 | 0.240964 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
d302d22f50f688110be5a8657edd0ce936b1d271 | 544 | py | Python | Self_Driving_Car----Vehicle-Detection/libraries.py | Nikhil-Xavier-DS/Self_Driving_Car----Computer-Vision---Deep-Learning | c293bb28ca7e639b1586f5204b2fad19180bce75 | [
"BSD-3-Clause"
] | null | null | null | Self_Driving_Car----Vehicle-Detection/libraries.py | Nikhil-Xavier-DS/Self_Driving_Car----Computer-Vision---Deep-Learning | c293bb28ca7e639b1586f5204b2fad19180bce75 | [
"BSD-3-Clause"
] | null | null | null | Self_Driving_Car----Vehicle-Detection/libraries.py | Nikhil-Xavier-DS/Self_Driving_Car----Computer-Vision---Deep-Learning | c293bb28ca7e639b1586f5204b2fad19180bce75 | [
"BSD-3-Clause"
] | null | null | null | import matplotlib.image as mpimg
import numpy as np
import cv2
from skimage.feature import hog
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
import collections
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.utils import shuffle
from sklearn.svm import LinearSVC
from scipy.ndimage.measurements import label
from glob import glob
from utils import (extract_features, slide_window, draw_boxes, find_cars)
import os
import pickle | 28.631579 | 73 | 0.852941 | 82 | 544 | 5.573171 | 0.512195 | 0.09628 | 0.091904 | 0.100656 | 0.227571 | 0.227571 | 0.227571 | 0.227571 | 0.227571 | 0.227571 | 0 | 0.004175 | 0.119485 | 544 | 19 | 74 | 28.631579 | 0.949896 | 0 | 0 | 0.333333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
d319632aadee6f9330eaba36c50b44249a6658f3 | 340 | py | Python | src/snap_to_bucket/__init__.py | siemens/snap-to-bucket | 8ce5f4d96ab724f337417b0a9e34f388784a9075 | [
"MIT"
] | 5 | 2020-05-22T12:00:20.000Z | 2022-01-27T09:44:20.000Z | src/snap_to_bucket/__init__.py | siemens/snap-to-bucket | 8ce5f4d96ab724f337417b0a9e34f388784a9075 | [
"MIT"
] | 2 | 2021-07-09T09:12:50.000Z | 2021-07-21T07:37:22.000Z | src/snap_to_bucket/__init__.py | siemens/snap-to-bucket | 8ce5f4d96ab724f337417b0a9e34f388784a9075 | [
"MIT"
] | 1 | 2021-09-29T06:51:56.000Z | 2021-09-29T06:51:56.000Z | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
SPDX-FileCopyrightText: Siemens AG, 2020 Gaurav Mishra <mishra.gaurav@siemens.com>
SPDX-License-Identifier: MIT
"""
__author__ = 'Siemens AG'
from .ec_2_handler import Ec2Handler
from .fs_handler import FsHandler
from .s3_handler import S3Handler
from .snap_handler import SnapToBucket
| 22.666667 | 82 | 0.767647 | 46 | 340 | 5.478261 | 0.673913 | 0.206349 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033445 | 0.120588 | 340 | 14 | 83 | 24.285714 | 0.809365 | 0.458824 | 0 | 0 | 0 | 0 | 0.057143 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.8 | 0 | 0.8 | 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 | 1 | 0 | 0 | 3 |
d325daaaf628f8de6cab95378088db7b15988ec4 | 38 | py | Python | openDAM/__init__.py | bcornelusse/openDAM | ad74541d5b5955b6ebb7212aecc6942ff5f71575 | [
"BSD-2-Clause"
] | 15 | 2018-09-18T23:28:41.000Z | 2022-01-11T12:44:10.000Z | openDAM/__init__.py | bcornelusse/openDAM | ad74541d5b5955b6ebb7212aecc6942ff5f71575 | [
"BSD-2-Clause"
] | 2 | 2018-07-06T13:18:59.000Z | 2018-07-11T08:53:29.000Z | openDAM/__init__.py | bcornelusse/openDAM | ad74541d5b5955b6ebb7212aecc6942ff5f71575 | [
"BSD-2-Clause"
] | 3 | 2020-06-02T04:16:54.000Z | 2021-02-22T10:52:06.000Z | __all__ = ["conf", "dataio", "model"]
| 19 | 37 | 0.578947 | 4 | 38 | 4.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.131579 | 38 | 1 | 38 | 38 | 0.545455 | 0 | 0 | 0 | 0 | 0 | 0.394737 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
d336fa5641f4a01bc200bbe063e0811ec77c1d64 | 55 | py | Python | helloworld.py | SURYANSH05/regression_multivar | 6e7d869e459f911fd026f400dd793f8e6b4e013a | [
"MIT"
] | null | null | null | helloworld.py | SURYANSH05/regression_multivar | 6e7d869e459f911fd026f400dd793f8e6b4e013a | [
"MIT"
] | null | null | null | helloworld.py | SURYANSH05/regression_multivar | 6e7d869e459f911fd026f400dd793f8e6b4e013a | [
"MIT"
] | null | null | null | print("hello git")
for i in range(10):
print("sojao")
| 13.75 | 19 | 0.654545 | 10 | 55 | 3.6 | 0.9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.042553 | 0.145455 | 55 | 3 | 20 | 18.333333 | 0.723404 | 0 | 0 | 0 | 0 | 0 | 0.254545 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.666667 | 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 | 1 | 0 | 3 |
d35681b637db718ad2348264f5929fda2384992f | 640 | py | Python | tests/fixtures/etl.py | wearefair/modelmapper | 7f420ceca0312373fdb0ab81fa3f6a3f8fb86086 | [
"MIT"
] | 5 | 2018-06-29T22:13:22.000Z | 2019-03-15T18:28:07.000Z | tests/fixtures/etl.py | wearefair/modelmapper | 7f420ceca0312373fdb0ab81fa3f6a3f8fb86086 | [
"MIT"
] | 13 | 2018-06-29T22:40:02.000Z | 2020-12-15T05:29:04.000Z | tests/fixtures/etl.py | wearefair/modelmapper | 7f420ceca0312373fdb0ab81fa3f6a3f8fb86086 | [
"MIT"
] | 1 | 2019-08-05T17:47:02.000Z | 2019-08-05T17:47:02.000Z | from modelmapper import ETL
class BasicETL(ETL):
def get_client_data(self):
pass
def report_exception(self, e):
pass
def encrypt_data(self, gen):
pass
def backup_data(self, content, key, metadata):
pass
def get_session(self):
pass
def insert_chunk_of_data_to_db(self, session, table, chunk):
pass
def encrypt_row_fields(self, cleaned_data_gen):
pass
def verify_access_to_backup_source(self):
pass
def pre_clean_transform(self, session, data_gen):
pass
def post_clean_transform(self, session, data_gen):
pass
| 18.285714 | 64 | 0.645313 | 85 | 640 | 4.564706 | 0.447059 | 0.162371 | 0.085052 | 0.072165 | 0.185567 | 0.185567 | 0.185567 | 0 | 0 | 0 | 0 | 0 | 0.282813 | 640 | 34 | 65 | 18.823529 | 0.845316 | 0 | 0 | 0.454545 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.454545 | false | 0.454545 | 0.045455 | 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 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
d36e82ffcf05ec3b5b3b81467aadffa257a66779 | 218 | py | Python | harissa/simulation/__init__.py | ulysseherbach/harissa | 047c04282a9539ba9d56eaaafb6ef99dfa0bbd51 | [
"BSD-3-Clause"
] | 7 | 2018-10-31T12:48:32.000Z | 2022-03-06T20:49:15.000Z | harissa/simulation/__init__.py | ulysseherbach/harissa | 047c04282a9539ba9d56eaaafb6ef99dfa0bbd51 | [
"BSD-3-Clause"
] | null | null | null | harissa/simulation/__init__.py | ulysseherbach/harissa | 047c04282a9539ba9d56eaaafb6ef99dfa0bbd51 | [
"BSD-3-Clause"
] | null | null | null | """
harissa.simulation
------------------
Simulation of the network model.
"""
from .base import Simulation
from .pdmp import BurstyPDMP
from .ode import ApproxODE
__all__ = ['Simulation', 'BurstyPDMP', 'ApproxODE']
| 18.166667 | 51 | 0.688073 | 23 | 218 | 6.347826 | 0.608696 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.12844 | 218 | 11 | 52 | 19.818182 | 0.768421 | 0.325688 | 0 | 0 | 0 | 0 | 0.208633 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.75 | 0 | 0.75 | 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 | 1 | 0 | 1 | 0 | 0 | 3 |
d370f6995d38a1738877a5673ba18dbbf6ff495e | 100 | py | Python | imageFile.py | JingChuanHe/PythonTools | 12a48482fb90975b54d1607f1769f555b70f663f | [
"Apache-2.0"
] | 1 | 2018-06-15T02:40:06.000Z | 2018-06-15T02:40:06.000Z | imageFile.py | JingChuanHe/PythonTools | 12a48482fb90975b54d1607f1769f555b70f663f | [
"Apache-2.0"
] | null | null | null | imageFile.py | JingChuanHe/PythonTools | 12a48482fb90975b54d1607f1769f555b70f663f | [
"Apache-2.0"
] | null | null | null |
def imageF():
image = imread(r"E:\Python Working\png")
if __name__ =="__main__":
imageF() | 14.285714 | 42 | 0.62 | 13 | 100 | 4.153846 | 0.923077 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | 100 | 7 | 43 | 14.285714 | 0.675 | 0 | 0 | 0 | 0 | 0 | 0.308511 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
d37386228f00064d3f619e13e43fa17e2ef15a69 | 162 | py | Python | tests/test_doctest.py | langloisjp/tornado-logging-app | 02505b8a5bef782f9b67120874355b64f1b3e81a | [
"MIT"
] | 1 | 2015-12-09T00:09:52.000Z | 2015-12-09T00:09:52.000Z | tests/test_doctest.py | langloisjp/tornado-logging-app | 02505b8a5bef782f9b67120874355b64f1b3e81a | [
"MIT"
] | null | null | null | tests/test_doctest.py | langloisjp/tornado-logging-app | 02505b8a5bef782f9b67120874355b64f1b3e81a | [
"MIT"
] | null | null | null | import unittest
import doctest
import tornadoutil
def load_tests(loader, tests, ignore):
tests.addTests(doctest.DocTestSuite(tornadoutil))
return tests
| 18 | 53 | 0.790123 | 19 | 162 | 6.684211 | 0.631579 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.141975 | 162 | 8 | 54 | 20.25 | 0.913669 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.5 | 0 | 0.833333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
d38b990d9e76ad4e1468183bdbdf36ec73bc28f1 | 7,850 | py | Python | Sense HAT Projects/Sense HAT test.py | jonasrains/RaspPi-Projects | 9132aca592d11cb76ad039786e326db58da2f293 | [
"MIT"
] | null | null | null | Sense HAT Projects/Sense HAT test.py | jonasrains/RaspPi-Projects | 9132aca592d11cb76ad039786e326db58da2f293 | [
"MIT"
] | null | null | null | Sense HAT Projects/Sense HAT test.py | jonasrains/RaspPi-Projects | 9132aca592d11cb76ad039786e326db58da2f293 | [
"MIT"
] | null | null | null | import time
import math
from sense_emu import SenseHat
hat = SenseHat()
arrows = [False, False, False, False, False]
# colors
red = [255, 0, 0]
orange = [255, 127, 0]
yellow = [255, 255, 0]
lightGreen = [0, 255, 0]
green = [0, 150, 0]
blue = [0, 0, 255]
lightBlue = [0, 255, 255]
purple = [170, 0, 255]
pink = [255, 0, 255]
brown = [127, 64, 0]
white = [255, 255, 255]
black = [0, 0, 0]
# presets
def line(color, line, direction):
# draws a verticle or horizontal line
if direction == "horizontal":
for i in range(64):
if (line - 1) * 8 <= i < (line - 1) * 8 + 8:
pixels[i] = color
elif direction == "verticle":
for i in range(8):
for ii in range(1, 9):
if ii == line:
pixels[i * 8 + ii - 1] = color
def fill(color):
# use as pixels = fill()
return([color for i in range(64)])
def pixel(color, x, y):
for i in range(1, 9):
for ii in range(1, 9):
if i == y and ii == x:
pixels[(i - 1) * 8 + ii-1] = color
def getPixel(x, y):
for i in range(1, 9):
for ii in range(1, 9):
if i == y and ii == x:
return(pixels[(i - 1) * 8 + ii-1])
def testPixel(x, y, color):
if(getPixel(x, y) == color):
return(True)
else:
return(False)
def mergeColor(color1, color2):
return([round((color1[0] + color2[0]) / 2), round((color1[1] + color2[1]) / 2),
round((color1[2] + color2[2]) / 2)])
def drawNumber(color, x, y, number):
if number == 0:
drawZero(color, x, y)
elif number == 1:
drawOne(color, x, y)
elif number == 2:
drawTwo(color, x, y)
elif number == 3:
drawThree(color, x, y)
elif number == 4:
drawFour(color, x, y)
elif number == 5:
drawFive(color, x, y)
elif number == 6:
drawSix(color, x, y)
elif number == 7:
drawSeven(color, x, y)
elif number == 8:
drawEight(color, x, y)
elif number == 9:
drawNine(color, x, y)
else:
drawNumber(color, x, y, int(str(number)[0]))
drawNumber(color, x + 5, y, int(str(number)[1]))
def drawZero(color, x, y):
pixel(color, x, y - 2)
pixel(color, x - 1, y - 2)
pixel(color, x - 1, y - 1)
pixel(color, x - 1, y)
pixel(color, x - 1, y + 1)
pixel(color, x - 1, y + 2)
pixel(color, x, y + 2)
pixel(color, x + 1, y - 2)
pixel(color, x + 1, y - 1)
pixel(color, x + 1, y)
pixel(color, x + 1, y + 1)
pixel(color, x + 1, y + 2)
def drawOne(color, x, y):
pixel(color, x - 1, y + 2)
pixel(color, x, y + 2)
pixel(color, x + 1, y + 2)
pixel(color, x, y + 1)
pixel(color, x, y)
pixel(color, x, y - 1)
pixel(color, x, y - 2)
pixel(color, x - 1, y - 2)
def drawTwo(color, x, y):
pixel(color, x - 1, y - 2)
pixel(color, x, y - 2)
pixel(color, x + 1, y - 1)
pixel(color, x + 1, y)
pixel(color, x, y)
pixel(color, x - 1, y + 1)
pixel(color, x - 1, y + 2)
pixel(color, x, y + 2)
pixel(color, x + 1, y + 2)
def drawThree(color, x, y):
pixel(color, x - 1, y - 2)
pixel(color, x, y - 2)
pixel(color, x + 1, y - 1)
pixel(color, x + 1, y)
pixel(color, x, y)
pixel(color, x + 1, y + 1)
pixel(color, x - 1, y + 2)
pixel(color, x, y + 2)
def drawFour(color, x, y):
pixel(color, x - 1, y - 2)
pixel(color, x + 1, y - 2)
pixel(color, x - 1, y - 1)
pixel(color, x + 1, y - 1)
pixel(color, x - 1, y)
pixel(color, x, y)
pixel(color, x + 1, y)
pixel(color, x + 1, y + 1)
pixel(color, x + 1, y + 2)
def drawFive(color, x, y):
pixel(color, x - 1, y + 2)
pixel(color, x, y + 2)
pixel(color, x + 1, y + 1)
pixel(color, x - 1, y)
pixel(color, x, y)
pixel(color, x - 1, y - 1)
pixel(color, x + 1, y - 2)
pixel(color, x, y - 2)
pixel(color, x - 1, y - 2)
def drawSix(color, x, y):
pixel(color, x - 1, y + 2)
pixel(color, x, y + 2)
pixel(color, x + 1, y + 1)
pixel(color, x - 1, y)
pixel(color, x, y)
pixel(color, x - 1, y - 1)
pixel(color, x + 1, y - 2)
pixel(color, x, y - 2)
pixel(color, x - 1, y + 1)
pixel(color, x + 1, y + 2)
pixel(color, x + 1, y)
def drawSeven(color, x, y):
pixel(color, x - 1, y - 2)
pixel(color, x, y - 2)
pixel(color, x + 1, y - 2)
pixel(color, x + 1, y - 1)
pixel(color, x, y)
pixel(color, x - 1, y + 1)
pixel(color, x - 1, y + 2)
def drawEight(color, x, y):
pixel(color, x, y - 2)
pixel(color, x - 1, y - 1)
pixel(color, x + 1, y - 1)
pixel(color, x, y)
pixel(color, x - 1, y + 1)
pixel(color, x, y + 2)
pixel(color, x + 1, y + 1)
def drawNine(color, x, y):
pixel(color, x + 1, y - 2)
pixel(color, x, y - 2)
pixel(color, x - 1, y - 1)
pixel(color, x + 1, y)
pixel(color, x, y)
pixel(color, x + 1, y + 1)
pixel(color, x - 1, y + 2)
pixel(color, x, y + 2)
pixel(color, x + 1, y - 1)
pixel(color, x - 1, y - 2)
pixel(color, x - 1, y)
def drawDigNumber(color, x, y, number):
if number == 0:
numList = [True, True, True, False, True, True, True]
elif number == 1:
numList = [False, False, False, False, False, True, True]
elif number == 2:
numList = [False, True, True, True, True, True, False]
elif number == 3:
numList = [False, False, True, True, True, True, True]
elif number == 4:
numList = [True, False, False, True, False, True, True]
elif number == 5:
numList = [True, False, True, True, True, False, True]
elif number == 6:
numList = [True, True, True, True, True, False, True]
elif number == 7:
numList = [False, False, True, False, False, True, True]
elif number == 8:
numList = [True for i in range(7)]
elif number == 9:
numList = [True, False, True, True, True, True, True]
else:
numList = [False for i in range(7)]
drawDigNumber(color, x, y, int(str(number)[0]))
drawDigNumber(color, x + 4, y, int(str(number)[1]))
if numList[0]:
pixel(color, x - 1, y - 2)
pixel(color, x - 1, y - 1)
if numList[1]:
pixel(color, x - 1, y + 1)
pixel(color, x - 1, y +2)
if numList[2]:
pixel(color, x, y - 3)
pixel(color, x + 1, y - 3)
if numList[3]:
pixel(color, x, y)
pixel(color, x + 1, y)
if numList[4]:
pixel(color, x, y + 3)
pixel(color, x + 1, y + 3)
if numList[5]:
pixel(color, x + 2, y - 2)
pixel(color, x + 2, y - 1)
if numList[6]:
pixel(color, x + 2, y + 1)
pixel(color, x + 2, y + 2)
# code
pixels = fill(black)
while True:
for event in hat.stick.get_events():
if event.direction == "up":
if event.action == "held" or event.action == "pressed":
arrows[0] = True
else:
arrows[0] = False
if event.direction == "left":
if event.action == "held" or event.action == "pressed":
arrows[1] = True
else:
arrows[1] = False
if event.direction == "right":
if event.action == "held" or event.action == "pressed":
arrows[2] = True
else:
arrows[2] = False
if event.direction == "down":
if event.action == "held" or event.action == "pressed":
arrows[3] = True
else:
arrows[3] = False
if event.direction == "middle":
if event.action == "held" or event.action == "pressed":
arrows[4] = True
else:
arrows[4] = False
pixels = fill(lightBlue)
hat.set_pixels(pixels)
| 28.442029 | 83 | 0.495924 | 1,229 | 7,850 | 3.165175 | 0.083808 | 0.203599 | 0.299743 | 0.215938 | 0.653985 | 0.560411 | 0.495887 | 0.454242 | 0.454242 | 0.386375 | 0 | 0.061824 | 0.340637 | 7,850 | 275 | 84 | 28.545455 | 0.689722 | 0.009936 | 0 | 0.544355 | 0 | 0 | 0.012104 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.072581 | false | 0 | 0.012097 | 0.008065 | 0.084677 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
6c976441700bf205b643636a4b2168127f347df3 | 4,270 | py | Python | tests/surrortg/image_recognition/test_async_video_capture.py | cedricsellin/surrogate | 03f13d297fdd74d7e5d164821039acc38d0b2103 | [
"MIT"
] | 2 | 2020-11-25T00:29:07.000Z | 2020-12-01T20:24:47.000Z | tests/surrortg/image_recognition/test_async_video_capture.py | cedricsellin/surrogate | 03f13d297fdd74d7e5d164821039acc38d0b2103 | [
"MIT"
] | 1 | 2021-04-10T11:59:23.000Z | 2021-04-10T11:59:23.000Z | tests/surrortg/image_recognition/test_async_video_capture.py | cedricsellin/surrogate | 03f13d297fdd74d7e5d164821039acc38d0b2103 | [
"MIT"
] | 2 | 2021-01-28T17:43:13.000Z | 2021-03-29T13:19:38.000Z | import asyncio # noqa:F401
import time # noqa:F401
import unittest # noqa:F401
# Run `pip install numpy opencv-contrib-python` tests can be run
# for AsyncioVideoCapture
"""
from surrortg.devices import AsyncVideoCapture, CapComm, VideoCaptureProcess
# logging.getLogger().setLevel(logging.INFO)
# logging.disable(logging.WARNING)
SAMPLE_FRAME = 1
# Modified process classes
class VideoCaptureProcessReturn(VideoCaptureProcess):
def run(self):
self._conn.send(CapComm.INIT_SUCCESS)
while True:
# wait until a new request
req = self._conn.recv()
# respond to the request
if req == CapComm.FRAME_REQUEST:
self._conn.send(SAMPLE_FRAME)
elif req == CapComm.RELEASE_REQUEST:
self._conn.send(CapComm.RELEASED)
break
class VideoCaptureProcessNeverReturn(VideoCaptureProcess):
def run(self):
self._conn.send(CapComm.INIT_SUCCESS)
while True:
# wait until a new request
req = self._conn.recv()
# respond to the request
if req == CapComm.FRAME_REQUEST:
pass
elif req == CapComm.RELEASE_REQUEST:
self._conn.send(CapComm.RELEASED)
break
class VideoCaptureProcessInitFailure(VideoCaptureProcess):
def run(self):
self._conn.send(CapComm.INIT_FAILURE)
class VideoCaptureProcessNeverInit(VideoCaptureProcess):
def run(self):
pass
class VideoCaptureProcessReleaseBlock(VideoCaptureProcess):
def run(self):
self._conn.send(CapComm.INIT_SUCCESS)
while True:
# wait until a new request
req = self._conn.recv()
# respond to the request
if req == CapComm.FRAME_REQUEST:
self._conn.send(SAMPLE_FRAME)
elif req == CapComm.RELEASE_REQUEST:
time.sleep(15)
self._conn.send(CapComm.RELEASED)
break
class GameTest(unittest.TestCase):
def test_read_frame(self):
async def _test_read_frame():
async with await AsyncVideoCapture.create(
None, process_class=VideoCaptureProcessReturn,
) as frames:
async for frame in frames:
self.assertEqual(frame, SAMPLE_FRAME)
break
asyncio.get_event_loop().run_until_complete(_test_read_frame())
def test_never_reads(self):
def raise_error():
raise RuntimeError("read failed")
async def _test_never_reads():
cap = await AsyncVideoCapture.create(
None,
read_timeout=0.01,
release_timeout=0.01,
process_class=VideoCaptureProcessNeverReturn,
)
cap._release = raise_error
with self.assertRaises(RuntimeError):
await cap.read()
asyncio.get_event_loop().run_until_complete(_test_never_reads())
def test_init_failure(self):
async def _test_init_failure():
with self.assertRaises(RuntimeError):
cap = await AsyncVideoCapture.create(
None, process_class=VideoCaptureProcessInitFailure
)
await cap.read()
asyncio.get_event_loop().run_until_complete(_test_init_failure())
def test_never_init(self):
async def _test_never_init():
with self.assertRaises(RuntimeError):
await AsyncVideoCapture.create(
None,
init_timeout=0.01,
process_class=VideoCaptureProcessNeverInit,
)
asyncio.get_event_loop().run_until_complete(_test_never_init())
def test_release_blocking_process(self):
async def main():
cap = await AsyncVideoCapture.create(
None,
release_timeout=0.01,
process_class=VideoCaptureProcessReleaseBlock,
)
await cap.read()
await cap.release()
start = time.time()
asyncio.get_event_loop().run_until_complete(main())
end = time.time()
self.assertLess(end - start, 1)
"""
| 30.283688 | 76 | 0.602342 | 425 | 4,270 | 5.832941 | 0.24 | 0.038725 | 0.043566 | 0.053651 | 0.51069 | 0.444534 | 0.385639 | 0.356595 | 0.340863 | 0.300121 | 0 | 0.008615 | 0.320375 | 4,270 | 140 | 77 | 30.5 | 0.845624 | 0.027166 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
6caec4273881186286c02d8eff2e9d90af413292 | 1,599 | py | Python | src/pyat88ck590.py | secworks/pyat88ck590 | 8881f205fb0ef08d62a04ce1a36e26d73f0c71e7 | [
"BSD-2-Clause"
] | 1 | 2017-10-28T02:52:35.000Z | 2017-10-28T02:52:35.000Z | src/pyat88ck590.py | secworks/pyat88ck590 | 8881f205fb0ef08d62a04ce1a36e26d73f0c71e7 | [
"BSD-2-Clause"
] | null | null | null | src/pyat88ck590.py | secworks/pyat88ck590 | 8881f205fb0ef08d62a04ce1a36e26d73f0c71e7 | [
"BSD-2-Clause"
] | null | null | null | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#=======================================================================
#
# pyat88ck590.py
# --------------
# Code to talk to the Atmel/Microchip Crypto Authentication Eval
# Kit USB dongle.
#
# path: "USB_03eb_2312_14100000"
# vendor_id: 0x03eb
# product_id: 0x2312
# serial_number: ""
# release_number: 0x1000
# manufacturer_string: "ATMEL"
# product_string: "Crypto Device Demo"
# usage_page: 65535
# usage: 1
# interface_number: -1
#
#=======================================================================
import sys
import hidapi
#-------------------------------------------------------------------
#-------------------------------------------------------------------
def dump_all_devices():
for dev in hidapi.hid_enumerate():
print dev.description()
#-------------------------------------------------------------------
#-------------------------------------------------------------------
def main():
hidapi.hid_init()
dump_all_devices()
#-------------------------------------------------------------------
# __name__
# Python thingy which allows the file to be run standalone as
# well as parsed from within a Python interpreter.
#-------------------------------------------------------------------
if __name__=="__main__":
# Run the main function.
sys.exit(main())
#=======================================================================
# EOF pyat88ck590.py
#=======================================================================
| 30.169811 | 72 | 0.355222 | 112 | 1,599 | 4.8125 | 0.696429 | 0.048237 | 0.051948 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032919 | 0.145091 | 1,599 | 52 | 73 | 30.75 | 0.361375 | 0.810507 | 0 | 0 | 0 | 0 | 0.02974 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.2 | null | null | 0.1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
6caf48ee7408e42d912bf16dcd90bd2d85690892 | 3,846 | py | Python | waterbutler/providers/bitbucket/metadata.py | KakeruMizuno/RDM-waterbutler | 58ecd801385a7572d1ed56568a31f701291c4e3e | [
"Apache-2.0"
] | 65 | 2015-01-23T03:22:04.000Z | 2022-01-11T22:33:19.000Z | waterbutler/providers/bitbucket/metadata.py | cslzchen/waterbutler | e4e07727e06885a752c9251e5731f5627f646da3 | [
"Apache-2.0"
] | 300 | 2015-02-16T16:45:02.000Z | 2022-01-31T14:49:07.000Z | waterbutler/providers/bitbucket/metadata.py | cslzchen/waterbutler | e4e07727e06885a752c9251e5731f5627f646da3 | [
"Apache-2.0"
] | 76 | 2015-01-20T20:45:17.000Z | 2021-07-30T13:18:10.000Z | from email.utils import parseaddr
from furl import furl
from waterbutler.core import metadata
class BaseBitbucketMetadata(metadata.BaseMetadata):
"""Metadata properties common to Bitbucket files and folders
*commit*: The commit sha that this metadata snapshot applies to.
The commit may not actually involve changes to the entity.
*branch*: A branch is mutable pointer to a commit sha. If a branch name was used to retrieve
the metadata for this entity, this property will be set. Otherwise, it is ``None``.
*ref*: The ref (commit or branch name) that this entity belongs to. For mutating
actions, this is the ref after the action has been committed.
"""
def __init__(self, raw, path_obj, owner=None, repo=None):
super().__init__(raw)
self._path_obj = path_obj
self.owner = owner
self.repo = repo
@property
def provider(self):
return 'bitbucket'
@property
def path(self):
return self.build_path()
@property
def name(self):
return self._path_obj.name
@property
def commit_sha(self):
return self._path_obj.commit_sha
@property
def branch_name(self):
return self._path_obj.branch_name
@property
def extra(self):
return {
'commitSha': self.commit_sha,
'branch': self.branch_name, # may be None if revision id is a sha
}
def build_path(self):
return super().build_path(self._path_obj.raw_path)
def _json_api_links(self, resource):
"""Update JSON-API links to add commitSha or branch, if available"""
links = super()._json_api_links(resource)
ref = None
if self.commit_sha is not None:
ref = {'commitSha': self.commit_sha}
elif self.branch_name is not None:
ref = {'branch': self.branch_name}
if ref is not None:
for action, link in links.items():
links[action] = furl(link).add(ref).url
for action in ['delete', 'upload', 'new_folder']:
if action in links:
links[action] = None
return links
class BitbucketFileMetadata(BaseBitbucketMetadata, metadata.BaseFileMetadata):
@property
def size(self):
return self.raw['size']
@property
def modified(self):
return self.raw.get('timestamp', None)
@property
def created_utc(self):
return self.raw.get('created_utc', None)
@property
def content_type(self):
return None
@property
def etag(self):
return '{}::{}'.format(self.path, self.commit_sha) # FIXME: maybe last_commit_sha?
@property
def extra(self):
return dict(super().extra, **{
'webView': self.web_view,
'lastCommitSha': self.last_commit_sha,
})
@property
def last_commit_sha(self):
return self.raw.get('revision', None)
@property
def web_view(self):
return 'https://bitbucket.org/{}/{}/src/{}{}?fileviewer=file-view-default'.format(
self.owner, self.repo, self.commit_sha, self.path,
)
class BitbucketFolderMetadata(BaseBitbucketMetadata, metadata.BaseFolderMetadata):
pass
class BitbucketRevisionMetadata(metadata.BaseFileRevisionMetadata):
@property
def version_identifier(self):
return 'commitSha'
@property
def modified(self):
return self.raw['timestamp']
@property
def modified_utc(self):
return self.raw['utctimestamp']
@property
def version(self):
return self.raw['raw_node']
@property
def extra(self):
return {
'user': {
'name': parseaddr(self.raw['raw_author'])[0] # real name only
},
'branch': self.raw['branch'],
}
| 25.986486 | 97 | 0.622465 | 464 | 3,846 | 5.034483 | 0.284483 | 0.085616 | 0.065925 | 0.050942 | 0.146404 | 0.052226 | 0.030822 | 0 | 0 | 0 | 0 | 0.000359 | 0.275871 | 3,846 | 147 | 98 | 26.163265 | 0.83842 | 0.169787 | 0 | 0.262626 | 0 | 0 | 0.08 | 0 | 0 | 0 | 0 | 0.006803 | 0 | 1 | 0.222222 | false | 0.010101 | 0.030303 | 0.20202 | 0.505051 | 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 | 1 | 0 | 0 | 3 |
6cbc6474484d3efd3e7bb5e7e60f39516be64f96 | 2,499 | py | Python | vcmp/object.py | ysc3839/vcmp-python-test | 3ccd7788cb97dc302b0a4d3d7ba833196585afde | [
"MIT"
] | 1 | 2022-01-13T18:40:11.000Z | 2022-01-13T18:40:11.000Z | vcmp/object.py | ysc3839/vcmp-python-test | 3ccd7788cb97dc302b0a4d3d7ba833196585afde | [
"MIT"
] | null | null | null | vcmp/object.py | ysc3839/vcmp-python-test | 3ccd7788cb97dc302b0a4d3d7ba833196585afde | [
"MIT"
] | null | null | null | # pylint: disable=missing-docstring
from typing import Tuple
from _vcmp import functions as func
Vector = Tuple[float, float, float]
Quaternion = Tuple[float, float, float, float]
class Object:
def __init__(self, object_id):
self._id = object_id
# Read-write properties
@property
def world(self):
return func.get_object_world(self._id)
@world.setter
def world(self, value: int):
func.set_object_world(self._id, value)
@property
def pos(self):
return func.get_object_position(self._id)
@pos.setter
def pos(self, value: Vector):
func.set_object_position(self._id, *value)
@property
def shot_report(self):
return func.is_object_shot_report_enabled(self._id)
@shot_report.setter
def shot_report(self, value: bool):
func.set_object_shot_report_enabled(self._id, value)
@property
def touched_report(self):
return func.is_object_touched_report_enabled(self._id)
@touched_report.setter
def touched_report(self, value: bool):
func.set_object_touched_report_enabled(self._id, value)
#Read-only properties
@property
def alpha(self):
return func.get_object_alpha(self._id)
@property
def model(self):
return func.get_object_model(self._id)
@property
def rotation(self):
return func.get_object_rotation(self._id)
@property
def rotation_euler(self):
return func.get_object_rotation_euler(self._id)
@property
def id(self):
return self._id
# Functions
def delete(self) -> None:
func.delete_object(self._id)
def move_to(self, pos: Vector, time: int) -> None:
func.move_object_to(self._id, *pos, time)
def move_by(self, offset: Vector, time: int) -> None:
func.move_object_by(self._id, *offset, time)
def rotate_to(self, rotation: Quaternion, time: int) -> None:
func.rotate_object_to(self._id, *rotation, time)
def rotate_by(self, rot_offset: Quaternion, time: int) -> None:
func.rotate_object_by(self._id, *rot_offset, time)
def rotate_to_euler(self, rotation: Vector, time: int) -> None:
func.rotate_to_euler(self._id, *rotation, time)
def rotate_by_euler(self, rot_offset: Vector, time: int) -> None:
func.rotate_by_euler(self._id, *rot_offset, time)
def set_alpha(self, alpha: int, fade_time: int) -> None:
func.set_object_alpha(self._id, alpha, fade_time)
| 26.305263 | 69 | 0.67387 | 346 | 2,499 | 4.580925 | 0.15896 | 0.083281 | 0.070662 | 0.066246 | 0.51735 | 0.368454 | 0.162776 | 0 | 0 | 0 | 0 | 0 | 0.220088 | 2,499 | 94 | 70 | 26.585106 | 0.813238 | 0.034014 | 0 | 0.145161 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.354839 | false | 0 | 0.032258 | 0.145161 | 0.548387 | 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 | 1 | 0 | 0 | 3 |
6cbdb28590cead8bcaf5bd75bde63c22f9d543ec | 380 | py | Python | FreeCodeCamp.org/BuildingATranslator.py | MizaN13/PythonAbc | db8aa05497a6a1bf3eafcfdd6c31880b57e509fb | [
"MIT"
] | null | null | null | FreeCodeCamp.org/BuildingATranslator.py | MizaN13/PythonAbc | db8aa05497a6a1bf3eafcfdd6c31880b57e509fb | [
"MIT"
] | null | null | null | FreeCodeCamp.org/BuildingATranslator.py | MizaN13/PythonAbc | db8aa05497a6a1bf3eafcfdd6c31880b57e509fb | [
"MIT"
] | null | null | null | def translate(phrase):
translation = ""
for letter in phrase:
if letter in "AEIOUaeiou":
if letter.isupper():
translation = translation + "M"
else:
translation = translation + "m"
else:
translation = translation + letter
return translation
print(translate(input("Enter a phrase: "))) | 29.230769 | 47 | 0.555263 | 34 | 380 | 6.205882 | 0.5 | 0.312796 | 0.218009 | 0.255924 | 0.36019 | 0.36019 | 0 | 0 | 0 | 0 | 0 | 0 | 0.352632 | 380 | 13 | 48 | 29.230769 | 0.857724 | 0 | 0 | 0.166667 | 0 | 0 | 0.073491 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.083333 | false | 0 | 0 | 0 | 0.166667 | 0.083333 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
6cd12ffc3cfd0e4aacfd7a109a25cf374822071d | 186 | py | Python | ramjet/analysis/color_palette.py | golmschenk/ramjet | 77fb4481a15088923308fda09804d80455d1a9cf | [
"Apache-2.0"
] | 3 | 2020-11-23T18:47:37.000Z | 2021-08-05T17:45:51.000Z | ramjet/analysis/color_palette.py | golmschenk/ramjet | 77fb4481a15088923308fda09804d80455d1a9cf | [
"Apache-2.0"
] | 5 | 2021-08-19T00:54:57.000Z | 2022-02-10T00:15:40.000Z | ramjet/analysis/color_palette.py | golmschenk/ramjet | 77fb4481a15088923308fda09804d80455d1a9cf | [
"Apache-2.0"
] | 3 | 2019-07-12T21:00:57.000Z | 2020-06-03T22:18:13.000Z | """
A color palette to make coloring consistent project wide.
"""
from bokeh.colors import named
light_curve_colors = [named.mediumblue, named.firebrick, named.green, named.darkorange]
| 26.571429 | 87 | 0.784946 | 25 | 186 | 5.76 | 0.8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.11828 | 186 | 6 | 88 | 31 | 0.878049 | 0.306452 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
9f322742453a98a07db4da0bc8c462acd2c9ca59 | 426 | py | Python | api_service/models/attendance.py | hansinahuja/fras | 1806963e9a0158e2b5daf0a7f2242dab6bc0b11f | [
"MIT"
] | null | null | null | api_service/models/attendance.py | hansinahuja/fras | 1806963e9a0158e2b5daf0a7f2242dab6bc0b11f | [
"MIT"
] | null | null | null | api_service/models/attendance.py | hansinahuja/fras | 1806963e9a0158e2b5daf0a7f2242dab6bc0b11f | [
"MIT"
] | null | null | null | from peewee import *
from datetime import datetime as DT
import logging
from passlib.handlers.pbkdf2 import pbkdf2_sha256
from models.base import *
from models.user import *
class Attendance(BaseModel):
user = ForeignKeyField(User, backref='user_attendance')
status = CharField(max_length=30)
class Meta:
indexes = (
# Unique index
(('user', 'status', 'ins_ts'), True),
)
| 25.058824 | 59 | 0.671362 | 50 | 426 | 5.64 | 0.62 | 0.070922 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.021472 | 0.234742 | 426 | 16 | 60 | 26.625 | 0.843558 | 0.028169 | 0 | 0 | 0 | 0 | 0.075243 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.076923 | 0.461538 | 0 | 0.769231 | 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 | 1 | 0 | 1 | 0 | 0 | 3 |
9f834d609e55dad9b293bad262168b77c5f76b57 | 185 | py | Python | scene/Scene.py | planchon/psVidTex | 07be9a271d7af772ef49f6e3b9de749d1959a959 | [
"MIT"
] | null | null | null | scene/Scene.py | planchon/psVidTex | 07be9a271d7af772ef49f6e3b9de749d1959a959 | [
"MIT"
] | null | null | null | scene/Scene.py | planchon/psVidTex | 07be9a271d7af772ef49f6e3b9de749d1959a959 | [
"MIT"
] | null | null | null | import numpy as np
from render.Container import Container
class Scene(Container):
def __init__(self, **kargs):
self.render()
def render(self):
pass
| 13.214286 | 38 | 0.621622 | 22 | 185 | 5.045455 | 0.636364 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.291892 | 185 | 13 | 39 | 14.230769 | 0.847328 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0.142857 | 0.285714 | 0 | 0.714286 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
9faad79adf85f5238758326c970a89d2595659a1 | 107 | py | Python | travis/readmail.py | selvanair/MacroMilter | 81bfc7564e6036540b54182686be84571412286a | [
"MIT"
] | 39 | 2016-02-17T00:09:50.000Z | 2021-11-17T17:08:50.000Z | travis/readmail.py | selvanair/MacroMilter | 81bfc7564e6036540b54182686be84571412286a | [
"MIT"
] | 47 | 2016-02-16T22:12:56.000Z | 2021-08-31T16:56:25.000Z | travis/readmail.py | selvanair/MacroMilter | 81bfc7564e6036540b54182686be84571412286a | [
"MIT"
] | 19 | 2016-02-20T14:59:31.000Z | 2021-09-30T15:16:40.000Z | #!/usr/bin/env python
import email
import sys
for line in sys.stdin.read().split('\n'):
print(line)
| 13.375 | 41 | 0.663551 | 18 | 107 | 3.944444 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.168224 | 107 | 7 | 42 | 15.285714 | 0.797753 | 0.186916 | 0 | 0 | 0 | 0 | 0.023256 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0.25 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
4ca830bdfe753c51a93b9a0f61b61db5481fd793 | 211 | py | Python | 2019/## Python/Funcoes/mdc_recursivo.py | ed1rac/AulasEstruturasDados | 1a351abee539a2be5e73cba60a61c3225c80164b | [
"MIT"
] | 8 | 2016-05-06T01:07:21.000Z | 2021-05-27T16:30:17.000Z | 2019/## Python/Funcoes/mdc_recursivo.py | ed1rac/AulasEstruturasDados | 1a351abee539a2be5e73cba60a61c3225c80164b | [
"MIT"
] | null | null | null | 2019/## Python/Funcoes/mdc_recursivo.py | ed1rac/AulasEstruturasDados | 1a351abee539a2be5e73cba60a61c3225c80164b | [
"MIT"
] | 3 | 2017-06-24T00:49:53.000Z | 2018-03-29T02:09:17.000Z | def mdc(a,b):
if a<b:
return mdc(b,a)
else:
if b==0:
return a
else:
return mdc(b, a % b)
print(mdc(12,8))
print(mdc(12,10))
| 15.071429 | 36 | 0.364929 | 31 | 211 | 2.483871 | 0.387097 | 0.077922 | 0.25974 | 0.285714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.07619 | 0.50237 | 211 | 13 | 37 | 16.230769 | 0.657143 | 0 | 0 | 0.2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0 | 0 | 0 | 0.4 | 0.2 | 0 | 0 | 0 | null | 0 | 1 | 1 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4ca84c6034cbf0583e4b0346e4bc4dfcc7abc744 | 296 | py | Python | tests/example_tests.py | ozet-team/ozet-server | 4772d37339634adee6ace65a5e2380df4bd22bbb | [
"MIT"
] | 1 | 2021-08-17T15:22:15.000Z | 2021-08-17T15:22:15.000Z | tests/example_tests.py | LuxQuad/ozet-core | e136723d720ed1aa40988b27fe6670bbdfa1106a | [
"MIT"
] | 4 | 2021-11-27T14:15:55.000Z | 2021-12-10T12:59:44.000Z | tests/example_tests.py | ozet-team/ozet-server | 4772d37339634adee6ace65a5e2380df4bd22bbb | [
"MIT"
] | null | null | null | import pytest
@pytest.fixture
def function_fixture():
print('Fixture for each test')
return 1
@pytest.fixture(scope='module')
def module_fixture():
print('Fixture for module')
return 2
def test_zero_division():
with pytest.raises(ZeroDivisionError):
var = 1 / 0
| 15.578947 | 42 | 0.682432 | 38 | 296 | 5.210526 | 0.552632 | 0.131313 | 0.191919 | 0.222222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017094 | 0.209459 | 296 | 18 | 43 | 16.444444 | 0.82906 | 0 | 0 | 0 | 0 | 0 | 0.152027 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.083333 | 0 | 0.5 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4cbb417a63fbfb508ce275724bfa415f0af19df2 | 373 | py | Python | src/models/modules/channel_pad.py | takedarts/skipresnet | d6f1e16042f8433a287355009e17e4e5768ad319 | [
"MIT"
] | 3 | 2022-02-03T13:25:12.000Z | 2022-02-04T16:12:23.000Z | src/models/modules/channel_pad.py | takedarts/skipresnet | d6f1e16042f8433a287355009e17e4e5768ad319 | [
"MIT"
] | null | null | null | src/models/modules/channel_pad.py | takedarts/skipresnet | d6f1e16042f8433a287355009e17e4e5768ad319 | [
"MIT"
] | 1 | 2022-02-04T12:28:02.000Z | 2022-02-04T12:28:02.000Z | import torch
import torch.nn as nn
from ..functions import channelpad
class ChannelPad(nn.Module):
def __init__(self, padding: int) -> None:
super().__init__()
self.padding = padding
def forward(self, x: torch.Tensor) -> torch.Tensor:
return channelpad(x, self.padding)
def extra_repr(self) -> str:
return str(self.padding)
| 21.941176 | 55 | 0.656836 | 48 | 373 | 4.916667 | 0.479167 | 0.186441 | 0.127119 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.230563 | 373 | 16 | 56 | 23.3125 | 0.8223 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.272727 | false | 0 | 0.272727 | 0.181818 | 0.818182 | 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 | 1 | 0 | 0 | 3 |
4ccd5bafda00358b31ed81736bd695b199f29aff | 54 | py | Python | 2413.py | Brincando-de-codigo/urionlinejudge | 9bba8ba7c714494231c4979487c9efce55901342 | [
"MIT"
] | null | null | null | 2413.py | Brincando-de-codigo/urionlinejudge | 9bba8ba7c714494231c4979487c9efce55901342 | [
"MIT"
] | null | null | null | 2413.py | Brincando-de-codigo/urionlinejudge | 9bba8ba7c714494231c4979487c9efce55901342 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
t = int(input())
print(t * 4) | 13.5 | 23 | 0.481481 | 9 | 54 | 2.888889 | 0.888889 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.046512 | 0.203704 | 54 | 4 | 24 | 13.5 | 0.55814 | 0.388889 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.5 | 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 | 1 | 0 | 3 |
4ce9532d84835930198b2fdf6ff25a02c5a9fca1 | 358 | py | Python | yolo/vedanet/engine/__init__.py | hilman-dayo/ObjectDetection-OneStageDet | 44054ad335e24e99a98fdad0d18b9bf3a80c941c | [
"MIT"
] | 331 | 2020-06-05T05:10:21.000Z | 2022-03-29T07:32:42.000Z | vedanet/engine/__init__.py | xiongcaihua/ObjectDetection-OneStageDet | d29f69cdce32b006bd040edb6e66427b3c987c70 | [
"Apache-2.0"
] | 10 | 2020-06-12T07:53:42.000Z | 2021-05-11T00:09:10.000Z | vedanet/engine/__init__.py | xiongcaihua/ObjectDetection-OneStageDet | d29f69cdce32b006bd040edb6e66427b3c987c70 | [
"Apache-2.0"
] | 84 | 2020-06-05T10:21:11.000Z | 2022-03-27T23:42:44.000Z | """
Lightnet Engine Module |br|
This module contains classes and functions to manage the training of your networks.
It has an engine, capable of orchestrating your training and test cycles, and also contains function to easily visualise data with visdom_.
"""
#from .engine import *
from ._voc_train import *
from ._voc_test import *
from ._speed import *
| 29.833333 | 139 | 0.776536 | 53 | 358 | 5.132075 | 0.660377 | 0.110294 | 0.095588 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.164804 | 358 | 11 | 140 | 32.545455 | 0.909699 | 0.76257 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
4cee6132a118117d6e52ff3408677c769a660ba8 | 448 | py | Python | authors/apps/authentication/tests/test_settings.py | andela/-ah-backend-thor | fe8d49531ccb1adebfea8b0f30ff0ebd172c31ba | [
"BSD-3-Clause"
] | 1 | 2018-11-08T16:47:03.000Z | 2018-11-08T16:47:03.000Z | authors/apps/authentication/tests/test_settings.py | andela/-ah-backend-thor | fe8d49531ccb1adebfea8b0f30ff0ebd172c31ba | [
"BSD-3-Clause"
] | 72 | 2018-10-23T12:34:14.000Z | 2021-06-01T22:50:57.000Z | authors/apps/authentication/tests/test_settings.py | andela/-ah-backend-thor | fe8d49531ccb1adebfea8b0f30ff0ebd172c31ba | [
"BSD-3-Clause"
] | 1 | 2018-10-23T16:18:01.000Z | 2018-10-23T16:18:01.000Z | from ....settings import DATABASES, TEST_RUNNER
from django.test import TestCase
class TestSettingsAndCore(TestCase):
def test_database(self):
checklist = ['ENGINE', 'NAME', 'USER', 'PASSWORD', 'HOST', 'PORT']
self.assertTrue('default' in DATABASES)
self.assertIn([x for x in checklist][0], DATABASES['default'])
def test_test_runner(self):
self.assertTrue('django_nose.NoseTestSuiteRunner', TEST_RUNNER)
| 34.461538 | 74 | 0.696429 | 52 | 448 | 5.884615 | 0.557692 | 0.098039 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002695 | 0.171875 | 448 | 12 | 75 | 37.333333 | 0.822102 | 0 | 0 | 0 | 0 | 0 | 0.167411 | 0.069196 | 0 | 0 | 0 | 0 | 0.333333 | 1 | 0.222222 | false | 0.111111 | 0.222222 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
4cf9c9265a295886c8d95b8fc3125bf4c6565fba | 290 | py | Python | fitsbits/__init__.py | waqasbhatti/fitsbits | 849fcb76d923ee7b91ca3000ff7fd0e2cd5708e7 | [
"MIT"
] | null | null | null | fitsbits/__init__.py | waqasbhatti/fitsbits | 849fcb76d923ee7b91ca3000ff7fd0e2cd5708e7 | [
"MIT"
] | null | null | null | fitsbits/__init__.py | waqasbhatti/fitsbits | 849fcb76d923ee7b91ca3000ff7fd0e2cd5708e7 | [
"MIT"
] | null | null | null | from ._version import get_versions
__version__ = get_versions()['version']
__gitrev__ = get_versions()['full-revisionid'][:7]
del get_versions
# the basic logging styles common to all modules
log_sub = '{'
log_fmt = '[{levelname} {asctime}] {message}'
log_date_fmt = '%Y-%m-%d %H:%M:%S%z'
| 29 | 50 | 0.713793 | 43 | 290 | 4.418605 | 0.72093 | 0.231579 | 0.189474 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003906 | 0.117241 | 290 | 9 | 51 | 32.222222 | 0.738281 | 0.158621 | 0 | 0 | 0 | 0 | 0.309917 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.142857 | 0 | 0.142857 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9816b104e42c67f2047a4e143731c03f7cc92184 | 250 | py | Python | metagraph/tests/test_types.py | eriknw/metagraph-1 | b6a4e92903e7779c31137a765cdb4852245918d2 | [
"Apache-2.0"
] | null | null | null | metagraph/tests/test_types.py | eriknw/metagraph-1 | b6a4e92903e7779c31137a765cdb4852245918d2 | [
"Apache-2.0"
] | null | null | null | metagraph/tests/test_types.py | eriknw/metagraph-1 | b6a4e92903e7779c31137a765cdb4852245918d2 | [
"Apache-2.0"
] | null | null | null | import pytest
from metagraph import types
def test_nodemap_not_implemented():
nodemap = types.NodeMap()
with pytest.raises(NotImplementedError):
nodemap[0]
with pytest.raises(NotImplementedError):
nodemap.num_nodes()
| 17.857143 | 44 | 0.72 | 27 | 250 | 6.518519 | 0.592593 | 0.113636 | 0.181818 | 0.397727 | 0.477273 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005 | 0.2 | 250 | 13 | 45 | 19.230769 | 0.875 | 0 | 0 | 0.25 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.25 | 0 | 0.375 | 0 | 1 | 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 | 3 |
981c619f2f7b98c66f2d9878e6cbf54904292b00 | 2,950 | py | Python | samples/python/13.core-bot/envs/chat_bot_02/Lib/site-packages/datatypes_date_time/timex_inference.py | luzeunice/BotBuilder-Samples | b62be4e8863125a567902b736b7b74313d9d4f28 | [
"MIT"
] | null | null | null | samples/python/13.core-bot/envs/chat_bot_02/Lib/site-packages/datatypes_date_time/timex_inference.py | luzeunice/BotBuilder-Samples | b62be4e8863125a567902b736b7b74313d9d4f28 | [
"MIT"
] | null | null | null | samples/python/13.core-bot/envs/chat_bot_02/Lib/site-packages/datatypes_date_time/timex_inference.py | luzeunice/BotBuilder-Samples | b62be4e8863125a567902b736b7b74313d9d4f28 | [
"MIT"
] | null | null | null | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from .timex_constants import Constants
class TimexInference:
@staticmethod
def infer(obj):
types = set()
if TimexInference.__is_present(obj):
types.add(Constants.TIMEX_TYPES_PRESENT)
if TimexInference.__is_definite(obj):
types.add(Constants.TIMEX_TYPES_DEFINITE)
if TimexInference.__is_date(obj):
types.add(Constants.TIMEX_TYPES_DATE)
if TimexInference.__is_date_range(obj):
types.add(Constants.TIMEX_TYPES_DATERANGE)
if TimexInference.__is_duration(obj):
types.add(Constants.TIMEX_TYPES_DURATION)
if TimexInference.__is_time(obj):
types.add(Constants.TIMEX_TYPES_TIME)
if TimexInference.__is_time_range(obj):
types.add(Constants.TIMEX_TYPES_TIMERANGE)
if Constants.TIMEX_TYPES_PRESENT in types:
types.add(Constants.TIMEX_TYPES_DATE)
types.add(Constants.TIMEX_TYPES_TIME)
if Constants.TIMEX_TYPES_TIME in types and Constants.TIMEX_TYPES_DURATION in types:
types.add(Constants.TIMEX_TYPES_TIMERANGE)
if Constants.TIMEX_TYPES_DATE in types and Constants.TIMEX_TYPES_TIME in types:
types.add(Constants.TIMEX_TYPES_DATETIME)
if Constants.TIMEX_TYPES_DATE in types and Constants.TIMEX_TYPES_DURATION in types:
types.add(Constants.TIMEX_TYPES_DATERANGE)
if Constants.TIMEX_TYPES_DATETIME in types and Constants.TIMEX_TYPES_DURATION in types:
types.add(Constants.TIMEX_TYPES_DATETIMERANGE)
if Constants.TIMEX_TYPES_DATE in types and Constants.TIMEX_TYPES_TIMERANGE in types:
types.add(Constants.TIMEX_TYPES_DATETIMERANGE)
return types
@staticmethod
def __is_present(obj):
return obj.now == True
@staticmethod
def __is_duration(obj):
return (obj.years or obj.months or obj.weeks or
obj.days or obj.hours or obj.minutes or obj.seconds)
@staticmethod
def __is_time(obj):
return obj.hour is not None and obj.minute is not None and obj.second is not None
@staticmethod
def __is_date(obj):
return (obj.month is not None and obj.day_of_month is not None) or obj.day_of_week
@staticmethod
def __is_time_range(obj):
return obj.part_of_day is not None
@staticmethod
def __is_date_range(obj):
return ((obj.year is not None and obj.day_of_month is None) or
(obj.year is not None and obj.month is not None and obj.day_of_month is None) or
(obj.month is not None and obj.day_of_month is None) or
obj.season or obj.week_of_year or obj.week_of_month)
@staticmethod
def __is_definite(obj):
return obj.year is not None and obj.month is not None and obj.day_of_month is not None
| 33.908046 | 96 | 0.690169 | 410 | 2,950 | 4.685366 | 0.15122 | 0.182197 | 0.247267 | 0.160333 | 0.616346 | 0.600729 | 0.51848 | 0.383654 | 0.352421 | 0.339407 | 0 | 0 | 0.246441 | 2,950 | 86 | 97 | 34.302326 | 0.864148 | 0.030169 | 0 | 0.310345 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.137931 | false | 0 | 0.017241 | 0.12069 | 0.310345 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
e218846aa5890b0ebf6f5c03bd566921c9ba7f7c | 502 | py | Python | elastic_agent_setup/api/__init__.py | MSAdministrator/elastic-agent-setup | 5cb8202aaed281f73706556a86657f5525495b56 | [
"MIT"
] | 1 | 2022-02-04T16:59:53.000Z | 2022-02-04T16:59:53.000Z | elastic_agent_setup/api/__init__.py | MSAdministrator/elastic-agent-setup | 5cb8202aaed281f73706556a86657f5525495b56 | [
"MIT"
] | 1 | 2021-07-21T11:30:13.000Z | 2021-11-09T14:30:10.000Z | elastic_agent_setup/api/__init__.py | MSAdministrator/elastic-agent-setup | 5cb8202aaed281f73706556a86657f5525495b56 | [
"MIT"
] | null | null | null | from .check_fleet_setup import CheckFleetSetup
from .check_fleet_agents_setup import CheckFleetAgentsSetup
from .check_service import CheckService
from .create_enrollment_key import CreateEnrollmentKey
from .delete_enrollment_key import DeleteEnrollmentKey
from .get_enrollment_key import GetEnrollmentKey
from .get_enrollment_keys import GetEnrollmentKeys
from .get_fleet_agent_policy_id import GetFleetAgentPolicyId
from .setup_fleet_agents import SetupFleetAgents
from .setup_fleet import SetupFleet | 50.2 | 60 | 0.90239 | 61 | 502 | 7.081967 | 0.42623 | 0.0625 | 0.131944 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.077689 | 502 | 10 | 61 | 50.2 | 0.933045 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
e25944edd26286dda7834c2a3c79d42ec43758c0 | 2,056 | py | Python | flask_assistant/manager.py | modi975/flask-assistant | 0d1807eb9098ed529f329b158a3735bd7786960d | [
"Apache-2.0"
] | null | null | null | flask_assistant/manager.py | modi975/flask-assistant | 0d1807eb9098ed529f329b158a3735bd7786960d | [
"Apache-2.0"
] | null | null | null | flask_assistant/manager.py | modi975/flask-assistant | 0d1807eb9098ed529f329b158a3735bd7786960d | [
"Apache-2.0"
] | null | null | null |
class Context(dict):
"""docstring for _Context"""
def __init__(self, name, parameters={}, lifespan=5):
self.name = name
self.parameters = parameters
self.lifespan = lifespan
# def __getattr__(self, param):
# if param in ['name', 'parameters', 'lifespan']:
# return getattr(self, param)
# return self.parameters[param]
def set(self, param_name, value):
self.parameters[param_name] = value
def get(self, param):
return self.parameters.get(param)
def sync(self, context_json):
self.__dict__.update(context_json)
def __repr__(self):
return self.name
@property
def serialize(self):
return {"name": self.name, "lifespan": self.lifespan, "parameters": self.parameters}
class ContextManager():
def __init__(self):
self._cache = {}
def add(self, *args, **kwargs):
context = Context(*args, **kwargs)
self._cache[context.name] = context
return context
def get(self, context_name, default=None):
return self._cache.get(context_name, default)
def set(self, context_name, param, val):
context = self.get(context_name)
context.set(param, val)
return context
def get_param(self, context_name, param):
return self._cache[context_name].parameters[param]
def update(self, contexts_json):
for obj in contexts_json:
context = Context(obj['name']) # TODO
context.lifespan = obj['lifespan']
context.parameters = obj['parameters']
self._cache[context.name] = context
@property
def status(self):
return {
'Active contexts': self.active,
'Expired contexts': self.expired,
}
@property
def active(self):
return [self._cache[c] for c in self._cache if self._cache[c].lifespan > 0]
@property
def expired(self):
return [self._cache[c] for c in self._cache if self._cache[c].lifespan == 0]
| 24.47619 | 92 | 0.605545 | 238 | 2,056 | 5.042017 | 0.176471 | 0.0825 | 0.05 | 0.05 | 0.186667 | 0.093333 | 0.093333 | 0.093333 | 0.093333 | 0.093333 | 0 | 0.002017 | 0.276751 | 2,056 | 83 | 93 | 24.771084 | 0.804976 | 0.087549 | 0 | 0.163265 | 0 | 0 | 0.040279 | 0 | 0 | 0 | 0 | 0.012048 | 0 | 1 | 0.306122 | false | 0 | 0 | 0.163265 | 0.55102 | 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 | 1 | 0 | 0 | 0 | 3 |
e26553c04cafa5848c91fe927e2f045d42674ceb | 806 | py | Python | airbnb/random_request.py | agroszer/airbnb-python | 7a8d343877c673e9db42f25647e678266655af09 | [
"WTFPL"
] | null | null | null | airbnb/random_request.py | agroszer/airbnb-python | 7a8d343877c673e9db42f25647e678266655af09 | [
"WTFPL"
] | null | null | null | airbnb/random_request.py | agroszer/airbnb-python | 7a8d343877c673e9db42f25647e678266655af09 | [
"WTFPL"
] | null | null | null | import random
import uuid
import os
class RandomRequest(object):
def __init__(self):
pass
def get_random_user_agent(self):
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'files/supported_ios_versions.txt')) as f:
ios_versions = f.read().splitlines()
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'files/airbnb_versions.txt')) as f:
airbnb_versions = f.read().splitlines()
return "Airbnb/{} iPhone/{} Type/Phone".format(random.choice(airbnb_versions), random.choice(ios_versions))
def get_random_udid(self):
hex_digits = "0123456789abcdef"
return ''.join(random.choice(hex_digits) for _ in range(40))
def get_random_uuid(self):
return str(uuid.uuid4()).upper()
| 32.24 | 118 | 0.676179 | 108 | 806 | 4.777778 | 0.444444 | 0.069767 | 0.069767 | 0.054264 | 0.209302 | 0.209302 | 0.209302 | 0.209302 | 0.209302 | 0.209302 | 0 | 0.019878 | 0.188586 | 806 | 24 | 119 | 33.583333 | 0.769113 | 0 | 0 | 0 | 0 | 0 | 0.127792 | 0.07072 | 0 | 0 | 0 | 0 | 0 | 1 | 0.235294 | false | 0.058824 | 0.176471 | 0.058824 | 0.647059 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
e2762a4f1be918db3a2835ab9f8a0611f2920374 | 713 | py | Python | apps/core/logic/url.py | techlib/celus | f32a7a22be5f4613dcac10b8e02c5c5a9bc297cb | [
"MIT"
] | 7 | 2020-02-20T13:24:40.000Z | 2022-01-28T19:36:04.000Z | apps/core/logic/url.py | techlib/celus | f32a7a22be5f4613dcac10b8e02c5c5a9bc297cb | [
"MIT"
] | 15 | 2020-04-28T13:09:02.000Z | 2021-11-03T15:21:24.000Z | apps/core/logic/url.py | techlib/celus | f32a7a22be5f4613dcac10b8e02c5c5a9bc297cb | [
"MIT"
] | 4 | 2020-02-20T13:48:30.000Z | 2021-03-19T00:33:34.000Z | def extract_organization_id_from_request_query(request):
return request.query_params.get('organization') or request.query_params.get('organization_id')
def extract_organization_id_from_request_data(request) -> (int, bool):
"""
Returns the organization id from the request.data and a bool indicating if the key
was present in the data (to distinguish between missing data and empty input value)
:param request:
:return:
"""
for source in (request.data, request.GET):
if 'organization' in source:
return source.get('organization'), True
if 'organization_id' in request.data:
return source.get('organization_id'), True
return None, False
| 39.611111 | 98 | 0.71108 | 94 | 713 | 5.234043 | 0.393617 | 0.170732 | 0.109756 | 0.097561 | 0.276423 | 0.142276 | 0 | 0 | 0 | 0 | 0 | 0 | 0.201964 | 713 | 17 | 99 | 41.941176 | 0.864675 | 0.267882 | 0 | 0 | 0 | 0 | 0.163968 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0 | 0.111111 | 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 | 1 | 1 | 0 | 0 | 3 |
e2878546ecd26dc52a42fd3584c9df95fb67ca7f | 141 | py | Python | backend/server/user/urls.py | munteanugabriel25/Javascript-RestApiDjango-FoodDelievery | 0a362cc48ae0c8435f0d89f7c352b325995f9098 | [
"Unlicense"
] | null | null | null | backend/server/user/urls.py | munteanugabriel25/Javascript-RestApiDjango-FoodDelievery | 0a362cc48ae0c8435f0d89f7c352b325995f9098 | [
"Unlicense"
] | null | null | null | backend/server/user/urls.py | munteanugabriel25/Javascript-RestApiDjango-FoodDelievery | 0a362cc48ae0c8435f0d89f7c352b325995f9098 | [
"Unlicense"
] | null | null | null | from django.urls import path, include
from .views import UserLoginApiView
urlpatterns = [
path('login/', UserLoginApiView.as_view()),
]
| 20.142857 | 47 | 0.744681 | 16 | 141 | 6.5 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.141844 | 141 | 6 | 48 | 23.5 | 0.859504 | 0 | 0 | 0 | 0 | 0 | 0.042553 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
e2a2f7e7a11875ed2aadb5258de28b87bb340ab3 | 244 | py | Python | curso-python/cursoemvideo/ex41aula12.py | RoSapia/Python-curso-em-video | a691aefa879d55af3a084e78f0a3c8ad8490fc22 | [
"MIT"
] | null | null | null | curso-python/cursoemvideo/ex41aula12.py | RoSapia/Python-curso-em-video | a691aefa879d55af3a084e78f0a3c8ad8490fc22 | [
"MIT"
] | null | null | null | curso-python/cursoemvideo/ex41aula12.py | RoSapia/Python-curso-em-video | a691aefa879d55af3a084e78f0a3c8ad8490fc22 | [
"MIT"
] | null | null | null | '''A confederação nacional de natacao precisa de um programa que leia o ano de nascimento de um atleta
e mostre sua categoria, de acordo com a idade
até 9 anos> MIRIM
até 14 anos: INFANTIL
até 19 anos JUNIOR
até 20 anos SENIOR
acima: MASTER''' | 34.857143 | 102 | 0.77459 | 45 | 244 | 4.2 | 0.733333 | 0.042328 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.035176 | 0.184426 | 244 | 7 | 103 | 34.857143 | 0.914573 | 0.97541 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
e2b5f9d54375407b636ca85a9ebc974666f05965 | 1,819 | py | Python | test_src/Pages/HomePage.py | BJanos87/Vizsgaremek-conduit-app | 1ffb309389b0cbe68aca56bfde50ba8b17219d03 | [
"MIT"
] | null | null | null | test_src/Pages/HomePage.py | BJanos87/Vizsgaremek-conduit-app | 1ffb309389b0cbe68aca56bfde50ba8b17219d03 | [
"MIT"
] | null | null | null | test_src/Pages/HomePage.py | BJanos87/Vizsgaremek-conduit-app | 1ffb309389b0cbe68aca56bfde50ba8b17219d03 | [
"MIT"
] | null | null | null | from test_src.Pages.base_commands import BaseCommands
from test_src.Data.test_data import HomePgWebElements
from test_src.Data.test_data import TestData
class HomePage(BaseCommands):
"""constructor of the page class"""
def __init__(self, driver):
super().__init__(driver)
self.get_url(TestData.BASE_URL)
"""Page Actions for Home Page"""
"""this used to reload Home Page"""
def reload_home_page(self):
self.driver.get(TestData.BASE_URL)
"""this used to get the current page url"""
def get_home_page_url(self):
return self.get_current_url()
"""this used to get the current page title"""
def get_home_page_title(self):
return self.get_current_title()
"""this used to get list of the cookies from Home Page"""
def get_cookie_status_from_homepage(self):
return len(self.get_cookies_list())
"""this used to check value of the cookie"""
def check_value_cookie_from_homepage(self):
cookie = self.check_value_cookie()
return cookie["value"]
"""this used to click on cookie accept button on Home Page"""
def click_cookie_accept_btn(self):
self.do_click(HomePgWebElements.cookie_accept_btn)
"""this used to check sign up button is displayed"""
def is_sign_up_btn_displayed(self):
return self.is_element_displayed(HomePgWebElements.sign_up_btn)
"""this used to sign up to app"""
def click_sign_up_btn(self):
self.do_click(HomePgWebElements.sign_up_btn)
"""this used to check sign in button is displayed"""
def is_sign_in_btn_displayed(self):
return self.is_element_displayed(HomePgWebElements.sign_in_btn)
"""this used to sign in to app"""
def click_sign_in_btn(self):
return self.do_click(HomePgWebElements.sign_in_btn)
| 33.072727 | 71 | 0.708081 | 267 | 1,819 | 4.543071 | 0.202247 | 0.065952 | 0.08244 | 0.042869 | 0.469909 | 0.358615 | 0.246496 | 0.156636 | 0.107172 | 0.107172 | 0 | 0 | 0.19956 | 1,819 | 54 | 72 | 33.685185 | 0.833104 | 0.015943 | 0 | 0 | 0 | 0 | 0.003855 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.392857 | false | 0 | 0.107143 | 0.214286 | 0.785714 | 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 | 1 | 0 | 0 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.