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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6844d6657f29dcfdc01894ebb8b0d377e067b664 | 489 | py | Python | tests/test_charm.py | mthaddon/concourse-worker-operator | 061afe3566ae3b0c40853e242111189fd82bf68d | [
"Apache-2.0"
] | 3 | 2021-06-18T07:46:05.000Z | 2021-07-07T22:30:38.000Z | tests/test_charm.py | mthaddon/concourse-worker-operator | 061afe3566ae3b0c40853e242111189fd82bf68d | [
"Apache-2.0"
] | 1 | 2021-06-18T07:05:40.000Z | 2022-01-20T07:52:25.000Z | tests/test_charm.py | mthaddon/concourse-worker-operator | 061afe3566ae3b0c40853e242111189fd82bf68d | [
"Apache-2.0"
] | null | null | null | # Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
#
# Learn more about testing at: https://juju.is/docs/sdk/testing
import unittest
from unittest.mock import Mock
from charm import ConcourseOperatorCharm
from ops.model import ActiveStatus
from ops.testing import Harness
class TestCharm(unittest.TestCase):
def setUp(self):
self.harness = Harness(ConcourseWebOperatorCharm)
self.addCleanup(self.harness.cleanup)
self.harness.begin()
| 25.736842 | 63 | 0.762781 | 61 | 489 | 6.114754 | 0.655738 | 0.088472 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009756 | 0.161554 | 489 | 18 | 64 | 27.166667 | 0.9 | 0.267894 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0 | 0.5 | 0 | 0.7 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
6845f91f472a4dd0b1004e5c62f551726c007721 | 355 | py | Python | app/serializers.py | Veena-1297/nimapinfotech | 96512e09fd27a9553854c070da7164a1b82d09a1 | [
"MIT"
] | null | null | null | app/serializers.py | Veena-1297/nimapinfotech | 96512e09fd27a9553854c070da7164a1b82d09a1 | [
"MIT"
] | null | null | null | app/serializers.py | Veena-1297/nimapinfotech | 96512e09fd27a9553854c070da7164a1b82d09a1 | [
"MIT"
] | null | null | null | from rest_framework.serializers import ModelSerializer
from app.models import Project, Client
class ProjectSerializer(ModelSerializer):
class Meta:
model = Project
depth = 2
fields = '__all__'
class ClientSerializer(ModelSerializer):
class Meta:
model = Client
depth = 2
fields = '__all__'
| 16.136364 | 54 | 0.659155 | 34 | 355 | 6.617647 | 0.558824 | 0.177778 | 0.213333 | 0.257778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007843 | 0.28169 | 355 | 21 | 55 | 16.904762 | 0.87451 | 0 | 0 | 0.5 | 0 | 0 | 0.03966 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
685c40dd42d9ea205417c61957c3ff20401777b8 | 3,113 | py | Python | brain_brew/utils.py | aplaice/brain-brew | 2a3bc51ed593de02f10b91d4e72949f49225731d | [
"Unlicense"
] | null | null | null | brain_brew/utils.py | aplaice/brain-brew | 2a3bc51ed593de02f10b91d4e72949f49225731d | [
"Unlicense"
] | null | null | null | brain_brew/utils.py | aplaice/brain-brew | 2a3bc51ed593de02f10b91d4e72949f49225731d | [
"Unlicense"
] | null | null | null | import logging
import os
import random
import re
import string
from pathlib import Path
from typing import List
def blank_str_if_none(s):
return '' if s is None else s
def list_of_str_to_lowercase(list_of_strings):
return [entry.lower() for entry in list_of_strings]
def single_item_to_list(item):
if isinstance(item, list):
return item
if item is None:
return []
return [item]
def str_to_lowercase_no_separators(str_to_tidy: str):
return re.sub(r'[\s+_-]+', '', str_to_tidy.lower())
def filename_from_full_path(full_path):
return re.findall(r'[^\\/:*?"<>|\r\n]+$', full_path)[0]
def find_media_in_field(field_value: str) -> List[str]:
if not field_value:
return []
images = re.findall(r'<\s*?img.*?src="(.*?)"[^>]*?>', field_value)
audio = re.findall(r'\[sound:(.*?)]', field_value)
return images + audio
def find_all_files_in_directory(directory, recursive=False):
found_files = []
for path, dirs, files in os.walk(directory):
for file in files:
found_files.append(os.path.join(path, file))
if not recursive:
return found_files
return found_files
def create_path_if_not_exists(path):
dir_name = os.path.dirname(path)
if not Path(dir_name).is_dir():
logging.warning(f"Creating missing filepath '{dir_name}'")
os.makedirs(dir_name, exist_ok=True)
def split_tags(tags_value: str) -> list:
split = [entry.strip() for entry in re.split(r';\s*|,\s*|\s+', tags_value)]
while "" in split:
split.remove("")
return split
def join_tags(tags_list: list) -> str:
from brain_brew.configuration.global_config import GlobalConfig
return GlobalConfig.get_instance().join_values_with.join(tags_list)
def generate_anki_guid() -> str:
"""Return a base91-encoded 64bit random number."""
def base62(num: int, extra: str = "") -> str:
s = string
table = s.ascii_letters + s.digits + extra
buf = ""
while num:
num, i = divmod(num, len(table))
buf = table[i] + buf
return buf
_base91_extra_chars = "!#$%&()*+,-./:;<=>?@[]^_`{|}~"
def base91(num: int) -> str:
# all printable characters minus quotes, backslash and separators
return base62(num, _base91_extra_chars)
return base91(random.randint(0, 2 ** 64 - 1))
def sort_dict(data, sort_by_keys, reverse_sort, case_insensitive_sort=None):
from brain_brew.configuration.global_config import GlobalConfig
if case_insensitive_sort is None:
case_insensitive_sort = GlobalConfig.get_instance().sort_case_insensitive
if sort_by_keys:
if case_insensitive_sort:
def sort_method(i):
return tuple((i[column] == "", i[column].lower()) for column in sort_by_keys)
else:
def sort_method(i):
return tuple((i[column] == "", i[column]) for column in sort_by_keys)
return sorted(data, key=sort_method, reverse=reverse_sort)
elif reverse_sort:
return list(reversed(data))
return data
| 27.794643 | 93 | 0.647607 | 434 | 3,113 | 4.410138 | 0.315668 | 0.039185 | 0.020899 | 0.022989 | 0.121212 | 0.121212 | 0.099269 | 0.099269 | 0.040752 | 0.040752 | 0 | 0.009125 | 0.225506 | 3,113 | 111 | 94 | 28.045045 | 0.784737 | 0.035014 | 0 | 0.105263 | 0 | 0 | 0.050033 | 0.019346 | 0 | 0 | 0 | 0 | 0 | 1 | 0.210526 | false | 0 | 0.118421 | 0.092105 | 0.605263 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
686a18f2050eb80bfc93a0b38e351a577765254d | 266 | py | Python | tests/testing/test_utils.py | yaal-fr/sheraf | 9821a53d8b0ea0aba420175e4cfa81529262f88c | [
"MIT"
] | 1 | 2020-03-18T09:54:52.000Z | 2020-03-18T09:54:52.000Z | tests/testing/test_utils.py | yaal-fr/sheraf | 9821a53d8b0ea0aba420175e4cfa81529262f88c | [
"MIT"
] | null | null | null | tests/testing/test_utils.py | yaal-fr/sheraf | 9821a53d8b0ea0aba420175e4cfa81529262f88c | [
"MIT"
] | null | null | null | import pytest
import sheraf
from tests.utils import close_database
def test_close_database():
db = sheraf.Database()
assert db == sheraf.Database.get()
close_database(db)
with pytest.raises(KeyError):
assert sheraf.Database.get() is None
| 19 | 44 | 0.714286 | 35 | 266 | 5.314286 | 0.514286 | 0.209677 | 0.16129 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.195489 | 266 | 13 | 45 | 20.461538 | 0.869159 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.222222 | 1 | 0.111111 | false | 0 | 0.333333 | 0 | 0.444444 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
6874e01756f957101a572590dd90452bcccffc45 | 177 | py | Python | src/model_type.py | MatthewATaylor/COVID-19-Chest-X-Ray-Classifier | b9bdc5cdfdb5e1c7a38d7334f02fc60b1264576e | [
"MIT"
] | 1 | 2020-08-03T14:02:29.000Z | 2020-08-03T14:02:29.000Z | src/model_type.py | MatthewATaylor/COVID-19-Chest-X-Ray-Classifier | b9bdc5cdfdb5e1c7a38d7334f02fc60b1264576e | [
"MIT"
] | null | null | null | src/model_type.py | MatthewATaylor/COVID-19-Chest-X-Ray-Classifier | b9bdc5cdfdb5e1c7a38d7334f02fc60b1264576e | [
"MIT"
] | null | null | null | from enum import Enum
class ModelType(Enum):
"""
An enum for describing the type of model to
generate
"""
CUSTOM = 1
XCEPTION = 2
INCEPTION_V3 = 3
| 14.75 | 47 | 0.610169 | 24 | 177 | 4.458333 | 0.875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033333 | 0.322034 | 177 | 11 | 48 | 16.090909 | 0.858333 | 0.293785 | 0 | 0 | 1 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
6883c01d96ed5397b9dc9cda520f4fbe1c74265e | 6,401 | py | Python | docs/source/_static/zzz_GENERATED_NOTEBOOK_SOURCE/readme/4_vep.py | a0x8o/glow | 8dd0c4d11fe4fb1b774e70b42b3ac3eab9d46cdd | [
"Apache-2.0"
] | 1 | 2021-09-16T17:19:48.000Z | 2021-09-16T17:19:48.000Z | docs/source/_static/zzz_GENERATED_NOTEBOOK_SOURCE/readme/4_vep.py | a0x8o/glow | 8dd0c4d11fe4fb1b774e70b42b3ac3eab9d46cdd | [
"Apache-2.0"
] | null | null | null | docs/source/_static/zzz_GENERATED_NOTEBOOK_SOURCE/readme/4_vep.py | a0x8o/glow | 8dd0c4d11fe4fb1b774e70b42b3ac3eab9d46cdd | [
"Apache-2.0"
] | null | null | null | # Databricks notebook source
# MAGIC %md
# MAGIC ##<img src="https://databricks.com/wp-content/themes/databricks/assets/images/databricks-logo.png" alt="logo" width="240"/>
# MAGIC ### <img src="https://databricks-knowledge-repo-images.s3.us-east-2.amazonaws.com/HLS/glow/project_glow_logo.png" alt="logo" width="35"/> Glow Technical Guide
# MAGIC
# MAGIC ##### Install the variant effect predictor ([VEP](https://github.com/Ensembl/ensembl-vep)) with [Databricks container services](https://docs.databricks.com/clusters/custom-containers.html)
# COMMAND ----------
# MAGIC %md
# MAGIC ##### From your laptop build and push Dockerfile
# COMMAND ----------
# MAGIC %md
# MAGIC ```
# MAGIC cd vep
# MAGIC docker build -f Dockerfile .
# MAGIC docker build -t projectglow/vep .
# MAGIC docker push projectglow/vep:latest
# MAGIC ```
# COMMAND ----------
# MAGIC %md
# MAGIC Find the latest version of this Docker container at,
# MAGIC
# MAGIC https://hub.docker.com/r/projectglow/vep
# COMMAND ----------
# MAGIC %md
# MAGIC Dockerfile
# COMMAND ----------
# MAGIC %md
# MAGIC ```
# MAGIC FROM databricksruntime/standard:latest
# MAGIC
# MAGIC ARG DEBIAN_FRONTEND=noninteractive
# MAGIC
# MAGIC ENV TZ=America/New_York
# MAGIC
# MAGIC RUN apt-get update && apt-get install -y \
# MAGIC build-essential \
# MAGIC git \
# MAGIC apt-transport-https \
# MAGIC ca-certificates \
# MAGIC cpanminus \
# MAGIC libpng-dev \
# MAGIC zlib1g-dev \
# MAGIC libbz2-dev \
# MAGIC liblzma-dev \
# MAGIC perl \
# MAGIC perl-base \
# MAGIC unzip \
# MAGIC curl \
# MAGIC gnupg2 \
# MAGIC software-properties-common \
# MAGIC jq \
# MAGIC libjemalloc1 \
# MAGIC libjemalloc-dev \
# MAGIC libdbi-perl \
# MAGIC libdbd-mysql-perl \
# MAGIC libdbd-sqlite3-perl
# MAGIC # ===== Set up VEP environment =====================================================================
# MAGIC ENV OPT_SRC /opt/vep/src
# MAGIC
# MAGIC ENV PERL5LIB $PERL5LIB:$OPT_SRC/ensembl-vep:$OPT_SRC/ensembl-vep/modules
# MAGIC RUN cpanm DBI && \
# MAGIC cpanm Set::IntervalTree && \
# MAGIC cpanm JSON && \
# MAGIC cpanm Text::CSV && \
# MAGIC cpanm Module::Build && \
# MAGIC cpanm PerlIO::gzip && \
# MAGIC cpanm IO::Uncompress::Gunzip
# MAGIC
# MAGIC RUN mkdir -p $OPT_SRC
# MAGIC
# MAGIC WORKDIR $OPT_SRC
# MAGIC
# MAGIC RUN git clone https://github.com/Ensembl/ensembl-vep.git WORKDIR ensembl-vep
# MAGIC
# MAGIC # The commit is the most recent one on release branch 100 as of July 29, 2020
# MAGIC RUN git checkout 10932fab1e9c113e8e5d317e1f668413390344ac && \
# MAGIC perl INSTALL.pl --NO_UPDATE -AUTO a && \
# MAGIC perl INSTALL.pl -n -a p --PLUGINS AncestralAllele && \
# MAGIC chmod +x vep
# MAGIC ```
# COMMAND ----------
# MAGIC %md
# MAGIC Go to your DockerHub page and you will see the repository ([example](https://hub.docker.com/r/projectglow/vep))
# MAGIC
# MAGIC Now, set up a cluster on the demo shard with the Docker Image URL
# MAGIC
# MAGIC <img src="https://databricks-knowledge-repo-images.s3.us-east-2.amazonaws.com/HLS/glow/vep_docker_container_cluster.png" alt="logo" width="700"/>
# COMMAND ----------
# MAGIC %md
# MAGIC Or Create Cluster using API:
# COMMAND ----------
# MAGIC %md
# MAGIC ##### Amazon Web Services (AWS)
# COMMAND ----------
# MAGIC %md
# MAGIC `curl -X POST -H "Authorization: Bearer <insert_token>" -d @create_cluster_dcs_vep_aws.json`
# MAGIC `https://<insert_workspace>.cloud.databricks.com/api/2.0/clusters/create`
# COMMAND ----------
# MAGIC %md
# MAGIC create_cluster_dcs_vep_aws.json
# COMMAND ----------
# MAGIC %md
# MAGIC ```
# MAGIC {
# MAGIC "cluster_name": "vep-glow",
# MAGIC "spark_version": "7.3.x-scala2.12",
# MAGIC "num_workers": 1,
# MAGIC "node_type_id": "i3.xlarge",
# MAGIC "driver_node_type_id": "i3.xlarge",
# MAGIC "autotermination_minutes": 60,
# MAGIC "enable_elastic_disk": true,
# MAGIC "docker_image": {
# MAGIC "url": "projectglow/vep:latest"
# MAGIC },
# MAGIC "aws_attributes": {
# MAGIC "first_on_demand": 1,
# MAGIC "availability": "SPOT_WITH_FALLBACK",
# MAGIC "spot_bid_price_percent": 100,
# MAGIC "zone_id": "us-west-2a"
# MAGIC }
# MAGIC }
# MAGIC ```
# COMMAND ----------
# MAGIC %md
# MAGIC Cluster creation will return the cluster_id, now layer on libraries to this cluster,
# MAGIC
# MAGIC Example cluster_id: `0510-162907-upped13`
# COMMAND ----------
# MAGIC %md
# MAGIC `curl -X POST -H "Authorization: Bearer <insert_token>" -d @install_glow.json` `https://<insert_workspace>.cloud.databricks.com/api/2.0/libraries/install`
# COMMAND ----------
# MAGIC %md
# MAGIC install_glow.json
# COMMAND ----------
# MAGIC %md
# MAGIC ```
# MAGIC {
# MAGIC "cluster_id": "<cluster_id>",
# MAGIC "libraries": [
# MAGIC {
# MAGIC "pypi": {
# MAGIC "package": "bioinfokit==0.8.5"
# MAGIC }
# MAGIC },
# MAGIC {
# MAGIC "pypi": {
# MAGIC "package": "glow.py==1.0.1"
# MAGIC }
# MAGIC },
# MAGIC {
# MAGIC "maven": {
# MAGIC "coordinates": "io.projectglow:glow-spark3_2.12:1.0.1"
# MAGIC }
# MAGIC }
# MAGIC ]
# MAGIC }
# MAGIC ```
# COMMAND ----------
# MAGIC %md
# MAGIC ##### Microsoft Azure
# MAGIC
# MAGIC Example `workspace`: adb-984763964297111.12
# COMMAND ----------
# MAGIC %md
# MAGIC `curl -X POST -H "Authorization: Bearer <insert_token>" -d @create_cluster_dcs_vep_azure.json`
# MAGIC `https://<insert_workspace>.azuredatabricks.net/api/2.0/clusters/create`
# COMMAND ----------
# MAGIC %md
# MAGIC create_cluster_dcs_vep_azure.json
# COMMAND ----------
# MAGIC %md
# MAGIC ```
# MAGIC {
# MAGIC "cluster_name": "vep-glow",
# MAGIC "spark_version": "7.3.x-scala2.12",
# MAGIC "num_workers": 1,
# MAGIC "node_type_id": "Standard_F8s_v2",
# MAGIC "autotermination_minutes": 60,
# MAGIC "enable_elastic_disk": true,
# MAGIC "docker_image": {
# MAGIC "url": "projectglow/vep:latest"
# MAGIC },
# MAGIC "azure_attributes": {
# MAGIC "first_on_demand": 1,
# MAGIC "availability": "SPOT_WITH_FALLBACK_AZURE",
# MAGIC "spot_bid_max_price": -1
# MAGIC }
# MAGIC }
# MAGIC ```
# COMMAND ----------
# MAGIC %md
# MAGIC ##### _Coming Soon_ Google Cloud Platform (GCP)
| 27.472103 | 196 | 0.63037 | 808 | 6,401 | 4.888614 | 0.315594 | 0.098734 | 0.063797 | 0.096203 | 0.441013 | 0.391899 | 0.345063 | 0.293924 | 0.283797 | 0.263291 | 0 | 0.025353 | 0.192782 | 6,401 | 232 | 197 | 27.590517 | 0.739114 | 0.928605 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
6887be76a1ea97305cd4e0a752eba15ccd94f0c6 | 1,973 | py | Python | galaxy/main/models/task.py | bmclaughlin/galaxy | 3f57e3684c27cb88d45881eaec16dc3095ac4e6d | [
"Apache-2.0"
] | 904 | 2016-10-11T13:35:19.000Z | 2022-03-25T09:29:09.000Z | galaxy/main/models/task.py | bmclaughlin/galaxy | 3f57e3684c27cb88d45881eaec16dc3095ac4e6d | [
"Apache-2.0"
] | 1,866 | 2016-10-15T21:28:09.000Z | 2022-03-29T18:09:20.000Z | galaxy/main/models/task.py | bmclaughlin/galaxy | 3f57e3684c27cb88d45881eaec16dc3095ac4e6d | [
"Apache-2.0"
] | 368 | 2016-10-11T13:44:08.000Z | 2022-03-30T02:23:12.000Z | # (c) 2012-2019, Ansible by Red Hat
#
# This file is part of Ansible Galaxy
#
# Ansible Galaxy is free software: you can redistribute it and/or modify
# it under the terms of the Apache License as published by
# the Apache Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Ansible Galaxy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Apache License for more details.
#
# You should have received a copy of the Apache License
# along with Galaxy. If not, see <http://www.apache.org/licenses/>.
import rq.job
from django.db import models
from django.contrib.postgres import fields as psql_fields
from pulpcore.app import models as pulp_models
class Task(models.Model):
"""
Generic table for handing tasks.
:var params: Task parameters json dictionary
:var result: Task result json dictionary
"""
params = psql_fields.JSONField(null=True)
result = psql_fields.JSONField(null=True)
pulp_task = models.OneToOneField(
pulp_models.Task, on_delete=models.CASCADE,
related_name='galaxy_task'
)
@property
def job_id(self):
return self.pulp_task.job_id
@property
def state(self):
return self.pulp_task.state
@property
def started_at(self):
return self.pulp_task.started_at
@property
def finished_at(self):
return self.pulp_task.finished_at
@property
def warnings(self):
return self.pulp_task.non_fatal_errors
@property
def error(self):
return self.pulp_task.error
@classmethod
def current(cls):
job = rq.job.get_current_job()
if job is None:
raise RuntimeError(
'This function is called outside of task context.'
)
return cls.objects.get(pulp_task__job_id=job.id)
| 27.027397 | 72 | 0.693867 | 280 | 1,973 | 4.785714 | 0.471429 | 0.047761 | 0.062687 | 0.080597 | 0.141791 | 0.035821 | 0 | 0 | 0 | 0 | 0 | 0.005956 | 0.234161 | 1,973 | 72 | 73 | 27.402778 | 0.880874 | 0.388748 | 0 | 0.162162 | 0 | 0 | 0.050557 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.189189 | false | 0 | 0.108108 | 0.162162 | 0.594595 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
6893f12b03bde009d02aa2122f6412042bc80cb0 | 488 | py | Python | apps/fhir/bluebutton/admin.py | dtisza1/bluebutton-web-server | 6322f28d75bd9e00f8dc4b5988a0cd5f7c6c80cb | [
"Apache-2.0"
] | null | null | null | apps/fhir/bluebutton/admin.py | dtisza1/bluebutton-web-server | 6322f28d75bd9e00f8dc4b5988a0cd5f7c6c80cb | [
"Apache-2.0"
] | null | null | null | apps/fhir/bluebutton/admin.py | dtisza1/bluebutton-web-server | 6322f28d75bd9e00f8dc4b5988a0cd5f7c6c80cb | [
"Apache-2.0"
] | null | null | null | from apps.fhir.bluebutton.models import Crosswalk
from django.contrib import admin
class CrosswalkAdmin(admin.ModelAdmin):
list_display = ('get_user_username', 'fhir_id')
search_fields = ('user__username', '_fhir_id')
raw_id_fields = ("user", )
def get_user_username(self, obj):
return obj.user.username
get_user_username.admin_order_field = "username"
get_user_username.short_description = "User Name"
admin.site.register(Crosswalk, CrosswalkAdmin)
| 27.111111 | 53 | 0.747951 | 62 | 488 | 5.564516 | 0.532258 | 0.208696 | 0.173913 | 0.104348 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.151639 | 488 | 17 | 54 | 28.705882 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0.137295 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0 | 0.181818 | 0.090909 | 0.727273 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
6894037cb1fc9939d80cc788c17c74692f71cf60 | 845 | py | Python | py/2016/23B.py | pedrotari7/advent_of_code | 98d5bc8d903435624a019a5702f5421d7b4ef8c8 | [
"MIT"
] | null | null | null | py/2016/23B.py | pedrotari7/advent_of_code | 98d5bc8d903435624a019a5702f5421d7b4ef8c8 | [
"MIT"
] | null | null | null | py/2016/23B.py | pedrotari7/advent_of_code | 98d5bc8d903435624a019a5702f5421d7b4ef8c8 | [
"MIT"
] | null | null | null | with open('23B.in','r') as f:
insts = [s.split() for s in f]
p = 0
r = {'a':12,'b':0,'c':0,'d':0}
def get_value(v):
try: return int(v)
except: return r[v]
while p < len(insts) and p >= 0:
inst = insts[p][0]
if inst == 'tgl':
n_p = p+int(r[insts[p][1]])
if n_p < len(insts) and n_p >= 0:
if len(insts[n_p]) == 2:
insts[n_p][0] = 'dec' if insts[n_p][0] == 'inc' else 'inc'
elif len(insts[n_p]) == 3:
insts[n_p][0] = 'cpy' if insts[n_p][0] == 'jnz' else 'jnz'
if inst == 'cpy':
r[insts[p][2]] = get_value(insts[p][1])
elif inst == 'dec':
r[insts[p][1]] -= 1
elif inst == 'inc':
r[insts[p][1]] += 1
elif inst == 'mul':
r[insts[p][3]] += get_value(insts[p][1])*get_value(insts[p][2])
elif inst == 'jnz':
if get_value(insts[p][1]) != 0:
p += get_value(insts[p][2])
continue
p+=1
print r['a']
| 22.236842 | 66 | 0.526627 | 173 | 845 | 2.485549 | 0.260116 | 0.153488 | 0.097674 | 0.162791 | 0.3 | 0.07907 | 0.07907 | 0 | 0 | 0 | 0 | 0.046547 | 0.211834 | 845 | 37 | 67 | 22.837838 | 0.599099 | 0 | 0 | 0 | 0 | 0 | 0.056805 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.033333 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
68b1e9e285cfb5ef18d40584290c76ea91b91dfe | 1,150 | py | Python | recipe_scrapers/taste.py | jhylands/recipe-scrapers | ad35af57c68c01717dda294527dd03f8443dd819 | [
"MIT"
] | null | null | null | recipe_scrapers/taste.py | jhylands/recipe-scrapers | ad35af57c68c01717dda294527dd03f8443dd819 | [
"MIT"
] | null | null | null | recipe_scrapers/taste.py | jhylands/recipe-scrapers | ad35af57c68c01717dda294527dd03f8443dd819 | [
"MIT"
] | null | null | null | from ._abstract import AbstractScraper
from ._utils import get_minutes, normalize_string
class Taste(AbstractScraper):
@classmethod
def host(self):
return ['taste.com.au']
def title(self):
return self.soup.find('h1').get_text()
def ingredients(self):
ingredients_html = self.soup.findAll('div', {'class': 'ingredient-description'})
return [
normalize_string(ingredient.get_text())
for ingredient in ingredients_html
]
def instructions(self):
instructions_html = self.soup.findAll('div', {'class': 'recipe-method-step-content'})
return '\n'.join([
normalize_string(instruction.get_text())
for instruction in instructions_html
])
def categories(self):
categories_html = self.soup.findAll('meta', {'name': 'keywords'})
return [
normalize_string(c) for category in categories_html
for c in category['content'].split(',')
]
def image_url(self):
image_html = self.soup.find('meta', {'property': 'og:image'})
return image_html['content']
| 28.04878 | 93 | 0.617391 | 125 | 1,150 | 5.528 | 0.4 | 0.057887 | 0.069465 | 0.082489 | 0.078148 | 0.078148 | 0 | 0 | 0 | 0 | 0 | 0.001172 | 0.258261 | 1,150 | 40 | 94 | 28.75 | 0.80891 | 0 | 0 | 0.068966 | 0 | 0 | 0.113913 | 0.041739 | 0 | 0 | 0 | 0 | 0 | 1 | 0.206897 | false | 0 | 0.068966 | 0.068966 | 0.517241 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
d79ff14bca2e418e8fde41df831e7ffdd62cfb01 | 1,489 | py | Python | application/controller/auth.py | hisahi/Nanibgal | 56d8741de0b6c5d10f55f7a5f225472d8c87b0b4 | [
"MIT"
] | null | null | null | application/controller/auth.py | hisahi/Nanibgal | 56d8741de0b6c5d10f55f7a5f225472d8c87b0b4 | [
"MIT"
] | 2 | 2018-10-07T10:51:17.000Z | 2018-10-18T09:38:21.000Z | application/controller/auth.py | hisahi/Nanibgal | 56d8741de0b6c5d10f55f7a5f225472d8c87b0b4 | [
"MIT"
] | 1 | 2018-10-18T07:55:21.000Z | 2018-10-18T07:55:21.000Z |
import application.models
from application.controller.users import get_user_by_name
def register(username, password, verify):
if len(username) < 4 or len(username) > 20:
return (None, "register.error.invalid_username_length")
if len(password) < 8 or len(password) > 256:
return (None, "register.error.invalid_password_length")
if password != verify:
return (None, "register.error.password_not_match")
username = username[:20]
if get_user_by_name(username = username) != None:
return (None, "register.error.username_taken")
# validate username
if not validate_username(username):
return (None, "register.error.invalid_username")
user = application.models.User(username, "", password)
user.add_itself()
return (user, None)
def validate_username(username):
if len(username) < 4 or len(username) > 20:
return False
if username[0] in "0123456789":
return False
for c in username:
if c not in "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_":
return False
return True
def login(username, password):
# find user by username
obj = get_user_by_name(username = username[:32])
# if no user with this username
if obj == None:
return (None, "login.invalid")
# if password is incorrect
if not obj.password_ok(password[:256]):
return (None, "login.invalid")
# return LoginUser object
return (obj, None)
| 34.627907 | 86 | 0.679651 | 183 | 1,489 | 5.409836 | 0.289617 | 0.070707 | 0.090909 | 0.116162 | 0.230303 | 0.2 | 0.070707 | 0.070707 | 0.070707 | 0 | 0 | 0.032759 | 0.220954 | 1,489 | 42 | 87 | 35.452381 | 0.82069 | 0.079248 | 0 | 0.212121 | 0 | 0 | 0.196481 | 0.170088 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0.242424 | 0.060606 | 0 | 0.545455 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
d7a8573fe3424771def31253354a368208310ffb | 341 | py | Python | notifications/management/commands/emit_subscriptions.py | aaronc-bixly/notifications | c93886397b98d832b85cbb442e19201a0889ba67 | [
"MIT"
] | 1 | 2015-08-03T07:40:34.000Z | 2015-08-03T07:40:34.000Z | notifications/management/commands/emit_subscriptions.py | aaronc-bixly/notifications | c93886397b98d832b85cbb442e19201a0889ba67 | [
"MIT"
] | null | null | null | notifications/management/commands/emit_subscriptions.py | aaronc-bixly/notifications | c93886397b98d832b85cbb442e19201a0889ba67 | [
"MIT"
] | null | null | null | import logging
from django.core.management.base import BaseCommand
from notifications.engine import send_subscriptions
class Command(BaseCommand):
help = "Send out digests to those subscribed"
def handle(self, *args, **options):
logging.basicConfig(level=logging.DEBUG, format="%(message)s")
send_subscriptions() | 26.230769 | 70 | 0.744868 | 40 | 341 | 6.3 | 0.775 | 0.134921 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.16129 | 341 | 13 | 71 | 26.230769 | 0.881119 | 0 | 0 | 0 | 0 | 0 | 0.137427 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.375 | 0 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
d7b2137dda10566225b867ac7f72fefb9f3ae77d | 176 | py | Python | server/bridge/template/keys.py | jainkuniya/Question-Generator | a13279076367e4c61a416d3c663016e525e4a0a6 | [
"Apache-2.0"
] | null | null | null | server/bridge/template/keys.py | jainkuniya/Question-Generator | a13279076367e4c61a416d3c663016e525e4a0a6 | [
"Apache-2.0"
] | null | null | null | server/bridge/template/keys.py | jainkuniya/Question-Generator | a13279076367e4c61a416d3c663016e525e4a0a6 | [
"Apache-2.0"
] | null | null | null | KEY_QUESTION_TYPE = 'question_type'
KEY_QUESTION = 'question'
KEY_ANSWER = 'answer'
KEY_OPTIONS = 'options'
KEY_COMPREHENSION = 'comprehension'
KEY_EXPLANATION = 'explanation'
| 25.142857 | 35 | 0.795455 | 20 | 176 | 6.6 | 0.35 | 0.166667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.102273 | 176 | 6 | 36 | 29.333333 | 0.835443 | 0 | 0 | 0 | 0 | 0 | 0.329545 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d7b348408e2e63d45adf6154854c46d97e893ef3 | 11,025 | py | Python | yandex/cloud/mdb/sqlserver/v1/user_pb2.py | korsar182/python-sdk | 873bf2a9b136a8f2faae72e86fae1f5b5c3d896a | [
"MIT"
] | 36 | 2018-12-23T13:51:50.000Z | 2022-03-25T07:48:24.000Z | yandex/cloud/mdb/sqlserver/v1/user_pb2.py | korsar182/python-sdk | 873bf2a9b136a8f2faae72e86fae1f5b5c3d896a | [
"MIT"
] | 15 | 2019-02-28T04:55:09.000Z | 2022-03-06T23:17:24.000Z | yandex/cloud/mdb/sqlserver/v1/user_pb2.py | korsar182/python-sdk | 873bf2a9b136a8f2faae72e86fae1f5b5c3d896a | [
"MIT"
] | 18 | 2019-02-23T07:10:57.000Z | 2022-03-28T14:41:08.000Z | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: yandex/cloud/mdb/sqlserver/v1/user.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
from yandex.cloud import validation_pb2 as yandex_dot_cloud_dot_validation__pb2
DESCRIPTOR = _descriptor.FileDescriptor(
name='yandex/cloud/mdb/sqlserver/v1/user.proto',
package='yandex.cloud.mdb.sqlserver.v1',
syntax='proto3',
serialized_options=b'\n!yandex.cloud.api.mdb.sqlserver.v1B\003PSUZKgithub.com/yandex-cloud/go-genproto/yandex/cloud/mdb/sqlserver/v1;sqlserver',
create_key=_descriptor._internal_create_key,
serialized_pb=b'\n(yandex/cloud/mdb/sqlserver/v1/user.proto\x12\x1dyandex.cloud.mdb.sqlserver.v1\x1a\x1dyandex/cloud/validation.proto\"h\n\x04User\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\ncluster_id\x18\x02 \x01(\t\x12>\n\x0bpermissions\x18\x03 \x03(\x0b\x32).yandex.cloud.mdb.sqlserver.v1.Permission\"\xbe\x02\n\nPermission\x12\x15\n\rdatabase_name\x18\x01 \x01(\t\x12\x46\n\x05roles\x18\x02 \x03(\x0e\x32..yandex.cloud.mdb.sqlserver.v1.Permission.RoleB\x07\x82\xc8\x31\x03>=1\"\xd0\x01\n\x04Role\x12\x14\n\x10ROLE_UNSPECIFIED\x10\x00\x12\x0c\n\x08\x44\x42_OWNER\x10\x01\x12\x14\n\x10\x44\x42_SECURITYADMIN\x10\x02\x12\x12\n\x0e\x44\x42_ACCESSADMIN\x10\x03\x12\x15\n\x11\x44\x42_BACKUPOPERATOR\x10\x04\x12\x0f\n\x0b\x44\x42_DDLADMIN\x10\x05\x12\x11\n\rDB_DATAWRITER\x10\x06\x12\x11\n\rDB_DATAREADER\x10\x07\x12\x15\n\x11\x44\x42_DENYDATAWRITER\x10\x08\x12\x15\n\x11\x44\x42_DENYDATAREADER\x10\t\"\x98\x01\n\x08UserSpec\x12+\n\x04name\x18\x01 \x01(\tB\x1d\xe8\xc7\x31\x01\x8a\xc8\x31\x04<=32\xf2\xc7\x31\r[a-zA-Z0-9_]*\x12\x1f\n\x08password\x18\x02 \x01(\tB\r\xe8\xc7\x31\x01\x8a\xc8\x31\x05\x38-128\x12>\n\x0bpermissions\x18\x03 \x03(\x0b\x32).yandex.cloud.mdb.sqlserver.v1.PermissionBu\n!yandex.cloud.api.mdb.sqlserver.v1B\x03PSUZKgithub.com/yandex-cloud/go-genproto/yandex/cloud/mdb/sqlserver/v1;sqlserverb\x06proto3'
,
dependencies=[yandex_dot_cloud_dot_validation__pb2.DESCRIPTOR,])
_PERMISSION_ROLE = _descriptor.EnumDescriptor(
name='Role',
full_name='yandex.cloud.mdb.sqlserver.v1.Permission.Role',
filename=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
values=[
_descriptor.EnumValueDescriptor(
name='ROLE_UNSPECIFIED', index=0, number=0,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='DB_OWNER', index=1, number=1,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='DB_SECURITYADMIN', index=2, number=2,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='DB_ACCESSADMIN', index=3, number=3,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='DB_BACKUPOPERATOR', index=4, number=4,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='DB_DDLADMIN', index=5, number=5,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='DB_DATAWRITER', index=6, number=6,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='DB_DATAREADER', index=7, number=7,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='DB_DENYDATAWRITER', index=8, number=8,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='DB_DENYDATAREADER', index=9, number=9,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
],
containing_type=None,
serialized_options=None,
serialized_start=323,
serialized_end=531,
)
_sym_db.RegisterEnumDescriptor(_PERMISSION_ROLE)
_USER = _descriptor.Descriptor(
name='User',
full_name='yandex.cloud.mdb.sqlserver.v1.User',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='name', full_name='yandex.cloud.mdb.sqlserver.v1.User.name', index=0,
number=1, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=b"".decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='cluster_id', full_name='yandex.cloud.mdb.sqlserver.v1.User.cluster_id', index=1,
number=2, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=b"".decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='permissions', full_name='yandex.cloud.mdb.sqlserver.v1.User.permissions', index=2,
number=3, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=106,
serialized_end=210,
)
_PERMISSION = _descriptor.Descriptor(
name='Permission',
full_name='yandex.cloud.mdb.sqlserver.v1.Permission',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='database_name', full_name='yandex.cloud.mdb.sqlserver.v1.Permission.database_name', index=0,
number=1, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=b"".decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='roles', full_name='yandex.cloud.mdb.sqlserver.v1.Permission.roles', index=1,
number=2, type=14, cpp_type=8, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=b'\202\3101\003>=1', file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
_PERMISSION_ROLE,
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=213,
serialized_end=531,
)
_USERSPEC = _descriptor.Descriptor(
name='UserSpec',
full_name='yandex.cloud.mdb.sqlserver.v1.UserSpec',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='name', full_name='yandex.cloud.mdb.sqlserver.v1.UserSpec.name', index=0,
number=1, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=b"".decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=b'\350\3071\001\212\3101\004<=32\362\3071\r[a-zA-Z0-9_]*', file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='password', full_name='yandex.cloud.mdb.sqlserver.v1.UserSpec.password', index=1,
number=2, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=b"".decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=b'\350\3071\001\212\3101\0058-128', file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='permissions', full_name='yandex.cloud.mdb.sqlserver.v1.UserSpec.permissions', index=2,
number=3, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=534,
serialized_end=686,
)
_USER.fields_by_name['permissions'].message_type = _PERMISSION
_PERMISSION.fields_by_name['roles'].enum_type = _PERMISSION_ROLE
_PERMISSION_ROLE.containing_type = _PERMISSION
_USERSPEC.fields_by_name['permissions'].message_type = _PERMISSION
DESCRIPTOR.message_types_by_name['User'] = _USER
DESCRIPTOR.message_types_by_name['Permission'] = _PERMISSION
DESCRIPTOR.message_types_by_name['UserSpec'] = _USERSPEC
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
User = _reflection.GeneratedProtocolMessageType('User', (_message.Message,), {
'DESCRIPTOR' : _USER,
'__module__' : 'yandex.cloud.mdb.sqlserver.v1.user_pb2'
# @@protoc_insertion_point(class_scope:yandex.cloud.mdb.sqlserver.v1.User)
})
_sym_db.RegisterMessage(User)
Permission = _reflection.GeneratedProtocolMessageType('Permission', (_message.Message,), {
'DESCRIPTOR' : _PERMISSION,
'__module__' : 'yandex.cloud.mdb.sqlserver.v1.user_pb2'
# @@protoc_insertion_point(class_scope:yandex.cloud.mdb.sqlserver.v1.Permission)
})
_sym_db.RegisterMessage(Permission)
UserSpec = _reflection.GeneratedProtocolMessageType('UserSpec', (_message.Message,), {
'DESCRIPTOR' : _USERSPEC,
'__module__' : 'yandex.cloud.mdb.sqlserver.v1.user_pb2'
# @@protoc_insertion_point(class_scope:yandex.cloud.mdb.sqlserver.v1.UserSpec)
})
_sym_db.RegisterMessage(UserSpec)
DESCRIPTOR._options = None
_PERMISSION.fields_by_name['roles']._options = None
_USERSPEC.fields_by_name['name']._options = None
_USERSPEC.fields_by_name['password']._options = None
# @@protoc_insertion_point(module_scope)
| 42.080153 | 1,326 | 0.752653 | 1,458 | 11,025 | 5.401235 | 0.143347 | 0.052571 | 0.08927 | 0.067556 | 0.700825 | 0.676825 | 0.647111 | 0.59327 | 0.548063 | 0.541206 | 0 | 0.049892 | 0.116463 | 11,025 | 261 | 1,327 | 42.241379 | 0.758546 | 0.041905 | 0 | 0.650862 | 1 | 0.012931 | 0.253081 | 0.209953 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.012931 | 0.021552 | 0 | 0.021552 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d7c5c6166c3fa787e22e19c056f65823ad85fe77 | 5,323 | py | Python | mayaSDK/maya/app/renderSetup/model/utils.py | FXTD-ODYSSEY/vscode-mayapy | 7a21872f80b5b740fc653e79c3f9b5268e87b3c3 | [
"MIT"
] | 20 | 2019-09-20T00:30:22.000Z | 2021-12-26T06:56:16.000Z | mayaSDK/maya/app/renderSetup/model/utils.py | minjiang999/vscode-mayapy | 7a21872f80b5b740fc653e79c3f9b5268e87b3c3 | [
"MIT"
] | 5 | 2019-12-29T15:19:03.000Z | 2022-03-29T16:54:19.000Z | mayaSDK/maya/app/renderSetup/model/utils.py | minjiang999/vscode-mayapy | 7a21872f80b5b740fc653e79c3f9b5268e87b3c3 | [
"MIT"
] | 8 | 2019-09-23T05:46:44.000Z | 2022-01-11T14:42:14.000Z | def isExistingClassification(t):
pass
def getSrcNodeName(dst):
"""
Get the name of the node connected to the argument dst plug.
"""
pass
def getCollectionsRecursive(parent):
pass
def disconnect(src, dst):
pass
def findVolumeShader(shadingEngine, search='False'):
"""
Returns the volume shader (as MObject) of the given shading engine (as MObject).
"""
pass
def transferPlug(src, dst):
"""
Transfer the connection or value set on plug 'src' on to the plug 'dst'.
"""
pass
def findSurfaceShader(shadingEngine, search='False'):
"""
Returns the surface shader (as MObject) of the given shading engine (as MObject).
"""
pass
def findPlug(userNode, attr):
"""
Return plug corresponding to attr on argument userNode.
If the argument userNode is None, or the attribute is not found, None
is returned.
"""
pass
def disconnectSrc(src):
"""
Disconnect a source (readable) plug from all its destinations.
Note that a single plug can be both source and destination, so this
interface makes the disconnection intent explicit.
"""
pass
def isSurfaceShaderNode(obj):
pass
def getSrcUserNode(dst):
"""
Get the user node connected to the argument dst plug.
Note: Only applies to MPxNode derived nodes
If the dst plug is unconnected, None is returned.
"""
pass
def plugSrc(dstPlug):
"""
Return the source of a connected destination plug.
If the destination is unconnected, returns None.
"""
pass
def getOverridesRecursive(parent):
pass
def nameToUserNode(name):
pass
def isShadingType(typeName):
pass
def canOverrideNode(node):
pass
def createSrcMsgAttr(longName, shortName):
"""
Create a source (a.k.a. output, or readable) message attribute.
"""
pass
def deleteNode(node):
"""
Remove the argument node from the graph.
This function is undoable.
"""
pass
def connect(src, dst):
"""
Connect source plug to destination plug.
If the dst plug is None, the src plug will be disconnected from all its
destinations (if any). If the src plug is None, the dst plug will be
disconnected from its source (if any). If both are None, this function
does nothing. If the destination is already connected, it will be
disconnected.
"""
pass
def isExistingType(t):
pass
def getDstUserNodes(src):
"""
Get the user nodes connected to the argument src plug.
Note: Only applies to MPxNode derived nodes
If the src plug is unconnected, None is returned.
"""
pass
def plugDst(srcPlug):
"""
Return the destinations of a connected source plug.
If the source is unconnected, returns None.
"""
pass
def _recursiveSearch(colList):
"""
# Fonctions to compute the number of operations when layer are switched
"""
pass
def getTotalNumberOperations(model):
pass
def _isDestination(plug):
"""
Returns True if the given plug is a destination plug, and False otherwise.
If the plug is a compond attribute it returns True if any of it's children is a
destination plug.
"""
pass
def isShadingNode(obj):
pass
def disconnectDst(dst):
"""
Disconnect a destination (writable) plug from its source.
Note that a single plug can be both source and destination, so this
interface makes the disconnection intent explicit.
"""
pass
def findDisplacementShader(shadingEngine, search='False'):
"""
Returns the displacement shader (as MObject) of the given shading engine (as MObject).
"""
pass
def _findShader(shadingEngine, attribute, classification='None'):
"""
Returns the shader connected to given attribute on given shading engine.
Optionally search for nodes from input connections to the shading engines
satisfying classification if plug to attribute is not a destination and
a classification string is specified.
"""
pass
def isInheritedType(parentTypeName, childTypeName):
pass
def getSrcNode(dst):
"""
Get the node connected to the argument dst plug.
"""
pass
def createGenericAttr(longName, shortName):
pass
def nameToExistingUserNode(name):
pass
def _transferConnectedPlug(src, dst):
pass
def connectMsgToDst(userNode, dst):
"""
Connect the argument userNode's message attribute to the
argument dst plug.
If the userNode is None the dst plug is disconnected
from its sources.
If the dst plug is None the userNode's message plug
is disconnected from its destinations
"""
pass
def isSurfaceShaderType(typeName):
pass
def notUndoRedoing(f):
"""
Decorator that will call the decorated method only if not currently in undoing or redoing.
Particularly useful to prevent callbacks from generating commands since that would clear the redo stack.
"""
pass
def createDstMsgAttr(longName, shortName):
"""
Create a destination (a.k.a. input, or writable) message attribute.
"""
pass
kNoSuchNode = []
kSupportedVectorTypes = set()
kSupportedSimpleTypes = set()
kPlugTypeMismatch = []
| 18.229452 | 108 | 0.672365 | 656 | 5,323 | 5.449695 | 0.282012 | 0.072448 | 0.018182 | 0.024615 | 0.292028 | 0.211748 | 0.194406 | 0.174545 | 0.153287 | 0.153287 | 0 | 0 | 0.25681 | 5,323 | 291 | 109 | 18.292096 | 0.903691 | 0.547811 | 0 | 0.475 | 0 | 0 | 0.009948 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.475 | false | 0.475 | 0 | 0 | 0.475 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
d7c6e3adcd6bfd81cf59334ea6f284043d069a60 | 28,090 | py | Python | app/models.py | Summerotter/dawnofworlds | 448811b0549820bcb24f6961501940d757336782 | [
"MIT"
] | 1 | 2019-12-25T01:20:20.000Z | 2019-12-25T01:20:20.000Z | app/models.py | Summerotter/dawnofworlds | 448811b0549820bcb24f6961501940d757336782 | [
"MIT"
] | 4 | 2020-03-24T16:03:50.000Z | 2021-02-02T23:00:50.000Z | app/models.py | Summerotter/dawnofworlds | 448811b0549820bcb24f6961501940d757336782 | [
"MIT"
] | null | null | null | from datetime import datetime
import hashlib
from werkzeug.security import generate_password_hash, check_password_hash
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
from markdown import markdown
import bleach
from flask import current_app, request
from flask.ext.login import UserMixin, AnonymousUserMixin
from . import db, login_manager
from random import randint
class Permission:
FOLLOW = 0x01
COMMENT = 0x02
WRITE_ARTICLES = 0x04
MODERATE_COMMENTS = 0x08
ADMINISTER = 0x80
class Role(db.Model):
__tablename__ = 'roles'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(64), unique=True)
default = db.Column(db.Boolean, default=False, index=True)
permissions = db.Column(db.Integer)
users = db.relationship('User', backref='role', lazy='dynamic')
@staticmethod
def insert_roles():
roles = {
'User': (Permission.FOLLOW |
Permission.COMMENT |
Permission.WRITE_ARTICLES, True),
'Moderator': (Permission.FOLLOW |
Permission.COMMENT |
Permission.WRITE_ARTICLES |
Permission.MODERATE_COMMENTS, False),
'Administrator': (0xff, False)
}
for r in roles:
role = Role.query.filter_by(name=r).first()
if role is None:
role = Role(name=r)
role.permissions = roles[r][0]
role.default = roles[r][1]
db.session.add(role)
db.session.commit()
def __repr__(self):
return '<Role %r>' % self.name
player_world_table = db.Table('player_worlds', db.Model.metadata,
db.Column('player_id', db.Integer,
db.ForeignKey('users.id')),
db.Column('world_id', db.Integer,
db.ForeignKey('world.id')))
class User(UserMixin, db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(64), unique=True, index=True)
username = db.Column(db.String(64), unique=True, index=True)
role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))
password_hash = db.Column(db.String(128))
confirmed = db.Column(db.Boolean, default=False)
name = db.Column(db.String(64))
location = db.Column(db.String(64))
about_me = db.Column(db.Text())
member_since = db.Column(db.DateTime(), default=datetime.utcnow)
last_seen = db.Column(db.DateTime(), default=datetime.utcnow)
avatar_hash = db.Column(db.String(32))
posts = db.relationship('Post', backref='author', lazy='dynamic')
armies = db.relationship('Armies', backref='army_owner', lazy='dynamic')
turnlog = db.relationship('TurnLog', backref='player_turn', lazy='dynamic')
events = db.relationship('Events', backref='player_event', lazy='dynamic')
races = db.relationship('Race', backref='race_creator', lazy='dynamic')
avatars = db.relationship('Avatars', backref='avatar_owner', lazy='dynamic')
orders = db.relationship('Orders', backref='order_owner', lazy='dynamic')
owned_worlds = db.relationship('World', backref='world_owner', lazy='dynamic')
worlds = db.relationship('World',
secondary=player_world_table,
backref =db.backref('players', lazy='dynamic'),
lazy='dynamic')
points = db.relationship('PowerPoints', backref='player_points',lazy='dynamic')
@staticmethod
def generate_fake(count=100):
from sqlalchemy.exc import IntegrityError
from random import seed
import forgery_py
seed()
for i in range(count):
u = User(email=forgery_py.internet.email_address(),
username=forgery_py.internet.user_name(True),
password=forgery_py.lorem_ipsum.word(),
confirmed=True,
name=forgery_py.name.full_name(),
location=forgery_py.address.city(),
about_me=forgery_py.lorem_ipsum.sentence(),
member_since=forgery_py.date.date(True))
db.session.add(u)
try:
db.session.commit()
except IntegrityError:
db.session.rollback()
def __init__(self, **kwargs):
super(User, self).__init__(**kwargs)
if self.role is None:
if self.email == current_app.config['FLASKY_ADMIN']:
self.role = Role.query.filter_by(permissions=0xff).first()
if self.role is None:
self.role = Role.query.filter_by(default=True).first()
if self.email is not None and self.avatar_hash is None:
self.avatar_hash = hashlib.md5(
self.email.encode('utf-8')).hexdigest()
@property
def password(self):
raise AttributeError('password is not a readable attribute')
@password.setter
def password(self, password):
self.password_hash = generate_password_hash(password)
def verify_password(self, password):
return check_password_hash(self.password_hash, password)
def generate_confirmation_token(self, expiration=3600):
s = Serializer(current_app.config['SECRET_KEY'], expiration)
return s.dumps({'confirm': self.id})
def confirm(self, token):
s = Serializer(current_app.config['SECRET_KEY'])
try:
data = s.loads(token)
except:
return False
if data.get('confirm') != self.id:
return False
self.confirmed = True
db.session.add(self)
return True
def generate_reset_token(self, expiration=3600):
s = Serializer(current_app.config['SECRET_KEY'], expiration)
return s.dumps({'reset': self.id})
def reset_password(self, token, new_password):
s = Serializer(current_app.config['SECRET_KEY'])
try:
data = s.loads(token)
except:
return False
if data.get('reset') != self.id:
return False
self.password = new_password
db.session.add(self)
return True
def generate_email_change_token(self, new_email, expiration=3600):
s = Serializer(current_app.config['SECRET_KEY'], expiration)
return s.dumps({'change_email': self.id, 'new_email': new_email})
def change_email(self, token):
s = Serializer(current_app.config['SECRET_KEY'])
try:
data = s.loads(token)
except:
return False
if data.get('change_email') != self.id:
return False
new_email = data.get('new_email')
if new_email is None:
return False
if self.query.filter_by(email=new_email).first() is not None:
return False
self.email = new_email
self.avatar_hash = hashlib.md5(
self.email.encode('utf-8')).hexdigest()
db.session.add(self)
return True
def can(self, permissions):
return self.role is not None and \
(self.role.permissions & permissions) == permissions
def is_administrator(self):
return self.can(Permission.ADMINISTER)
def ping(self):
self.last_seen = datetime.utcnow()
db.session.add(self)
def gravatar(self, size=100, default='identicon', rating='g'):
if request.is_secure:
url = 'https://secure.gravatar.com/avatar'
else:
url = 'http://www.gravatar.com/avatar'
hash = self.avatar_hash or hashlib.md5(
self.email.encode('utf-8')).hexdigest()
return '{url}/{hash}?s={size}&d={default}&r={rating}'.format(
url=url, hash=hash, size=size, default=default, rating=rating)
def __repr__(self):
return '<User %r>' % self.username
def get_id(self):
return self.id
def return_points_obj(self,world_id):
points = self.points.filter_by(world=world_id).first()
try:
points.points >= 0
except:
points = PowerPoints()
points.points = 0
return points
def is_anon(self):
return False
class AnonymousUser(AnonymousUserMixin):
def can(self, permissions):
return False
def is_administrator(self):
return False
def return_points_obj(self,world_id):
points = PowerPoints()
points.points = -1
return points
def is_anon(self):
return True
login_manager.anonymous_user = AnonymousUser
@login_manager.user_loader
def load_user(user_id):
return User.query.get(user_id)
class Post(db.Model):
__tablename__ = 'posts'
id = db.Column(db.Integer, primary_key=True)
body = db.Column(db.Text)
body_html = db.Column(db.Text)
timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)
author_id = db.Column(db.Integer, db.ForeignKey('users.id'))
@staticmethod
def generate_fake(count=100):
from random import seed, randint
import forgery_py
seed()
user_count = User.query.count()
for i in range(count):
u = User.query.offset(randint(0, user_count - 1)).first()
p = Post(body=forgery_py.lorem_ipsum.sentences(randint(1, 5)),
timestamp=forgery_py.date.date(True),
author=u)
db.session.add(p)
db.session.commit()
@staticmethod
def on_changed_body(target, value, oldvalue, initiator):
allowed_tags = ['a', 'abbr', 'acronym', 'b', 'blockquote', 'code',
'em', 'i', 'li', 'ol', 'pre', 'strong', 'ul',
'h1', 'h2', 'h3', 'p']
target.body_html = bleach.linkify(bleach.clean(
markdown(value, output_format='html'),
tags=allowed_tags, strip=True))
db.event.listen(Post.body, 'set', Post.on_changed_body)
from app import db
from hashlib import md5
from flask import url_for
order_location_table = db.Table('order_location', db.Model.metadata,
db.Column('order_id', db.Integer,
db.ForeignKey('orders.id')),
db.Column('location_id', db.Integer,
db.ForeignKey('worldmap.id')))
class OrderTypes(db.Model):
id = db.Column(db.Integer, primary_key = True)
text = db.Column(db.String(64))
def insert_orders():
orders = ('Cultural Religion', 'Religious', "Military","Trade","Criminal","Technology","Magic")
for o in orders:
order = OrderTypes.query.filter_by(text=o).first()
if order is None:
order = OrderTypes(text=o)
db.session.add(order)
db.session.commit()
class WorldMap(db.Model):
__tablename__ = 'worldmap'
id = db.Column(db.Integer, primary_key=True)
world = db.Column(db.Integer, db.ForeignKey('world.id'))
race = db.Column(db.Integer,db.ForeignKey('race.id'),default=0)
race_color = db.Column(db.Integer,default=0)
letter_coord = db.Column(db.Integer)
number_coord = db.Column(db.Integer)
terrain = db.Column(db.String(16))
image = db.Column(db.String(16))
city = db.relationship("City",backref='world_location',lazy='dynamic')
has_city = db.Column(db.Integer)
army = db.relationship("Armies",backref='worldmap_id',lazy='dynamic')
events = db.relationship("Events",backref="worldmap_event_id",lazy='dynamic')
prov_bldg = db.relationship("BldgProv",backref="worldmap",lazy='dynamic')
avatars = db.relationship("Avatars",backref="worldmap_avatar",lazy='dynamic')
def coords(self):
return str(self.letter_coord)+"x/"+str(self.number_coord)+"y"
def regen_coords(self):
return {"y":self.number_coord,"x":int(self.letter_coord),}
def return_image(self):
return url_for('static',filename="image/"+self.image)
def return_race(self):
return Race.query.get(self.race)
def return_live_city(self):
return self.city.filter_by(is_alive=1).first()
def return_live_provbldge(self):
return self.prov_bldg.filter_by(is_alive=1).all()
def return_ruin_city(self):
return self.city.filter_by(is_alive=0).all()
def return_ruin_provbldg(self):
return self.prov_bldg.filter_by(is_alive=0).all()
class World(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(64),index=True,unique=True)
age = db.Column(db.Integer ,index=True, default=1)
turn_of_age = db.Column(db.Integer, index=True,default=1)
total_turns = db.Column(db.Integer, index=True,default=1)
races = db.relationship('Race', backref='homeworld', lazy='dynamic')
active = db.Column(db.Integer,default=0)
cities = db.relationship('City', backref='city_homeworld', lazy='dynamic')
avatars = db.relationship("Avatars", backref='avatar_homeworld', lazy='dynamic')
turnlog = db.relationship("TurnLog", backref='turnlog_homeworld', lazy='dynamic')
event = db.relationship("Events", backref='event_homeworld', lazy='dynamic')
orders = db.relationship("Orders", backref='order_homeworld', lazy='dynamic')
provbldg = db.relationship("BldgProv", backref="world",lazy='dynamic')
armies = db.relationship("Armies", backref="worldid",lazy='dynamic')
history = db.relationship("WorldHistory",backref="worldbackref",lazy='dynamic')
points = db.relationship('PowerPoints', backref='world_points',lazy='dynamic')
size = db.Column(db.Integer,default=50)
owner = db.Column(db.Integer, db.ForeignKey('users.id'))
def __repr__(self):
return '<World %r>' % (self.name)
def age_turn(self):
return "A"+str(self.age)+":T"+str(self.turn_of_age)
def ret_history(self):
return WorldHistory.query.filter_by(world=self.id).order_by(WorldHistory.id.desc())
def delete_self(self):
for each in self.provbldg.all():
db.session.delete(each)
for each in self.armies.all():
db.session.delete(each)
for each in self.history.all():
db.session.delete(each)
for each in self.points.all():
db.session.delete(each)
for each in self.avatars.all():
db.session.delete(each)
for each in self.event.all():
db.session.delete(each)
for each in self.orders.all():
for location in each.locations.all():
db.session.delete(location)
db.session.delete(each)
for each in Race.query.filter_by(world_id=self.id).all():
each.remove_stuff()
db.session.delete(each)
for each in self.cities:
each.remove_stuff()
db.session.delete(each)
for each in WorldMap.query.filter_by(world=self.id).all():
db.session.delete(each)
db.session.commit()
class Race(db.Model):
id = db.Column(db.Integer, primary_key = True)
world_id = db.Column(db.Integer, db.ForeignKey('world.id'))
#Check culture_name when calling to make certain unique per world
culture_name = db.Column(db.String(128),index=True)
race_name = db.Column(db.String(64))
map_color = db.Column(db.Integer)
alignment = db.Column(db.Integer)
creator = db.Column(db.Integer, db.ForeignKey('users.id'))
abs_turn_made = db.Column(db.Integer)
age_turn = db.Column(db.String(64))
#subrace - 0 or race_id
subrace = db.Column(db.Integer, default=0)
controlled_cities = db.relationship('City', backref='city_builders', lazy='dynamic')
controlled_provbldg = db.relationship('BldgProv', backref='bldgprov_builders', lazy='dynamic')
armies = db.relationship('Armies', backref='culture', lazy='dynamic')
orders = db.relationship("Orders", backref='founders',lazy='dynamic')
religion = db.Column(db.Integer)
location = db.relationship("WorldMap",backref='race_location',lazy='dynamic')
advances = db.relationship("RaceAdvances",backref="race_obj",lazy='dynamic')
def remove_stuff(self):
#part of deleting a world
for each in self.advances.all():
db.session.delete(each)
for each in self.location.all():
db.session.delete(each)
for each in self.armies.all():
db.session.delete(each)
db.session.commit()
def subrace_of(self):
if self.subrace == 0:
return "None"
else:
parent_id = self.subrace
parent = Race.query.get(parent_id)
return parent.culture_name
def made_by(self):
if self.creator == 0 or self.creator == None:
return "Orphaned"
else:
creator = User.query.get(self.creator)
return creator.name
def get_religion(self):
if self.religion == 0:
return None
elif self.religion == None:
return None
else:
religion = Orders.query.get(self.religion)
return religion
class City(db.Model):
id = db.Column(db.Integer, primary_key = True)
world_id = db.Column(db.Integer, db.ForeignKey('world.id'))
name = db.Column(db.String(64))
#Building Race's ID
built_by = db.Column(db.Integer)
owned_by = db.Column(db.Integer, db.ForeignKey('race.id'))
location = db.Column(db.Integer, db.ForeignKey('worldmap.id'))
alignment = db.Column(db.Integer)
buildings = db.relationship("BldgCity", backref="bldg_here", lazy='dynamic')
armies = db.relationship("Armies", backref='army_built_here', lazy='dynamic')
age_turn = db.Column(db.String(64))
turn_built = db.Column(db.Integer)
is_alive = db.Column(db.Integer, default = 1)
destroyed_in = db.Column(db.Integer)
history = db.relationship("CityHistory",backref="history",lazy='dynamic')
orders = db.relationship("Order_City",backref="order_city_cityobj",lazy='dynamic')
advances = db.relationship("CityAdvances",backref="city_obj",lazy='dynamic')
def remove_stuff(self):
for each in self.buildings.all():
db.session.delete(each)
for each in self.history.all():
db.session.delete(each)
for each in self.advances.all():
db.session.delete(each)
def builder_name(self):
builder = Race.query.get(self.built_by)
return builder.culture_name
def owner_name(self):
if self.is_alive:
owner = Race.query.get(self.owned_by)
return owner.culture_name
else:
return "Ruins"
def ret_history(self):
return CityHistory.query.filter_by(cityid=self.id).order_by(CityHistory.id.desc())
def return_location(self):
return WorldMap.query.get(self.location)
def return_owner_player(self):
race = Race.query.get(self.owned_by)
player = User.query.get(race.creator)
return player.id
class BldgCity(db.Model):
id = db.Column(db.Integer, primary_key = True)
name = db.Column(db.String(64))
desc = db.Column(db.String(64))
built_in = db.Column(db.Integer, db.ForeignKey('city.id'))
age_turn = db.Column(db.String(64))
turn_built = db.Column(db.Integer)
class BldgProv(db.Model):
id = db.Column(db.Integer, primary_key = True)
#Building race's ID
built_by = db.Column(db.Integer)
world_in = db.Column(db.Integer, db.ForeignKey('world.id'))
owned_by = db.Column(db.Integer, db.ForeignKey('race.id'))
location = db.Column(db.Integer, db.ForeignKey('worldmap.id'))
name = db.Column(db.String(64))
description = db.Column(db.String(64))
age_turn = db.Column(db.String(64))
turn_built = db.Column(db.Integer)
is_alive = db.Column(db.Integer)
destroyed_in = db.Column(db.String())
def builder_name(self):
builder = Race.query.get(self.built_by)
return builder.culture_name
def owner_name(self):
if self.is_alive:
owner = Race.query.get(self.owned_by)
return owner.culture_name
else:
return "Ruins"
def owner_id(self):
if self.is_alive:
owner = Race.query.get(self.owned_by)
return owner.creator
else:
return 0
def new_owner(self, owner):
if self.owned_by != owner:
self.owned_by = owner
def return_location(self):
return WorldMap.query.get(self.location)
class Order_City(db.Model):
__tablename__ = 'order_city'
id = db.Column(db.Integer,primary_key=True)
order_id = db.Column(db.Integer,db.ForeignKey('orders.id'))
city_id = db.Column(db.Integer,db.ForeignKey('city.id'))
def return_city(self):
return City.query.get(self.city_id)
def return_order(self):
return Orders.query.get(self.order_id)
class Orders(db.Model):
id = db.Column(db.Integer, primary_key=True)
owner = db.Column(db.Integer, db.ForeignKey('users.id'))
world = db.Column(db.Integer, db.ForeignKey('world.id'))
description = db.Column(db.String(128))
name = db.Column(db.String(64))
abs_turn = db.Column(db.Integer)
age_turn = db.Column(db.String(128))
is_alive = db.Column(db.Integer)
type = db.Column(db.Integer)
#1=cultural_religion_DONOTDELETE,2=religion, 3=military, 4=trade, 5=criminal,6=research, 7=magical
founding_culture = db.Column(db.Integer, db.ForeignKey('race.id'))
cities = db.relationship("Order_City",backref="order_city_orderobj",lazy='dynamic')
locations = db.relationship('WorldMap',
secondary=order_location_table,
backref =db.backref('orders', lazy='dynamic'),
lazy='dynamic')
def owner_name(self):
owner = User.query.get(self.owner)
return owner.name
def order_type(self):
if self.type:
type = OrderTypes.query.get(self.type)
if type == None:
return "None"
else:
return type.text
else:
return "None"
class Events(db.Model):
id = db.Column(db.Integer, primary_key=True)
age_turn = db.Column(db.String(64))
abs_turn = db.Column(db.Integer)
location = db.Column(db.Integer,db.ForeignKey('worldmap.id'))
event_info = db.Column(db.String(128))
played_by = db.Column(db.Integer, db.ForeignKey('users.id'))
world = db.Column(db.Integer, db.ForeignKey('world.id'))
duration = db.Column(db.Integer)
def playedby_name(self):
return User.query.get(self.played_by).name
def return_location(self):
return WorldMap.query.get(self.location)
class Unit(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(24))
power = db.Column(db.Float)
health = db.Column(db.Integer)
max_health = db.Column(db.Integer)
assigned_army = db.Column(db.Integer, db.ForeignKey('armies.id'))
player = db.Column(db.Integer, db.ForeignKey("users.id"))
world = db.Column(db.Integer, db.ForeignKey("world.id"))
def attack(self):
return random.randint(1,10)*(self.power*(self.health/self.max_health))
class Armies(db.Model):
#and also navies!
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(64))
#1 for armies, 0 for navies
army = db.Column(db.Integer)
supported_from = db.Column(db.Integer, db.ForeignKey('city.id'))
home_culture = db.Column(db.Integer, db.ForeignKey('race.id'))
owner = db.Column(db.Integer, db.ForeignKey('users.id'))
location = db.Column(db.Integer,db.ForeignKey('worldmap.id'))
world = db.Column(db.Integer,db.ForeignKey('world.id'))
home_city = db.Column(db.Integer)
is_alive = db.Column(db.Integer, default=1)
movement_range = db.Column(db.Integer, default=2)
has_moved = db.Column(db.Integer, default=0)
def army_navy(self):
if self.army:
return "Army"
else:
return "Navy"
def owner_name(self):
return User.query.get(self.owner).name
def homecity_name(self):
return City.query.get(self.home_city).name
def homeculture_name(self):
return Race.query.get(self.home_culture).culture_name
def supporting_city(self):
if self.supported_from:
return City.query.get(self.supported_from).name
else:
return "Orphaned"
def return_location(self):
return WorldMap.query.get(self.location)
def attack(self):
attack_total = 0
units = Unit.query.filter_by(assigned_army=self.id).all()
if units:
for unit in units:
attack_total += unit.attack()
return attack_total
def unit_count(self):
units = Unit.query.filter_by(assigned_army=self.id).all()
return len(units)
class TurnLog(db.Model):
id = db.Column(db.Integer, primary_key = True)
world_id = db.Column(db.Integer, db.ForeignKey('world.id'))
age_turn = db.Column(db.String(64))
abs_turn = db.Column(db.Integer)
player = db.Column(db.Integer, db.ForeignKey('users.id'))
actions = db.Column(db.String(256))
class Avatars(db.Model):
id = db.Column(db.Integer, primary_key = True)
owner = db.Column(db.Integer, db.ForeignKey('users.id'))
world = db.Column(db.Integer, db.ForeignKey('world.id'))
#birthed_race = 0 or Race.Primary.Key
birthed_race = db.Column(db.Integer, default=0)
description = db.Column(db.String(64))
abs_turn = db.Column(db.Integer)
age_turn = db.Column(db.String(64))
location = db.Column(db.Integer, db.ForeignKey('worldmap.id'))
name = db.Column(db.String(64))
is_alive = db.Column(db.Integer,default=1)
movement_range = db.Column(db.Integer,default=3)
has_moved = db.Column(db.Integer,default=0)
def owner_name(self):
return User.query.get(self.owner).name
def return_location(self):
return WorldMap.query.get(self.location)
class CityHistory(db.Model):
id = db.Column(db.Integer, primary_key = True)
cityid = db.Column(db.Integer, db.ForeignKey('city.id'))
abs_turn = db.Column(db.Integer)
age_turn = db.Column(db.String(64))
entry = db.Column(db.String(256))
class WorldHistory(db.Model):
id = db.Column(db.Integer, primary_key=True)
world = db.Column(db.Integer, db.ForeignKey('world.id'))
abs_turn = db.Column(db.Integer)
age_turn = db.Column(db.String(64))
text = db.Column(db.String(256))
def worldname(self):
return World.query.get(self.world).name
class PowerPoints(db.Model):
id = db.Column(db.Integer, primary_key=True)
player = db.Column(db.Integer,db.ForeignKey('users.id'))
world = db.Column(db.Integer,db.ForeignKey('world.id'))
points = db.Column(db.Integer,default=0)
bonus = db.Column(db.Integer,default=0)
is_ready = db.Column(db.Integer,default=0)
player_status = db.Column(db.String,default="pending")
class CityAdvances(db.Model):
id = db.Column(db.Integer,primary_key=True)
city_id = db.Column(db.Integer, db.ForeignKey('city.id'))
text = db.Column(db.String(256))
class RaceAdvances(db.Model):
id = db.Column(db.Integer,primary_key=True)
race_id = db.Column(db.Integer, db.ForeignKey('race.id'))
text = db.Column(db.String(256)) | 37.107001 | 103 | 0.61837 | 3,580 | 28,090 | 4.735475 | 0.107821 | 0.077862 | 0.094968 | 0.110305 | 0.566036 | 0.497198 | 0.4447 | 0.373503 | 0.317466 | 0.271928 | 0 | 0.009047 | 0.252367 | 28,090 | 757 | 104 | 37.107001 | 0.7982 | 0.011428 | 0 | 0.403846 | 1 | 0 | 0.073052 | 0.001585 | 0 | 0 | 0.001009 | 0 | 0 | 1 | 0.11859 | false | 0.019231 | 0.028846 | 0.059295 | 0.650641 | 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 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
d7d33d1049a84d8fb825a03f0301f336ebd2b0ea | 367 | py | Python | src/sima/riflex/hysteresis.py | SINTEF/simapy | 650b8c2f15503dad98e2bfc0d0788509593822c7 | [
"MIT"
] | null | null | null | src/sima/riflex/hysteresis.py | SINTEF/simapy | 650b8c2f15503dad98e2bfc0d0788509593822c7 | [
"MIT"
] | null | null | null | src/sima/riflex/hysteresis.py | SINTEF/simapy | 650b8c2f15503dad98e2bfc0d0788509593822c7 | [
"MIT"
] | null | null | null | # Generated with Hysteresis
#
from enum import Enum
from enum import auto
class Hysteresis(Enum):
""""""
NO_HYSTERESIS = auto()
GENERATED_HYSTERESIS = auto()
def label(self):
if self == Hysteresis.NO_HYSTERESIS:
return "No hysteresis"
if self == Hysteresis.GENERATED_HYSTERESIS:
return "Generated hysteresis" | 24.466667 | 51 | 0.651226 | 39 | 367 | 6.025641 | 0.358974 | 0.153191 | 0.119149 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.26158 | 367 | 15 | 52 | 24.466667 | 0.867159 | 0.06812 | 0 | 0 | 1 | 0 | 0.099099 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0 | 0.2 | 0 | 0.8 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
d7d4efb18c8bda64e76002883f528e65dc703162 | 1,529 | py | Python | plugins/python_3_script/komand_python_3_script/actions/run/schema.py | lukaszlaszuk/insightconnect-plugins | 8c6ce323bfbb12c55f8b5a9c08975d25eb9f8892 | [
"MIT"
] | 46 | 2019-06-05T20:47:58.000Z | 2022-03-29T10:18:01.000Z | plugins/python_3_script/komand_python_3_script/actions/run/schema.py | lukaszlaszuk/insightconnect-plugins | 8c6ce323bfbb12c55f8b5a9c08975d25eb9f8892 | [
"MIT"
] | 386 | 2019-06-07T20:20:39.000Z | 2022-03-30T17:35:01.000Z | plugins/python_3_script/komand_python_3_script/actions/run/schema.py | lukaszlaszuk/insightconnect-plugins | 8c6ce323bfbb12c55f8b5a9c08975d25eb9f8892 | [
"MIT"
] | 43 | 2019-07-09T14:13:58.000Z | 2022-03-28T12:04:46.000Z | # GENERATED BY KOMAND SDK - DO NOT EDIT
import komand
import json
class Component:
DESCRIPTION = "Run Python function"
class Input:
FUNCTION = "function"
INPUT = "input"
class Output:
RESULT1 = "result1"
RESULT2 = "result2"
class RunInput(komand.Input):
schema = json.loads("""
{
"type": "object",
"title": "Variables",
"properties": {
"function": {
"type": "string",
"title": "Function",
"displayType": "python",
"description": "Function definition. Must be named `run`. Accepts the `input` object as params. Returns the dict as output",
"default": "def run(params={}):\\\\n return {}",
"format": "python",
"order": 1
},
"input": {
"type": "object",
"title": "Input",
"description": "Input object to be passed as `params={}` to the `run` function",
"order": 2
}
}
}
""")
def __init__(self):
super(self.__class__, self).__init__(self.schema)
class RunOutput(komand.Output):
schema = json.loads("""
{
"type": "object",
"title": "Variables",
"properties": {
"result1": {
"type": "string",
"title": "Result1",
"description": "Sample output result1 (delete or edit)",
"order": 1
},
"result2": {
"type": "string",
"title": "Result2",
"description": "Sample output result2 (delete or edit)",
"order": 2
}
}
}
""")
def __init__(self):
super(self.__class__, self).__init__(self.schema)
| 20.945205 | 130 | 0.557881 | 155 | 1,529 | 5.348387 | 0.36129 | 0.038601 | 0.054282 | 0.045838 | 0.236429 | 0.236429 | 0.236429 | 0.236429 | 0.118215 | 0.118215 | 0 | 0.012556 | 0.270765 | 1,529 | 72 | 131 | 21.236111 | 0.730942 | 0.024199 | 0 | 0.372881 | 1 | 0.016949 | 0.685235 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.033898 | false | 0.016949 | 0.033898 | 0 | 0.271186 | 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 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d7e212f4180464cfef58f5492714b814f5d2c7f1 | 463 | py | Python | taraxa/jsonrpc/__init__.py | Taraxa-project/taraxa-py | 95aa0d8054bf4eba2c3200f3298421575b7bb5a0 | [
"MIT"
] | null | null | null | taraxa/jsonrpc/__init__.py | Taraxa-project/taraxa-py | 95aa0d8054bf4eba2c3200f3298421575b7bb5a0 | [
"MIT"
] | 1 | 2022-03-02T15:51:17.000Z | 2022-03-02T15:51:17.000Z | taraxa/jsonrpc/__init__.py | Taraxa-project/taraxa-py | 95aa0d8054bf4eba2c3200f3298421575b7bb5a0 | [
"MIT"
] | null | null | null | NODE_HOST = "0.0.0.0"
NODE_PORT = 7777
NODE_WS_HOST = "0.0.0.0"
NODE_WS_PORT = 8777
JSONRPC = "2.0"
ID = 1
from .utl import tag_check
from .http_eth import *
from .http_taraxa import *
from .http_web3 import *
from .http_net import *
from ._http import send, message, traxa_rpc, set, reset
from ._websocket import send_ws, message_ws, traxa_rpc_ws, set_ws, reset_ws
from ._websocket import eth_subscribe, newDagBlocks, newScheduleBlocks, newDagBlocksFinalized
| 25.722222 | 93 | 0.771058 | 77 | 463 | 4.350649 | 0.415584 | 0.035821 | 0.035821 | 0.041791 | 0.071642 | 0.071642 | 0 | 0 | 0 | 0 | 0 | 0.050125 | 0.138229 | 463 | 17 | 94 | 27.235294 | 0.789474 | 0 | 0 | 0 | 0 | 0 | 0.036717 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.571429 | 0 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
d7e57c0c71b7a0fd6420968406e18d44b2b17663 | 269 | py | Python | scripts/utils/__init__.py | JimCircadian/inconsistentrecords | 0a9bbf345aef632eaac8ad450a10eb86048c5d29 | [
"MIT"
] | null | null | null | scripts/utils/__init__.py | JimCircadian/inconsistentrecords | 0a9bbf345aef632eaac8ad450a10eb86048c5d29 | [
"MIT"
] | null | null | null | scripts/utils/__init__.py | JimCircadian/inconsistentrecords | 0a9bbf345aef632eaac8ad450a10eb86048c5d29 | [
"MIT"
] | null | null | null | import configparser
import logging
import os
from github import Github
def github_conn(filename="$HOME/.github_api"):
config = configparser.ConfigParser()
config.read(os.path.expandvars(filename))
token = config['api']['token']
return Github(token)
| 19.214286 | 46 | 0.732342 | 33 | 269 | 5.909091 | 0.515152 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.152416 | 269 | 13 | 47 | 20.692308 | 0.855263 | 0 | 0 | 0 | 0 | 0 | 0.092937 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.444444 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
d7e739b30b6986759c4e7a59626a980fe2edf8b3 | 1,062 | py | Python | Taller_Estructuras_de_Control_Secuenciales/Ejercicio_17.py | LeonardoJimenezUbaque/Algoritmos_y_Programacion_C4_G2 | 7bb6fffa7d5d99ac2b5c0a3724f97a84e145bbb7 | [
"MIT"
] | null | null | null | Taller_Estructuras_de_Control_Secuenciales/Ejercicio_17.py | LeonardoJimenezUbaque/Algoritmos_y_Programacion_C4_G2 | 7bb6fffa7d5d99ac2b5c0a3724f97a84e145bbb7 | [
"MIT"
] | null | null | null | Taller_Estructuras_de_Control_Secuenciales/Ejercicio_17.py | LeonardoJimenezUbaque/Algoritmos_y_Programacion_C4_G2 | 7bb6fffa7d5d99ac2b5c0a3724f97a84e145bbb7 | [
"MIT"
] | null | null | null | """
Ejercicio 17
En un hospital rural existen tres áreas: Ginecología, Pediatría y Traumatología. El presupuesto anual del hospital
se reparte conforme a la siguiente tabla:
Área Porcentaje del presupuesto
Ginecología 40%
Traumatología 30%
Pediatría 30%
Obtener la cantidad de dinero que recibirá cada área, para cualquier monto presupuestado.
Entradas
Presupuesto_Anual --> Float --> P_A
Salidas
Presupuesto_Anual_Ginecología --> Float --> G
Presupuesto_Anual_Traumatologia --> Float --> T
Presupuesto_Anual_Pediatría --> Float --> P
"""
# Instrucciones al usuario
print("Para conocer el presupuesto que recibira cada área del hospítal, escriba lo siguiente: ")
# Entradas
P_A = float(input("Digite el presupuesto anual del hospital: "))
# Caja negra
G = P_A*0.40
T = P_A*0.30
P = P_A*0.30
# Salidas
print(f"A ginecología le corresponde del presupuesto anual: {G}$")
print(f"A traumatología le corresponde del presupuesto anual: {T}$")
print(f"A pediatría le corresponde del presupuesto anual: {P}$")
| 33.1875 | 114 | 0.727872 | 146 | 1,062 | 5.212329 | 0.431507 | 0.189225 | 0.011827 | 0.106439 | 0.202365 | 0 | 0 | 0 | 0 | 0 | 0 | 0.019699 | 0.187382 | 1,062 | 31 | 115 | 34.258065 | 0.862109 | 0.620527 | 0 | 0 | 0 | 0 | 0.72973 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.5 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
d7f2f4b9b3ef166510db9440760e6c0f5e385c88 | 248 | py | Python | my_code.py | Athenian-Computer-Science/write-file-practice-assignment-template | 937fd9fea311b65f76fee4e9003724740f0b18af | [
"Apache-2.0"
] | null | null | null | my_code.py | Athenian-Computer-Science/write-file-practice-assignment-template | 937fd9fea311b65f76fee4e9003724740f0b18af | [
"Apache-2.0"
] | null | null | null | my_code.py | Athenian-Computer-Science/write-file-practice-assignment-template | 937fd9fea311b65f76fee4e9003724740f0b18af | [
"Apache-2.0"
] | null | null | null | # Collaborators (including web sites where you got help: (enter none if you didn't need help)
#
# Decide on a name for your text file. Then open it and write at least 2 lines.
# Next, reopen the file and append at least 2 more lines to it.
| 22.545455 | 93 | 0.717742 | 46 | 248 | 3.869565 | 0.804348 | 0.078652 | 0.089888 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010471 | 0.229839 | 248 | 10 | 94 | 24.8 | 0.921466 | 0.939516 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d7f31ab1b12a33f8508724d87fa712c65d781517 | 243 | py | Python | tests/nowCoder/a.py | bixia/MyVnpy | c0b464dce2ca65b0d040472b53a581d933c8b742 | [
"MIT"
] | null | null | null | tests/nowCoder/a.py | bixia/MyVnpy | c0b464dce2ca65b0d040472b53a581d933c8b742 | [
"MIT"
] | null | null | null | tests/nowCoder/a.py | bixia/MyVnpy | c0b464dce2ca65b0d040472b53a581d933c8b742 | [
"MIT"
] | null | null | null | #
# longest common substring
# @param str1 string字符串 the string
# @param str2 string字符串 the string
# @return string字符串
#
class Solution:
def LCS(self , str1 , str2 ):
# write code here
# dp[i][j] str1在i处,str2在j处时,它的最长公共子串
| 20.25 | 44 | 0.666667 | 31 | 243 | 5.225806 | 0.774194 | 0.148148 | 0.222222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032432 | 0.238683 | 243 | 11 | 45 | 22.090909 | 0.843243 | 0.654321 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d7ff168cd8b57d85133ece5a6f61d43d4c8b2c20 | 8,068 | py | Python | pytorch/testing_hmf.py | JSHBaxter/DeepFlow | aff9ebff59a96289918a7efabddab4c38872f7b9 | [
"Unlicense"
] | null | null | null | pytorch/testing_hmf.py | JSHBaxter/DeepFlow | aff9ebff59a96289918a7efabddab4c38872f7b9 | [
"Unlicense"
] | null | null | null | pytorch/testing_hmf.py | JSHBaxter/DeepFlow | aff9ebff59a96289918a7efabddab4c38872f7b9 | [
"Unlicense"
] | null | null | null | import unittest
import numpy as np
import time
import torch
from hmf_deepflow import HMF_MAP1d,HMF_MAP2d,HMF_MAP3d
from hmf_deepflow import HMF_Mean1d,HMF_Mean2d,HMF_Mean3d
b=1
l=3
c=2**l
br=2**(l+1)-2
x=2**12
epsilon = 0.000000001
def get_size_into(d, device):
x_used = int(x**(1/d)+0.001)
parentage = np.zeros(shape=(br,)).astype(np.int32)
for i in range(br):
parentage[i] = i//2-1
parentage = torch.tensor(parentage, device=torch.device(device))
return tuple( [b,c]+[x_used for i in range(d)] ), tuple( [b,br]+[x_used for i in range(d)] ), \
tuple( [1,c]+[x_used for i in range(d)] ), tuple( [1,br]+[x_used for i in range(d)] ), \
tuple([i+2 for i in range(d)]), parentage,
def test_no_smoothness(d,device,asserter):
print("Testing (no smoothness) \t Dim: " +str(d)+ " \t Dev: " + device)
size_info_d, size_info_r, size_red_info_d, size_red_info_r, axes, parentage = get_size_into(d, device)
data_t = np.random.normal(0,1,size=size_info_d).astype(np.float32)
data_w = np.random.normal(0,1,size=size_info_d).astype(np.float32)
data_rx = np.zeros(shape=size_info_r).astype(np.float32)
if d > 1:
data_ry = np.zeros(shape=size_info_r).astype(np.float32)
if d > 2:
data_rz = np.zeros(shape=size_info_r).astype(np.float32)
t = torch.tensor(data_t, device=torch.device(device))
t.requires_grad = True
w = torch.tensor(data_w, device=torch.device(device))
rx = torch.tensor(data_rx, device=torch.device(device))
rx.requires_grad = True
if d > 1:
ry = torch.tensor(data_ry, device=torch.device(device))
ry.requires_grad = True
if d > 2:
rz = torch.tensor(data_rz, device=torch.device(device))
rz.requires_grad = True
if d == 1:
oa = torch.exp(HMF_MAP1d.apply(t,rx,parentage))
print("Finished MAP")
om = HMF_Mean1d.apply(t,rx,parentage)
print("Finished Mean")
elif d == 2:
oa = torch.exp(HMF_MAP2d.apply(t,rx,ry,parentage))
om = HMF_Mean2d.apply(t,rx,ry,parentage)
elif d == 3:
oa = torch.exp(HMF_MAP3d.apply(t,rx,ry,rz,parentage))
om = HMF_Mean3d.apply(t,rx,ry,rz,parentage)
loss = torch.sum(w*om)
loss.backward()
oa_np = oa.detach().cpu().numpy()
om_np = om.detach().cpu().numpy()
ot_np = t.grad.detach().cpu().numpy()
#make sure not nan
asserter.assertFalse(np.any(np.isnan(oa_np)))
asserter.assertFalse(np.any(np.isnan(om_np)))
asserter.assertFalse(np.any(np.isnan(ot_np)))
#resize into more usable form
dt_np_l = [data_t[0,i,...].flatten() for i in range(c)]
dw_np_l = [data_w[0,i,...].flatten() for i in range(c)]
oa_np_l = [oa_np[0,i,...].flatten() for i in range(c)]
om_np_l = [om_np[0,i,...].flatten() for i in range(c)]
ot_np_l = [ot_np[0,i,...].flatten() for i in range(c)]
x_space = len(dt_np_l[0])
#ensure MAP assigns 1 to highest term and 0 to everything else
for i in range(x_space):
highest = max([o[i] for o in dt_np_l])
for ic in range(c):
if(dt_np_l[ic][i] == highest and oa_np_l[ic][i] < 0.5):
raise Exception(str(dt_np_l[ic][i])+"\t"+str([o[i] for o in dt_np_l])+"\t"+str(highest)+"\t"+str(oa_np_l[ic][i])+"\t"+str([o[i] for o in oa_np_l]))
if(dt_np_l[ic][i] < highest - epsilon and oa_np_l[ic][i] > 0.5):
raise Exception(str(dt_np_l[ic][i])+"\t"+str([o[i] for o in dt_np_l])+"\t"+str(highest)+"\t"+str(oa_np_l[ic][i])+"\t"+str([o[i] for o in oa_np_l]))
#ensure mean pass is equivalent to the data terms only
for i in range(c):
for val_df, val_d in zip(om_np_l[i],dt_np_l[i]):
if(abs(val_df-val_d) > epsilon):
raise Exception(str(val_df) + "\t" + str(val_d))
#ensure gradient wrt data terms are passed immediately through
for i in range(c):
for val_df, val_d in zip(ot_np_l[i],dw_np_l[i]):
if(abs(val_df-val_d) > epsilon):
raise Exception(str(val_df) + "\t" + str(val_d))
def test_smoothness_dom(d,device,asserter):
print("Testing (smoothness dom.) \t Dim: " +str(d)+ " \t Dev: " + device)
size_info_d, size_info_r, size_red_info_d, size_red_info_r, axes, parentage = get_size_into(d, device)
winner = int(np.random.uniform()*c)
data_t = 1*np.random.uniform(0,1,size=size_info_d).astype(np.float32)
data_t[:,winner,...] = 0.75
data_rx = 100+np.zeros(shape=size_info_r).astype(np.float32)
if d > 1:
data_ry = 100+np.zeros(shape=size_info_r).astype(np.float32)
if d > 2:
data_rz = 100+np.zeros(shape=size_info_r).astype(np.float32)
t = torch.tensor(data_t, device=torch.device(device))
t.requires_grad = True
rx = torch.tensor(data_rx, device=torch.device(device))
rx.requires_grad = True
if d > 1:
ry = torch.tensor(data_ry, device=torch.device(device))
if d > 2:
rz = torch.tensor(data_rz, device=torch.device(device))
if d == 1:
oa = torch.exp(HMF_MAP1d.apply(t,rx,parentage))
print("Finished MAP")
om = HMF_Mean1d.apply(t,rx,parentage)
print("Finished Mean")
elif d == 2:
oa = torch.exp(HMF_MAP2d.apply(t,rx,ry,parentage))
om = HMF_Mean2d.apply(t,rx,ry,parentage)
elif d == 3:
oa = torch.exp(HMF_MAP3d.apply(t,rx,ry,rz,parentage))
om = HMF_Mean3d.apply(t,rx,ry,rz,parentage)
oa_np = oa.detach().cpu().numpy()
om_np = om.detach().cpu().numpy()
#make sure not nan
asserter.assertFalse(np.any(np.isnan(oa_np)))
asserter.assertFalse(np.any(np.isnan(om_np)))
asserter.assertFalse(np.any(np.isnan(om_np)))
#resize into more usable form
dt_np_l = [data_t[0,i,...].flatten() for i in range(c)]
oa_np_l = [oa_np[0,i,...].flatten() for i in range(c)]
om_np_l = [om_np[0,i,...].flatten() for i in range(c)]
x_space = len(dt_np_l[0])
#ensure MAP assigns 1 to highest terms
sums = [np.sum(o) for o in dt_np_l]
highest = max(sums)
for i in range(c):
for val_df in oa_np_l[i]:
if(sums[i] == highest and val_df < 0.5):
raise Exception(str(sums[i])+ "\t" + str(sums) + "\t" + str(val_df))
if(sums[i] < highest and val_df > 0.5):
raise Exception(str(sums[i])+ "\t" + str(sums) + "\t" + str(val_df))
class Test_Extreme(unittest.TestCase):
def test_no_smoothness_1D(self):
print("")
test_no_smoothness(1,"cpu",self)
if torch.has_cuda:
test_no_smoothness(1,"cuda",self)
def test_no_smoothness_2D(self):
print("")
test_no_smoothness(2,"cpu",self)
if torch.has_cuda:
test_no_smoothness(2,"cuda",self)
def test_no_smoothness_3D(self):
print("")
test_no_smoothness(3,"cpu",self)
if torch.has_cuda:
test_no_smoothness(3,"cuda",self)
def test_smoothness_dom_1D(self):
print("")
if torch.has_cuda:
test_smoothness_dom(1,"cuda",self)
test_smoothness_dom(1,"cpu",self)
def test_smoothness_dom_2D(self):
print("")
if torch.has_cuda:
test_smoothness_dom(2,"cuda",self)
test_smoothness_dom(2,"cpu",self)
def test_smoothness_dom_3D(self):
print("")
if torch.has_cuda:
test_smoothness_dom(3,"cuda",self)
test_smoothness_dom(3,"cpu",self)
#def test_equivalence_1d(self):
# print("")
# if torch.has_cuda:
# test_device_equivalence(1,["cpu","cuda"],self)
#def test_equivalence_2d(self):
# print("")
# if torch.has_cuda:
# test_device_equivalence(2,["cpu","cuda"],self)
#def test_equivalence_3d(self):
# print("")
# if torch.has_cuda:
# test_device_equivalence(3,["cpu","cuda"],self)
if __name__ == '__main__':
unittest.main()
| 33.757322 | 163 | 0.602132 | 1,333 | 8,068 | 3.444111 | 0.114779 | 0.01895 | 0.023524 | 0.043128 | 0.814855 | 0.739708 | 0.697669 | 0.690264 | 0.680462 | 0.580048 | 0 | 0.023654 | 0.240208 | 8,068 | 238 | 164 | 33.89916 | 0.725285 | 0.081681 | 0 | 0.518519 | 0 | 0 | 0.028695 | 0 | 0 | 0 | 0 | 0 | 0.049383 | 1 | 0.055556 | false | 0 | 0.037037 | 0 | 0.104938 | 0.074074 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
cc04f0248d3ca78f25e38f1198a1a30f13977b87 | 2,047 | py | Python | refex/python/matchers/test_extern_matchers.py | ssbr/refex | 221d343b8584362900fb93a07ff96a4b9d9d4ece | [
"Apache-2.0"
] | 11 | 2020-08-28T03:54:49.000Z | 2022-01-06T05:55:21.000Z | refex/python/matchers/test_extern_matchers.py | ssbr/refex | 221d343b8584362900fb93a07ff96a4b9d9d4ece | [
"Apache-2.0"
] | 5 | 2020-08-25T16:19:05.000Z | 2021-06-07T21:31:03.000Z | refex/python/matchers/test_extern_matchers.py | ssbr/refex | 221d343b8584362900fb93a07ff96a4b9d9d4ece | [
"Apache-2.0"
] | null | null | null | # Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for refex.matchers.extern_matchers."""
from absl.testing import absltest
from refex import search
from refex.python import matcher_test_util
from refex.python.matchers import extern_matchers
def _rewrite(m, code):
return search.rewrite_string(
search.PyMatcherRewritingSearcher.from_matcher(m, {}), code, 'example.py')
class RewriteFileTest(matcher_test_util.MatcherTestCase):
def test_rewrite_fail(self):
class Fail(extern_matchers.RewriteFile):
def rewrite(self, context, candidate):
return None
self.assertEqual(_rewrite(Fail('metavar'), 'old'), 'old')
def test_rewrite_succeed(self):
class Succeed(extern_matchers.RewriteFile):
def rewrite(self, context, candidate):
return 'new'
self.assertEqual(_rewrite(Succeed('metavar'), 'old'), 'new')
class ExternalCommandTest(matcher_test_util.MatcherTestCase):
def test_replace_noop(self):
code = '1\n2\n'
self.assertEqual(
_rewrite(extern_matchers.ExternalCommand('cat', ['cat']), code), code)
def test_replace(self):
code = '1\n2\n'
self.assertEqual(
_rewrite(
extern_matchers.ExternalCommand('echo', ['echo', 'hello']), code),
'hello\n')
def test_shell_true(self):
code = '1\n2\n'
self.assertEqual(
_rewrite(
extern_matchers.ExternalCommand('echo', 'echo hello', shell=True),
code), 'hello\n')
if __name__ == '__main__':
absltest.main()
| 28.041096 | 80 | 0.706888 | 262 | 2,047 | 5.377863 | 0.438931 | 0.069553 | 0.07807 | 0.023421 | 0.291696 | 0.291696 | 0.239177 | 0.239177 | 0.239177 | 0.15259 | 0 | 0.008373 | 0.183195 | 2,047 | 72 | 81 | 28.430556 | 0.83433 | 0.288715 | 0 | 0.27027 | 0 | 0 | 0.077886 | 0 | 0 | 0 | 0 | 0 | 0.135135 | 1 | 0.216216 | false | 0 | 0.108108 | 0.081081 | 0.513514 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
cc0916cd1f20533e61a94c416a8e969ecfed47c0 | 1,401 | py | Python | cheese_farm/python/cheese_pb2_grpc.py | pantuza/grpc-golang-examples | d43abfca763ea0a380321d5366da002935da7cef | [
"Apache-2.0"
] | 5 | 2019-09-28T14:55:51.000Z | 2020-07-24T14:08:43.000Z | cheese_farm/python/cheese_pb2_grpc.py | pantuza/grpc-golang-examples | d43abfca763ea0a380321d5366da002935da7cef | [
"Apache-2.0"
] | null | null | null | cheese_farm/python/cheese_pb2_grpc.py | pantuza/grpc-golang-examples | d43abfca763ea0a380321d5366da002935da7cef | [
"Apache-2.0"
] | null | null | null | # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc
import cheese_pb2 as cheese__pb2
class CheeseServiceStub(object):
# missing associated documentation comment in .proto file
pass
def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.Order = channel.unary_unary(
'/cheesefarm.CheeseService/Order',
request_serializer=cheese__pb2.CheeseRequest.SerializeToString,
response_deserializer=cheese__pb2.Cheese.FromString,
)
class CheeseServiceServicer(object):
# missing associated documentation comment in .proto file
pass
def Order(self, request, context):
# missing associated documentation comment in .proto file
pass
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def add_CheeseServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
'Order': grpc.unary_unary_rpc_method_handler(
servicer.Order,
request_deserializer=cheese__pb2.CheeseRequest.FromString,
response_serializer=cheese__pb2.Cheese.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'cheesefarm.CheeseService', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
| 29.808511 | 71 | 0.745896 | 151 | 1,401 | 6.649007 | 0.417219 | 0.053785 | 0.089641 | 0.110558 | 0.173307 | 0.173307 | 0.173307 | 0.173307 | 0.121514 | 0.121514 | 0 | 0.005204 | 0.177016 | 1,401 | 46 | 72 | 30.456522 | 0.865568 | 0.201999 | 0 | 0.107143 | 1 | 0 | 0.096715 | 0.050182 | 0 | 0 | 0 | 0 | 0 | 1 | 0.107143 | false | 0.107143 | 0.071429 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
cc0e0a43c8b56f5eb033e503c89c44f5232f6af2 | 1,043 | py | Python | soccer/gameplay/plays/testing/set_formation.py | rfccambridge/robocup-software-2017 | c35cf6455597c1d4eb3b4afd0694fb9f5f6a3c0a | [
"Apache-2.0"
] | null | null | null | soccer/gameplay/plays/testing/set_formation.py | rfccambridge/robocup-software-2017 | c35cf6455597c1d4eb3b4afd0694fb9f5f6a3c0a | [
"Apache-2.0"
] | null | null | null | soccer/gameplay/plays/testing/set_formation.py | rfccambridge/robocup-software-2017 | c35cf6455597c1d4eb3b4afd0694fb9f5f6a3c0a | [
"Apache-2.0"
] | null | null | null | import play
import behavior
import tactics.set_formation
import robocup
import constants
class SetFormation(play.Play):
def __init__(self, formation=None):
super().__init__(continuous=False)
self.add_transition(behavior.Behavior.State.start,
behavior.Behavior.State.running, lambda: True,
'immediately')
self.add_transition(
behavior.Behavior.State.running, behavior.Behavior.State.completed,
lambda: self.subbehavior_with_name("SetFormation").state == behavior.Behavior.State.completed,
'all robots reach target positions')
self.add_transition(
behavior.Behavior.State.completed, behavior.Behavior.State.running,
lambda: self.subbehavior_with_name("SetFormation").state == behavior.Behavior.State.running,
'robots havent reached target positions')
l = tactics.set_formation.SetFormation(formation)
self.add_subbehavior(l, name="SetFormation", required=True)
| 40.115385 | 106 | 0.681687 | 107 | 1,043 | 6.476636 | 0.35514 | 0.184704 | 0.242424 | 0.161616 | 0.44733 | 0.357864 | 0.193362 | 0.193362 | 0.193362 | 0.193362 | 0 | 0 | 0.225312 | 1,043 | 25 | 107 | 41.72 | 0.857673 | 0 | 0 | 0.095238 | 0 | 0 | 0.113135 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.047619 | false | 0 | 0.238095 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
cc1b87efa9aa3a2bbc9f4fd54499ae686574a7d4 | 1,328 | py | Python | quiz/models.py | arpitptl/quiz-up | e85329e799abe4da314021369990413225b34ae8 | [
"MIT"
] | null | null | null | quiz/models.py | arpitptl/quiz-up | e85329e799abe4da314021369990413225b34ae8 | [
"MIT"
] | null | null | null | quiz/models.py | arpitptl/quiz-up | e85329e799abe4da314021369990413225b34ae8 | [
"MIT"
] | null | null | null | from django.db import models
from django.contrib.auth.models import User
class Quiz(models.Model):
name = models.CharField(max_length=50)
description = models.CharField(max_length=500)
number_of_questions = models.IntegerField(default=1)
duration = models.IntegerField(help_text="Duration of the quiz in seconds", default="60")
def __str__(self):
return self.name
def get_questions(self):
return self.questions.all()
class Question(models.Model):
content = models.CharField(max_length=200)
quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE, related_name='questions')
def __str__(self):
return self.content
def get_options(self):
return self.options.all()
class Option(models.Model):
content = models.CharField(max_length=200)
correct = models.BooleanField(default=False)
question = models.ForeignKey(Question, on_delete=models.CASCADE, related_name='options')
def __str__(self):
return f"question: {self.question.content}, option: {self.content}, correct: {self.correct}"
class UserMarks(models.Model):
quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE)
score = models.FloatField()
def __str__(self):
return str(self.quiz)
| 28.255319 | 100 | 0.715361 | 168 | 1,328 | 5.470238 | 0.321429 | 0.065288 | 0.078346 | 0.104461 | 0.286181 | 0.242655 | 0.195865 | 0.195865 | 0 | 0 | 0 | 0.012739 | 0.17244 | 1,328 | 46 | 101 | 28.869565 | 0.823476 | 0 | 0 | 0.2 | 0 | 0.033333 | 0.098793 | 0.0181 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.066667 | 0.2 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
cc21a933c99da01c489e9660e9b07f5290afa44d | 140 | py | Python | src/main.py | AntoineMeresse/urt-skin-generator | 02c92913c395f376a9d32307ed68d8c4a8a8b892 | [
"MIT"
] | null | null | null | src/main.py | AntoineMeresse/urt-skin-generator | 02c92913c395f376a9d32307ed68d8c4a8a8b892 | [
"MIT"
] | null | null | null | src/main.py | AntoineMeresse/urt-skin-generator | 02c92913c395f376a9d32307ed68d8c4a8a8b892 | [
"MIT"
] | null | null | null | from explorer import FileExplorer
def main():
explorer = FileExplorer()
explorer.to_string()
if __name__ == "__main__":
main() | 17.5 | 33 | 0.685714 | 15 | 140 | 5.8 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | 140 | 8 | 34 | 17.5 | 0.776786 | 0 | 0 | 0 | 0 | 0 | 0.056738 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.166667 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
cc2f7ed0e898bc7c4706d02d3c7c28a3f3d35656 | 423 | py | Python | ipy_user_conf.py | mbeko/moztrap | db75e1f8756ef2c0c39652a66302b19c8afa0256 | [
"BSD-2-Clause"
] | 1 | 2015-02-10T15:09:42.000Z | 2015-02-10T15:09:42.000Z | ipy_user_conf.py | mbeko/moztrap | db75e1f8756ef2c0c39652a66302b19c8afa0256 | [
"BSD-2-Clause"
] | null | null | null | ipy_user_conf.py | mbeko/moztrap | db75e1f8756ef2c0c39652a66302b19c8afa0256 | [
"BSD-2-Clause"
] | null | null | null | """
Makes IPython import all of your projects models when shell is started.
1. Save as ipy_user_conf.py in project root
2. ./manage.py shell
3. profit
"""
import IPython.ipapi
ip = IPython.ipapi.get()
def main():
print "\nImported:\n\n"
imports = [
"import datetime",
"from moztrap import model",
]
for imp in imports:
ip.ex(imp)
print imp
print "\n"
main()
| 14.586207 | 71 | 0.605201 | 60 | 423 | 4.233333 | 0.7 | 0.094488 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009901 | 0.283688 | 423 | 28 | 72 | 15.107143 | 0.828383 | 0 | 0 | 0 | 0 | 0 | 0.213483 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.461538 | null | null | 0.230769 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
cc31f2eb12334d5c2ff5f45c606ea152f5db3e25 | 1,689 | py | Python | rlkit/torch/algorithms/her/her.py | Ericonaldo/ILSwiss | efd25d457fd1578005c6fbc45cae29e9ab64a99d | [
"MIT"
] | 46 | 2021-07-28T03:15:23.000Z | 2022-03-31T22:19:22.000Z | rlkit/torch/algorithms/her/her.py | Ericonaldo/ILSwiss | efd25d457fd1578005c6fbc45cae29e9ab64a99d | [
"MIT"
] | 3 | 2021-07-30T09:55:01.000Z | 2022-03-17T17:21:26.000Z | rlkit/torch/algorithms/her/her.py | Ericonaldo/ILSwiss | efd25d457fd1578005c6fbc45cae29e9ab64a99d | [
"MIT"
] | 5 | 2021-07-28T16:45:14.000Z | 2022-03-11T01:39:19.000Z | import numpy as np
from collections import OrderedDict
import torch
import torch.optim as optim
from torch import nn
import torch.nn.functional as F
import gtimer as gt
import rlkit.torch.utils.pytorch_util as ptu
from rlkit.torch.core import np_to_pytorch_batch
from rlkit.torch.algorithms.torch_rl_algorithm import TorchRLAlgorithm
from rlkit.data_management.relabel_replay_buffer import HindsightReplayBuffer
from rlkit.data_management.path_builder import PathBuilder
from rlkit.samplers import PathSampler
class HER(TorchRLAlgorithm):
"""
Hindsight Experience Replay. Default using TD3 for RL policy trainer.
"""
def __init__(
self,
replay_buffer=None,
her_ratio=0.8,
relabel_type="future",
**kwargs
):
if replay_buffer is None:
assert kwargs['max_path_length'] < kwargs['replay_buffer_size']
replay_buffer = HindsightReplayBuffer(
kwargs['replay_buffer_size'], kwargs['env'], random_seed=np.random.randint(10000), relabel_type=relabel_type, her_ratio=her_ratio
)
super().__init__(replay_buffer=replay_buffer, **kwargs)
def get_batch(self, keys=None):
buffer = self.replay_buffer
batch = buffer.random_batch(self.batch_size, keys=keys)
batch = np_to_pytorch_batch(batch)
return batch
def _get_action_and_info(self, observation):
"""
Get an action to take in the environment.
:param observation:
:return:
"""
self.exploration_policy.set_num_steps_total(self._n_env_steps_total)
return self.exploration_policy.get_actions(
observation,
) | 33.117647 | 145 | 0.703375 | 212 | 1,689 | 5.330189 | 0.419811 | 0.095575 | 0.024779 | 0.028319 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006093 | 0.222617 | 1,689 | 51 | 146 | 33.117647 | 0.854532 | 0.082889 | 0 | 0 | 0 | 0 | 0.040134 | 0 | 0 | 0 | 0 | 0 | 0.027027 | 1 | 0.081081 | false | 0 | 0.351351 | 0 | 0.513514 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
0bc3bc328ea369665bdf3aec5df698a61efbc91b | 857 | py | Python | icbd/compiler/tests/b.py | kmod/icbd | 9636564eb3993afa07c6220d589bbd1991923d74 | [
"MIT"
] | 7 | 2015-04-06T15:17:13.000Z | 2020-10-21T04:57:00.000Z | icbd/compiler/tests/b.py | kmod/icbd | 9636564eb3993afa07c6220d589bbd1991923d74 | [
"MIT"
] | null | null | null | icbd/compiler/tests/b.py | kmod/icbd | 9636564eb3993afa07c6220d589bbd1991923d74 | [
"MIT"
] | 4 | 2016-05-16T17:53:08.000Z | 2020-11-28T17:18:50.000Z | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def print_time():
import time
print time.time()
# print "%0.3f" % time.time()
print_time()
table = [range(1000) for i in range(1000)]
print_time()
class a(object):
def main(self, table):
_buffer = []
_buffer_write = _buffer.append
_buffer_write('<table xmlns:py="http://spitfire/">')
_buffer_write('\n')
for i in xrange(len(table)):
row = table[i]
_buffer_write('<tr>')
_buffer_write('\n')
for j in xrange(len(row)):
column = row[j]
_buffer_write('<td>')
_buffer_write(str(column))
_buffer_write('</td>')
_buffer_write('\n')
_buffer_write('</tr>')
_buffer_write('\n')
_buffer_write('</table>')
_buffer_write('\n')
print_time()
return ''.join(_buffer)
a().main(table)
print_time()
| 21.974359 | 56 | 0.581097 | 113 | 857 | 4.106195 | 0.371681 | 0.30819 | 0.12931 | 0.064655 | 0.237069 | 0.107759 | 0 | 0 | 0 | 0 | 0 | 0.016768 | 0.234539 | 857 | 38 | 57 | 22.552632 | 0.690549 | 0.08168 | 0 | 0.3 | 0 | 0 | 0.090561 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.033333 | null | null | 0.2 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
0bc878822f0cdfb2142a0b635f68e9e180c65f97 | 12,144 | py | Python | src/unity/python/turicreate/toolkits/_feature_engineering/_feature_engineering.py | shreyasvj25/turicreate | 32e84ca16aef8d04aff3d49ae9984bd49326bffd | [
"BSD-3-Clause"
] | 1 | 2018-12-15T20:03:51.000Z | 2018-12-15T20:03:51.000Z | src/unity/python/turicreate/toolkits/_feature_engineering/_feature_engineering.py | shreyasvj25/turicreate | 32e84ca16aef8d04aff3d49ae9984bd49326bffd | [
"BSD-3-Clause"
] | 3 | 2021-09-08T02:18:00.000Z | 2022-03-12T00:39:44.000Z | src/unity/python/turicreate/toolkits/_feature_engineering/_feature_engineering.py | ZeroInfinite/turicreate | dd210c2563930881abd51fd69cb73007955b33fd | [
"BSD-3-Clause"
] | 1 | 2020-10-21T17:46:28.000Z | 2020-10-21T17:46:28.000Z | # -*- coding: utf-8 -*-
# Copyright © 2017 Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can
# be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
from __future__ import print_function as _
from __future__ import division as _
from __future__ import absolute_import as _
import turicreate as _tc
from turicreate.util import _make_internal_url
import turicreate.connect.main as glconnect
from turicreate.toolkits._internal_utils import _toolkit_repr_print, \
_precomputed_field, \
_raise_error_if_not_sframe
# Base class for models written by users
# ---------------------------------------------------
class TransformerBase(object):
"""
An abstract base class for user defined Transformers.
**Overview**
A Transformer is a stateful object that transforms input data (as an
SFrame) from one form to another. Transformers are commonly used for
feature engineering. In addition to the modules provided in Turi
Create, users can extend the following class and write transformers that
integrate seamlessly with the already existing ones.
**Defining Custom Transformers**
Each transformer object is one must have the following methods:
+---------------+---------------------------------------------------+
| Method | Description |
+===============+===================================================+
| __init__ | Construct the object. |
+---------------+---------------------------------------------------+
| fit | Fit the object using training data. |
+---------------+---------------------------------------------------+
| transform | Transform the object on training/test data. |
+---------------+---------------------------------------------------+
In addition to these methods, there are convenience methods with default
implementations:
+---------------+---------------------------------------------------+
| Method | Description |
+===============+===================================================+
| fit_transform | First perform fit() and then transform() on data. |
+---------------+---------------------------------------------------+
See Also
--------
:class:`turicreate.toolkits.feature_engineering.TransformerChain`,
:func:`turicreate.toolkits.feature_engineering.create`
Notes
------
- User defined Transformers behave identically to those that are already
provided. They can be saved/loaded both locally and remotely, can
be chained together, and can be deployed as components of predictive
services.
Examples
--------
In this example, we will write a simple Transformer that will subtract
(for each column) the mean value observed during the `fit` stage.
.. sourcecode:: python
import turicreate
from . import TransformerBase
class MyTransformer(TransformerBase):
def __init__(self):
pass
def fit(self, dataset):
''' Learn means during the fit stage.'''
self.mean = {}
for col in dataset.column_names():
self.mean[col] = dataset[col].mean()
return self
def transform(self, dataset):
''' Subtract means during the transform stage.'''
new_dataset = turicreate.SFrame()
for col in dataset.column_names():
new_dataset[col] = dataset[col] - self.mean[col]
return new_dataset
# Create the model
model = tc.feature_engineering.create(dataset, MyTransformer())
# Transform new data
transformed_sf = model.transform(sf)
# Save and load this model.
model.save('foo-bar')
loaded_model = turicreate.load_model('foo-bar')
"""
def __init__(self, **kwargs):
pass
def _get_summary_struct(self):
model_fields = []
for attr in self.__dict__:
if not attr.startswith('_'):
model_fields.append((attr, _precomputed_field(getattr(self, attr))))
return ([model_fields], ['Attributes'] )
def __repr__(self):
(sections, section_titles) = self._get_summary_struct()
return _toolkit_repr_print(self, sections, section_titles, width=20)
def fit(self, data):
"""
Fits a transformer using the SFrame `data`.
Parameters
----------
data : SFrame
The data used to fit the transformer.
Returns
-------
self (A fitted object)
See Also
--------
transform, fit_transform
Examples
--------
.. sourcecode:: python
my_tr = MyTransformer(features = ['salary', 'age'])
my_tr = mt_tr.fit(sf)
"""
pass
def transform(self, data):
"""
Transform the SFrame `data` using a fitted model.
Parameters
----------
data : SFrame
The data to be transformed.
Returns
-------
A transformed SFrame.
Returns
-------
out: SFrame
A transformed SFrame.
See Also
--------
fit, fit_transform
Examples
--------
.. sourcecode:: python
my_tr = turicreate.feature_engineering.create(train_data,
MyTransformer())
transformed_sf = my_tr.transform(sf)
"""
raise NotImplementedError
def fit_transform(self, data):
"""
First fit a transformer using the SFrame `data` and then return a transformed
version of `data`.
Parameters
----------
data : SFrame
The data used to fit the transformer. The same data is then also
transformed.
Returns
-------
Transformed SFrame.
See Also
--------
transform, fit_transform
Notes
-----
The default implementation calls `fit` and then calls `transform`.
You may override this function with a more efficient implementation."
Examples
--------
.. sourcecode:: python
my_tr = MyTransformer()
transformed_sf = my_tr.fit_transform(sf)
"""
self.fit(data)
return self.transform(data)
@classmethod
def _get_queryable_methods(cls):
return {'transform': {}}
def _get_instance_and_data(self):
raise NotImplementedError
# Base class for Models written in C++ using the SDK.
# ---------------------------------------------------
class Transformer(TransformerBase):
_fit_examples_doc = '''
'''
_fit_transform_examples_doc = '''
'''
_transform_examples_doc = '''
'''
def __init__(self, model_proxy = None, _class = None):
self.__proxy__ = model_proxy
if _class:
self.__class__ = _class
def fit(self, data):
"""
Fit a transformer using the SFrame `data`.
Parameters
----------
data : SFrame
The data used to fit the transformer.
Returns
-------
self (A fitted version of the object)
See Also
--------
transform, fit_transform
Examples
--------
.. sourcecode:: python
{examples}
"""
_raise_error_if_not_sframe(data, "data")
self.__proxy__.fit(data)
return self
def transform(self, data):
"""
Transform the SFrame `data` using a fitted model.
Parameters
----------
data : SFrame
The data to be transformed.
Returns
-------
A transformed SFrame.
See Also
--------
fit, fit_transform
Examples
--------
.. sourcecode:: python
{examples}
"""
_raise_error_if_not_sframe(data, "data")
return self.__proxy__.transform(data)
def fit_transform(self, data):
"""
First fit a transformer using the SFrame `data` and then return a
transformed version of `data`.
Parameters
----------
data : SFrame
The data used to fit the transformer. The same data is then also
transformed.
Returns
-------
Transformed SFrame.
See Also
--------
fit, transform
Notes
------
- Fit transform modifies self.
Examples
--------
.. sourcecode:: python
{examples}
"""
_raise_error_if_not_sframe(data, "data")
return self.__proxy__.fit_transform(data)
def _list_fields(self):
"""
List of fields stored in the model. Each of these fields can be queried
using the ``get(field)`` function or ``m[field]``.
Returns
-------
out : list[str]
A list of fields that can be queried using the ``get`` method.
See Also
---------
get
"""
return self.__proxy__.list_fields()
def _get(self, field):
"""Return the value for the queried field.
Each of these fields can be queried in one of two ways:
>>> out = m['field']
>>> out = m.get('field') # equivalent to previous line
Parameters
----------
field : string
Name of the field to be retrieved.
Returns
-------
out : value
The current value of the requested field.
"""
if field in self._list_fields():
return self.__proxy__.get(field)
else:
raise KeyError('Field \"%s\" not in model. Available fields are '
'%s.' % (field, ', '.join(self._list_fields())))
def __getitem__(self, key):
return self.get(key)
@classmethod
def _is_gl_pickle_safe(cls):
"""
Return True if the model is GLPickle safe i.e if the model does not
contain elements that are written using Python + Turi objects.
"""
return False
@classmethod
def _get_queryable_methods(cls):
return {'transform': {'data': 'sframe'}}
class _SampleTransformer(Transformer):
def __init__(self, features=None, constant=0.5):
# Set up options
opts = {}
opts['features'] = features
opts['constant'] = constant
# Initialize object
proxy = _tc.extensions._SampleTransformer()
proxy.init_transformer(opts)
super(_SampleTransformer, self).__init__(proxy, self.__class__)
def _get_summary_struct(self):
"""
Returns a structured description of the model, including (where
relevant) the schema of the training data, description of the training
data, training statistics, and model hyperparameters.
Returns
-------
sections : list (of list of tuples)
A list of summary sections.
Each section is a list.
Each item in a section list is a tuple of the form:
('<label>','<field>')
section_titles: list
A list of section titles.
The order matches that of the 'sections' object.
"""
section = []
section_titles = ['Attributes']
for f in self._list_fields():
section.append( ("%s" % f,"%s"% f) )
return ([section], section_titles)
def __repr__(self):
(section, section_titles) = self._get_summary_struct()
return _toolkit_repr_print(self, section, section_titles, width=30)
| 28.777251 | 85 | 0.525527 | 1,197 | 12,144 | 5.142857 | 0.244779 | 0.025341 | 0.012671 | 0.022417 | 0.311241 | 0.274854 | 0.252112 | 0.240903 | 0.224334 | 0.211339 | 0 | 0.0016 | 0.330863 | 12,144 | 421 | 86 | 28.845606 | 0.755845 | 0.582098 | 0 | 0.287356 | 0 | 0 | 0.042645 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.229885 | false | 0.022989 | 0.08046 | 0.034483 | 0.54023 | 0.045977 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
0bce112e4655924624f844f4d85fa286633dc882 | 1,251 | py | Python | OCBO/strategies/__init__.py | zhaofeng-shu33/OCBO | a8e132f3ab77da4a6f58c630b27bfe7e37cc0380 | [
"MIT"
] | null | null | null | OCBO/strategies/__init__.py | zhaofeng-shu33/OCBO | a8e132f3ab77da4a6f58c630b27bfe7e37cc0380 | [
"MIT"
] | null | null | null | OCBO/strategies/__init__.py | zhaofeng-shu33/OCBO | a8e132f3ab77da4a6f58c630b27bfe7e37cc0380 | [
"MIT"
] | null | null | null | from argparse import Namespace
from OCBO.strategies.agnostic_opt import agn_strats
from OCBO.strategies.corr_opt import corr_strats, corr_args
from OCBO.strategies.multi_opt import multi_opt_args
from OCBO.strategies.random_strat import RandomOpt, JointRandom
from OCBO.strategies.mei import MEI
from OCBO.strategies.mts import MTS
from OCBO.strategies.joint_agnostic_opt import ja_strats
from OCBO.strategies.joint_mei import JointMEI
from OCBO.strategies.joint_mts import JointMTS
discrete_strategies = [Namespace(name='Random', impl=RandomOpt),
Namespace(impl=MTS, name=MTS.get_opt_method_name()),
Namespace(impl=MEI, name=MEI.get_opt_method_name())] \
+ agn_strats \
+ corr_strats
joint_strategies = [Namespace(impl=JointRandom,
name=JointRandom.get_opt_method_name()),
Namespace(impl=JointMTS,
name=JointMTS.get_opt_method_name()),
Namespace(impl=JointMEI,
name=JointMEI.get_opt_method_name())] \
+ ja_strats
strategies = discrete_strategies + joint_strategies
strat_args = corr_args + multi_opt_args
| 41.7 | 77 | 0.673062 | 146 | 1,251 | 5.493151 | 0.191781 | 0.089776 | 0.201995 | 0.099751 | 0.108479 | 0.108479 | 0 | 0 | 0 | 0 | 0 | 0 | 0.257394 | 1,251 | 29 | 78 | 43.137931 | 0.863294 | 0 | 0 | 0 | 0 | 0 | 0.004796 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.416667 | 0 | 0.416667 | 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 | 0 | 0 | 0 | 2 |
0bcfe8c6ad58610913d76b1ce63fb464fc0c3e85 | 1,100 | py | Python | App/forms.py | Aishu1412/WomenHealthCare | a972c2b12d8afe2bdb0b74a51f85dd7ad0edf39c | [
"MIT"
] | 3 | 2018-01-07T16:42:55.000Z | 2021-05-31T14:21:11.000Z | App/forms.py | Aishu1412/WomenHealthCare | a972c2b12d8afe2bdb0b74a51f85dd7ad0edf39c | [
"MIT"
] | null | null | null | App/forms.py | Aishu1412/WomenHealthCare | a972c2b12d8afe2bdb0b74a51f85dd7ad0edf39c | [
"MIT"
] | 2 | 2017-01-02T20:39:02.000Z | 2019-08-21T02:02:24.000Z | from django.contrib.auth.forms import AuthenticationForm
from django import forms
from django.contrib.auth.models import User
from .models import *
class UserSignUpForm(forms.ModelForm):
class Meta:
model = User
fields = ('username','password','email','first_name','last_name')
help_texts = {
'username': None,
}
widgets = {
'password':forms.PasswordInput(),
}
class ModelUserSignup(forms.ModelForm):
class Meta:
model = ModelUser
exclude = ('user', 'role',)
class LoginForm(AuthenticationForm):
username = forms.CharField(label="Username", max_length=30,widget=forms.TextInput(attrs={'class': 'form-control', 'name': 'username'}))
password = forms.CharField(label="Password", max_length=30,widget=forms.PasswordInput(attrs={'class': 'form-control', 'name': 'password'}))
class DiscussForm(forms.ModelForm):
class Meta:
model = ModelDiscuss
fields = ('__all__')
class AnswerForm(forms.ModelForm):
class Meta:
model = ModelAnswer
exclude = ('user', 'ques',)
class QuestionForm(forms.ModelForm):
class Meta:
model = ModelQuestion
exclude = ('user',)
| 26.829268 | 140 | 0.719091 | 124 | 1,100 | 6.306452 | 0.395161 | 0.089514 | 0.121483 | 0.147059 | 0.299233 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004197 | 0.133636 | 1,100 | 40 | 141 | 27.5 | 0.816369 | 0 | 0 | 0.151515 | 0 | 0 | 0.142727 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.090909 | 0.121212 | 0 | 0.515152 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
0be508d837483dd205c23366ea0a9152dad9118d | 140 | py | Python | week4RegularExpressions/RegularExpressionsIntroductie/findMailAddresses.py | hanbioinformatica/owe2a | f572866ef3bc75689d2d571cb393c6d60480655b | [
"Apache-2.0"
] | null | null | null | week4RegularExpressions/RegularExpressionsIntroductie/findMailAddresses.py | hanbioinformatica/owe2a | f572866ef3bc75689d2d571cb393c6d60480655b | [
"Apache-2.0"
] | null | null | null | week4RegularExpressions/RegularExpressionsIntroductie/findMailAddresses.py | hanbioinformatica/owe2a | f572866ef3bc75689d2d571cb393c6d60480655b | [
"Apache-2.0"
] | 1 | 2018-12-04T15:23:47.000Z | 2018-12-04T15:23:47.000Z | import re
b = open("demo.txt", 'r')
for regel in b:
if re.search(".*(@|\[at\]).*(\.|\[dot\])(com|nl|be)", regel):
print(regel)
| 20 | 65 | 0.492857 | 22 | 140 | 3.136364 | 0.818182 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.192857 | 140 | 6 | 66 | 23.333333 | 0.610619 | 0 | 0 | 0 | 0 | 0 | 0.328571 | 0.264286 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 0.2 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
0be6458ae67777712a9648e86be72d6174653333 | 95 | py | Python | constants.py | SonOfLilit/melody | 684e3d1e4ca9cd8d586e3f96226eb5cf7a67ff74 | [
"MIT"
] | 1 | 2021-04-05T09:34:10.000Z | 2021-04-05T09:34:10.000Z | constants.py | SonOfLilit/melody | 684e3d1e4ca9cd8d586e3f96226eb5cf7a67ff74 | [
"MIT"
] | null | null | null | constants.py | SonOfLilit/melody | 684e3d1e4ca9cd8d586e3f96226eb5cf7a67ff74 | [
"MIT"
] | null | null | null | for name in 'channel pitch time duration velocity'.split():
globals()[name.upper()] = name
| 31.666667 | 59 | 0.694737 | 13 | 95 | 5.076923 | 0.846154 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.157895 | 95 | 2 | 60 | 47.5 | 0.825 | 0 | 0 | 0 | 0 | 0 | 0.378947 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
0bf0b8b687fcadfab8f6b7b7be9b02693947260e | 152 | py | Python | ABC/056/a.py | fumiyanll23/AtCoder | 362ca9fcacb5415c1458bc8dee5326ba2cc70b65 | [
"MIT"
] | null | null | null | ABC/056/a.py | fumiyanll23/AtCoder | 362ca9fcacb5415c1458bc8dee5326ba2cc70b65 | [
"MIT"
] | null | null | null | ABC/056/a.py | fumiyanll23/AtCoder | 362ca9fcacb5415c1458bc8dee5326ba2cc70b65 | [
"MIT"
] | null | null | null | def main():
# input
a, b = input().split()
# compute
# output
print('H' if a==b else 'D')
if __name__ == '__main__':
main()
| 11.692308 | 31 | 0.486842 | 20 | 152 | 3.3 | 0.7 | 0.060606 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.328947 | 152 | 12 | 32 | 12.666667 | 0.647059 | 0.131579 | 0 | 0 | 0 | 0 | 0.078125 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | true | 0 | 0 | 0 | 0.2 | 0.2 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
040c9b330bae1e7167f5755483f6770ba2dfe9ee | 1,631 | py | Python | resolver/main.py | s4g4/hashCrack | 68120779d11334b10049ba082d37becb2d9407cd | [
"MIT"
] | null | null | null | resolver/main.py | s4g4/hashCrack | 68120779d11334b10049ba082d37becb2d9407cd | [
"MIT"
] | null | null | null | resolver/main.py | s4g4/hashCrack | 68120779d11334b10049ba082d37becb2d9407cd | [
"MIT"
] | null | null | null | __author__ = "s4g4"
__date__ = "$6 June, 2016 6:00:00 PM$"
#!/usr/bin/python
import sys
sys.path.append("..")
from config import config
import hashlib
import requests,json
from time import sleep
def getHash(line):
string_arr = line.split(":")
return string_arr[0].strip()
def find(hash):
es_url = config.get('ES_URL')
search_string ='{ "query":{ "query_string" : { "fields" : ["sha1", "sha256","md5"],"analyzer" : "whitespace", "query" : "\\"'+hash+'\\"" } }}'
result = requests.post(es_url+"/_search", data=search_string)
data = result.json()
if bool(data['hits']['hits']):
return data['hits']['hits'][0]['_source']['password']
else:
return "0"
def storeInNewFile(line,password):
line = line.strip()
with open("cracked", "a") as myfile:
myfile.write(line+":"+password+"\r\n")
if __name__ == "__main__":
with open('input.txt') as fp:
counter = 0
line_no = 0
for line in fp:
line_no = line_no+1
try:
print line
hash = getHash(line)
password = find(hash)
if password != '0':
storeInNewFile(line,password)
counter = counter+1
except Exception as e:
print ("problem with line", line,". exception is ", e)
#appending in the done file
with open("done.txt", "w") as myfile:
myfile.write(str(line_no))
#sys.exit()
sleep(0.01)
print "Data Imported Finished, total = %s" % counter
| 28.12069 | 146 | 0.534641 | 193 | 1,631 | 4.362694 | 0.476684 | 0.057007 | 0.026128 | 0.045131 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.025045 | 0.314531 | 1,631 | 57 | 147 | 28.614035 | 0.728086 | 0.034335 | 0 | 0 | 0 | 0.023256 | 0.191964 | 0.016582 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.139535 | 0.139535 | null | null | 0.069767 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
04175dbaedc6143463dde0620968b023380ec0b2 | 158 | py | Python | janitriapp/choices.py | kumarisneha/daily_news | dc067f7474cac94f6df351133efdfffb41c52627 | [
"MIT"
] | null | null | null | janitriapp/choices.py | kumarisneha/daily_news | dc067f7474cac94f6df351133efdfffb41c52627 | [
"MIT"
] | null | null | null | janitriapp/choices.py | kumarisneha/daily_news | dc067f7474cac94f6df351133efdfffb41c52627 | [
"MIT"
] | null | null | null | from django.utils.translation import ugettext_lazy as _
INTEREST_CHOICES = (
(1, _("Entertainment")),
(2, _("Sports")),
(3, _("Technology")),
)
| 17.555556 | 55 | 0.626582 | 16 | 158 | 5.8125 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.023438 | 0.189873 | 158 | 8 | 56 | 19.75 | 0.703125 | 0 | 0 | 0 | 0 | 0 | 0.183544 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.166667 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
041800311dbe4c8e956029e4a58e6a0b77650c84 | 24,122 | py | Python | src/oci/log_analytics/models/create_log_analytics_object_collection_rule_details.py | ezequielramos/oci-python-sdk | cc4235cf217beaf9feed75760e9ce82610222762 | [
"Apache-2.0",
"BSD-3-Clause"
] | 249 | 2017-09-11T22:06:05.000Z | 2022-03-04T17:09:29.000Z | src/oci/log_analytics/models/create_log_analytics_object_collection_rule_details.py | ezequielramos/oci-python-sdk | cc4235cf217beaf9feed75760e9ce82610222762 | [
"Apache-2.0",
"BSD-3-Clause"
] | 228 | 2017-09-11T23:07:26.000Z | 2022-03-23T10:58:50.000Z | src/oci/log_analytics/models/create_log_analytics_object_collection_rule_details.py | ezequielramos/oci-python-sdk | cc4235cf217beaf9feed75760e9ce82610222762 | [
"Apache-2.0",
"BSD-3-Clause"
] | 224 | 2017-09-27T07:32:43.000Z | 2022-03-25T16:55:42.000Z | # coding: utf-8
# Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel # noqa: F401
from oci.decorators import init_model_state_from_kwargs
@init_model_state_from_kwargs
class CreateLogAnalyticsObjectCollectionRuleDetails(object):
"""
The configuration details of collection rule to enable automatic log collection from an object storage bucket.
"""
#: A constant which can be used with the collection_type property of a CreateLogAnalyticsObjectCollectionRuleDetails.
#: This constant has a value of "LIVE"
COLLECTION_TYPE_LIVE = "LIVE"
#: A constant which can be used with the collection_type property of a CreateLogAnalyticsObjectCollectionRuleDetails.
#: This constant has a value of "HISTORIC"
COLLECTION_TYPE_HISTORIC = "HISTORIC"
#: A constant which can be used with the collection_type property of a CreateLogAnalyticsObjectCollectionRuleDetails.
#: This constant has a value of "HISTORIC_LIVE"
COLLECTION_TYPE_HISTORIC_LIVE = "HISTORIC_LIVE"
def __init__(self, **kwargs):
"""
Initializes a new CreateLogAnalyticsObjectCollectionRuleDetails object with values from keyword arguments.
The following keyword arguments are supported (corresponding to the getters/setters of this class):
:param name:
The value to assign to the name property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type name: str
:param description:
The value to assign to the description property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type description: str
:param compartment_id:
The value to assign to the compartment_id property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type compartment_id: str
:param os_namespace:
The value to assign to the os_namespace property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type os_namespace: str
:param os_bucket_name:
The value to assign to the os_bucket_name property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type os_bucket_name: str
:param collection_type:
The value to assign to the collection_type property of this CreateLogAnalyticsObjectCollectionRuleDetails.
Allowed values for this property are: "LIVE", "HISTORIC", "HISTORIC_LIVE"
:type collection_type: str
:param poll_since:
The value to assign to the poll_since property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type poll_since: str
:param poll_till:
The value to assign to the poll_till property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type poll_till: str
:param log_group_id:
The value to assign to the log_group_id property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type log_group_id: str
:param log_source_name:
The value to assign to the log_source_name property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type log_source_name: str
:param entity_id:
The value to assign to the entity_id property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type entity_id: str
:param char_encoding:
The value to assign to the char_encoding property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type char_encoding: str
:param is_enabled:
The value to assign to the is_enabled property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type is_enabled: bool
:param overrides:
The value to assign to the overrides property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type overrides: dict(str, list[PropertyOverride])
:param object_name_filters:
The value to assign to the object_name_filters property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type object_name_filters: list[str]
:param defined_tags:
The value to assign to the defined_tags property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type defined_tags: dict(str, dict(str, object))
:param freeform_tags:
The value to assign to the freeform_tags property of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type freeform_tags: dict(str, str)
"""
self.swagger_types = {
'name': 'str',
'description': 'str',
'compartment_id': 'str',
'os_namespace': 'str',
'os_bucket_name': 'str',
'collection_type': 'str',
'poll_since': 'str',
'poll_till': 'str',
'log_group_id': 'str',
'log_source_name': 'str',
'entity_id': 'str',
'char_encoding': 'str',
'is_enabled': 'bool',
'overrides': 'dict(str, list[PropertyOverride])',
'object_name_filters': 'list[str]',
'defined_tags': 'dict(str, dict(str, object))',
'freeform_tags': 'dict(str, str)'
}
self.attribute_map = {
'name': 'name',
'description': 'description',
'compartment_id': 'compartmentId',
'os_namespace': 'osNamespace',
'os_bucket_name': 'osBucketName',
'collection_type': 'collectionType',
'poll_since': 'pollSince',
'poll_till': 'pollTill',
'log_group_id': 'logGroupId',
'log_source_name': 'logSourceName',
'entity_id': 'entityId',
'char_encoding': 'charEncoding',
'is_enabled': 'isEnabled',
'overrides': 'overrides',
'object_name_filters': 'objectNameFilters',
'defined_tags': 'definedTags',
'freeform_tags': 'freeformTags'
}
self._name = None
self._description = None
self._compartment_id = None
self._os_namespace = None
self._os_bucket_name = None
self._collection_type = None
self._poll_since = None
self._poll_till = None
self._log_group_id = None
self._log_source_name = None
self._entity_id = None
self._char_encoding = None
self._is_enabled = None
self._overrides = None
self._object_name_filters = None
self._defined_tags = None
self._freeform_tags = None
@property
def name(self):
"""
**[Required]** Gets the name of this CreateLogAnalyticsObjectCollectionRuleDetails.
A unique name given to the rule. The name must be unique within the tenancy, and cannot be modified.
:return: The name of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: str
"""
return self._name
@name.setter
def name(self, name):
"""
Sets the name of this CreateLogAnalyticsObjectCollectionRuleDetails.
A unique name given to the rule. The name must be unique within the tenancy, and cannot be modified.
:param name: The name of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: str
"""
self._name = name
@property
def description(self):
"""
Gets the description of this CreateLogAnalyticsObjectCollectionRuleDetails.
A string that describes the details of the rule. It does not have to be unique, and can be changed.
Avoid entering confidential information.
:return: The description of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: str
"""
return self._description
@description.setter
def description(self, description):
"""
Sets the description of this CreateLogAnalyticsObjectCollectionRuleDetails.
A string that describes the details of the rule. It does not have to be unique, and can be changed.
Avoid entering confidential information.
:param description: The description of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: str
"""
self._description = description
@property
def compartment_id(self):
"""
**[Required]** Gets the compartment_id of this CreateLogAnalyticsObjectCollectionRuleDetails.
The `OCID`__ of the compartment to which this rule belongs.
__ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
:return: The compartment_id of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: str
"""
return self._compartment_id
@compartment_id.setter
def compartment_id(self, compartment_id):
"""
Sets the compartment_id of this CreateLogAnalyticsObjectCollectionRuleDetails.
The `OCID`__ of the compartment to which this rule belongs.
__ https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm
:param compartment_id: The compartment_id of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: str
"""
self._compartment_id = compartment_id
@property
def os_namespace(self):
"""
**[Required]** Gets the os_namespace of this CreateLogAnalyticsObjectCollectionRuleDetails.
Object Storage namespace.
:return: The os_namespace of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: str
"""
return self._os_namespace
@os_namespace.setter
def os_namespace(self, os_namespace):
"""
Sets the os_namespace of this CreateLogAnalyticsObjectCollectionRuleDetails.
Object Storage namespace.
:param os_namespace: The os_namespace of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: str
"""
self._os_namespace = os_namespace
@property
def os_bucket_name(self):
"""
**[Required]** Gets the os_bucket_name of this CreateLogAnalyticsObjectCollectionRuleDetails.
Name of the Object Storage bucket.
:return: The os_bucket_name of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: str
"""
return self._os_bucket_name
@os_bucket_name.setter
def os_bucket_name(self, os_bucket_name):
"""
Sets the os_bucket_name of this CreateLogAnalyticsObjectCollectionRuleDetails.
Name of the Object Storage bucket.
:param os_bucket_name: The os_bucket_name of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: str
"""
self._os_bucket_name = os_bucket_name
@property
def collection_type(self):
"""
Gets the collection_type of this CreateLogAnalyticsObjectCollectionRuleDetails.
The type of collection.
Allowed values for this property are: "LIVE", "HISTORIC", "HISTORIC_LIVE"
:return: The collection_type of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: str
"""
return self._collection_type
@collection_type.setter
def collection_type(self, collection_type):
"""
Sets the collection_type of this CreateLogAnalyticsObjectCollectionRuleDetails.
The type of collection.
:param collection_type: The collection_type of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: str
"""
allowed_values = ["LIVE", "HISTORIC", "HISTORIC_LIVE"]
if not value_allowed_none_or_none_sentinel(collection_type, allowed_values):
raise ValueError(
"Invalid value for `collection_type`, must be None or one of {0}"
.format(allowed_values)
)
self._collection_type = collection_type
@property
def poll_since(self):
"""
Gets the poll_since of this CreateLogAnalyticsObjectCollectionRuleDetails.
The oldest time of the file in the bucket to consider for collection.
Accepted values are: BEGINNING or CURRENT_TIME or RFC3339 formatted datetime string.
Use this for HISTORIC or HISTORIC_LIVE collection types. When collectionType is LIVE, specifying pollSince value other than CURRENT_TIME will result in error.
:return: The poll_since of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: str
"""
return self._poll_since
@poll_since.setter
def poll_since(self, poll_since):
"""
Sets the poll_since of this CreateLogAnalyticsObjectCollectionRuleDetails.
The oldest time of the file in the bucket to consider for collection.
Accepted values are: BEGINNING or CURRENT_TIME or RFC3339 formatted datetime string.
Use this for HISTORIC or HISTORIC_LIVE collection types. When collectionType is LIVE, specifying pollSince value other than CURRENT_TIME will result in error.
:param poll_since: The poll_since of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: str
"""
self._poll_since = poll_since
@property
def poll_till(self):
"""
Gets the poll_till of this CreateLogAnalyticsObjectCollectionRuleDetails.
The newest time of the file in the bucket to consider for collection.
Accepted values are: CURRENT_TIME or RFC3339 formatted datetime string.
Use this for HISTORIC collection type. When collectionType is LIVE or HISTORIC_LIVE, specifying pollTill will result in error.
:return: The poll_till of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: str
"""
return self._poll_till
@poll_till.setter
def poll_till(self, poll_till):
"""
Sets the poll_till of this CreateLogAnalyticsObjectCollectionRuleDetails.
The newest time of the file in the bucket to consider for collection.
Accepted values are: CURRENT_TIME or RFC3339 formatted datetime string.
Use this for HISTORIC collection type. When collectionType is LIVE or HISTORIC_LIVE, specifying pollTill will result in error.
:param poll_till: The poll_till of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: str
"""
self._poll_till = poll_till
@property
def log_group_id(self):
"""
**[Required]** Gets the log_group_id of this CreateLogAnalyticsObjectCollectionRuleDetails.
Logging Analytics Log group OCID to associate the processed logs with.
:return: The log_group_id of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: str
"""
return self._log_group_id
@log_group_id.setter
def log_group_id(self, log_group_id):
"""
Sets the log_group_id of this CreateLogAnalyticsObjectCollectionRuleDetails.
Logging Analytics Log group OCID to associate the processed logs with.
:param log_group_id: The log_group_id of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: str
"""
self._log_group_id = log_group_id
@property
def log_source_name(self):
"""
**[Required]** Gets the log_source_name of this CreateLogAnalyticsObjectCollectionRuleDetails.
Name of the Logging Analytics Source to use for the processing.
:return: The log_source_name of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: str
"""
return self._log_source_name
@log_source_name.setter
def log_source_name(self, log_source_name):
"""
Sets the log_source_name of this CreateLogAnalyticsObjectCollectionRuleDetails.
Name of the Logging Analytics Source to use for the processing.
:param log_source_name: The log_source_name of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: str
"""
self._log_source_name = log_source_name
@property
def entity_id(self):
"""
Gets the entity_id of this CreateLogAnalyticsObjectCollectionRuleDetails.
Logging Analytics entity OCID. Associates the processed logs with the given entity (optional).
:return: The entity_id of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: str
"""
return self._entity_id
@entity_id.setter
def entity_id(self, entity_id):
"""
Sets the entity_id of this CreateLogAnalyticsObjectCollectionRuleDetails.
Logging Analytics entity OCID. Associates the processed logs with the given entity (optional).
:param entity_id: The entity_id of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: str
"""
self._entity_id = entity_id
@property
def char_encoding(self):
"""
Gets the char_encoding of this CreateLogAnalyticsObjectCollectionRuleDetails.
An optional character encoding to aid in detecting the character encoding of the contents of the objects while processing.
It is recommended to set this value as ISO_8859_1 when configuring content of the objects having more numeric characters,
and very few alphabets.
For e.g. this applies when configuring VCN Flow Logs.
:return: The char_encoding of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: str
"""
return self._char_encoding
@char_encoding.setter
def char_encoding(self, char_encoding):
"""
Sets the char_encoding of this CreateLogAnalyticsObjectCollectionRuleDetails.
An optional character encoding to aid in detecting the character encoding of the contents of the objects while processing.
It is recommended to set this value as ISO_8859_1 when configuring content of the objects having more numeric characters,
and very few alphabets.
For e.g. this applies when configuring VCN Flow Logs.
:param char_encoding: The char_encoding of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: str
"""
self._char_encoding = char_encoding
@property
def is_enabled(self):
"""
Gets the is_enabled of this CreateLogAnalyticsObjectCollectionRuleDetails.
Whether or not this rule is currently enabled.
:return: The is_enabled of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: bool
"""
return self._is_enabled
@is_enabled.setter
def is_enabled(self, is_enabled):
"""
Sets the is_enabled of this CreateLogAnalyticsObjectCollectionRuleDetails.
Whether or not this rule is currently enabled.
:param is_enabled: The is_enabled of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: bool
"""
self._is_enabled = is_enabled
@property
def overrides(self):
"""
Gets the overrides of this CreateLogAnalyticsObjectCollectionRuleDetails.
The override is used to modify some important configuration properties for objects matching a specific pattern inside the bucket.
Supported propeties for override are: logSourceName, charEncoding, entityId.
Supported matchType for override are \"contains\".
:return: The overrides of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: dict(str, list[PropertyOverride])
"""
return self._overrides
@overrides.setter
def overrides(self, overrides):
"""
Sets the overrides of this CreateLogAnalyticsObjectCollectionRuleDetails.
The override is used to modify some important configuration properties for objects matching a specific pattern inside the bucket.
Supported propeties for override are: logSourceName, charEncoding, entityId.
Supported matchType for override are \"contains\".
:param overrides: The overrides of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: dict(str, list[PropertyOverride])
"""
self._overrides = overrides
@property
def object_name_filters(self):
"""
Gets the object_name_filters of this CreateLogAnalyticsObjectCollectionRuleDetails.
When the filters are provided, only the objects matching the filters are picked up for processing.
The matchType supported is exact match and accommodates wildcard \"*\".
For more information on filters, see `Event Filters`__.
__ https://docs.oracle.com/en-us/iaas/Content/Events/Concepts/filterevents.htm
:return: The object_name_filters of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: list[str]
"""
return self._object_name_filters
@object_name_filters.setter
def object_name_filters(self, object_name_filters):
"""
Sets the object_name_filters of this CreateLogAnalyticsObjectCollectionRuleDetails.
When the filters are provided, only the objects matching the filters are picked up for processing.
The matchType supported is exact match and accommodates wildcard \"*\".
For more information on filters, see `Event Filters`__.
__ https://docs.oracle.com/en-us/iaas/Content/Events/Concepts/filterevents.htm
:param object_name_filters: The object_name_filters of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: list[str]
"""
self._object_name_filters = object_name_filters
@property
def defined_tags(self):
"""
Gets the defined_tags of this CreateLogAnalyticsObjectCollectionRuleDetails.
Defined tags for this resource. Each key is predefined and scoped to a namespace.
Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`
:return: The defined_tags of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: dict(str, dict(str, object))
"""
return self._defined_tags
@defined_tags.setter
def defined_tags(self, defined_tags):
"""
Sets the defined_tags of this CreateLogAnalyticsObjectCollectionRuleDetails.
Defined tags for this resource. Each key is predefined and scoped to a namespace.
Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`
:param defined_tags: The defined_tags of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: dict(str, dict(str, object))
"""
self._defined_tags = defined_tags
@property
def freeform_tags(self):
"""
Gets the freeform_tags of this CreateLogAnalyticsObjectCollectionRuleDetails.
Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only.
Example: `{\"bar-key\": \"value\"}`
:return: The freeform_tags of this CreateLogAnalyticsObjectCollectionRuleDetails.
:rtype: dict(str, str)
"""
return self._freeform_tags
@freeform_tags.setter
def freeform_tags(self, freeform_tags):
"""
Sets the freeform_tags of this CreateLogAnalyticsObjectCollectionRuleDetails.
Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only.
Example: `{\"bar-key\": \"value\"}`
:param freeform_tags: The freeform_tags of this CreateLogAnalyticsObjectCollectionRuleDetails.
:type: dict(str, str)
"""
self._freeform_tags = freeform_tags
def __repr__(self):
return formatted_flat_dict(self)
def __eq__(self, other):
if other is None:
return False
return self.__dict__ == other.__dict__
def __ne__(self, other):
return not self == other
| 38.657051 | 245 | 0.689702 | 2,606 | 24,122 | 6.202226 | 0.110514 | 0.031925 | 0.268205 | 0.112294 | 0.759079 | 0.670606 | 0.569696 | 0.455856 | 0.415208 | 0.404442 | 0 | 0.002484 | 0.24886 | 24,122 | 623 | 246 | 38.719101 | 0.889563 | 0.630876 | 0 | 0.094972 | 0 | 0 | 0.125669 | 0.003516 | 0 | 0 | 0 | 0 | 0 | 1 | 0.212291 | false | 0 | 0.011173 | 0.011173 | 0.363128 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
04288fa83de7c548b9e67aff2e10a6c3173296da | 1,130 | py | Python | etc/__init__.py | justb4/REST-Flask-boostrap | 5de8ba92552f3c3ae6c85f6e587acfb131069ac9 | [
"MIT"
] | 9 | 2018-04-29T18:49:02.000Z | 2022-01-01T17:34:43.000Z | etc/__init__.py | justb4/REST-Flask-boostrap | 5de8ba92552f3c3ae6c85f6e587acfb131069ac9 | [
"MIT"
] | null | null | null | etc/__init__.py | justb4/REST-Flask-boostrap | 5de8ba92552f3c3ae6c85f6e587acfb131069ac9 | [
"MIT"
] | 2 | 2018-05-22T20:41:17.000Z | 2020-08-30T08:20:31.000Z | #!/usr/bin/python3
# -*- coding: utf-8 -*-
"""etc Module for classes defining Flask configuration.
PORT configuation and HOST are configured as arguments in app"""
from flask_env import MetaFlaskEnv
import os, tempfile
from __init__ import __version__
# pylint: disable=too-few-public-methods
class BaseConfig(metaclass=MetaFlaskEnv):
"""BaseClass from where other configurations will de derived"""
DEBUG = True
SQLALCHEMY_TRACK_MODIFICATIONS = False # Just to remove the warning and tracking of SQLALCHEMY
DBPATH = os.path.join(".", "task_database.db")
SQLALCHEMY_DATABASE_URI = 'sqlite:///{}'.format(DBPATH)
LOG_FILE = "flask.log"
UPLOAD_FOLDER = tempfile.mkdtemp(prefix="rest_api")
PORT = 5001
MAX_UPLOAD = 100
VERSION = __version__
HOST = "0.0.0.0"
# pylint: disable=too-few-public-methods
class DevelopmentConfig(BaseConfig):
"""Class with development configurations inhered from BaseConfig"""
pass
# pylint: disable=too-few-public-methods
class ProductionConfig(BaseConfig):
"""Class with production configurations inhered from BaseConfig"""
DEBUG = False
| 31.388889 | 99 | 0.734513 | 139 | 1,130 | 5.81295 | 0.633094 | 0.048267 | 0.059406 | 0.070545 | 0.137376 | 0.137376 | 0.137376 | 0 | 0 | 0 | 0 | 0.013742 | 0.162832 | 1,130 | 35 | 100 | 32.285714 | 0.840381 | 0.447788 | 0 | 0 | 0 | 0 | 0.088629 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.055556 | 0.166667 | 0 | 0.944444 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
04316b894909b470ea9c361ab8592bfeedae314d | 270 | py | Python | conference/context_processors.py | burhan/DjangoConEurope2017 | 8ffba68d4fd9c78a7ec4346c08917e34365529d0 | [
"BSD-3-Clause"
] | 7 | 2016-11-21T12:53:37.000Z | 2020-03-30T23:22:48.000Z | conference/context_processors.py | burhan/DjangoConEurope2017 | 8ffba68d4fd9c78a7ec4346c08917e34365529d0 | [
"BSD-3-Clause"
] | 17 | 2016-11-17T19:25:48.000Z | 2017-04-06T08:43:46.000Z | conference/context_processors.py | burhan/DjangoConEurope2017 | 8ffba68d4fd9c78a7ec4346c08917e34365529d0 | [
"BSD-3-Clause"
] | 7 | 2016-11-30T21:40:55.000Z | 2020-10-02T09:21:31.000Z | # -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
from django.conf import settings
def context_settings(request):
context = dict()
context['GOOGLE_ANALYTICS_ID'] = settings.GOOGLE_ANALYTICS_ID
return context
| 24.545455 | 72 | 0.762963 | 33 | 270 | 5.878788 | 0.666667 | 0.154639 | 0.175258 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004348 | 0.148148 | 270 | 10 | 73 | 27 | 0.83913 | 0.077778 | 0 | 0 | 0 | 0 | 0.076923 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.333333 | 0 | 0.666667 | 0.166667 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
0433b8675541efd6300b09ace6c71442df53860e | 266 | py | Python | res/assets.py | yuesubi/kanji | 60eac6e1a2d53fdb15a4e3a2f610aad0cc742c45 | [
"MIT"
] | null | null | null | res/assets.py | yuesubi/kanji | 60eac6e1a2d53fdb15a4e3a2f610aad0cc742c45 | [
"MIT"
] | null | null | null | res/assets.py | yuesubi/kanji | 60eac6e1a2d53fdb15a4e3a2f610aad0cc742c45 | [
"MIT"
] | null | null | null |
import os
# from tkinter import PhotoImage
RES_DIR = os.path.dirname(__file__)
leave = os.path.join(RES_DIR, "leave.png")
check = os.path.join(RES_DIR, "check.png")
correct = os.path.join(RES_DIR, "correct.png")
wrong = os.path.join(RES_DIR, "wrong.png")
| 20.461538 | 46 | 0.703008 | 44 | 266 | 4.045455 | 0.363636 | 0.168539 | 0.224719 | 0.292135 | 0.359551 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.139098 | 266 | 12 | 47 | 22.166667 | 0.777293 | 0.112782 | 0 | 0 | 0 | 0 | 0.16309 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.166667 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
04517852a6bdf55c4e802fda1a27deac6a87a16b | 2,260 | py | Python | one_piece.py | binglel/turtle_toy | db4e1a7a41377e8e2b6e3821c5040d9eb10c220f | [
"Apache-2.0"
] | 1 | 2020-06-03T01:20:36.000Z | 2020-06-03T01:20:36.000Z | one_piece.py | binglel/turtle_toy | db4e1a7a41377e8e2b6e3821c5040d9eb10c220f | [
"Apache-2.0"
] | null | null | null | one_piece.py | binglel/turtle_toy | db4e1a7a41377e8e2b6e3821c5040d9eb10c220f | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
# 路飞骷髅
import turtle as t
# 黄底帽子
t.pu()
t.goto(0, 200)
t.circle(-130, -80)
t.pd()
t.colormode(255)
t.pensize(5)
t.color(242, 232, 184) # 帽子黄底RGB
t.begin_fill()
t.pencolor(0, 0, 0)
t.circle(-130, 160)
t.seth(180)
t.fd(255)
t.end_fill()
# 红色线条
t.begin_fill()
t.color(221, 65, 43) # 帽子红色带
t.pencolor(0, 0, 0)
t.seth(80)
t.circle(-130, 19)
t.seth(0)
t.fd(225)
t.seth(-59)
t.circle(-130, 19)
t.seth(180)
t.fd(255)
t.end_fill()
# 帽檐
t.begin_fill()
t.color(242, 232, 184)
t.pencolor(0, 0, 0)
t.fd(60)
t.circle(12, 180)
t.fd(375)
t.circle(12, 180)
t.fd(255 + 60)
t.end_fill()
# 脸部下半轮廓
t.pu()
t.setpos(0, -30)
t.seth(-180)
t.circle(-130, -75)
t.pd()
t.circle(-130, 150)
# 眼睛鼻子
t.pu()
t.color(33, 24, 24) # 眼睛、鼻子RGB
t.setpos(-45, 64)
t.seth(-180)
t.pd()
t.begin_fill()
t.circle(33)
t.pu()
t.setpos(45, 64)
t.pd()
t.circle(33)
t.end_fill()
t.pu()
t.setpos(0, 5)
t.pd()
t.begin_fill()
t.circle(8)
t.end_fill()
# 下巴
t.pencolor(0, 0, 0)
t.pu()
t.setpos(0, 0)
t.seth(0)
t.circle(-75, 45)
t.pd()
t.circle(-75, 270)
# 牙齿
t.pu()
t.setpos(0, 120)
t.seth(0)
t.circle(-105, 136)
t.pd()
t.circle(-105, 86)
t.pu()
t.seth(0)
t.goto(0, 200)
t.circle(-130, 150)
t.pd()
t.circle(-130, 60)
t.pu() # 牙齿三根竖线
t.setpos(-30, -27)
t.seth(260)
t.pd()
t.fd(52)
t.pu()
t.setpos(30, -27)
t.pd()
t.seth(-260)
t.fd(-52)
t.pu()
t.setpos(0, -30)
t.seth(-90)
t.pd()
t.fd(56)
# 上排右侧小爪爪
# 释放注释为:上排右侧小爪爪实心金方案
t.pu()
# t.color(255,215,0) #金色的RGB
t.pencolor(0, 0, 0)
t.setpos(110, 145)
t.seth(45)
t.pd()
# t.begin_fill()
t.fd(40)
t.seth(135)
t.circle(-30, 235)
t.seth(-20)
t.circle(-30, 220)
t.seth(-135)
t.fd(40)
# t.end_fill()
# 上排左侧小爪爪
t.pu()
t.pencolor(0, 0, 0)
t.setpos(-110, 145)
t.seth(135)
t.pd()
t.fd(40)
t.seth(45)
t.circle(30, 235)
t.seth(-160)
t.circle(30, 220)
t.seth(-45)
t.fd(40)
# 下排右侧小爪爪
t.pu()
t.setpos(70, -10)
t.seth(-45)
t.pd()
t.fd(70)
t.seth(45)
t.circle(-30, 235)
t.seth(-70)
t.circle(-30, 255)
t.seth(135)
t.fd(22)
# 下排左侧小爪爪
t.pu()
t.setpos(-70, -10)
t.seth(-135)
t.pd()
t.fd(70)
t.seth(135)
t.circle(30, 235)
t.seth(-110)
t.circle(30, 255)
t.seth(45)
t.fd(22)
t.done() | 13.139535 | 34 | 0.55885 | 482 | 2,260 | 2.595436 | 0.186722 | 0.115907 | 0.047962 | 0.071942 | 0.645883 | 0.478817 | 0.321343 | 0.220624 | 0.161471 | 0.047962 | 0 | 0.189797 | 0.193363 | 2,260 | 172 | 35 | 13.139535 | 0.496434 | 0.084956 | 0 | 0.671429 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.007143 | 0 | 0.007143 | 0 | 0 | 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 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
045486bf02c61718feb42e1bef73ebdc68618d75 | 2,105 | py | Python | python_cookbook/c04/p04_iterator_protocol.py | AtlantisFox/Green-Point-Challenge | e4f7ee6fbc8c3480bb10e818eb85d4aafdd7db58 | [
"MIT"
] | 1 | 2017-10-31T01:46:25.000Z | 2017-10-31T01:46:25.000Z | python_cookbook/c04/p04_iterator_protocol.py | AtlantisFox/Green-Point-Challenge | e4f7ee6fbc8c3480bb10e818eb85d4aafdd7db58 | [
"MIT"
] | 1 | 2017-10-31T12:31:24.000Z | 2017-10-31T15:32:54.000Z | python_cookbook/c04/p04_iterator_protocol.py | AtlantisFox/Green-Point-Challenge | e4f7ee6fbc8c3480bb10e818eb85d4aafdd7db58 | [
"MIT"
] | null | null | null | """
topc: 实现迭代器协议
desc: 构建一个能支持迭代操作的自定义对象,并希望找到一个能实现迭代协议的简单方法。
"""
class Node:
def __init__(self, value):
self._value = value
self._children = []
def __repr__(self):
return 'Node({!r})'.format(self._value)
def add_child(self, node):
self._children.append(node)
def __iter__(self):
return iter(self._children)
def depth_first(self):
yield self
for c in self:
yield from c.depth_first()
"""
python的迭代协议要求一个__iter__()方法发挥一个特殊的迭代器对象,
这个迭代器对象实现了__next__()方法, 并通过StopIteration异常标识迭代的完成.
但是实现比较繁琐.
下面我们演示这种方式, 如何使用一个关联迭代器类重新实现depth_first()方法
"""
class Node2:
def __init(self, value):
self._value = value
self._children = []
def __repr(self):
return 'Node({!r})'.format(self._value)
def add_child(self, node):
self._children.append(node)
def __iter__(self):
return iter(self._children)
def depth_first(self):
return DepthFirstInterator(self)
class DepthFirstInterator(object):
"""
深度优先遍历
"""
def __init__(self, start_node):
self._node = start_node
self._children_iter = None
self._child_iter = None
def __iter__(self):
return self
def __next__(self):
# 如果是开始节点就返回自身; 为子节点生成一个迭代器
if self._children_iter is None:
self._children_iter = iter(self._node)
return self._node
# 如果执行到子节点, 就返回它的下一个节点
elif self._child_iter:
try:
nextchild = next(self._child_iter)
return nextchild
except StopIteration:
self._child_iter = None
return next(self)
else:
self._child_iter = next(self._children_iter).depth_first()
return next(self)
if __name__ == '__main__':
root = Node(0)
child1 = Node(1)
child2 = Node(2)
root.add_child(child1)
root.add_child(child2)
child1.add_child(Node(3))
child1.add_child(Node(4))
child2.add_child(Node(5))
for ch in root.depth_first():
print(ch)
| 21.927083 | 70 | 0.605701 | 236 | 2,105 | 5.004237 | 0.283898 | 0.101609 | 0.055038 | 0.043184 | 0.287892 | 0.287892 | 0.287892 | 0.287892 | 0.287892 | 0.287892 | 0 | 0.009377 | 0.290736 | 2,105 | 95 | 71 | 22.157895 | 0.781648 | 0.053682 | 0 | 0.362069 | 0 | 0 | 0.015453 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.224138 | false | 0 | 0 | 0.103448 | 0.448276 | 0.017241 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
04559deff0583973ffd72d4293ef6e3cc21015aa | 235 | py | Python | examples/project_path.py | qualichat/questionary | d13e7e534d355810b27770a6dc672f9bc1b4e6de | [
"MIT"
] | 851 | 2018-12-10T10:32:50.000Z | 2022-03-29T10:21:00.000Z | examples/project_path.py | qualichat/questionary | d13e7e534d355810b27770a6dc672f9bc1b4e6de | [
"MIT"
] | 150 | 2019-01-08T14:08:34.000Z | 2022-03-23T09:10:17.000Z | examples/project_path.py | qualichat/questionary | d13e7e534d355810b27770a6dc672f9bc1b4e6de | [
"MIT"
] | 68 | 2019-01-08T13:58:18.000Z | 2022-01-26T06:57:54.000Z | import questionary
if __name__ == "__main__":
path = questionary.path("Path to the projects version file").ask()
if path:
print(f"Found version file at {path} 🦄")
else:
print("No version file it is then!")
| 26.111111 | 70 | 0.634043 | 33 | 235 | 4.30303 | 0.666667 | 0.232394 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.246809 | 235 | 8 | 71 | 29.375 | 0.79661 | 0 | 0 | 0 | 0 | 0 | 0.417021 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.142857 | 0 | 0.142857 | 0.285714 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
04564f78ad7441bd241926e48f98fbef85aa26d1 | 660 | py | Python | SeriesAnalysis/Filters/SavgolFilter.py | AcudoDev/FinanceToolbox | 90676e798f2e8eac164ccfcd6708cc717e1911f2 | [
"MIT"
] | null | null | null | SeriesAnalysis/Filters/SavgolFilter.py | AcudoDev/FinanceToolbox | 90676e798f2e8eac164ccfcd6708cc717e1911f2 | [
"MIT"
] | null | null | null | SeriesAnalysis/Filters/SavgolFilter.py | AcudoDev/FinanceToolbox | 90676e798f2e8eac164ccfcd6708cc717e1911f2 | [
"MIT"
] | null | null | null | import pandas as pd
import numpy as np
import yfinance as yf
from sklearn.linear_model import LinearRegression
import statsmodels
import statsmodels.api as sm
import statsmodels.tsa.stattools as ts
import datetime
import scipy.stats
import math
import openpyxl as pyxl
from scipy import signal
from scipy import stats as ss
import statistics
from finta import TA
from filterpy.kalman import KalmanFilter
from filterpy.common import Q_discrete_white_noise
import pandas_ta as ta
from pingouin import gzscore
def SavgolFilter(series, window=51, order=3):
xhat = savgol_filter(series, 51, 3)
xhat.index = series.index
return pd.DataFrame(xhat)
| 21.290323 | 50 | 0.809091 | 101 | 660 | 5.227723 | 0.524752 | 0.096591 | 0.056818 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010733 | 0.15303 | 660 | 30 | 51 | 22 | 0.93381 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.043478 | false | 0 | 0.826087 | 0 | 0.913043 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
f09ae5b9acadb3267f7a2a7a4c2b272d588412c2 | 548 | py | Python | Dataset/Leetcode/test/12/166.py | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | Dataset/Leetcode/test/12/166.py | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | Dataset/Leetcode/test/12/166.py | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | class Solution:
def XXX(self, num: int) -> str:
tbl = {
1:'I',
5:'V',
10:'X',
50:'L',
100:'C',
500:'D',
1000:'M',
4:'IV',
9:'IX',
40:'XL',
90:'XC',
400:'CD',
900:'CM',
}
res = ''
for k in sorted(tbl.keys(), reverse=True):
if num >= k:
m = num // k
num %= k
res += tbl[k] * m
return res
| 21.076923 | 50 | 0.268248 | 58 | 548 | 2.534483 | 0.775862 | 0.081633 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.119658 | 0.572993 | 548 | 25 | 51 | 21.92 | 0.508547 | 0 | 0 | 0 | 0 | 0 | 0.034735 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
f0a9818857de073c9e54827236958c4d358d0835 | 613 | py | Python | Udemy/python-django-dev-to-deployment/btre_django/realtors/models.py | mohammedelzanaty/myRoad2BeFullStack | eea3a5edb6c6a999136b04fdaea6ce0c81137a58 | [
"MIT"
] | 2 | 2021-04-21T12:05:01.000Z | 2022-01-19T09:58:38.000Z | Udemy/python-django-dev-to-deployment/btre_django/realtors/models.py | mohammedelzanaty/myRoad2BeFullStack | eea3a5edb6c6a999136b04fdaea6ce0c81137a58 | [
"MIT"
] | 34 | 2019-12-26T11:21:42.000Z | 2022-02-27T19:55:10.000Z | Udemy/python-django-dev-to-deployment/btre_django/realtors/models.py | mohammedelzanaty/myRoad2BeFullStack | eea3a5edb6c6a999136b04fdaea6ce0c81137a58 | [
"MIT"
] | 2 | 2021-08-15T07:59:36.000Z | 2022-01-16T06:17:32.000Z | from django.db import models
from django.utils import timezone
class Realtor(models.Model):
name = models.CharField(max_length=100)
photo = models.ImageField(upload_to="photos/%Y/%m/%d/")
description = models.TextField(blank=True)
email = models.CharField(max_length=50)
phone = models.CharField(max_length=20)
is_mvp = models.BooleanField(default=False)
hire_date = models.DateTimeField(timezone.now, blank=True)
def __str__(self):
return self.name
# id: INT
# name: STR
# photo: STR
# description: TEXT
# email: STR
# phone: STR
# is_mvp: BOOL [0]
# hire_date: DATE
| 23.576923 | 62 | 0.706362 | 85 | 613 | 4.952941 | 0.576471 | 0.106888 | 0.128266 | 0.171021 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015779 | 0.17292 | 613 | 25 | 63 | 24.52 | 0.814596 | 0.164763 | 0 | 0 | 0 | 0 | 0.031809 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.083333 | false | 0 | 0.166667 | 0.083333 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
f0b4f807d05e3007d816cecd25c7cbef1748f241 | 414 | py | Python | pagetools/sections/tests/test_models.py | theithec/pagetools | f5fba7213864555275bddcc1882122f3be843f19 | [
"MIT"
] | null | null | null | pagetools/sections/tests/test_models.py | theithec/pagetools | f5fba7213864555275bddcc1882122f3be843f19 | [
"MIT"
] | 14 | 2020-02-23T12:15:49.000Z | 2022-02-13T14:07:27.000Z | pagetools/sections/tests/test_models.py | theithec/django-pagetools | 8fb73285acee8c8162329fc2895a3816fcb40165 | [
"MIT"
] | null | null | null | from django.conf import settings
from django.db.models.base import ModelBase
from django.test import TestCase
from pagetools.sections.models import PageNode
class TestModelMixin(TestCase):
def setUp(self):
self.model = PageNode
self.node1 = self.model.objects.create(title="w1")
class ModelTests(TestModelMixin):
def test_title(self):
self.assertEqual(self.node1.title, "w1")
| 23 | 58 | 0.736715 | 53 | 414 | 5.735849 | 0.509434 | 0.098684 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011628 | 0.169082 | 414 | 17 | 59 | 24.352941 | 0.872093 | 0 | 0 | 0 | 0 | 0 | 0.009662 | 0 | 0 | 0 | 0 | 0 | 0.090909 | 1 | 0.181818 | false | 0 | 0.363636 | 0 | 0.727273 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
f0b97fe922a2ab2d1ee7bfb7fcdad669cd976fde | 351 | py | Python | scheduler/__init__.py | entchen66/sinbad3.1 | 3353118b8693c84d5572ab2a7a2278a32be2a76c | [
"MIT"
] | null | null | null | scheduler/__init__.py | entchen66/sinbad3.1 | 3353118b8693c84d5572ab2a7a2278a32be2a76c | [
"MIT"
] | null | null | null | scheduler/__init__.py | entchen66/sinbad3.1 | 3353118b8693c84d5572ab2a7a2278a32be2a76c | [
"MIT"
] | 1 | 2020-02-29T10:57:21.000Z | 2020-02-29T10:57:21.000Z | import discord
from .message import replacement_delete_messages
from .scheduler import Scheduler
def setup(bot):
# Next line *does* work as intended. Mypy just hates it (see __slots__ use for why)
discord.TextChannel.delete_messages = replacement_delete_messages # type: ignore
cog = Scheduler(bot)
bot.add_cog(cog)
cog.init()
| 27 | 87 | 0.749288 | 48 | 351 | 5.270833 | 0.666667 | 0.166008 | 0.197628 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.179487 | 351 | 12 | 88 | 29.25 | 0.878472 | 0.267806 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.375 | 0 | 0.5 | 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 | 0 | 0 | 0 | 2 |
f0ba969a17d2eafaa01cc2255e43debfddecaf79 | 419 | py | Python | chord/test.py | xiayuu/chord | b1779bcb5c2e6c223c15123fbe8b1ff5599e336d | [
"Apache-2.0"
] | 1 | 2018-08-20T21:29:28.000Z | 2018-08-20T21:29:28.000Z | chord/test.py | xiayuu/chord | b1779bcb5c2e6c223c15123fbe8b1ff5599e336d | [
"Apache-2.0"
] | null | null | null | chord/test.py | xiayuu/chord | b1779bcb5c2e6c223c15123fbe8b1ff5599e336d | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/env python
# encoding: utf-8
from hashlib import sha1
from rpcudp.rpcserver import RPCServer, rpccall
RING_SIZE = 4
class ChordProtocol(RPCServer):
@rpccall
def rdict(self, dest):
pass
@rpccall
def find_successor(self, dest, ident):
pass
def rpc_rdict(self):
return self.dict()
node = ChordProtocol()
print(node.find_successor(('192.168.1.4', 9001), 10))
| 16.115385 | 53 | 0.663484 | 56 | 419 | 4.892857 | 0.660714 | 0.116788 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.052147 | 0.221957 | 419 | 25 | 54 | 16.76 | 0.788344 | 0.085919 | 0 | 0.285714 | 0 | 0 | 0.028871 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.214286 | false | 0.142857 | 0.142857 | 0.071429 | 0.5 | 0.071429 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
f0c7e2d76ebe64ac86ea2a179b50f507420a4f76 | 139 | py | Python | app/flask_factory.py | anthony-munoz/python-serverless | 39d094d47f972e8752d6e568408702088ab28c69 | [
"MIT"
] | null | null | null | app/flask_factory.py | anthony-munoz/python-serverless | 39d094d47f972e8752d6e568408702088ab28c69 | [
"MIT"
] | null | null | null | app/flask_factory.py | anthony-munoz/python-serverless | 39d094d47f972e8752d6e568408702088ab28c69 | [
"MIT"
] | null | null | null | from flask import Flask
from flask_dotenv import DotEnv
app = Flask(__name__)
env = DotEnv()
env.init_app(app)
settings = app.config
| 11.583333 | 31 | 0.748201 | 21 | 139 | 4.666667 | 0.47619 | 0.183673 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.172662 | 139 | 11 | 32 | 12.636364 | 0.852174 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 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 | 0 | 0 | 0 | 2 |
f0d7d67cf87c818fcb7de17d1b096f637fcf453a | 535 | py | Python | portal/applications/migrations/0006_application_application_over_email_sent.py | LDSSA/portal | 9561da1e262678fe68dcf51c66007c0fb13eb51a | [
"MIT"
] | 2 | 2020-11-09T03:48:36.000Z | 2021-07-02T14:30:09.000Z | portal/applications/migrations/0006_application_application_over_email_sent.py | LDSSA/portal | 9561da1e262678fe68dcf51c66007c0fb13eb51a | [
"MIT"
] | 132 | 2020-04-25T15:57:56.000Z | 2022-03-10T19:15:51.000Z | portal/applications/migrations/0006_application_application_over_email_sent.py | LDSSA/portal | 9561da1e262678fe68dcf51c66007c0fb13eb51a | [
"MIT"
] | 1 | 2020-10-24T16:15:57.000Z | 2020-10-24T16:15:57.000Z | # Generated by Django 3.0.3 on 2020-05-11 18:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("applications", "0005_auto_20200509_2034")]
operations = [
migrations.AddField(
model_name="application",
name="application_over_email_sent",
field=models.CharField(
choices=[("passed", "failed")],
default=None,
max_length=10,
null=True,
),
)
]
| 24.318182 | 64 | 0.557009 | 52 | 535 | 5.576923 | 0.846154 | 0.103448 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.092697 | 0.334579 | 535 | 21 | 65 | 25.47619 | 0.72191 | 0.084112 | 0 | 0 | 1 | 0 | 0.17418 | 0.102459 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.066667 | 0.066667 | 0 | 0.266667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
f0ea88a787eb91452214e783185b8faa2db85626 | 1,867 | py | Python | fat/errors.py | samuelvanderwaal/fat-py | 46f2eeafd202ea47befc3c516220605eca6111b3 | [
"MIT"
] | 2 | 2019-12-02T11:23:51.000Z | 2021-01-12T15:05:22.000Z | fat/errors.py | samuelvanderwaal/fat-py | 46f2eeafd202ea47befc3c516220605eca6111b3 | [
"MIT"
] | null | null | null | fat/errors.py | samuelvanderwaal/fat-py | 46f2eeafd202ea47befc3c516220605eca6111b3 | [
"MIT"
] | 1 | 2021-01-17T12:54:49.000Z | 2021-01-17T12:54:49.000Z | def handle_error_response(resp):
codes = {
-1: FATdAPIError,
-32600: InvalidRequest,
-32601: MethodNotFound,
-32602: InvalidParam,
-32603: InternalError,
-32700: ParseError,
-32800: TokenNotFound,
-32801: InvalidToken,
-32802: InvalidAddress,
-32803: TransactionNotFound,
-32804: InvalidTransaction,
-32805: TokenSyncing,
}
error = resp.json().get("error", {})
message = error.get("message")
code = error.get("code", -1)
data = error.get("data", {})
raise codes[code](message=message, code=code, data=data, response=resp)
class FATdAPIError(Exception):
response = None
data = {}
code = -1
message = "An unknown error occurred"
def __init__(self, message=None, code=None, data=None, response=None):
if data is None:
data = {}
self.response = response
if message:
self.message = message
if code:
self.code = code
if data:
self.data = data
def __str__(self):
if self.code:
return "{}: {}".format(self.code, self.message)
return self.message
class InvalidRequest(FATdAPIError):
pass
class MethodNotFound(FATdAPIError):
pass
class InternalError(FATdAPIError):
pass
class ParseError(FATdAPIError):
pass
class TokenNotFound(FATdAPIError):
pass
class InvalidToken(FATdAPIError):
pass
class InvalidAddress(FATdAPIError):
pass
class TransactionNotFound(FATdAPIError):
pass
class InvalidTransaction(FATdAPIError):
pass
class TokenSyncing(FATdAPIError):
pass
class InvalidFactoidKey(ValueError):
pass
class InvalidChainID(ValueError):
pass
class InvalidParam(ValueError):
pass
class MissingRequiredParameter(Exception):
pass
| 18.303922 | 75 | 0.629888 | 177 | 1,867 | 6.587571 | 0.305085 | 0.100343 | 0.180103 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.042553 | 0.269952 | 1,867 | 101 | 76 | 18.485149 | 0.812913 | 0 | 0 | 0.238806 | 0 | 0 | 0.027317 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.044776 | false | 0.208955 | 0 | 0 | 0.358209 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
f0f4da7e19ee83d858b0a170f097fa2138d53c1c | 2,973 | py | Python | tests/test_cabac.py | IENT/PyCabac | 9d64cfda8e8fd9f1e91417ff552bc659fa47ae9e | [
"BSD-3-Clause"
] | 3 | 2021-09-20T12:10:53.000Z | 2022-03-28T10:17:57.000Z | tests/test_cabac.py | IENT/PyCabac | 9d64cfda8e8fd9f1e91417ff552bc659fa47ae9e | [
"BSD-3-Clause"
] | null | null | null | tests/test_cabac.py | IENT/PyCabac | 9d64cfda8e8fd9f1e91417ff552bc659fa47ae9e | [
"BSD-3-Clause"
] | 1 | 2021-09-21T15:42:22.000Z | 2021-09-21T15:42:22.000Z | import unittest
import random
import cabac
class MainTest(unittest.TestCase):
def test_enc_dec(self):
p1_init = 0.6
shift_idx = 8
bitsToEncode = [random.randint(0, 1) for _ in range(0, 1000)]
enc = cabac.cabacEncoder()
enc.initCtx([(p1_init, shift_idx), (p1_init, shift_idx)])
enc.start()
for i, bit in enumerate(bitsToEncode):
if i != 0:
ctx = bitsToEncode[i - 1]
else:
ctx = 0
enc.encodeBin(bit, ctx)
enc.encodeBinTrm(1)
enc.finish()
enc.writeByteAlignment()
bs = enc.getBitstream()
decodedBits = []
dec = cabac.cabacDecoder(bs)
dec.initCtx([(p1_init, shift_idx), (p1_init, shift_idx)])
dec.start()
for i in range(0, len(bitsToEncode)):
if i != 0:
ctx = decodedBits[i - 1]
else:
ctx = 0
decodedBit = dec.decodeBin(ctx)
decodedBits.append(decodedBit)
dec.decodeBinTrm()
dec.finish()
self.assertTrue(decodedBits == bitsToEncode)
def test_context_init(self):
# lets encode a unit step function with the smallest possible shift_idx
# IMHO this model should adapt quite quickly and result in the lowest
# possible bitrate
p1_init = 0
shift_idx = 0
bitsToEncode = [0] * 1000 + [1] * 1000
enc = cabac.cabacEncoder()
enc.initCtx([(p1_init, shift_idx)])
enc.start()
for i, bit in enumerate(bitsToEncode):
ctx = 0
enc.encodeBin(bit, ctx)
enc.encodeBinTrm(1)
enc.finish()
enc.writeByteAlignment()
bs = enc.getBitstream()
decodedBits = []
dec = cabac.cabacDecoder(bs)
dec.initCtx([(p1_init, shift_idx)])
dec.start()
for i in range(0, len(bitsToEncode)):
ctx = 0
decodedBit = dec.decodeBin(ctx)
decodedBits.append(decodedBit)
dec.decodeBinTrm()
dec.finish()
len1 = len(bs)
# Try with a larger shift_idx. This should end a a higher bitrate
shift_idx = 8
enc = cabac.cabacEncoder()
enc.initCtx([(p1_init, shift_idx)])
enc.start()
for i, bit in enumerate(bitsToEncode):
ctx = 0
enc.encodeBin(bit, ctx)
enc.encodeBinTrm(1)
enc.finish()
enc.writeByteAlignment()
bs = enc.getBitstream()
decodedBits = []
dec = cabac.cabacDecoder(bs)
dec.initCtx([(p1_init, shift_idx)])
dec.start()
for i in range(0, len(bitsToEncode)):
ctx = 0
decodedBit = dec.decodeBin(ctx)
decodedBits.append(decodedBit)
dec.decodeBinTrm()
dec.finish()
len2 = len(bs)
self.assertTrue(len1 < len2)
if __name__ == "__main__":
unittest.main()
| 26.783784 | 79 | 0.544568 | 331 | 2,973 | 4.782477 | 0.238671 | 0.065698 | 0.055591 | 0.070752 | 0.681617 | 0.665193 | 0.665193 | 0.665193 | 0.665193 | 0.665193 | 0 | 0.027461 | 0.350824 | 2,973 | 110 | 80 | 27.027273 | 0.792746 | 0.073327 | 0 | 0.752941 | 0 | 0 | 0.002909 | 0 | 0 | 0 | 0 | 0 | 0.023529 | 1 | 0.023529 | false | 0 | 0.035294 | 0 | 0.070588 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
f0f764b0db8aca5c56a82e63ae276f69198633e6 | 903 | py | Python | kernel/blog/migrations/0002_auto_20180605_1353.py | sageteam/behpack | 3b8afb81dc7da70807308af4c8a2d2ab92b1a133 | [
"MIT"
] | null | null | null | kernel/blog/migrations/0002_auto_20180605_1353.py | sageteam/behpack | 3b8afb81dc7da70807308af4c8a2d2ab92b1a133 | [
"MIT"
] | null | null | null | kernel/blog/migrations/0002_auto_20180605_1353.py | sageteam/behpack | 3b8afb81dc7da70807308af4c8a2d2ab92b1a133 | [
"MIT"
] | null | null | null | # Generated by Django 2.0.6 on 2018-06-05 09:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('blog', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='news',
name='sku',
field=models.CharField(default='vxY6mlScUwA', help_text='Unique code for refrence to supervisors', max_length=15),
),
migrations.AlterField(
model_name='newsmovies',
name='sku',
field=models.CharField(default='HXFm4TZBuwI', help_text='Unique code for refrence to supervisors', max_length=15),
),
migrations.AlterField(
model_name='newsphotos',
name='sku',
field=models.CharField(default='xPBjYllJVBs', help_text='Unique code for refrence to supervisors', max_length=15),
),
]
| 31.137931 | 126 | 0.612403 | 96 | 903 | 5.65625 | 0.5 | 0.110497 | 0.138122 | 0.160221 | 0.587477 | 0.587477 | 0.399632 | 0.399632 | 0.399632 | 0.399632 | 0 | 0.041096 | 0.272425 | 903 | 28 | 127 | 32.25 | 0.785388 | 0.049834 | 0 | 0.409091 | 1 | 0 | 0.232477 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.045455 | 0 | 0.181818 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
0b058a645e897beb64104d87e95c61b11cd1fee8 | 973 | py | Python | Parker/002 Chequebook/stupid way 0-19.py | eMUQI/MakePythonProject | b70646ab2318c4b9828bc0186c92d725c6b0b136 | [
"MIT"
] | 8 | 2020-08-28T13:17:59.000Z | 2020-12-27T01:47:34.000Z | Parker/002 Chequebook/stupid way 0-19.py | eMUQI/MakePythonProject | b70646ab2318c4b9828bc0186c92d725c6b0b136 | [
"MIT"
] | 1 | 2021-03-13T16:08:04.000Z | 2021-03-13T16:08:04.000Z | Parker/002 Chequebook/stupid way 0-19.py | eMUQI/MakePythonProject | b70646ab2318c4b9828bc0186c92d725c6b0b136 | [
"MIT"
] | 5 | 2020-08-25T14:02:03.000Z | 2020-09-07T07:51:34.000Z | def Function(anumber):
if anumber == 1:
print ("One")
elif anumber == 2:
print ("Two")
elif anumber == 3:
print ("Three")
elif anumber == 4:
print ("Four")
elif anumber == 5:
print ("Five")
elif anumber == 6:
print ("Six")
elif anumber == 7:
print ("Seven")
elif anumber == 8:
print ("Eight")
elif anumber == 9:
print ("Nine")
elif anumber == 10:
print ("Ten")
elif anumber == 11:
print ("Eleven")
elif anumber == 12:
print ("Twelve")
elif anumber == 13:
print ("Thirteen")
elif anumber == 14:
print ("Fourteen")
elif anumber == 15:
print ("Fifteen")
elif anumber == 16:
print ("Sixteen")
elif anumber == 17:
print ("Seventeen")
elif anumber == 18:
print ("Eighteen")
elif anumber == 19:
print ("Nineteen")
Function(6)
| 20.702128 | 27 | 0.476876 | 100 | 973 | 4.64 | 0.44 | 0.426724 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.049834 | 0.381295 | 973 | 46 | 28 | 21.152174 | 0.72093 | 0 | 0 | 0 | 0 | 0 | 0.108941 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.025 | false | 0 | 0 | 0 | 0.025 | 0.475 | 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 | 0 | 0 | 0 | 1 | 0 | 2 |
0b0a9dc713a85a0e9e52b654240b1a0c0342b452 | 1,138 | py | Python | var/spack/repos/builtin/packages/r-assertive-reflection/package.py | varioustoxins/spack | cab0e4cb240f34891a6d753f3393e512f9a99e9a | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | null | null | null | var/spack/repos/builtin/packages/r-assertive-reflection/package.py | varioustoxins/spack | cab0e4cb240f34891a6d753f3393e512f9a99e9a | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 6 | 2022-01-08T08:41:11.000Z | 2022-03-14T19:28:07.000Z | var/spack/repos/builtin/packages/r-assertive-reflection/package.py | foeroyingur/spack | 5300cbbb2e569190015c72d0970d25425ea38647 | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | null | null | null | # Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class RAssertiveReflection(RPackage):
"""assertive.reflection: Assertions for Checking the State of R
A set of predicates and assertions for checking the state
and capabilities of R, the operating system it is running
on, and the IDE being used. This is mainly for use by other
package developers who want to include run-time testing
features in their own packages. End-users will usually want
to use assertive directly."""
homepage = "https://bitbucket.org/richierocks/assertive.reflection"
url = "https://cloud.r-project.org/src/contrib/assertive.reflection_0.0-5.tar.gz"
list_url = "https://cloud.r-project.org/src/contrib/Archive/assertive.reflection"
version('0.0-5', sha256='c2ca9b27cdddb9b9876351afd2ebfaf0fbe72c636cd12aa2af5d64e33fbf34bd')
depends_on('r@3.0.0:', type=('build', 'run'))
depends_on('r-assertive-base@0.0-7:', type=('build', 'run'))
| 42.148148 | 97 | 0.73638 | 160 | 1,138 | 5.2125 | 0.6125 | 0.091127 | 0.05036 | 0.057554 | 0.151079 | 0.081535 | 0.081535 | 0.081535 | 0 | 0 | 0 | 0.05625 | 0.156415 | 1,138 | 26 | 98 | 43.769231 | 0.8125 | 0.500879 | 0 | 0 | 0 | 0.125 | 0.581308 | 0.162617 | 0 | 0 | 0 | 0 | 0.625 | 1 | 0 | false | 0 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
0b0cc0e10df00c8c365ac6e18fc8a432edc89d9b | 481 | py | Python | 08/00/7.py | pylangstudy/201710 | 139cad34d40f23beac85800633ec2ed63d530bfd | [
"CC0-1.0"
] | null | null | null | 08/00/7.py | pylangstudy/201710 | 139cad34d40f23beac85800633ec2ed63d530bfd | [
"CC0-1.0"
] | 25 | 2017-10-03T00:12:53.000Z | 2017-10-29T23:58:17.000Z | 08/00/7.py | pylangstudy/201710 | 139cad34d40f23beac85800633ec2ed63d530bfd | [
"CC0-1.0"
] | null | null | null | from functools import singledispatch
@singledispatch
def fun(arg, verbose=False):
if verbose:
print("Let me just say,", end=" ")
print(arg)
@fun.register(int)
def _(arg, verbose=False):
if verbose:
print("Strength in numbers, eh?", end=" ")
print(arg)
@fun.register(list)
def _(arg, verbose=False):
if verbose:
print("Enumerate this:")
for i, elem in enumerate(arg):
print(i, elem)
print(fun(1, True))
print(fun([2], True))
| 22.904762 | 50 | 0.62578 | 66 | 481 | 4.530303 | 0.469697 | 0.100334 | 0.150502 | 0.170569 | 0.458194 | 0.311037 | 0.214047 | 0 | 0 | 0 | 0 | 0.005333 | 0.220374 | 481 | 20 | 51 | 24.05 | 0.792 | 0 | 0 | 0.368421 | 0 | 0 | 0.118503 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.157895 | false | 0 | 0.052632 | 0 | 0.210526 | 0.421053 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
0b15922f9b1b565f5c12d8838021c8e30ac2f17a | 808 | py | Python | 535-encode-and-decode-tinyurl/535-encode-and-decode-tinyurl.py | hyeseonko/LeetCode | 48dfc93f1638e13041d8ce1420517a886abbdc77 | [
"MIT"
] | 2 | 2021-12-05T14:29:06.000Z | 2022-01-01T05:46:13.000Z | 535-encode-and-decode-tinyurl/535-encode-and-decode-tinyurl.py | hyeseonko/LeetCode | 48dfc93f1638e13041d8ce1420517a886abbdc77 | [
"MIT"
] | null | null | null | 535-encode-and-decode-tinyurl/535-encode-and-decode-tinyurl.py | hyeseonko/LeetCode | 48dfc93f1638e13041d8ce1420517a886abbdc77 | [
"MIT"
] | null | null | null | class Codec:
def __init__(self):
self.codec_dict = dict()
self.codec_reversed = dict()
self.codec_len = 0
def encode(self, longUrl: str) -> str:
"""Encodes a URL to a shortened URL.
"""
if longUrl not in self.codec_dict:
self.codec_dict[longUrl]=self.codec_len
self.codec_reversed[self.codec_len] = longUrl
self.codec_len+=1
return "http://tinyurl.com/{}".format(self.codec_dict[longUrl])
def decode(self, shortUrl: str) -> str:
"""Decodes a shortened URL to its original URL.
"""
val = int(shortUrl.split("/")[-1])
return self.codec_reversed[val]
# Your Codec object will be instantiated and called as such:
# codec = Codec()
# codec.decode(codec.encode(url)) | 32.32 | 71 | 0.600248 | 105 | 808 | 4.47619 | 0.409524 | 0.210638 | 0.110638 | 0.085106 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005128 | 0.27599 | 808 | 25 | 72 | 32.32 | 0.798291 | 0.252475 | 0 | 0 | 0 | 0 | 0.037162 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.214286 | false | 0 | 0 | 0 | 0.428571 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
0b1d84da0ed8c08c35fd5d02999eedaef40546b0 | 1,364 | py | Python | python_parikshith21/Day15.py | 01coders/50-Days-Of-Code | 98928cf0e186ee295bc90a4da0aa9554e2918659 | [
"MIT"
] | null | null | null | python_parikshith21/Day15.py | 01coders/50-Days-Of-Code | 98928cf0e186ee295bc90a4da0aa9554e2918659 | [
"MIT"
] | null | null | null | python_parikshith21/Day15.py | 01coders/50-Days-Of-Code | 98928cf0e186ee295bc90a4da0aa9554e2918659 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
Created on Wed May 22 17:54:15 2019
@author: Parikshith.H
"""
L1 = [10,20,30,40]
print(L1)
print(L1[0])
print(L1[3])
L1[3] = 50
print(L1)
#output:
# =============================================================================
# [10, 20, 30, 40]
# 10
# 40
# [10, 20, 30, 50]
# =============================================================================
L2 = [10,2.5,"hello"]
print(L2)
print(L2[2])
L2[1] = "welcome" #lists are mutable
print(L2)
# =============================================================================
# #output:
# [10, 2.5, 'hello']
# hello
# [10, 'welcome', 'hello']
# =============================================================================
l3 = [10,20,'hello',['A','B']] #4 elements int,int,string,list #it has list
#inside a list
print(l3[3])
print(l3[2])
print(l3[3][0])#in list3 acces 4th element inside that 1st element
# =============================================================================
# #output:
# ['A', 'B']
# hello
# A
# =============================================================================
l4 = [[10,20,30],[2,5,6]]
print(l4)
# =============================================================================
# #output:
# [[10, 20, 30], [2, 5, 6]]
# =============================================================================
| 24.8 | 79 | 0.285191 | 129 | 1,364 | 3.015504 | 0.418605 | 0.061697 | 0.077121 | 0.041131 | 0.046272 | 0.046272 | 0 | 0 | 0 | 0 | 0 | 0.088161 | 0.126833 | 1,364 | 54 | 80 | 25.259259 | 0.238455 | 0.728739 | 0 | 0.235294 | 0 | 0 | 0.057402 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.647059 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
9bceeb359ee70a3dd74046be9ae6a7955db25e62 | 1,320 | py | Python | trebelge/XMLFileProcessStrategy/XMLFileProcessStrategyContext.py | askmetoo/trebelge | bff1b13edf41d1a9afd9ddb039f5b4089cb83dd6 | [
"MIT"
] | null | null | null | trebelge/XMLFileProcessStrategy/XMLFileProcessStrategyContext.py | askmetoo/trebelge | bff1b13edf41d1a9afd9ddb039f5b4089cb83dd6 | [
"MIT"
] | null | null | null | trebelge/XMLFileProcessStrategy/XMLFileProcessStrategyContext.py | askmetoo/trebelge | bff1b13edf41d1a9afd9ddb039f5b4089cb83dd6 | [
"MIT"
] | 1 | 2022-03-17T21:53:07.000Z | 2022-03-17T21:53:07.000Z | # from __future__ import annotations
from trebelge.XMLFileProcessStrategy import XMLFileProcessStrategy
class XMLFileProcessStrategyContext:
"""
The Context defines the interface of interest to clients.
"""
_file_path: str = ''
_strategy: XMLFileProcessStrategy = None
"""
Usually, the Context accepts a strategy through the constructor, but
also provides a setter to change it at runtime.
"""
def set_strategy(self, strategy: XMLFileProcessStrategy):
"""
Usually, the Context allows replacing a Strategy object at runtime.
"""
self._strategy = strategy
def get_strategy(self):
"""
The Context maintains a reference to one of the Strategy objects. The
Context does not know the concrete class of a strategy. It should work
with all strategies via the Strategy interface.
"""
return self._strategy
def set_file_path(self, file_path: str):
self._file_path = file_path
def get_file_path(self):
return self._file_path
def return_file_data(self):
"""
The Context delegates some work to the Strategy object instead of
implementing multiple versions of the algorithm on its own.
"""
return self._strategy.return_file_data(self)
| 31.428571 | 78 | 0.680303 | 157 | 1,320 | 5.55414 | 0.426752 | 0.06422 | 0.041284 | 0.041284 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.260606 | 1,320 | 41 | 79 | 32.195122 | 0.893443 | 0.360606 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.357143 | false | 0 | 0.071429 | 0.071429 | 0.857143 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
9bdb2ed67432112ce4645478f8d4665dc55e4ebc | 117 | py | Python | test1.py | zhuligs/Pallas | c8d77d0963c080fa7331560f1659001488b0328f | [
"MIT"
] | null | null | null | test1.py | zhuligs/Pallas | c8d77d0963c080fa7331560f1659001488b0328f | [
"MIT"
] | null | null | null | test1.py | zhuligs/Pallas | c8d77d0963c080fa7331560f1659001488b0328f | [
"MIT"
] | null | null | null |
a = [[3,],[]]
for x in a:
x.append(4)
# print (x)
print (a)
b= []
for x in b:
print (3)
print (x) | 9 | 15 | 0.418803 | 22 | 117 | 2.227273 | 0.409091 | 0.163265 | 0.244898 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.04 | 0.358974 | 117 | 13 | 16 | 9 | 0.613333 | 0.076923 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.375 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
9bea7afdf3c575010e827d9449ff5c44c638dd78 | 347 | py | Python | myuw/test/management/commands/test_memcache.py | uw-it-aca/myuw | 3fa1fabeb3c09d81a049f7c1a8c94092d612438a | [
"Apache-2.0"
] | 18 | 2015-02-04T01:09:11.000Z | 2021-11-25T03:10:39.000Z | myuw/test/management/commands/test_memcache.py | uw-it-aca/myuw | 3fa1fabeb3c09d81a049f7c1a8c94092d612438a | [
"Apache-2.0"
] | 2,323 | 2015-01-15T19:45:10.000Z | 2022-03-21T19:57:06.000Z | myuw/test/management/commands/test_memcache.py | uw-it-aca/myuw | 3fa1fabeb3c09d81a049f7c1a8c94092d612438a | [
"Apache-2.0"
] | 9 | 2015-01-15T19:29:26.000Z | 2022-02-11T04:51:23.000Z | # Copyright 2021 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0
from django.test import TestCase
from django.core.management import call_command
class TestFlushMemcache(TestCase):
def test_run(self):
call_command('memcache', '-f')
call_command('memcache', '--flush')
call_command('memcache')
| 24.785714 | 48 | 0.717579 | 43 | 347 | 5.674419 | 0.697674 | 0.180328 | 0.233607 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020833 | 0.170029 | 347 | 13 | 49 | 26.692308 | 0.826389 | 0.236311 | 0 | 0 | 0 | 0 | 0.125954 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.285714 | 0 | 0.571429 | 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 | 0 | 0 | 1 | 0 | 0 | 2 |
9bf4ef9499dbdae8a4c7dd345bc2c4de01e39618 | 2,111 | py | Python | lib/utils/sort_points.py | nevermore3/PlateRecognition | 2d4a7604b0d85be4368542ad9fbd3553c99caa6a | [
"Apache-2.0"
] | 70 | 2017-04-06T12:57:00.000Z | 2022-03-01T01:35:42.000Z | lib/utils/sort_points.py | nevermore3/PlateRecognition | 2d4a7604b0d85be4368542ad9fbd3553c99caa6a | [
"Apache-2.0"
] | 9 | 2017-06-23T12:36:02.000Z | 2020-04-02T08:57:20.000Z | lib/utils/sort_points.py | nevermore3/plateRecognition | 2d4a7604b0d85be4368542ad9fbd3553c99caa6a | [
"Apache-2.0"
] | 35 | 2017-04-26T02:15:18.000Z | 2021-05-31T11:01:27.000Z | # @Time : 2018/2/9
# @Author : fh
# @File : sort_points.py
# @Desc :
"""
Sort points of quadrilateral
"""
import numpy as np
def sort_points(points):
"""
sort points
-> x
\
y
0 3
\-----------\
\ \
\ \
\-----------\
1 2
:param points: [4, 2] (x, y)
:return: sorted_points: [4, 2] (x, y)
"""
x = points[:, 0]
x_sort = np.argsort(x)
sorted_by_x = points[x_sort]
sorted_approx = []
p0 = sorted_by_x[0]
p1 = sorted_by_x[1]
p2 = sorted_by_x[2]
l0 = np.linalg.norm(p0 - p1)
l1 = np.linalg.norm(p0 - p2)
l2 = np.linalg.norm(p1 - p2)
min_index = np.argmin([l0, l1, l2])
rest_points = [sorted_by_x[3]]
if min_index == 0:
if p0[1] < p1[1]:
sorted_approx.append(p0)
sorted_approx.append(p1)
else:
sorted_approx.append(p1)
sorted_approx.append(p0)
rest_points.append(p2)
elif min_index == 1:
if p0[1] < p2[1]:
sorted_approx.append(p0)
sorted_approx.append(p2)
else:
sorted_approx.append(p2)
sorted_approx.append(p0)
rest_points.append(p1)
elif min_index == 2:
if p1[1] < p2[1]:
sorted_approx.append(p1)
sorted_approx.append(p2)
else:
sorted_approx.append(p2)
sorted_approx.append(p1)
rest_points.append(p0)
if rest_points[0][1] > rest_points[1][1]:
sorted_approx.append(rest_points[0])
sorted_approx.append(rest_points[1])
else:
sorted_approx.append(rest_points[1])
sorted_approx.append(rest_points[0])
return np.array(sorted_approx)
if __name__ == '__main__':
test_points = np.array([[871., 807.],
[871., 774.],
[1012., 774.],
[1012., 807.]])
print("Before sort: ", test_points)
print("Sorted: ", sort_points(test_points))
| 26.061728 | 47 | 0.494079 | 261 | 2,111 | 3.770115 | 0.214559 | 0.219512 | 0.292683 | 0.096545 | 0.428862 | 0.408537 | 0.343496 | 0.186992 | 0.126016 | 0.126016 | 0 | 0.073408 | 0.367598 | 2,111 | 80 | 48 | 26.3875 | 0.66367 | 0.16343 | 0 | 0.384615 | 0 | 0 | 0.017079 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.019231 | false | 0 | 0.019231 | 0 | 0.057692 | 0.038462 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
9bfbe7797dd432da6840d9fe52cb85c3a37e9afd | 466 | py | Python | src/evg/models/evg_manifest.py | dbradf/async-evg-py | 0ab54db9ec9f7cda3429b9a1e4669ff0899a76b5 | [
"Apache-2.0"
] | 1 | 2020-12-28T03:41:03.000Z | 2020-12-28T03:41:03.000Z | src/evg/models/evg_manifest.py | dbradf/aio-evergreen.py | 0ab54db9ec9f7cda3429b9a1e4669ff0899a76b5 | [
"Apache-2.0"
] | null | null | null | src/evg/models/evg_manifest.py | dbradf/aio-evergreen.py | 0ab54db9ec9f7cda3429b9a1e4669ff0899a76b5 | [
"Apache-2.0"
] | null | null | null | """Representation of evergreen manifest."""
from typing import Dict
from pydantic.main import BaseModel
class EvgManifestModule(BaseModel):
"""Represents a module in the evergreen manifest."""
branch: str
repo: str
revision: str
owner: str
url: str
class EvgManifest(BaseModel):
"""Representation of an evergreen manifest."""
id: str
revision: str
project: str
branch: str
modules: Dict[str, EvgManifestModule]
| 18.64 | 56 | 0.688841 | 53 | 466 | 6.056604 | 0.54717 | 0.158879 | 0.087227 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.223176 | 466 | 24 | 57 | 19.416667 | 0.88674 | 0.26824 | 0 | 0.285714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.142857 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
9bfe489ee7ac62f16617e97eb6d1f34680c70735 | 957 | py | Python | cssqc/rules/noUnderscores.py | matematik7/CSSQC | f8048435e60f688fef70d1608651d31e1288b4cf | [
"MIT"
] | null | null | null | cssqc/rules/noUnderscores.py | matematik7/CSSQC | f8048435e60f688fef70d1608651d31e1288b4cf | [
"MIT"
] | null | null | null | cssqc/rules/noUnderscores.py | matematik7/CSSQC | f8048435e60f688fef70d1608651d31e1288b4cf | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------
# cssqc/noUnderscores.py
#
# Do not underscores in class, id and mixin names.
# ----------------------------------------------------------------
# copyright (c) 2014 - Domen Ipavec
# Distributed under The MIT License, see LICENSE
# ----------------------------------------------------------------
from cssqc.qualityWarning import QualityWarning
def getHelp():
return """Do not allow underscores in class, id and mixin names."""
class noUnderscores:
def __init__(self, data):
self.on_HASH = self.on_IDENT
self.on_ATKEYWORD = self.on_IDENT
self.on_ATBRACES = self.on_IDENT
self.on_FUNCTION = self.on_IDENT
def on_IDENT(self, i):
if '_' in i.value:
return [QualityWarning('noUnderscores', i.lineno, 'Underscore appears in "%s".' % i.value)]
else:
return []
| 33 | 103 | 0.517241 | 101 | 957 | 4.762376 | 0.534653 | 0.099792 | 0.091476 | 0.093555 | 0.243243 | 0.137214 | 0.137214 | 0 | 0 | 0 | 0 | 0.007752 | 0.191223 | 957 | 28 | 104 | 34.178571 | 0.613695 | 0.409613 | 0 | 0 | 0 | 0 | 0.171171 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.214286 | false | 0 | 0.071429 | 0.071429 | 0.571429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
500bdbb2d5ebdaff51f375464a27591016b45b88 | 239 | py | Python | en/073/python/main.py | franciscogomes2020/exercises | 8b33c4b9349a9331e4002a8225adc2a482c70024 | [
"MIT"
] | null | null | null | en/073/python/main.py | franciscogomes2020/exercises | 8b33c4b9349a9331e4002a8225adc2a482c70024 | [
"MIT"
] | null | null | null | en/073/python/main.py | franciscogomes2020/exercises | 8b33c4b9349a9331e4002a8225adc2a482c70024 | [
"MIT"
] | null | null | null | # Create a tuple filled with the top 20 placed on the Brazilian Football Championship Table, in order of placement. Then show:
a) Top 5 teams.
b) Last 4 placed.
c) Teams in alphabetical order.
d) What position is the Chapecoense team in.
| 39.833333 | 126 | 0.76569 | 42 | 239 | 4.357143 | 0.785714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020513 | 0.1841 | 239 | 5 | 127 | 47.8 | 0.917949 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
500c802f8bd08f9738ac3f4e1af568630b760e6c | 1,749 | py | Python | Chapter01/Monolith/mythoughts/thoughts/models.py | ibiscum/Hands-On-Docker-for-Microservices-with-Python | 4fe648c5bc976251cbfeccabe9ee3ebb66ee87e4 | [
"MIT"
] | null | null | null | Chapter01/Monolith/mythoughts/thoughts/models.py | ibiscum/Hands-On-Docker-for-Microservices-with-Python | 4fe648c5bc976251cbfeccabe9ee3ebb66ee87e4 | [
"MIT"
] | null | null | null | Chapter01/Monolith/mythoughts/thoughts/models.py | ibiscum/Hands-On-Docker-for-Microservices-with-Python | 4fe648c5bc976251cbfeccabe9ee3ebb66ee87e4 | [
"MIT"
] | null | null | null | import bcrypt
from django.db import models
import random
import logging
# Get an instance of a logger
logger = logging.getLogger(__name__)
class UserModel(models.Model):
DoesNotExist = None
objects = None
username = models.CharField(max_length=50)
password_hash = models.CharField(max_length=100)
class IncorrectPassword(Exception):
pass
def check_password(self, password):
"""
Check the stored password, if incorrect will raise IncorrectPassword
"""
to_check = password.encode()
db_hash = self.password_hash.encode()
if bcrypt.hashpw(to_check, db_hash) == db_hash:
# Valid password
return True
raise self.IncorrectPassword
def login_user(self, password):
self.check_password(password)
return SessionModel.new_session(self.username)
class SessionModel(models.Model):
DoesNotExist = None
objects = None
session = models.CharField(max_length=50)
username = models.CharField(max_length=50)
@classmethod
def new_session(cls, username):
"""
Create a new session for the user, store it,
and clean old ones.
"""
new_session = random.getrandbits(248)
logger.error(new_session)
new = cls(session=new_session, username=username)
# Delete old sessions
cls.objects.filter(username=username).delete()
# Save the new session
new.save()
# Set the cookie with the session
return new_session
class ThoughtModel(models.Model):
objects = None
username = models.CharField(max_length=50)
text = models.CharField(max_length=250)
timestamp = models.DateTimeField(auto_now_add=True)
| 26.5 | 76 | 0.667238 | 205 | 1,749 | 5.556098 | 0.395122 | 0.070237 | 0.09482 | 0.126427 | 0.188762 | 0.165935 | 0.079017 | 0.079017 | 0 | 0 | 0 | 0.012987 | 0.251572 | 1,749 | 65 | 77 | 26.907692 | 0.857143 | 0.142939 | 0 | 0.205128 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.076923 | false | 0.230769 | 0.102564 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
501986ecc03667c077c2d02513118c32fc1eed06 | 1,730 | py | Python | wsic/multiprocessing.py | John-P/wsic | 751c71de9cb644adbbdc16b7d9ce7df75114eb6f | [
"MIT"
] | 4 | 2022-03-16T12:04:27.000Z | 2022-03-30T13:25:06.000Z | wsic/multiprocessing.py | John-P/wsic | 751c71de9cb644adbbdc16b7d9ce7df75114eb6f | [
"MIT"
] | null | null | null | wsic/multiprocessing.py | John-P/wsic | 751c71de9cb644adbbdc16b7d9ce7df75114eb6f | [
"MIT"
] | 1 | 2022-03-31T08:28:32.000Z | 2022-03-31T08:28:32.000Z | import multiprocessing.queues
from typing import Any
class Queue(multiprocessing.queues.Queue):
"""A multiprocessing.Queue subclass with a shared counter.
The `multiprocessing.Queue.qsize` is unreliable and may raise
`NotImplementedError` on Unix platforms like macOS where
`sem_getvalue()` is not implemented. Here we use a shared counter
instead.
"""
def __init__(self, *args, **kwargs) -> None:
"""Initialise the queue."""
super().__init__(*args, ctx=multiprocessing.get_context(), **kwargs)
self.counter = multiprocessing.Value("i", 0)
def put(self, *args, **kwargs) -> None:
"""Put an item into the queue."""
with self.counter.get_lock():
self.counter.value += 1
return super().put(*args, **kwargs)
def get(self, *args, **kwargs) -> Any:
"""Remove and return an item from the queue."""
value = super().get(*args, **kwargs)
with self.counter.get_lock():
self.counter.value -= 1
return value # noqa: R504
def qsize(self) -> int:
"""Return the number of items in the queue."""
return self.counter.value
def empty(self) -> bool:
"""Return True if the queue is empty."""
return self.qsize() == 0
def clear(self) -> None:
"""Clear the queue."""
while not self.empty():
self.get()
def __getstate__(self) -> Any:
"""Return the state of the queue."""
return (self.counter, super().__getstate__())
def __setstate__(self, state: Any) -> None:
"""Restore the state of the queue."""
self.counter, state = state
super().__setstate__(state)
self._after_fork()
| 32.037037 | 76 | 0.601156 | 210 | 1,730 | 4.809524 | 0.361905 | 0.063366 | 0.041584 | 0.035644 | 0.166337 | 0.089109 | 0.089109 | 0.089109 | 0.089109 | 0.089109 | 0 | 0.005495 | 0.263584 | 1,730 | 53 | 77 | 32.641509 | 0.787284 | 0.294798 | 0 | 0.071429 | 0 | 0 | 0.000867 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.071429 | 0 | 0.571429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
501b9f0e8e9673ee246edb03fa5e9ff0ab337e4a | 1,494 | py | Python | _tests/pagination.py | vivsh/django-ginger | d293109becc72845a23f2aeb732ed808a7a67d69 | [
"MIT"
] | null | null | null | _tests/pagination.py | vivsh/django-ginger | d293109becc72845a23f2aeb732ed808a7a67d69 | [
"MIT"
] | null | null | null | _tests/pagination.py | vivsh/django-ginger | d293109becc72845a23f2aeb732ed808a7a67d69 | [
"MIT"
] | null | null | null |
import mock
import random
from django import test
from django.utils import six
from ginger import utils
from ginger.paginator import GingerPaginator
def parse_url(url):
parts = six.moves.urllib.parse.urlparse(url)
return six.moves.urllib.parse.parse_qs(parts.query)
class TestGingerPaginator(test.SimpleTestCase):
def setUp(self):
self.factory = test.RequestFactory()
def request(self, **kwargs):
return self.factory.get("/", data=kwargs)
def test_missing_page(self):
pass
def test_invalid_page(self):
pass
def test_valid_page(self):
request = self.request()
# paginator = GingerPaginator([], per_page=10, page_limit=limit, parameter_name=param)
def test_constructor(self):
param = "pg"
limit = random.randint(10, 100)
paginator = GingerPaginator([], per_page=10, page_limit=limit, parameter_name=param)
self.assertEqual(paginator.page_limit, limit)
self.assertEqual(paginator.parameter_name, param)
def test_page(self):
param = "pg"
paginator = GingerPaginator([i for i in range(100)], per_page=10, parameter_name=param)
page_num = random.randint(1, 9)
req = self.request(**{param: page_num})
page = paginator.page(req)
self.assertEqual(page.paginator.parameter_name, param)
self.assertEqual(page.number, page.number)
page_links = page.build_links(req)
self.assertTrue(page_links)
| 27.666667 | 95 | 0.679384 | 187 | 1,494 | 5.28877 | 0.320856 | 0.035389 | 0.091001 | 0.038423 | 0.250758 | 0.131446 | 0.131446 | 0.131446 | 0.131446 | 0.131446 | 0 | 0.013652 | 0.215529 | 1,494 | 53 | 96 | 28.188679 | 0.830205 | 0.056225 | 0 | 0.111111 | 0 | 0 | 0.003564 | 0 | 0 | 0 | 0 | 0 | 0.138889 | 1 | 0.222222 | false | 0.055556 | 0.166667 | 0.027778 | 0.472222 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
50221c331ef03973bfea67141283fd5a39689f6c | 255 | py | Python | mmur/viz/commons.py | RUrlus/ModelMetricUncertaintyResearch | 37daa1421a3a45a6adaea3788e2d00493477ff96 | [
"Apache-2.0"
] | null | null | null | mmur/viz/commons.py | RUrlus/ModelMetricUncertaintyResearch | 37daa1421a3a45a6adaea3788e2d00493477ff96 | [
"Apache-2.0"
] | null | null | null | mmur/viz/commons.py | RUrlus/ModelMetricUncertaintyResearch | 37daa1421a3a45a6adaea3788e2d00493477ff96 | [
"Apache-2.0"
] | null | null | null | import matplotlib.pyplot as plt
def _set_plot_style():
plt.style.use('ggplot')
plt.rcParams['text.color'] = 'black'
plt.rcParams['figure.max_open_warning'] = 0
return [i['color'] for i in plt.rcParams['axes.prop_cycle']] # type: ignore
| 28.333333 | 80 | 0.682353 | 38 | 255 | 4.421053 | 0.763158 | 0.196429 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004673 | 0.160784 | 255 | 8 | 81 | 31.875 | 0.780374 | 0.047059 | 0 | 0 | 0 | 0 | 0.26556 | 0.095436 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | true | 0 | 0.166667 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
503acd77117bf7f4c10b8192c362e2f9fd39004a | 248 | py | Python | sample/garuda_custom.py | dhilipsiva/garuda | a1b1fdcf08ca0a808459bb21ea0b58d9673af64d | [
"MIT"
] | 22 | 2018-07-21T06:00:04.000Z | 2020-12-02T03:23:11.000Z | sample/garuda_custom.py | chr1043086360/garuda | a1b1fdcf08ca0a808459bb21ea0b58d9673af64d | [
"MIT"
] | 10 | 2020-02-11T23:04:56.000Z | 2021-07-30T11:22:28.000Z | sample/garuda_custom.py | chr1043086360/garuda | a1b1fdcf08ca0a808459bb21ea0b58d9673af64d | [
"MIT"
] | 1 | 2019-11-20T01:14:12.000Z | 2019-11-20T01:14:12.000Z | from garuda_dir.garuda_pb2 import Void
class GarudaCustom(object):
def CustomCallDemo(self, context, void):
'''
rpc CustomCallDemo(Void) returns (Void);
'''
print("Just a dummy RPC call")
return Void()
| 22.545455 | 48 | 0.616935 | 28 | 248 | 5.392857 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005587 | 0.278226 | 248 | 10 | 49 | 24.8 | 0.837989 | 0.16129 | 0 | 0 | 0 | 0 | 0.11413 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.2 | 0 | 0.8 | 0.2 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
504c0f2889b302ac3e2eb5d8b965f9fb817e3819 | 579 | py | Python | equipment_slots.py | Yamgrenade/Gou | fa4fea253ef1a7d6fdc4f59b51d27d7442cc3ded | [
"MIT"
] | null | null | null | equipment_slots.py | Yamgrenade/Gou | fa4fea253ef1a7d6fdc4f59b51d27d7442cc3ded | [
"MIT"
] | 9 | 2019-08-30T15:02:25.000Z | 2019-10-03T17:33:54.000Z | equipment_slots.py | Yamgrenade/Gou | fa4fea253ef1a7d6fdc4f59b51d27d7442cc3ded | [
"MIT"
] | 1 | 2020-07-13T16:29:19.000Z | 2020-07-13T16:29:19.000Z | from enum import Enum, auto
class EquipmentSlots(Enum):
MAIN_HAND = auto()
OFF_HAND = auto()
HEAD = auto()
CHEST= auto()
HANDS = auto()
LEGS = auto()
FEET = auto()
class EquipmentSlotGroups():
WEAPONS = [EquipmentSlots.MAIN_HAND]
ARMOR = [EquipmentSlots.HEAD, EquipmentSlots.CHEST, EquipmentSlots.HANDS, EquipmentSlots.LEGS, EquipmentSlots.FEET, EquipmentSlots.OFF_HAND]
ALL = [EquipmentSlots.MAIN_HAND, EquipmentSlots.OFF_HAND, EquipmentSlots.HEAD, EquipmentSlots.CHEST, EquipmentSlots.HANDS, EquipmentSlots.LEGS, EquipmentSlots.FEET]
| 34.058824 | 168 | 0.734024 | 61 | 579 | 6.868852 | 0.295082 | 0.057279 | 0.105012 | 0.176611 | 0.439141 | 0.439141 | 0.439141 | 0.439141 | 0.439141 | 0.439141 | 0 | 0 | 0.158895 | 579 | 16 | 169 | 36.1875 | 0.86037 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.076923 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
505856281f8e046199943aa0cddc7e9407a7668d | 743 | py | Python | utils/test/test_get_all_block_transactions.py | DanielSola/bitcoin-analysis | 1d86ebdc91984403b1dedb99cb74641cd8367066 | [
"MIT"
] | null | null | null | utils/test/test_get_all_block_transactions.py | DanielSola/bitcoin-analysis | 1d86ebdc91984403b1dedb99cb74641cd8367066 | [
"MIT"
] | null | null | null | utils/test/test_get_all_block_transactions.py | DanielSola/bitcoin-analysis | 1d86ebdc91984403b1dedb99cb74641cd8367066 | [
"MIT"
] | null | null | null | import unittest
from utils import get_all_block_transactions
from .expected_values import expected_number_of_transactions
class TestGetAllBlockTransactions(unittest.TestCase):
def setUp(self):
self.blocks_file_path = './data/blocks.json'
self.result_dict = get_all_block_transactions(self.blocks_file_path)
def test_number_of_blocks(self):
expected_number_of_blocks = 144
obtained_number_of_blocks = len(self.result_dict.keys())
self.assertEqual(expected_number_of_blocks, obtained_number_of_blocks)
def test_number_of_transactions(self):
result_number_of_transactions = list(self.result_dict.values())
self.assertEqual(result_number_of_transactions, expected_number_of_transactions) | 37.15 | 86 | 0.803499 | 97 | 743 | 5.701031 | 0.329897 | 0.144665 | 0.180832 | 0.083183 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004637 | 0.129206 | 743 | 20 | 86 | 37.15 | 0.850077 | 0 | 0 | 0 | 0 | 0 | 0.024194 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 1 | 0.214286 | false | 0 | 0.214286 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
505c63b752f316992a64ea06482884bde0c2df69 | 438 | py | Python | shopyo/autoapp.py | AbhijithGanesh/shopyo | 4d3bb949d63c80b98aaa9caa5fd5eb5db564a6a7 | [
"MIT"
] | null | null | null | shopyo/autoapp.py | AbhijithGanesh/shopyo | 4d3bb949d63c80b98aaa9caa5fd5eb5db564a6a7 | [
"MIT"
] | null | null | null | shopyo/autoapp.py | AbhijithGanesh/shopyo | 4d3bb949d63c80b98aaa9caa5fd5eb5db564a6a7 | [
"MIT"
] | null | null | null | from shopyo.app import create_app
# CONFIG_JSON_PATH = os.path.dirname(os.path.abspath(__file__))
# try:
# if not os.path.exists("config.json"):
# trycopy("config_demo.json", "config.json")
# except Exception as e:
# print(e)
# sys.exit(1)
# with open(os.path.join(CONFIG_JSON_PATH, "config.json")) as f:
# config_json = json.load(f)
# environment = config_json["environment"]
app = create_app("production")
| 23.052632 | 64 | 0.675799 | 64 | 438 | 4.421875 | 0.515625 | 0.24735 | 0.09894 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00274 | 0.166667 | 438 | 18 | 65 | 24.333333 | 0.772603 | 0.789954 | 0 | 0 | 0 | 0 | 0.123457 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
acc8364c04389893bc7ef4a263ea9b90612f94b4 | 246 | py | Python | finder/urls.py | plaunezkiy/unibase | 31a7cb801349c329270e0e5c91ca5c02d146aeed | [
"MIT"
] | null | null | null | finder/urls.py | plaunezkiy/unibase | 31a7cb801349c329270e0e5c91ca5c02d146aeed | [
"MIT"
] | null | null | null | finder/urls.py | plaunezkiy/unibase | 31a7cb801349c329270e0e5c91ca5c02d146aeed | [
"MIT"
] | null | null | null | from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="index"),
path("autocomplete/", views.autocomplete, name='autocomplete'),
path("<str:subject_name>/", views.subject_view, name="subject"),
]
| 27.333333 | 68 | 0.686992 | 29 | 246 | 5.758621 | 0.448276 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.138211 | 246 | 8 | 69 | 30.75 | 0.787736 | 0 | 0 | 0 | 0 | 0 | 0.227642 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.285714 | 0 | 0.285714 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
accd2672893995cb2caf5714edaf8d67f4493178 | 256 | py | Python | cosimulation/source/generate_fmu/fmu/cymdisttofmu/parser/utilities/CYMDISTModelicaTemplate_JModelica.py | Jonathan56/CyDER | 58cc88f5140585b6d4d9073eca29e3d3b324eb5e | [
"BSD-3-Clause-LBNL"
] | 10 | 2017-05-03T18:00:49.000Z | 2021-07-25T03:09:32.000Z | cosimulation/source/generate_fmu/fmu/cymdisttofmu/parser/utilities/CYMDISTModelicaTemplate_JModelica.py | Jonathan56/CyDER | 58cc88f5140585b6d4d9073eca29e3d3b324eb5e | [
"BSD-3-Clause-LBNL"
] | null | null | null | cosimulation/source/generate_fmu/fmu/cymdisttofmu/parser/utilities/CYMDISTModelicaTemplate_JModelica.py | Jonathan56/CyDER | 58cc88f5140585b6d4d9073eca29e3d3b324eb5e | [
"BSD-3-Clause-LBNL"
] | 2 | 2018-02-12T17:14:15.000Z | 2021-02-02T02:12:27.000Z | from pymodelica import compile_fmu
fmu_name = compile_fmu("{{model_name}}", "{{model_name}}.mo",
version="{{fmi_version}}", target="{{fmi_api}}",
compiler_options={'extra_lib_dirs':["{{sim_lib_path}}"]})
| 25.6 | 80 | 0.566406 | 28 | 256 | 4.75 | 0.678571 | 0.150376 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.246094 | 256 | 9 | 81 | 28.444444 | 0.689119 | 0 | 0 | 0 | 0 | 0 | 0.345238 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
accd4a962c3360d4173a900029c89689f8c4a859 | 620 | py | Python | bin/change_psl_4digit.py | jason-weirather/IDP | a79ac178317dcfa6eaec0cb0d8d9e65c827a79a2 | [
"Apache-2.0"
] | 5 | 2017-09-18T18:21:26.000Z | 2020-05-01T23:29:26.000Z | bin/change_psl_4digit.py | jason-weirather/IDP | a79ac178317dcfa6eaec0cb0d8d9e65c827a79a2 | [
"Apache-2.0"
] | 3 | 2018-11-26T16:35:12.000Z | 2021-11-22T07:16:51.000Z | bin/change_psl_4digit.py | jason-weirather/IDP | a79ac178317dcfa6eaec0cb0d8d9e65c827a79a2 | [
"Apache-2.0"
] | 4 | 2018-01-02T13:06:39.000Z | 2020-04-14T13:20:52.000Z | #!/usr/bin/python
import sys
import os
if len(sys.argv) >= 2 :
psl_filename = sys.argv[1]
else:
print("usage: psl_filename")
print("or ")
sys.exit(1)
################################################################################
psl = open(psl_filename,'r')
for line in psl:
ls = line.strip().split("\t")
identity = str(round(float(ls[0])/float(ls[10]),4))
name = identity + "_" + ls[10]
if ls[9][-3:] == "ccs":
name = name + "|ccs"
ls[9] = name
print "\t".join(ls)
psl.close()
################################################################################
| 22.962963 | 80 | 0.403226 | 72 | 620 | 3.416667 | 0.555556 | 0.134146 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.023762 | 0.185484 | 620 | 26 | 81 | 23.846154 | 0.463366 | 0.025806 | 0 | 0 | 0 | 0 | 0.079007 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.111111 | null | null | 0.166667 | 0 | 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 | 2 |
4a1105d1512c135df92938d058bf57907992b708 | 644 | py | Python | data/modules/graphic/two_D/background.py | Sheidaas/gamee | 434db4648e1719a648b8784f201b03b4c8e243c3 | [
"CC-BY-3.0"
] | null | null | null | data/modules/graphic/two_D/background.py | Sheidaas/gamee | 434db4648e1719a648b8784f201b03b4c8e243c3 | [
"CC-BY-3.0"
] | null | null | null | data/modules/graphic/two_D/background.py | Sheidaas/gamee | 434db4648e1719a648b8784f201b03b4c8e243c3 | [
"CC-BY-3.0"
] | null | null | null | import pygame
class Background:
def __init__(self, x1, y1, x2, y2, color: tuple, screen):
self.size = (x1 * screen.engine.settings.graphic['screen']['resolution_scale'][0],
y1 * screen.engine.settings.graphic['screen']['resolution_scale'][1],
x2 * screen.engine.settings.graphic['screen']['resolution_scale'][0],
y2 * screen.engine.settings.graphic['screen']['resolution_scale'][1])
self.color = color
self.rect = None
self.screen = screen
def render_background(self):
pygame.draw.rect(self.screen.screen, self.color, self.size)
| 37.882353 | 90 | 0.613354 | 75 | 644 | 5.146667 | 0.346667 | 0.124352 | 0.207254 | 0.279793 | 0.507772 | 0.507772 | 0.507772 | 0.507772 | 0 | 0 | 0 | 0.02459 | 0.242236 | 644 | 16 | 91 | 40.25 | 0.766393 | 0 | 0 | 0 | 0 | 0 | 0.136646 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.083333 | 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 | 0 | 0 | 0 | 0 | 0 | 2 |
4a215e57c1f4e299e48764c4fb0d2cb8ee0a9f57 | 686 | py | Python | IWS/plugins/twilio/reqhandler.py | FlyingDiver/Indigo-Twilio | b912e83c8a62f62329d01881d719de5ae097037d | [
"MIT"
] | 1 | 2016-12-10T20:57:49.000Z | 2016-12-10T20:57:49.000Z | IWS/plugins/twilio/reqhandler.py | FlyingDiver/Indigo-Twilio | b912e83c8a62f62329d01881d719de5ae097037d | [
"MIT"
] | 9 | 2018-05-07T21:59:44.000Z | 2022-01-29T22:49:29.000Z | IWS/plugins/twilio/reqhandler.py | FlyingDiver/Indigo-Twilio | b912e83c8a62f62329d01881d719de5ae097037d | [
"MIT"
] | null | null | null | ####################
import cherrypy
from indigopy.basereqhandler import BaseRequestHandler
####################
def PluginName():
return u"Twilio Ping"
def PluginDescription():
return u"This is the Twilio-Indigo Ping Plugin."
def ShowOnControlPageList():
return False # if True, then above name/description is shown on the Control Page list index
####################
class TwilioRequestHandler(BaseRequestHandler):
def __init__(self, logFunc, debugLogFunc):
BaseRequestHandler.__init__(self, logFunc, debugLogFunc)
def ping(self, **params):
cherrypy.server.indigoDb.VariableSetValue(cherrypy.server.indigoConn, "twilio_ping", "true")
return
ping.exposed = True
| 26.384615 | 94 | 0.714286 | 73 | 686 | 6.589041 | 0.60274 | 0.087318 | 0.06237 | 0.112266 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.120991 | 686 | 25 | 95 | 27.44 | 0.797678 | 0.110787 | 0 | 0 | 0 | 0 | 0.116788 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.133333 | 0.2 | 0.8 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
c57a3cb7787d2fa4383a3fabe7ca10ba202545cf | 3,208 | py | Python | submit.py | meypporul/mp1 | 452f70cdbdf8978a45dbb44051dfd2e95f538da3 | [
"Apache-2.0"
] | 1 | 2020-09-11T16:33:15.000Z | 2020-09-11T16:33:15.000Z | submit.py | meypporul/mp1 | 452f70cdbdf8978a45dbb44051dfd2e95f538da3 | [
"Apache-2.0"
] | null | null | null | submit.py | meypporul/mp1 | 452f70cdbdf8978a45dbb44051dfd2e95f538da3 | [
"Apache-2.0"
] | null | null | null | #**********************
#*
#* Progam Name: MP1. Membership Protocol.
#*
#* Current file: submit.py
#* About this file: Submission python script.
#*
#***********************
import urllib
import urllib2
import hashlib
import random
import email
import email.message
import email.encoders
import StringIO
import sys
import subprocess
import json
import os
""""""""""""""""""""
""""""""""""""""""""
class NullDevice:
def write(self, s):
pass
def submit():
print '==\n== [sandbox] Submitting Solutions \n=='
(login, password) = loginPrompt()
if not login:
print '!! Submission Cancelled'
return
output = subprocess.Popen(['sh', 'run.sh', str(0)]).communicate()[0]
submissions = [source(i) for i in range(3)]
submitSolution(login, password, submissions)
# =========================== LOGIN HELPERS - NO NEED TO CONFIGURE THIS =======================================
def loginPrompt():
"""Prompt the user for login credentials. Returns a tuple (login, password)."""
(login, password) = basicPrompt()
return login, password
def basicPrompt():
"""Prompt the user for login credentials. Returns a tuple (login, password)."""
login = raw_input('Login (Email address): ')
password = raw_input('One-time Password (from the assignment page. This is NOT your own account\'s password): ')
return login, password
def partPrompt():
print 'Hello! These are the assignment parts that you can submit:'
counter = 0
for part in partFriendlyNames:
counter += 1
print str(counter) + ') ' + partFriendlyNames[counter - 1]
partIdx = int(raw_input('Please enter which part you want to submit (1-' + str(counter) + '): ')) - 1
return (partIdx, partIds[partIdx])
def submit_url():
"""Returns the submission url."""
return "https://www.coursera.org/api/onDemandProgrammingScriptSubmissions.v1"
def submitSolution(email_address,password, submissions):
"""Submits a solution to the server. Returns (result, string)."""
values = {
"assignmentKey": akey, \
"submitterEmail": email_address, \
"secret": password, \
"parts": {
partIds[0]: {
"output": submissions[0]
},
partIds[1]: {
"output": submissions[1]
},
partIds[2]: {
"output": submissions[2]
}
}
}
url = submit_url()
data = json.dumps(values)
req = urllib2.Request(url)
req.add_header('Content-Type', 'application/json')
req.add_header('Cache-Control', 'no-cache')
response = urllib2.urlopen(req, data)
return
## This collects the source code (just for logging purposes)
def source(partIdx):
# open the file, get all lines
f = open("dbg.%d.log" % partIdx)
src = f.read()
f.close()
#print src
return src
def cleanup():
for i in range(3):
try:
os.remove("dbg.%s.log" % i)
except:
pass
akey = 'Mj8OkgI-EeaTLQonT2FRpw'
# the "Identifier" you used when creating the part
partIds = ['b9m9h', 'MxUat', '8ATm3']
# used to generate readable run-time information for students
partFriendlyNames = ['Single Failure', 'Multiple Failure', 'Message Drop Single Failure']
submit()
cleanup()
| 25.259843 | 114 | 0.620948 | 370 | 3,208 | 5.359459 | 0.47027 | 0.04589 | 0.006051 | 0.011094 | 0.075643 | 0.06354 | 0.06354 | 0.06354 | 0.06354 | 0.06354 | 0 | 0.010256 | 0.209788 | 3,208 | 126 | 115 | 25.460317 | 0.771992 | 0.147756 | 0 | 0.096386 | 0 | 0 | 0.23102 | 0.00898 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.120482 | 0.144578 | null | null | 0.048193 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
c58009bbaa19de05511cebf60d93bfb3138744b0 | 2,147 | py | Python | keystoneclient/client.py | jamielennox/python-keystoneclient | a1bc48c0fc475db6bca761a9023c35adab740dab | [
"Apache-1.1"
] | 1 | 2020-12-18T01:07:30.000Z | 2020-12-18T01:07:30.000Z | keystoneclient/client.py | jamielennox/python-keystoneclient | a1bc48c0fc475db6bca761a9023c35adab740dab | [
"Apache-1.1"
] | null | null | null | keystoneclient/client.py | jamielennox/python-keystoneclient | a1bc48c0fc475db6bca761a9023c35adab740dab | [
"Apache-1.1"
] | null | null | null | # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from keystoneclient import discover
from keystoneclient import httpclient
from keystoneclient import session as client_session
# Using client.HTTPClient is deprecated. Use httpclient.HTTPClient instead.
HTTPClient = httpclient.HTTPClient
def Client(version=None, unstable=False, session=None, **kwargs):
"""Factory function to create a new identity service client.
:param tuple version: The required version of the identity API. If
specified the client will be selected such that the
major version is equivalent and an endpoint provides
at least the specified minor version. For example to
specify the 3.1 API use (3, 1).
:param bool unstable: Accept endpoints not marked as 'stable'. (optional)
:param Session session: A session object to be used for communication. If
one is not provided it will be constructed from the
provided kwargs. (optional)
:param kwargs: Additional arguments are passed through to the client
that is being created.
:returns: New keystone client object
(keystoneclient.v2_0.Client or keystoneclient.v3.Client).
:raises: DiscoveryFailure if the server's response is invalid
:raises: VersionNotAvailable if a suitable client cannot be found.
"""
if not session:
session = client_session.Session.construct(kwargs)
d = discover.Discover(session=session, **kwargs)
return d.create_client(version=version, unstable=unstable)
| 45.680851 | 79 | 0.700978 | 279 | 2,147 | 5.379928 | 0.491039 | 0.039973 | 0.047968 | 0.021319 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006769 | 0.24313 | 2,147 | 46 | 80 | 46.673913 | 0.916923 | 0.754075 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.333333 | 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 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
c58095647c068e98c5f4131f14a7a8bde81af705 | 83 | py | Python | packages/girder_worker/girder_worker/plugins/types/format/image/pil_to_png.py | ShenQianwithC/HistomicsTK | 4ad7e72a7ebdabbdfc879254fad04ce7ca47e320 | [
"Apache-2.0"
] | null | null | null | packages/girder_worker/girder_worker/plugins/types/format/image/pil_to_png.py | ShenQianwithC/HistomicsTK | 4ad7e72a7ebdabbdfc879254fad04ce7ca47e320 | [
"Apache-2.0"
] | null | null | null | packages/girder_worker/girder_worker/plugins/types/format/image/pil_to_png.py | ShenQianwithC/HistomicsTK | 4ad7e72a7ebdabbdfc879254fad04ce7ca47e320 | [
"Apache-2.0"
] | null | null | null | from six import StringIO
s = StringIO()
input.save(s, 'png')
output = s.getvalue()
| 16.6 | 24 | 0.698795 | 13 | 83 | 4.461538 | 0.769231 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.144578 | 83 | 4 | 25 | 20.75 | 0.816901 | 0 | 0 | 0 | 0 | 0 | 0.036145 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c58251b2c54ebf654497de91e5577b7ac5109191 | 568 | py | Python | gidibooks/users/models.py | luckyadogun/gidibooks | f06d3116eb0e954e515eeb8b82956a67c4b91861 | [
"MIT"
] | 1 | 2021-04-09T08:58:38.000Z | 2021-04-09T08:58:38.000Z | gidibooks/users/models.py | luckyadogun/gidibooks | f06d3116eb0e954e515eeb8b82956a67c4b91861 | [
"MIT"
] | null | null | null | gidibooks/users/models.py | luckyadogun/gidibooks | f06d3116eb0e954e515eeb8b82956a67c4b91861 | [
"MIT"
] | null | null | null | import uuid
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.utils.translation import gettext as _
from django.core.validators import RegexValidator
from users.modelmanager import CustomUserManager
class User(AbstractUser):
username = None
email = models.EmailField(
_("email"), max_length=250, unique=True
)
user_id = models.UUIDField(default=uuid.uuid4)
USERNAME_FIELD = "email"
REQUIRED_FIELDS = []
objects = CustomUserManager()
def __str__(self):
return self.email
| 22.72 | 51 | 0.734155 | 66 | 568 | 6.166667 | 0.636364 | 0.09828 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008677 | 0.18838 | 568 | 24 | 52 | 23.666667 | 0.874187 | 0 | 0 | 0 | 0 | 0 | 0.017606 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.058824 | false | 0 | 0.352941 | 0.058824 | 0.882353 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
c59f6db307116cfc4431aa1ddcbefadd91e1e51e | 850 | py | Python | osr/apps/registry/models/directories.py | offurface/osr | 83ebcc11f0d9d8050ac2139bc6e9e560e93e8b9e | [
"MIT"
] | null | null | null | osr/apps/registry/models/directories.py | offurface/osr | 83ebcc11f0d9d8050ac2139bc6e9e560e93e8b9e | [
"MIT"
] | 10 | 2021-03-19T09:01:32.000Z | 2022-02-10T21:34:43.000Z | osr/apps/registry/models/directories.py | offurface/osr | 83ebcc11f0d9d8050ac2139bc6e9e560e93e8b9e | [
"MIT"
] | null | null | null | from django.db import models
from .objects import *
from django.urls import reverse
class Sport_type(models.Model):
name = models.CharField(max_length=250, verbose_name="Наименование")
def __str__(self):
return self.name
def get_absolute_url(self,*args,**kwargs):
return reverse('sport-type-detail', kwargs={'pk': self.pk})
class Meta:
ordering = ("name",)
verbose_name = "Вид спорта"
verbose_name_plural = "Виды спорта"
class Rank(models.Model):
name = models.CharField(max_length=250, verbose_name="Наименование разряда")
rank = models.PositiveIntegerField(verbose_name="Разряд")
def __str__(self):
return "%s %s" % (self.name, self.rank)
class Meta:
ordering = ("name", "rank",)
verbose_name = "Разряд"
verbose_name_plural = "Разряд"
| 26.5625 | 80 | 0.66 | 104 | 850 | 5.182692 | 0.394231 | 0.142857 | 0.055659 | 0.077922 | 0.241187 | 0.241187 | 0.241187 | 0.241187 | 0.241187 | 0.241187 | 0 | 0.009009 | 0.216471 | 850 | 31 | 81 | 27.419355 | 0.8003 | 0 | 0 | 0.181818 | 0 | 0 | 0.126179 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.136364 | false | 0 | 0.136364 | 0.136364 | 0.727273 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
c5b9227e1ab3ff07abfb7d98feb7a657b67f00a3 | 1,365 | py | Python | tests/test_packets.py | slee124565/pytwseia | 4c633cef12e37f5ba0d11748b8966ab598975a19 | [
"Apache-2.0"
] | 3 | 2021-04-14T09:17:22.000Z | 2021-05-10T06:04:56.000Z | tests/test_packets.py | slee124565/twseia | 4c633cef12e37f5ba0d11748b8966ab598975a19 | [
"Apache-2.0"
] | null | null | null | tests/test_packets.py | slee124565/twseia | 4c633cef12e37f5ba0d11748b8966ab598975a19 | [
"Apache-2.0"
] | null | null | null | import unittest
from tests.sample_pdus import *
import twseia
class TestSAInfoRegisterPackets(unittest.TestCase):
def test_sa_info_request_packet(self):
pdu = [6, 0, 0, 255, 255, 6] # Register Request Packet
packet = twseia.SAInfoRequestPacket.create(
sa_info_type=twseia.SARegisterServiceIDEnum.REGISTRATION
)
self.assertEqual(packet.to_pdu(), pdu)
def test_sa_info_register_packet(self):
pdu = kHITACHI_AC_RAD_50NK_REGISTER_PDU
packet = twseia.SARegisterPacket.from_pdu(pdu=pdu)
self.assertEqual(packet.type_id, twseia.SATypeIDEnum.AIR_CONDITIONER)
self.assertEqual(packet.class_id, twseia.SAClassID.HOME_DEVICE)
self.assertEqual(packet.data_type_id, twseia.SAPacketDataLenType.FIXED_LEN)
self.assertEqual(packet.major_ver, 4)
self.assertEqual(packet.minor_ver, 0)
self.assertEqual(packet.brand, 'HITACHI')
self.assertEqual(packet.model, 'RAD-50NK')
self.assertEqual(len(packet.services), 18)
for service in packet.services:
self.assertTrue(isinstance(service, twseia.SAServiceBase))
self.assertTrue(twseia.ACServiceIDEnum(service.service_id).name,
f'service_id {service.service_id}')
self.assertTrue(packet)
if __name__ == '__main__':
unittest.main()
| 39 | 83 | 0.698901 | 157 | 1,365 | 5.834395 | 0.414013 | 0.14738 | 0.183406 | 0.028384 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.016605 | 0.205861 | 1,365 | 34 | 84 | 40.147059 | 0.828413 | 0.01685 | 0 | 0 | 0 | 0 | 0.040299 | 0 | 0 | 0 | 0 | 0 | 0.428571 | 1 | 0.071429 | false | 0 | 0.107143 | 0 | 0.214286 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c5c04a66d7472852de88b1f4dff56090fb6cc696 | 731 | py | Python | 7.py | Rostislav9821/Lab_21 | 30e64f81620c3486dae3ff48f10a5731502eb6c3 | [
"MIT"
] | null | null | null | 7.py | Rostislav9821/Lab_21 | 30e64f81620c3486dae3ff48f10a5731502eb6c3 | [
"MIT"
] | null | null | null | 7.py | Rostislav9821/Lab_21 | 30e64f81620c3486dae3ff48f10a5731502eb6c3 | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
# -*- config: utf-8 -*-
from tkinter import *
root = Tk()
mainmenu = Menu(root)
root.config(menu=mainmenu)
filemenu = Menu(mainmenu, tearoff=0)
filemenu.add_command(label="Открыть...")
filemenu.add_command(label="Новый")
filemenu.add_command(label="Сохранить...")
filemenu.add_command(label="Выход")
helpmenu = Menu(mainmenu, tearoff=0)
helpmenu2 = Menu(helpmenu, tearoff=0)
helpmenu2.add_command(label="Локальная справка")
helpmenu2.add_command(label="На сайте")
helpmenu.add_cascade(label="Помощь", menu=helpmenu2)
helpmenu.add_command(label="О программе")
mainmenu.add_cascade(label="Файл", menu=filemenu)
mainmenu.add_cascade(label="Справка", menu=helpmenu)
root.mainloop() | 28.115385 | 53 | 0.737346 | 95 | 731 | 5.568421 | 0.378947 | 0.132325 | 0.198488 | 0.173913 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013761 | 0.105335 | 731 | 26 | 54 | 28.115385 | 0.795107 | 0.058824 | 0 | 0 | 0 | 0 | 0.128399 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.055556 | 0 | 0.055556 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c5c1bf857e3db866b33e937104e9909ed4fe74ae | 656 | py | Python | star_tides/core/actions/delete_project_action.py | STAR-TIDES/kb | 6f895b03db0eefa86a1667d3024f4fe5b92ea99e | [
"MIT"
] | 2 | 2021-06-10T20:58:27.000Z | 2021-12-29T14:40:44.000Z | star_tides/core/actions/delete_project_action.py | STAR-TIDES/kb | 6f895b03db0eefa86a1667d3024f4fe5b92ea99e | [
"MIT"
] | 38 | 2021-05-13T06:23:49.000Z | 2021-10-12T23:32:36.000Z | star_tides/core/actions/delete_project_action.py | STAR-TIDES/kb | 6f895b03db0eefa86a1667d3024f4fe5b92ea99e | [
"MIT"
] | null | null | null | '''star_tides.core.actions.delete_project_action
'''
from mongoengine.errors import DoesNotExist
from star_tides.core.actions.base_action import Action
from star_tides.services.databases.mongo.models.project_model import ProjectModel
from star_tides.exceptions import NotFoundError
class DeleteProjectAction(Action):
def __init__(self, project_id: str) -> None:
self.project_id = project_id
def run(self) -> None:
try:
ProjectModel.objects.get(id=self.project_id).delete()
except DoesNotExist as e:
raise NotFoundError(
f'Could not find project with ID {self.project_id}.') from e
| 34.526316 | 81 | 0.72561 | 84 | 656 | 5.464286 | 0.5 | 0.098039 | 0.11329 | 0.087146 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.190549 | 656 | 18 | 82 | 36.444444 | 0.864407 | 0.068598 | 0 | 0 | 0 | 0 | 0.081126 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.153846 | false | 0 | 0.307692 | 0 | 0.538462 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
c5d70184b09291c7c118cf261eccc6649ff7a644 | 209 | py | Python | test/mylib.py | iafisher/autosuite | f6b1d2e0c7466f85fa9b46387d2b10a5a8bef4cb | [
"MIT"
] | null | null | null | test/mylib.py | iafisher/autosuite | f6b1d2e0c7466f85fa9b46387d2b10a5a8bef4cb | [
"MIT"
] | 6 | 2018-06-24T15:56:35.000Z | 2019-11-01T02:28:00.000Z | test/mylib.py | iafisher/autosuite | f6b1d2e0c7466f85fa9b46387d2b10a5a8bef4cb | [
"MIT"
] | null | null | null | def fib(n):
if n < 0:
raise FibonacciError
elif n <= 2:
return 1
else:
return fib(n-1) + fib(n-2)
class FibonacciError(Exception):
pass
class FibTestClass:
pass
| 13.0625 | 34 | 0.555024 | 28 | 209 | 4.142857 | 0.571429 | 0.103448 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.036765 | 0.349282 | 209 | 15 | 35 | 13.933333 | 0.816176 | 0 | 0 | 0.181818 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0.181818 | 0 | 0 | 0.454545 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
c5d7edb5fff19a18c4cd98a03ab012940f15299a | 747 | py | Python | pyppeteer_folder/0.version.py | relax-space/python-learning | 22987e20a4b0a741e1c5ed8603a952a0fc8dd4bd | [
"Apache-2.0"
] | null | null | null | pyppeteer_folder/0.version.py | relax-space/python-learning | 22987e20a4b0a741e1c5ed8603a952a0fc8dd4bd | [
"Apache-2.0"
] | null | null | null | pyppeteer_folder/0.version.py | relax-space/python-learning | 22987e20a4b0a741e1c5ed8603a952a0fc8dd4bd | [
"Apache-2.0"
] | null | null | null | # """
# chromium version
# 默认版本是:575458
# # 可执行文件默认路径:C:\Users\Administrator\AppData\Local\pyppeteer\pyppeteer\local-chromium\575458\chrome-win32\chrome.exe
# win64平台下载链接为:https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/575458/chrome-win32.zip
# https://storage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win_x64/878785/
# https://chromium.woolyss.com/download/#windows
# python.exe .\pyppeteer_folder\0.version.py
# """
import pyppeteer.chromium_downloader
print('默认版本是:{}'.format(pyppeteer.__chromium_revision__))
print('可执行文件默认路径:{}'.format(
pyppeteer.chromium_downloader.chromiumExecutable.get('win64')))
print('win64平台下载链接为:{}'.format(
pyppeteer.chromium_downloader.downloadURLs.get('win64')))
| 35.571429 | 116 | 0.784471 | 87 | 747 | 6.609195 | 0.505747 | 0.118261 | 0.14087 | 0.086957 | 0.170435 | 0.170435 | 0.170435 | 0 | 0 | 0 | 0 | 0.058074 | 0.054886 | 747 | 20 | 117 | 37.35 | 0.756374 | 0.582329 | 0 | 0 | 0 | 0 | 0.15 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.166667 | 0 | 0.166667 | 0.5 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
c5da5643a639610fa652d156292f5fcb67a3e2db | 1,262 | py | Python | gpgkeyring/decorators.py | joeblackwaslike/gpgkeyring | 65d595c2db2007eff400f929307fb3a036b7069c | [
"MIT"
] | null | null | null | gpgkeyring/decorators.py | joeblackwaslike/gpgkeyring | 65d595c2db2007eff400f929307fb3a036b7069c | [
"MIT"
] | null | null | null | gpgkeyring/decorators.py | joeblackwaslike/gpgkeyring | 65d595c2db2007eff400f929307fb3a036b7069c | [
"MIT"
] | null | null | null | """
:mod:`gpgkeyring.decorators`
~~~~~~~~~~~~~~~~~~~~
GPG/Keychain related decorators.
:copyright: (c) 2018 by Joseph Black.
:license: MIT, see LICENSE for more details.
.. module:: gpgkeyring.decorators
.. moduleauthor:: Joseph Black <me@joeblack.nyc>
"""
from functools import wraps
from . import events
__all__ = ["expires_cache", "passthru"]
def expires_cache(func):
"""Automatically expire cache.
:param typing.Callable func: the function to expire cache for.
:returns: the wrapped function.
:rtype: instance of :class:`typing.Callable`.
:emits: :term:`event` of :class:`gpgkeyring.events.KeyCacheExpiry`.
"""
@wraps(func)
def _wrapper(self, *args, **kwargs):
load_func = getattr(self, "_load", None)
load_func.cache_clear()
result = func(self, *args, **kwargs)
load_func.cache_clear()
return result
return _wrapper
def passthru(func):
"""Return value of function by same name in proxied object.
Proxied object is located as an attribute named `_wrapped` in proxy object.
"""
@wraps(func)
def _wrapper(self, *args, **kwargs):
name = func.__name__
return getattr(self._wrapped, func.__name__)(*args, **kwargs)
return _wrapper
| 23.811321 | 79 | 0.659271 | 150 | 1,262 | 5.373333 | 0.5 | 0.049628 | 0.052109 | 0.047146 | 0.119107 | 0.081886 | 0.081886 | 0 | 0 | 0 | 0 | 0.003988 | 0.20523 | 1,262 | 52 | 80 | 24.269231 | 0.799601 | 0.493661 | 0 | 0.444444 | 0 | 0 | 0.043993 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0.111111 | 0.111111 | 0 | 0.555556 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
c5e0062414a44705c36ec1a789884971b4f2f62a | 610 | py | Python | users/migrations/0002_auto_20200622_0928.py | pythonmentor/teiva-p11 | 4be26edbad6e490c3991ca1ce5680e889b2ab75a | [
"MIT",
"Unlicense"
] | null | null | null | users/migrations/0002_auto_20200622_0928.py | pythonmentor/teiva-p11 | 4be26edbad6e490c3991ca1ce5680e889b2ab75a | [
"MIT",
"Unlicense"
] | 4 | 2021-03-30T14:25:16.000Z | 2021-06-17T06:53:27.000Z | users/migrations/0002_auto_20200622_0928.py | pythonmentor/teiva-p11 | 4be26edbad6e490c3991ca1ce5680e889b2ab75a | [
"MIT",
"Unlicense"
] | 2 | 2020-08-15T17:23:42.000Z | 2020-08-15T17:23:55.000Z | # Generated by Django 3.0.7 on 2020-06-22 09:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("users", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="user",
name="email",
field=models.EmailField(
max_length=100, verbose_name="Adresse mail"
),
),
migrations.AlterField(
model_name="user",
name="first_name",
field=models.CharField(max_length=100, verbose_name="Prénom"),
),
]
| 23.461538 | 74 | 0.555738 | 61 | 610 | 5.42623 | 0.655738 | 0.120846 | 0.151057 | 0.175227 | 0.362538 | 0.223565 | 0 | 0 | 0 | 0 | 0 | 0.061125 | 0.329508 | 610 | 25 | 75 | 24.4 | 0.748166 | 0.07377 | 0 | 0.368421 | 1 | 0 | 0.10302 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.052632 | 0 | 0.210526 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
c5e25afd26f568ed2524f9b8d833b423e018f904 | 685 | py | Python | travels/migrations/0030_auto_20190120_1305.py | minikdo/travelarchive2 | 56def21103e2f064bdb9817ca0ba8c8efe51ab48 | [
"Apache-2.0"
] | null | null | null | travels/migrations/0030_auto_20190120_1305.py | minikdo/travelarchive2 | 56def21103e2f064bdb9817ca0ba8c8efe51ab48 | [
"Apache-2.0"
] | 1 | 2021-04-17T15:18:54.000Z | 2021-04-17T15:18:54.000Z | travels/migrations/0030_auto_20190120_1305.py | minikdo/travelarchive2 | 56def21103e2f064bdb9817ca0ba8c8efe51ab48 | [
"Apache-2.0"
] | null | null | null | # Generated by Django 2.1.5 on 2019-01-20 12:05
from django.db import migrations, models
import travels.models
class Migration(migrations.Migration):
dependencies = [
('travels', '0029_auto_20190119_1709'),
]
operations = [
migrations.AddField(
model_name='flight',
name='boarding_pass',
field=models.ImageField(blank=True, null=True, upload_to=travels.models.flight_upload_location),
),
migrations.AlterField(
model_name='travel',
name='key_photo',
field=models.ImageField(blank=True, null=True, upload_to=travels.models.travel_upload_location),
),
]
| 27.4 | 108 | 0.636496 | 76 | 685 | 5.565789 | 0.578947 | 0.092199 | 0.099291 | 0.122931 | 0.27896 | 0.27896 | 0.27896 | 0.27896 | 0.27896 | 0.27896 | 0 | 0.060665 | 0.254015 | 685 | 24 | 109 | 28.541667 | 0.767123 | 0.065693 | 0 | 0.111111 | 1 | 0 | 0.100313 | 0.03605 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.055556 | 0.111111 | 0 | 0.277778 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
c5ea6471aa218f8c5a26ae0c155367a6822c697d | 1,206 | py | Python | render.py | sharmapulkit/roNNie-Pool | 84f511236bc01d80983fcbabba896f065a658028 | [
"Apache-2.0"
] | 2 | 2017-10-03T19:41:46.000Z | 2020-03-01T17:39:04.000Z | render.py | sharmapulkit/roNNie-pool | 84f511236bc01d80983fcbabba896f065a658028 | [
"Apache-2.0"
] | null | null | null | render.py | sharmapulkit/roNNie-pool | 84f511236bc01d80983fcbabba896f065a658028 | [
"Apache-2.0"
] | 2 | 2018-08-07T05:02:09.000Z | 2019-07-31T20:40:25.000Z | from fastfiz import fastfiz
import cv2
import numpy as np
import os
import itertools
# Colors:
bg_color=(15,150,15)
color_steps=5
colors_array=np.linspace(0, 255, color_steps)
# Remove green colored ball later
ball_colors=list(itertools.product(colors_array, colors_array, colors_array))
ball_colors.insert(0, (255, 255, 255))
ball_radius=2
def render_balls(dims, ball_positions, ball_params=None, output_filename='positions.png'):
img_height, img_width, margin = dims
img = np.zeros((img_width + 2*margin, img_height + 2*margin, 3), np.uint8)
for x in range(margin, img_width + margin):
for y in range(margin, img_height + margin):
img[x, y, :] = bg_color[:]
for b_id, b_pos in enumerate(ball_positions):
cv2.circle(img, tuple(map(lambda x, y: x + y, b_pos, (margin, margin))), ball_radius, ball_colors[b_id], 6)
cv2.imshow('img', img)
cv2.waitKey(0)
#img.save(output_filename, "PNG")
def get_ball_positions():
## TODO : Caller to fastfiz API
def get_game_config():
## TODO
if __name__=="__main__":
img_width = 480
img_height = 240
margin = 20
ball_positions = [(10, 10), (50, 50), (60, 60), (80, 60), (95, 10)]
render_balls([img_width, img_height, margin], ball_positions)
| 27.409091 | 109 | 0.721393 | 199 | 1,206 | 4.130653 | 0.41206 | 0.079075 | 0.041363 | 0.053528 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.058767 | 0.139303 | 1,206 | 43 | 110 | 28.046512 | 0.733141 | 0.087065 | 0 | 0 | 0 | 0 | 0.021958 | 0 | 0 | 0 | 0 | 0.023256 | 0 | 0 | null | null | 0 | 0.172414 | null | null | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
6806f238e7e1dfab4756b4cd98b2e26d1a7e9586 | 486 | py | Python | adv/gala_luca_maxstacks.py | XenoXilus/dl | cdfce03835cd67aac553140d6d88bc4c5c5d60ff | [
"Apache-2.0"
] | null | null | null | adv/gala_luca_maxstacks.py | XenoXilus/dl | cdfce03835cd67aac553140d6d88bc4c5c5d60ff | [
"Apache-2.0"
] | null | null | null | adv/gala_luca_maxstacks.py | XenoXilus/dl | cdfce03835cd67aac553140d6d88bc4c5c5d60ff | [
"Apache-2.0"
] | null | null | null | from core.advbase import *
import adv.gala_luca
def module():
return Gala_Luca
class Gala_Luca(adv.gala_luca.Gala_Luca):
comment = '7 buff icons from team (buff value not considered); use VC/FitF if HP<70'
conf = adv.gala_luca.Gala_Luca.conf.copy()
conf['slots.a'] = ['The_Wyrmclan_Duo', 'Primal_Crisis']
def buff_icon_count(self):
return 7
if __name__ == '__main__':
from core.simulate import test_with_argv
test_with_argv(Gala_Luca, *sys.argv) | 27 | 88 | 0.709877 | 77 | 486 | 4.155844 | 0.571429 | 0.2 | 0.103125 | 0.09375 | 0.11875 | 0 | 0 | 0 | 0 | 0 | 0 | 0.01005 | 0.18107 | 486 | 18 | 89 | 27 | 0.79397 | 0 | 0 | 0 | 0 | 0 | 0.238193 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.153846 | false | 0 | 0.230769 | 0.153846 | 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 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
681229f63a17e2ea93497c2bff31c7a185587371 | 1,588 | py | Python | calculate_iou.py | tianyikong/calculate_iou | b0921597717ea07fa4008cb16ab4ff6df343d830 | [
"MIT"
] | null | null | null | calculate_iou.py | tianyikong/calculate_iou | b0921597717ea07fa4008cb16ab4ff6df343d830 | [
"MIT"
] | null | null | null | calculate_iou.py | tianyikong/calculate_iou | b0921597717ea07fa4008cb16ab4ff6df343d830 | [
"MIT"
] | null | null | null | class Box:
def __init__(self, xmin, xmax, ymin, ymax):
assert xmax > xmin >= 0, ("Got invalid box with xmin: {0} and xmax {1}".format(xmin, xmax))
assert ymax > ymin >= 0, ("Got invalid box with ymin: {0} and ymax {1}".format(ymin, ymax))
self._xmin = xmin
self._xmax = xmax
self._ymin = ymin
self._ymax = ymax
@property
def xmin(self):
return self._xmin
@property
def ymin(self):
return self._ymin
@property
def xmax(self):
return self._xmax
@property
def ymax(self):
return self._ymax
@property
def width(self):
return self.xmax - self.xmin
@property
def height(self):
return self.ymax - self.ymin
@property
def area(self):
return self.width * self.height
def intersection(box1: Box, box2: Box):
# find the upper left and bottom right corner of intersection box
xmin = max(box1.xmin, box2.xmin)
xmax = min(box1.xmax, box2.xmax)
ymin = max(box1.ymin, box2.ymin)
ymax = min(box1.ymax, box2.ymax)
intersection_area = max(xmax - xmin, 0) * max(ymax - ymin, 0)
return intersection_area
def calculate_iou(box1: Box, box2: Box):
_intersection = intersection(box1, box2)
union = box1.area + box2.area - _intersection
return _intersection / union
if __name__ == "__main__":
# some test samples
a = [0, 1, 0, 1]
b = [0, 1, 0, 2]
box1 = Box(*a)
box2 = Box(*b)
print(box1)
print(box1.area)
print(calculate_iou(box1, box2)) | 24.060606 | 99 | 0.59194 | 214 | 1,588 | 4.266355 | 0.224299 | 0.084337 | 0.107338 | 0.030668 | 0.03943 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033808 | 0.292191 | 1,588 | 66 | 100 | 24.060606 | 0.77847 | 0.051008 | 0 | 0.145833 | 0 | 0 | 0.062458 | 0 | 0 | 0 | 0 | 0 | 0.041667 | 1 | 0.208333 | false | 0 | 0 | 0.145833 | 0.416667 | 0.0625 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
a84efadfe6951429829134f269e6e55de64287ce | 2,150 | py | Python | google-cloud-sdk/lib/surface/compute/addresses/list.py | bopopescu/searchparty | afdc2805cb1b77bd5ac9fdd1a76217f4841f0ea6 | [
"Apache-2.0"
] | 1 | 2017-11-29T18:52:27.000Z | 2017-11-29T18:52:27.000Z | google-cloud-sdk/lib/surface/compute/addresses/list.py | bopopescu/searchparty | afdc2805cb1b77bd5ac9fdd1a76217f4841f0ea6 | [
"Apache-2.0"
] | null | null | null | google-cloud-sdk/lib/surface/compute/addresses/list.py | bopopescu/searchparty | afdc2805cb1b77bd5ac9fdd1a76217f4841f0ea6 | [
"Apache-2.0"
] | 3 | 2017-07-27T18:44:13.000Z | 2020-07-25T17:48:53.000Z | # Copyright 2014 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command for listing addresses."""
from googlecloudsdk.api_lib.compute import base_classes
class List(base_classes.GlobalRegionalLister):
"""List addresses."""
@property
def global_service(self):
return self.compute.globalAddresses
@property
def regional_service(self):
return self.compute.addresses
@property
def resource_type(self):
return 'addresses'
@property
def allowed_filtering_types(self):
return ['globalAddresses', 'addresses']
List.detailed_help = {
'brief': 'List addresses',
'DESCRIPTION': """\
*{command}* lists summary information of addresses in a project. The
*--uri* option can be used to display URIs instead. Users who want to
see more data should use `gcloud compute addresses describe`.
By default, global addresses and addresses from all regions are listed.
The results can be narrowed down by providing the *--regions* or
*--global* flag.
""",
'EXAMPLES': """\
To list all addresses in a project in table form, run:
$ {command}
To list the URIs of all addresses in a project, run:
$ {command} --uri
To list all of the global addresses in a project, run:
$ {command} --global
To list all of the regional addresses in a project, run:
$ {command} --regions
To list all of the addresses from the ``us-central1'' and the
``europe-west1'' regions, run:
$ {command} --regions us-central1,europe-west1
""",
}
| 29.452055 | 79 | 0.677674 | 283 | 2,150 | 5.116608 | 0.473498 | 0.041436 | 0.041436 | 0.065608 | 0.145028 | 0.060083 | 0 | 0 | 0 | 0 | 0 | 0.007286 | 0.233953 | 2,150 | 72 | 80 | 29.861111 | 0.871888 | 0.286512 | 0 | 0.157895 | 0 | 0 | 0.684977 | 0.015884 | 0 | 0 | 0 | 0 | 0 | 1 | 0.105263 | false | 0 | 0.026316 | 0.105263 | 0.263158 | 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 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.