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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
de87015a313af7c062d533dd9d22bacab721a3a2 | 274 | py | Python | ch01/img_show.py | TAYAyuki/deep-learning-from-scratch | c86526135a6f1b93c7f646b54574eabdef7207f6 | [
"MIT"
] | null | null | null | ch01/img_show.py | TAYAyuki/deep-learning-from-scratch | c86526135a6f1b93c7f646b54574eabdef7207f6 | [
"MIT"
] | null | null | null | ch01/img_show.py | TAYAyuki/deep-learning-from-scratch | c86526135a6f1b93c7f646b54574eabdef7207f6 | [
"MIT"
] | null | null | null | # coding: utf-8
"""画像の表示"""
import matplotlib.pyplot as plt
from matplotlib.image import imread
img = imread('../dataset/lena.png') # 画像の読み込み
plt.imshow(img)
#画像表示のためのメソッド
plt.show()
"""
-*- ポイント -*-
from matplotlib.image import imread
imread('画像の情報')
plt.imshow(画像)
"""
| 15.222222 | 45 | 0.69708 | 37 | 274 | 5.162162 | 0.621622 | 0.146597 | 0.198953 | 0.26178 | 0.324607 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004167 | 0.124088 | 274 | 17 | 46 | 16.117647 | 0.791667 | 0.145985 | 0 | 0 | 0 | 0 | 0.136691 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
de8e775fe1f7510a6aba361c0069f1eabf302bd4 | 170 | py | Python | model/permission.py | boggard/jira-telegram-bot | 90d7d94dd32bb1629f88f70015c73cc394264bb9 | [
"MIT"
] | 5 | 2017-11-21T07:38:50.000Z | 2019-06-03T12:53:53.000Z | model/permission.py | boggard/jira-telegram-bot | 90d7d94dd32bb1629f88f70015c73cc394264bb9 | [
"MIT"
] | 2 | 2017-11-02T13:51:24.000Z | 2017-11-15T15:01:25.000Z | model/permission.py | boggard/jira-telegram-bot | 90d7d94dd32bb1629f88f70015c73cc394264bb9 | [
"MIT"
] | 6 | 2017-10-26T20:17:50.000Z | 2020-12-13T02:29:21.000Z | from peewee import *
from model.abstract_entity import AbstractEntity
class Permission(AbstractEntity):
id = PrimaryKeyField()
t_id = IntegerField(unique=True)
| 21.25 | 48 | 0.776471 | 19 | 170 | 6.842105 | 0.789474 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.152941 | 170 | 7 | 49 | 24.285714 | 0.902778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
de97edb97b6d217dd6cbf7390496c9585e37cb13 | 873 | py | Python | 꼬아버리기.py | Tim232/Memes | 4324f1ffcf36b6f10e7b38439ca9a4225900b15b | [
"Unlicense"
] | 2 | 2020-12-29T10:43:56.000Z | 2021-01-06T23:23:09.000Z | 꼬아버리기.py | Tim232/Memes | 4324f1ffcf36b6f10e7b38439ca9a4225900b15b | [
"Unlicense"
] | null | null | null | 꼬아버리기.py | Tim232/Memes | 4324f1ffcf36b6f10e7b38439ca9a4225900b15b | [
"Unlicense"
] | null | null | null | def meme1():
return str(
bytes(
list(
map(
lambda i: i + 48,
[
int("49"),
int("3c", 16),
int("60"),
int(str(-16)),
int("38", 16),
int("41", 12),
int("1l", 36),
int("2020", 3),
int("-100", 4),
int("30", 21),
int("1o", 26),
int("3h", 18),
int("2j", 25),
int("29", 31),
int(str(63), int("1011", 2)),
],
)
)
),
"".join(map(lambda c: chr(ord(c) + 12), list("ihZ,"))),
)
| 30.103448 | 63 | 0.207331 | 67 | 873 | 2.701493 | 0.626866 | 0.082873 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.185304 | 0.641466 | 873 | 28 | 64 | 31.178571 | 0.392971 | 0 | 0 | 0 | 0 | 0 | 0.043528 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.035714 | true | 0 | 0 | 0.035714 | 0.071429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 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 | 3 |
dea6a255e51e2ac181836d439ad008dbf8942a77 | 1,163 | py | Python | calculadora.py | Josh0105/practicaPresencial | 4d0d6513c2b299ad457486280f49e610c933843f | [
"Apache-2.0"
] | null | null | null | calculadora.py | Josh0105/practicaPresencial | 4d0d6513c2b299ad457486280f49e610c933843f | [
"Apache-2.0"
] | null | null | null | calculadora.py | Josh0105/practicaPresencial | 4d0d6513c2b299ad457486280f49e610c933843f | [
"Apache-2.0"
] | null | null | null | import math
class calculadora:
def __init__(self):
self.historial = []
def suma(self,a,b):
self.historial.append(str(a)+" + "+str(b)+" = "+str(a+b))
return a+b
def resta(self,a,b):
self.historial.append(str(a)+" - "+str(b)+" = "+str(a-b))
return a-b
def multiplicar(self,a,b):
self.historial.append(str(a)+" * "+str(b)+" = "+str(a*b))
return a*b
def dividir(self,a,b):
try:
self.historial.append(str(a)+" / "+str(b)+" = "+str(a/b))
return a/b
except:
self.historial.append("Division no definida")
return False
def potencia(self,a,b):
try:
self.historial.append(str(a)+" ^ "+str(b)+" = "+str(pow(a,b)))
return pow(a,b)
except:
self.historial.append("Potencia no definida")
False
def raiz(self,a,b):
try:
self.historial.append(str(b)+" ^ ( 1 / "+str(a)+" ) = "+str(pow(b,(1/a))))
return pow(b,(1/a))
except:
self.historial.append("Raiz no definida")
return False | 28.365854 | 86 | 0.484093 | 153 | 1,163 | 3.653595 | 0.176471 | 0.057245 | 0.305903 | 0.236136 | 0.568873 | 0.568873 | 0.47585 | 0.47585 | 0.420394 | 0.420394 | 0 | 0.003876 | 0.33448 | 1,163 | 41 | 87 | 28.365854 | 0.718346 | 0 | 0 | 0.235294 | 0 | 0 | 0.085911 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.205882 | false | 0 | 0.029412 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
dead8a50f0b2fb30fc7b9bb1099009d6c4721627 | 1,178 | py | Python | blog/managers.py | thecodeblogs/django-tcp-blog | 1b00f6b97faa594348ed8326d45b8446087214f1 | [
"MIT"
] | 1 | 2021-01-21T21:05:35.000Z | 2021-01-21T21:05:35.000Z | blog/managers.py | thecodeblogs/django-tcb-blog | 1b00f6b97faa594348ed8326d45b8446087214f1 | [
"MIT"
] | null | null | null | blog/managers.py | thecodeblogs/django-tcb-blog | 1b00f6b97faa594348ed8326d45b8446087214f1 | [
"MIT"
] | null | null | null | from django.db.models import QuerySet, Manager, Q
class EntriesQuerySet(QuerySet):
def only_published(self):
return self.filter(Q(published=True) & Q(defunct=False))
def for_author(self, handle):
return self.filter(author__handle=handle)
def with_tags(self, tags):
return self.filter(tag_set__in=tags)
class DefaultEntriesManager(Manager):
def get_queryset(self):
return EntriesQuerySet(self.model, using=self._db)
def only_published(self):
return self.get_queryset().only_published()
def for_author(self, handle):
return self.get_queryset().for_author(handle)
def with_tags(self, tags):
return self.get_queryset().with_tags(tags)
class CommentQuerySet(QuerySet):
def public(self):
return self.filter(user__profile__comments_public=True)
def approved(self):
return self.filter(approved=True)
class DefaultCommentManager(Manager):
def get_queryset(self):
return CommentQuerySet(self.model, using=self._db)
def public(self):
return self.get_queryset().public();
def approved(self):
return self.get_queryset().approved();
| 26.177778 | 64 | 0.698642 | 147 | 1,178 | 5.408163 | 0.258503 | 0.125786 | 0.10566 | 0.132075 | 0.534591 | 0.376101 | 0.168553 | 0.08805 | 0 | 0 | 0 | 0 | 0.194397 | 1,178 | 44 | 65 | 26.772727 | 0.837724 | 0 | 0 | 0.413793 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.413793 | false | 0 | 0.034483 | 0.413793 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
deaf8f0cb7538a596d125acba929a964c7d3e9f5 | 2,310 | py | Python | packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-basic/TestBasicVector.py | xiaobai/swift-lldb | 9238527ce430e6837108a16d2a91b147551fb83c | [
"Apache-2.0"
] | 765 | 2015-12-03T16:44:59.000Z | 2022-03-07T12:41:10.000Z | packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-basic/TestBasicVector.py | xiaobai/swift-lldb | 9238527ce430e6837108a16d2a91b147551fb83c | [
"Apache-2.0"
] | 1,815 | 2015-12-11T23:56:05.000Z | 2020-01-10T19:28:43.000Z | packages/Python/lldbsuite/test/commands/expression/import-std-module/vector-basic/TestBasicVector.py | xiaobai/swift-lldb | 9238527ce430e6837108a16d2a91b147551fb83c | [
"Apache-2.0"
] | 284 | 2015-12-03T16:47:25.000Z | 2022-03-12T05:39:48.000Z | """
Test basic std::vector functionality.
"""
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestBasicVector(TestBase):
mydir = TestBase.compute_mydir(__file__)
# FIXME: This should work on more setups, so remove these
# skipIf's in the future.
@add_test_categories(["libc++"])
@skipIf(compiler=no_match("clang"))
@skipIf(oslist=no_match(["linux"]))
@skipIf(debug_info=no_match(["dwarf"]))
def test(self):
self.build()
lldbutil.run_to_source_breakpoint(self,
"// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
self.runCmd("settings set target.import-std-module true")
self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3'])
self.expect("expr (int)a.front()", substrs=['(int) $1 = 3'])
self.expect("expr (int)a[1]", substrs=['(int) $2 = 1'])
self.expect("expr (int)a.back()", substrs=['(int) $3 = 2'])
self.expect("expr std::sort(a.begin(), a.end())")
self.expect("expr (int)a.front()", substrs=['(int) $4 = 1'])
self.expect("expr (int)a[1]", substrs=['(int) $5 = 2'])
self.expect("expr (int)a.back()", substrs=['(int) $6 = 3'])
self.expect("expr std::reverse(a.begin(), a.end())")
self.expect("expr (int)a.front()", substrs=['(int) $7 = 3'])
self.expect("expr (int)a[1]", substrs=['(int) $8 = 2'])
self.expect("expr (int)a.back()", substrs=['(int) $9 = 1'])
self.expect("expr (int)(*a.begin())", substrs=['(int) $10 = 3'])
self.expect("expr (int)(*a.rbegin())", substrs=['(int) $11 = 1'])
self.expect("expr a.pop_back()")
self.expect("expr (int)a.back()", substrs=['(int) $12 = 2'])
self.expect("expr (size_t)a.size()", substrs=['(size_t) $13 = 2'])
self.expect("expr (int)a.at(0)", substrs=['(int) $14 = 3'])
self.expect("expr a.push_back(4)")
self.expect("expr (int)a.back()", substrs=['(int) $15 = 4'])
self.expect("expr (size_t)a.size()", substrs=['(size_t) $16 = 3'])
self.expect("expr a.emplace_back(5)")
self.expect("expr (int)a.back()", substrs=['(int) $17 = 5'])
self.expect("expr (size_t)a.size()", substrs=['(size_t) $18 = 4'])
| 39.827586 | 76 | 0.569697 | 330 | 2,310 | 3.912121 | 0.306061 | 0.185902 | 0.260263 | 0.197521 | 0.494191 | 0.469404 | 0.422928 | 0.422928 | 0.275755 | 0.178156 | 0 | 0.028633 | 0.198701 | 2,310 | 57 | 77 | 40.526316 | 0.668828 | 0.051082 | 0 | 0 | 0 | 0 | 0.382043 | 0.02153 | 0 | 0 | 0 | 0.017544 | 0 | 1 | 0.026316 | false | 0 | 0.105263 | 0 | 0.184211 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
dec595d613117649b48414bde0749a680353cc41 | 158 | py | Python | src/medium_api/__init__.py | weeping-angel/medium-apis | bccda63c31cf8b11699b3c000fcd49a6cb866e44 | [
"MIT"
] | 1 | 2022-03-23T14:38:59.000Z | 2022-03-23T14:38:59.000Z | src/medium_api/__init__.py | weeping-angel/medium-api | bccda63c31cf8b11699b3c000fcd49a6cb866e44 | [
"MIT"
] | null | null | null | src/medium_api/__init__.py | weeping-angel/medium-api | bccda63c31cf8b11699b3c000fcd49a6cb866e44 | [
"MIT"
] | null | null | null | from medium_api.medium import Medium
# To prevent importing other modules while `from medium_api import *`
__all__ = [
'Medium'
]
__version__ = '0.2.4' | 17.555556 | 69 | 0.721519 | 22 | 158 | 4.727273 | 0.681818 | 0.192308 | 0.25 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.023256 | 0.183544 | 158 | 9 | 70 | 17.555556 | 0.782946 | 0.424051 | 0 | 0 | 0 | 0 | 0.122222 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.2 | 0 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
def9067dc8bfb4f7d40bf7b5ed1ddefd9e6730bf | 853 | py | Python | app/migrations/0002_auto_20201207_1312.py | Gr8ayu/SPCPortal | 1aaaff36b5db6d1f5d4eb6a5aa483f4c61720a2e | [
"MIT"
] | 5 | 2021-11-22T08:03:41.000Z | 2021-12-18T10:46:41.000Z | app/migrations/0002_auto_20201207_1312.py | Gr8ayu/SPCPortal | 1aaaff36b5db6d1f5d4eb6a5aa483f4c61720a2e | [
"MIT"
] | 2 | 2021-09-26T06:33:12.000Z | 2021-09-26T08:07:35.000Z | app/migrations/0002_auto_20201207_1312.py | Gr8ayu/SPCPortal | 1aaaff36b5db6d1f5d4eb6a5aa483f4c61720a2e | [
"MIT"
] | 3 | 2020-12-06T14:09:25.000Z | 2022-01-23T10:34:18.000Z | # Generated by Django 3.1 on 2020-12-07 07:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='education',
name='admission_mode_rank',
field=models.IntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='education',
name='bio',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='education',
name='no_of_backlogs',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='education',
name='sem',
field=models.IntegerField(default=1),
),
]
| 25.088235 | 61 | 0.552169 | 80 | 853 | 5.775 | 0.525 | 0.155844 | 0.199134 | 0.233766 | 0.363636 | 0.363636 | 0.190476 | 0 | 0 | 0 | 0 | 0.035088 | 0.33177 | 853 | 33 | 62 | 25.848485 | 0.775439 | 0.05041 | 0 | 0.444444 | 1 | 0 | 0.111386 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.037037 | 0 | 0.148148 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
def994f59860fd14f0281177480eda6bf12f73ff | 164 | py | Python | setup.py | vinsfan368/saspt | 773292fc245c01ceb8e1f7a7e50b475aa003f00c | [
"MIT"
] | null | null | null | setup.py | vinsfan368/saspt | 773292fc245c01ceb8e1f7a7e50b475aa003f00c | [
"MIT"
] | 1 | 2021-12-10T16:34:29.000Z | 2021-12-10T16:34:29.000Z | setup.py | alecheckert/saspt | 773292fc245c01ceb8e1f7a7e50b475aa003f00c | [
"MIT"
] | null | null | null | """ Everything is in setup.cfg.
If installing from local repo, use
pip install .
from the top-level repo directory.
"""
from setuptools import setup
setup()
| 14.909091 | 34 | 0.719512 | 24 | 164 | 4.916667 | 0.791667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.195122 | 164 | 10 | 35 | 16.4 | 0.893939 | 0.713415 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
723caf91818af2a48a40eb74c52808c44c375bb9 | 5,727 | py | Python | Surface Velocity/SurfaceVelocityParse.py | Valentin-Aslanyan/ASOT | 9d1fbe9c28b366085b25c852e0179cd543bd5146 | [
"MIT"
] | null | null | null | Surface Velocity/SurfaceVelocityParse.py | Valentin-Aslanyan/ASOT | 9d1fbe9c28b366085b25c852e0179cd543bd5146 | [
"MIT"
] | null | null | null | Surface Velocity/SurfaceVelocityParse.py | Valentin-Aslanyan/ASOT | 9d1fbe9c28b366085b25c852e0179cd543bd5146 | [
"MIT"
] | null | null | null | #####################Change rotation_params and delete labelled line
import sys
sys.path[:0]=['/Change/This/Path']
from ASOT_Functions_Python import *
rlsfl=7.000e+10
rrsfl=7.020e+10
rcsfl=7.010e+10
krsfl=0.0
vrsfl=0.0
rotation_params=[
# tlsfl trsfl tcsfl ktsfl vtsfl plsfl prsfl pcsfl kpsfl vpsfl tilsfl tirsfl ticsfl ktisfl
[ 0.319, 0.364, 0.342, +4.00e+01, -2.50e+05, 0.636, 0.681, -0.101, +4.00e+01, +2.50e+05, 0.0e+3, 8.0e+3, 0.0e+3, 4.0],
[ 0.339, 0.383, 0.361, +4.00e+01, +2.50e+05, 0.617, 0.661, -0.098, +4.00e+01, -2.50e+05, 1.0e+3, 9.0e+3, 1.0e+3, 4.0],
[ 0.334, 0.378, 0.356, +4.00e+01, +2.50e+05, 0.622, 0.666, -0.065, +4.00e+01, -2.50e+05, 0.0e+3, 8.0e+3, 0.0e+3, 4.0],
[ 0.337, 0.381, 0.359, +4.00e+01, -2.50e+05, 0.619, 0.663, -0.043, +4.00e+01, +2.50e+05, 0.5e+3, 8.5e+3, 0.5e+3, 4.0],
[ 0.352, 0.397, 0.375, +4.00e+01, -1.50e+05, 0.603, 0.648, -0.020, +4.00e+01, +1.50e+05, 0.8e+3, 8.8e+3, 0.8e+3, 4.0],
[ 0.372, 0.417, 0.395, +4.00e+01, +1.50e+05, 0.583, 0.628, -0.022, +4.00e+01, -1.50e+05, 1.2e+3, 9.2e+3, 1.2e+3, 4.0],
[ 0.383, 0.428, 0.406, +4.00e+01, -2.00e+05, 0.572, 0.617, -0.062, +4.00e+01, +2.00e+05, 0.2e+3, 8.2e+3, 0.2e+3, 4.0],
[ 0.374, 0.418, 0.396, +4.00e+01, +2.00e+05, 0.582, 0.626, 0.030, +4.00e+01, -2.00e+05, 0.0e+3, 8.0e+3, 0.0e+3, 4.0],
[ 0.386, 0.430, 0.408, +4.00e+01, +2.50e+05, 0.570, 0.614, -0.082, +4.00e+01, -2.50e+05, 0.1e+3, 8.1e+3, 0.1e+3, 4.0],
[ 0.417, 0.461, 0.439, +4.00e+01, -2.50e+05, 0.539, 0.583, -0.087, +4.00e+01, +2.50e+05, 1.3e+3, 9.3e+3, 1.3e+3, 4.0],
[ 0.427, 0.472, 0.449, +4.00e+01, -2.00e+05, 0.528, 0.573, -0.072, +4.00e+01, +2.00e+05, 0.0e+3, 8.0e+3, 0.0e+3, 4.0],
[ 0.432, 0.477, 0.455, +4.00e+01, +2.00e+05, 0.523, 0.568, -0.049, +4.00e+01, -2.00e+05, 0.0e+3, 8.0e+3, 0.0e+3, 4.0],
[ 0.425, 0.470, 0.448, +4.00e+01, -1.00e+05, 0.530, 0.575, -0.010, +4.00e+01, +1.00e+05, 0.7e+3, 8.7e+3, 0.7e+3, 4.0],
[ 0.376, 0.420, 0.398, +4.00e+01, +1.00e+05, 0.580, 0.624, 0.174, +4.00e+01, -1.00e+05, 0.3e+3, 8.3e+3, 0.3e+3, 4.0],
[ 0.364, 0.409, 0.387, +4.00e+01, -2.50e+05, 0.591, 0.636, 0.123, +4.00e+01, +2.50e+05, 0.2e+3, 8.2e+3, 0.2e+3, 4.0],
[ 0.395, 0.440, 0.417, +4.00e+01, +2.50e+05, 0.560, 0.605, 0.099, +4.00e+01, -2.50e+05, 0.5e+3, 8.5e+3, 0.5e+3, 4.0],
[ 0.395, 0.439, 0.417, +4.00e+01, +2.50e+05, 0.561, 0.605, 0.036, +4.00e+01, -2.50e+05, 1.0e+3, 9.0e+3, 1.0e+3, 4.0],
[ 0.358, 0.403, 0.381, +4.00e+01, -2.50e+05, 0.597, 0.642, 0.035, +4.00e+01, +2.50e+05, 0.0e+3, 8.0e+3, 0.0e+3, 4.0]]
print("% Flow Options")
print("")
print("")
print("Separable Boundary Flow")
print("Radial Left")
print("No Bn Diffusion")
print("Time Uniform")
print("")
for idx in range(len(rotation_params)):
print("Separable Boundary Flow")
print("Radial Left")
print("Theta Csc Theta")
print("Theta Gauss Theta")
print("Theta DGauss Phi")
print("Phi DGauss Theta")
print("Phi Gauss Phi")
print("No Bn Diffusion")
print("Time Cos")
print("")
print("")
print("% Flow Data")
print("")
print(" nsflow")
print(str(len(rotation_params)+1).rjust(10))
print(" rlsfl rrsfl rcsfl krsfl vrsfl")
print(" 7.000e+10 7.020e+10 7.010e+10 0.0 0.0")
print(" tlsfl trsfl tcsfl ktsfl vtsfl")
print(" 0.0 1.0 0.5 0.0 0.0")
print(" plsfl prsfl pcsfl kpsfl vpsfl")
print(" -1.0 1.0 1.0 0.0 0.0")
print(" tilsfl tirsfl ticsfl ktisfl")
print(" 0.0e+4 1.0e+6 0.0e+4 0.0")
for idx in range(len(rotation_params)):
print(" rlsfl rrsfl rcsfl krsfl vrsfl")
print("{:.3e}".format(rlsfl).rjust(10)+"{:.3e}".format(rrsfl).rjust(13)+"{:.3e}".format(rcsfl).rjust(12)+str(krsfl).rjust(9)+str(vrsfl).rjust(10))
print(" tlsfl trsfl tcsfl ktsfl vtsfl")
print("{:.3f}".format(rotation_params[idx][0]).rjust(10)+"{:.3f}".format(rotation_params[idx][1]).rjust(13)+"{:.3f}".format(rotation_params[idx][2]).rjust(12)+"{:.3f}".format(rotation_params[idx][3]).rjust(9)+"{:.1e}".format(rotation_params[idx][4]).rjust(10))
print(" plsfl prsfl pcsfl kpsfl vpsfl")
#print("{:.3f}".format(rotation_params[idx][5]).rjust(10)+"{:.3f}".format(rotation_params[idx][6]).rjust(13)+"{:.3f}".format(rotation_params[idx][7]).rjust(12)+"{:.3f}".format(rotation_params[idx][8]).rjust(9)+"{:.1e}".format(rotation_params[idx][9]).rjust(10))
#Delete the next line!!!
print("{:.3f}".format(rotation_params[idx][7]-0.023).rjust(10)+"{:.3f}".format(rotation_params[idx][7]+0.023).rjust(13)+"{:.3f}".format(rotation_params[idx][7]).rjust(12)+"{:.3f}".format(rotation_params[idx][8]).rjust(9)+"{:.1e}".format(rotation_params[idx][9]).rjust(10))
print(" tilsfl tirsfl ticsfl ktisfl")
print("{:.3e}".format(rotation_params[idx][10]).rjust(10)+"{:.3e}".format(rotation_params[idx][11]).rjust(13)+"{:.3e}".format(rotation_params[idx][12]).rjust(12)+"{:.3f}".format(rotation_params[idx][13]).rjust(9))
| 62.25 | 273 | 0.500262 | 1,050 | 5,727 | 2.70381 | 0.18 | 0.050722 | 0.076083 | 0.069038 | 0.636492 | 0.581895 | 0.514266 | 0.27087 | 0.215569 | 0.180697 | 0 | 0.274959 | 0.260171 | 5,727 | 91 | 274 | 62.934066 | 0.395091 | 0.086258 | 0 | 0.323529 | 0 | 0.014706 | 0.1869 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.029412 | 0 | 0.029412 | 0.573529 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
723d1c1043b812ccaa4e0db2fecf106f233a51e4 | 207 | py | Python | scam/exceptions.py | andreysorokin/scam-net | 13b6d2c474ece6e2d833c496d31b9e6e1022cf07 | [
"Apache-2.0"
] | 9 | 2019-12-09T09:09:32.000Z | 2021-06-29T21:50:00.000Z | scam/exceptions.py | andreysorokin/scam-net | 13b6d2c474ece6e2d833c496d31b9e6e1022cf07 | [
"Apache-2.0"
] | 1 | 2021-04-14T07:17:33.000Z | 2021-04-14T07:17:33.000Z | scam/exceptions.py | andreysorokin/scam-net | 13b6d2c474ece6e2d833c496d31b9e6e1022cf07 | [
"Apache-2.0"
] | 3 | 2020-04-04T05:54:51.000Z | 2020-12-20T11:38:42.000Z | class InvalidState(ValueError):
def __init__(self, message, *args):
self.message = message # without this you may get DeprecationWarning
super(InvalidState, self).__init__(message, *args) | 51.75 | 76 | 0.719807 | 23 | 207 | 6.130435 | 0.652174 | 0.156028 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.183575 | 207 | 4 | 77 | 51.75 | 0.83432 | 0.207729 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
7250700387ce9ec00830097c4a3a72c8de0e611b | 145 | py | Python | file.py | alexhong121/py_pt | 78f11f2a2fed54154017371a97de563a8fffcd81 | [
"MIT"
] | null | null | null | file.py | alexhong121/py_pt | 78f11f2a2fed54154017371a97de563a8fffcd81 | [
"MIT"
] | null | null | null | file.py | alexhong121/py_pt | 78f11f2a2fed54154017371a97de563a8fffcd81 | [
"MIT"
] | null | null | null | fout=open('oops.txt','wt')
print('oops, i created a file',file=fout)
fout.close()
fin=open('oops.txt','rt')
po=fin.read()
fin.close()
print(po) | 16.111111 | 41 | 0.662069 | 27 | 145 | 3.555556 | 0.555556 | 0.166667 | 0.229167 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.082759 | 145 | 9 | 42 | 16.111111 | 0.721805 | 0 | 0 | 0 | 0 | 0 | 0.287671 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.285714 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a0dbcdaf837737f3803fab73212404dda3050bc5 | 236 | py | Python | ParseBfield.py | Valentin-Aslanyan/ASOT | 9d1fbe9c28b366085b25c852e0179cd543bd5146 | [
"MIT"
] | null | null | null | ParseBfield.py | Valentin-Aslanyan/ASOT | 9d1fbe9c28b366085b25c852e0179cd543bd5146 | [
"MIT"
] | null | null | null | ParseBfield.py | Valentin-Aslanyan/ASOT | 9d1fbe9c28b366085b25c852e0179cd543bd5146 | [
"MIT"
] | null | null | null |
file_directory="./"
bfield_file="bfield.0057883"
import sys
sys.path[:0]=['/Change/This/Path']
from ASOT_Functions_Python import *
time,ntblks,nlblks,coord_logR,coord_theta,coord_phi,B=read_bfield_file(file_directory,bfield_file)
| 18.153846 | 98 | 0.79661 | 36 | 236 | 4.916667 | 0.638889 | 0.169492 | 0.214689 | 0.259887 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.036364 | 0.067797 | 236 | 12 | 99 | 19.666667 | 0.768182 | 0 | 0 | 0 | 0 | 0 | 0.141026 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
a0e94db008bf2193826b10850034fca2e3a3e229 | 221 | py | Python | 0x03-python-data_structures/6-print_matrix_integer.py | Dev-Loup/holbertonschool-higher_level_programming | af6fe9a05c87dcdbb88270eec4c7ec81d6a70d9b | [
"FSFAP"
] | null | null | null | 0x03-python-data_structures/6-print_matrix_integer.py | Dev-Loup/holbertonschool-higher_level_programming | af6fe9a05c87dcdbb88270eec4c7ec81d6a70d9b | [
"FSFAP"
] | null | null | null | 0x03-python-data_structures/6-print_matrix_integer.py | Dev-Loup/holbertonschool-higher_level_programming | af6fe9a05c87dcdbb88270eec4c7ec81d6a70d9b | [
"FSFAP"
] | null | null | null | #!/usr/bin/python3
def print_matrix_integer(matrix=[[]]):
for X in matrix:
for Y in X:
print('{:d}'.format(Y), end="")
if Y != X[-1]:
print(' ', end="")
print()
| 24.555556 | 43 | 0.429864 | 28 | 221 | 3.321429 | 0.571429 | 0.193548 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.014286 | 0.366516 | 221 | 8 | 44 | 27.625 | 0.65 | 0.076923 | 0 | 0 | 0 | 0 | 0.024631 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0 | 0 | 0.142857 | 0.571429 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
a0f081d26a8a92268917ba0dcd9be677dcb24d90 | 1,173 | py | Python | src/tests/test_resources.py | null-none/fhir-faker | cf98113bed7d67d3819280d62701e5260f2de986 | [
"MIT"
] | 5 | 2021-12-19T02:56:44.000Z | 2022-03-14T09:28:49.000Z | src/tests/test_resources.py | null-none/fhir-faker | cf98113bed7d67d3819280d62701e5260f2de986 | [
"MIT"
] | null | null | null | src/tests/test_resources.py | null-none/fhir-faker | cf98113bed7d67d3819280d62701e5260f2de986 | [
"MIT"
] | null | null | null | from src.fake import FakeFHIR
class TestResources:
def test_organization(self):
fake = FakeFHIR()
assert "resourceType" in fake.organization().serialize()
assert "name" in fake.organization().serialize()
def test_patient(self):
fake = FakeFHIR()
assert "resourceType" in fake.patient(sex="male").serialize()
assert "name" in fake.patient(sex="male").serialize()
def test_practitioner(self):
fake = FakeFHIR()
assert "resourceType" in fake.practitioner(sex="female").serialize()
assert "name" in fake.practitioner(sex="female").serialize()
def test_appointment(self):
fake = FakeFHIR()
assert "resourceType" in fake.appointment().serialize()
def test_person(self):
fake = FakeFHIR()
assert "resourceType" in fake.person().serialize()
def test_schedule(self):
fake = FakeFHIR()
assert "actor" in fake.schedule().serialize()
def test_slot(self):
fake = FakeFHIR()
assert "status" in fake.slot().serialize()
assert "start" in fake.slot().serialize()
assert "end" in fake.slot().serialize() | 32.583333 | 76 | 0.635124 | 129 | 1,173 | 5.72093 | 0.224806 | 0.097561 | 0.151762 | 0.208672 | 0.559621 | 0.430894 | 0.271003 | 0 | 0 | 0 | 0 | 0 | 0.235294 | 1,173 | 36 | 77 | 32.583333 | 0.822742 | 0 | 0 | 0.25 | 0 | 0 | 0.094549 | 0 | 0 | 0 | 0 | 0 | 0.428571 | 1 | 0.25 | false | 0 | 0.035714 | 0 | 0.321429 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a0fe3e166fac7a1880148dc6b016a9465c2dd02d | 1,440 | py | Python | lib/position.py | ArcosJuan/Get-out-of-my-fucking-maze | ca2cfeaaeecb6c6f583ad647d020f25176170805 | [
"MIT"
] | 2 | 2021-09-09T14:03:40.000Z | 2021-11-03T03:35:55.000Z | lib/position.py | ArcosJuan/Get-out-of-my-fucking-maze | ca2cfeaaeecb6c6f583ad647d020f25176170805 | [
"MIT"
] | null | null | null | lib/position.py | ArcosJuan/Get-out-of-my-fucking-maze | ca2cfeaaeecb6c6f583ad647d020f25176170805 | [
"MIT"
] | null | null | null |
class Position:
""" Coordanates system that uses an 'y' and 'x' notation
to represent unequivocally a specific location that goes
universally for every object.
"""
__slots__ = ('y', 'x')
@staticmethod
def create_collection(first_position: tuple, last_position: tuple):
""" Generates the postions between the passed two position index.
"""
assert type(last_position[0]) == int and type(first_position[0]) == int, \
"'y' must be an int."
assert type(first_position[1]) == int and type(last_position[1]) == int, \
"'x' must be an int."
return [[Position(y, x)
for x in range(first_position[1], last_position[1] + 1)]
for y in range(first_position[0], last_position[0] + 1)]
def __init__(self, y:int, x:int):
self.y = y
self.x = x
def get_index(self):
return (self.y, self.x)
def __hash__(self): return hash((self.y, self.x))
def __repr__(self): return f"({self.y}, {self.x})"
def __getitem__(self, i): return list(self.get_index())[i]
def __eq__(self, other):
""" Uses the get_index method to equalize
both instannces of position
"""
try:
other_get_index = other.get_index
except AttributeError:
return False
return self.get_index() == other_get_index()
| 25.714286 | 82 | 0.578472 | 188 | 1,440 | 4.196809 | 0.356383 | 0.070976 | 0.030418 | 0.038023 | 0.102662 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00997 | 0.303472 | 1,440 | 55 | 83 | 26.181818 | 0.77667 | 0.1875 | 0 | 0 | 0 | 0 | 0.054645 | 0 | 0 | 0 | 0 | 0 | 0.08 | 1 | 0.28 | false | 0 | 0 | 0.16 | 0.52 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
9d18542866f3c84f2c8f900b16b9d01351759796 | 516 | py | Python | ois_api_client/v3_0/dto/UserHeader.py | peterkulik/ois_api_client | 51dabcc9f920f89982c4419bb058f5a88193cee0 | [
"MIT"
] | 7 | 2020-10-22T08:15:29.000Z | 2022-01-27T07:59:39.000Z | ois_api_client/v3_0/dto/UserHeader.py | peterkulik/ois_api_client | 51dabcc9f920f89982c4419bb058f5a88193cee0 | [
"MIT"
] | null | null | null | ois_api_client/v3_0/dto/UserHeader.py | peterkulik/ois_api_client | 51dabcc9f920f89982c4419bb058f5a88193cee0 | [
"MIT"
] | null | null | null | from dataclasses import dataclass
from .Crypto import Crypto
@dataclass
class UserHeader:
"""Authentication data of the request
:param login: Login name of the technical user
:param password_hash: Hash value of the technical user's password
:param tax_number: The taxpayer's tax number, whose name the technical user operates in
:param request_signature: Hash value of the request's signature
"""
login: str
password_hash: Crypto
tax_number: str
request_signature: Crypto
| 27.157895 | 91 | 0.744186 | 71 | 516 | 5.323944 | 0.408451 | 0.05291 | 0.126984 | 0.095238 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.207364 | 516 | 18 | 92 | 28.666667 | 0.924205 | 0.581395 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.125 | 0.25 | 0 | 0.875 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
9d2818031ba95a7a4ce4939fe3e5923a7ff3fb6b | 412 | py | Python | backend/apps/cat/api/serializers.py | ambient-innovation/workshop-django | 3105f6684097a4443919edc0ac300f64937a1371 | [
"MIT"
] | null | null | null | backend/apps/cat/api/serializers.py | ambient-innovation/workshop-django | 3105f6684097a4443919edc0ac300f64937a1371 | [
"MIT"
] | null | null | null | backend/apps/cat/api/serializers.py | ambient-innovation/workshop-django | 3105f6684097a4443919edc0ac300f64937a1371 | [
"MIT"
] | null | null | null | from rest_framework import serializers
from apps.cat.models import Cat, Food
class FoodSerializer(serializers.ModelSerializer):
class Meta:
model = Food
fields = [
'id',
'name',
]
class CatSerializer(serializers.ModelSerializer):
class Meta:
model = Cat
fields = [
'id',
'name',
'colour',
]
| 17.913043 | 50 | 0.531553 | 35 | 412 | 6.228571 | 0.542857 | 0.238532 | 0.284404 | 0.321101 | 0.366972 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.381068 | 412 | 22 | 51 | 18.727273 | 0.854902 | 0 | 0 | 0.470588 | 0 | 0 | 0.043689 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.117647 | 0 | 0.352941 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9d55d4f88228628b0987aaa71b9a16df1c33e498 | 147 | py | Python | clients/db.py | jobdataexchange/competensor | 4565c876a31605deca91dafcb7681c0256b3639a | [
"Apache-2.0"
] | 1 | 2020-01-19T03:40:28.000Z | 2020-01-19T03:40:28.000Z | clients/db.py | jobdataexchange/competensor | 4565c876a31605deca91dafcb7681c0256b3639a | [
"Apache-2.0"
] | null | null | null | clients/db.py | jobdataexchange/competensor | 4565c876a31605deca91dafcb7681c0256b3639a | [
"Apache-2.0"
] | null | null | null | """
Implements a set of ORMs for getting, setting against a database
"""
class RawJobDescriptionClient(object):
raise NotImplementedError | 21 | 68 | 0.755102 | 16 | 147 | 6.9375 | 0.9375 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.176871 | 147 | 7 | 69 | 21 | 0.917355 | 0.435374 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
19ef9637ff30eecd8c109c0e720c095166300a04 | 108 | py | Python | tests/main_test.py | thobianchi/gitlabctl | 3090b7f72ba53a3ce4a8491b7bf7c7410e3e8595 | [
"MIT"
] | 2 | 2020-05-31T10:58:35.000Z | 2021-06-24T10:39:43.000Z | tests/main_test.py | thobianchi/getGitlabEnv | 3090b7f72ba53a3ce4a8491b7bf7c7410e3e8595 | [
"MIT"
] | null | null | null | tests/main_test.py | thobianchi/getGitlabEnv | 3090b7f72ba53a3ce4a8491b7bf7c7410e3e8595 | [
"MIT"
] | 1 | 2021-06-24T10:35:44.000Z | 2021-06-24T10:35:44.000Z | # -*- coding: utf-8 -*-
__author__ = "Thomas Bianchi"
__copyright__ = "Thomas Bianchi"
__license__ = "mit"
| 18 | 32 | 0.675926 | 11 | 108 | 5.545455 | 0.818182 | 0.42623 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010989 | 0.157407 | 108 | 5 | 33 | 21.6 | 0.659341 | 0.194444 | 0 | 0 | 0 | 0 | 0.364706 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
c21582cb2f36cf6e06463c2c44c8c57c2b62403a | 2,490 | py | Python | SimGeneral/MixingModule/python/mix_2018_25ns_ProjectedPileup_PoissonOOTPU_cfi.py | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 852 | 2015-01-11T21:03:51.000Z | 2022-03-25T21:14:00.000Z | SimGeneral/MixingModule/python/mix_2018_25ns_ProjectedPileup_PoissonOOTPU_cfi.py | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 30,371 | 2015-01-02T00:14:40.000Z | 2022-03-31T23:26:05.000Z | SimGeneral/MixingModule/python/mix_2018_25ns_ProjectedPileup_PoissonOOTPU_cfi.py | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 3,240 | 2015-01-02T05:53:18.000Z | 2022-03-31T17:24:21.000Z | import FWCore.ParameterSet.Config as cms
from SimGeneral.MixingModule.mix_probFunction_25ns_PoissonOOTPU_cfi import *
mix.input.nbPileupEvents.probFunctionVariable = cms.vint32(
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98
)
mix.input.nbPileupEvents.probValue = cms.vdouble(
0.00056178559316322207, 0.0007578881923109293, 0.00089840730652213097, 0.0010038191685453057, 0.0011915955692529678,
0.0016831225948408246, 0.0027497191913425922, 0.0045576253905892372, 0.0069810771383345127, 0.0095816180109977722,
0.011853505857288837, 0.013561941683292389, 0.014868909493088722, 0.016164621338248253, 0.017800241708755493,
0.019943427294492722, 0.022553266957402229, 0.02537936344742775, 0.027978429570794106, 0.029862202703952789,
0.030737783759832382, 0.030647184699773788, 0.029888983815908432, 0.028840301558375359, 0.027826078236103058,
0.027054192498326302, 0.026599425822496414, 0.02642328292131424, 0.026400813832879066, 0.026344424113631248,
0.026030091568827629, 0.025283832103013992, 0.024102954193949699, 0.022694429382681847, 0.021359216421842575,
0.020321305841207504, 0.019643651321530342, 0.019244605675339699, 0.018951877951622009, 0.018589355051517487,
0.018086889758706093, 0.017514361068606377, 0.016997335478663445, 0.01660793274641037, 0.016348866745829582,
0.016209937632083893, 0.016200525686144829, 0.016327474266290665, 0.016558451578021049, 0.016807874664664268,
0.016936073079705238, 0.016756467521190643, 0.01605769619345665, 0.014654850587248802, 0.012486033141613007,
0.0097413137555122375, 0.0068911332637071609, 0.0044789197854697704, 0.0028035130817443132, 0.0017981450073421001,
0.0011986247263848782, 0.00078225688776001334, 0.00046188471606001258, 0.0002335387107450515, 9.8074830020777881e-05,
3.36361990775913e-05, 9.325763130618725e-06, 2.0754421257151989e-06, 3.6864730645902455e-07, 5.1980304505150343e-08,
5.7291127397718355e-09, 4.2278064382728076e-10, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0)
| 71.142857 | 121 | 0.735341 | 332 | 2,490 | 5.503012 | 0.590361 | 0.058019 | 0.085386 | 0.111658 | 0.029557 | 0.029557 | 0.029557 | 0.029557 | 0.029557 | 0.029557 | 0 | 0.757083 | 0.135341 | 2,490 | 34 | 122 | 73.235294 | 0.0915 | 0 | 0 | 0.121212 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.060606 | 0 | 0.060606 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
c23c0ff24671fd594b8f4ac078e81f33533b32c5 | 91 | py | Python | math3d_side.py | spencerparkin/pyMath3D | 8a0a5155f7db11a0d4d555d6963faf0bc0ea2b71 | [
"MIT"
] | null | null | null | math3d_side.py | spencerparkin/pyMath3D | 8a0a5155f7db11a0d4d555d6963faf0bc0ea2b71 | [
"MIT"
] | null | null | null | math3d_side.py | spencerparkin/pyMath3D | 8a0a5155f7db11a0d4d555d6963faf0bc0ea2b71 | [
"MIT"
] | 1 | 2021-03-06T05:28:22.000Z | 2021-03-06T05:28:22.000Z | # math3d_side.py
class Side:
NEITHER = 'NEITHER'
BACK = 'BACK'
FRONT = 'FRONT' | 15.166667 | 23 | 0.593407 | 11 | 91 | 4.818182 | 0.636364 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015152 | 0.274725 | 91 | 6 | 24 | 15.166667 | 0.787879 | 0.153846 | 0 | 0 | 0 | 0 | 0.210526 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
c2498db343881ee15b79445f57ef98b9582fa052 | 4,816 | py | Python | apps/nlp/gen_title/text.py | mayi140611/mayiutils | 5340d7bd4590e2a41afd5d02ffc569745d67c866 | [
"Apache-2.0"
] | null | null | null | apps/nlp/gen_title/text.py | mayi140611/mayiutils | 5340d7bd4590e2a41afd5d02ffc569745d67c866 | [
"Apache-2.0"
] | null | null | null | apps/nlp/gen_title/text.py | mayi140611/mayiutils | 5340d7bd4590e2a41afd5d02ffc569745d67c866 | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/python
# encoding: utf-8
"""
@author: Ian
@contact:yongguiluo@hotmail.com
@file: text.py.py
@time: 2019/3/20 14:02
"""
title = '智能金融起锚:文因、数库、通联瞄准的kensho革命'
text = '''2015年9月13日,39岁的鲍捷乘上从硅谷至北京的飞机,开启了他心中的金融梦想。
鲍捷,人工智能博士后,如今他是文因互联公司创始人兼CEO。和鲍捷一样,越来越多的硅谷以及华尔街的金融和科技人才已经踏上了归国创业征程。
在硅谷和华尔街,已涌现出Alphasense、Kensho等智能金融公司。
如今,这些公司已经成长为独角兽。
大数据、算法驱动的人工智能已经进入到金融领域。人工智能有望在金融领域最新爆发。
前段时间,笔者写完了《激荡二十五年:Wind、同花顺、东方财富、大智慧等金融服务商争霸史》、《边缘崛起:雪球、老虎、富途、牛股王等互联网券商的新玩法》,探讨了互联网时代、移动互联网时代创业者们的创想。
人工智能与金融正在融合,这里我们聚焦一下投研领域,后续会向交易、投顾等领域延展。这篇文章将描绘一下Kensho、文因互联、数库科技、通联数据在这个领域的探索和尝试,看看新时代正在掀起的巨浪。
1、Kensho的颠覆式革命
华尔街的Kensho是金融数据分析领域里谁也绕不过的一个独角兽。这家公司获得由高盛领投的6280万美元投资,总融资高达7280万美元。
33岁的Kensho创始人Daniel Nadler预言:在未来十年内,由于Kensho和其他自动化软件,金融行业有三分之一到二分之一的雇员将失业。
2014年,Nadler在哈佛大学学习数学和古希腊文化。大学期间,他在美联储担任访问学者时惊奇地发现,这家全球最具权势的金融监管机构仍然依靠Excel来对经济进行分析。
当时,希腊选举以及整个欧洲的不稳定局面正强烈冲击金融市场。访问期间,Nadler意识到无论是监管者还是银行家,除了翻过去的新闻消息以外,并不能给出什么好的方案。
于是,他和麻省理工学院的好友一起想办法,并借鉴Google的信息处理方法,来分析资本市场,设计出了Kensho软件。
一个典型的工作场景是:早上八点,华尔街的金融分析师冲进办公室,等待即将在8点半公布的劳工统计局月度就业报告。他打开电脑,用Kensho软件搜集劳工部数据。
两分钟之内,一份Kensho自动分析报告便出现在他的电脑屏幕上:一份简明的概览,随后是13份基于以往类似就业报告对投资情况的预测。
金融分析师们再无需检查,因为Kensho提取的这些分析基于来自数十个数据库的成千上万条数据。
Kensho界面与Google相似,由一条简单的黑色搜索框构成。其搜索引擎自动将发生的事件根据抽象特征进行分类。
福布斯报道过运用Kensho的成功案例。例如,英国脱欧期间,交易员成功运用Kensho了解到退欧选举造成当地货币贬值;此外,Kensho还分析了美国总统任期的前100天内股票涨跌情况(见下图):
(图片来源:福布斯)
Kensho在构建金融与万物的关联,并用结构化、数据化的方式去呈现。公司还专门雇佣了一位机器学习专家,而这位专家此前为谷歌研究世界图书馆的大型分类方法。
处理复杂的事件与投资关联,Kensho只需要几分钟。但是在华尔街一个普通的分析师需要几天时间去测算对各类资产的影响。而这些分析师普遍拿着30—40万美元的年薪。
此外,硅谷的创业公司AlphaSense公司已经悄然建成了一个解决专业信息获取和解决信息碎片问题的金融搜索引擎。
AlphaSense的首席执行官Jack Kukko曾是摩根士丹利分析师,这赋予了其强大的金融基因。
AlphaSense可以搜索“研究文献,包括公司提交的文件证明、演示、实时新闻、新闻报道、华尔街的投资研究、以及客户的内部内容。”
AlphaSense几秒钟内即可搜索数百万个不同的财务文档, 公司内部纰漏内容和卖方研究等,使用户可以快速发现关键数据点,并通过智能提醒、跟踪重要信息点、防止数据遗漏,做出关键的决策。
AlphaSense目前已经向包括摩根大通等投资和咨询公司、全球银行、律师事务所和公司(如甲骨文)等500余位客户提供服务。
2、海归博士的智能金融实验
2017年6月,在北京朝阳区的一个居民楼的办公室内,鲍捷和他的20名创业伙伴正在摸索打造一款智能金融分析工具,而他的目标正是华尔街的AlphaSense和Kensho。
41岁的鲍捷很享受创业,他说在中国这是最好的创业时代。在此之前,他有一段漫长的求学历程。
鲍捷是一个信息整理控,他从小学开始整理所有的历史人物、水文地理、卡通人物的关系等。合肥工业大学研究生阶段,他师从德国斯图加特大学归来的博士高隽,学习人工智能,深度研究神经网络。
2001年,他离开中国进入美国,先后为Lowa State Univ博士、RPI博士后、MIT访问研究员、BBN访问研究员,在美国完成了11年人工智能的学习和研究。他先后师从语义网创始人Jim Hendler和万维网发明人、图灵奖得主Tim Berners-Lee,参与了语义网学科形成期间的一些关键研究项目,并是知识图谱国际标准OWL的作者之一。
2013年,在三星研究院工作不到两年后,他开始了在硅谷的创业,研发了一款名为“好东西传送门”的产品。
该产品主要利用机器人程序在网站抓取人工智能、机器学习、大数据的最新技术资讯,利用专业领域知识过滤后,自动生产内容,传送至需要的人。
好东西传送门获取了数万铁粉,但无法盈利。2015年9月,他离开硅谷飞往北京,归国的第一天,便获得了无量资本100万美元的天使轮融资。他在中国创立了“文因互联”。
其实鲍捷很早就看到了人工智能和金融结合的前景。在2010年,他就提出了金融报表语言XBRL的语义模型。2015年底,他看到了Kensho在金融领域带来的革命,结合国内的投资需求,他选择了在新三板领域开始切入,当时只有7名员工,经过半年研发,文因在2016年5月推出了“快报”和“搜索”。
“快报”能够自动抓取每日公告、财报、新闻资讯等;而“搜索”能够自动提取产业链上下游公司、结构化财报等各类数据。
“这两款产品为我们获取了1万铁粉,虽然产品有很多缺陷,但是依旧很多人喜欢这个工具,因为以前没有能够满足这种需求的服务。”鲍捷向华尔街见闻表示。
但是他们发现做搜索需要庞大的知识架构,需要去集成各种金融相关数据,开发公司标签、产业标签、产业链等复杂的知识图谱,而做这个体系,再烧几亿,可能也无法完成。
更为恐怖的是,做完产品还要和金融信息服务商竞争。Wind、同花顺、东方财富,挡在了文因互联面前。
“我放弃了从头到尾设计一个大系统的想法,而是从具体场景出发解决单点问题。从年底开始我分了一部分人去做项目,但每一个项目都是我们大系统里面的一个组件,这个项目根据金融客户的真实需求去打磨,然后将这些组件整合为一个系统的产品。”鲍捷反思道,创业需要寻找用户最痛的点,然后扎下去解决问题。
经过一年的创业,鲍捷变得更接地气。去年下半年以来,他密集地拜访各大银行、基金、保险、券商,根据金融机构的需求,在标准化产品之上定制化,从具体业务的自动化出发走向智能化。
目前恒丰银行、南京银行、中债资信等均已成为文因互联的合作客户。
文因互联很快根据金融机构的需求开发出了公告摘要、自动化报告、财报结构化数据等多个软件产品,并开发出了投研小机器人。
2016年年底,文因互联再次获得睿鲸资本Pre-A轮融资。而这位睿鲸资本的投资人,曾经是鲍捷的网友,他们经常在一起讨论人工智能问题。
鲍捷举例说,深市、沪市、新三板加在一起每天平均大概3000-4000份公告,每天处理公告数据提取和摘要,这是一件非常繁琐的事情。很多金融机构要养20多人处理公告,而且这些人还不能快速高效准确地处理。这类事情机器做最适合。给机器程序输入金融知识,并通过模型训练,能够快速准确地提取各项公告摘要和年报摘要。
鲍捷表示,文因互联长远目标是Kensho,用人工智能提升金融投研效率和渠道效率,而这还有很长的路要走。
3、中国式创新距离Kensho有多远?
上海的另外一位海归,也选择在金融研投领域创业,他叫刘彦,已经归国创业了八年。
八年前,他创立的数库科技,如今获得了京东金融1000万美元的投资。
2003年,23岁的他从密歇根商学院毕业,进入华尔街瑞信公司,一年后他主动调到香港分公司。 5年里,他主导完成了建设银行、工商银行、太平洋保险等大公司的上市项目。
华尔街2008年的金融危机波及全球,人性的贪婪和恐惧暴露无遗。在刘彦眼里,从数据层面到决策层面,每一个环节都充斥着被加工过的信息。2009年,他选择回到上海创业。刘彦最初的野心很大,想构建中国的彭博终端,他花费两年的时间构建完成“半结构化数据”。
2011年,数库获得穆迪资本500万美元投资。很快,原公司从70人扩张到140人。但因数库的战略计划并未完成,穆迪资本放弃进一步投资,他和联合创始人沈鑫卖掉房子,继续维持运营。
刘彦破釜沉舟,公司很快攻克了信息识别系统和精度抓取,并在深度分析等方面取得突破。
数库科技试图覆盖全球上市公司:A股3218家、港股1993家美股4953家、新三板10725家、非上市金融490家、股权交易中心2467家。
目前,数库主要服务于B端金融机构。数库自称核心独家的产品有两款:其一、SAM(Segment Analytics Mapping)行业分析工具。数库是根据上市公司实际披露的产品分项推导出其行业分类,会根据上市公司的定期报告实时做出调整。数库行业分类,分为10个层级,4000个产品节点,帮助投资者快速了解产业竞争环境、系统化对比公司财务及运营数据。其二、产业链的分析工具。数库在行业分析工具SAM的基础上,衍生出的一个分析工具。从产业链条的角度,将上市公司通过产品相互关联,帮助投资人优先布局上下游的投资机会。
刘彦的终极理想是通过科技的发展,使金融从“投机”和“博弈”中逐渐走出来,走向非人为的自动化运行,把专业人士和投资弱势群体之间的距离拉近,使个人拥有机构投资者的能力。
这两年,科技金融成为创投最热的风口。中国的大集团也瞄准了这个产业变革的机会。国内民营巨头万向集团看准了智能金融这个方向。
2011年,万向集团挖来了时任博时基金总经理肖风,担任万向集团副董事长。他迅速构建起庞大的金融帝国:浙商银行、浙商基金、民生人寿、万向财务、通联数据等公司。
2013年12月,注册资本3亿元的通联数据在上海创立,肖峰为创始人兼董事长。
通联数据的野心很庞大,目前员工达到300人,正面与Wind、同花顺、东方财富竞争,并推出了PC和移动端的资产管理业务的一站式服务平台,内容涵盖大数据分析、智能投资研究、量化研究、智能投顾和资产配置管理服务等多个领域。
通联数据认为,自己的核心是有一批高素质的技术人才,同时还有顶级金融人才。
2017年6月6日,恒生电子正式面向金融机构推出最新的人工智能产品:涵盖智能投资、智能资讯、智能投顾、智能客服四大领域。其中一款产品智能小梵可通过强大人机自然交互,提供精准数据提炼及智能资讯分析。
在笔者的走访中,越来越多高科技人才、金融人才进入智能金融投研领域,这个领域已经成为红海。
谁能够乘着人工智能浪潮,成为新一代的金融信息服务终端?
敬请关注后续报道。
'''
| 33.915493 | 255 | 0.876453 | 417 | 4,816 | 10.1247 | 0.968825 | 0.003316 | 0.005211 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.040387 | 0.03343 | 4,816 | 141 | 256 | 34.156028 | 0.86638 | 0.024502 | 0 | 0 | 0 | 0.089552 | 0.993602 | 0.935381 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
df9aa9d5f9804826540f95ed22bd4bc7f5b2270b | 1,213 | py | Python | django-react/venv/Lib/site-packages/knox/certificate/cert_aws.py | alirezaryahi/Movie-Rate | eba38f3d17878b7bc9164828ebefb9a68e22d119 | [
"MIT"
] | 2 | 2020-05-14T20:54:56.000Z | 2021-07-28T21:21:16.000Z | django-react/venv/Lib/site-packages/knox/certificate/cert_aws.py | alirezaryahi/Movie-Rate | eba38f3d17878b7bc9164828ebefb9a68e22d119 | [
"MIT"
] | 4 | 2021-04-18T20:27:02.000Z | 2021-04-18T20:27:11.000Z | django-react/venv/Lib/site-packages/knox/certificate/cert_aws.py | alirezaryahi/Movie-Rate | eba38f3d17878b7bc9164828ebefb9a68e22d119 | [
"MIT"
] | 2 | 2020-11-14T08:58:53.000Z | 2021-06-05T00:04:03.000Z | """
Apache Software License 2.0
Copyright (c) 2020, 8x8, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import re
from dynaconf import settings
from .cert import Cert
class AWSCert(Cert):
"""
AWSCert Class
"""
def __init__(self, common_name: str, arn: str = None):
super().__init__(settings=settings, common_name=common_name)
self._arn = arn
@classmethod
def ARNPATTERN(cls) -> re.Pattern: # noqa: PEP8
return re.compile("arn:aws:acm:\w+:\d+:certificate\/.*") # noqa: PEP8 W605
@property
def arn(self) -> str:
return self._arn
@arn.setter
def arn(self, value) -> None:
if AWSCert.ARNPATTERN().match(value):
self._arn = value
| 25.808511 | 83 | 0.691674 | 174 | 1,213 | 4.741379 | 0.574713 | 0.072727 | 0.021818 | 0.038788 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017782 | 0.211871 | 1,213 | 46 | 84 | 26.369565 | 0.845188 | 0.512778 | 0 | 0 | 0 | 0 | 0.061728 | 0.061728 | 0 | 0 | 0 | 0 | 0 | 1 | 0.235294 | false | 0 | 0.176471 | 0.117647 | 0.588235 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
dfb24d16869518a92fca1363a95c49198873ecf0 | 278 | py | Python | src/rqt_sosvr_controller/setup.py | taherahmadi/IranOpen2017 | 5bbc5a5c679ba4bd282eb733a3ec60cb233549b9 | [
"MIT"
] | 4 | 2018-08-18T15:17:33.000Z | 2019-04-25T22:00:26.000Z | src/rqt_sosvr_controller/setup.py | taherahmadi/IranOpen2017 | 5bbc5a5c679ba4bd282eb733a3ec60cb233549b9 | [
"MIT"
] | null | null | null | src/rqt_sosvr_controller/setup.py | taherahmadi/IranOpen2017 | 5bbc5a5c679ba4bd282eb733a3ec60cb233549b9 | [
"MIT"
] | 2 | 2018-05-06T14:06:11.000Z | 2020-09-11T13:09:28.000Z | from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
# fetch values from package.xml
setup_args = generate_distutils_setup(
packages=['rqt_sosvr_controller'],
package_dir={'': 'src'},
requires=['std_msgs', 'rospy']
)
setup(**setup_args)
| 27.8 | 60 | 0.794964 | 38 | 278 | 5.5 | 0.631579 | 0.162679 | 0.210526 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.082734 | 278 | 9 | 61 | 30.888889 | 0.819608 | 0.104317 | 0 | 0 | 1 | 0 | 0.145749 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
dfc6e6c66234a804521737ff620bc2e00e5e8624 | 122 | py | Python | straintables/Definitions.py | Gab0/linkageMapper | 549b292e5b6ab22e03373483cd27236aa2f635eb | [
"MIT"
] | null | null | null | straintables/Definitions.py | Gab0/linkageMapper | 549b292e5b6ab22e03373483cd27236aa2f635eb | [
"MIT"
] | 1 | 2020-05-03T15:13:07.000Z | 2020-05-04T03:01:59.000Z | straintables/Definitions.py | Gab0/straintables | 549b292e5b6ab22e03373483cd27236aa2f635eb | [
"MIT"
] | null | null | null | #!/bin/python
PrimerTypes = ["ForwardPrimer", "ReversePrimer"]
FastaRegionPrefix = "REGION_"
ClustalCommand = "clustalo"
| 20.333333 | 48 | 0.754098 | 9 | 122 | 10.111111 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.098361 | 122 | 5 | 49 | 24.4 | 0.827273 | 0.098361 | 0 | 0 | 0 | 0 | 0.376147 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
dfcd3092b7160dd4d5ae4f5183c7e13ec42c59fc | 849 | py | Python | oompa/tracking/github/GitHubMetdataStore.py | sjtsp2008/oompa | 2dfdecba192c408c0463da27e0b5859ef9ce3db6 | [
"Apache-2.0"
] | 2 | 2016-02-23T00:58:11.000Z | 2017-06-14T15:39:22.000Z | oompa/tracking/github/GitHubMetdataStore.py | sjtsp2008/oompa | 2dfdecba192c408c0463da27e0b5859ef9ce3db6 | [
"Apache-2.0"
] | 3 | 2015-06-21T11:13:50.000Z | 2015-06-21T13:27:03.000Z | oompa/tracking/github/GitHubMetdataStore.py | sjtsp2008/oompa | 2dfdecba192c408c0463da27e0b5859ef9ce3db6 | [
"Apache-2.0"
] | null | null | null | #
# GitHubMetadataStore.py
#
"""
package oompa.tracking.github
"""
class GitHubMetadataStore:
_kinds = [ "User", "Organization", "Repository" ]
_kinds_lowered = [ kind.lower() for kind in _kinds ]
def __init__(self, config, githubHelper):
self._config = config
self._githubHelper = githubHelper
return
def getEntityMetadata(self, folder):
"""
returns EntityMetadata
"""
raise NotImplementedError
# get
# set
pass
def getGitHubMetadataStore(config):
"""
factory for specific backends
"""
from oompa.tracking.github.FileMetadataStore import FileMetadataStore
# XXX support other backends - esp sqlite
metadataStore = FileMetadataStore(config, self)
return metadataStore
| 16.018868 | 73 | 0.614841 | 69 | 849 | 7.42029 | 0.637681 | 0.050781 | 0.074219 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.303887 | 849 | 52 | 74 | 16.326923 | 0.866328 | 0.18139 | 0 | 0 | 0 | 0 | 0.040373 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.214286 | false | 0.071429 | 0.071429 | 0 | 0.642857 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
dff5c75e48888bdb60bd8201a935c005a760860f | 384 | py | Python | lambdas/_bool.py | orsinium-labs/python-lambda-calculus | 64aa19618a1951d37acc550e4894c1393b977c92 | [
"MIT"
] | 30 | 2020-06-20T04:11:45.000Z | 2022-03-26T15:31:19.000Z | lambdas/_bool.py | orsinium-labs/python-lambda-calculus | 64aa19618a1951d37acc550e4894c1393b977c92 | [
"MIT"
] | null | null | null | lambdas/_bool.py | orsinium-labs/python-lambda-calculus | 64aa19618a1951d37acc550e4894c1393b977c92 | [
"MIT"
] | 5 | 2020-09-23T15:33:17.000Z | 2022-01-16T23:32:28.000Z | IDENTITY = lambda a: a
IF = IDENTITY
# boolean values
TRUE = lambda a: lambda b: a
FALSE = lambda a: lambda b: b
# base boolean operations
OR = lambda a: lambda b: a(TRUE)(b)
AND = lambda a: lambda b: a(b)(FALSE)
NOT = lambda a: a(FALSE)(TRUE)
# additional boolean operations
XOR = lambda a: lambda b: a(b(FALSE)(TRUE))(b(TRUE)(FALSE))
XNOR = lambda a: lambda b: NOT(XOR(a)(b))
| 24 | 60 | 0.666667 | 69 | 384 | 3.710145 | 0.246377 | 0.21875 | 0.304688 | 0.328125 | 0.28125 | 0.164063 | 0.164063 | 0 | 0 | 0 | 0 | 0 | 0.1875 | 384 | 15 | 61 | 25.6 | 0.820513 | 0.177083 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
dfff9141a77d644df47751ef1f32fd29ba8d5551 | 860 | py | Python | Register/migrations/0003_auto_20181202_1711.py | Abdulrahmannaser/Journal | ee10dfe6e3d447087b4de829a4a46af74595b730 | [
"MIT"
] | null | null | null | Register/migrations/0003_auto_20181202_1711.py | Abdulrahmannaser/Journal | ee10dfe6e3d447087b4de829a4a46af74595b730 | [
"MIT"
] | null | null | null | Register/migrations/0003_auto_20181202_1711.py | Abdulrahmannaser/Journal | ee10dfe6e3d447087b4de829a4a46af74595b730 | [
"MIT"
] | 2 | 2020-07-08T00:55:49.000Z | 2020-12-11T04:14:50.000Z | # Generated by Django 2.1.3 on 2018-12-02 15:11
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('Register', '0002_users_picture'),
]
operations = [
migrations.AlterField(
model_name='users',
name='Email',
field=models.CharField(max_length=110),
),
migrations.AlterField(
model_name='users',
name='Name',
field=models.CharField(max_length=50),
),
migrations.AlterField(
model_name='users',
name='Password.html',
field=models.CharField(max_length=50),
),
migrations.AlterField(
model_name='users',
name='Picture',
field=models.CharField(default='None', max_length=110),
),
]
| 25.294118 | 67 | 0.551163 | 83 | 860 | 5.590361 | 0.46988 | 0.172414 | 0.215517 | 0.25 | 0.523707 | 0.461207 | 0.297414 | 0.297414 | 0.297414 | 0.297414 | 0 | 0.05026 | 0.32907 | 860 | 33 | 68 | 26.060606 | 0.753899 | 0.052326 | 0 | 0.518519 | 1 | 0 | 0.097171 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.037037 | 0.037037 | 0 | 0.148148 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a0432e3533cb907d41ae402c4207ba51615dfc6e | 1,284 | py | Python | HackyEaster/he2021/ch29/pwn.py | tbrup/ctf-writeups | dfac11abb3051af657ed3384c3c389c14a40c10e | [
"MIT"
] | null | null | null | HackyEaster/he2021/ch29/pwn.py | tbrup/ctf-writeups | dfac11abb3051af657ed3384c3c389c14a40c10e | [
"MIT"
] | null | null | null | HackyEaster/he2021/ch29/pwn.py | tbrup/ctf-writeups | dfac11abb3051af657ed3384c3c389c14a40c10e | [
"MIT"
] | null | null | null | # from pwn import *
from telnetlib import Telnet
def run(b1, b2):
r = Telnet('46.101.107.117', 2112)
r.read_until(b'> ')
# crafting payload
payload = b'/bin/ls\x00AABBBBBBBBBBCCCCCCCCCCDDEEEEEEEE' + \
bytes([0xc1, 0x07, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00]) + \
bytes([0xbf, 0x07, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00]) + \
b1 + b2 + \
bytes([0xff, 0xff, 0xff, 0x7f, 0x00, 0x00]) + \
bytes([0x20, 0x06, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00]) + \
b'\n'
# bytes([0xcc, 0x07, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00]) + \
r.write(payload)
s = r.read_until(b'\n')
print(hex(int.from_bytes(b1,'little')), b1,b2, s)
try:
with open('payload', 'wb') as payF:
payF.write(payload)
s = r.read_until(b'flag')
print('XXXXX', s)
s = 1 / 0
except EOFError:
pass
except ConnectionResetError:
pass
for b2 in range(0xe1, 0xe2):
for b1 in range(0,256,4):
# print(b1.to_bytes(1,'little'), bytes(b2))
run(b1.to_bytes(1,'little'), b2.to_bytes(1,'little'))
# with open('payload', 'wb') as payF:
# payF.write(payload)
# # r.read_until(b'\033[H\033[J\033[8;0H')
# # log.info('enjoy your shell :)')
# r.interact()
| 27.319149 | 71 | 0.551402 | 182 | 1,284 | 3.846154 | 0.406593 | 0.194286 | 0.205714 | 0.182857 | 0.362857 | 0.317143 | 0.282857 | 0.111429 | 0.111429 | 0 | 0 | 0.168094 | 0.272586 | 1,284 | 46 | 72 | 27.913043 | 0.58137 | 0.219626 | 0 | 0.074074 | 0 | 0 | 0.1 | 0.043434 | 0 | 0 | 0.129293 | 0 | 0 | 1 | 0.037037 | false | 0.074074 | 0.037037 | 0 | 0.074074 | 0.074074 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
a043ed5ac83e700e874d3be94408e2fc2f78c551 | 6,307 | py | Python | src/python_pybind11/test/Spline_TEST.py | srmainwaring/ign-math | ff55578b52b9c42daaea666c3c1205551b07afbb | [
"ECL-2.0",
"Apache-2.0"
] | 43 | 2019-08-21T20:50:05.000Z | 2022-03-27T11:48:25.000Z | src/python_pybind11/test/Spline_TEST.py | srmainwaring/ign-math | ff55578b52b9c42daaea666c3c1205551b07afbb | [
"ECL-2.0",
"Apache-2.0"
] | 277 | 2020-04-16T23:38:50.000Z | 2022-03-31T11:11:58.000Z | src/python_pybind11/test/Spline_TEST.py | srmainwaring/ign-math | ff55578b52b9c42daaea666c3c1205551b07afbb | [
"ECL-2.0",
"Apache-2.0"
] | 48 | 2020-04-15T21:15:43.000Z | 2022-03-14T19:29:04.000Z | # Copyright (C) 2021 Open Source Robotics Foundation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import math
import unittest
from ignition.math import Spline
from ignition.math import Vector3d
class TestSpline(unittest.TestCase):
def test_spline(self):
s = Spline()
s.add_point(Vector3d(0, 0, 0))
self.assertEqual(1, s.point_count())
s.clear()
self.assertEqual(0, s.point_count())
s.add_point(Vector3d(0, 0, 0))
self.assertTrue(s.point(0) == Vector3d(0, 0, 0))
s.add_point(Vector3d(1, 1, 1))
self.assertTrue(s.point(1) == Vector3d(1, 1, 1))
# update_point
self.assertFalse(s.update_point(2, Vector3d(2, 2, 2)))
self.assertTrue(s.update_point(1, Vector3d(2, 2, 2)))
s.auto_calculate(False)
self.assertTrue(s.update_point(0, Vector3d(-1, -1, -1)))
s.auto_calculate(True)
# interpolate
self.assertAlmostEqual(s.interpolate(0.0), Vector3d(-1, -1, -1))
self.assertAlmostEqual(s.interpolate(0.5), Vector3d(0.5, 0.5, 0.5))
self.assertAlmostEqual(s.interpolate(1.0), Vector3d(2, 2, 2))
# interpolate
s.add_point(Vector3d(4, 4, 4))
self.assertAlmostEqual(s.interpolate(1, 0.2),
Vector3d(2.496, 2.496, 2.496))
def test_fixed_tangent(self):
s = Spline()
# add_point
s.auto_calculate(False)
s.add_point(Vector3d(0, 0, 0))
s.add_point(Vector3d(0, 0.5, 0), Vector3d(0, 1, 0))
s.add_point(Vector3d(0.5, 1, 0), Vector3d(1, 0, 0))
s.add_point(Vector3d(1, 1, 0), Vector3d(1, 0, 0))
# update_point
s.update_point(0, Vector3d(0, 0, 0), Vector3d(0, 1, 0))
s.auto_calculate(True)
s.recalc_tangents()
# interpolate
self.assertAlmostEqual(s.interpolate(0, 0.5), Vector3d(0, 0.25, 0))
self.assertAlmostEqual(s.interpolate_tangent(0, 0.5),
Vector3d(0, 0.25, 0))
self.assertAlmostEqual(s.interpolate(1, 0.5),
Vector3d(0.125, 0.875, 0))
self.assertAlmostEqual(s.interpolate(2, 0.5), Vector3d(0.75, 1, 0))
self.assertAlmostEqual(s.interpolate_tangent(2, 0.5),
Vector3d(0.25, 0, 0))
def test_arc_length(self):
s = Spline()
self.assertFalse(math.isfinite(s.arc_length()))
s.add_point(Vector3d(1, 1, 1), Vector3d(1, 1, 1))
self.assertFalse(math.isfinite(s.arc_length(0)))
s.add_point(Vector3d(3, 3, 3), Vector3d(1, 1, 1))
s.add_point(Vector3d(4, 4, 4), Vector3d(1, 1, 1))
self.assertAlmostEqual(s.arc_length(0, 1.0),
3.46410161513775, delta=1e-14)
self.assertAlmostEqual(s.arc_length(), 5.19615242270663, delta=1e-14)
self.assertAlmostEqual(s.arc_length(), s.arc_length(1.0))
self.assertFalse(math.isfinite(s.arc_length(-1.0)))
self.assertFalse(math.isfinite(s.arc_length(4, 0.0)))
def test_tension(self):
s = Spline()
s.tension(0.1)
self.assertAlmostEqual(s.tension(), 0.1)
def test_interpolate(self):
s = Spline()
self.assertFalse(s.interpolate(0, 0.1).is_finite())
s.add_point(Vector3d(0, 0, 0))
self.assertAlmostEqual(s.interpolate(0, 0.1), Vector3d(0, 0, 0))
self.assertFalse(s.interpolate_tangent(0.1).is_finite())
s.add_point(Vector3d(1, 2, 3))
self.assertAlmostEqual(s.interpolate(0, 0.0), s.point(0))
self.assertFalse(s.interpolate(0, -0.1).is_finite())
self.assertAlmostEqual(s.interpolate_tangent(0, 0.0), s.tangent(0))
# Fast and slow call variations
self.assertAlmostEqual(s.interpolate(0, 0.5), Vector3d(0.5, 1.0, 1.5))
self.assertAlmostEqual(s.interpolate(0, 1.0), s.point(1))
self.assertAlmostEqual(s.interpolate_tangent(0, 0.5),
Vector3d(1.25, 2.5, 3.75))
self.assertAlmostEqual(s.interpolate_tangent(0, 1.0), s.tangent(1))
self.assertAlmostEqual(s.interpolate_mth_derivative(2, 0.5),
Vector3d(0, 0, 0))
self.assertAlmostEqual(s.interpolate_mth_derivative(2, 1.0),
Vector3d(-3, -6, -9))
self.assertAlmostEqual(s.interpolate_mth_derivative(3, 0.5),
Vector3d(-6, -12, -18))
self.assertAlmostEqual(s.interpolate_mth_derivative(3, 1.0),
Vector3d(-6, -12, -18))
self.assertAlmostEqual(s.interpolate_mth_derivative(4, 0.5),
Vector3d(0, 0, 0))
self.assertAlmostEqual(s.interpolate_mth_derivative(4, 1.0),
Vector3d(0, 0, 0))
def test_point(self):
s = Spline()
self.assertFalse(s.point(0).is_finite())
def test_tangent(self):
s = Spline()
self.assertFalse(s.tangent(0).is_finite())
s.add_point(Vector3d(0, 0, 0))
self.assertFalse(s.tangent(0).is_finite())
s.add_point(Vector3d(1, 0, 0))
self.assertAlmostEqual(s.tangent(0), Vector3d(0.5, 0, 0))
s.add_point(Vector3d(1, 1, 0), Vector3d(-1, 1, 0))
self.assertAlmostEqual(s.tangent(1), Vector3d(0.5, 0.5, 0))
self.assertAlmostEqual(s.tangent(2), Vector3d(-1, 1, 0))
def test_recalc_tangents(self):
s = Spline()
s.add_point(Vector3d(0, 0, 0))
s.add_point(Vector3d(.4, .4, .4))
s.add_point(Vector3d(0, 0, 0))
s.recalc_tangents()
self.assertAlmostEqual(s.interpolate(0, 0.5), Vector3d(0.2, 0.2, 0.2))
self.assertAlmostEqual(s.interpolate(1, 0.5), Vector3d(0.2, 0.2, 0.2))
if __name__ == '__main__':
unittest.main()
| 37.766467 | 78 | 0.599176 | 893 | 6,307 | 4.136618 | 0.145577 | 0.025988 | 0.184624 | 0.214402 | 0.656199 | 0.551705 | 0.458581 | 0.342177 | 0.283974 | 0.19843 | 0 | 0.091239 | 0.256223 | 6,307 | 166 | 79 | 37.993976 | 0.696227 | 0.107183 | 0 | 0.27027 | 0 | 0 | 0.001425 | 0 | 0 | 0 | 0 | 0 | 0.432432 | 1 | 0.072072 | false | 0 | 0.036036 | 0 | 0.117117 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a0a779ecab8b9a6a6806a92a54c8aa4a01ba5453 | 39 | py | Python | test/completion/import_tree/flow_import.py | mrclary/jedi | 803c3cb271ead297c4fe3ca916b54ed05a623459 | [
"MIT"
] | 4,213 | 2015-01-02T15:43:22.000Z | 2022-03-31T16:15:01.000Z | test/completion/import_tree/flow_import.py | mrclary/jedi | 803c3cb271ead297c4fe3ca916b54ed05a623459 | [
"MIT"
] | 1,392 | 2015-01-02T18:43:39.000Z | 2022-03-27T18:43:59.000Z | test/completion/import_tree/flow_import.py | PeterJCLaw/jedi | 070f191f550990c23220d7f209df076178307cf6 | [
"MIT"
] | 525 | 2015-01-02T19:07:31.000Z | 2022-03-13T02:03:20.000Z | if name:
env = 1
else:
env = 2
| 7.8 | 11 | 0.461538 | 7 | 39 | 2.571429 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.090909 | 0.435897 | 39 | 4 | 12 | 9.75 | 0.727273 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a0c2870db05ee494f743f75532de9acc60a24f71 | 725 | py | Python | lec3.py | RJFeerick/IA241-github | 23127088cf2936aa9ad3dd4c6b4d53382f8ec44d | [
"MIT"
] | null | null | null | lec3.py | RJFeerick/IA241-github | 23127088cf2936aa9ad3dd4c6b4d53382f8ec44d | [
"MIT"
] | null | null | null | lec3.py | RJFeerick/IA241-github | 23127088cf2936aa9ad3dd4c6b4d53382f8ec44d | [
"MIT"
] | null | null | null | '''
lec 3
'''
my_list = [1,2,3,4,5]
print(my_list)
my_nested_list = [1,2,3,my_list]
print(my_nested_list)
my_list [0] = 6
print(my_list)
print(my_list[0])
print(my_list[1])
print(my_list[-1])
print(my_list)
print(my_list[1:3])
print(my_list[:])
x,y = ['a', 'b']
print(x,y)
print(my_list)
my_list.append(7)
print(my_list)
my_list.remove(7)
print(my_list)
my_list.sort()
print(my_list)
my_list.reverse()
print(my_list)
print(my_list + [8,9])
my_list.extend( ['a', 'b'])
print(my_list)
print('a' in my_list)
print('hello\tworld')
print('hello\nworld')
my_letter_list = ['a','a','b','b','c']
print(my_letter_list)
print( set(my_letter_list))
my_unique_letters = set(my_letter_list)
print(my_unique_letters)
| 12.288136 | 39 | 0.685517 | 142 | 725 | 3.21831 | 0.232394 | 0.315098 | 0.36105 | 0.142232 | 0.350109 | 0.275711 | 0.076586 | 0 | 0 | 0 | 0 | 0.031056 | 0.111724 | 725 | 58 | 40 | 12.5 | 0.678571 | 0.006897 | 0 | 0.264706 | 0 | 0 | 0.04782 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.676471 | 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 | 1 | 0 | 3 |
260875952257cea82ab86f78d98e3f65ebd2e2b0 | 85 | py | Python | ABC_B/ABC160_B.py | ryosuke0825/atcoder_python | 185cdbe7db44ecca1aaf357858d16d31ce515ddb | [
"MIT"
] | null | null | null | ABC_B/ABC160_B.py | ryosuke0825/atcoder_python | 185cdbe7db44ecca1aaf357858d16d31ce515ddb | [
"MIT"
] | null | null | null | ABC_B/ABC160_B.py | ryosuke0825/atcoder_python | 185cdbe7db44ecca1aaf357858d16d31ce515ddb | [
"MIT"
] | null | null | null | x = int(input())
ans = 0
ans = (x//500)*1000
x = x % 500
ans += (x//5)*5
print(ans)
| 10.625 | 19 | 0.505882 | 18 | 85 | 2.388889 | 0.5 | 0.186047 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.19697 | 0.223529 | 85 | 7 | 20 | 12.142857 | 0.454545 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.166667 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
26150f1cb1718c8f4dc449fad65c37819904e673 | 1,673 | py | Python | db/util.py | wojtekwrona232/seminar-flask-showcase | 82ebc4f694f90f009bbbd3fb4e14adbaa07e1cb0 | [
"MIT"
] | null | null | null | db/util.py | wojtekwrona232/seminar-flask-showcase | 82ebc4f694f90f009bbbd3fb4e14adbaa07e1cb0 | [
"MIT"
] | null | null | null | db/util.py | wojtekwrona232/seminar-flask-showcase | 82ebc4f694f90f009bbbd3fb4e14adbaa07e1cb0 | [
"MIT"
] | null | null | null | # ****************************************************************************************
# Copyright (c) 2021. Wojciech Wrona *
# ****************************************************************************************
from sqlalchemy import engine
from sqlalchemy.orm import Session, sessionmaker
from sqlalchemy.engine import create_engine
class SQLUtil:
_engine = engine
_session = Session
_connection = engine
_transaction = engine
def __init__(self):
self._create_engine()
self._open_session()
# creates new engine for orm
def _create_engine(self):
string = 'mysql+pymysql://root:@localhost:3306/seminar'
self._engine = create_engine(string)
# return current engine for orm
def get_engine(self):
return self._engine
# creates new session for orm
def _open_session(self):
session = sessionmaker()
session.configure(bind=self._engine)
self._session = session()
def get_session(self):
return self._session
def close_session(self):
self._session.close()
def open_connection(self):
self._connection = self.get_engine().connect()
def get_connection(self):
return self._connection
def close_connection(self):
return self._connection.close()
def transaction(self):
self._transaction = self._connection.begin()
def get_transaction(self):
return self._transaction
def transaction_rollback(self):
return self._transaction.rollback()
def session_rollback(self):
return self._session.rollback()
| 27.42623 | 90 | 0.580395 | 162 | 1,673 | 5.734568 | 0.246914 | 0.07535 | 0.10549 | 0.032293 | 0.073197 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006294 | 0.240287 | 1,673 | 60 | 91 | 27.883333 | 0.724626 | 0.209803 | 0 | 0 | 0 | 0 | 0.03346 | 0.03346 | 0 | 0 | 0 | 0 | 0 | 1 | 0.342105 | false | 0 | 0.078947 | 0.184211 | 0.736842 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
26547ed6328b2601f088172316155186086a7289 | 853 | py | Python | predictionserver/serverhabits/ownershiphabits.py | microprediction/predictionserver | 817243a4c85aac63995ab3a18cfbdcb01bb07bd0 | [
"MIT"
] | 1 | 2020-12-04T17:59:19.000Z | 2020-12-04T17:59:19.000Z | predictionserver/serverhabits/ownershiphabits.py | microprediction/predictionserver | 817243a4c85aac63995ab3a18cfbdcb01bb07bd0 | [
"MIT"
] | null | null | null | predictionserver/serverhabits/ownershiphabits.py | microprediction/predictionserver | 817243a4c85aac63995ab3a18cfbdcb01bb07bd0 | [
"MIT"
] | 1 | 2021-03-05T05:03:36.000Z | 2021-03-05T05:03:36.000Z | from predictionserver.serverhabits.obscurityhabits import ObscurityHabits
# Ownership server has the limited responsibility of tracking the official
# owners of each stream
#
# Terminology:
# - sponsor refers to public identity (code, the shash of the write_key)
# - owner/authority refers to private identity, the write_key
class OwnershipHabits(ObscurityHabits):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def _OWNERSHIP(self):
return self.obscurity() + "ownership" # Official map from name to write_key
def _BLACKLIST(self):
return self.obscurity() + "blacklist" # List of discarded keys
def _NAMES(self):
# Location of redundant set of all stream names (needed for random
# sampling when collecting garbage)
return self.obscurity() + "names"
| 32.807692 | 85 | 0.699883 | 99 | 853 | 5.888889 | 0.575758 | 0.041166 | 0.09777 | 0.078902 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.223916 | 853 | 25 | 86 | 34.12 | 0.880665 | 0.485346 | 0 | 0 | 0 | 0 | 0.053738 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.4 | false | 0 | 0.1 | 0.3 | 0.9 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
2668a61beceb0a1d93085a3077d3f413da33d5e4 | 121 | py | Python | tests/fixtures/test_body_block_content/content_41_expected.py | elifesciences/elife-tools | ee345bf0e6703ef0f7e718355e85730abbdfd117 | [
"MIT"
] | 9 | 2015-04-16T08:13:31.000Z | 2020-05-18T14:03:06.000Z | tests/fixtures/test_body_block_content/content_41_expected.py | elifesciences/elife-tools | ee345bf0e6703ef0f7e718355e85730abbdfd117 | [
"MIT"
] | 310 | 2015-02-11T00:30:09.000Z | 2021-07-14T23:58:50.000Z | tests/fixtures/test_body_block_content/content_41_expected.py | elifesciences/elife-tools | ee345bf0e6703ef0f7e718355e85730abbdfd117 | [
"MIT"
] | 9 | 2015-02-04T01:21:28.000Z | 2021-06-15T12:50:47.000Z | from collections import OrderedDict
expected = OrderedDict([("type", "paragraph"), ("text", "Text <i>more</i> text ")])
| 30.25 | 83 | 0.677686 | 14 | 121 | 5.857143 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.115702 | 121 | 3 | 84 | 40.333333 | 0.766355 | 0 | 0 | 0 | 0 | 0 | 0.322314 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
268ccf683a34d3386e5a2b2f8c5d13e2df8d30e4 | 123 | py | Python | scripts/elasticsearch/delete-index.py | iamprovidence/Lama | d1033a6628afe31285e7bb439de7f14a95f72a0f | [
"MIT"
] | 1 | 2020-03-13T15:28:47.000Z | 2020-03-13T15:28:47.000Z | scripts/elasticsearch/delete-index.py | iamprovidence/Lama | d1033a6628afe31285e7bb439de7f14a95f72a0f | [
"MIT"
] | 75 | 2020-01-05T10:32:10.000Z | 2020-04-23T21:11:10.000Z | scripts/elasticsearch/delete-index.py | iamprovidence/Lama | d1033a6628afe31285e7bb439de7f14a95f72a0f | [
"MIT"
] | 1 | 2020-02-07T20:20:36.000Z | 2020-02-07T20:20:36.000Z | import requests
index_name = input("Enter index name: ")
url = f'http://localhost:9200/{index_name}'
requests.delete(url)
| 20.5 | 43 | 0.739837 | 18 | 123 | 4.944444 | 0.666667 | 0.303371 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.036364 | 0.105691 | 123 | 5 | 44 | 24.6 | 0.772727 | 0 | 0 | 0 | 0 | 0 | 0.422764 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cd044adaa027d9a5d39808092f1ee7ffced3041a | 145 | py | Python | hail/python/hailtop/pipeline/utils.py | 3vivekb/hail | 82c9e0f3ec2154335f91f2219b84c0fb5dbac526 | [
"MIT"
] | null | null | null | hail/python/hailtop/pipeline/utils.py | 3vivekb/hail | 82c9e0f3ec2154335f91f2219b84c0fb5dbac526 | [
"MIT"
] | null | null | null | hail/python/hailtop/pipeline/utils.py | 3vivekb/hail | 82c9e0f3ec2154335f91f2219b84c0fb5dbac526 | [
"MIT"
] | null | null | null |
class PipelineException(Exception):
def __init__(self, msg=''):
self.msg = msg
super(PipelineException, self).__init__(msg)
| 24.166667 | 52 | 0.662069 | 15 | 145 | 5.866667 | 0.533333 | 0.159091 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.213793 | 145 | 5 | 53 | 29 | 0.77193 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cd0bea61ab662a83b684160b16ec1983f176274e | 223 | py | Python | api/serializers.py | kamyabdesign/DRF_Django | 7930ef9ad259c092e16e7ae1885054cef1608415 | [
"Apache-2.0"
] | null | null | null | api/serializers.py | kamyabdesign/DRF_Django | 7930ef9ad259c092e16e7ae1885054cef1608415 | [
"Apache-2.0"
] | null | null | null | api/serializers.py | kamyabdesign/DRF_Django | 7930ef9ad259c092e16e7ae1885054cef1608415 | [
"Apache-2.0"
] | null | null | null | from django.db import models
from rest_framework import serializers
from blog.models import Article
class ArticleSerializer(serializers.ModelSerializer):
class Meta:
model = Article
fields = '__all__'
| 22.3 | 53 | 0.753363 | 25 | 223 | 6.52 | 0.68 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.197309 | 223 | 9 | 54 | 24.777778 | 0.910615 | 0 | 0 | 0 | 0 | 0 | 0.03139 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.428571 | 0 | 0.714286 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
cd110011770d8ed75aee2f23f23a0b2bc6673774 | 25 | py | Python | bindings/pydeck/pydeck/frontend_semver.py | Eo300/deck.gl | 36bc5fe2afaaa99f9164aad379f3f1f82095675a | [
"MIT"
] | 1 | 2020-11-03T21:07:49.000Z | 2020-11-03T21:07:49.000Z | bindings/pydeck/pydeck/frontend_semver.py | Edwson/deck.gl | 36bc5fe2afaaa99f9164aad379f3f1f82095675a | [
"MIT"
] | 1 | 2022-02-14T14:16:55.000Z | 2022-02-14T14:16:55.000Z | bindings/pydeck/pydeck/frontend_semver.py | Edwson/deck.gl | 36bc5fe2afaaa99f9164aad379f3f1f82095675a | [
"MIT"
] | null | null | null | DECKGL_SEMVER = "~8.3.*"
| 12.5 | 24 | 0.6 | 4 | 25 | 3.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.090909 | 0.12 | 25 | 1 | 25 | 25 | 0.545455 | 0 | 0 | 0 | 0 | 0 | 0.24 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cd13928c109f1ce74cf1a3e6b2455af3a004899a | 290 | py | Python | Dataset/Leetcode/valid/4/277.py | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | Dataset/Leetcode/valid/4/277.py | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | Dataset/Leetcode/valid/4/277.py | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | ```class Solution:
def XXX(self, nums1: List[int], nums2: List[int]) -> float:
nums1 = list(sorted(nums1+nums2))
l= len(nums1)
if l%2==0:
ans = (nums1[int(l/2)]+nums1[int(l/2)-1])/2
else:
ans = nums1[int(l/2)]
return ans
| 26.363636 | 63 | 0.489655 | 43 | 290 | 3.302326 | 0.465116 | 0.056338 | 0.190141 | 0.211268 | 0.183099 | 0 | 0 | 0 | 0 | 0 | 0 | 0.082051 | 0.327586 | 290 | 10 | 64 | 29 | 0.646154 | 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 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cd1cf0cd36aa3eea1fe91a9e05e96afb66ce5c4f | 115 | py | Python | pages/urls.py | Tanmoy-Sarkar/Varsity-Management-System | 11bf506d78cf15b11553bd2a971efef9d8272225 | [
"MIT"
] | null | null | null | pages/urls.py | Tanmoy-Sarkar/Varsity-Management-System | 11bf506d78cf15b11553bd2a971efef9d8272225 | [
"MIT"
] | 1 | 2020-06-14T16:51:52.000Z | 2020-06-14T16:51:52.000Z | pages/urls.py | Tanmoy-Sarkar/Varsity-Management-System | 11bf506d78cf15b11553bd2a971efef9d8272225 | [
"MIT"
] | null | null | null | from django.urls import path
from .views import HomePageView
urlpatterns = [
path('',HomePageView,name='home')
] | 19.166667 | 34 | 0.747826 | 14 | 115 | 6.142857 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.130435 | 115 | 6 | 35 | 19.166667 | 0.86 | 0 | 0 | 0 | 0 | 0 | 0.034483 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
cd44af1d63dc43223711c9f9598d19e0501513c3 | 205 | py | Python | expenses/urls.py | aniket1004/covidapi | 7eb8fc2c2aec932590c3ad62f61c1798ddfb96e5 | [
"MIT"
] | null | null | null | expenses/urls.py | aniket1004/covidapi | 7eb8fc2c2aec932590c3ad62f61c1798ddfb96e5 | [
"MIT"
] | null | null | null | expenses/urls.py | aniket1004/covidapi | 7eb8fc2c2aec932590c3ad62f61c1798ddfb96e5 | [
"MIT"
] | null | null | null | from django.urls import path
from . import views
urlpatterns = [
path('',views.ExpenseListAPIView.as_view(),name='expenses'),
path('<int:id>',views.ExpenseDetailAPIView.as_view(),name='expense'),
] | 34.166667 | 73 | 0.721951 | 25 | 205 | 5.84 | 0.64 | 0.082192 | 0.136986 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.102439 | 205 | 6 | 74 | 34.166667 | 0.793478 | 0 | 0 | 0 | 0 | 0 | 0.11165 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
cd6684041bbfbfbdba5d22a66e7a51d078b1eac9 | 258 | py | Python | CursoEmVideo/pythonProject/ex010.py | cassio645/Aprendendo-python | 17a8b5a0e7abc3342d24841ed28093db13d2c130 | [
"MIT"
] | null | null | null | CursoEmVideo/pythonProject/ex010.py | cassio645/Aprendendo-python | 17a8b5a0e7abc3342d24841ed28093db13d2c130 | [
"MIT"
] | null | null | null | CursoEmVideo/pythonProject/ex010.py | cassio645/Aprendendo-python | 17a8b5a0e7abc3342d24841ed28093db13d2c130 | [
"MIT"
] | null | null | null | #conversor de moedas
reais = float(input('Digite o valor em reais: R$ '))
print('R$ {:.2f} equivalem a US$ {:.2f} dolares. Triste :<'.format(reais, (reais/5.74)))
print ('R$ {:.2f} equivalem a € {:.2f} euros. hahaha só piora\n'.format(reais, (reais/6.71)))
| 43 | 93 | 0.635659 | 43 | 258 | 3.837209 | 0.674419 | 0.072727 | 0.09697 | 0.206061 | 0.218182 | 0 | 0 | 0 | 0 | 0 | 0 | 0.044843 | 0.135659 | 258 | 5 | 94 | 51.6 | 0.690583 | 0.073643 | 0 | 0 | 0 | 0 | 0.565401 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.666667 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
cd6b3dd2f6569d114955d8a8ac6c4edefc12b32a | 59 | py | Python | seabreeze/__init__.py | anffray/python-seabreeze | 60569e7b2c0e766d1f00267bb4a752333df4eb77 | [
"MIT"
] | null | null | null | seabreeze/__init__.py | anffray/python-seabreeze | 60569e7b2c0e766d1f00267bb4a752333df4eb77 | [
"MIT"
] | null | null | null | seabreeze/__init__.py | anffray/python-seabreeze | 60569e7b2c0e766d1f00267bb4a752333df4eb77 | [
"MIT"
] | null | null | null |
from seabreeze.backends import use
__version__ = "0.6.0"
| 11.8 | 34 | 0.745763 | 9 | 59 | 4.444444 | 0.888889 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.06 | 0.152542 | 59 | 4 | 35 | 14.75 | 0.74 | 0 | 0 | 0 | 0 | 0 | 0.086207 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
cd75784374550a812b55f5fe45a5accd0159d245 | 430 | py | Python | annotation-portal/backend/annotation/urls.py | precog-iiitd/distracted-driving-snapchat | f972e8e5d38f119a5a075b2f5de30e54e72dbd4a | [
"MIT"
] | null | null | null | annotation-portal/backend/annotation/urls.py | precog-iiitd/distracted-driving-snapchat | f972e8e5d38f119a5a075b2f5de30e54e72dbd4a | [
"MIT"
] | 16 | 2020-02-12T03:03:57.000Z | 2022-03-08T23:05:20.000Z | annotation-portal/backend/annotation/urls.py | precog-iiitd/distracted-driving-snapchat | f972e8e5d38f119a5a075b2f5de30e54e72dbd4a | [
"MIT"
] | 1 | 2020-04-15T09:04:20.000Z | 2020-04-15T09:04:20.000Z | from django.conf.urls import url
from . import views
urlpatterns = [url(r'^$', views.dashboard, name='dashboard'), url(r'^instructions$', views.instructions, name='instructions'), url(r'^understood$', views.understood, name='understood'), url(r'^getContent$', views.sendContent, name='sendContent'), url(r'^submitAnnotation$', views.submitAnnotation, name='submitAnnotation'), url(r'^skip$', views.videoSkip, name='videoSkip'), ]
| 107.5 | 376 | 0.737209 | 51 | 430 | 6.215686 | 0.352941 | 0.07571 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.067442 | 430 | 3 | 377 | 143.333333 | 0.790524 | 0 | 0 | 0 | 0 | 0 | 0.304651 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.666667 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
cd82d423e3892b1828d120e146afbd0d16351ca6 | 857 | py | Python | leetcode/python/535_encode_and_decode_tiny_url.py | VVKot/leetcode-solutions | 7d6e599b223d89a7861929190be715d3b3604fa4 | [
"MIT"
] | 4 | 2019-04-22T11:57:36.000Z | 2019-10-29T09:12:56.000Z | leetcode/python/535_encode_and_decode_tiny_url.py | VVKot/coding-competitions | 7d6e599b223d89a7861929190be715d3b3604fa4 | [
"MIT"
] | null | null | null | leetcode/python/535_encode_and_decode_tiny_url.py | VVKot/coding-competitions | 7d6e599b223d89a7861929190be715d3b3604fa4 | [
"MIT"
] | null | null | null | """
T: O(N)
S: O(N)
We need to only store one mapping using this scheme. Also, the performance of
the encoding method can be treated as O(1) due to the total number of short
URLs being quite large - 62**6.
"""
import random
import string
class Codec:
ALPHABET = string.digits + string.ascii_letters
def __init__(self, url_len=6):
self.url_len = url_len
self.url_map = {}
def encode(self, longUrl: str) -> str:
short_url = self._get_short_url()
while short_url in self.url_map:
short_url = self._get_short_url()
self.url_map[short_url] = longUrl
return short_url
def decode(self, shortUrl: str) -> str:
return self.url_map[shortUrl]
def _get_short_url(self) -> str:
return "".join(
random.choice(self.ALPHABET) for _ in range(self.url_len))
| 24.485714 | 77 | 0.647608 | 131 | 857 | 4.022901 | 0.480916 | 0.121442 | 0.075901 | 0.056926 | 0.140417 | 0.087287 | 0 | 0 | 0 | 0 | 0 | 0.007825 | 0.254376 | 857 | 34 | 78 | 25.205882 | 0.816901 | 0.235706 | 0 | 0.111111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.111111 | 0.111111 | 0.611111 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
cd968c06c4eef11f63497c2c23a79c6328183732 | 69 | py | Python | code/python/array_multi.py | evmorov/ruby-coffeescript | 1c61c5ce351509b210e26feceee6efab0b255442 | [
"MIT"
] | 29 | 2016-06-15T09:19:18.000Z | 2022-03-21T14:34:47.000Z | code/python/array_multi.py | evmorov/ruby-coffeescript | 1c61c5ce351509b210e26feceee6efab0b255442 | [
"MIT"
] | 7 | 2016-06-16T07:02:43.000Z | 2020-01-08T21:12:30.000Z | code/python/array_multi.py | evmorov/ruby-coffeescript | 1c61c5ce351509b210e26feceee6efab0b255442 | [
"MIT"
] | 7 | 2016-06-15T14:57:46.000Z | 2021-12-09T17:57:22.000Z | multi = [['first', 'second'], ['third', 'forth']]
print(multi[1][1])
| 23 | 49 | 0.550725 | 9 | 69 | 4.222222 | 0.777778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032258 | 0.101449 | 69 | 2 | 50 | 34.5 | 0.580645 | 0 | 0 | 0 | 0 | 0 | 0.304348 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
269b4d386fcf6cc858c6938ce2d7fb0e0ed3c93a | 205 | py | Python | env/setup.py | hendrikunger/factorySim | 1f1ccc921a5addcf160e6418eafa4b3db1491b36 | [
"MIT"
] | null | null | null | env/setup.py | hendrikunger/factorySim | 1f1ccc921a5addcf160e6418eafa4b3db1491b36 | [
"MIT"
] | 2 | 2020-03-17T14:27:44.000Z | 2020-03-27T15:03:38.000Z | env/setup.py | hendrikunger/factorySim | 1f1ccc921a5addcf160e6418eafa4b3db1491b36 | [
"MIT"
] | null | null | null | from setuptools import setup
setup(name='local_factorySim',
version='0.2dev0',
packages=['factorySim',],
install_requires=['gym', 'pycairo', 'pandas', 'fabulous', 'Polygon3',]
)
| 22.777778 | 76 | 0.629268 | 20 | 205 | 6.35 | 0.9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.024242 | 0.195122 | 205 | 8 | 77 | 25.625 | 0.745455 | 0 | 0 | 0 | 0 | 0 | 0.317073 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
26a13e91b47d213458bbad76fcd859414ac9c1c7 | 882 | py | Python | tmpNoteIcon.py | jmg1138/tmpnote | eb04ab313307e8ab30300355af334fdde8abd5ca | [
"MIT"
] | 3 | 2017-02-13T23:00:31.000Z | 2020-11-08T21:17:53.000Z | tmpNoteIcon.py | jmg1138/tmpnote | eb04ab313307e8ab30300355af334fdde8abd5ca | [
"MIT"
] | 2 | 2017-11-10T18:33:07.000Z | 2017-11-10T20:36:49.000Z | tmpNoteIcon.py | jmg1138/tmpnote | eb04ab313307e8ab30300355af334fdde8abd5ca | [
"MIT"
] | 2 | 2017-07-24T14:31:56.000Z | 2020-08-16T15:35:46.000Z | # ----------------------------------------------------------------------
# This file was generated by img2py.py
# python img2py.py -i path/to/your/icon.ico myIcon.py
from wx.lib.embeddedimage import PyEmbeddedImage
catalog = {}
index = []
tmpNoteIcon = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAN5J"
"REFUWIXtl8ttRCEMRQ/pZZpwQaxTCts0QglTQZRFPL3cLBg/wXw0b5HR29grY8zlGCMkCiAO"
"tI8jN0+ABEiABEiABEiABEiABEiAFcAa8rZ7oSR6Dd8f5riE7dGids1G7fJp3Ix1Hm58X2LG"
"mh95m2avYnyIxOZYk7wpgHodIliTN9uE+wTUXKpXgIhD3YD8uib2mOEj9vQO/H7fx87ACfg5"
"j/HnqfClvT87Ay4AlFJuWjARRguiyvkEpFHxXMXonk9H3PVQEwS2aAAq0YdXJumO/D9sN8C7"
"7PB34A9CYBEFFqJdwwAAAABJRU5ErkJggg==")
gettmpNoteIconData = tmpNoteIcon.GetData
gettmpNoteIconImage = tmpNoteIcon.GetImage
gettmpNoteIconBitmap = tmpNoteIcon.GetBitmap
gettmpNoteIconIcon = tmpNoteIcon.GetIcon
| 42 | 78 | 0.780045 | 53 | 882 | 12.981132 | 0.849057 | 0.023256 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.069221 | 0.082766 | 882 | 20 | 79 | 44.1 | 0.781211 | 0.180272 | 0 | 0 | 1 | 0 | 0.550765 | 0.550765 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.071429 | 0 | 0.071429 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
26e2f542fc71e18f19c064a02e4f9bd0bbcad500 | 77 | py | Python | test/integration/samples_in/digit_ordering.py | Inveracity/flynt | b975b6f61893d5db1114d68fbb5d212c4e11aeb8 | [
"MIT"
] | 487 | 2019-06-10T17:44:56.000Z | 2022-03-26T01:28:19.000Z | test/integration/samples_in/digit_ordering.py | Inveracity/flynt | b975b6f61893d5db1114d68fbb5d212c4e11aeb8 | [
"MIT"
] | 118 | 2019-07-03T12:26:39.000Z | 2022-03-06T22:40:17.000Z | test/integration/samples_in/digit_ordering.py | Inveracity/flynt | b975b6f61893d5db1114d68fbb5d212c4e11aeb8 | [
"MIT"
] | 25 | 2019-07-10T08:39:58.000Z | 2022-03-03T14:44:15.000Z | log.notice("Search: finished in {0:,} ms.".format(vm.search_time_elapsed_ms)) | 77 | 77 | 0.753247 | 13 | 77 | 4.230769 | 0.846154 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013699 | 0.051948 | 77 | 1 | 77 | 77 | 0.739726 | 0 | 0 | 0 | 0 | 0 | 0.371795 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
26f17145216f78b212ae7241d8b51e5ccbb5dd0b | 446 | py | Python | addons/source-python/plugins/warcraft/items/__init__.py | ThomasVieth/WCS-Remastered | 28aceac73abef8b8839a17680cc046bf4c078169 | [
"MIT"
] | null | null | null | addons/source-python/plugins/warcraft/items/__init__.py | ThomasVieth/WCS-Remastered | 28aceac73abef8b8839a17680cc046bf4c078169 | [
"MIT"
] | null | null | null | addons/source-python/plugins/warcraft/items/__init__.py | ThomasVieth/WCS-Remastered | 28aceac73abef8b8839a17680cc046bf4c078169 | [
"MIT"
] | null | null | null | """
"""
## python imports
from configobj import ConfigObj
from glob import glob
from os.path import dirname, basename, isfile
## warcraft.package imports
from warcraft.item import Item
from warcraft.utility import classproperty
## __all__ declaration
modules = glob(dirname(__file__) + '/*.py')
__all__ = ["ini_items", "load_ini_items"] + list(basename(f)[:-3] for f in modules if isfile(f))
ini_items = None
load_ini_items = None ## TODO | 20.272727 | 96 | 0.737668 | 62 | 446 | 5.016129 | 0.516129 | 0.102894 | 0.07717 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002625 | 0.14574 | 446 | 22 | 97 | 20.272727 | 0.813648 | 0.143498 | 0 | 0 | 0 | 0 | 0.076503 | 0 | 0 | 0 | 0 | 0.045455 | 0 | 1 | 0 | false | 0 | 0.555556 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
f811bbb5706a57525cf2ce743d829e002f2c581e | 233 | py | Python | chapter7/exercises/EG7-09 get_value investigation 2.py | munnep/begin_to_code_with_python | 3ef14d90785526b6b26d262a7627eee73791d7d0 | [
"MIT"
] | null | null | null | chapter7/exercises/EG7-09 get_value investigation 2.py | munnep/begin_to_code_with_python | 3ef14d90785526b6b26d262a7627eee73791d7d0 | [
"MIT"
] | null | null | null | chapter7/exercises/EG7-09 get_value investigation 2.py | munnep/begin_to_code_with_python | 3ef14d90785526b6b26d262a7627eee73791d7d0 | [
"MIT"
] | null | null | null | # EG7-09 get_value investigation 2
def get_value(prompt, value_min, value_max):
return
ride_number=get_value(prompt='Please enter the ride number you want:',value_min=1,value_max=5)
print('You have selected ride:',ride_number)
| 33.285714 | 94 | 0.781116 | 40 | 233 | 4.325 | 0.575 | 0.138728 | 0.16185 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.029126 | 0.11588 | 233 | 6 | 95 | 38.833333 | 0.81068 | 0.137339 | 0 | 0 | 0 | 0 | 0.306533 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0 | 0.25 | 0.5 | 0.25 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
f81247cd71ccc16644b04da026915a4f2afc619e | 416 | py | Python | backEnd/app/api/util/util.py | HenryYDJ/flaskAPI | 9947fbad1050d6ba29c29e365c561689ea3e22d8 | [
"MIT"
] | null | null | null | backEnd/app/api/util/util.py | HenryYDJ/flaskAPI | 9947fbad1050d6ba29c29e365c561689ea3e22d8 | [
"MIT"
] | 14 | 2022-03-27T13:34:58.000Z | 2022-03-31T14:37:19.000Z | backEnd/app/api/util/util.py | HenryYDJ/flaskAPI | 9947fbad1050d6ba29c29e365c561689ea3e22d8 | [
"MIT"
] | null | null | null | from flask import jsonify, request
from app.api import bluePrint
from app.api.auth.auth_utils import jwt_roles_required
from app.utils.utils import Roles
from app.dbUtils.dbUtils import query_validated_user
@bluePrint.route('/util/coverpic', methods=['POST'])
@jwt_roles_required(Roles.ADMIN)
def add_cover_pic():
"""
This API adds a cover picture.
"""
return jsonify(message="Picture added"), 201
| 27.733333 | 54 | 0.762019 | 61 | 416 | 5.04918 | 0.57377 | 0.090909 | 0.064935 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008333 | 0.134615 | 416 | 14 | 55 | 29.714286 | 0.847222 | 0.072115 | 0 | 0 | 0 | 0 | 0.083784 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | true | 0 | 0.555556 | 0 | 0.777778 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
f82fe770d1e9b9781fa0dec070f03ab26799fe0a | 289 | py | Python | www/Python Code/connector.py | GsProjects/ProjectCode | 771d660ad161edccc3f2153e1fdc442e6f2976d3 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | www/Python Code/connector.py | GsProjects/ProjectCode | 771d660ad161edccc3f2153e1fdc442e6f2976d3 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | www/Python Code/connector.py | GsProjects/ProjectCode | 771d660ad161edccc3f2153e1fdc442e6f2976d3 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | import mysql.connector
def create_connection():
cnx2 = mysql.connector.connect(host='gProject.mysql.pythonanywhere-services.com',
user='gProject', password= '_mf698t_',
database='gProject$Lamina')
return cnx2
| 32.111111 | 85 | 0.577855 | 25 | 289 | 6.56 | 0.76 | 0.170732 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02551 | 0.321799 | 289 | 8 | 86 | 36.125 | 0.811224 | 0 | 0 | 0 | 0 | 0 | 0.252595 | 0.145329 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0.166667 | 0.166667 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
f83d90e55e7bf801f522af998ab313ca32af0980 | 1,381 | py | Python | release/data_prepare/baseModel_data_convert.py | plataKwon/KPRN | 248133e37b636ddd56e3c4c21a6a8510ab21e912 | [
"MIT"
] | 258 | 2019-01-22T02:58:17.000Z | 2022-03-31T06:41:15.000Z | release/data_prepare/baseModel_data_convert.py | plataKwon/KPRN | 248133e37b636ddd56e3c4c21a6a8510ab21e912 | [
"MIT"
] | 10 | 2019-02-28T15:18:52.000Z | 2020-12-17T09:20:44.000Z | release/data_prepare/baseModel_data_convert.py | plataKwon/KPRN | 248133e37b636ddd56e3c4c21a6a8510ab21e912 | [
"MIT"
] | 93 | 2019-02-13T01:56:38.000Z | 2022-03-24T03:43:44.000Z | #***********************************************************
#Copyright 2018 eBay Inc.
#Use of this source code is governed by a MIT-style
#license that can be found in the LICENSE file or at
#https://opensource.org/licenses/MIT.
#***********************************************************
# -*- coding:utf-8 -*-
from __future__ import print_function
import codecs
if __name__ == "__main__":
file_writer = codecs.open("data/output/baseModel/baseModel_train.txt", mode="w", encoding="utf-8")
file_reader = codecs.open("data/output/fmg_data/user_song_train.txt", mode="r")
line = file_reader.readline()
while line:
line_list = line.strip().split("\t")
file_writer.write(line_list[0].replace("u", "")+"\t"+line_list[1].replace("s", "")+"\t"+line_list[2]+"\n")
line = file_reader.readline()
file_writer.close()
file_reader.close()
file_writer = codecs.open("data/output/baseModel/baseModel_test.txt", mode="w", encoding="utf-8")
file_reader = codecs.open("data/output/fmg_test_samples_0.0.txt", mode="r")
line = file_reader.readline()
while line:
line_list = line.strip().split("\t")
file_writer.write(
line_list[0].replace("u", "") + "\t" + line_list[1].replace("s", "") + "\t" + line_list[2] + "\n")
line = file_reader.readline()
file_writer.close()
file_reader.close()
| 40.617647 | 114 | 0.597393 | 184 | 1,381 | 4.25 | 0.402174 | 0.102302 | 0.071611 | 0.102302 | 0.705882 | 0.705882 | 0.705882 | 0.705882 | 0.58312 | 0.58312 | 0 | 0.012864 | 0.155684 | 1,381 | 33 | 115 | 41.848485 | 0.657804 | 0.217234 | 0 | 0.545455 | 0 | 0 | 0.185289 | 0.146183 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.090909 | 0 | 0.090909 | 0.045455 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f84a514906675482c94eb99280669c6f15cf45de | 138 | py | Python | decision trees/python/assignment1.py | Manu-Fraile/Machine-Learning | 7428a594b07c23b6b4326ad3f80b11860ac8d507 | [
"MIT"
] | null | null | null | decision trees/python/assignment1.py | Manu-Fraile/Machine-Learning | 7428a594b07c23b6b4326ad3f80b11860ac8d507 | [
"MIT"
] | null | null | null | decision trees/python/assignment1.py | Manu-Fraile/Machine-Learning | 7428a594b07c23b6b4326ad3f80b11860ac8d507 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
import monkdata as m
import dtree as d
t = d.buildTree(m.monk1, m.attributes)
print(d.check(t, m.monk1test)) | 23 | 39 | 0.65942 | 24 | 138 | 3.791667 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.026316 | 0.173913 | 138 | 6 | 40 | 23 | 0.77193 | 0.152174 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0.25 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
f85e0d5253f84878be7cf744f20773137a971b96 | 5,672 | py | Python | wealthbot/client/migrations/0001_initial.py | jliev/wealthbot_chatterbot | f6681da8e5f833990ccd321e166994f31253353f | [
"MIT"
] | 1 | 2019-04-22T07:20:31.000Z | 2019-04-22T07:20:31.000Z | wealthbot/client/migrations/0001_initial.py | jliev/wealthbot_chatterbot | f6681da8e5f833990ccd321e166994f31253353f | [
"MIT"
] | null | null | null | wealthbot/client/migrations/0001_initial.py | jliev/wealthbot_chatterbot | f6681da8e5f833990ccd321e166994f31253353f | [
"MIT"
] | null | null | null | # Generated by Django 2.1.4 on 2019-01-08 06:48
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('user', '0002_auto_20190108_1448'),
]
operations = [
migrations.CreateModel(
name='ClientAdditionalContact',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(blank=True, max_length=255, null=True)),
('last_name', models.CharField(blank=True, max_length=255, null=True)),
('middle_name', models.CharField(blank=True, max_length=255, null=True)),
('street', models.CharField(blank=True, max_length=255, null=True)),
('city', models.CharField(blank=True, max_length=255, null=True)),
('state_id', models.IntegerField(blank=True, default=0, null=True)),
('zip', models.CharField(blank=True, max_length=255, null=True)),
('is_different_address', models.BooleanField(null=True)),
('mailing_street', models.CharField(blank=True, max_length=255, null=True)),
('mailing_city', models.CharField(blank=True, max_length=255, null=True)),
('mailing_state_id', models.IntegerField(blank=True, default=0, null=True)),
('mailing_zip', models.CharField(blank=True, max_length=255, null=True)),
('birth_date', models.DateField(blank=True, null=True)),
('phone_number', models.CharField(blank=True, max_length=255, null=True)),
('dependents', models.SmallIntegerField(blank=True, null=True)),
('ssn_tin', models.CharField(blank=True, max_length=20, null=True)),
('income_source', models.CharField(blank=True, max_length=100, null=True)),
('employer_name', models.CharField(blank=True, max_length=255, null=True)),
('industry', models.CharField(blank=True, max_length=255, null=True)),
('occupation', models.CharField(blank=True, max_length=255, null=True)),
('business_type', models.CharField(blank=True, max_length=255, null=True)),
('employer_address', models.CharField(blank=True, max_length=255, null=True)),
('employment_city', models.CharField(blank=True, max_length=255, null=True)),
('employment_state_id', models.IntegerField(blank=True, default=0, null=True)),
('employment_zip', models.CharField(blank=True, max_length=255, null=True)),
('is_senior_political_figure', models.BooleanField(null=True)),
('senior_spf_name', models.CharField(blank=True, max_length=255, null=True)),
('senior_political_title', models.CharField(blank=True, max_length=255, null=True)),
('senior_account_owner_relationship', models.CharField(blank=True, max_length=255, null=True)),
('senior_country_office', models.CharField(blank=True, max_length=255, null=True)),
('is_publicly_traded_company', models.BooleanField(null=True)),
('publicle_company_name', models.CharField(blank=True, max_length=255, null=True)),
('publicle_address', models.CharField(blank=True, max_length=255, null=True)),
('publicle_city', models.CharField(blank=True, max_length=255, null=True)),
('publicle_state_id', models.IntegerField(blank=True, default=0, null=True)),
('is_broker_security_exchange_person', models.BooleanField(null=True)),
('broker_security_exchange_company_name', models.CharField(blank=True, max_length=255, null=True)),
('broker_security_exchange_compliance_letter', models.CharField(blank=True, max_length=255, null=True)),
('email', models.CharField(blank=True, max_length=255, null=True)),
('type', models.CharField(choices=[('spouse', 'spouse'), ('other', 'other')], max_length=10)),
('relationship', models.CharField(blank=True, max_length=255, null=True)),
('employment_type', models.CharField(blank=True, max_length=50, null=True)),
('marital_status', models.CharField(blank=True, max_length=20, null=True)),
('spouse_first_name', models.CharField(blank=True, max_length=255, null=True)),
('spouse_middle_name', models.CharField(blank=True, max_length=255, null=True)),
('spouse_last_name', models.CharField(blank=True, max_length=255, null=True)),
('spouse_birth_date', models.DateField(blank=True, null=True)),
('client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='user.User')),
],
options={
'db_table': 'client_additional_contacts',
},
),
migrations.CreateModel(
name='ClientSettings',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('stop_tlh_value', models.FloatField(blank=True, null=True)),
('client_type', models.CharField(choices=[('new', 'new'), ('current', 'current')], default='new', max_length=10)),
('client', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='user.User')),
],
options={
'db_table': 'client_settings',
},
),
]
| 65.953488 | 130 | 0.618653 | 637 | 5,672 | 5.318681 | 0.199372 | 0.11098 | 0.206612 | 0.247934 | 0.72255 | 0.698642 | 0.688902 | 0.6768 | 0.652597 | 0.549292 | 0 | 0.032391 | 0.232546 | 5,672 | 85 | 131 | 66.729412 | 0.745922 | 0.007934 | 0 | 0.153846 | 1 | 0 | 0.1696 | 0.059378 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.025641 | 0 | 0.076923 | 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 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f85f856630ecb02e9798220e7898ba83af30ae77 | 121 | py | Python | tasks/common.py | kunxianhuang/mail_handler | 8a84e6eeedf1bfe4083bf49735891eecc12c3848 | [
"MIT"
] | 9 | 2021-04-15T15:04:44.000Z | 2021-11-17T10:05:09.000Z | tasks/common.py | kunxianhuang/mail_handler | 8a84e6eeedf1bfe4083bf49735891eecc12c3848 | [
"MIT"
] | 21 | 2020-05-17T07:59:48.000Z | 2022-03-25T09:11:43.000Z | tasks/common.py | kunxianhuang/mail_handler | 8a84e6eeedf1bfe4083bf49735891eecc12c3848 | [
"MIT"
] | 15 | 2020-05-16T07:02:06.000Z | 2022-03-23T03:42:35.000Z | VENV_PREFIX = "poetry run"
_COMMON_TARGETS = ["mail_handler", "tests"]
COMMON_TARGETS_AS_STR = " ".join(_COMMON_TARGETS)
| 30.25 | 49 | 0.760331 | 16 | 121 | 5.1875 | 0.75 | 0.46988 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.099174 | 121 | 3 | 50 | 40.333333 | 0.761468 | 0 | 0 | 0 | 0 | 0 | 0.231405 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f85fed0d2dcae73e1cbad9310233931ff031fd13 | 530 | py | Python | frappe_notification/frappe_notification/doctype/tests.py | leam-tech/frappe_notification | 79e40f2c541d86d714a0b8d48b87f32b2f85076a | [
"MIT"
] | null | null | null | frappe_notification/frappe_notification/doctype/tests.py | leam-tech/frappe_notification | 79e40f2c541d86d714a0b8d48b87f32b2f85076a | [
"MIT"
] | null | null | null | frappe_notification/frappe_notification/doctype/tests.py | leam-tech/frappe_notification | 79e40f2c541d86d714a0b8d48b87f32b2f85076a | [
"MIT"
] | null | null | null | from .notification_channel.test_notification_channel import TestNotificationChannel
from .notification_client.test_notification_client import TestNotificationClient
from .notification_outbox.test_notification_outbox import TestNotificationOutbox
from .notification_template.test_notification_template import TestNotificationTemplate
def get_frappe_notification_doctype_tests():
return [
TestNotificationChannel,
TestNotificationClient,
TestNotificationOutbox,
TestNotificationTemplate,
]
| 37.857143 | 86 | 0.841509 | 43 | 530 | 10 | 0.418605 | 0.148837 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.126415 | 530 | 13 | 87 | 40.769231 | 0.928726 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | true | 0 | 0.363636 | 0.090909 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
f8a01984a30975c58b5e650ecf3941c4a5504182 | 616 | py | Python | gen.py | ingun37/irradiance | e99f9acf6d86162108df76b66b4dabc06f110a6e | [
"BSD-3-Clause"
] | null | null | null | gen.py | ingun37/irradiance | e99f9acf6d86162108df76b66b4dabc06f110a6e | [
"BSD-3-Clause"
] | null | null | null | gen.py | ingun37/irradiance | e99f9acf6d86162108df76b66b4dabc06f110a6e | [
"BSD-3-Clause"
] | null | null | null | import re
def changeModuleName(str):
return re.sub(r'^module Wasm', r'module Main', str)
def importAsterius(str):
return re.sub(r'^import(.+)$', r'import Asterius.Types\nimport Asterius.ByteString\nimport\1', str, 1, re.MULTILINE)
def uncomment(str):
return re.sub(r'^-- ', '', str, 0, re.MULTILINE)
def comment_out(str):
return re.sub(r'(.+)-- comment out$', r'-- \1', str, 0, re.MULTILINE)
with open("src/Wasm.hs", "r") as src_file:
src = src_file.read()
modified = comment_out(uncomment(changeModuleName(src)))
with open("Wasm.hs", "w") as dst_file:
dst_file.write(modified) | 36.235294 | 120 | 0.659091 | 94 | 616 | 4.255319 | 0.351064 | 0.09 | 0.11 | 0.14 | 0.15 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009597 | 0.154221 | 616 | 17 | 121 | 36.235294 | 0.758157 | 0 | 0 | 0 | 0 | 0 | 0.230146 | 0.082658 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.214286 | 0.285714 | 0.785714 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
f8b113b15c6c2b50c606feb20075157aaaf549e4 | 108 | py | Python | pyrichlet/exceptions.py | cabo40/pyrichlet | 941b84e3fcf3c92de2239767e96ee235ff165adb | [
"Apache-2.0"
] | 13 | 2022-02-13T00:33:47.000Z | 2022-03-08T16:28:27.000Z | pyrichlet/exceptions.py | cabo40/pyrichlet | 941b84e3fcf3c92de2239767e96ee235ff165adb | [
"Apache-2.0"
] | null | null | null | pyrichlet/exceptions.py | cabo40/pyrichlet | 941b84e3fcf3c92de2239767e96ee235ff165adb | [
"Apache-2.0"
] | null | null | null | class NotFittedError(Exception):
"""Exception to raise if class method must be called after fitting."""
| 36 | 74 | 0.75 | 14 | 108 | 5.785714 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.157407 | 108 | 2 | 75 | 54 | 0.89011 | 0.592593 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f8b60861d9ba9a5bea7cf1a914b7c98c951d3a41 | 716 | py | Python | api/serializers.py | fmondaini/car-api | d64ac2923267a4d3b6c9f815d5d9e95d9fb2fb2d | [
"MIT"
] | null | null | null | api/serializers.py | fmondaini/car-api | d64ac2923267a4d3b6c9f815d5d9e95d9fb2fb2d | [
"MIT"
] | null | null | null | api/serializers.py | fmondaini/car-api | d64ac2923267a4d3b6c9f815d5d9e95d9fb2fb2d | [
"MIT"
] | null | null | null | from .models import (
Manufacturer,
CarModel,
Car,
Service,
)
from rest_framework import serializers
class ManufacturerSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Manufacturer
fields = ('name')
class CarModelSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = CarModel
fields = ('name', 'year', 'manufacturer')
class CarSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Car
fields = ('name')
class ServiceSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Service
fields = ('car', 'name', 'description', 'replaced_parts')
| 23.096774 | 69 | 0.682961 | 58 | 716 | 8.396552 | 0.413793 | 0.303901 | 0.344969 | 0.377823 | 0.418891 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.22486 | 716 | 30 | 70 | 23.866667 | 0.877477 | 0 | 0 | 0.26087 | 0 | 0 | 0.083799 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.086957 | 0 | 0.434783 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3e1629424c535ff69df27ccc797f2d5c3ec979ad | 71,019 | py | Python | dlkit/abstract_osid/osid/objects.py | UOC/dlkit | a9d265db67e81b9e0f405457464e762e2c03f769 | [
"MIT"
] | 2 | 2018-02-23T12:16:11.000Z | 2020-10-08T17:54:24.000Z | dlkit/abstract_osid/osid/objects.py | UOC/dlkit | a9d265db67e81b9e0f405457464e762e2c03f769 | [
"MIT"
] | 87 | 2017-04-21T18:57:15.000Z | 2021-12-13T19:43:57.000Z | dlkit/abstract_osid/osid/objects.py | UOC/dlkit | a9d265db67e81b9e0f405457464e762e2c03f769 | [
"MIT"
] | 1 | 2018-03-01T16:44:25.000Z | 2018-03-01T16:44:25.000Z | """Implementations of osid abstract base class objects."""
# pylint: disable=invalid-name
# Method names comply with OSID specification.
# pylint: disable=no-init
# Abstract classes do not define __init__.
# pylint: disable=too-few-public-methods
# Some interfaces are specified as 'markers' and include no methods.
# pylint: disable=too-many-public-methods
# Number of methods are defined in specification
# pylint: disable=too-many-ancestors
# Inheritance defined in specification
# pylint: disable=too-many-arguments
# Argument signature defined in specification.
# pylint: disable=duplicate-code
# All apparent duplicates have been inspected. They aren't.
import abc
class OsidObject:
"""``OsidObject`` is the top level interface for all OSID Objects.
An OSID Object is an object identified by an OSID ``Id`` and may
implements optional interfaces. OSID Objects also contain a display
name and a description. These fields are required but may be used
for a variety of purposes ranging from a primary name and
description of the object to a more user friendly display of various
attributes.
Creation of OSID Objects and the modification of their data is
managed through the associated ``OsidSession`` which removes the
dependency of updating data elements upon object retrieval.The
``OsidManager`` should be used to test if updates are available and
determine what ``PropertyTypes`` are supported. The ``OsidManager``
is also used to create the appropriate ``OsidSession`` for object
creation, updates and deletes.
All ``OsidObjects`` are identified by an immutable ``Id``. An ``Id``
is assigned to an object upon creation of the object and cannot be
changed once assigned.
An ``OsidObject`` may support one or more supplementary records
which are expressed in the form of interfaces. Each record interface
is identified by a Type. A record interface may extend another
record interface where support of the parent record interface is
implied. In this case of interface inheritance, support of the
parent record type may be implied through ``has_record_type()`` and
not explicit in ``getRecordTypes()``.
For example, if recordB extends recordA, typeB is a child of typeA.
If a record implements typeB, than it also implements typeA. An
application that only knows about typeA retrieves recordA. An
application that knows about typeB, retrieves recordB which is the
union of methods specified in typeA and typeB. If an application
requests typeA, it may not attempt to access methods defined in
typeB as they may not exist until explicitly requested. The
mechanics of this polymorphism is defined by the language binder.
One mechanism might be the use of casting.
In addition to the record ``Types,`` OSID Objects also have a genus
``Type``. A genus ``Type`` indicates a classification or kind of the
object where an "is a" relationship exists. The purpose of of the
genus ``Type`` is to avoid the creation of unnecessary record types
that may needlessly complicate an interface hierarchy or introduce
interoperability issues. For example, an OSID object may have a
record ``Type`` of ``Publication`` that defines methods pertinent to
publications, such as an ISBN number. A provider may wish to
distinguish between books and journals without having the need of
new record interfaces. In this case, the genus ``Type`` may be one
of ``Book`` or ``Journal``. While this distinction can aid a search,
these genres should be treated in such a way that do not introduce
interoperability problems.
Like record Types, the genus Types may also exist in an implicit
type hierarchy. An OSID object always has at least one genus. Genus
types should not be confused with subject tagging, which is managed
externally to the object. Unlike record ``Types,`` an object's genus
may be modified. However, once an object's record is created with a
record ``Type,`` it cannot be changed.
Methods that return values are not permitted to return nulls. If a
value is not set, it is indicated in the ``Metadata`` of the update
form.
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_display_name(self):
"""Gets the preferred display name associated with this instance of this OSID object appropriate for display to the user.
:return: the display name
:rtype: ``osid.locale.DisplayText``
*compliance: mandatory -- This method must be implemented.*
*implementation notes*: A display name is a string used for
identifying an object in human terms. A provider may wish to
initialize the display name based on one or more object
attributes. In some cases, the display name may not map to a
specific or significant object attribute but simply be used as a
preferred display name that can be modified. A provider may also
wish to translate the display name into a specific locale using
the Locale service. Some OSIDs define methods for more detailed
naming.
"""
return # osid.locale.DisplayText
display_name = property(fget=get_display_name)
@abc.abstractmethod
def get_description(self):
"""Gets the description associated with this instance of this OSID object.
:return: the description
:rtype: ``osid.locale.DisplayText``
*compliance: mandatory -- This method must be implemented.*
*implementation notes*: A description is a string used for
describing an object in human terms and may not have
significance in the underlying system. A provider may wish to
initialize the description based on one or more object
attributes and/or treat it as an auxiliary piece of data that
can be modified. A provider may also wish to translate the
description into a specific locale using the Locale service.
"""
return # osid.locale.DisplayText
description = property(fget=get_description)
@abc.abstractmethod
def get_genus_type(self):
"""Gets the genus type of this object.
:return: the genus type of this object
:rtype: ``osid.type.Type``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.type.Type
genus_type = property(fget=get_genus_type)
@abc.abstractmethod
def is_of_genus_type(self, genus_type):
"""Tests if this object is of the given genus ``Type``.
The given genus type may be supported by the object through the
type hierarchy.
:param genus_type: a genus type
:type genus_type: ``osid.type.Type``
:return: ``true`` if this object is of the given genus ``Type,`` ``false`` otherwise
:rtype: ``boolean``
:raise: ``NullArgument`` -- ``genus_type`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
class OsidRelationship:
"""A ``Relationship`` associates two OSID objects.
Relationships are transient. They define a date range for which they
are in effect.
Unlike other ``OsidObjects`` that rely on the auxiliary Journaling
OSID to track variance over time, ``OsidRelationships`` introduce a
different concept of time independent from journaling. For example,
in the present, a student was registered in a course and dropped it.
The relationship between the student and the course remains
pertinent, independent of any journaled changes that may have
occurred to either the student or the course.
Once the student has dropped the course, the relationship has
expired such that ``is_effective()`` becomes false. It can be
inferred that during the period of the effective dates, the student
was actively registered in the course. Here is an example:
* T1. September 1: Student registers for course for grades
* T2. September 10: Student drops course
* T3. September 15: Student re-registers for course pass/fail
The relationships are:
T1. R1 {effective, September 1 -> end of term, data=grades}
T2. R1 {ineffective, September 1 -> September 10, data=grades}
T3. R1 {ineffective, September 1 -> September 10, data=grades}
R2 {effective, September 10 -> end of term, data=p/f}
An OSID Provider may also permit dates to be set in the future in
which case the relationship can become automatically become
effective at a future time and later expire. More complex
effectiveness management can be done through other rule-based
services.
OSID Consumer lookups and queries of relationships need to consider
that it may be only effective relationshps are of interest.
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def has_end_reason(self):
"""Tests if a reason this relationship came to an end is known.
:return: ``true`` if an end reason is available, ``false`` otherwise
:rtype: ``boolean``
:raise: ``IllegalState`` -- ``is_effective()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def get_end_reason_id(self):
"""Gets a state ``Id`` indicating why this relationship has ended.
:return: a state ``Id``
:rtype: ``osid.id.Id``
:raise: ``IllegalState`` -- ``has_end_reason()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.id.Id
end_reason_id = property(fget=get_end_reason_id)
@abc.abstractmethod
def get_end_reason(self):
"""Gets a state indicating why this relationship has ended.
:return: a state
:rtype: ``osid.process.State``
:raise: ``IllegalState`` -- ``has_end_reason()`` is ``false``
:raise: ``OperationFailed`` -- unable to complete request
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.process.State
end_reason = property(fget=get_end_reason)
class OsidCatalog:
"""``OsidCatalog`` is the top level interface for all OSID catalog-like objects.
A catalog relates to other OSID objects for the purpose of
organization and federation and almost always are hierarchical. An
example catalog is a ``Repository`` that relates to a collection of
``Assets``.
``OsidCatalogs`` allow for the retrieval of a provider identity and
branding.
Collections visible through an ``OsidCatalog`` may be the output of
a dynamic query or some other rules-based evaluation. The facts
surrounding the evaluation are the ``OsidObjects`` visible to the
``OsidCatalog`` from its position in the federated hierarchy. The
input conditions may satisifed on a service-wide basis using an
``OsidQuery`` or environmental conditions supplied to the services
via a ``Proxy`` .
Often, the selection of an ``OsidCatalog`` in instantiating an
``OsidSession`` provides access to a set of ``OsidObjects`` .
Because the view inside an ``OsidCatalog`` can also be produced
behaviorally using a rules evaluation, the ``Id`` (or well-known
alias) of the ``OsidCatalog`` may be used as an abstract means of
requesting a predefined set of behaviors or data constraints from an
OSID Provider.
The flexibility of interpretation together with its central role in
federation to build a rich and complex service from a set of
individual OSID Providers makes cataloging an essential pattern to
achieve abstraction from implementations in the OSIDs without loss
of functionality. Most OSIDs include a cataloging pattern.
"""
__metaclass__ = abc.ABCMeta
class OsidRule:
"""An ``OsidRule`` identifies an explicit or implicit rule evaluation.
An associated ``Rule`` may be available in cases where the behavior
of the object can be explicitly modified using a defined rule. In
many cases, an ``OsidObject`` may define specific methods to manage
certain common behavioral aspects and delegate anything above and
beyond what has been defined to a rule evaluation.
Rules are defined to be operable. In the case of a statement
evaluation, an enabled rule overrides any evaluation to return
``true`` and a disabled rule overrides any evaluation to return
``false``.
``Rules`` are never required to consume or implement. They serve as
a mechanism to offer a level of management not attainable in the
immediate service definition. Each Rule implies evaluating a set of
facts known to the service to produce a resulting beavior. Rule
evaluations may also accept input data or conditions, however,
``OsidRules`` as they appear in throughout the services may or may
not provide a means of supplying ``OsidConditions`` directly. In the
services where an explicit ``OsidCondition`` is absent they may be
masquerading as another interface such as a ``Proxy`` or an
``OsidQuery`` .
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def has_rule(self):
"""Tests if an explicit rule is available.
:return: ``true`` if an explicit rule is available, ``false`` otherwise
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def get_rule_id(self):
"""Gets the explicit rule ``Id``.
:return: the rule ``Id``
:rtype: ``osid.id.Id``
:raise: ``IllegalState`` -- ``has_rule()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.id.Id
rule_id = property(fget=get_rule_id)
@abc.abstractmethod
def get_rule(self):
"""Gets the explicit rule.
:return: the rule
:rtype: ``osid.rules.Rule``
:raise: ``IllegalState`` -- ``has_rule()`` is ``false``
:raise: ``OperationFailed`` -- unable to complete request
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.rules.Rule
rule = property(fget=get_rule)
class OsidEnabler:
"""``OsidEnabler`` is used to manage the effectiveness, enabledness, or operation of an ``OsidObejct``.
The ``OsidEnabler`` itself is active or inactive When an
``OsidEnabler`` is active, any ``OsidObject`` mapped to it is "on."
When all ``OsidEnablers`` mapped to an ``OsidObject`` are inactive,
then the ``OsidObject`` is "off."
The managed ``OsidObject`` may have varying semantics as to what its
on/off status means and in particular, which methods are used to
indicate the effect of an ``OsidEnabler``. Some axamples:
* ``Operables:`` ``OsidEnablers`` effect the operational status.
* ``Temporals:`` ``OsidEnablers`` may be used to extend or
shorten the effectiveness of a ``Temporal`` such as an
``OsidRelationship.``
In the case where an ``OsidEnabler`` may cause a discontinuity in a
``Temporal,`` the ``OsidEnabler`` may cause the creation of new
``Temporals`` to capture the gap in effectiveness.
For example, An ``OsidRelationship`` that began in 2007 may be
brought to an end in 2008 due to the absence of any active
``OsidEnablers``. When an effective ``OsidEnabler`` appears in 2009,
a new ``OsidRelationship`` is created with a starting effective date
of 2009 leaving the existing ``OsidRelationship`` with effective
dates from 2007 to 2008.
An ``OsidEnabler`` itself is both a ``Temporal`` and an ``OsidRule``
whose activity status of the object may be controlled
administratively, using a span of effective dates, through an
external rule, or all three. The ``OsidEnabler`` defines a set of
canned rules based on dates, events, and cyclic events.
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_effective_by_schedule(self):
"""Tests if the effectiveness of the enabler is governed by a ``Schedule``.
If a schedule exists, it is bounded by the effective dates of
this enabler. If ``is_effective_by_schedule()`` is ``true,``
``is_effective_by_event()`` and
``is_effective_by_cyclic_event()`` must be ``false``.
:return: ``true`` if the enabler is governed by schedule, ``false`` otherwise
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def get_schedule_id(self):
"""Gets the schedule ``Id``.
:return: the schedule ``Id``
:rtype: ``osid.id.Id``
:raise: ``IllegalState`` -- ``is_effective_by_schedule()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.id.Id
schedule_id = property(fget=get_schedule_id)
@abc.abstractmethod
def get_schedule(self):
"""Gets the schedule.
:return: the schedule
:rtype: ``osid.calendaring.Schedule``
:raise: ``IllegalState`` -- ``is_effective_by_schedule()`` is ``false``
:raise: ``OperationFailed`` -- unable to complete request
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.calendaring.Schedule
schedule = property(fget=get_schedule)
@abc.abstractmethod
def is_effective_by_event(self):
"""Tests if the effectiveness of the enabler is governed by an ``Event`` such that the start and end dates of the event govern the effectiveness.
The event may also be a ``RecurringEvent`` in which case the
enabler is effective for start and end dates of each event in
the series If an event exists, it is bounded by the effective
dates of this enabler. If ``is_effective_by_event()`` is
``true,`` ``is_effective_by_schedule()`` and
``is_effective_by_cyclic_event()`` must be ``false``.
:return: ``true`` if the enabler is governed by an event, ``false`` otherwise
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def get_event_id(self):
"""Gets the event ``Id``.
:return: the event ``Id``
:rtype: ``osid.id.Id``
:raise: ``IllegalState`` -- ``is_effective_by_event()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.id.Id
event_id = property(fget=get_event_id)
@abc.abstractmethod
def get_event(self):
"""Gets the event.
:return: the event
:rtype: ``osid.calendaring.Event``
:raise: ``IllegalState`` -- ``is_effective_by_event()`` is ``false``
:raise: ``OperationFailed`` -- unable to complete request
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.calendaring.Event
event = property(fget=get_event)
@abc.abstractmethod
def is_effective_by_cyclic_event(self):
"""Tests if the effectiveness of the enabler is governed by a ``CyclicEvent``.
If a cyclic event exists, it is evaluated by the accompanying
cyclic time period. If ``is_effective_by_cyclic_event()`` is
``true,`` ``is_effective_by_schedule()`` and
``is_effective_by_event()`` must be ``false``.
:return: ``true`` if the enabler is governed by a cyclic event, ``false`` otherwise
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def get_cyclic_event_id(self):
"""Gets the cyclic event ``Id``.
:return: the cyclic event ``Id``
:rtype: ``osid.id.Id``
:raise: ``IllegalState`` -- ``is_effective_by_cyclic_event()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.id.Id
cyclic_event_id = property(fget=get_cyclic_event_id)
@abc.abstractmethod
def get_cyclic_event(self):
"""Gets the cyclic event.
:return: the cyclic event
:rtype: ``osid.calendaring.cycle.CyclicEvent``
:raise: ``IllegalState`` -- ``is_effective_by_cyclic_event()`` is ``false``
:raise: ``OperationFailed`` -- unable to complete request
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.calendaring.cycle.CyclicEvent
cyclic_event = property(fget=get_cyclic_event)
@abc.abstractmethod
def is_effective_for_demographic(self):
"""Tests if the effectiveness of the enabler applies to a demographic resource.
:return: ``true`` if the rule apples to a demographic. ``false`` otherwise
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def get_demographic_id(self):
"""Gets the demographic resource ``Id``.
:return: the resource ``Id``
:rtype: ``osid.id.Id``
:raise: ``IllegalState`` -- ``is_effective_for_demographic()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.id.Id
demographic_id = property(fget=get_demographic_id)
@abc.abstractmethod
def get_demographic(self):
"""Gets the demographic resource.
:return: the resource representing the demographic
:rtype: ``osid.resource.Resource``
:raise: ``IllegalState`` -- ``is_effective_for_demographic()`` is ``false``
:raise: ``OperationFailed`` -- unable to complete request
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.resource.Resource
demographic = property(fget=get_demographic)
class OsidConstrainer:
"""An ``OsidConstrainer`` marks an interface as a control point to constrain another object.
A constrainer may define specific methods to describe the
constrainment or incorporate external logic using a rule.
"""
__metaclass__ = abc.ABCMeta
class OsidProcessor:
"""An ``OsidProcessor`` is an interface describing the operation of another object.
A processor may define specific methods to manage processing, or
incorporate external logic using a rule.
"""
__metaclass__ = abc.ABCMeta
class OsidGovernator:
"""An ``OsidGovernator`` is a control point to govern the behavior of a service.
``OsidGovernators`` generally indicate the presence of
``OsidEnablers`` and other rule governing interfaces to provide a
means of managing service operations and constraints from a "behind
the scenes" perspective. The ``OsidGovernator`` is a focal point for
these various rules.
``OsidGovernators`` are ``Sourceable``. An ``OsidGovernator``
implies a governance that often corresponds to a provider of a
process as opposed to a catalog provider of ``OsidObjects``.
``OsidGovernators`` are ``Operable``. They indicate an active and
operational status and related rules may be administratively
overridden using this control point. Administratively setting the
enabled or disabled flags in the operator overrides any enabling
rule mapped to this ``OsidGovernator``.
"""
__metaclass__ = abc.ABCMeta
class OsidCompendium:
"""``OsidCompendium`` is the top level interface for reports based on measurements, calculations, summaries, or views of transactional activity within periods of time.
This time dimension of this report may align with managed time
periods, specific dates, or both. Oh my.
Reports are often derived dynamically based on an examination of
data managed elsewhere in an OSID. Reports may also be directly
managed outside where it is desirable to capture summaries without
the detail of the implied evaluated data. The behavior of a direct
create or update of a report is not specified but is not limited to
an override or a cascading update of underlying data.
The start and end date represents the date range used in the
evaluation of the transactional data on which this report is based.
The start and end date may be the same indicating that the
evaluation occurred at a point in time rather than across a date
range. The start and end date requested may differ from the start
and end date indicated in this report because of the inability to
interpolate or extrapolate the date. These dates should be examined
to understand what actually occurred and to what dates the
information in this report pertains.
These dates differ from the dates the report itself was requested,
created, or modified. The dates refer to the context of the
evaluation. In a managed report, the dates are simply the dates to
which the report information pertains. The history of a single
report may be examined in the Journaling OSID.
For example, the Location of a Resource at 12:11pm is reported to be
in Longwood and at 12:23pm is reported to be at Chestnut Hill. A
request of a ``ResourceLocation``. A data correction may update the
Longwood time to be 12:09pm. The update of the ``ResourceLocation``
from 12:11pm to 12:09pm may be examined in the Journaling OSID while
the 12:11pm time would not longer be visible in current versions of
this report.
Reports may be indexed by a managed time period such as a ``Term``
or ``FiscalPeriod``. The evaluation dates may map to the opening and
closing dates of the time period. Evaluation dates that differ from
the time period may indicate that the transactional data is
incomplete for that time period or that the report was calculated
using a requested date range.
``OsidCompendiums`` are subjugates to other ``OsidObjects`` in that
what is reported is tied to an instance of a dimension such as a
person, account, or an ``OsidCatalog`` .
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_start_date(self):
"""Gets the start date used in the evaluation of the transactional data on which this report is based.
:return: the date
:rtype: ``osid.calendaring.DateTime``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.calendaring.DateTime
start_date = property(fget=get_start_date)
@abc.abstractmethod
def get_end_date(self):
"""Gets the end date used in the evaluation of the transactional data on which this report is based.
:return: the date
:rtype: ``osid.calendaring.DateTime``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.calendaring.DateTime
end_date = property(fget=get_end_date)
@abc.abstractmethod
def is_interpolated(self):
"""Tests if this report is interpolated within measured data or known transactions.
Interpolation may occur if the start or end date fall between
two known facts or managed time period.
:return: ``true`` if this report is interpolated, ``false`` otherwise
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def is_extrapolated(self):
"""Tests if this report is extrapolated outside measured data or known transactions.
Extrapolation may occur if the start or end date fall outside
two known facts or managed time period. Extrapolation may occur
within a managed time period in progress where the results of
the entire time period are projected.
:return: ``true`` if this report is extrapolated, ``false`` otherwise
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
class OsidCapsule:
"""``OsidCapsule`` wraps other objects.
The interface has no meaning other than to return a set of
semantically unrelated objects from a method.
"""
__metaclass__ = abc.ABCMeta
class OsidForm:
"""The ``OsidForm`` is the vehicle used to create and update objects.
The form is a container for data to be sent to an update or create
method of a session. Applications should persist their own data
until a form is successfully submitted in an update or create
transaction.
The form may provide some feedback as to the validity of certain
data updates before the update transaction is issued to the
correspodning session but a successful modification of the form is
not a guarantee of success for the update transaction. A consumer
may elect to perform all updates within a single update transaction
or break up a large update intio smaller units. The tradeoff is the
granularity of error feedback vs. the performance gain of a single
transaction.
``OsidForms`` are ``Identifiable``. The ``Id`` of the ``OsidForm``
is used to uniquely identify the update or create transaction and
not that of the object being updated. Currently, it is not necessary
to have these ``Ids`` persisted.
As with all aspects of the OSIDs, nulls cannot be used. Methods to
clear values are also defined in the form.
A new ``OsidForm`` should be acquired for each transaction upon an
``OsidObject``. Forms should not be reused from one object to
another even if the supplied data is the same as the forms may
encapsulate data specific to the object requested. Example of
changing a display name and a color defined in a color interface
extension:
ObjectForm form = session.getObjectFormForUpdate(objectId);
form.setDisplayName("new name");
ColorForm recordForm = form.getFormRecord(colorRecordType);
recordForm.setColor("green");
session.updateObject(objectId, form);
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_for_update(self):
"""Tests if this form is for an update operation.
:return: ``true`` if this form is for an update operation, ``false`` if for a create operation
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def get_default_locale(self):
"""Gets a default locale for ``DisplayTexts`` when a locale is not specified.
:return: the default locale
:rtype: ``osid.locale.Locale``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.locale.Locale
default_locale = property(fget=get_default_locale)
@abc.abstractmethod
def get_locales(self):
"""Gets a list of locales for available ``DisplayText`` translations that can be performed using this form.
:return: a list of available locales or an empty list if no translation operations are available
:rtype: ``osid.locale.LocaleList``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.locale.LocaleList
locales = property(fget=get_locales)
@abc.abstractmethod
def set_locale(self, language_type, script_type):
"""Specifies a language and script type for ``DisplayText`` fields in this form.
Setting a locale to something other than the default locale may
affect the ``Metadata`` in this form.
If multiple locales are available for managing translations, the
``Metadata`` indicates the fields are unset as they may be
returning a defeult value based on the default locale.
:param language_type: the language type
:type language_type: ``osid.type.Type``
:param script_type: the script type
:type script_type: ``osid.type.Type``
:raise: ``NullArgument`` -- ``language_type`` or ``script_type`` is null
:raise: ``Unsupported`` -- ``language_type`` and ``script_type`` not available from ``get_locales()``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def get_journal_comment_metadata(self):
"""Gets the metadata for the comment corresponding to this form submission.
The comment is used for describing the nature of the change to
the corresponding object for the purposes of logging and
auditing.
:return: metadata for the comment
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
journal_comment_metadata = property(fget=get_journal_comment_metadata)
@abc.abstractmethod
def set_journal_comment(self, comment):
"""Sets a comment.
:param comment: the new comment
:type comment: ``string``
:raise: ``InvalidArgument`` -- ``comment`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadonly()`` is ``true``
:raise: ``NullArgument`` -- ``comment`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
journal_comment = property(fset=set_journal_comment)
@abc.abstractmethod
def is_valid(self):
"""Tests if ths form is in a valid state for submission.
A form is valid if all required data has been supplied compliant
with any constraints.
:return: ``false`` if there is a known error in this form, ``true`` otherwise
:rtype: ``boolean``
:raise: ``OperationFailed`` -- attempt to perform validation failed
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def get_validation_messages(self):
"""Gets text messages corresponding to additional instructions to pass form validation.
:return: a list of messages
:rtype: ``osid.locale.DisplayText``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.locale.DisplayText
validation_messages = property(fget=get_validation_messages)
@abc.abstractmethod
def get_invalid_metadata(self):
"""Gets a list of metadata for the elements in this form which are not valid.
:return: invalid metadata
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
invalid_metadata = property(fget=get_invalid_metadata)
class OsidIdentifiableForm:
"""The ``OsidIdentifiableForm`` is used to create and update identifiable objects.
The form is a container for data to be sent to an update or create
method of a session.
"""
__metaclass__ = abc.ABCMeta
class OsidExtensibleForm:
"""The ``OsidExtensibleForm`` is used to create and update extensible objects.
The form is a container for data to be sent to an update or create
method of a session.
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_required_record_types(self):
"""Gets the required record types for this form.
The required records may change as a result of other data in
this form and should be checked before submission.
:return: a list of required record types
:rtype: ``osid.type.TypeList``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.type.TypeList
required_record_types = property(fget=get_required_record_types)
class OsidBrowsableForm:
"""The ``OsidBrowsableForm`` is used to create and update browsable objects.
The form is a container for data to be sent to an update or create
method of a session.
"""
__metaclass__ = abc.ABCMeta
class OsidTemporalForm:
"""This form is used to create and update temporals."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_start_date_metadata(self):
"""Gets the metadata for a start date.
:return: metadata for the date
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
start_date_metadata = property(fget=get_start_date_metadata)
@abc.abstractmethod
def set_start_date(self, date):
"""Sets the start date.
:param date: the new date
:type date: ``osid.calendaring.DateTime``
:raise: ``InvalidArgument`` -- ``date`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``date`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_start_date(self):
"""Clears the start date.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
start_date = property(fset=set_start_date, fdel=clear_start_date)
@abc.abstractmethod
def get_end_date_metadata(self):
"""Gets the metadata for an end date.
:return: metadata for the date
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
end_date_metadata = property(fget=get_end_date_metadata)
@abc.abstractmethod
def set_end_date(self, date):
"""Sets the end date.
:param date: the new date
:type date: ``osid.calendaring.DateTime``
:raise: ``InvalidArgument`` -- ``date`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``date`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_end_date(self):
"""Clears the end date.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
end_date = property(fset=set_end_date, fdel=clear_end_date)
class OsidSubjugateableForm:
"""This form is used to create and update dependent objects."""
__metaclass__ = abc.ABCMeta
class OsidAggregateableForm:
"""This form is used to create and update assemblages."""
__metaclass__ = abc.ABCMeta
class OsidContainableForm:
"""This form is used to create and update containers."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_sequestered_metadata(self):
"""Gets the metadata for the sequestered flag.
:return: metadata for the sequestered flag
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
sequestered_metadata = property(fget=get_sequestered_metadata)
@abc.abstractmethod
def set_sequestered(self, sequestered):
"""Sets the sequestered flag.
:param sequestered: the new sequestered flag
:type sequestered: ``boolean``
:raise: ``InvalidArgument`` -- ``sequestered`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_sequestered(self):
"""Clears the sequestered flag.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
sequestered = property(fset=set_sequestered, fdel=clear_sequestered)
class OsidSourceableForm:
"""This form is used to create and update sourceables."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_provider_metadata(self):
"""Gets the metadata for a provider.
:return: metadata for the provider
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
provider_metadata = property(fget=get_provider_metadata)
@abc.abstractmethod
def set_provider(self, provider_id):
"""Sets a provider.
:param provider_id: the new provider
:type provider_id: ``osid.id.Id``
:raise: ``InvalidArgument`` -- ``provider_id`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``provider_id`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_provider(self):
"""Removes the provider.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
provider = property(fset=set_provider, fdel=clear_provider)
@abc.abstractmethod
def get_branding_metadata(self):
"""Gets the metadata for the asset branding.
:return: metadata for the asset branding.
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
branding_metadata = property(fget=get_branding_metadata)
@abc.abstractmethod
def set_branding(self, asset_ids):
"""Sets the branding.
:param asset_ids: the new assets
:type asset_ids: ``osid.id.Id[]``
:raise: ``InvalidArgument`` -- ``asset_ids`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``asset_ids`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_branding(self):
"""Removes the branding.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
branding = property(fset=set_branding, fdel=clear_branding)
@abc.abstractmethod
def get_license_metadata(self):
"""Gets the metadata for the license.
:return: metadata for the license
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
license_metadata = property(fget=get_license_metadata)
@abc.abstractmethod
def set_license(self, license_):
"""Sets the license.
:param license: the new license
:type license: ``string``
:raise: ``InvalidArgument`` -- ``license`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``license`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_license(self):
"""Removes the license.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
license_ = property(fset=set_license, fdel=clear_license)
class OsidFederateableForm:
"""This form is used to create and update federateables."""
__metaclass__ = abc.ABCMeta
class OsidOperableForm:
"""This form is used to create and update operables."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_enabled_metadata(self):
"""Gets the metadata for the enabled flag.
:return: metadata for the enabled flag
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
enabled_metadata = property(fget=get_enabled_metadata)
@abc.abstractmethod
def set_enabled(self, enabled):
"""Sets the administratively enabled flag.
:param enabled: the new enabled flag
:type enabled: ``boolean``
:raise: ``InvalidArgument`` -- ``enabled`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_enabled(self):
"""Removes the administratively enabled flag.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
enabled = property(fset=set_enabled, fdel=clear_enabled)
@abc.abstractmethod
def get_disabled_metadata(self):
"""Gets the metadata for the disabled flag.
:return: metadata for the disabled flag
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
disabled_metadata = property(fget=get_disabled_metadata)
@abc.abstractmethod
def set_disabled(self, disabled):
"""Sets the administratively disabled flag.
:param disabled: the new disabled flag
:type disabled: ``boolean``
:raise: ``InvalidArgument`` -- ``disabled`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_disabled(self):
"""Removes the administratively disabled flag.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
disabled = property(fset=set_disabled, fdel=clear_disabled)
class OsidObjectForm:
"""The ``OsidObjectForm`` is used to create and update ``OsidObjects``.
The form is not an ``OsidObject`` but merely a container for data to
be sent to an update or create method of a session. A provider may
or may not combine the ``OsidObject`` and ``OsidObjectForm``
interfaces into a single object.
Generally, a set method parallels each get method of an
``OsidObject``. Additionally, ``Metadata`` may be examined for each
data element to assist in understanding particular rules concerning
acceptable data.
The form may provide some feedback as to the validity of certain
data updates before the update transaction is issued to the
correspodning session but a successful modification of the form is
not a guarantee of success for the update transaction. A consumer
may elect to perform all updates within a single update transaction
or break up a large update intio smaller units. The tradeoff is the
granularity of error feedback vs. the performance gain of a single
transaction.
As with all aspects of the OSIDs, nulls cannot be used. Methods to
clear values are also defined in the form.
A new ``OsidForm`` should be acquired for each transaction upon an
``OsidObject``. Forms should not be reused from one object to
another even if the supplied data is the same as the forms may
encapsulate data specific to the object requested. Example of
changing a display name and a color defined in a color interface
extension:
ObjectForm form = session.getObjectFormForUpdate(objectId);
form.setDisplayName("new name");
ColorForm recordForm = form.getFormRecord(colorRecordType);
recordForm.setColor("green");
session.updateObject(objectId, form);
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_display_name_metadata(self):
"""Gets the metadata for a display name.
:return: metadata for the display name
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
display_name_metadata = property(fget=get_display_name_metadata)
@abc.abstractmethod
def set_display_name(self, display_name):
"""Sets a display name.
A display name is required and if not set, will be set by the
provider.
:param display_name: the new display name
:type display_name: ``string``
:raise: ``InvalidArgument`` -- ``display_name`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadonly()`` is ``true``
:raise: ``NullArgument`` -- ``display_name`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_display_name(self):
"""Clears the display name.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
display_name = property(fset=set_display_name, fdel=clear_display_name)
@abc.abstractmethod
def get_description_metadata(self):
"""Gets the metadata for a description.
:return: metadata for the description
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
description_metadata = property(fget=get_description_metadata)
@abc.abstractmethod
def set_description(self, description):
"""Sets a description.
:param description: the new description
:type description: ``string``
:raise: ``InvalidArgument`` -- ``description`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadonly()`` is ``true``
:raise: ``NullArgument`` -- ``description`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_description(self):
"""Clears the description.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
description = property(fset=set_description, fdel=clear_description)
@abc.abstractmethod
def get_genus_type_metadata(self):
"""Gets the metadata for a genus type.
:return: metadata for the genus
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
genus_type_metadata = property(fget=get_genus_type_metadata)
@abc.abstractmethod
def set_genus_type(self, genus_type):
"""Sets a genus.
A genus cannot be cleared because all objects have at minimum a
root genus.
:param genus_type: the new genus
:type genus_type: ``osid.type.Type``
:raise: ``InvalidArgument`` -- ``genus_type`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadonly()`` is ``true``
:raise: ``NullArgument`` -- ``genus_type`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_genus_type(self):
"""Clears the genus type.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
genus_type = property(fset=set_genus_type, fdel=clear_genus_type)
class OsidRelationshipForm:
"""This form is used to create and update relationshps."""
__metaclass__ = abc.ABCMeta
class OsidCatalogForm:
"""This form is used to create and update catalogs."""
__metaclass__ = abc.ABCMeta
class OsidRuleForm:
"""This form is used to create and update rules."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_rule_metadata(self):
"""Gets the metadata for an associated rule.
:return: metadata for the rule
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
rule_metadata = property(fget=get_rule_metadata)
@abc.abstractmethod
def set_rule(self, rule_id):
"""Sets a rule.
:param rule_id: the new rule
:type rule_id: ``osid.id.Id``
:raise: ``InvalidArgument`` -- ``rule_id`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``rule_id`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_rule(self):
"""Removes the rule.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
rule = property(fset=set_rule, fdel=clear_rule)
class OsidEnablerForm:
"""This form is used to create and update enablers."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_schedule_metadata(self):
"""Gets the metadata for an associated schedule.
:return: metadata for the schedule
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
schedule_metadata = property(fget=get_schedule_metadata)
@abc.abstractmethod
def set_schedule(self, schedule_id):
"""Sets a schedule.
:param schedule_id: the new schedule
:type schedule_id: ``osid.id.Id``
:raise: ``InvalidArgument`` -- ``schedule_id`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``schedule_id`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_schedule(self):
"""Removes the schedule.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
schedule = property(fset=set_schedule, fdel=clear_schedule)
@abc.abstractmethod
def get_event_metadata(self):
"""Gets the metadata for an associated event.
:return: metadata for the event
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
event_metadata = property(fget=get_event_metadata)
@abc.abstractmethod
def set_event(self, event_id):
"""Sets an event.
:param event_id: the new event
:type event_id: ``osid.id.Id``
:raise: ``InvalidArgument`` -- ``event_id`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``event_id`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_event(self):
"""Removes the event.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
event = property(fset=set_event, fdel=clear_event)
@abc.abstractmethod
def get_cyclic_event_metadata(self):
"""Gets the metadata for the cyclic event.
:return: metadata for the cyclic event
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
cyclic_event_metadata = property(fget=get_cyclic_event_metadata)
@abc.abstractmethod
def set_cyclic_event(self, cyclic_event_id):
"""Sets the cyclic event.
:param cyclic_event_id: the new cyclic event
:type cyclic_event_id: ``osid.id.Id``
:raise: ``InvalidArgument`` -- ``cyclic_event_id`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``cyclic_event_id`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_cyclic_event(self):
"""Removes the cyclic event.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
cyclic_event = property(fset=set_cyclic_event, fdel=clear_cyclic_event)
@abc.abstractmethod
def get_demographic_metadata(self):
"""Gets the metadata for an associated demographic.
:return: metadata for the resource.
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
demographic_metadata = property(fget=get_demographic_metadata)
@abc.abstractmethod
def set_demographic(self, resource_id):
"""Sets a resource demographic.
:param resource_id: the new resource
:type resource_id: ``osid.id.Id``
:raise: ``InvalidArgument`` -- ``resource_id`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``resource_id`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_demographic(self):
"""Removes the resource demographic.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
demographic = property(fset=set_demographic, fdel=clear_demographic)
class OsidConstrainerForm:
"""This form is used to create and update constrainers."""
__metaclass__ = abc.ABCMeta
class OsidProcessorForm:
"""This form is used to create and update processors."""
__metaclass__ = abc.ABCMeta
class OsidGovernatorForm:
"""This form is used to create and update governators."""
__metaclass__ = abc.ABCMeta
class OsidCompendiumForm:
"""This form is used to create and update governators."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_start_date_metadata(self):
"""Gets the metadata for a start date.
:return: metadata for the date
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
start_date_metadata = property(fget=get_start_date_metadata)
@abc.abstractmethod
def set_start_date(self, date):
"""Sets the start date.
:param date: the new date
:type date: ``osid.calendaring.DateTime``
:raise: ``InvalidArgument`` -- ``date`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``date`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_start_date(self):
"""Clears the start date.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
start_date = property(fset=set_start_date, fdel=clear_start_date)
@abc.abstractmethod
def get_end_date_metadata(self):
"""Gets the metadata for an end date.
:return: metadata for the date
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
end_date_metadata = property(fget=get_end_date_metadata)
@abc.abstractmethod
def set_end_date(self, date):
"""Sets the end date.
:param date: the new date
:type date: ``osid.calendaring.DateTime``
:raise: ``InvalidArgument`` -- ``date`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``date`` is ``null``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_end_date(self):
"""Clears the end date.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
end_date = property(fset=set_end_date, fdel=clear_end_date)
@abc.abstractmethod
def get_interpolated_metadata(self):
"""Gets the metadata for the interpolated flag.
:return: metadata for the interpolated flag
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
interpolated_metadata = property(fget=get_interpolated_metadata)
@abc.abstractmethod
def set_interpolated(self, interpolated):
"""Sets the interpolated flag.
:param interpolated: the new interpolated flag
:type interpolated: ``boolean``
:raise: ``InvalidArgument`` -- ``interpolated`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_interpolated(self):
"""Clears the interpolated flag.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
interpolated = property(fset=set_interpolated, fdel=clear_interpolated)
@abc.abstractmethod
def get_extrapolated_metadata(self):
"""Gets the metadata for the extrapolated flag.
:return: metadata for the extrapolated flag
:rtype: ``osid.Metadata``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.Metadata
extrapolated_metadata = property(fget=get_extrapolated_metadata)
@abc.abstractmethod
def set_extrapolated(self, extrapolated):
"""Sets the extrapolated flag.
:param extrapolated: the new extrapolated flag
:type extrapolated: ``boolean``
:raise: ``InvalidArgument`` -- ``extrapolated`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
@abc.abstractmethod
def clear_extrapolated(self):
"""Clears the extrapolated flag.
:raise: ``NoAccess`` -- ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
pass
extrapolated = property(fset=set_extrapolated, fdel=clear_extrapolated)
class OsidCapsuleForm:
"""This form is used to create and update capsules."""
__metaclass__ = abc.ABCMeta
class OsidList:
"""``OsidList`` is the top-level interface for all OSID lists.
An OSID list provides sequential access, one at a time or many at a
time, access to a set of elements. These elements are not required
to be OsidObjects but generally are. The element retrieval methods
are defined in the sub-interface of ``OsidList`` where the
appropriate return type is defined.
Osid lists are a once pass through iteration of elements. The size
of the object set and the means in which the element set is
generated or stored is not known. Assumptions based on the length of
the element set by copying the entire contents of the list into a
fixed buffer should be done with caution a awareness that an
implementation may return a number of elements ranging from zero to
infinity.
Lists are returned by methods when multiple return values are
possible. There is no guarantee that successive calls to the same
method will return the same set of elements in a list. Unless an
order is specified in an interface definition, the order of the
elements is not known.
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def has_next(self):
"""Tests if there are more elements in this list.
:return: ``true`` if more elements are available in this list, ``false`` if the end of the list has been reached
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
*implementation notes*: Any errors that may result from accesing
the underlying set of elements are to be deferred until the
consumer attempts retrieval in which case the provider must
return ``true`` for this method.
"""
return # boolean
@abc.abstractmethod
def available(self):
"""Gets the number of elements available for retrieval.
The number returned by this method may be less than or equal to
the total number of elements in this list. To determine if the
end of the list has been reached, the method ``has_next()``
should be used. This method conveys what is known about the
number of remaining elements at a point in time and can be used
to determine a minimum size of the remaining elements, if known.
A valid return is zero even if ``has_next()`` is true.
This method does not imply asynchronous usage. All OSID methods
may block.
:return: the number of elements available for retrieval
:rtype: ``cardinal``
*compliance: mandatory -- This method must be implemented.*
*implementation notes*: Any errors that may result from accesing
the underlying set of elements are to be deferred until the
consumer attempts retrieval in which case the provider must
return a positive integer for this method so the consumer can
continue execution to receive the error. In all other
circumstances, the provider must not return a number greater
than the number of elements known since this number will be fed
as a parameter to the bulk retrieval method.
"""
return # cardinal
@abc.abstractmethod
def skip(self, n):
"""Skip the specified number of elements in the list.
If the number skipped is greater than the number of elements in
the list, hasNext() becomes false and available() returns zero
as there are no more elements to retrieve.
:param n: the number of elements to skip
:type n: ``cardinal``
*compliance: mandatory -- This method must be implemented.*
"""
pass
class OsidNode:
"""A node interface for hierarchical objects.
The ``Id`` of the node is the ``Id`` of the object represented at
this node.
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_root(self):
"""Tests if this node is a root in the hierarchy (has no parents).
A node may have no more parents available in this node structure
but is not a root in the hierarchy. If both ``is_root()`` and
``has_parents()`` is false, the parents of this node may be
accessed thorugh another node structure retrieval.
:return: ``true`` if this node is a root in the hierarchy, ``false`` otherwise
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def has_parents(self):
"""Tests if any parents are available in this node structure.
There may be no more parents in this node structure however
there may be parents that exist in the hierarchy.
:return: ``true`` if this node has parents, ``false`` otherwise
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def get_parent_ids(self):
"""Gets the parents of this node.
:return: the parents of this node
:rtype: ``osid.id.IdList``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.id.IdList
parent_ids = property(fget=get_parent_ids)
@abc.abstractmethod
def is_leaf(self):
"""Tests if this node is a leaf in the hierarchy (has no children).
A node may have no more children available in this node
structure but is not a leaf in the hierarchy. If both
``is_leaf()`` and ``has_children()`` is false, the children of
this node may be accessed thorugh another node structure
retrieval.
:return: ``true`` if this node is a leaf in the hierarchy, ``false`` otherwise
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def has_children(self):
"""Tests if any children are available in this node structure.
There may be no more children available in this node structure
but this node may have children in the hierarchy.
:return: ``true`` if this node has children, ``false`` otherwise
:rtype: ``boolean``
*compliance: mandatory -- This method must be implemented.*
"""
return # boolean
@abc.abstractmethod
def get_child_ids(self):
"""Gets the children of this node.
:return: the children of this node
:rtype: ``osid.id.IdList``
*compliance: mandatory -- This method must be implemented.*
"""
return # osid.id.IdList
child_ids = property(fget=get_child_ids)
| 32.488106 | 171 | 0.657556 | 8,637 | 71,019 | 5.32986 | 0.106634 | 0.023895 | 0.045618 | 0.066147 | 0.515641 | 0.462267 | 0.435982 | 0.40116 | 0.371617 | 0.356128 | 0 | 0.00135 | 0.248947 | 71,019 | 2,185 | 172 | 32.502975 | 0.861696 | 0.694152 | 0 | 0.587054 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.234375 | false | 0.095982 | 0.002232 | 0 | 0.669643 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
3e1d892a42dc0394c1de5a07ecf405acc00c72a0 | 298 | py | Python | huizenzoeker/exceptions.py | bpeschier/huizenzoeker | 9cace82095a69647c4033a5a3fd9d01f1968ff33 | [
"MIT"
] | 1 | 2019-08-04T17:25:11.000Z | 2019-08-04T17:25:11.000Z | huizenzoeker/exceptions.py | bpeschier/huizenzoeker | 9cace82095a69647c4033a5a3fd9d01f1968ff33 | [
"MIT"
] | null | null | null | huizenzoeker/exceptions.py | bpeschier/huizenzoeker | 9cace82095a69647c4033a5a3fd9d01f1968ff33 | [
"MIT"
] | null | null | null | class FilterDoesNotExistError(Exception):
"""
Raised when a filter does not exist.
"""
pass
class APIError(Exception):
"""
Error returned by the API.
"""
pass
class ValidationError(Exception):
"""
Raised when filters receive invalid data
"""
pass | 15.684211 | 44 | 0.620805 | 30 | 298 | 6.166667 | 0.733333 | 0.162162 | 0.205405 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.281879 | 298 | 19 | 45 | 15.684211 | 0.864486 | 0.348993 | 0 | 0.5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.5 | 0 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
3e276bc480af22c39102e4696e406d6abd93f0bd | 175 | py | Python | app/todo/urls.py | harddownloader/django-todo | 855ce2ac803bcaf48bf46dd4e97d8d2a4ec15337 | [
"MIT"
] | null | null | null | app/todo/urls.py | harddownloader/django-todo | 855ce2ac803bcaf48bf46dd4e97d8d2a4ec15337 | [
"MIT"
] | null | null | null | app/todo/urls.py | harddownloader/django-todo | 855ce2ac803bcaf48bf46dd4e97d8d2a4ec15337 | [
"MIT"
] | null | null | null | from rest_framework import routers
from .api import TodoViewSet
router = routers.DefaultRouter()
router.register('api/todo', TodoViewSet, 'todo')
urlpatterns = router.urls | 19.444444 | 48 | 0.788571 | 21 | 175 | 6.52381 | 0.619048 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.114286 | 175 | 9 | 49 | 19.444444 | 0.883871 | 0 | 0 | 0 | 0 | 0 | 0.068182 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
3e2d57024ff0df6708be2b3a1a9ebfa687a970b2 | 5,320 | py | Python | modules/NucleicAcids.py | tbrunetti/neoantigENcyclopedia | b7033ea775f9a31de0a02a78570b7b8b3b953291 | [
"MIT"
] | null | null | null | modules/NucleicAcids.py | tbrunetti/neoantigENcyclopedia | b7033ea775f9a31de0a02a78570b7b8b3b953291 | [
"MIT"
] | null | null | null | modules/NucleicAcids.py | tbrunetti/neoantigENcyclopedia | b7033ea775f9a31de0a02a78570b7b8b3b953291 | [
"MIT"
] | null | null | null | from typing import *
import sys
import os
sys.path.append(os.getcwd())
from Codon import *
class Rna:
rna_pairs = {'A':'U', 'U':'A', 'G':'C', 'C':'G'}
RNA_NUCLEOTIDES = ('A', 'U', 'G', 'C')
def __init__(self, sequence : str, rna_base_options = RNA_NUCLEOTIDES) -> None:
check_nt = set([sequence[pos].upper() for pos in range(0, len(sequence))])
if check_nt <= set(rna_base_options):
print('Confirmed sequence contains exclusive RNA basepairs')
else:
raise ValueError('%s is not a valid nucleotide for a RNA object.' % check_nt)
self.sequence = sequence.upper()
def translate(self, codon_library : Dict[str, Codon], ignore_stop : bool) -> str:
import math
#last_loop = math.floor(len(self.sequence)/3) - 1 # ensures codon is not translated if too short
last_loop_adjustment = len(self.sequence) % 3
protein_seq = []
try:
if ignore_stop == True:
'''
for loopId, codon in enumerate(range(0, len(self.sequence), 3)):
if loopId != last_loop: # confirms this is last loop that contains a full valid codon
protein_seq.append(codon_library[self.sequence[codon:codon+3]].translate_symbol())
elif loopId == last_loop:
protein_seq.append(codon_library[self.sequence[codon:codon+3]].translate_symbol())
break
'''
for codon in range(0, len(self.sequence) - last_loop_adjustment, 3):
protein_seq.append(codon_library[self.sequence[codon:codon+3]].translate_symbol())
else:
'''
for loopId, codon in enumerate(range(0, len(self.sequence), 3)):
if loopId != last_loop: # confirms this is last loop that contains a full valid codon
try:
assert codon_library[self.sequence[codon:codon+3]].translate_symbol() != '*', "Stop codon has been reached...suspending the remainder of the translation"
protein_seq.append(codon_library[self.sequence[codon:codon+3]].translate_symbol())
except AssertionError as e:
print(e)
protein_seq.append(codon_library[self.sequence[codon:codon+3]].translate_symbol())
break
elif loopId == last_loop:
protein_seq.append(codon_library[self.sequence[codon:codon+3]].translate_symbol())
break
'''
for codon in range(0, len(self.sequence) - last_loop_adjustment, 3):
try:
assert codon_library[self.sequence[codon:codon+3]].translate_symbol() != '*', "Stop codon has been reached...suspending the remainder of the translation"
protein_seq.append(codon_library[self.sequence[codon:codon+3]].translate_symbol())
except AssertionError as e:
print(e)
protein_seq.append(codon_library[self.sequence[codon:codon+3]].translate_symbol())
break
except KeyError as e:
print('Issue: {}.'.format(e))
print('sequence: {}'.format(self.sequence))
print('last loop calculation: {}'.format(str(last_loop_adjustment)))
print('protein seq until error: {}'.format(''.join(protein_seq)))
return ''.join(protein_seq)
class Dna:
dna_pairs = {'A':'T', 'T':'A', 'G':'C', 'C':'G'}
DNA_NUCLEOTIDES = ('A', 'T', 'G', 'C')
def __init__(self, sequence : str, dna_base_options = DNA_NUCLEOTIDES) -> None:
check_nt = set([sequence[pos].upper() for pos in range(0, len(sequence))])
if check_nt <= set(dna_base_options):
print('Confirmed sequence contains exclusive DNA basepairs')
else:
raise ValueError('%s is not a valid nucleotide for a DNA object.' % check_nt)
self.sequence = sequence.upper()
def complement(self) -> str:
'''
input:
description:
return:
'''
dna_pairs = {'A':'T', 'T':'A', 'G':'C', 'C':'G'}
complement_list = [dna_pairs[base] for base in list(self.sequence)]
return ''.join(complement_list)
def reverse(self) -> str:
'''
input:
description:
return:
'''
reverse_list = [base for base in list(self.sequence)[::-1]]
return ''.join(reverse_list)
def reverse_complement(self) -> str:
'''
input:
description:
return:
'''
dna_pairs = {'A':'T', 'T':'A', 'G':'C', 'C':'G'}
reverse_list = [base for base in list(self.sequence)[::-1]]
rc_list = [dna_pairs[base] for base in reverse_list]
return ''.join(rc_list)
def transcribe(self) -> Rna:
'''
input:
description:
return:
'''
return Rna(self.sequence.replace('T', 'U'))
| 38.832117 | 181 | 0.532895 | 595 | 5,320 | 4.616807 | 0.186555 | 0.10921 | 0.058245 | 0.087368 | 0.730979 | 0.718602 | 0.718602 | 0.640699 | 0.610848 | 0.610848 | 0 | 0.007147 | 0.342481 | 5,320 | 137 | 182 | 38.832117 | 0.778159 | 0.038722 | 0 | 0.306452 | 0 | 0 | 0.110631 | 0 | 0 | 0 | 0 | 0 | 0.032258 | 1 | 0.112903 | false | 0 | 0.080645 | 0 | 0.370968 | 0.112903 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3e310aacd4701d17b38a2fe52fe5520d394ca8fa | 1,272 | py | Python | pyzoo/zoo/pipeline/api/onnx/mapper/pow.py | abdolence/analytics-zoo | 364856abcbe9aff7f7b6cf9b9f8648d51e07ca64 | [
"Apache-2.0"
] | 2,970 | 2017-06-08T00:24:43.000Z | 2022-03-30T12:14:55.000Z | pyzoo/zoo/pipeline/api/onnx/mapper/pow.py | abdolence/analytics-zoo | 364856abcbe9aff7f7b6cf9b9f8648d51e07ca64 | [
"Apache-2.0"
] | 3,530 | 2017-05-09T08:29:10.000Z | 2022-03-21T02:11:45.000Z | pyzoo/zoo/pipeline/api/onnx/mapper/pow.py | abdolence/analytics-zoo | 364856abcbe9aff7f7b6cf9b9f8648d51e07ca64 | [
"Apache-2.0"
] | 972 | 2017-05-09T07:03:50.000Z | 2022-03-23T07:48:48.000Z | #
# Copyright 2018 Analytics Zoo Authors.
#
# 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 zoo.pipeline.api.onnx.mapper.operator_mapper import OperatorMapper
from zoo.pipeline.api.onnx.onnx_helper import OnnxHelper
import zoo.pipeline.api.keras.layers as zlayers
import numpy as np
class PowMapper(OperatorMapper):
def __init__(self, node, _params, _all_tensors):
super(PowMapper, self).__init__(node, _params, _all_tensors)
def _extract_model_inputs(self):
"""
:return: list of OnnxInput
"""
return [self._to_zoo_input(self._input_list[0])]
def _to_tensor(self):
exponent = self._input_list[1].zvalue.get_weight()[0]
pow = zlayers.Power(exponent)
return pow(self.model_inputs[0].zvalue)
| 35.333333 | 74 | 0.731918 | 182 | 1,272 | 4.950549 | 0.571429 | 0.066593 | 0.046615 | 0.035516 | 0.048835 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011505 | 0.180031 | 1,272 | 35 | 75 | 36.342857 | 0.852349 | 0.461478 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.307692 | 0 | 0.769231 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
3e3d5369be791cb14ed9a6e5c94418547ef45aa0 | 547 | py | Python | run.py | gvmossato/numerico-ep1 | 10b360e7ea4724ea90093f033718d0029afa28b6 | [
"MIT"
] | null | null | null | run.py | gvmossato/numerico-ep1 | 10b360e7ea4724ea90093f033718d0029afa28b6 | [
"MIT"
] | null | null | null | run.py | gvmossato/numerico-ep1 | 10b360e7ea4724ea90093f033718d0029afa28b6 | [
"MIT"
] | null | null | null | # ======================= #
# Módulo para execução do #
# Exercío-Promgrama #
# ======================= #
import interface
print(
"""\033[32m
===================================================
Exercício-Programa #1
===================================================
Algoritmo QR: autovalores e autovetores de matrizes
tridiagonais simétricas.
MAP3121 – Métodos Numéricos e Aplicações
===================================================
\033[0m"""
)
interface.start()
print('\n\033[31mExecução finalizada.\033[0m')
| 20.259259 | 51 | 0.427788 | 40 | 547 | 5.875 | 0.825 | 0.042553 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.048729 | 0.137112 | 547 | 26 | 52 | 21.038462 | 0.447034 | 0.180987 | 0 | 0 | 0 | 0 | 0.366337 | 0 | 0 | 0 | 0 | 0.038462 | 0 | 1 | 0 | true | 0 | 0.2 | 0 | 0.2 | 0.4 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3e55b9e32776844990376212e6b889245bf4e24d | 251 | py | Python | Python/String-1/make_abba.py | LucasHenrique-dev/exerc-cios-codingbat | ff92db10387757b9a2e3f72be6b7e51824b1ffa6 | [
"MIT"
] | 2 | 2020-12-09T13:36:44.000Z | 2021-08-16T01:17:16.000Z | Python/String-1/make_abba.py | LucasHenrique-dev/exerc-cios-codingbat | ff92db10387757b9a2e3f72be6b7e51824b1ffa6 | [
"MIT"
] | null | null | null | Python/String-1/make_abba.py | LucasHenrique-dev/exerc-cios-codingbat | ff92db10387757b9a2e3f72be6b7e51824b1ffa6 | [
"MIT"
] | null | null | null | """
Dada 2 Strings ("a" e "b"), retorne outra no fomato "abba".
Ex.:(('Hi', 'Bye') → 'HiByeByeHi'; ('What', 'Up') → 'WhatUpUpWhat'; ('Yo', 'Alice') → 'YoAliceAliceYo').
"""
def make_abba(a, b):
return a + 2*b + a
print(make_abba("Hi", "bye"))
| 20.916667 | 104 | 0.549801 | 39 | 251 | 3.564103 | 0.666667 | 0.071942 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009662 | 0.175299 | 251 | 11 | 105 | 22.818182 | 0.647343 | 0.653386 | 0 | 0 | 0 | 0 | 0.063291 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0 | 0.333333 | 0.666667 | 0.333333 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
3e5783ef284ef195f0b3e3fc9cdd3f11d767b206 | 54 | py | Python | pubtrack/pubs/__init__.py | the16thpythonist/pubtrack | 5d44914ed6aafe01dc7b234e9f4e8d12e45dfb50 | [
"MIT"
] | null | null | null | pubtrack/pubs/__init__.py | the16thpythonist/pubtrack | 5d44914ed6aafe01dc7b234e9f4e8d12e45dfb50 | [
"MIT"
] | 4 | 2020-07-28T10:04:57.000Z | 2021-09-22T19:03:17.000Z | pubtrack/pubs/__init__.py | the16thpythonist/pubtrack | 5d44914ed6aafe01dc7b234e9f4e8d12e45dfb50 | [
"MIT"
] | null | null | null | default_app_config = 'pubtrack.pubs.apps.PubsConfig'
| 18 | 52 | 0.814815 | 7 | 54 | 6 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.074074 | 54 | 2 | 53 | 27 | 0.84 | 0 | 0 | 0 | 0 | 0 | 0.54717 | 0.54717 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3e689b982e34225791bd786fa5c78004292ae084 | 1,866 | py | Python | test/test_worm_api.py | Atomicology/isilon_sdk_python | 91039da803ae37ed4abf8d2a3f59c333f3ef1866 | [
"MIT"
] | null | null | null | test/test_worm_api.py | Atomicology/isilon_sdk_python | 91039da803ae37ed4abf8d2a3f59c333f3ef1866 | [
"MIT"
] | null | null | null | test/test_worm_api.py | Atomicology/isilon_sdk_python | 91039da803ae37ed4abf8d2a3f59c333f3ef1866 | [
"MIT"
] | null | null | null | # coding: utf-8
"""
Copyright 2016 SmartBear Software
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.
ref: https://github.com/swagger-api/swagger-codegen
"""
from __future__ import absolute_import
import os
import sys
import unittest
import swagger_client
from swagger_client.rest import ApiException
from swagger_client.apis.worm_api import WormApi
class TestWormApi(unittest.TestCase):
""" WormApi unit test stubs """
def setUp(self):
self.api = swagger_client.apis.worm_api.WormApi()
def tearDown(self):
pass
def test_create_worm_domain(self):
"""
Test case for create_worm_domain
"""
pass
def test_get_worm_domain(self):
"""
Test case for get_worm_domain
"""
pass
def test_get_worm_settings(self):
"""
Test case for get_worm_settings
"""
pass
def test_list_worm_domains(self):
"""
Test case for list_worm_domains
"""
pass
def test_update_worm_domain(self):
"""
Test case for update_worm_domain
"""
pass
def test_update_worm_settings(self):
"""
Test case for update_worm_settings
"""
pass
if __name__ == '__main__':
unittest.main() | 20.505495 | 75 | 0.638264 | 235 | 1,866 | 4.859574 | 0.455319 | 0.052539 | 0.057793 | 0.078809 | 0.258319 | 0.181261 | 0.049037 | 0 | 0 | 0 | 0 | 0.006813 | 0.292069 | 1,866 | 91 | 76 | 20.505495 | 0.857684 | 0.469453 | 0 | 0.269231 | 0 | 0 | 0.01027 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.307692 | false | 0.269231 | 0.269231 | 0 | 0.615385 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
3e6f088e63babd44f7365a37668520b3808f43e1 | 3,075 | py | Python | compass/tests/config_management/utils/test_config_merger_callbacks.py | huawei-cloud/compass | 1f09b2d270917ffcc3829e533dd90c04ef664ff6 | [
"Apache-2.0"
] | 2 | 2015-12-07T06:47:16.000Z | 2016-01-18T05:27:52.000Z | compass/tests/config_management/utils/test_config_merger_callbacks.py | SysCompass/compass-core | b04d02ae97d6fbeea9a6c42c6d368778c371ccde | [
"Apache-2.0"
] | 1 | 2016-03-17T17:36:56.000Z | 2016-03-17T17:36:56.000Z | compass/tests/config_management/utils/test_config_merger_callbacks.py | SysCompass/compass-core | b04d02ae97d6fbeea9a6c42c6d368778c371ccde | [
"Apache-2.0"
] | 4 | 2016-06-13T17:19:14.000Z | 2018-09-10T03:11:51.000Z | import unittest2
from compass.config_management.utils import config_merger_callbacks
from compass.config_management.utils import config_reference
class TestAssignRoles(unittest2.TestCase):
def test_assign_roles(self):
lower_configs = {
1: {'roles': ['control']},
2: {'roles': ['api', 'compute']},
3: {'roles': []},
4: {},
5: {},
}
lower_refs = {}
for hostid, config in lower_configs.items():
lower_refs[hostid] = config_reference.ConfigReference(config)
roles = ['control', 'api', 'compute']
maxs = {'control': 1, 'api': 2, 'compute': -1}
default_min = 1
exclusives = ['control']
assigned = config_merger_callbacks.assign_roles(
None, None, lower_refs, 'roles', roles=roles,
maxs=maxs,
default_min=default_min,
exclusives=exclusives)
self.assertEqual(assigned, {1: ['control'],
2: ['api', 'compute'],
3: ['api'],
4: ['compute'],
5: ['compute']})
default_min = 2
maxs = {'control': 1, 'api': 2, 'compute': 2}
lower_configs = {
1: {'roles': ['control']},
2: {'roles': ['api', 'compute']},
3: {'roles': []},
4: {},
5: {},
}
lower_refs = {}
for hostid, config in lower_configs.items():
lower_refs[hostid] = config_reference.ConfigReference(config)
assigned = config_merger_callbacks.assign_roles(
None, None, lower_refs, 'roles', roles=roles,
maxs=maxs, default_min=default_min,
exclusives=exclusives)
self.assertEqual(assigned, {1: ['control'],
2: ['api', 'compute'],
3: ['control'],
4: ['api'],
5: ['compute']})
default_min = 1
roles = ['control', 'api', 'compute', 'mysql']
maxs = {'control': 1, 'api': 2, 'compute': -1, 'mysql': 2}
bundles = [['control', 'api']]
lower_configs = {
1: {},
2: {},
3: {},
4: {},
5: {},
}
lower_refs = {}
for hostid, config in lower_configs.items():
lower_refs[hostid] = config_reference.ConfigReference(config)
assigned = config_merger_callbacks.assign_roles(
None, None, lower_refs, 'roles', roles=roles,
maxs=maxs, default_min=default_min,
exclusives=exclusives, bundles=bundles)
self.assertEqual(assigned, {1: ['control', 'api'],
2: ['compute'],
3: ['mysql'],
4: ['mysql'],
5: ['compute']})
if __name__ == '__main__':
unittest2.main()
| 37.048193 | 73 | 0.458862 | 267 | 3,075 | 5.093633 | 0.172285 | 0.059559 | 0.061765 | 0.024265 | 0.748529 | 0.725735 | 0.708824 | 0.608824 | 0.608824 | 0.608824 | 0 | 0.024959 | 0.40065 | 3,075 | 82 | 74 | 37.5 | 0.712968 | 0 | 0 | 0.573333 | 0 | 0 | 0.097886 | 0 | 0 | 0 | 0 | 0 | 0.04 | 1 | 0.013333 | false | 0.026667 | 0.04 | 0 | 0.066667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3e71114f38b4f04c52f39c0119666453108bd7f2 | 5,677 | py | Python | tests/test_sqlite_joins.py | WinVector/data_algebra | 3d6002ddf8231d310e03537a0435df0554b62234 | [
"BSD-3-Clause"
] | 37 | 2019-08-28T08:16:48.000Z | 2022-03-14T21:18:39.000Z | tests/test_sqlite_joins.py | WinVector/data_algebra | 3d6002ddf8231d310e03537a0435df0554b62234 | [
"BSD-3-Clause"
] | 1 | 2019-09-02T23:13:29.000Z | 2019-09-08T01:43:10.000Z | tests/test_sqlite_joins.py | WinVector/data_algebra | 3d6002ddf8231d310e03537a0435df0554b62234 | [
"BSD-3-Clause"
] | 3 | 2019-08-28T12:23:11.000Z | 2020-02-08T19:22:31.000Z |
import numpy
import data_algebra
import data_algebra.test_util
import data_algebra.util
from data_algebra.data_ops import *
import data_algebra.SQLite
import data_algebra.MySQL
direct_test_sqlite = False
def test_sqlite_joins_left_to_right():
sqlite_handle = None
if direct_test_sqlite:
sqlite_handle = data_algebra.SQLite.example_handle()
# No none keys, as they treat missingness different
# in Pandas and databases
d1 = data_algebra.default_data_model.pd.DataFrame({
'g': ['a', 'a', 'b', 'b', 'b'],
'v1': [1, None, 3, 4, None],
'v2': [None, 1, 2, 7, 8],
})
d2 = data_algebra.default_data_model.pd.DataFrame({
'g': ['c', 'b', 'b'],
'v1': [None, 1, None],
'v2': [1, None, 2],
})
ops_1 = descr(d1=d1).natural_join(b=descr(d2=d2), by=['g'], jointype='left')
expect_1 = data_algebra.default_data_model.pd.DataFrame({
'g': ['a', 'a', 'b', 'b', 'b', 'b', 'b', 'b'],
'v1': [1.0, None, 3.0, 3.0, 4.0, 4.0, 1.0, None],
'v2': [None, 1.0, 2.0, 2.0, 7.0, 7.0, 8.0, 8.0],
})
res_1 = ops_1.eval({'d1': d1, 'd2': d2})
assert data_algebra.test_util.equivalent_frames(res_1, expect_1)
if direct_test_sqlite:
print(sqlite_handle.to_sql(ops_1))
data_algebra.test_util.check_transform(
ops=ops_1,
data={'d1': d1, 'd2': d2},
expect=expect_1,
models_to_skip={str(data_algebra.MySQL.MySQLModel())},)
ops_2 = descr(d1=d1).natural_join(b=descr(d2=d2), by=['g'], jointype='right')
expect_2 = data_algebra.default_data_model.pd.DataFrame({
'g': ['c', 'b', 'b', 'b', 'b', 'b', 'b'],
'v1': [None, 3.0, 4.0, 1.0, 3.0, 4.0, None],
'v2': [1.0, 2.0, 7.0, 8.0, 2.0, 7.0, 8.0],
})
res_2 = ops_2.eval({'d1': d1, 'd2': d2})
assert data_algebra.test_util.equivalent_frames(res_2, expect_2)
if direct_test_sqlite:
print(sqlite_handle.to_sql(ops_2))
data_algebra.test_util.check_transform(
ops=ops_2,
data={'d1': d1, 'd2': d2},
expect=expect_2,
models_to_skip={str(data_algebra.MySQL.MySQLModel())},)
# check test is strong enough
assert not data_algebra.test_util.equivalent_frames(expect_1, expect_2)
# naive reversal (interferes with coalesce)
ops_n = descr(d2=d2).natural_join(b=descr(d1=d1), by=['g'], jointype='left')
res_n = ops_n.eval({'d1': d1, 'd2': d2})
assert not data_algebra.test_util.equivalent_frames(res_n, expect_1)
assert not data_algebra.test_util.equivalent_frames(res_n, expect_2)
if sqlite_handle is not None:
sqlite_handle.close()
def test_sqlite_joins_simulate_full_join():
sqlite_handle = None
if direct_test_sqlite:
sqlite_handle = data_algebra.SQLite.example_handle()
d1 = data_algebra.default_data_model.pd.DataFrame({
'g': ['a', 'a', 'b', 'b', 'b'],
'v1': [1, None, 3, 4, None],
'v2': [None, 1, None, 7, 8],
})
d2 = data_algebra.default_data_model.pd.DataFrame({
'g': ['c', 'b', 'b'],
'v1': [None, 1, None],
'v2': [1, None, 2],
})
join_columns = ['g']
ops = (
descr(d1=d1)
.natural_join(
b=descr(d2=d2),
by=join_columns,
jointype='full')
)
res_pandas = ops.eval({'d1': d1, 'd2': d2})
if direct_test_sqlite:
print(sqlite_handle.to_sql(ops))
data_algebra.test_util.check_transform(
ops=ops,
data={'d1': d1, 'd2': d2},
expect=res_pandas,
models_to_skip={str(data_algebra.MySQL.MySQLModel())},)
ops_simulate = (
# get shared key set
descr(d1=d1)
.project({}, group_by=join_columns)
.concat_rows(
b=descr(d2=d2)
.project({}, group_by=join_columns),
id_column=None,
)
.project({}, group_by=join_columns)
# simulate full join with left joins
.natural_join(
b=descr(d1=d1),
by=join_columns,
jointype='left')
.natural_join(
b=descr(d2=d2),
by=join_columns,
jointype='left')
)
data_algebra.test_util.check_transform(
ops=ops_simulate,
data={'d1': d1, 'd2': d2},
expect=res_pandas,
models_to_skip={str(data_algebra.MySQL.MySQLModel())},)
if sqlite_handle is not None:
sqlite_handle.close()
def test_sqlite_joins_staged():
sqlite_handle = None
if direct_test_sqlite:
sqlite_handle = data_algebra.SQLite.example_handle()
d1 = data_algebra.default_data_model.pd.DataFrame({
'g': ['a', 'a', 'b', 'b', 'b'],
'v1': [1, None, 3, 4, None],
'v2': [None, 1, None, 7, 8],
})
d2 = data_algebra.default_data_model.pd.DataFrame({
'g': ['c', 'b', 'b'],
'v1': [None, 1, None],
'v2': [1, None, 2],
})
join_columns = ['g']
ops = (
descr(d1=d1)
.extend({'v1': 'v1 * v1'})
.natural_join(
b=(
descr(d2=d2)
.extend({'v2': 'v2 + v2'})),
by=join_columns,
jointype='full')
)
res_pandas = ops.eval({'d1': d1, 'd2': d2})
if direct_test_sqlite:
print(sqlite_handle.to_sql(ops))
data_algebra.test_util.check_transform(
ops=ops,
data={'d1': d1, 'd2': d2},
expect=res_pandas,
models_to_skip={str(data_algebra.MySQL.MySQLModel())}, )
if sqlite_handle is not None:
sqlite_handle.close()
| 29.878947 | 81 | 0.557689 | 790 | 5,677 | 3.770886 | 0.121519 | 0.11816 | 0.055388 | 0.070158 | 0.794226 | 0.750587 | 0.73951 | 0.699899 | 0.632091 | 0.616314 | 0 | 0.04798 | 0.28043 | 5,677 | 189 | 82 | 30.037037 | 0.681273 | 0.034701 | 0 | 0.651007 | 0 | 0 | 0.03125 | 0 | 0 | 0 | 0 | 0 | 0.033557 | 1 | 0.020134 | false | 0 | 0.04698 | 0 | 0.067114 | 0.026846 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
e445dad981d2fa93b206aba41a7f7174097ff577 | 391 | py | Python | pypytorch/nn/modules/__init__.py | dark-ai/pypytorch | d28e0f858ad7c33a14e4bb71dc68ae56ba97c5cf | [
"MIT"
] | 10 | 2019-08-13T10:29:14.000Z | 2022-02-21T01:57:33.000Z | pypytorch/nn/modules/__init__.py | dark-ai/pypytorch | d28e0f858ad7c33a14e4bb71dc68ae56ba97c5cf | [
"MIT"
] | 1 | 2019-10-25T02:26:45.000Z | 2019-10-25T11:15:10.000Z | pypytorch/nn/modules/__init__.py | dark-ai/pypytorch | d28e0f858ad7c33a14e4bb71dc68ae56ba97c5cf | [
"MIT"
] | 2 | 2019-08-17T00:48:37.000Z | 2019-10-24T09:22:37.000Z | # -*- coding: utf-8 -*-
from .module import (Module, Sequential)
from .linear import Linear
from .conv import Conv2d
from .pooling import MaxPool2d, AvgPool2d
from .loss import (MSELoss, NLLLoss, CrossEntropyLoss)
from .activation import (ReLU, Sigmoid, Tanh)
from .dropout import DropOut
from .batchnorm import BatchNorm2d
from .deconv import DeConv2d
from .upsample import NearestUpsample | 32.583333 | 54 | 0.790281 | 49 | 391 | 6.306122 | 0.571429 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017647 | 0.130435 | 391 | 12 | 55 | 32.583333 | 0.891176 | 0.053708 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
e45629dfc7c4983527c0bd273b1fa62845a855fb | 542 | py | Python | scripts/key_value_client_example.py | pthomaid/constellations | 517c0d825ae45fe9bde92b8873a52ff22941764b | [
"MIT"
] | 1 | 2016-05-11T15:42:45.000Z | 2016-05-11T15:42:45.000Z | scripts/key_value_client_example.py | pthomaid/constellations | 517c0d825ae45fe9bde92b8873a52ff22941764b | [
"MIT"
] | 2 | 2016-01-19T17:14:27.000Z | 2016-01-20T20:36:35.000Z | scripts/key_value_client_example.py | pthomaid/constellations | 517c0d825ae45fe9bde92b8873a52ff22941764b | [
"MIT"
] | null | null | null |
import sys
import time
import json
from constellations.socket_transport import SocketTransport
from constellations import discovery
from constellations.key_value import Gossip_key_value
from constellations.key_value_client import Key_value_client
from constellations.node import Node
from constellations.gossip import Gossip
"""Using the gossip key value store, using a client
"""
kvc = Key_value_client()
print(kvc.distributed_get("key1"))
print(kvc.distributed_get("key2"))
time.sleep(1)
input("Press Enter to continue...")
sys.exit() | 23.565217 | 60 | 0.819188 | 76 | 542 | 5.684211 | 0.434211 | 0.25 | 0.097222 | 0.12037 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006173 | 0.103321 | 542 | 23 | 61 | 23.565217 | 0.882716 | 0 | 0 | 0 | 0 | 0 | 0.069815 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.6 | 0 | 0.6 | 0.133333 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
e45dd24002fc29326ae46ed028489f5414ad8503 | 150 | py | Python | src/common/status.py | THUKElab/Video2Description | 76aed1f473d1c9e0cca80829a28914262e64acd0 | [
"Apache-2.0"
] | 152 | 2018-04-29T12:25:03.000Z | 2022-03-31T07:13:17.000Z | src/common/status.py | THUKElab/Video2Description | 76aed1f473d1c9e0cca80829a28914262e64acd0 | [
"Apache-2.0"
] | 23 | 2018-12-21T09:48:48.000Z | 2022-03-15T00:54:34.000Z | src/common/status.py | THUKElab/Video2Description | 76aed1f473d1c9e0cca80829a28914262e64acd0 | [
"Apache-2.0"
] | 56 | 2018-07-26T04:57:24.000Z | 2021-12-29T10:46:47.000Z | from enum import Enum
class ModelWeightsStatus(Enum):
NO_INFO = 0
SUCCESS = 1
MODEL_NOT_FOUND = 2
WIP = 3 | 21.428571 | 31 | 0.54 | 18 | 150 | 4.333333 | 0.888889 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.045455 | 0.413333 | 150 | 7 | 32 | 21.428571 | 0.840909 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
e472f41e009d2010dedc5d2023e7d4528bb66b38 | 1,919 | py | Python | pysnmp-with-texts/ChrTrap-MIB.py | agustinhenze/mibs.snmplabs.com | 1fc5c07860542b89212f4c8ab807057d9a9206c7 | [
"Apache-2.0"
] | 8 | 2019-05-09T17:04:00.000Z | 2021-06-09T06:50:51.000Z | pysnmp-with-texts/ChrTrap-MIB.py | agustinhenze/mibs.snmplabs.com | 1fc5c07860542b89212f4c8ab807057d9a9206c7 | [
"Apache-2.0"
] | 4 | 2019-05-31T16:42:59.000Z | 2020-01-31T21:57:17.000Z | pysnmp-with-texts/ChrTrap-MIB.py | agustinhenze/mibs.snmplabs.com | 1fc5c07860542b89212f4c8ab807057d9a9206c7 | [
"Apache-2.0"
] | 10 | 2019-04-30T05:51:36.000Z | 2022-02-16T03:33:41.000Z | #
# PySNMP MIB module ChrTrap-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ChrTrap-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:36:20 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
SingleValueConstraint, ValueSizeConstraint, ValueRangeConstraint, ConstraintsUnion, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueSizeConstraint", "ValueRangeConstraint", "ConstraintsUnion", "ConstraintsIntersection")
chrComTrap, = mibBuilder.importSymbols("Chromatis-MIB", "chrComTrap")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
IpAddress, NotificationType, iso, TimeTicks, NotificationType, Counter64, Counter32, Integer32, ObjectIdentity, Gauge32, ModuleIdentity, MibIdentifier, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, Bits = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "NotificationType", "iso", "TimeTicks", "NotificationType", "Counter64", "Counter32", "Integer32", "ObjectIdentity", "Gauge32", "ModuleIdentity", "MibIdentifier", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Bits")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
chrComTrapLoggedTrap = NotificationType((1, 3, 6, 1, 4, 1, 3695, 1, 6) + (0,1))
if mibBuilder.loadTexts: chrComTrapLoggedTrap.setDescription('This trap informs about a new event that was reported to the TrapLog table.')
mibBuilder.exportSymbols("ChrTrap-MIB", chrComTrapLoggedTrap=chrComTrapLoggedTrap)
| 106.611111 | 515 | 0.789995 | 192 | 1,919 | 7.895833 | 0.567708 | 0.106201 | 0.05343 | 0.100264 | 0.373351 | 0.242744 | 0.242744 | 0.242744 | 0.242744 | 0.242744 | 0 | 0.046459 | 0.08025 | 1,919 | 17 | 516 | 112.882353 | 0.812465 | 0.164669 | 0 | 0 | 0 | 0 | 0.354454 | 0.027604 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.7 | 0 | 0.7 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
e4763d05e1ed40c7c1ff72a2bb9a698bee46a392 | 138 | py | Python | extra_old_code/turtle_ex/circle.py | ugo-en/some-python-code | 95ca7d9f34ab175dc25556b1c0485134c49b0370 | [
"MIT"
] | null | null | null | extra_old_code/turtle_ex/circle.py | ugo-en/some-python-code | 95ca7d9f34ab175dc25556b1c0485134c49b0370 | [
"MIT"
] | null | null | null | extra_old_code/turtle_ex/circle.py | ugo-en/some-python-code | 95ca7d9f34ab175dc25556b1c0485134c49b0370 | [
"MIT"
] | null | null | null | import turtle
turtle.pensize(3)
turtle.color("red","royalblue")
turtle.begin_fill()
turtle.delay(20)
turtle.circle(100)
turtle.end_fill()
| 17.25 | 31 | 0.775362 | 21 | 138 | 5 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.046154 | 0.057971 | 138 | 7 | 32 | 19.714286 | 0.761538 | 0 | 0 | 0 | 0 | 0 | 0.086957 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.142857 | 0 | 0.142857 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
e4b207d112ee2426c0377551427a2c6c33b802e8 | 437 | py | Python | server/server/parsing/__init__.py | InbarShirizly/zoom_attendance_check | 8a151baa3b774c68c1b32aa05ac365002ca272ca | [
"MIT"
] | 15 | 2020-08-26T04:53:34.000Z | 2022-03-13T13:19:43.000Z | server/server/parsing/__init__.py | InbarShirizly/zoom_attendance_check | 8a151baa3b774c68c1b32aa05ac365002ca272ca | [
"MIT"
] | 41 | 2020-09-22T13:34:13.000Z | 2021-09-04T15:37:02.000Z | server/server/parsing/__init__.py | InbarShirizly/zoom_attendance_check | 8a151baa3b774c68c1b32aa05ac365002ca272ca | [
"MIT"
] | 1 | 2020-10-14T01:44:55.000Z | 2020-10-14T01:44:55.000Z | from server.config import ParseConfig
from server.parsing.parse_class_file import ParseClassFile
from collections import namedtuple
# create parser instance
parser = ParseClassFile.from_object(ParseConfig)
# create namedtuple instance called "meta_data" - with variables that will be inserted to the Attendance class
AttendanceMetaData = namedtuple('meta_data', ['filter_modes', 'time_delta', 'start_sentence', 'zoom_names_to_ignore'])
| 48.555556 | 118 | 0.828375 | 55 | 437 | 6.381818 | 0.690909 | 0.05698 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.100687 | 437 | 8 | 119 | 54.625 | 0.89313 | 0.299771 | 0 | 0 | 0 | 0 | 0.214521 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.6 | 0 | 0.6 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
e4c25266d5a89015f20669dd5c1091ad733e41f7 | 4,938 | py | Python | config/colorterms.py | raphaelshirley/obs_vista | 69457409dcbeb856c174e4233d2dd5419602b93f | [
"Apache-2.0"
] | 1 | 2020-07-16T16:20:00.000Z | 2020-07-16T16:20:00.000Z | config/colorterms.py | raphaelshirley/obs_vista | 69457409dcbeb856c174e4233d2dd5419602b93f | [
"Apache-2.0"
] | 1 | 2020-07-16T10:17:07.000Z | 2020-07-20T15:30:49.000Z | config/colorterms.py | raphaelshirley/obs_vista | 69457409dcbeb856c174e4233d2dd5419602b93f | [
"Apache-2.0"
] | 1 | 2021-06-07T10:09:03.000Z | 2021-06-07T10:09:03.000Z | #colorterms = config.photoCal.colorterms
from lsst.pipe.tasks.colorterms import ColortermDict, Colorterm
config.data = {
"ps1*": ColortermDict(data={
# Names used by Exposure.getFilter() in Gen2.
# 'g': Colorterm(primary="g", secondary="r", c0=0.005728, c1=0.061749, c2=-0.001125),
# 'r': Colorterm(primary="r", secondary="i", c0=-0.000144, c1=0.001369, c2=-0.008380),
# # 'r2': Colorterm(primary="r", secondary="i", c0=-0.000032, c1=-0.002866, c2=-0.012638),
# 'i': Colorterm(primary="i", secondary="z", c0=0.000643, c1=-0.130078, c2=-0.006855),
# # 'i2': Colorterm(primary="i", secondary="z", c0=0.001625, c1=-0.200406, c2=-0.013666),
# 'z': Colorterm(primary="z", secondary="y", c0=-0.005362, c1=-0.221551, c2=-0.308279),
# 'y': Colorterm(primary="y", secondary="z", c0=-0.002055, c1=0.209680, c2=0.227296),
# 'z2': Colorterm(primary="z2", secondary="z2"),
# 'y2': Colorterm(primary="y2", secondary="y2"),
# 'j': Colorterm(primary="j", secondary="j"),
# 'h': Colorterm(primary="h", secondary="h"),
# 'ks': Colorterm(primary="ks", secondary="ks"),
# Names used by data IDs in both Gen2 and Gen3, and
# Exposure.getFilter() in Gen3 (data is the same).
'HSC-G': Colorterm(primary="g", secondary="r", c0=0.005728, c1=0.061749, c2=-0.001125),
'HSC-R': Colorterm(primary="r", secondary="i", c0=-0.000144, c1=0.001369, c2=-0.008380),
# 'HSC-R2': Colorterm(primary="r", secondary="i", c0=-0.000032, c1=-0.002866, c2=-0.012638),
'HSC-I': Colorterm(primary="i", secondary="z", c0=0.000643, c1=-0.130078, c2=-0.006855),
# 'HSC-I2': Colorterm(primary="i", secondary="z", c0=0.001625, c1=-0.200406, c2=-0.013666),
'HSC-Z': Colorterm(primary="z", secondary="y", c0=-0.005362, c1=-0.221551, c2=-0.308279),
'HSC-Y': Colorterm(primary="y", secondary="z", c0=-0.002055, c1=0.209680, c2=0.227296),
'VIRCAM-Z': Colorterm(primary="z2", secondary="z2"),
'VIRCAM-Y': Colorterm(primary="y2", secondary="y2"),
'VIRCAM-J': Colorterm(primary="j", secondary="j"),
'VIRCAM-H': Colorterm(primary="h", secondary="h"),
'VIRCAM-Ks': Colorterm(primary="ks", secondary="ks"),
}),
}
# if 'vista' in ref_cat:
# colorterms.data["ps1*"] = ColortermDict(data={
# #####HSC COLOUR TERMS FROM obs_subaru
# 'HSC-G': Colorterm(primary="g", secondary="r",
# c0=0.00730066, c1=0.06508481, c2=-0.01510570),
# 'HSC-R': Colorterm(primary="r", secondary="i",
# c0=0.00279757, c1=0.02093734, c2=-0.01877566),
# 'HSC-I': Colorterm(primary="i", secondary="z",
# c0=0.00166891, c1=-0.13944659, c2=-0.03034094),
# 'HSC-Z': Colorterm(primary="z", secondary="y",
# c0=-0.00907517, c1=-0.28840221, c2=-0.00316369),
# 'HSC-Y': Colorterm(primary="y", secondary="z",
# c0=-0.00156858, c1=0.14747401, c2=0.02880125),
# 'VISTA-Z': Colorterm(primary="z2", secondary="y2",
# c0=0.0, c1=-0.0, c2=-0.0),
# 'VISTA-Y': Colorterm(primary="y2", secondary="z2",
# c0=0.0, c1=0.0, c2=0.0),
# 'VISTA-J': Colorterm(primary="j", secondary="y",
# c0=0.0, c1=0.0, c2=0.0),
# 'VISTA-H': Colorterm(primary="h", secondary="y",
# c0=0.0, c1=0.0, c2=0.0),
# 'VISTA-Ks': Colorterm(primary="ks", secondary="y",
# c0=0.0, c1=0.0, c2=0.0),
# })
# elif ref_cat.endswith('2mass'):
# colorterms.data["ps1*"] = ColortermDict(data={
# #####HSC COLOUR TERMS FROM obs_subaru
# 'HSC-G': Colorterm(primary="g", secondary="r",
# c0=0.00730066, c1=0.06508481, c2=-0.01510570),
# 'HSC-R': Colorterm(primary="r", secondary="i",
# c0=0.00279757, c1=0.02093734, c2=-0.01877566),
# 'HSC-I': Colorterm(primary="i", secondary="z",
# c0=0.00166891, c1=-0.13944659, c2=-0.03034094),
# 'HSC-Z': Colorterm(primary="z2", secondary="y2",
# c0=-0.00907517, c1=-0.28840221, c2=-0.00316369),
# 'HSC-Y': Colorterm(primary="y2", secondary="z2",
# c0=-0.00156858, c1=0.14747401, c2=0.02880125),
# ####2MASS COLOUR TERMS - all from J, Ks - see above
# 'VISTA-Z': Colorterm(primary="j", secondary="ks",
# c0=0.502-0.004, c1=0.86, c2=-0.0),
# 'VISTA-Y': Colorterm(primary="j", secondary="ks",
# c0=0.600+0.022, c1=0.46, c2=0.0),
# 'VISTA-J': Colorterm(primary="j", secondary="ks",
# c0=0.916, c1=0.031, c2=0.0),
# 'VISTA-H': Colorterm(primary="h", secondary="j",
# c0=1.366-0.019, c1=0.032, c2=0.0),
# 'VISTA-Ks': Colorterm(primary="ks", secondary="j",
# c0=1.827+0.011, c1=0.006, c2=0.0), #Sign inverted from form above
# })
# For the HSC r2 and i2 filters, use the r and i values from the catalog
# for refObjLoader in (config.calibrate.astromRefObjLoader,
# config.calibrate.photoRefObjLoader,
# config.charImage.refObjLoader,
# ):
# pass
# refObjLoader.filterMap['r2'] = 'r'
### refObjLoader.filterMap['i2'] = 'i'
| 50.907216 | 100 | 0.592345 | 736 | 4,938 | 3.96875 | 0.171196 | 0.241013 | 0.013694 | 0.040055 | 0.773708 | 0.733311 | 0.673742 | 0.647381 | 0.617939 | 0.525847 | 0 | 0.194805 | 0.173552 | 4,938 | 96 | 101 | 51.4375 | 0.520951 | 0.772377 | 0 | 0 | 0 | 0 | 0.093204 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.066667 | 0 | 0.066667 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
90097229d9d7bef5210477f68f16006b0f745123 | 190,443 | py | Python | Engine.py | yashraj466/ManageSchool | 666521917502ef8ab6a06ff073c39b66b7c50635 | [
"MIT"
] | null | null | null | Engine.py | yashraj466/ManageSchool | 666521917502ef8ab6a06ff073c39b66b7c50635 | [
"MIT"
] | null | null | null | Engine.py | yashraj466/ManageSchool | 666521917502ef8ab6a06ff073c39b66b7c50635 | [
"MIT"
] | null | null | null | import tkinter
import sqlite3
from PIL import ImageTk, Image
from tkinter import messagebox, filedialog, ttk
background_colour = "SkyBlue4"
# bi functional variables = img, lic, sm, ins
bi_img = None
bi_driver_lic = None
bi_veh_sm_card_copy = None
bi_veh_ins_copy = None
# try to create table if not exists
try:
my_database_ct = sqlite3.connect('Database.db')
my_cursor_ct = my_database_ct.cursor()
def create_table_sqlite():
# Student Table
my_cursor_ct.execute(""" CREATE TABLE IF NOT EXISTS student_data(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
global_student_id INT(25),
name VARCHAR(30) NOT NULL,
class VARCHAR(20),
roll_no INT,
class_teacher_name VARCHAR(30),
gender VARCHAR(5),
age INT,
cast VARCHAR(20),
phone_no INT,
image BLOB,
address VARCHAR(80),
education VARCHAR(15),
father_name VARCHAR(30),
mother_name VARCHAR(30),
admission_date TEXT,
admission_form_no INT,
fee_submitted INT,
fee_submission_date TEXT,
adhar_no INT,
register_no INT,
blood_group VARCHAR(4),
TAG VARCHAR(15) ); """)
# Teacher Table
my_cursor_ct.execute(""" CREATE TABLE IF NOT EXISTS teacher_data(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name VARCHAR(30) NOT NULL,
gender VARCHAR(5),
age INT,
teacher_of_class VARCHAR(20),
subject VARCHAR(10),
phone_no INT,
image BLOB,
address VARCHAR(80),
education VARCHAR(15),
salry INT,
joining_date TEXT,
adhar_no INT,
TAG VARCHAR(15) ); """)
# Bus Driver Table
my_cursor_ct.execute(""" CREATE TABLE IF NOT EXISTS driver_data(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name VARCHAR(30) NOT NULL,
gender VARCHAR(5),
age INT,
phone_no INT,
image BLOB,
address VARCHAR(80),
joining_date TEXT,
adhar_no INT,
travel_rout VARCHAR(40),
vehicle_no VARCHAR(15),
driving_license_copy BLOB,
vehicle_smart_card_copy BLOB,
vehicle_insurance_copy BLOB,
TAG VARCHAR(15) ); """)
# Worker Table
my_cursor_ct.execute(""" CREATE TABLE IF NOT EXISTS worker_data(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name VARCHAR(30) NOT NULL,
gender VARCHAR(5),
age INT,
phone_no INT,
image BLOB,
address VARCHAR(80),
joining_date TEXT,
adhar_no INT,
salry INT,
TAG VARCHAR(15) ); """)
my_database_ct.commit()
my_cursor_ct.close()
my_database_ct.close()
create_table_sqlite()
except Exception:
pass
def write_binary_image(file, img):
with open(file, 'wb') as w:
w.write(img)
def read_binary_image(filename):
try:
with open(filename, 'rb') as file:
binary_img = file.read()
return binary_img
except FileNotFoundError:
pass
def add_new_student():
but_frame.place_forget()
search_entry.place_forget()
search_button.place_forget()
def on_add_new_but():
msg_box_con = tkinter.messagebox.askquestion("Confirmation", "Do you want to save the new data ?")
if msg_box_con == "yes":
global bi_img
st_glob_id = entry_glob_id.get()
st_name = entry_name.get()
st_class = entry_class.get()
st_roll = entry_roll.get()
st_class_teacher = entry_class_teacher.get()
st_gender = entry_gender_text.get()
st_age = entry_age.get()
st_cast = entry_cast.get()
st_phone = entry_ph.get()
st_img = bi_img
st_add = entry_add.get()
st_edu = entry_edu.get()
st_f_name = entry_f_name.get()
st_m_name = entry_m_name.get()
st_adm_date = entry_ad_date.get()
st_ad_form_no = entry_ad_form_no.get()
st_fee_subm = entry_fee_subm.get()
st_fee_subm_date = entry_fee_subm_date.get()
st_adhar_no = entry_adh_no.get()
st_reg_no = entry_reg_no.get()
st_bld_g = entry_bl_g.get()
st_TAG = entry_TAG_text.get()
bi_img = None
if st_name == "":
pass
else:
my_database_as = sqlite3.connect("Database.db")
my_cur_add_stu = my_database_as.cursor()
my_cur_add_stu.execute("""SELECT id FROM student_data""")
give_id = my_cur_add_stu.fetchall()
if not give_id:
my_cur_add_stu.execute("""INSERT INTO student_data(id, name) VALUES(100, 'id_counter')""")
my_database_as.commit()
else:
pass
query = ''' INSERT INTO
student_data(global_student_id, name, class, roll_no, class_teacher_name, gender, age, cast, phone_no, image, address, education, father_name, mother_name, admission_date, admission_form_no, fee_submitted, fee_submission_date, adhar_no, register_no, blood_group, TAG)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
'''
st_tuple = (st_glob_id, st_name, st_class, st_roll, st_class_teacher, st_gender, st_age, st_cast, st_phone, st_img, st_add, st_edu, st_f_name, st_m_name, st_adm_date, st_ad_form_no, st_fee_subm, st_fee_subm_date, st_adhar_no, st_reg_no, st_bld_g, st_TAG)
my_cur_add_stu.execute(query, st_tuple)
my_database_as.commit()
query_check = f'''SELECT id, name, class, address, image FROM student_data
WHERE
name='{st_name}' AND
class='{st_class}' AND
address='{st_add}';'''
my_cur_add_stu.execute(query_check)
check = my_cur_add_stu.fetchall()
my_cur_add_stu.close()
my_database_as.close()
st_id_check = ''
st_name_check = ''
st_class_check = ''
st_add_check = ''
st_img_check = ''
for col in check:
st_id_check = col[0]
st_name_check = col[1]
st_class_check = col[2]
st_add_check = col[3]
st_img_check = col[4]
if st_name_check == st_name and st_class_check == st_class and st_add_check == st_add and st_img_check == st_img:
tkinter.messagebox.showinfo("Status", f"Data is inserted successfully in the database\nStudent Id = {st_id_check}")
else:
tkinter.messagebox.showerror("Status", f"Failed to Add data")
else:
pass
def on_add_image_button_add_new_student_frame():
global bi_img
path = filedialog.askopenfilename()
bi_img = read_binary_image(path)
try:
resize_img = Image.open(path)
resize_img = resize_img.resize((200, 260), Image.ANTIALIAS)
resize_img.save("nres_img.ppm", "ppm")
open_img = ImageTk.PhotoImage(Image.open('nres_img.ppm'))
save_img.destroy()
add_image.create_image(0, 0, image=open_img, anchor="nw")
add_new_frame.mainloop()
except AttributeError:
pass
add_new_frame = tkinter.Frame(main_window, width=1200, height=650, bg=background_colour)
add_new_frame.place(x=80, y=30)
# add new students labels and entries
label_add_data = tkinter.Label(add_new_frame, text="Add Data in Below Columns", font=("bold", 12), bg=background_colour, fg="white")
label_add_data.place(x=100, y=20)
label_glob_id = tkinter.Label(add_new_frame, text="Global Student ID:", bg=background_colour, fg="white", font=("bold", 10))
label_glob_id.place(x=0, y=65)
entry_glob_id_text = tkinter.StringVar()
entry_glob_id = tkinter.Entry(add_new_frame, text=entry_glob_id_text, width=40)
entry_glob_id.place(x=150, y=65)
label_name = tkinter.Label(add_new_frame, text="Student Name :", bg=background_colour, fg="white", font=("bold", 10))
label_name.place(x=0, y=115)
entry_name_text = tkinter.StringVar()
entry_name = tkinter.Entry(add_new_frame, text=entry_name_text, width=40)
entry_name.place(x=150, y=115)
label_class = tkinter.Label(add_new_frame, text="Student Class :", bg=background_colour, fg="white", font=("bold", 10))
label_class.place(x=0, y=165)
entry_class_text = tkinter.StringVar()
entry_class = tkinter.Entry(add_new_frame, text=entry_class_text, width=40)
entry_class.place(x=150, y=165)
label_roll = tkinter.Label(add_new_frame, text="Roll No. :", bg=background_colour, fg="white", font=("bold", 10))
label_roll.place(x=0, y=215)
entry_roll_text = tkinter.StringVar()
entry_roll = tkinter.Entry(add_new_frame, text=entry_roll_text, width=40)
entry_roll.place(x=150, y=215)
label_class_teacher = tkinter.Label(add_new_frame, text="Class Teacher Name :", bg=background_colour, fg="white", font=("bold", 10))
label_class_teacher.place(x=0, y=265)
entry_class_teacher_text = tkinter.StringVar()
entry_class_teacher = tkinter.Entry(add_new_frame, text=entry_class_teacher_text, width=40)
entry_class_teacher.place(x=150, y=265)
label_gender = tkinter.Label(add_new_frame, text="Student Gender :", bg=background_colour, fg="white", font=("bold", 10))
label_gender.place(x=0, y=315)
entry_gender_text = tkinter.StringVar()
entry_gender_text.set(0)
entry_gender_m = tkinter.Radiobutton(add_new_frame, text="Male", variable=entry_gender_text, value="M", bg=background_colour)
entry_gender_m.place(x=150, y=315)
entry_gender_f = tkinter.Radiobutton(add_new_frame, text="Female", variable=entry_gender_text, value="F", bg=background_colour)
entry_gender_f.place(x=220, y=315)
label_age = tkinter.Label(add_new_frame, text="Student Age :", bg=background_colour, fg="white", font=("bold", 10))
label_age.place(x=0, y=365)
entry_age_text = tkinter.StringVar()
entry_age = tkinter.Entry(add_new_frame, text=entry_age_text, width=40)
entry_age.place(x=150, y=365)
label_cast = tkinter.Label(add_new_frame, text="Student Cast :", bg=background_colour, fg="white", font=("bold", 10))
label_cast.place(x=0, y=415)
entry_cast_text = tkinter.StringVar()
entry_cast = tkinter.Entry(add_new_frame, text=entry_cast_text, width=40)
entry_cast.place(x=150, y=415)
label_ph = tkinter.Label(add_new_frame, text="Student Ph.No. :", bg=background_colour, fg="white", font=("bold", 10))
label_ph.place(x=0, y=465)
entry_ph_text = tkinter.StringVar()
entry_ph = tkinter.Entry(add_new_frame, text=entry_ph_text, width=40)
entry_ph.place(x=150, y=465)
add_image = tkinter.Canvas(add_new_frame, width=200, height=260)
add_image.place(x=500, y=100)
add_leb_image = tkinter.Label(add_new_frame, text="Student Image", bg=background_colour, fg="white", font=("bold", 10))
add_leb_image.place(x=500, y=65)
add_but_img = tkinter.PhotoImage(file="add_image.png")
save_img = tkinter.Button(add_new_frame, image=add_but_img, bd=0, relief="groove", command=on_add_image_button_add_new_student_frame)
save_img.place(x=580, y=200)
label_add = tkinter.Label(add_new_frame, text="Student Add :", bg=background_colour, fg="white", font=("bold", 10))
label_add.place(x=0, y=515)
entry_add_text = tkinter.StringVar()
entry_add = tkinter.Entry(add_new_frame, text=entry_add_text, width=40)
entry_add.place(x=150, y=515)
label_edu = tkinter.Label(add_new_frame, text=" Student Education :", bg=background_colour, fg="white", font=("bold", 10))
label_edu.place(x=0, y=565)
entry_edu_text = tkinter.StringVar()
entry_edu = tkinter.Entry(add_new_frame, text=entry_edu_text, width=40)
entry_edu.place(x=150, y=565)
label_f_name = tkinter.Label(add_new_frame, text=" Father's Name :", bg=background_colour, fg="white", font=("bold", 10))
label_f_name.place(x=750, y=65)
entry_f_name_text = tkinter.StringVar()
entry_f_name = tkinter.Entry(add_new_frame, text=entry_f_name_text, width=40)
entry_f_name.place(x=900, y=65)
label_m_name = tkinter.Label(add_new_frame, text=" Mother's Name :", bg=background_colour, fg="white", font=("bold", 10))
label_m_name.place(x=750, y=115)
entry_m_name_text = tkinter.StringVar()
entry_m_name = tkinter.Entry(add_new_frame, text=entry_m_name_text, width=40)
entry_m_name.place(x=900, y=115)
label_ad_date = tkinter.Label(add_new_frame, text=" Admission Date :", bg=background_colour, fg="white", font=("bold", 10))
label_ad_date.place(x=750, y=165)
entry_ad_date_text = tkinter.StringVar()
entry_ad_date = tkinter.Entry(add_new_frame, text=entry_ad_date_text, width=40)
entry_ad_date.place(x=900, y=165)
label_ad_form_no = tkinter.Label(add_new_frame, text=" Admission Form No. :", bg=background_colour, fg="white", font=("bold", 10))
label_ad_form_no.place(x=750, y=215)
entry_ad_form_no_text = tkinter.StringVar()
entry_ad_form_no = tkinter.Entry(add_new_frame, text=entry_ad_form_no_text, width=40)
entry_ad_form_no.place(x=900, y=215)
label_fee_subm = tkinter.Label(add_new_frame, text=" Fee Submitted :", bg=background_colour, fg="white", font=("bold", 10))
label_fee_subm.place(x=750, y=265)
entry_fee_subm_text = tkinter.StringVar()
entry_fee_subm = tkinter.Entry(add_new_frame, text=entry_fee_subm_text, width=40)
entry_fee_subm.place(x=900, y=265)
label_fee_subm_date = tkinter.Label(add_new_frame, text=" Fee Submission Date :", bg=background_colour, fg="white", font=("bold", 10))
label_fee_subm_date.place(x=750, y=315)
entry_fee_subm_date_text = tkinter.StringVar()
entry_fee_subm_date = tkinter.Entry(add_new_frame, text=entry_fee_subm_date_text, width=40)
entry_fee_subm_date.place(x=900, y=315)
label_adh_no = tkinter.Label(add_new_frame, text=" Adhar No. :", bg=background_colour, fg="white", font=("bold", 10))
label_adh_no.place(x=750, y=365)
entry_adh_no_text = tkinter.StringVar()
entry_adh_no = tkinter.Entry(add_new_frame, text=entry_adh_no_text, width=40)
entry_adh_no.place(x=900, y=365)
label_reg_no = tkinter.Label(add_new_frame, text=" G.Reg. No. :", bg=background_colour, fg="white", font=("bold", 10))
label_reg_no.place(x=750, y=415)
entry_reg_no_text = tkinter.StringVar()
entry_reg_no = tkinter.Entry(add_new_frame, text=entry_reg_no_text, width=40)
entry_reg_no.place(x=900, y=415)
label_bl_g = tkinter.Label(add_new_frame, text="Blood Group :", bg=background_colour, fg="white", font=("bold", 10))
label_bl_g.place(x=750, y=465)
entry_bl_g_text = tkinter.StringVar()
entry_bl_g = tkinter.Entry(add_new_frame, text=entry_bl_g_text, width=40)
entry_bl_g.place(x=900, y=465)
label_TAG = tkinter.Label(add_new_frame, text="TAG :", bg=background_colour, fg="white", font=("bold", 10))
label_TAG.place(x=750, y=515)
options_for_TAG = ["STUDENT", "TEACHER", "DRIVER", "WORKER", "PRINCIPAL", "ASSISTANT", "OTHER"]
entry_TAG_text = tkinter.StringVar()
entry_TAG = tkinter.OptionMenu(add_new_frame, entry_TAG_text, *options_for_TAG)
entry_TAG.config(relief="raised", bd=0)
entry_TAG.place(x=900, y=515)
def cancel_fun():
add_new_frame.destroy()
but_frame.place(x=80, y=80)
search_entry.place(x=50, y=30)
search_button.place(x=300, y=28)
but_frame_func()
# save changes button
save_but = tkinter.Button(add_new_frame, text="Save", command=on_add_new_but, width=10, relief="groove")
save_but.place(x=1070, y=620)
cancel_but = tkinter.Button(add_new_frame, text="Cancel", command=cancel_fun, width=10, relief="groove")
cancel_but.place(x=970, y=620)
add_new_frame.mainloop()
def show_all_student():
search_entry.config(state='disabled')
search_button.config(state='disabled')
but_frame.place_forget()
def select_rec():
reco = tree_view.focus()
if reco == "":
pass
else:
temp = tree_view.item(reco)
cmp = temp['values']
search_entry.config(state='normal')
search_button.config(state='normal')
search_entry.insert(0, cmp[0])
tree_view_frame.destroy()
on_search_button()
tree_view_frame = tkinter.Frame(main_window, width=1100, height=530, bg=background_colour)
tree_view_frame.place(x=80, y=100)
tree_view = ttk.Treeview(tree_view_frame, columns=("", "", "", "", ""), height=24, selectmode="browse")
tree_view.place(x=0, y=30)
scroll_bar = ttk.Scrollbar(tree_view_frame, orient='vertical', command=tree_view.yview)
scroll_bar.place(x=975, y=30, height=500)
tree_view.configure(yscrollcommand=scroll_bar.set)
tree_view.heading('#0', text='No.', anchor="w")
tree_view.column("#0", width=60)
tree_view.heading('#1', text='Id No.', anchor="center")
tree_view.column("#1", width=60)
tree_view.heading('#2', text='Name', anchor="center")
tree_view.column("#2", width=250)
tree_view.heading('#3', text='Class', anchor="center")
tree_view.column("#3", width=100)
tree_view.heading('#4', text='Address', anchor="center")
tree_view.column("#4", width=300)
tree_view.heading('#5', text='Phone No.', anchor="center")
tree_view.column("#5", width=200)
style = ttk.Style()
style.configure("Treeview.Heading", foreground='black', font=('bold', 10))
my_database_show_all_student = sqlite3.connect("Database.db")
my_cur_show_stu = my_database_show_all_student.cursor()
my_cur_show_stu.execute("SELECT id, name, class, address, phone_no FROM student_data WHERE id>100 ORDER BY name")
read = my_cur_show_stu.fetchall()
my_cur_show_stu.close()
my_database_show_all_student.close()
total_record = tkinter.Label(tree_view_frame, text=f"Total Record = {len(read)}", bg=background_colour, font=("bold", 10), fg="gold")
total_record.place(x=0, y=0)
i = 1
for col in read:
tree_view.insert("", "end", text=i, values=(col[0], col[1], col[2], col[3], col[4]))
i += 1
def cancel():
tree_view_frame.destroy()
search_entry.config(state='normal')
search_button.config(state='normal')
but_frame.place(x=80, y=80)
open_but = tkinter.Button(tree_view_frame, text="Open", relief="groove", width=10, command=select_rec)
open_but.place(x=1000, y=30)
cancel_but = tkinter.Button(tree_view_frame, text="Cancel", relief="groove", width=10, command=cancel)
cancel_but.place(x=1000, y=80)
def add_new_teacher():
but_frame.place_forget()
search_entry.place_forget()
search_button.place_forget()
def on_add_new_but():
msg_box_con = tkinter.messagebox.askquestion("Confirmation", "Do you want to save the new data ?")
if msg_box_con == "yes":
global bi_img
name = entry_name.get()
gen = entry_gender_text.get()
age = entry_age.get()
t_class = entry_class.get()
sub = entry_sub.get()
ph = entry_ph.get()
img = bi_img
add = entry_add.get()
edu = entry_edu.get()
sal = entry_sal.get()
jo_date = entry_jd.get()
adh_no = entry_adh_no.get()
TAG = entry_TAG_text.get()
bi_img = None
if name == "":
pass
else:
my_database_insert_teacher = sqlite3.connect("Database.db")
my_cur_insert_teacher = my_database_insert_teacher.cursor()
my_cur_insert_teacher.execute("""SELECT id FROM teacher_data""")
give_id = my_cur_insert_teacher.fetchall()
if not give_id:
my_cur_insert_teacher.execute("""INSERT INTO teacher_data(id, name) VALUES(5000, 'id_counter')""")
my_database_insert_teacher.commit()
else:
pass
query = f'''INSERT INTO teacher_data(name, gender, age, teacher_of_class, subject, phone_no, image, address, education, salry, joining_date, adhar_no, TAG)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); '''
tuple_ = (name, gen, age, t_class, sub, ph, img, add, edu, sal, jo_date, adh_no, TAG)
my_cur_insert_teacher.execute(query, tuple_)
my_database_insert_teacher.commit()
query_check = f'''SELECT id, name, teacher_of_class, image FROM teacher_data
WHERE
name='{name}' AND
teacher_of_class='{t_class}';
'''
my_cur_insert_teacher.execute(query_check)
check = my_cur_insert_teacher.fetchall()
my_cur_insert_teacher.close()
my_database_insert_teacher.close()
id_check = ''
name_check = ''
te_of_class = ''
img_check = ''
for col in check:
id_check = col[0]
name_check = col[1]
te_of_class = col[2]
img_check = col[3]
if name_check == name and te_of_class == t_class and img_check == img :
tkinter.messagebox.showinfo("Status",
f"Data is inserted successfully in the database\nTeacher Id = {id_check}")
else:
tkinter.messagebox.showerror("Status", f"Failed to Add data")
def on_add_image_button_add_new_student_frame():
global bi_img
path = filedialog.askopenfilename()
bi_img = read_binary_image(path)
try:
resize_img = Image.open(path)
resize_img = resize_img.resize((200, 260), Image.ANTIALIAS)
resize_img.save("nres_img.ppm", "ppm")
open_img = ImageTk.PhotoImage(Image.open('nres_img.ppm'))
save_img.destroy()
add_image.create_image(0, 0, image=open_img, anchor="nw")
add_new_frame.mainloop()
except AttributeError:
pass
add_new_frame = tkinter.Frame(main_window, width=1200, height=650, bg=background_colour)
add_new_frame.place(x=80, y=30)
# add new students labels and entries
label_add_data = tkinter.Label(add_new_frame, text="Add Data in Below Columns", font=("bold", 12),
bg=background_colour, fg="white")
label_add_data.place(x=100, y=20)
label_name = tkinter.Label(add_new_frame, text="Teacher Name :", bg=background_colour, fg="white", font=("bold", 10))
label_name.place(x=0, y=65)
entry_name_text = tkinter.StringVar()
entry_name = tkinter.Entry(add_new_frame, text=entry_name_text, width=40)
entry_name.place(x=150, y=65)
label_gender = tkinter.Label(add_new_frame, text="Teacher Gender :", bg=background_colour, fg="white", font=("bold", 10))
label_gender.place(x=0, y=115)
entry_gender_text = tkinter.StringVar()
entry_gender_text.set(0)
entry_gender_m = tkinter.Radiobutton(add_new_frame, text="Male", variable=entry_gender_text, value="M", bg=background_colour)
entry_gender_m.place(x=150, y=115)
entry_gender_f = tkinter.Radiobutton(add_new_frame, text="Female", variable=entry_gender_text, value="F", bg=background_colour)
entry_gender_f.place(x=220, y=115)
label_age = tkinter.Label(add_new_frame, text="Teacher Age :", bg=background_colour, fg="white", font=("bold", 10))
label_age.place(x=0, y=165)
entry_age_text = tkinter.StringVar()
entry_age = tkinter.Entry(add_new_frame, text=entry_age_text, width=40)
entry_age.place(x=150, y=165)
label_class = tkinter.Label(add_new_frame, text="Teacher Of Class :", bg=background_colour, fg="white", font=("bold", 10))
label_class.place(x=0, y=215)
entry_class_text = tkinter.StringVar()
entry_class = tkinter.Entry(add_new_frame, text=entry_class_text, width=40)
entry_class.place(x=150, y=215)
label_sub = tkinter.Label(add_new_frame, text="Teaching subject :", bg=background_colour, fg="white", font=("bold", 10))
label_sub.place(x=0, y=265)
entry_sub_text = tkinter.StringVar()
entry_sub = tkinter.Entry(add_new_frame, text=entry_sub_text, width=40)
entry_sub.place(x=150, y=265)
label_ph = tkinter.Label(add_new_frame, text="Teacher Ph.No. :", bg=background_colour, fg="white", font=("bold", 10))
label_ph.place(x=0, y=315)
entry_ph_text = tkinter.StringVar()
entry_ph = tkinter.Entry(add_new_frame, text=entry_ph_text, width=40)
entry_ph.place(x=150, y=315)
add_image = tkinter.Canvas(add_new_frame, width=200, height=260)
add_image.place(x=500, y=100)
add_leb_image = tkinter.Label(add_new_frame, text="Teacher Image :", bg=background_colour, fg="white", font=("bold", 10))
add_leb_image.place(x=500, y=65)
add_but_img = tkinter.PhotoImage(file="add_image.png")
save_img = tkinter.Button(add_new_frame, image=add_but_img, bd=0, relief="groove",
command=on_add_image_button_add_new_student_frame)
save_img.place(x=580, y=200)
label_add = tkinter.Label(add_new_frame, text="Teacher Add :", bg=background_colour, fg="white", font=("bold", 10))
label_add.place(x=0, y=365)
entry_add_text = tkinter.StringVar()
entry_add = tkinter.Entry(add_new_frame, text=entry_add_text, width=40)
entry_add.place(x=150, y=365)
label_edu = tkinter.Label(add_new_frame, text="Teacher edu. :", bg=background_colour, fg="white", font=("bold", 10))
label_edu.place(x=0, y=415)
entry_edu_text = tkinter.StringVar()
entry_edu = tkinter.Entry(add_new_frame, text=entry_edu_text, width=40)
entry_edu.place(x=150, y=415)
label_sal = tkinter.Label(add_new_frame, text="Teacher Salary :", bg=background_colour, fg="white", font=("bold", 10))
label_sal.place(x=0, y=465)
entry_sal_text = tkinter.StringVar()
entry_sal = tkinter.Entry(add_new_frame, text=entry_sal_text, width=40)
entry_sal.place(x=150, y=465)
label_jd = tkinter.Label(add_new_frame, text="Joining Date :", bg=background_colour, fg="white", font=("bold", 10))
label_jd.place(x=0, y=515)
entry_jd_text = tkinter.StringVar()
entry_jd = tkinter.Entry(add_new_frame, text=entry_jd_text, width=40)
entry_jd.place(x=150, y=515)
label_adh_no = tkinter.Label(add_new_frame, text="Adhar No. :", bg=background_colour, fg="white", font=("bold", 10))
label_adh_no.place(x=0, y=565)
entry_adh_no_text = tkinter.StringVar()
entry_adh_no = tkinter.Entry(add_new_frame, text=entry_adh_no_text, width=40)
entry_adh_no.place(x=150, y=565)
label_TAG = tkinter.Label(add_new_frame, text="TAG :", bg=background_colour, fg="white", font=("bold", 10))
label_TAG.place(x=750, y=65)
option_for_TAG = ["STUDENT", "TEACHER", "DRIVER", "WORKER", "PRINCIPAL", "ASSISTANT", "OTHER"]
entry_TAG_text = tkinter.StringVar()
entry_TAG = tkinter.OptionMenu(add_new_frame, entry_TAG_text, *option_for_TAG)
entry_TAG.config(relief="raised", bd=0)
entry_TAG.place(x=900, y=65)
def cancel_fun():
add_new_frame.destroy()
but_frame.place(x=80, y=80)
search_entry.place(x=50, y=30)
search_button.place(x=300, y=28)
but_frame_func()
# save changes button
save_but = tkinter.Button(add_new_frame, text="Save", command=on_add_new_but, width=10, relief="groove")
save_but.place(x=1070, y=620)
cancel_but = tkinter.Button(add_new_frame, text="Cancel", command=cancel_fun, width=10, relief="groove")
cancel_but.place(x=970, y=620)
add_new_frame.mainloop()
def show_all_teacher():
search_entry.config(state='disabled')
search_button.config(state='disabled')
but_frame.place_forget()
def select_rec():
reco = tree_view.focus()
if reco == "":
pass
else:
temp = tree_view.item(reco)
cmp = temp['values']
search_entry.config(state='normal')
search_button.config(state='normal')
search_entry.insert(0, cmp[0])
tree_view_frame.destroy()
on_search_button()
tree_view_frame = tkinter.Frame(main_window, width=1100, height=530, bg=background_colour)
tree_view_frame.place(x=80, y=100)
tree_view = ttk.Treeview(tree_view_frame, columns=("", "", "", "", ""), height=24, selectmode="browse")
tree_view.place(x=0, y=30)
scroll_bar = ttk.Scrollbar(tree_view_frame, orient='vertical', command=tree_view.yview)
scroll_bar.place(x=975, y=30, height=500)
tree_view.configure(yscrollcommand=scroll_bar.set)
tree_view.heading('#0', text='No.', anchor="w")
tree_view.column("#0", width=60)
tree_view.heading('#1', text='Id No.', anchor="center")
tree_view.column("#1", width=60)
tree_view.heading('#2', text='Name', anchor="center")
tree_view.column("#2", width=250)
tree_view.heading('#3', text='Address', anchor="center")
tree_view.column("#3", width=300)
tree_view.heading('#4', text='Phone No.', anchor="center")
tree_view.column("#4", width=100)
tree_view.heading('#5', text='Education', anchor="center")
tree_view.column("#5", width=200)
style = ttk.Style()
style.configure("Treeview.Heading", foreground='black', font=('bold', 10))
my_database_show_all_teacher = sqlite3.connect("Database.db")
my_cur_show_all_teacher = my_database_show_all_teacher.cursor()
my_cur_show_all_teacher.execute(
"SELECT id, name, address, phone_no, education FROM teacher_data WHERE id>5000 ORDER BY name")
read = my_cur_show_all_teacher.fetchall()
my_cur_show_all_teacher.close()
my_database_show_all_teacher.close()
total_record = tkinter.Label(tree_view_frame, text=f"Total Record = {len(read)}", bg=background_colour,
font=("bold", 10), fg="gold")
total_record.place(x=0, y=0)
i = 1
for col in read:
tree_view.insert("", "end", text=i, values=(col[0], col[1], col[2], col[3], col[4]))
i += 1
def cancel():
tree_view_frame.destroy()
search_entry.config(state='normal')
search_button.config(state='normal')
but_frame.place(x=80, y=80)
open_but = tkinter.Button(tree_view_frame, text="Open", relief="groove", width=10, command=select_rec)
open_but.place(x=1000, y=30)
cancel_but = tkinter.Button(tree_view_frame, text="Cancel", relief="groove", width=10, command=cancel)
cancel_but.place(x=1000, y=80)
def add_new_driver():
but_frame.place_forget()
search_entry.place_forget()
search_button.place_forget()
def on_add_new_but():
msg_box_con = tkinter.messagebox.askquestion("Confirmation", "Do you want to save the new data ?")
if msg_box_con == "yes":
global bi_img
global bi_driver_lic
global bi_veh_sm_card_copy
global bi_veh_ins_copy
name = entry_name.get()
gen = entry_gender_text.get()
age = entry_age.get()
ph = entry_ph.get()
img = bi_img
add = entry_add.get()
jo_date = entry_jo_date.get()
adh_no = entry_adh_no.get()
tr_rout = entry_t_rout.get()
v_no = entry_v_no.get()
v_lic = bi_driver_lic
v_sm = bi_veh_sm_card_copy
v_ins = bi_veh_ins_copy
TAG = entry_TAG_text.get()
bi_img = None
bi_driver_lic = None
bi_veh_sm_card_copy = None
bi_veh_ins_copy = None
if name == "":
tkinter.messagebox.showwarning("Warring", "Insert at least Name. ?")
pass
else:
my_database_add_driver = sqlite3.connect("Database.db")
my_cur_add_driver = my_database_add_driver.cursor()
my_cur_add_driver.execute("""SELECT id FROM driver_data""")
give_id = my_cur_add_driver.fetchall()
if not give_id:
my_cur_add_driver.execute("""INSERT INTO driver_data(id, name) VALUES(6000, 'id_counter')""")
my_database_add_driver.commit()
else:
pass
query = f'''INSERT INTO driver_data(name, gender, age, phone_no, image, address, joining_date, adhar_no, travel_rout, vehicle_no, driving_license_copy, vehicle_smart_card_copy, vehicle_insurance_copy, TAG)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'''
tuple_ = (name, gen, age, ph, img, add, jo_date, adh_no, tr_rout, v_no, v_lic, v_sm, v_ins, TAG)
my_cur_add_driver.execute(query, tuple_)
my_database_add_driver.commit()
query_check = f'''SELECT id, name, address, gender, image FROM driver_data
WHERE
name='{name}' AND
address='{add}' AND
gender='{gen}';
'''
my_cur_add_driver.execute(query_check)
check = my_cur_add_driver.fetchall()
my_cur_add_driver.close()
my_database_add_driver.close()
id_check = ''
name_check = ''
add_check = ''
gen_check = ''
img_check = ''
for col in check:
id_check = col[0]
name_check = col[1]
add_check = col[2]
gen_check = col[3]
img_check = col[4]
if name_check == name and add_check == add and gen_check == gen and img_check == img:
tkinter.messagebox.showinfo("Status",
f"Data is inserted successfully in the database\nTeacher Id = {id_check}")
else:
tkinter.messagebox.showerror("Status", f"Failed to Add data")
def on_add_image_button_add_new_student_frame():
global bi_img
path = filedialog.askopenfilename()
bi_img = read_binary_image(path)
try:
resize_img = Image.open(path)
resize_img = resize_img.resize((200, 260), Image.ANTIALIAS)
resize_img.save("nres_img.ppm", "ppm")
open_img = ImageTk.PhotoImage(Image.open('nres_img.ppm'))
save_img.destroy()
add_image.create_image(0, 0, image=open_img, anchor="nw")
add_new_frame.mainloop()
except AttributeError:
pass
add_new_frame = tkinter.Frame(main_window, width=1200, height=650, bg=background_colour)
add_new_frame.place(x=80, y=30)
# add new students labels and entries
label_add_data = tkinter.Label(add_new_frame, text="Add Data in Below Columns", font=("bold", 12),
bg=background_colour, fg="white")
label_add_data.place(x=100, y=20)
label_name = tkinter.Label(add_new_frame, text="Driver Name :", bg=background_colour, fg="white", font=("bold", 10))
label_name.place(x=0, y=65)
entry_name_text = tkinter.StringVar()
entry_name = tkinter.Entry(add_new_frame, text=entry_name_text, width=40)
entry_name.place(x=150, y=65)
leble_gender = tkinter.Label(add_new_frame, text="Driver Gender :", bg=background_colour, fg="white", font=("bold", 10))
leble_gender.place(x=0, y=115)
entry_gender_text = tkinter.StringVar()
entry_gender_text.set(0)
entry_gender_m = tkinter.Radiobutton(add_new_frame, text="Male", variable=entry_gender_text, value="M", bg=background_colour)
entry_gender_m.place(x=150, y=115)
entry_gender_f = tkinter.Radiobutton(add_new_frame, text="Female", variable=entry_gender_text, value="F", bg=background_colour)
entry_gender_f.place(x=220, y=115)
label_age = tkinter.Label(add_new_frame, text="Driver Age :", bg=background_colour, fg="white", font=("bold", 10))
label_age.place(x=0, y=165)
entry_age_text = tkinter.StringVar()
entry_age = tkinter.Entry(add_new_frame, text=entry_age_text, width=40)
entry_age.place(x=150, y=165)
label_ph = tkinter.Label(add_new_frame, text="Driver Ph.No. :", bg=background_colour, fg="white", font=("bold", 10))
label_ph.place(x=0, y=215)
entry_ph_text = tkinter.StringVar()
entry_ph = tkinter.Entry(add_new_frame, text=entry_ph_text, width=40)
entry_ph.place(x=150, y=215)
add_image = tkinter.Canvas(add_new_frame, width=200, height=260)
add_image.place(x=500, y=100)
add_leb_image = tkinter.Label(add_new_frame, text="Driver Image :", bg=background_colour, fg="white", font=("bold", 10))
add_leb_image.place(x=500, y=65)
add_but_img = tkinter.PhotoImage(file="add_image.png")
save_img = tkinter.Button(add_new_frame, image=add_but_img, bd=0, relief="groove", command=on_add_image_button_add_new_student_frame)
save_img.place(x=580, y=200)
label_add = tkinter.Label(add_new_frame, text="Driver Add :", bg=background_colour, fg="white", font=("bold", 10))
label_add.place(x=0, y=265)
entry_add_text = tkinter.StringVar()
entry_add = tkinter.Entry(add_new_frame, text=entry_add_text, width=40)
entry_add.place(x=150, y=265)
label_jo_date = tkinter.Label(add_new_frame, text="Joining Date :", bg=background_colour, fg="white", font=("bold", 10))
label_jo_date.place(x=0, y=315)
entry_jo_date_text = tkinter.StringVar()
entry_jo_date = tkinter.Entry(add_new_frame, text=entry_jo_date_text, width=40)
entry_jo_date.place(x=150, y=315)
label_adh_no = tkinter.Label(add_new_frame, text="Adhar No. :", bg=background_colour, fg="white", font=("bold", 10))
label_adh_no.place(x=0, y=365)
entry_adh_no_text = tkinter.StringVar()
entry_adh_no = tkinter.Entry(add_new_frame, text=entry_adh_no_text, width=40)
entry_adh_no.place(x=150, y=365)
label_t_rout = tkinter.Label(add_new_frame, text="Travel Rout :", bg=background_colour, fg="white", font=("bold", 10))
label_t_rout.place(x=0, y=415)
entry_t_rout_text = tkinter.StringVar()
entry_t_rout = tkinter.Entry(add_new_frame, text=entry_t_rout_text, width=40)
entry_t_rout.place(x=150, y=415)
label_v_no = tkinter.Label(add_new_frame, text="Vehicle No. :", bg=background_colour, fg="white", font=("bold", 10))
label_v_no.place(x=0, y=465)
entry_v_no_text = tkinter.StringVar()
entry_v_no = tkinter.Entry(add_new_frame, text=entry_v_no_text, width=40)
entry_v_no.place(x=150, y=465)
label_v_lic = tkinter.Label(add_new_frame, text="Vehicle Documents :", bg=background_colour, fg="white", font=("bold", 10))
label_v_lic.place(x=720, y=65)
def on_add_lic():
global bi_driver_lic
path = filedialog.askopenfilename()
bi_driver_lic = read_binary_image(path)
entry_v_lic = tkinter.Button(add_new_frame, text="Add Driving License", bd=1, command=on_add_lic)
entry_v_lic.place(x=850, y=65)
def on_add_sm_card():
global bi_veh_sm_card_copy
path = filedialog.askopenfilename()
bi_veh_sm_card_copy = read_binary_image(path)
entry_v_sm = tkinter.Button(add_new_frame, text="Add veh. Smart card", bd=1, command=on_add_sm_card)
entry_v_sm.place(x=850, y=100)
def on_add_ins():
global bi_veh_ins_copy
path = filedialog.askopenfilename()
bi_veh_ins_copy = read_binary_image(path)
entry_v_in = tkinter.Button(add_new_frame, text="Add veh. Insurance", bd=1, command=on_add_ins)
entry_v_in.place(x=850, y=135)
label_TAG = tkinter.Label(add_new_frame, text="TAG :", bg=background_colour, fg="white", font=("bold", 10))
label_TAG.place(x=0, y=515)
option_for_TAG = ["STUDENT", "TEACHER", "DRIVER", "WORKER", "PRINCIPAL", "ASSISTANT", "OTHER"]
entry_TAG_text = tkinter.StringVar()
entry_TAG = tkinter.OptionMenu(add_new_frame, entry_TAG_text, *option_for_TAG)
entry_TAG.config(relief="raised", bd=0)
entry_TAG.place(x=150, y=515)
def cancel_fun():
add_new_frame.destroy()
but_frame.place(x=80, y=80)
search_entry.place(x=50, y=30)
search_button.place(x=300, y=28)
but_frame_func()
# save changes button
save_but = tkinter.Button(add_new_frame, text="Save", command=on_add_new_but, width=10, relief="groove")
save_but.place(x=1070, y=620)
cancel_but = tkinter.Button(add_new_frame, text="Cancel", command=cancel_fun, width=10, relief="groove")
cancel_but.place(x=970, y=620)
add_new_frame.mainloop()
def show_all_driver():
search_entry.config(state='disabled')
search_button.config(state='disabled')
but_frame.place_forget()
def select_rec():
reco = tree_view.focus()
if reco == "":
pass
else:
temp = tree_view.item(reco)
cmp = temp['values']
search_entry.config(state='normal')
search_button.config(state='normal')
search_entry.insert(0, cmp[0])
tree_view_frame.destroy()
on_search_button()
tree_view_frame = tkinter.Frame(main_window, width=1100, height=530, bg=background_colour)
tree_view_frame.place(x=80, y=100)
tree_view = ttk.Treeview(tree_view_frame, columns=("", "", "", "", ""), height=24, selectmode="browse")
tree_view.place(x=0, y=30)
scroll_bar = ttk.Scrollbar(tree_view_frame, orient='vertical', command=tree_view.yview)
scroll_bar.place(x=975, y=30, height=500)
tree_view.configure(yscrollcommand=scroll_bar.set)
tree_view.heading('#0', text='No.', anchor="w")
tree_view.column("#0", width=60)
tree_view.heading('#1', text='Id No.', anchor="center")
tree_view.column("#1", width=60)
tree_view.heading('#2', text='Name', anchor="center")
tree_view.column("#2", width=250)
tree_view.heading('#3', text='Address', anchor="center")
tree_view.column("#3", width=300)
tree_view.heading('#4', text='Phone No.', anchor="center")
tree_view.column("#4", width=100)
tree_view.heading('#5', text='Traveling Rout', anchor="center")
tree_view.column("#5", width=200)
style = ttk.Style()
style.configure("Treeview.Heading", foreground='black', font=('bold', 10))
my_database_show_driver = sqlite3.connect("Database.db")
my_cur_show_driver = my_database_show_driver.cursor()
my_cur_show_driver.execute(
"SELECT id, name, address, phone_no, travel_rout FROM driver_data WHERE id>6000 ORDER BY name")
read = my_cur_show_driver.fetchall()
my_cur_show_driver.close()
my_database_show_driver.close()
total_record = tkinter.Label(tree_view_frame, text=f"Total Record = {len(read)}", bg=background_colour,
font=("bold", 10), fg="gold")
total_record.place(x=0, y=0)
i = 1
for col in read:
tree_view.insert("", "end", text=i, values=(col[0], col[1], col[2], col[3], col[4]))
i += 1
def cancel():
tree_view_frame.destroy()
search_entry.config(state='normal')
search_button.config(state='normal')
but_frame.place(x=80, y=80)
open_but = tkinter.Button(tree_view_frame, text="Open", relief="groove", width=10, command=select_rec)
open_but.place(x=1000, y=30)
cancel_but = tkinter.Button(tree_view_frame, text="Cancel", relief="groove", width=10, command=cancel)
cancel_but.place(x=1000, y=80)
def add_new_worker():
but_frame.place_forget()
search_entry.place_forget()
search_button.place_forget()
def on_add_new_but():
msg_box_con = tkinter.messagebox.askquestion("Confirmation", "Do you want to save the new data ?")
if msg_box_con == "yes":
global bi_img
name = entry_name.get()
gen = entry_gender_text.get()
age = entry_age.get()
ph = entry_ph.get()
img = bi_img
add = entry_add.get()
jo_date = entry_jo_date.get()
adh = entry_adh.get()
sal = entry_sal.get()
TAG = entry_TAG_text.get()
bi_img = None
if name == "":
tkinter.messagebox.showwarning("Warring", "You should have to type attlist name")
pass
else:
my_database_add_worker = sqlite3.connect("Database.db")
my_cur_add_worker = my_database_add_worker.cursor()
my_cur_add_worker.execute("""SELECT id FROM worker_data""")
give_id = my_cur_add_worker.fetchall()
if not give_id:
my_cur_add_worker.execute("""INSERT INTO worker_data(id, name) VALUES(7000, 'id_counter')""")
my_database_add_worker.commit()
else:
pass
query = f'''INSERT INTO worker_data(name, gender, age, phone_no, image, address, joining_date, adhar_no, salry, TAG)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);'''
tuple_ = (name, gen, age, ph, img, add, jo_date, adh, sal, TAG)
my_cur_add_worker.execute(query, tuple_)
my_database_add_worker.commit()
query_check = f'''SELECT id, name, address FROM worker_data
WHERE
name='{name}' AND
address='{add}';
'''
my_cur_add_worker.execute(query_check)
check = my_cur_add_worker.fetchall()
my_cur_add_worker.close()
my_database_add_worker.close()
id_check = ''
name_check = ''
add_check = ''
for col in check:
id_check = col[0]
name_check = col[1]
add_check = col[2]
if name_check == name and add_check == add:
tkinter.messagebox.showinfo("Status",
f"Data is inserted successfully in the database\nTeacher Id = {id_check}")
else:
tkinter.messagebox.showerror("Status", f"Failed to Add data")
else:
pass
def on_add_image_button_add_new_student_frame():
global bi_img
path = filedialog.askopenfilename()
bi_img = read_binary_image(path)
try:
resize_img = Image.open(path)
resize_img = resize_img.resize((200, 260), Image.ANTIALIAS)
resize_img.save("nres_img.ppm", "ppm")
open_img = ImageTk.PhotoImage(Image.open('nres_img.ppm'))
save_img.destroy()
add_image.create_image(0, 0, image=open_img, anchor="nw")
add_new_frame.mainloop()
except AttributeError:
pass
add_new_frame = tkinter.Frame(main_window, width=1200, height=650, bg=background_colour)
add_new_frame.place(x=80, y=30)
# add new students labels and entries
label_add_data = tkinter.Label(add_new_frame, text="Add Data in Below Columns", font=("bold", 12),
bg=background_colour, fg="white")
label_add_data.place(x=100, y=20)
label_name = tkinter.Label(add_new_frame, text="Worker Name :", bg=background_colour, fg="white", font=("bold", 10))
label_name.place(x=0, y=65)
entry_name_text = tkinter.StringVar()
entry_name = tkinter.Entry(add_new_frame, text=entry_name_text, width=40)
entry_name.place(x=150, y=65)
lebel_gender = tkinter.Label(add_new_frame, text="Worker Gender :", bg=background_colour, fg="white",
font=("bold", 10))
lebel_gender.place(x=0, y=115)
entry_gender_text = tkinter.StringVar()
entry_gender_text.set(0)
entry_gender_m = tkinter.Radiobutton(add_new_frame, text="Male", variable=entry_gender_text, value="M",
bg=background_colour)
entry_gender_m.place(x=150, y=115)
entry_gender_f = tkinter.Radiobutton(add_new_frame, text="Female", variable=entry_gender_text, value="F",
bg=background_colour)
entry_gender_f.place(x=220, y=115)
label_age = tkinter.Label(add_new_frame, text="Worker Age :", bg=background_colour, fg="white", font=("bold", 10))
label_age.place(x=0, y=165)
entry_age_text = tkinter.StringVar()
entry_age = tkinter.Entry(add_new_frame, text=entry_age_text, width=40)
entry_age.place(x=150, y=165)
label_ph = tkinter.Label(add_new_frame, text="Worker Ph.No. :", bg=background_colour, fg="white",
font=("bold", 10))
label_ph.place(x=0, y=215)
entry_ph_text = tkinter.StringVar()
entry_ph = tkinter.Entry(add_new_frame, text=entry_ph_text, width=40)
entry_ph.place(x=150, y=215)
add_image = tkinter.Canvas(add_new_frame, width=200, height=260)
add_image.place(x=500, y=100)
add_leb_image = tkinter.Label(add_new_frame, text="Worker Image :", bg=background_colour, fg="white",
font=("bold", 10))
add_leb_image.place(x=500, y=65)
add_but_img = tkinter.PhotoImage(file="add_image.png")
save_img = tkinter.Button(add_new_frame, image=add_but_img, bd=0, relief="groove",
command=on_add_image_button_add_new_student_frame)
save_img.place(x=580, y=200)
label_add = tkinter.Label(add_new_frame, text="Worker Add :", bg=background_colour, fg="white", font=("bold", 10))
label_add.place(x=0, y=265)
entry_add_text = tkinter.StringVar()
entry_add = tkinter.Entry(add_new_frame, text=entry_add_text, width=40)
entry_add.place(x=150, y=265)
label_jo_date = tkinter.Label(add_new_frame, text="Joining Date :", bg=background_colour, fg="white", font=("bold", 10))
label_jo_date.place(x=0, y=315)
entry_jo_date_text = tkinter.StringVar()
entry_jo_date = tkinter.Entry(add_new_frame, text=entry_jo_date_text, width=40)
entry_jo_date.place(x=150, y=315)
label_adh = tkinter.Label(add_new_frame, text="Adhar No. :", bg=background_colour, fg="white",
font=("bold", 10))
label_adh.place(x=0, y=365)
entry_adh_text = tkinter.StringVar()
entry_adh = tkinter.Entry(add_new_frame, text=entry_adh_text, width=40)
entry_adh.place(x=150, y=365)
label_sal = tkinter.Label(add_new_frame, text="Salary :", bg=background_colour, fg="white",
font=("bold", 10))
label_sal.place(x=0, y=415)
entry_sal_text = tkinter.StringVar()
entry_sal = tkinter.Entry(add_new_frame, text=entry_sal_text, width=40)
entry_sal.place(x=150, y=415)
label_TAG = tkinter.Label(add_new_frame, text="TAG :", bg=background_colour, fg="white", font=("bold", 10))
label_TAG.place(x=0, y=465)
option_for_TAG = ["STUDENT", "TEACHER", "DRIVER", "WORKER", "PRINCIPAL", "ASSISTANT", "OTHER"]
entry_TAG_text = tkinter.StringVar()
entry_TAG = tkinter.OptionMenu(add_new_frame, entry_TAG_text, *option_for_TAG)
entry_TAG.config(relief="raised", bd=0)
entry_TAG.place(x=150, y=465)
def cancel_fun():
add_new_frame.destroy()
but_frame.place(x=80, y=80)
search_entry.place(x=50, y=30)
search_button.place(x=300, y=28)
but_frame_func()
# save changes button
save_but = tkinter.Button(add_new_frame, text="Save", command=on_add_new_but, width=10, relief="groove")
save_but.place(x=1070, y=620)
cancel_but = tkinter.Button(add_new_frame, text="Cancel", command=cancel_fun, width=10, relief="groove")
cancel_but.place(x=970, y=620)
add_new_frame.mainloop()
def show_all_worker():
search_entry.config(state='disabled')
search_button.config(state='disabled')
but_frame.place_forget()
def select_rec():
reco = tree_view.focus()
if reco == "":
pass
else:
temp = tree_view.item(reco)
cmp = temp['values']
search_entry.config(state='normal')
search_button.config(state='normal')
search_entry.insert(0, cmp[0])
tree_view_frame.destroy()
on_search_button()
tree_view_frame = tkinter.Frame(main_window, width=1100, height=530, bg=background_colour)
tree_view_frame.place(x=80, y=100)
tree_view = ttk.Treeview(tree_view_frame, columns=("", "", "", "", ""), height=24, selectmode="browse")
tree_view.place(x=0, y=30)
scroll_bar = ttk.Scrollbar(tree_view_frame, orient='vertical', command=tree_view.yview)
scroll_bar.place(x=975, y=30, height=500)
tree_view.configure(yscrollcommand=scroll_bar.set)
tree_view.heading('#0', text='No.', anchor="w")
tree_view.column("#0", width=60)
tree_view.heading('#1', text='Id No.', anchor="center")
tree_view.column("#1", width=60)
tree_view.heading('#2', text='Name', anchor="center")
tree_view.column("#2", width=250)
tree_view.heading('#3', text='Address', anchor="center")
tree_view.column("#3", width=300)
tree_view.heading('#4', text='Phone No.', anchor="center")
tree_view.column("#4", width=100)
tree_view.heading('#5', text='Salary', anchor="center")
tree_view.column("#5", width=200)
style = ttk.Style()
style.configure("Treeview.Heading", foreground='black', font=('bold', 10))
my_database_show_all_worker = sqlite3.connect("Database.db")
my_cur_show_all_worker = my_database_show_all_worker.cursor()
my_cur_show_all_worker.execute(
"SELECT id, name, address, phone_no, salry FROM worker_data WHERE id>7000 ORDER BY name")
read = my_cur_show_all_worker.fetchall()
my_cur_show_all_worker.close()
my_database_show_all_worker.close()
total_record = tkinter.Label(tree_view_frame, text=f"Total Record = {len(read)}", bg=background_colour,
font=("bold", 10), fg="gold")
total_record.place(x=0, y=0)
i = 1
for col in read:
tree_view.insert("", "end", text=i, values=(col[0], col[1], col[2], col[3], col[4]))
i += 1
def cancel():
tree_view_frame.destroy()
search_entry.config(state='normal')
search_button.config(state='normal')
but_frame.place(x=80, y=80)
open_but = tkinter.Button(tree_view_frame, text="Open", relief="groove", width=10, command=select_rec)
open_but.place(x=1000, y=30)
cancel_but = tkinter.Button(tree_view_frame, text="Cancel", relief="groove", width=10, command=cancel)
cancel_but.place(x=1000, y=80)
def but_frame_func():
search_entry.config(state="normal")
search_button.config(state='normal')
add_student_button_photo = tkinter.PhotoImage(file="add_student_image.png")
add_student_button = tkinter.Button(but_frame, bd=0, bg=background_colour, fg="gold", relief="groove", text="Add Student",
font=("bold", 11), image=add_student_button_photo, compound="top", command=add_new_student)
add_student_button.place(x=5, y=10)
add_teacher_button_photo = tkinter.PhotoImage(file="add_teacher_image.png")
add_teacher_button = tkinter.Button(but_frame, bd=0, bg=background_colour, fg="gold", relief="groove", text="Add Teacher",
font=("bold", 11), image=add_teacher_button_photo, compound="top", command=add_new_teacher)
add_teacher_button.place(x=5, y=150)
add_bus_driver_button_photo = tkinter.PhotoImage(file="add_bus_driver_image.png")
add_bus_driver_button = tkinter.Button(but_frame, bd=0, bg=background_colour, fg="gold", relief="groove", text="Add Bus Driver",
font=("bold", 11), image=add_bus_driver_button_photo, compound="top", command=add_new_driver)
add_bus_driver_button.place(x=5, y=300)
add_worker_button_photo = tkinter.PhotoImage(file="add_worker_image.png")
add_worker_button = tkinter.Button(but_frame, bd=0, bg=background_colour, fg="gold", relief="groove", text="Add Worker",
font=("bold", 11), image=add_worker_button_photo, compound="top", command=add_new_worker)
add_worker_button.place(x=5, y=450)
all_student_button = tkinter.Button(but_frame, text="Show all Students", width=20, height=2, relief="groove",
font=("bold", 10), bg=background_colour, fg="white", command=show_all_student)
all_student_button.place(x=140, y=50)
all_teacher_button = tkinter.Button(but_frame, text="Show all Teachers", width=20, height=2, relief="groove",
font=("bold", 10), bg=background_colour, fg="white", command=show_all_teacher)
all_teacher_button.place(x=140, y=190)
all_driver_button = tkinter.Button(but_frame, text="Show all Bus Driver", width=20, height=2, relief="groove",
font=("bold", 10), bg=background_colour, fg="white", command=show_all_driver)
all_driver_button.place(x=140, y=340)
all_worker_button = tkinter.Button(but_frame, text="Show all Workers", width=20, height=2, relief="groove",
font=("bold", 10), bg=background_colour, fg="white", command=show_all_worker)
all_worker_button.place(x=140, y=490)
but_frame.mainloop()
def on_search_button():
value = search_entry.get()
search_entry.delete(0, 'end')
def show_student_data(student_value):
st_id = ""
st_glob_id = ""
st_name = ""
st_class = ""
st_roll_no = ""
st_class_teacher_name = ""
st_gender = ""
st_age = ""
st_cast = ""
st_phone_no = ""
st_image = ""
st_add = ""
st_edu = ""
st_f_name = ""
st_m_name = ""
st_adm_date = ""
st_adm_form_no = ""
st_fee_submitted = ""
st_fee_submitted_date = ""
st_adhar_no = ""
st_reg_no = ""
st_bl_g = ""
st_TAG = ""
query = f''' SELECT * FROM student_data
WHERE name='{student_value}'
OR id='{student_value}'
OR global_student_id='{student_value}'
'''
my_database_read_student = sqlite3.connect("Database.db")
my_cursor_read_student = my_database_read_student.cursor()
my_cursor_read_student.execute(query)
read = my_cursor_read_student.fetchall()
my_cursor_read_student.close()
my_database_read_student.close()
for col in read:
st_id = col[0]
st_glob_id = col[1]
st_name = col[2]
st_class = col[3]
st_roll_no = col[4]
st_class_teacher_name = col[5]
st_gender = col[6]
st_age = col[7]
st_cast = col[8]
st_phone_no = col[9]
st_image = col[10]
st_add = col[11]
st_edu = col[12]
st_f_name = col[13]
st_m_name = col[14]
st_adm_date = col[15]
st_adm_form_no = col[16]
st_fee_submitted = col[17]
st_fee_submitted_date = col[18]
st_adhar_no = col[19]
st_reg_no = col[20]
st_bl_g = col[21]
st_TAG = col[22]
if st_id == "":
return "No"
else:
def on_edit_button():
def on_edit_save_button_edit_frame():
msg = tkinter.messagebox.askquestion("Confirmation", "Do you want to save this changes?")
if msg == "yes":
global bi_img
get_st_glob_id = edit_entry_student_glob_id.get()
get_st_name = edit_entry_student_name.get()
get_st_class = edit_entry_student_class.get()
get_st_roll = edit_entry_student_roll_no.get()
get_st_class_te_name = edit_entry_student_cls_te_name.get()
get_st_gen = gender.get()
get_st_age = edit_entry_student_age.get()
get_st_cast = edit_entry_student_cast.get()
get_st_ph = edit_entry_student_ph.get()
get_st_img = bi_img
get_st_add = edit_entry_student_add.get()
get_st_edu = edit_entry_student_edu.get()
get_st_f_name = edit_entry_student_f_name.get()
get_st_m_name = edit_entry_student_m_name.get()
get_st_adm_date = edit_entry_student_adm_date.get()
get_st_adm_form_no = edit_entry_student_adm_f_no.get()
get_st_fee_subm = edit_entry_student_fee_sub.get()
get_st_fee_subm_date = edit_entry_student_fee_sub_date.get()
get_st_adh_no = edit_entry_student_adh_no.get()
get_st_reg_no = edit_entry_student_reg_no.get()
get_st_bl_g = edit_entry_student_bl_g.get()
get_st_TAG = edit_entry_student_TAG_text.get()
bi_img = None
if get_st_glob_id == "":
get_st_glob_id = st_glob_id
if get_st_name == "":
get_st_name = st_name
if get_st_class == "":
get_st_class = st_class
if get_st_roll == "":
get_st_roll = st_roll_no
if get_st_class_te_name == "":
get_st_class_te_name = st_class_teacher_name
if get_st_gen == "0":
get_st_gen = st_gender
if get_st_age == "":
get_st_age = st_age
if get_st_cast == "":
get_st_cast = st_cast
if get_st_ph == "":
get_st_ph = st_phone_no
if get_st_img is None:
get_st_img = st_image
if get_st_add == "":
get_st_add = st_add
if get_st_edu == "":
get_st_edu = st_edu
if get_st_f_name == "":
get_st_f_name = st_f_name
if get_st_m_name == "":
get_st_m_name = st_m_name
if get_st_adm_date == "":
get_st_adm_date = st_adm_date
if get_st_adm_form_no == "":
get_st_adm_form_no = st_adm_form_no
if get_st_fee_subm == "":
get_st_fee_subm = st_fee_submitted
if get_st_fee_subm_date == "":
get_st_fee_subm_date = st_fee_submitted_date
if get_st_adh_no == "":
get_st_adh_no = st_adhar_no
if get_st_reg_no == "":
get_st_reg_no = st_reg_no
if get_st_bl_g == "":
get_st_bl_g = st_bl_g
if get_st_TAG == "":
get_st_TAG = st_TAG
query_update_data = f'''
UPDATE student_data
SET
global_student_id=?,
name=?,
class=?,
roll_no=?,
class_teacher_name=?,
gender=?,
age=?,
cast=?,
phone_no=?,
image=?,
address=?,
education=?,
father_name=?,
mother_name=?,
admission_date=?,
admission_form_no=?,
fee_submitted=?,
fee_submission_date=?,
adhar_no=?,
register_no=?,
blood_group=?,
TAG=?
WHERE id = {st_id}
'''
tuple_update = (get_st_glob_id, get_st_name, get_st_class, get_st_roll, get_st_class_te_name, get_st_gen, get_st_age, get_st_cast, get_st_ph, get_st_img, get_st_add, get_st_edu, get_st_f_name, get_st_m_name, get_st_adm_date, get_st_adm_form_no, get_st_fee_subm, get_st_fee_subm_date, get_st_adh_no, get_st_reg_no, get_st_bl_g, get_st_TAG)
my_database_up_student = sqlite3.connect("Database.db")
my_cursor_update_student = my_database_up_student.cursor()
my_cursor_update_student.execute(query_update_data, tuple_update)
my_database_up_student.commit()
query_update_check = f'''SELECT id, name, class, address, image FROM student_data
WHERE
id={st_id}; '''
my_cursor_update_student.execute(query_update_check)
update_check = my_cursor_update_student.fetchall()
my_cursor_update_student.close()
my_database_up_student.close()
up_ch_id = ''
up_ch_name = ''
up_ch_class = ''
up_ch_add = ''
up_ch_img = ''
for up_col in update_check:
up_ch_id = up_col[0]
up_ch_name = up_col[1]
up_ch_class = up_col[2]
up_ch_add = up_col[3]
up_ch_img = up_col[4]
if up_ch_name == get_st_name and up_ch_class == get_st_class and up_ch_add == get_st_add and up_ch_img == get_st_img:
tkinter.messagebox.showinfo(f"Status of Id no.= {up_ch_id}",
"Data is Updated successfully")
else:
tkinter.messagebox.showerror("Status", "Failed to update data !!!")
def on_add_image_button_edit_frame():
global bi_img
path = filedialog.askopenfilename()
bi_img = read_binary_image(path)
try:
re_image = Image.open(path)
re_image = re_image.resize((200, 260), Image.ANTIALIAS)
re_image.save("nres_img.ppm", "ppm")
open_img = ImageTk.PhotoImage(Image.open("nres_img.ppm"))
edit_img.destroy()
edit_image.create_image(0, 0, image=open_img, anchor="nw")
student_edit_frame.mainloop()
except AttributeError:
pass
student_edit_frame.mainloop()
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ON Add Image BUTTON END IN edit frame @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
def on_delete_button_edit_frame():
msg = tkinter.messagebox.askquestion("Confirmation",
"Do yo want to delete this record, Note if you delete it will permanently delete the record.")
if msg == "yes":
my_database_del_student = sqlite3.connect("Database.db")
my_cursor_del_student = my_database_del_student.cursor()
my_cursor_del_student.execute(f"DELETE FROM student_data WHERE id={st_id}")
msg_ = tkinter.messagebox.askquestion("Confirm Again", "Are you sure...!!!")
if msg_ == "yes":
my_database_del_student.commit()
else:
pass
my_cursor_del_student.execute(f"SELECT id FROM student_data WHERE id={st_id}")
delete_read = my_cursor_del_student.fetchall()
my_database_del_student.close()
if not delete_read:
tkinter.messagebox.showinfo(f"Status of Id= {st_id}, Name= {st_name}",
"Record Successfully deleted from database.")
else:
tkinter.messagebox.showwarning("Status", "Record is not deleted from database.")
else:
pass
student_frame.place_forget()
student_edit_frame = tkinter.Frame(main_window, width=1300, height=650, bg=background_colour)
student_edit_frame.place(x=20, y=30)
# edit_frame = labels and Entries and buttons
edit_label_old_data = tkinter.Label(student_edit_frame, text="Old Data:", font=("bold", 12), bg=background_colour, fg="white")
edit_label_old_data.place(x=100, y=0)
edit_label_old_data = tkinter.Label(student_edit_frame, text="Insert New Data:", font=("bold", 12), bg=background_colour, fg="white")
edit_label_old_data.place(x=340, y=0)
edit_label_old_data_ = tkinter.Label(student_edit_frame, text="Old Data:", font=("bold", 12), bg=background_colour, fg="white")
edit_label_old_data_.place(x=850, y=0)
edit_label_old_data_ = tkinter.Label(student_edit_frame, text="Insert New Data:", font=("bold", 12), bg=background_colour, fg="white")
edit_label_old_data_.place(x=1100, y=0)
# Labels and Entries
edit_label_student_glob_id = tkinter.Label(student_edit_frame, text="Student Global ID:", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_glob_id.place(x=0, y=75)
edit_label_student_glob_id_ans = tkinter.Label(student_edit_frame, text=st_glob_id, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_glob_id_ans.place(x=150, y=75)
edit_entry_student_glob_id_text = tkinter.StringVar()
edit_entry_student_glob_id = tkinter.Entry(student_edit_frame, text=edit_entry_student_glob_id_text, width=30)
edit_entry_student_glob_id.place(x=320, y=75)
edit_label_student_name = tkinter.Label(student_edit_frame, text="Student Name:", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_name.place(x=0, y=125)
edit_label_student_name_ans = tkinter.Label(student_edit_frame, text=st_name, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_name_ans.place(x=150, y=125)
edit_entry_student_name_text = tkinter.StringVar()
edit_entry_student_name = tkinter.Entry(student_edit_frame, text=edit_entry_student_name_text, width=30)
edit_entry_student_name.place(x=320, y=125)
edit_label_student_class = tkinter.Label(student_edit_frame, text="Student Class :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_class.place(x=0, y=175)
edit_label_student_class_ans = tkinter.Label(student_edit_frame, text=st_class, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_class_ans.place(x=150, y=175)
edit_entry_student_class_text = tkinter.StringVar()
edit_entry_student_class = tkinter.Entry(student_edit_frame, text=edit_entry_student_class_text, width=30)
edit_entry_student_class.place(x=320, y=175)
edit_label_student_roll_no = tkinter.Label(student_edit_frame, text="Student Roll No. :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_roll_no.place(x=0, y=225)
edit_label_student_roll_no_ans = tkinter.Label(student_edit_frame, text=st_roll_no, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_roll_no_ans.place(x=150, y=225)
edit_entry_student_roll_no_text = tkinter.StringVar()
edit_entry_student_roll_no = tkinter.Entry(student_edit_frame, text=edit_entry_student_roll_no_text, width=30)
edit_entry_student_roll_no.place(x=320, y=225)
edit_label_student_cls_te_name = tkinter.Label(student_edit_frame, text="Class Teacher Name :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_cls_te_name.place(x=0, y=275)
edit_label_student_cls_te_name_ans = tkinter.Label(student_edit_frame, text=st_class_teacher_name, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_cls_te_name_ans.place(x=150, y=275)
edit_entry_student_cls_te_name_text = tkinter.StringVar()
edit_entry_student_cls_te_name = tkinter.Entry(student_edit_frame, text=edit_entry_student_cls_te_name_text, width=30)
edit_entry_student_cls_te_name.place(x=320, y=275)
edit_label_student_gen = tkinter.Label(student_edit_frame, text="Student Gender:", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_gen.place(x=0, y=325)
edit_re_gen = "-"
if st_gender == "F":
edit_re_gen = "Female"
if st_gender == "M":
edit_re_gen = "Male"
edit_student_gender = tkinter.Label(student_edit_frame, text=edit_re_gen, bg=background_colour, fg="gold", font=("bold", 10))
edit_student_gender.place(x=150, y=325)
gender = tkinter.StringVar()
gender.set(0)
edit_leb_student_gender_m = tkinter.Radiobutton(student_edit_frame, text="Male", variable=gender, value="M", bg=background_colour, fg="black", font=("bold", 10))
edit_leb_student_gender_m.place(x=320, y=325)
edit_leb_student_gender_f = tkinter.Radiobutton(student_edit_frame, text="Female", variable=gender, value="F", bg=background_colour, fg="black", font=("bold", 10))
edit_leb_student_gender_f.place(x=380, y=325)
edit_label_student_age = tkinter.Label(student_edit_frame, text="Student Age :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_age.place(x=0, y=375)
edit_label_student_age_ans = tkinter.Label(student_edit_frame, text=st_age, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_age_ans.place(x=150, y=375)
edit_entry_student_age_text = tkinter.StringVar()
edit_entry_student_age = tkinter.Entry(student_edit_frame, text=edit_entry_student_age_text, width=30)
edit_entry_student_age.place(x=320, y=375)
edit_label_student_cast = tkinter.Label(student_edit_frame, text="Student Cast :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_cast.place(x=0, y=425)
edit_label_student_cast_ans = tkinter.Label(student_edit_frame, text=st_cast, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_cast_ans.place(x=150, y=425)
edit_entry_student_cast_text = tkinter.StringVar()
edit_entry_student_cast = tkinter.Entry(student_edit_frame, text=edit_entry_student_cast_text, width=30)
edit_entry_student_cast.place(x=320, y=425)
edit_label_student_ph = tkinter.Label(student_edit_frame, text="Student Ph.No. :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_ph.place(x=0, y=475)
edit_label_student_ph_ans = tkinter.Label(student_edit_frame, text=st_phone_no, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_ph_ans.place(x=150, y=475)
edit_entry_student_ph_text = tkinter.StringVar()
edit_entry_student_ph = tkinter.Entry(student_edit_frame, text=edit_entry_student_ph_text, width=30)
edit_entry_student_ph.place(x=320, y=475)
edit_image = tkinter.Canvas(student_edit_frame, width=200, height=260)
edit_image.place(x=530, y=100)
edit_leb_image = tkinter.Label(student_edit_frame, text="Student Image", bg=background_colour, fg="white", font=("bold", 10))
edit_leb_image.place(x=530, y=75)
edit_but_img = tkinter.PhotoImage(file="add_image.png")
edit_img = tkinter.Button(student_edit_frame, image=edit_but_img, bd=0, relief="groove", command=on_add_image_button_edit_frame)
edit_img.place(x=605, y=200)
edit_label_student_add = tkinter.Label(student_edit_frame, text="Student Add :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_add.place(x=0, y=525)
edit_label_student_add_ans = tkinter.Label(student_edit_frame, text=st_add, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_add_ans.place(x=150, y=525)
edit_entry_student_add_text = tkinter.StringVar()
edit_entry_student_add = tkinter.Entry(student_edit_frame, text=edit_entry_student_add_text, width=30)
edit_entry_student_add.place(x=320, y=525)
edit_label_student_edu = tkinter.Label(student_edit_frame, text="Student Education :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_edu.place(x=0, y=575)
edit_label_student_edu_ans = tkinter.Label(student_edit_frame, text=st_edu, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_edu_ans.place(x=150, y=575)
edit_entry_student_edu_text = tkinter.StringVar()
edit_entry_student_edu = tkinter.Entry(student_edit_frame, text=edit_entry_student_edu_text, width=30)
edit_entry_student_edu.place(x=320, y=575)
edit_label_student_f_name = tkinter.Label(student_edit_frame, text="Father's Name :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_f_name.place(x=750, y=75)
edit_label_student_f_name_ans = tkinter.Label(student_edit_frame, text=st_f_name, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_f_name_ans.place(x=900, y=75)
edit_entry_student_f_name_text = tkinter.StringVar()
edit_entry_student_f_name = tkinter.Entry(student_edit_frame, text=edit_entry_student_f_name_text, width=30)
edit_entry_student_f_name.place(x=1070, y=75)
edit_label_student_m_name = tkinter.Label(student_edit_frame, text="Mother's Name :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_m_name.place(x=750, y=125)
edit_label_student_m_name_ans = tkinter.Label(student_edit_frame, text=st_m_name, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_m_name_ans.place(x=900, y=125)
edit_entry_student_m_name_text = tkinter.StringVar()
edit_entry_student_m_name = tkinter.Entry(student_edit_frame, text=edit_entry_student_m_name_text, width=30)
edit_entry_student_m_name.place(x=1070, y=125)
edit_label_student_adm_date = tkinter.Label(student_edit_frame, text="Admission Date :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_adm_date.place(x=750, y=175)
edit_label_student_adm_date_ans = tkinter.Label(student_edit_frame, text=st_adm_date, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_adm_date_ans.place(x=900, y=175)
edit_entry_student_adm_date_text = tkinter.StringVar()
edit_entry_student_adm_date = tkinter.Entry(student_edit_frame, text=edit_entry_student_adm_date_text, width=30)
edit_entry_student_adm_date.place(x=1070, y=175)
edit_label_student_adm_f_no = tkinter.Label(student_edit_frame, text="Admission Form No. :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_adm_f_no.place(x=750, y=225)
edit_label_student_adm_f_no_ans = tkinter.Label(student_edit_frame, text=st_adm_form_no, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_adm_f_no_ans.place(x=900, y=225)
edit_entry_student_adm_f_no_text = tkinter.StringVar()
edit_entry_student_adm_f_no = tkinter.Entry(student_edit_frame, text=edit_entry_student_adm_f_no_text, width=30)
edit_entry_student_adm_f_no.place(x=1070, y=225)
edit_label_student_fee_sub = tkinter.Label(student_edit_frame, text="Fee Submitted :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_fee_sub.place(x=750, y=275)
edit_label_student_fee_sub_ans = tkinter.Label(student_edit_frame, text=st_fee_submitted, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_fee_sub_ans.place(x=900, y=275)
edit_entry_student_fee_sub_text = tkinter.StringVar()
edit_entry_student_fee_sub = tkinter.Entry(student_edit_frame, text=edit_entry_student_fee_sub_text, width=30)
edit_entry_student_fee_sub.place(x=1070, y=275)
edit_label_student_fee_sub_date = tkinter.Label(student_edit_frame, text="Fee Submission Data:", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_fee_sub_date.place(x=750, y=325)
edit_label_student_fee_sub_date_ans = tkinter.Label(student_edit_frame, text=st_fee_submitted_date, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_fee_sub_date_ans.place(x=900, y=325)
edit_entry_student_fee_sub_date_text = tkinter.StringVar()
edit_entry_student_fee_sub_date = tkinter.Entry(student_edit_frame, text=edit_entry_student_fee_sub_date_text, width=30)
edit_entry_student_fee_sub_date.place(x=1070, y=325)
edit_label_student_adh_no = tkinter.Label(student_edit_frame, text="Adhar No. :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_adh_no.place(x=750, y=375)
edit_label_student_adh_no_ans = tkinter.Label(student_edit_frame, text=st_adhar_no, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_adh_no_ans.place(x=900, y=375)
edit_entry_student_adh_no_text = tkinter.StringVar()
edit_entry_student_adh_no = tkinter.Entry(student_edit_frame, text=edit_entry_student_adh_no_text, width=30)
edit_entry_student_adh_no.place(x=1070, y=375)
edit_label_student_reg_no = tkinter.Label(student_edit_frame, text="G.Reg. No. :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_reg_no.place(x=750, y=425)
edit_label_student_reg_no_ans = tkinter.Label(student_edit_frame, text=st_reg_no, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_reg_no_ans.place(x=900, y=425)
edit_entry_student_reg_no_text = tkinter.StringVar()
edit_entry_student_reg_no = tkinter.Entry(student_edit_frame, text=edit_entry_student_reg_no_text, width=30)
edit_entry_student_reg_no.place(x=1070, y=425)
edit_label_student_bl_g = tkinter.Label(student_edit_frame, text="Blood Group :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_bl_g.place(x=750, y=475)
edit_label_student_bl_g_ans = tkinter.Label(student_edit_frame, text=st_bl_g, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_bl_g_ans.place(x=900, y=475)
edit_entry_student_bl_g_text = tkinter.StringVar()
edit_entry_student_bl_g = tkinter.Entry(student_edit_frame, text=edit_entry_student_bl_g_text, width=30)
edit_entry_student_bl_g.place(x=1070, y=475)
edit_label_student_TAG = tkinter.Label(student_edit_frame, text="TAG :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_student_TAG.place(x=750, y=525)
edit_label_student_TAG_ans = tkinter.Label(student_edit_frame, text=st_TAG, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_student_TAG_ans.place(x=900, y=525)
options_for_TAG = ["STUDENT", "TEACHER", "DRIVER", "WORKER", "PRINCIPAL", "ASSISTANT", "OTHER"]
edit_entry_student_TAG_text = tkinter.StringVar()
edit_entry_student_TAG = tkinter.OptionMenu(student_edit_frame, edit_entry_student_TAG_text, *options_for_TAG)
edit_entry_student_TAG.place(x=1070, y=525)
edit_entry_student_TAG.config(relief="raised", bd=0)
# This function is used to destroy() the edit frame and go back to on_search_button function
def cancel_but():
student_edit_frame.destroy()
student_frame.place(x=50, y=30)
# edit_frame - Buttons
edit_button_save = tkinter.Button(student_edit_frame, text="Save Changes", width=14,relief="groove", command=on_edit_save_button_edit_frame)
edit_button_save.place(x=1150, y=620)
edit_button_cancel = tkinter.Button(student_edit_frame, text="Cancel", width=10, relief="groove", command=cancel_but)
edit_button_cancel.place(x=1050, y=620)
edit_button_delete = tkinter.Button(student_edit_frame, text="Delete Record", width=14, relief="groove", command=on_delete_button_edit_frame)
edit_button_delete.place(x=920, y=620)
student_edit_frame.mainloop()
# placement of main frame
student_frame = tkinter.Frame(main_window, width=1300, height=650, bg=background_colour)
student_frame.place(x=50, y=30)
# main frame = labels and Entries and buttons
# adding gender image with Tag, name in the form of label
if st_gender == "M":
gen_img_logo = "img_gender_male.png"
elif st_gender == "F":
gen_img_logo = "img_gender_female.png"
else:
gen_img_logo = "img_gender_male.png"
img_gender = ImageTk.PhotoImage(Image.open(gen_img_logo))
label_student_name = tkinter.Label(student_frame, image=img_gender, text=f" {st_name}", width=400, anchor="nw",
font=("bold", 15), compound="left", bg=background_colour, fg="gold")
label_student_name.place(x=0, y=0)
label_student_glob_id = tkinter.Label(student_frame, text="Student ID:", bg=background_colour, fg="white",
font=("bold", 10))
label_student_glob_id.place(x=0, y=65)
entry_student_glob_id = tkinter.Label(student_frame, text=st_id, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_glob_id.place(x=150, y=65)
label_student_id = tkinter.Label(student_frame, text="Global Student ID:", bg=background_colour, fg="white",
font=("bold", 10))
label_student_id.place(x=0, y=115)
entry_student_id = tkinter.Label(student_frame, text=st_glob_id, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_id.place(x=150, y=115)
label_student_class = tkinter.Label(student_frame, text="Student Class :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_class.place(x=0, y=165)
entry_student_class = tkinter.Label(student_frame, text=st_class, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_class.place(x=150, y=165)
label_student_roll_no = tkinter.Label(student_frame, text="Student Roll No. :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_roll_no.place(x=0, y=215)
entry_student_roll_no = tkinter.Label(student_frame, text=st_roll_no, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_roll_no.place(x=150, y=215)
label_student_cls_name = tkinter.Label(student_frame, text="Class Teacher Name :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_cls_name.place(x=0, y=265)
entry_student_cls_name = tkinter.Label(student_frame, text=st_class_teacher_name, width=30, anchor="nw",
font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_cls_name.place(x=150, y=265)
label_student_gender = tkinter.Label(student_frame, text="Student gender:", bg=background_colour, fg="white",
font=("bold", 10))
label_student_gender.place(x=0, y=315)
re_gen = ""
if st_gender == "F":
re_gen = "Female"
if st_gender == "M":
re_gen = "Male"
entry_student_gender = tkinter.Label(student_frame, text=re_gen, bg=background_colour, fg="gold",
font=("bold", 14))
entry_student_gender.place(x=150, y=315)
label_student_age = tkinter.Label(student_frame, text="Student Age :", bg=background_colour,
fg="white",
font=("bold", 10))
label_student_age.place(x=0, y=365)
entry_student_age = tkinter.Label(student_frame, text=st_age, width=30, anchor="nw",
font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_age.place(x=150, y=365)
label_student_cast = tkinter.Label(student_frame, text="Student Cast :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_cast.place(x=0, y=415)
entry_student_cast = tkinter.Label(student_frame, text=st_cast, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_cast.place(x=150, y=415)
label_student_ph = tkinter.Label(student_frame, text="Student Ph.No. :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_ph.place(x=0, y=465)
entry_student_ph = tkinter.Label(student_frame, text=st_phone_no, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_ph.place(x=150, y=465)
# Image of Student
label_for_image = tkinter.Label(student_frame, text="Student Image:", font=("Bold", 10), bg=background_colour,
fg="white")
label_for_image.place(x=1050, y=65)
canvas_frame = tkinter.Canvas(student_frame, width=200, height=267, bg="White")
canvas_frame.place(x=1050, y=90)
try:
write_binary_image('got_image_from_mysql_db.jpg', st_image)
resize_img = Image.open('got_image_from_mysql_db.jpg')
resize_img = resize_img.resize((200, 267), Image.ANTIALIAS)
resize_img.save("nres_img.ppm", "ppm")
got_image = ImageTk.PhotoImage(file='nres_img.ppm')
canvas_frame.create_image(0, 0, anchor="nw", image=got_image)
except TypeError:
pass
label_student_add = tkinter.Label(student_frame, text="Student Add :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_add.place(x=0, y=515)
entry_student_add = tkinter.Label(student_frame, text=st_add, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_add.place(x=150, y=515)
label_student_edu = tkinter.Label(student_frame, text="Student Education :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_edu.place(x=0, y=565)
entry_student_edu = tkinter.Label(student_frame, text=st_edu, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_edu.place(x=150, y=565)
label_student_f_name = tkinter.Label(student_frame, text="Father's Name :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_f_name.place(x=500, y=65)
entry_student_f_name = tkinter.Label(student_frame, text=st_f_name, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_f_name.place(x=650, y=65)
label_student_m_name = tkinter.Label(student_frame, text="Mother's Name :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_m_name.place(x=500, y=115)
entry_student_m_name = tkinter.Label(student_frame, text=st_m_name, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_m_name.place(x=650, y=115)
label_student_adm_date = tkinter.Label(student_frame, text="Admission Date :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_adm_date.place(x=500, y=165)
entry_student_adm_date = tkinter.Label(student_frame, text=st_adm_date, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_adm_date.place(x=650, y=165)
label_student_adm_f_no = tkinter.Label(student_frame, text="Admission Form No. :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_adm_f_no.place(x=500, y=215)
entry_student_adm_f_no = tkinter.Label(student_frame, text=st_adm_form_no, width=30, anchor="nw",
font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_adm_f_no.place(x=650, y=215)
label_student_fee_sub = tkinter.Label(student_frame, text="Fee Submitted :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_fee_sub.place(x=500, y=265)
entry_student_fee_sub = tkinter.Label(student_frame, text=st_fee_submitted, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_fee_sub.place(x=650, y=265)
label_student_fee_sub_date = tkinter.Label(student_frame, text="Fee Submission Date :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_fee_sub_date.place(x=500, y=315)
entry_student_fee_sub_date = tkinter.Label(student_frame, text=st_fee_submitted_date, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_fee_sub_date.place(x=650, y=315)
label_student_adh_no = tkinter.Label(student_frame, text="Adhar No. :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_adh_no.place(x=500, y=365)
entry_student_adh_no = tkinter.Label(student_frame, text=st_adhar_no, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_adh_no.place(x=650, y=365)
label_student_reg_no = tkinter.Label(student_frame, text="G.Reg. No. :", bg=background_colour, fg="white", font=("bold", 10))
label_student_reg_no.place(x=500, y=415)
entry_student_reg_no = tkinter.Label(student_frame, text=st_reg_no, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_reg_no.place(x=650, y=415)
label_student_bl_g = tkinter.Label(student_frame, text="Blood Group :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_bl_g.place(x=500, y=465)
entry_student_bl_g = tkinter.Label(student_frame, text=st_bl_g, width=30, anchor="nw",
font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_bl_g.place(x=650, y=465)
label_student_tag = tkinter.Label(student_frame, text="TAG :", bg=background_colour, fg="white",
font=("bold", 10))
label_student_tag.place(x=500, y=515)
entry_student_tag = tkinter.Label(student_frame, text=st_TAG, width=30, anchor="nw",
font=("bold", 14),
bg=background_colour, fg="gold")
entry_student_tag.place(x=650, y=515)
def cancel():
student_frame.destroy()
search_entry.place(x=50, y=30)
search_button.place(x=300, y=28)
but_frame.place(x=80, y=80)
# button to edit data of student
edit_data_button = tkinter.Button(student_frame, text="Edit Data", width=10, relief="groove", command=on_edit_button)
edit_data_button.place(x=1150, y=620)
cancel_button = tkinter.Button(student_frame, text="Cancel", width=10, relief="groove", command=cancel)
cancel_button.place(x=1050, y=620)
student_frame.mainloop()
def show_teacher_data(teacher_value):
te_id = ""
te_name = ""
te_gen = ""
te_age = ""
te_of_class = ""
te_sub = ""
te_phone = ""
te_img = ""
te_add = ""
te_edu = ""
te_salary = ""
te_jo_date = ""
te_adhar_no = ""
te_TAG = ""
my_database_te_data = sqlite3.connect("Database.db")
my_cursor_te_data = my_database_te_data.cursor()
query = f'''SELECT * FROM teacher_data
WHERE id = '{teacher_value}' or name = '{teacher_value}';
'''
my_cursor_te_data.execute(query)
read = my_cursor_te_data.fetchall()
my_cursor_te_data.close()
my_database_te_data.close()
for col in read:
te_id = col[0]
te_name = col[1]
te_gen = col[2]
te_age = col[3]
te_of_class = col[4]
te_sub = col[5]
te_phone = col[6]
te_img = col[7]
te_add = col[8]
te_edu = col[9]
te_salary = col[10]
te_jo_date = col[11]
te_adhar_no = col[12]
te_TAG = col[13]
if te_id == "":
return "No"
else:
def on_edit_button():
def on_edit_save_button_edit_frame():
msg = tkinter.messagebox.askquestion("Confirmation ", "Do you want to update record ?")
if msg == "yes":
global bi_img
up_te_name = edit_entry_teacher_name.get()
up_te_gen = gender.get()
up_te_age = edit_entry_teacher_age.get()
up_te_of_cl = edit_entry_teacher_of_cl.get()
up_te_sub = edit_entry_teacher_sub.get()
up_te_ph = edit_entry_teacher_ph.get()
up_te_img = bi_img
up_te_add = edit_entry_teacher_add.get()
up_te_edu = edit_entry_teacher_edu.get()
up_te_sal = edit_entry_teacher_sal.get()
up_te_jo_date = edit_entry_teacher_jo_date.get()
up_te_adh = edit_entry_teacher_adh_no.get()
up_te_TAG = edit_entry_te_TAG_text.get()
bi_img = None
if up_te_name == "":
up_te_name = te_name
if up_te_gen == "0":
up_te_gen = te_gen
if up_te_age == "":
up_te_age = te_age
if up_te_of_cl == "":
up_te_of_cl = te_of_class
if up_te_sub == "":
up_te_sub = te_sub
if up_te_ph == "":
up_te_ph = te_phone
if up_te_img is None:
up_te_img = te_img
if up_te_add == "":
up_te_add = te_add
if up_te_edu == "":
up_te_edu = te_edu
if up_te_sal == "":
up_te_sal =te_salary
if up_te_jo_date == "":
up_te_jo_date = te_jo_date
if up_te_adh == "":
up_te_adh = te_adhar_no
if up_te_TAG == "":
up_te_TAG =te_TAG
update_query = f''' UPDATE teacher_data
SET
name=?,
gender=?,
age=?,
teacher_of_class=?,
subject=?,
phone_no=?,
image=?,
address=?,
education=?,
salry=?,
joining_date=?,
adhar_no=?,
TAG=?
WHERE id={te_id};
'''
my_database_up_te = sqlite3.connect("Database.db")
my_cursor_up_te = my_database_up_te.cursor()
up_te_tuple = (up_te_name, up_te_gen, up_te_age, up_te_of_cl, up_te_sub, up_te_ph, up_te_img,up_te_add, up_te_edu, up_te_sal, up_te_jo_date, up_te_adh, up_te_TAG )
my_cursor_up_te.execute(update_query, up_te_tuple)
my_database_up_te.commit()
my_cursor_up_te.execute(f'''SELECT id, name, address, image FROM teacher_data WHERE id={te_id}''')
up_read = my_cursor_up_te.fetchall()
my_cursor_up_te.close()
my_database_up_te.close()
up_ch_id = ''
up_ch_name = ''
up_ch_add = ''
up_ch_img = ''
for up_col in up_read:
up_ch_id = up_col[0]
up_ch_name = up_col[1]
up_ch_add = up_col[2]
up_ch_img = up_col[3]
if up_ch_name == up_te_name and up_ch_add == up_te_add and up_ch_img == up_te_img:
tkinter.messagebox.showinfo(f"Status of Id no.= {up_ch_id}", "Data is Updated successfully")
else:
tkinter.messagebox.showerror("Status", "Failed to update data !!!")
def on_add_image_button_edit_frame():
global bi_img
path = filedialog.askopenfilename()
bi_img = read_binary_image(path)
try:
re_img = Image.open(path)
re_img = re_img.resize((200, 260), Image.ANTIALIAS)
re_img.save("nres_img.ppm", "ppm")
photo = ImageTk.PhotoImage(Image.open("nres_img.ppm"))
edit_img.destroy()
edit_image.create_image(0, 0, image=photo, anchor="nw")
teacher_edit_frame.mainloop()
except AttributeError:
pass
def on_delete_button_edit_frame():
msg = tkinter.messagebox.askquestion("Confirmation", "Do you want to delete this Record, Note if you delete the record it will permanently delete...")
if msg == "yes":
my_database_del_te = sqlite3.connect("Database.db")
my_cursor_del_te = my_database_del_te.cursor()
my_cursor_del_te.execute(f'''DELETE FROM teacher_data WHERE id={te_id};''')
msg_ = tkinter.messagebox.askquestion("Confirm Again", "Are you sure...!!!")
if msg_ == "yes":
my_database_del_te.commit()
else:
pass
my_cursor_del_te.execute(f'''SELECT id FROM teacher_data WHERE id={te_id}''')
delete_read = my_cursor_del_te.fetchall()
if not delete_read:
tkinter.messagebox.showinfo(f"Status of Id= {te_id}, Name= {te_name}", "Record Successfully deleted from database.")
else:
tkinter.messagebox.showwarning("Status", "Record is not deleted from database.")
else:
pass
teacher_frame.place_forget()
teacher_edit_frame = tkinter.Frame(main_window, width=1300, height=650, bg=background_colour)
teacher_edit_frame.place(x=20, y=30)
# edit_frame = labels and Entries and buttons
edit_label_old_data = tkinter.Label(teacher_edit_frame, text="Old Data:", font=("bold", 12), bg=background_colour, fg="white")
edit_label_old_data.place(x=50, y=0)
edit_label_old_data = tkinter.Label(teacher_edit_frame, text="Insert New Data:", font=("bold", 12), bg=background_colour, fg="white")
edit_label_old_data.place(x=300, y=0)
edit_label_old_data_ = tkinter.Label(teacher_edit_frame, text="Old Data:", font=("bold", 12), bg=background_colour, fg="white")
edit_label_old_data_.place(x=850, y=0)
edit_label_old_data_ = tkinter.Label(teacher_edit_frame, text="Insert New Data:", font=("bold", 12), bg=background_colour, fg="white")
edit_label_old_data_.place(x=1100, y=0)
# Labels and Entries
edit_label_teacher_name = tkinter.Label(teacher_edit_frame, text="Teacher Name:", bg=background_colour, fg="white", font=("bold", 10))
edit_label_teacher_name.place(x=0, y=75)
edit_label_teacher_name_ans = tkinter.Label(teacher_edit_frame, text=te_name, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_teacher_name_ans.place(x=150, y=75)
edit_entry_teacher_name_text = tkinter.StringVar()
edit_entry_teacher_name = tkinter.Entry(teacher_edit_frame, text=edit_entry_teacher_name_text, width=30)
edit_entry_teacher_name.place(x=320, y=75)
edit_label_teacher_gen = tkinter.Label(teacher_edit_frame, text="Teacher Gender:", bg=background_colour, fg="white", font=("bold", 10))
edit_label_teacher_gen.place(x=0, y=125)
edit_re_gen = ""
if te_gen == "F":
edit_re_gen = "Female"
if te_gen == "M":
edit_re_gen = "Male"
edit_teacher_gender = tkinter.Label(teacher_edit_frame, text=edit_re_gen, bg=background_colour, fg="gold", font=("bold", 10))
edit_teacher_gender.place(x=150, y=125)
gender = tkinter.StringVar()
gender.set(0)
edit_leb_teacher_gender_m = tkinter.Radiobutton(teacher_edit_frame, text="Male", variable=gender, value="M", bg=background_colour, fg="black", font=("bold", 10))
edit_leb_teacher_gender_m.place(x=320, y=125)
edit_leb_teacher_gender_f = tkinter.Radiobutton(teacher_edit_frame, text="Female", variable=gender, value="F", bg=background_colour, fg="black", font=("bold", 10))
edit_leb_teacher_gender_f.place(x=390, y=125)
edit_label_teacher_age = tkinter.Label(teacher_edit_frame, text="Teacher Age :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_teacher_age.place(x=0, y=175)
edit_label_teacher_age_ans = tkinter.Label(teacher_edit_frame, text=te_age, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_teacher_age_ans.place(x=150, y=175)
edit_entry_teacher_age_text = tkinter.StringVar()
edit_entry_teacher_age = tkinter.Entry(teacher_edit_frame, text=edit_entry_teacher_age_text, width=30)
edit_entry_teacher_age.place(x=320, y=175)
edit_label_teacher_of_cl = tkinter.Label(teacher_edit_frame, text="Teacher of Class :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_teacher_of_cl.place(x=0, y=225)
edit_label_teacher_of_cl_ans = tkinter.Label(teacher_edit_frame, text=te_of_class, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_teacher_of_cl_ans.place(x=150, y=225)
edit_entry_teacher_of_cl_text = tkinter.StringVar()
edit_entry_teacher_of_cl = tkinter.Entry(teacher_edit_frame, text=edit_entry_teacher_of_cl_text, width=30)
edit_entry_teacher_of_cl.place(x=320, y=225)
edit_label_teacher_sub = tkinter.Label(teacher_edit_frame, text="Subject :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_teacher_sub.place(x=0, y=275)
edit_label_teacher_sub_ans = tkinter.Label(teacher_edit_frame, text=te_sub, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_teacher_sub_ans.place(x=150, y=275)
edit_entry_teacher_sub_text = tkinter.StringVar()
edit_entry_teacher_sub = tkinter.Entry(teacher_edit_frame, text=edit_entry_teacher_sub_text, width=30)
edit_entry_teacher_sub.place(x=320, y=275)
edit_label_teacher_ph = tkinter.Label(teacher_edit_frame, text="Teacher Ph.No. :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_teacher_ph.place(x=0, y=325)
edit_label_teacher_ph_ans = tkinter.Label(teacher_edit_frame, text=te_phone, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_teacher_ph_ans.place(x=150, y=325)
edit_entry_teacher_ph_text = tkinter.StringVar()
edit_entry_teacher_ph = tkinter.Entry(teacher_edit_frame, text=edit_entry_teacher_ph_text, width=30)
edit_entry_teacher_ph.place(x=320, y=325)
edit_leb_image = tkinter.Label(teacher_edit_frame, text="Student Image", bg=background_colour, fg="white", font=("bold", 10))
edit_leb_image.place(x=530, y=75)
edit_image = tkinter.Canvas(teacher_edit_frame, width=200, height=260)
edit_image.place(x=530, y=100)
edit_but_img = tkinter.PhotoImage(file="add_image.png")
edit_img = tkinter.Button(teacher_edit_frame, image=edit_but_img, bd=0, relief="groove", command=on_add_image_button_edit_frame)
edit_img.place(x=605, y=200)
edit_label_teacher_add = tkinter.Label(teacher_edit_frame, text="Teacher Add :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_teacher_add.place(x=0, y=375)
edit_label_teacher_add_ans = tkinter.Label(teacher_edit_frame, text=te_add, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_teacher_add_ans.place(x=150, y=375)
edit_entry_teacher_add_text = tkinter.StringVar()
edit_entry_teacher_add = tkinter.Entry(teacher_edit_frame, text=edit_entry_teacher_add_text, width=30)
edit_entry_teacher_add.place(x=320, y=375)
edit_label_teacher_edu = tkinter.Label(teacher_edit_frame, text="Teacher Edu. :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_teacher_edu.place(x=0, y=425)
edit_label_teacher_edu_ans = tkinter.Label(teacher_edit_frame, text=te_edu, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_teacher_edu_ans.place(x=150, y=425)
edit_entry_teacher_edu_text = tkinter.StringVar()
edit_entry_teacher_edu = tkinter.Entry(teacher_edit_frame, text=edit_entry_teacher_edu_text, width=30)
edit_entry_teacher_edu.place(x=320, y=425)
edit_label_teacher_sal = tkinter.Label(teacher_edit_frame, text="Teacher Salary :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_teacher_sal.place(x=0, y=475)
edit_label_teacher_sal_ans = tkinter.Label(teacher_edit_frame, text=te_salary, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_teacher_sal_ans.place(x=150, y=475)
edit_entry_teacher_sal_text = tkinter.StringVar()
edit_entry_teacher_sal = tkinter.Entry(teacher_edit_frame, text=edit_entry_teacher_sal_text, width=30)
edit_entry_teacher_sal.place(x=320, y=475)
edit_label_teacher_jo_date = tkinter.Label(teacher_edit_frame, text="Joining date :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_teacher_jo_date.place(x=0, y=525)
edit_label_teacher_jo_date_ans = tkinter.Label(teacher_edit_frame, text=te_jo_date, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_teacher_jo_date_ans.place(x=150, y=525)
edit_entry_teacher_jo_date_text = tkinter.StringVar()
edit_entry_teacher_jo_date = tkinter.Entry(teacher_edit_frame, text=edit_entry_teacher_jo_date_text, width=30)
edit_entry_teacher_jo_date.place(x=320, y=525)
edit_label_teacher_adh_no = tkinter.Label(teacher_edit_frame, text="Adhar No. :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_teacher_adh_no.place(x=0, y=575)
edit_label_teacher_adh_no_ans = tkinter.Label(teacher_edit_frame, text=te_adhar_no, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_teacher_adh_no_ans.place(x=150, y=575)
edit_entry_teacher_adh_no_text = tkinter.StringVar()
edit_entry_teacher_adh_no = tkinter.Entry(teacher_edit_frame, text=edit_entry_teacher_adh_no_text, width=30)
edit_entry_teacher_adh_no.place(x=320, y=575)
edit_label_te_TAG = tkinter.Label(teacher_edit_frame, text="TAG :", bg=background_colour, fg="white", font=("bold", 10))
edit_label_te_TAG.place(x=750, y=75)
edit_label_te_TAG_ans = tkinter.Label(teacher_edit_frame, text=te_TAG, width=20, anchor="nw", bg=background_colour, fg="gold", font=("bold", 10))
edit_label_te_TAG_ans.place(x=850, y=75)
options_for_TAG = ["STUDENT", "TEACHER", "DRIVER", "WORKER", "PRINCIPAL", "ASSISTANT", "OTHER"]
edit_entry_te_TAG_text = tkinter.StringVar()
edit_entry_te_TAG = tkinter.OptionMenu(teacher_edit_frame, edit_entry_te_TAG_text, *options_for_TAG)
edit_entry_te_TAG.place(x=1070, y=75)
edit_entry_te_TAG.config(relief="raised", bd=0)
# This function is used to destroy() the edit frame and go back to on_search_button function
def cancel_but():
teacher_edit_frame.destroy()
teacher_frame.place(x=50, y=30)
# edit_frame - Buttons
edit_button_save = tkinter.Button(teacher_edit_frame, text="Save Changes", width=14, relief="groove", command=on_edit_save_button_edit_frame)
edit_button_save.place(x=1150, y=620)
edit_button_cancel = tkinter.Button(teacher_edit_frame, text="Cancel", width=10, relief="groove", command=cancel_but)
edit_button_cancel.place(x=1050, y=620)
edit_button_delete = tkinter.Button(teacher_edit_frame, text="Delete Record", width=14, relief="groove", command=on_delete_button_edit_frame)
edit_button_delete.place(x=920, y=620)
teacher_edit_frame.mainloop()
teacher_frame = tkinter.Frame(main_window, width=1300, height=650, bg=background_colour)
teacher_frame.place(x=50, y=30)
if te_gen == "M":
gen_img_logo = "img_gender_male.png"
elif te_gen == "F":
gen_img_logo = "img_gender_female.png"
else:
gen_img_logo = "img_gender_male.png"
img_gender = ImageTk.PhotoImage(Image.open(gen_img_logo))
name_leb = tkinter.Label(teacher_frame, image=img_gender, compound="left", width=400, text = f" {te_name}", font=("bold", 15), bg=background_colour, fg="gold", anchor="nw")
name_leb.place(x=0, y=0)
id_leb = tkinter.Label(teacher_frame, text="Teacher ID:", bg=background_colour, fg="white", font=("bold", 10))
id_leb.place(x=0, y=65)
entry_id_leb = tkinter.Label(teacher_frame, text=te_id, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_id_leb.place(x=150, y=65)
gen_leb = tkinter.Label(teacher_frame, text="Teacher gender:", bg=background_colour, fg="white", font=("bold", 10))
gen_leb.place(x=0, y=115)
re_gen = ""
if te_gen == "F":
re_gen = "Female"
if te_gen == "M":
re_gen = "Male"
entry_gen_leb = tkinter.Label(teacher_frame, text=re_gen, bg=background_colour, fg="gold", font=("bold", 14))
entry_gen_leb.place(x=150, y=115)
add_age = tkinter.Label(teacher_frame, text="Teacher Age :", bg=background_colour, fg="white",
font=("bold", 10))
add_age.place(x=0, y=165)
entry_age_leb = tkinter.Label(teacher_frame, text=te_age, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_age_leb.place(x=150, y=165)
add_class = tkinter.Label(teacher_frame, text="Teacher Of Class :", bg=background_colour, fg="white",
font=("bold", 10))
add_class.place(x=0, y=215)
entry_class_leb = tkinter.Label(teacher_frame, text=te_of_class, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_class_leb.place(x=150, y=215)
add_sub = tkinter.Label(teacher_frame, text="Teacher Sub :", bg=background_colour, fg="white",
font=("bold", 10))
add_sub.place(x=0, y=265)
entry_sub_leb = tkinter.Label(teacher_frame, text=te_sub, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_sub_leb.place(x=150, y=265)
ph_leb = tkinter.Label(teacher_frame, text="Teacher Ph.No. :", bg=background_colour, fg="white",
font=("bold", 10))
ph_leb.place(x=0, y=315)
entry_ph_leb = tkinter.Label(teacher_frame, text=te_phone, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_ph_leb.place(x=150, y=315)
# Image of Teacher
img_leb = tkinter.Label(teacher_frame, text="Teacher Image:", font=("Bold", 10), bg=background_colour,
fg="white")
img_leb.place(x=1050, y=65)
canvas_frame = tkinter.Canvas(teacher_frame, width=200, height=260, bg=background_colour)
canvas_frame.place(x=1050, y=90)
try:
write_binary_image('got_image_from_mysql_db.jpg', te_img)
resize_img = Image.open('got_image_from_mysql_db.jpg')
resize_img = resize_img.resize((200, 260), Image.ANTIALIAS)
resize_img.save('nres_img.ppm', 'ppm')
got_image = ImageTk.PhotoImage(file='nres_img.ppm')
canvas_frame.create_image(0, 0, anchor="nw", image=got_image)
except TypeError:
pass
add_leb = tkinter.Label(teacher_frame, text="Teacher Add :", bg=background_colour, fg="white", font=("bold", 10))
add_leb.place(x=0, y=365)
entry_add_leb = tkinter.Label(teacher_frame, text=te_add, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_add_leb.place(x=150, y=365)
edu_leb = tkinter.Label(teacher_frame, text="Teacher Edu. :", bg=background_colour, fg="white", font=("bold", 10))
edu_leb.place(x=0, y=415)
entry_edu_leb = tkinter.Label(teacher_frame, text=te_edu, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_edu_leb.place(x=150, y=415)
sal_leb = tkinter.Label(teacher_frame, text="Teacher Salary :", bg=background_colour, fg="white", font=("bold", 10))
sal_leb.place(x=0, y=465)
entry_sal_leb = tkinter.Label(teacher_frame, text=te_salary, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_sal_leb.place(x=150, y=465)
jo_date_leb = tkinter.Label(teacher_frame, text="Joining Date :", bg=background_colour, fg="white", font=("bold", 10))
jo_date_leb.place(x=0, y=515)
entry_jo_date_leb = tkinter.Label(teacher_frame, text=te_jo_date, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_jo_date_leb.place(x=150, y=515)
adh_leb = tkinter.Label(teacher_frame, text="Adhar No. :", bg=background_colour, fg="white", font=("bold", 10))
adh_leb.place(x=0, y=565)
entry_adh_leb = tkinter.Label(teacher_frame, text=te_adhar_no, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_adh_leb.place(x=150, y=565)
TAG_leb = tkinter.Label(teacher_frame, text="TAG :", bg=background_colour, fg="white", font=("bold", 10))
TAG_leb.place(x=500, y=65)
entry_TAG_leb = tkinter.Label(teacher_frame, text=te_TAG, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_TAG_leb.place(x=650, y=65)
def cancel():
teacher_frame.destroy()
search_entry.place(x=50, y=30)
search_button.place(x=300, y=28)
but_frame.place(x=80, y=80)
# button to edit data of student
edit_data_button = tkinter.Button(teacher_frame, text="Edit Data", width=10, relief="groove", command=on_edit_button)
edit_data_button.place(x=1150, y=620)
cancel_button = tkinter.Button(teacher_frame, text="Cancel", width=10, relief="groove", command=cancel)
cancel_button.place(x=1050, y=620)
teacher_frame.mainloop()
def show_bus_driver_data(driver_value):
d_id = ""
d_name = ""
d_gen = ""
d_age = ""
d_phone = ""
d_img = ""
d_add = ""
d_jo_date = ""
d_adh_no = ""
d_tr_rout = ""
d_v_no = ""
d_lic = ""
d_v_sm = ""
d_v_ins = ""
d_TAG = ""
my_database_show_driver = sqlite3.connect("Database.db")
my_cursor_show_driver = my_database_show_driver.cursor()
query = f'''SELECT * FROM driver_data
WHERE id = '{driver_value}' or name = '{driver_value}';
'''
my_cursor_show_driver.execute(query)
read = my_cursor_show_driver.fetchall()
my_cursor_show_driver.close()
my_database_show_driver.close()
for col in read:
d_id = col[0]
d_name = col[1]
d_gen = col[2]
d_age = col[3]
d_phone = col[4]
d_img = col[5]
d_add = col[6]
d_jo_date = col[7]
d_adh_no = col[8]
d_tr_rout = col[9]
d_v_no = col[10]
d_lic = col[11]
d_v_sm = col[12]
d_v_ins = col[13]
d_TAG = col[14]
if d_id == "":
return "No"
else:
def on_edit_button():
def on_edit_save_button_edit_frame():
msg = tkinter.messagebox.askquestion("Confirmation ", "Do you want to update record ?")
if msg == "yes":
global bi_img
global bi_driver_lic
global bi_veh_sm_card_copy
global bi_veh_ins_copy
up_d_name = edit_entry_d_name.get()
up_d_gen = gender.get()
up_d_age = edit_entry_d_age.get()
up_d_ph = edit_entry_d_ph.get()
up_d_img = bi_img
up_d_add = edit_entry_d_add.get()
up_d_jo_date = edit_entry_d_jo_date.get()
up_d_adh = edit_entry_adh.get()
up_d_rout = edit_entry_v_rout.get()
up_d_v_no = edit_entry_v_no.get()
up_d_dr_lic = bi_driver_lic
up_d_v_sm = bi_veh_sm_card_copy
up_d_v_ins = bi_veh_ins_copy
up_d_TAG = edit_entry_d_TAG_text.get()
bi_img = None
bi_driver_lic = None
bi_veh_sm_card_copy = None
bi_veh_ins_copy = None
if up_d_name == "":
up_d_name = d_name
if up_d_gen == "0":
up_d_gen = d_gen
if up_d_age == "":
up_d_age = d_age
if up_d_ph == "":
up_d_ph = d_phone
if up_d_img is None:
up_d_img = d_img
if up_d_add == "":
up_d_add = d_add
if up_d_jo_date == "":
up_d_jo_date = d_jo_date
if up_d_adh == "":
up_d_adh = d_adh_no
if up_d_rout == "":
up_d_rout = d_tr_rout
if up_d_v_no == "":
up_d_v_no = d_v_no
if up_d_dr_lic is None:
up_d_dr_lic = d_lic
if up_d_v_sm is None:
up_d_v_sm = d_v_sm
if up_d_v_ins is None:
up_d_v_ins = d_v_ins
if up_d_TAG == "":
up_d_TAG = d_TAG
update_query = f''' UPDATE driver_data
SET
name=?,
gender=?,
age=?,
phone_no=?,
image=?,
address=?,
joining_date=?,
adhar_no=?,
travel_rout=?,
vehicle_no=?,
driving_license_copy=?,
vehicle_smart_card_copy=?,
vehicle_insurance_copy=?,
TAG=?
WHERE id={d_id}; '''
up_te_tuple = (up_d_name, up_d_gen, up_d_age, up_d_ph, up_d_img, up_d_add, up_d_jo_date, up_d_adh, up_d_rout, up_d_v_no, up_d_dr_lic, up_d_v_sm, up_d_v_ins, up_d_TAG)
my_database_up_driver = sqlite3.connect('Database.db')
my_cursor_up_driver = my_database_up_driver.cursor()
my_cursor_up_driver.execute(update_query, up_te_tuple)
my_database_up_driver.commit()
my_cursor_up_driver.execute(f''' SELECT id, name, address FROM driver_data WHERE id={d_id}''')
up_read = my_cursor_up_driver.fetchall()
my_cursor_up_driver.close()
my_database_up_driver.close()
up_ch_id = ''
up_ch_name = ''
up_ch_add = ''
for up_col in up_read:
up_ch_id = up_col[0]
up_ch_name = up_col[1]
up_ch_add = up_col[2]
if up_ch_name == up_d_name and up_ch_add == up_d_add:
tkinter.messagebox.showinfo(f"Status of Id no.= {up_ch_id}",
"Data is Updated successfully")
else:
tkinter.messagebox.showerror("Status", "Failed to update data !!!")
else:
pass
def on_add_image_button_edit_frame():
global bi_img
path = filedialog.askopenfilename()
bi_img = read_binary_image(path)
try:
re_img = Image.open(path)
re_img = re_img.resize((200, 260), Image.ANTIALIAS)
re_img.save("nres_img.ppm", "ppm")
photo = ImageTk.PhotoImage(Image.open("nres_img.ppm"))
edit_img.destroy()
edit_image.create_image(0, 0, image=photo, anchor="nw")
driver_edit_frame.mainloop()
except AttributeError:
pass
def on_delete_button_edit_frame():
msg = tkinter.messagebox.askquestion("Confirmation",
"Do you want to delete this Record, Note if you delete the record it will permanently delete...")
if msg == "yes":
my_database_del_driver = sqlite3.connect("Database.db")
my_cursor_del_driver = my_database_del_driver.cursor()
my_cursor_del_driver.execute(f'''DELETE FROM driver_data WHERE id={d_id};''')
msg_ = tkinter.messagebox.askquestion("Confirm Again", "Are you sure...!!!")
if msg_ == "yes":
my_database_del_driver.commit()
else:
pass
my_cursor_del_driver.execute(
f'''SELECT id FROM driver_data WHERE id={d_id}''')
delete_read = my_cursor_del_driver.fetchall()
my_cursor_del_driver.close()
my_database_del_driver.close()
if not delete_read:
tkinter.messagebox.showinfo(f"Status of Id= {d_id}, Name= {d_name}",
"Record Successfully deleted from database.")
else:
tkinter.messagebox.showwarning("Status", "Record is not deleted from database.")
else:
pass
driver_frame.place_forget()
driver_edit_frame = tkinter.Frame(main_window, width=1300, height=650, bg=background_colour)
driver_edit_frame.place(x=20, y=30)
# edit_frame = labels and Entries and buttons
edit_label_old_data = tkinter.Label(driver_edit_frame, text="Old Data:", font=("bold", 12),
bg=background_colour, fg="white")
edit_label_old_data.place(x=50, y=0)
edit_label_old_data = tkinter.Label(driver_edit_frame, text="Insert New Data:", font=("bold", 12),
bg=background_colour, fg="white")
edit_label_old_data.place(x=300, y=0)
# Labels and Entries
edit_label_d_name = tkinter.Label(driver_edit_frame, text="Driver Name:", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_d_name.place(x=0, y=75)
edit_label_d_name_ans = tkinter.Label(driver_edit_frame, text=d_name, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_d_name_ans.place(x=150, y=75)
edit_entry_d_name_text = tkinter.StringVar()
edit_entry_d_name = tkinter.Entry(driver_edit_frame, text=edit_entry_d_name_text, width=30)
edit_entry_d_name.place(x=320, y=75)
edit_label_d_gen = tkinter.Label(driver_edit_frame, text="Driver Gender:", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_d_gen.place(x=0, y=125)
edit_re_gen = ""
if d_gen == "F":
edit_re_gen = "Female"
if d_gen == "M":
edit_re_gen = "Male"
edit_d_gender = tkinter.Label(driver_edit_frame, text=edit_re_gen, bg=background_colour,
fg="gold", font=("bold", 10))
edit_d_gender.place(x=150, y=125)
gender = tkinter.StringVar()
gender.set(0)
edit_leb_d_gender_m = tkinter.Radiobutton(driver_edit_frame, text="Male", variable=gender,
value="M", bg=background_colour, fg="black",
font=("bold", 10))
edit_leb_d_gender_m.place(x=320, y=125)
edit_leb_d_gender_f = tkinter.Radiobutton(driver_edit_frame, text="Female", variable=gender,
value="F", bg=background_colour, fg="black",
font=("bold", 10))
edit_leb_d_gender_f.place(x=400, y=125)
edit_label_d_age = tkinter.Label(driver_edit_frame, text="Driver Age :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_d_age.place(x=0, y=175)
edit_label_d_age_ans = tkinter.Label(driver_edit_frame, text=d_age, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_d_age_ans.place(x=150, y=175)
edit_entry_d_age_text = tkinter.StringVar()
edit_entry_d_age = tkinter.Entry(driver_edit_frame, text=edit_entry_d_age_text, width=30)
edit_entry_d_age.place(x=320, y=175)
edit_label_d_ph = tkinter.Label(driver_edit_frame, text="Driver Ph.No. :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_d_ph.place(x=0, y=225)
edit_label_d_ph_ans = tkinter.Label(driver_edit_frame, text=d_phone, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_d_ph_ans.place(x=150, y=225)
edit_entry_d_ph_text = tkinter.StringVar()
edit_entry_d_ph = tkinter.Entry(driver_edit_frame, text=edit_entry_d_ph_text, width=30)
edit_entry_d_ph.place(x=320, y=225)
edit_leb_image = tkinter.Label(driver_edit_frame, text="Driver Image", bg=background_colour,
fg="white", font=("bold", 10))
edit_leb_image.place(x=530, y=75)
edit_image = tkinter.Canvas(driver_edit_frame, width=200, height=260)
edit_image.place(x=530, y=100)
edit_but_img = tkinter.PhotoImage(file="add_image.png")
edit_img = tkinter.Button(driver_edit_frame, image=edit_but_img, bd=0, relief="groove",
command=on_add_image_button_edit_frame)
edit_img.place(x=605, y=200)
edit_label_d_add = tkinter.Label(driver_edit_frame, text="Driver Add :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_d_add.place(x=0, y=275)
edit_label_d_add_ans = tkinter.Label(driver_edit_frame, text=d_add, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_d_add_ans.place(x=150, y=275)
edit_entry_d_add_text = tkinter.StringVar()
edit_entry_d_add = tkinter.Entry(driver_edit_frame, text=edit_entry_d_add_text, width=30)
edit_entry_d_add.place(x=320, y=275)
edit_label_d_jo_date = tkinter.Label(driver_edit_frame, text="Joining Date :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_d_jo_date.place(x=0, y=325)
edit_label_d_jo_date_ans = tkinter.Label(driver_edit_frame, text=d_jo_date, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_d_jo_date_ans.place(x=150, y=325)
edit_entry_d_jo_date_text = tkinter.StringVar()
edit_entry_d_jo_date = tkinter.Entry(driver_edit_frame, text=edit_entry_d_jo_date_text, width=30)
edit_entry_d_jo_date.place(x=320, y=325)
edit_label_adh = tkinter.Label(driver_edit_frame, text="Adhar No. :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_adh.place(x=0, y=375)
edit_label_adh_ans = tkinter.Label(driver_edit_frame, text=d_adh_no, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_adh_ans.place(x=150, y=375)
edit_entry_adh_text = tkinter.StringVar()
edit_entry_adh = tkinter.Entry(driver_edit_frame, text=edit_entry_adh_text, width=30)
edit_entry_adh.place(x=320, y=375)
edit_label_v_rout = tkinter.Label(driver_edit_frame, text="Vehicle rout :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_v_rout.place(x=0, y=425)
edit_label_v_rout_ans = tkinter.Label(driver_edit_frame, text=d_tr_rout, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_v_rout_ans.place(x=150, y=425)
edit_entry_v_rout_text = tkinter.StringVar()
edit_entry_v_rout = tkinter.Entry(driver_edit_frame, text=edit_entry_v_rout_text, width=30)
edit_entry_v_rout.place(x=320, y=425)
edit_label_v_no = tkinter.Label(driver_edit_frame, text="Vehicle No. :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_v_no.place(x=0, y=475)
edit_label_v_no_ans = tkinter.Label(driver_edit_frame, text=d_v_no, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_v_no_ans.place(x=150, y=475)
edit_entry_v_no_text = tkinter.StringVar()
edit_entry_v_no = tkinter.Entry(driver_edit_frame, text=edit_entry_v_no_text, width=30)
edit_entry_v_no.place(x=320, y=475)
edit_label_d_TAG = tkinter.Label(driver_edit_frame, text="TAG :", bg=background_colour, fg="white",
font=("bold", 10))
edit_label_d_TAG.place(x=0, y=525)
edit_label_d_TAG_ans = tkinter.Label(driver_edit_frame, text=d_TAG, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_d_TAG_ans.place(x=150, y=525)
options_for_TAG = ["STUDENT", "TEACHER", "DRIVER", "WORKER", "PRINCIPAL", "ASSISTANT", "OTHER"]
edit_entry_d_TAG_text = tkinter.StringVar()
edit_entry_d_TAG = tkinter.OptionMenu(driver_edit_frame, edit_entry_d_TAG_text, *options_for_TAG)
edit_entry_d_TAG.place(x=320, y=525)
edit_entry_d_TAG.config(relief="raised", bd=0)
label_v_lic = tkinter.Label(driver_edit_frame, text="Vehicle Documents :", bg=background_colour, fg="white",
font=("bold", 10))
label_v_lic.place(x=750, y=65)
def on_add_lic():
global bi_driver_lic
path = filedialog.askopenfilename()
bi_driver_lic = read_binary_image(path)
entry_v_lic = tkinter.Button(driver_edit_frame, text="Add Driving License", bd=1, command=on_add_lic)
entry_v_lic.place(x=900, y=65)
def on_add_sm_card():
global bi_veh_sm_card_copy
path = filedialog.askopenfilename()
bi_veh_sm_card_copy = read_binary_image(path)
entry_v_sm = tkinter.Button(driver_edit_frame, text="Add veh. Smart card", bd=1, command=on_add_sm_card)
entry_v_sm.place(x=900, y=100)
def on_add_ins():
global bi_veh_ins_copy
path = filedialog.askopenfilename()
bi_veh_ins_copy = read_binary_image(path)
entry_v_in = tkinter.Button(driver_edit_frame, text="Add veh. Insurance", bd=1, command=on_add_ins)
entry_v_in.place(x=900, y=135)
# This function is used to destroy() the edit frame and go back to on_search_button function
def cancel_but():
driver_edit_frame.destroy()
driver_frame.place(x=50, y=30)
# edit_frame - Buttons
edit_button_save = tkinter.Button(driver_edit_frame, text="Save Changes", width=14, relief="groove",
command=on_edit_save_button_edit_frame)
edit_button_save.place(x=1150, y=620)
edit_button_cancel = tkinter.Button(driver_edit_frame, text="Cancel", width=10, relief="groove",
command=cancel_but)
edit_button_cancel.place(x=1050, y=620)
edit_button_delete = tkinter.Button(driver_edit_frame, text="Delete Record", width=14, relief="groove",
command=on_delete_button_edit_frame)
edit_button_delete.place(x=920, y=620)
driver_edit_frame.mainloop()
def driver_v_doc():
try:
write_binary_image('doc_/Driver_car_License_copy.png', d_lic)
write_binary_image('doc_/Driver_car_smart_card_copy.png', d_v_sm)
write_binary_image('doc_/Driver_car_insurance_copy.png', d_v_ins)
filedialog.askopenfilename(initialdir="doc_")
except TypeError:
tkinter.messagebox.showinfo("Information", "Documents are Absent.\nTry to Add Documents")
driver_frame = tkinter.Frame(main_window, width=1300, height=650, bg=background_colour)
driver_frame.place(x=50, y=30)
if d_gen == "M":
gen_img_logo = "img_gender_male.png"
elif d_gen == "F":
gen_img_logo = "img_gender_female.png"
else:
gen_img_logo = "img_gender_male.png"
img_gender = ImageTk.PhotoImage(Image.open(gen_img_logo))
name_leb = tkinter.Label(driver_frame, image=img_gender, compound="left", width=400, text=f" {d_name}",
font=("bold", 15), bg=background_colour, fg="gold", anchor="nw")
name_leb.place(x=0, y=0)
id_leb = tkinter.Label(driver_frame, text="Driver ID:", bg=background_colour, fg="white",
font=("bold", 10))
id_leb.place(x=0, y=65)
entry_id_leb = tkinter.Label(driver_frame, text=d_id, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_id_leb.place(x=150, y=65)
gen_leb = tkinter.Label(driver_frame, text="Driver gender:", bg=background_colour, fg="white", font=("bold", 10))
gen_leb.place(x=0, y=115)
re_gen = ""
if d_gen == "F":
re_gen = "Female"
if d_gen == "M":
re_gen = "Male"
entry_gen_leb = tkinter.Label(driver_frame, text=re_gen, bg=background_colour, fg="gold", font=("bold", 14))
entry_gen_leb.place(x=150, y=115)
age_leb = tkinter.Label(driver_frame, text="Driver Age :", bg=background_colour, fg="white", font=("bold", 10))
age_leb.place(x=0, y=165)
entry_age_leb = tkinter.Label(driver_frame, text=d_age, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_age_leb.place(x=150, y=165)
ph_leb = tkinter.Label(driver_frame, text="Driver ph.No. :", bg=background_colour, fg="white", font=("bold", 10))
ph_leb.place(x=0, y=215)
entry_ph_leb = tkinter.Label(driver_frame, text=d_phone, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_ph_leb.place(x=150, y=215)
# Image of Teacher
img_leb = tkinter.Label(driver_frame, text="Driver Image:", font=("Bold", 10), bg=background_colour, fg="white")
img_leb.place(x=1050, y=65)
canvas_frame = tkinter.Canvas(driver_frame, width=200, height=260, bg=background_colour)
canvas_frame.place(x=1050, y=90)
try:
write_binary_image('got_image_from_mysql_db.jpg', d_img)
resize_img = Image.open('got_image_from_mysql_db.jpg')
resize_img = resize_img.resize((200, 260), Image.ANTIALIAS)
resize_img.save("nres_img.ppm", "ppm")
got_image = ImageTk.PhotoImage(file='nres_img.ppm')
canvas_frame.create_image(0, 0, anchor="nw", image=got_image)
except TypeError:
pass
add_leb = tkinter.Label(driver_frame, text="Driver Add :", bg=background_colour, fg="white", font=("bold", 10))
add_leb.place(x=0, y=265)
entry_add_leb = tkinter.Label(driver_frame, text=d_add, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_add_leb.place(x=150, y=265)
jo_date_leb = tkinter.Label(driver_frame, text="Joining Date :", bg=background_colour, fg="white", font=("bold", 10))
jo_date_leb.place(x=0, y=315)
entry_jo_date_leb = tkinter.Label(driver_frame, text=d_jo_date, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_jo_date_leb.place(x=150, y=315)
adh_no_leb = tkinter.Label(driver_frame, text="Adhar No. :", bg=background_colour, fg="white", font=("bold", 10))
adh_no_leb.place(x=0, y=365)
entry_adh_no_leb = tkinter.Label(driver_frame, text=d_adh_no, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_adh_no_leb.place(x=150, y=365)
tr_rout_leb = tkinter.Label(driver_frame, text="Travel Rout :", bg=background_colour, fg="white", font=("bold", 10))
tr_rout_leb.place(x=0, y=415)
entry_tr_rout_leb = tkinter.Label(driver_frame, text=d_tr_rout, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_tr_rout_leb.place(x=150, y=415)
v_no_leb = tkinter.Label(driver_frame, text="Vehicle No. :", bg=background_colour, fg="white", font=("bold", 10))
v_no_leb.place(x=0, y=465)
entry_v_no_leb = tkinter.Label(driver_frame, text=d_v_no, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_v_no_leb.place(x=150, y=465)
TAG_leb = tkinter.Label(driver_frame, text="TAG :", bg=background_colour, fg="white", font=("bold", 10))
TAG_leb.place(x=0, y=515)
entry_TAG_leb = tkinter.Label(driver_frame, text=d_TAG, width=30, anchor="nw", font=("bold", 14), bg=background_colour, fg="gold")
entry_TAG_leb.place(x=150, y=515)
lic_leb = tkinter.Label(driver_frame, text="Vehicle Documents :", bg=background_colour, fg="white", font=("bold", 10))
lic_leb.place(x=500, y=65)
doc_img = tkinter.PhotoImage(file='driver_doc_img.png')
entry_lic_leb = tkinter.Button(driver_frame, image=doc_img, bd=1, bg=background_colour, command=driver_v_doc)
entry_lic_leb.place(x=650, y=65)
def cancel():
driver_frame.destroy()
search_entry.place(x=50, y=30)
search_button.place(x=300, y=28)
but_frame.place(x=80, y=80)
# button to edit data of student
edit_data_button = tkinter.Button(driver_frame, text="Edit Data", width=10, relief="groove", command=on_edit_button)
edit_data_button.place(x=1150, y=620)
cancel_button = tkinter.Button(driver_frame, text="Cancel", width=10, relief="groove", command=cancel)
cancel_button.place(x=1050, y=620)
driver_frame.mainloop()
def show_worker(worker_value):
w_id = ""
w_name = ""
w_gen = ""
w_age = ""
w_phone = ""
w_img = ""
w_add = ""
w_jo_date = ""
w_adhar_no = ""
w_sal = ""
w_TAG = ""
my_database_show_worker = sqlite3.connect("Database.db")
my_cursor_show_worker = my_database_show_worker.cursor()
query = f'''SELECT * FROM worker_data
WHERE id = '{worker_value}' or name = '{worker_value}';
'''
my_cursor_show_worker.execute(query)
read = my_cursor_show_worker.fetchall()
my_cursor_show_worker.close()
my_database_show_worker.close()
for col in read:
w_id = col[0]
w_name = col[1]
w_gen = col[2]
w_age = col[3]
w_phone = col[4]
w_img = col[5]
w_add = col[6]
w_jo_date = col[7]
w_adhar_no = col[8]
w_sal = col[9]
w_TAG = col[10]
if w_id == "":
return "No"
else:
def on_edit_button():
def on_edit_save_button_edit_frame():
msg = tkinter.messagebox.askquestion("Confirmation ", "Do you want to update record ?")
if msg == "yes":
global bi_img
up_name = edit_entry_name.get()
up_gen = gender.get()
up_age = edit_entry_age.get()
up_ph = edit_entry_ph.get()
up_img = bi_img
up_add = edit_entry_add.get()
up_jo_date = edit_entry_jo_date.get()
up_adh_no = edit_entry_adh.get()
up_sal = edit_entry_sal.get()
up_TAG = edit_entry_w_TAG_text.get()
bi_img = None
if up_name == "":
up_name = w_name
if up_gen == "0":
up_gen = w_gen
if up_age == "":
up_age = w_age
if up_ph == "":
up_ph = w_phone
if up_img is None:
up_img = w_img
if up_add == "":
up_add = w_add
if up_jo_date == "":
up_jo_date = w_jo_date
if up_adh_no == "":
up_adh_no = w_adhar_no
if up_sal == "":
up_sal = w_sal
if up_TAG == "":
up_TAG = w_TAG
update_query = f''' UPDATE worker_data
SET
name=?,
gender=?,
age=?,
phone_no=?,
image=?,
address=?,
joining_date=?,
adhar_no=?,
salry=?,
TAG=?
WHERE id={w_id};
'''
up_te_tuple = (up_name, up_gen, up_age, up_ph, up_img, up_add, up_jo_date, up_adh_no, up_sal, up_TAG)
my_database_up_worker = sqlite3.connect("Database.db")
my_cursor_up_worker = my_database_up_worker.cursor()
my_cursor_up_worker.execute(update_query, up_te_tuple)
my_database_up_worker.commit()
my_cursor_up_worker.execute(f''' SELECT id, name, address FROM worker_data WHERE id={w_id}''')
up_read = my_cursor_up_worker.fetchall()
my_cursor_up_worker.close()
my_database_up_worker.close()
up_ch_id = ''
up_ch_name = ''
up_ch_add = ''
for up_col in up_read:
up_ch_id = up_col[0]
up_ch_name = up_col[1]
up_ch_add = up_col[2]
if up_ch_name == up_name and up_ch_add == up_add:
tkinter.messagebox.showinfo(f"Status of Id no.= {up_ch_id}",
"Data is Updated successfully")
else:
tkinter.messagebox.showerror("Status", "Failed to update data !!!")
else:
pass
def on_add_image_button_edit_frame():
global bi_img
path = filedialog.askopenfilename()
bi_img = read_binary_image(path)
try:
re_img = Image.open(path)
re_img = re_img.resize((200, 260), Image.ANTIALIAS)
re_img.save("nres_img.ppm", "ppm")
photo = ImageTk.PhotoImage(Image.open('nres_img.ppm'))
edit_img.destroy()
edit_image.create_image(0, 0, image=photo, anchor="nw")
worker_edit_frame.mainloop()
except AttributeError:
pass
def on_delete_button_edit_frame():
msg = tkinter.messagebox.askquestion("Confirmation",
"Do you want to delete this Record, Note if you delete the record it will permanently delete...")
if msg == "yes":
my_database_del_worker = sqlite3.connect("Database.db")
my_cursor_del_worker = my_database_del_worker.cursor()
my_cursor_del_worker.execute(f'''DELETE FROM worker_data WHERE id={w_id};''')
msg_ = tkinter.messagebox.askquestion("Confirm Again", "Are you sure...!!!")
if msg_ == "yes":
my_database_del_worker.commit()
else:
pass
my_cursor_del_worker.execute(
f'''SELECT id FROM worker_data WHERE id={w_id}''')
delete_read = my_cursor_del_worker.fetchall()
my_cursor_del_worker.close()
my_database_del_worker.close()
if not delete_read:
tkinter.messagebox.showinfo(f"Status of Id= {w_id}, Name= {w_name}",
"Record Successfully deleted from database.")
else:
tkinter.messagebox.showwarning("Status", "Record is not deleted from database.")
else:
pass
worker_frame.place_forget()
worker_edit_frame = tkinter.Frame(main_window, width=1300, height=650, bg=background_colour)
worker_edit_frame.place(x=50, y=30)
# edit_frame = labels and Entries and buttons
edit_label_old_data = tkinter.Label(worker_edit_frame, text="Old Data:", font=("bold", 12),
bg=background_colour, fg="white")
edit_label_old_data.place(x=50, y=0)
edit_label_old_data = tkinter.Label(worker_edit_frame, text="Insert New Data:", font=("bold", 12),
bg=background_colour, fg="white")
edit_label_old_data.place(x=300, y=0)
# Labels and Entries
edit_label_name = tkinter.Label(worker_edit_frame, text="Worker Name:", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_name.place(x=0, y=75)
edit_label_name_ans = tkinter.Label(worker_edit_frame, text=w_name, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_name_ans.place(x=150, y=75)
edit_entry_name_text = tkinter.StringVar()
edit_entry_name = tkinter.Entry(worker_edit_frame, text=edit_entry_name_text, width=30)
edit_entry_name.place(x=320, y=75)
edit_label_gen = tkinter.Label(worker_edit_frame, text="Worker Gender:", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_gen.place(x=0, y=125)
edit_re_gen = ""
if w_gen == "F":
edit_re_gen = "Female"
if w_gen == "M":
edit_re_gen = "Male"
edit_gender = tkinter.Label(worker_edit_frame, text=edit_re_gen, bg=background_colour,
fg="gold", font=("bold", 10))
edit_gender.place(x=150, y=125)
gender = tkinter.StringVar()
gender.set(0)
edit_leb_gender_m = tkinter.Radiobutton(worker_edit_frame, text="Male", variable=gender,
value="M", bg=background_colour, fg="black",
font=("bold", 10))
edit_leb_gender_m.place(x=320, y=125)
edit_leb_gender_f = tkinter.Radiobutton(worker_edit_frame, text="Female", variable=gender,
value="F", bg=background_colour, fg="black",
font=("bold", 10))
edit_leb_gender_f.place(x=390, y=125)
edit_label_age = tkinter.Label(worker_edit_frame, text="Worker Age :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_age.place(x=0, y=175)
edit_label_age_ans = tkinter.Label(worker_edit_frame, text=w_age, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_age_ans.place(x=150, y=175)
edit_entry_age_text = tkinter.StringVar()
edit_entry_age = tkinter.Entry(worker_edit_frame, text=edit_entry_age_text, width=30)
edit_entry_age.place(x=320, y=175)
edit_label_ph = tkinter.Label(worker_edit_frame, text="Worker Ph.No. :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_ph.place(x=0, y=225)
edit_label_ph_ans = tkinter.Label(worker_edit_frame, text=w_phone, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_ph_ans.place(x=150, y=225)
edit_entry_ph_text = tkinter.StringVar()
edit_entry_ph = tkinter.Entry(worker_edit_frame, text=edit_entry_ph_text, width=30)
edit_entry_ph.place(x=320, y=225)
edit_leb_image = tkinter.Label(worker_edit_frame, text="Worker Image", bg=background_colour,
fg="white", font=("bold", 10))
edit_leb_image.place(x=570, y=75)
edit_image = tkinter.Canvas(worker_edit_frame, width=200, height=260)
edit_image.place(x=570, y=100)
edit_but_img = tkinter.PhotoImage(file="add_image.png")
edit_img = tkinter.Button(worker_edit_frame, image=edit_but_img, bd=0, relief="groove",
command=on_add_image_button_edit_frame)
edit_img.place(x=645, y=200)
edit_label_add = tkinter.Label(worker_edit_frame, text="Worker Add :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_add.place(x=0, y=275)
edit_label_add_ans = tkinter.Label(worker_edit_frame, text=w_add, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_add_ans.place(x=150, y=275)
edit_entry_add_text = tkinter.StringVar()
edit_entry_add = tkinter.Entry(worker_edit_frame, text=edit_entry_add_text, width=30)
edit_entry_add.place(x=320, y=275)
edit_label_jo_date = tkinter.Label(worker_edit_frame, text="Joining Date :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_jo_date.place(x=0, y=325)
edit_label_jo_date_ans = tkinter.Label(worker_edit_frame, text=w_jo_date, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_jo_date_ans.place(x=150, y=325)
edit_entry_jo_date_text = tkinter.StringVar()
edit_entry_jo_date = tkinter.Entry(worker_edit_frame, text=edit_entry_jo_date_text, width=30)
edit_entry_jo_date.place(x=320, y=325)
edit_label_adh = tkinter.Label(worker_edit_frame, text="Adhar No. :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_adh.place(x=0, y=375)
edit_label_adh_ans = tkinter.Label(worker_edit_frame, text=w_adhar_no, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_adh_ans.place(x=150, y=375)
edit_entry_adh_text = tkinter.StringVar()
edit_entry_adh = tkinter.Entry(worker_edit_frame, text=edit_entry_adh_text, width=30)
edit_entry_adh.place(x=320, y=375)
edit_label_sal = tkinter.Label(worker_edit_frame, text="Salary :", bg=background_colour,
fg="white", font=("bold", 10))
edit_label_sal.place(x=0, y=425)
edit_label_sal_ans = tkinter.Label(worker_edit_frame, text=w_sal, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_sal_ans.place(x=150, y=425)
edit_entry_sal_text = tkinter.StringVar()
edit_entry_sal = tkinter.Entry(worker_edit_frame, text=edit_entry_sal_text, width=30)
edit_entry_sal.place(x=320, y=425)
edit_label_w_TAG = tkinter.Label(worker_edit_frame, text="TAG :", bg=background_colour, fg="white",
font=("bold", 10))
edit_label_w_TAG.place(x=0, y=475)
edit_label_w_TAG_ans = tkinter.Label(worker_edit_frame, text=w_TAG, width=20, anchor="nw",
bg=background_colour, fg="gold", font=("bold", 10))
edit_label_w_TAG_ans.place(x=150, y=475)
options_for_TAG = ["STUDENT", "TEACHER", "DRIVER", "WORKER", "PRINCIPAL", "ASSISTANT", "OTHER"]
edit_entry_w_TAG_text = tkinter.StringVar()
edit_entry_w_TAG = tkinter.OptionMenu(worker_edit_frame, edit_entry_w_TAG_text, *options_for_TAG)
edit_entry_w_TAG.place(x=320, y=475)
edit_entry_w_TAG.config(relief="raised", bd=0)
# This function is used to destroy() the edit frame and go back to on_search_button function
def cancel_but():
worker_edit_frame.destroy()
worker_frame.place(x=50, y=30)
# edit_frame - Buttons
edit_button_save = tkinter.Button(worker_edit_frame, text="Save Changes", width=14, relief="groove",
command=on_edit_save_button_edit_frame)
edit_button_save.place(x=1150, y=620)
edit_button_cancel = tkinter.Button(worker_edit_frame, text="Cancel", width=10, relief="groove",
command=cancel_but)
edit_button_cancel.place(x=1050, y=620)
edit_button_delete = tkinter.Button(worker_edit_frame, text="Delete Record", width=14, relief="groove",
command=on_delete_button_edit_frame)
edit_button_delete.place(x=920, y=620)
worker_edit_frame.mainloop()
worker_frame = tkinter.Frame(main_window, width=1300, height=650, bg=background_colour)
worker_frame.place(x=50, y=30)
if w_gen == "M":
gen_img_logo = "img_gender_male.png"
elif w_gen == "F":
gen_img_logo = "img_gender_female.png"
else:
gen_img_logo = "img_gender_male.png"
img_gender = ImageTk.PhotoImage(Image.open(gen_img_logo))
name_leb = tkinter.Label(worker_frame, image=img_gender, compound="left", width=400, text=f" {w_name}",
font=("bold", 15), bg=background_colour, fg="gold", anchor="nw")
name_leb.place(x=0, y=0)
id_leb = tkinter.Label(worker_frame, text="Worker ID:", bg=background_colour, fg="white",
font=("bold", 10))
id_leb.place(x=0, y=65)
entry_id_leb = tkinter.Label(worker_frame, text=w_id, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_id_leb.place(x=150, y=65)
gen_leb = tkinter.Label(worker_frame, text="Worker gender:", bg=background_colour, fg="white",
font=("bold", 10))
gen_leb.place(x=0, y=115)
re_gen = ""
if w_gen == "F":
re_gen = "Female"
if w_gen == "M":
re_gen = "Male"
entry_gen_leb = tkinter.Label(worker_frame, text=re_gen, bg=background_colour, fg="gold",
font=("bold", 14))
entry_gen_leb.place(x=150, y=115)
age_leb = tkinter.Label(worker_frame, text="Worker Age :", bg=background_colour, fg="white",
font=("bold", 10))
age_leb.place(x=0, y=165)
entry_age_leb = tkinter.Label(worker_frame, text=w_age, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_age_leb.place(x=150, y=165)
ph_leb = tkinter.Label(worker_frame, text="Worker ph.No. :", bg=background_colour, fg="white",
font=("bold", 10))
ph_leb.place(x=0, y=215)
entry_ph_leb = tkinter.Label(worker_frame, text=w_phone, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_ph_leb.place(x=150, y=215)
# Image of Teacher
img_leb = tkinter.Label(worker_frame, text="Worker Image:", font=("Bold", 10), bg=background_colour,
fg="white")
img_leb.place(x=500, y=0)
canvas_frame = tkinter.Canvas(worker_frame, width=200, height=260, bg=background_colour)
canvas_frame.place(x=500, y=24)
try:
write_binary_image('got_image_from_mysql_db.jpg', w_img)
resize_img = Image.open("got_image_from_mysql_db.jpg")
resize_img = resize_img.resize((200, 260), Image.ANTIALIAS)
resize_img.save("nres_img.ppm", "ppm")
got_image = ImageTk.PhotoImage(file='nres_img.ppm')
canvas_frame.create_image(0, 0, anchor="nw", image=got_image)
except TypeError:
pass
add_leb = tkinter.Label(worker_frame, text="Worker Add :", bg=background_colour, fg="white",
font=("bold", 10))
add_leb.place(x=0, y=265)
entry_add_leb = tkinter.Label(worker_frame, text=w_add, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_add_leb.place(x=150, y=265)
jo_date_leb = tkinter.Label(worker_frame, text="Joining Date :", bg=background_colour, fg="white",
font=("bold", 10))
jo_date_leb.place(x=0, y=315)
entry_jo_date_leb = tkinter.Label(worker_frame, text=w_jo_date, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_jo_date_leb.place(x=150, y=315)
adh_leb = tkinter.Label(worker_frame, text="Adhar No. :", bg=background_colour, fg="white",
font=("bold", 10))
adh_leb.place(x=0, y=365)
entry_adh_leb = tkinter.Label(worker_frame, text=w_adhar_no, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_adh_leb.place(x=150, y=365)
sal_leb = tkinter.Label(worker_frame, text="Salary :", bg=background_colour, fg="white",
font=("bold", 10))
sal_leb.place(x=0, y=415)
entry_sal_leb = tkinter.Label(worker_frame, text=w_sal, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_sal_leb.place(x=150, y=415)
TAG_leb = tkinter.Label(worker_frame, text="TAG :", bg=background_colour, fg="white",
font=("bold", 10))
TAG_leb.place(x=0, y=465)
entry_TAG_leb = tkinter.Label(worker_frame, text=w_TAG, width=30, anchor="nw", font=("bold", 14),
bg=background_colour, fg="gold")
entry_TAG_leb.place(x=150, y=465)
def cancel():
worker_frame.destroy()
search_entry.place(x=50, y=30)
search_button.place(x=300, y=28)
but_frame.place(x=80, y=80)
# button to edit data of student
edit_data_button = tkinter.Button(worker_frame, text="Edit Data", width=12, relief="groove", command=on_edit_button)
edit_data_button.place(x=1150, y=620)
cancel_button = tkinter.Button(worker_frame, text="Cancel", width=10, relief="groove", command=cancel)
cancel_button.place(x=1050, y=620)
worker_frame.mainloop()
if value == "":
pass
else:
search_entry.place_forget()
search_button.place_forget()
but_frame.place_forget()
student_search = show_student_data(value)
print("Student search = ", student_search)
teacher_search = show_teacher_data(value)
print("Teacher Search = ", teacher_search)
driver_search = show_bus_driver_data(value)
print("Driver search = ", driver_search)
worker_search = show_worker(value)
print("Worker search = ", worker_search)
if student_search == "No" and teacher_search == "No" and driver_search == "No" and worker_search == "No":
but_frame.place(x=80, y=80)
search_entry.place(x=50, y=30)
search_button.place(x=300, y=28)
tkinter.messagebox.showinfo(f"Info of {value}", f"The Data is not available. Named={value}\n You can try by Searching in show all fields. or\n You can Add new Data.")
# @@@@@@@@@@@@@@@@@ Main CODE @@@@@@@@@@@@@@@@
main_window = tkinter.Tk()
main_window.geometry("1200x600+20+20")
main_window.title("School Management System")
main_window.config(bg=background_colour)
main_window.iconbitmap('Engine_icon.ico')
menu = tkinter.Menu(main_window)
main_window.config(menu=menu)
file_ = tkinter.Menu(menu)
file_.add_command(label="Exit", command=main_window.destroy)
menu.add_cascade(label="File", menu=file_)
def on_con_us():
con_win = tkinter.Tk()
con_win.geometry("300x100")
con_win.title("Contact Us")
tkinter.Label(con_win, text="Not Given").pack()
con_win.mainloop()
edit = tkinter.Menu(menu)
edit.add_command(label="contact us", command=on_con_us)
menu.add_cascade(label="Help", menu=edit)
def on_ab_us():
con_win = tkinter.Tk()
con_win.geometry("600x150")
con_win.title("About Us")
tkinter.Label(con_win, text="School Management Software-").place(x=2, y=0)
tkinter.Label(con_win, text="1)Enables you to store and use the data ex. Student, Teacher, Driver and Worker.").place(x=2, y=20)
tkinter.Label(con_win, text="2)Data can be modify.").place(x=2, y=40)
tkinter.Label(con_win, text="3)We can store name, class, address, phone No., Image, documents, etc...").place(x=2, y=60)
con_win.mainloop()
about_us = tkinter.Menu(menu)
about_us.add_command(label="About software", command=on_ab_us)
menu.add_cascade(label="About Us", menu=about_us)
# Search Entry
def entry_bind(event):
on_search_button()
search_text = tkinter.StringVar()
search_entry = tkinter.Entry(main_window, text=search_text, width=40, bd=1)
search_entry.place(x=50, y=30)
search_entry.bind("<Return>", entry_bind)
search_img = tkinter.PhotoImage(file='search_img.png')
search_button = tkinter.Button(main_window, image=search_img, text=" Search", width=80, bg='white', relief="groove", command=on_search_button, compound='left')
search_button.place(x=300, y=28)
# but_frame to show all the add and show button present on main_window
but_frame = tkinter.Frame(main_window, width=1000, height=600, bg=background_colour)
but_frame.place(x=80, y=80)
but_frame_func()
main_window.mainloop()
# @@@@@@@@@@@@@@@@@ Main CODE END@@@@@@@@@@@@@@@@
| 54.677864 | 363 | 0.549466 | 23,752 | 190,443 | 4.074815 | 0.020335 | 0.033972 | 0.064163 | 0.064266 | 0.87808 | 0.827132 | 0.757514 | 0.669153 | 0.609733 | 0.579398 | 0 | 0.037335 | 0.342916 | 190,443 | 3,482 | 364 | 54.693567 | 0.736097 | 0.008675 | 0 | 0.455913 | 0 | 0.002051 | 0.136673 | 0.004394 | 0 | 0 | 0 | 0 | 0 | 1 | 0.024265 | false | 0.013329 | 0.001367 | 0 | 0.027341 | 0.001367 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
902a06c6360b802a362e125cdb2ee6ae3bdf0fab | 1,099 | py | Python | coreapi/models/company.py | recentfahim/smartbusinessbd | 61a74ae629f2c6e2317c41da23476c8780446e84 | [
"Apache-2.0"
] | null | null | null | coreapi/models/company.py | recentfahim/smartbusinessbd | 61a74ae629f2c6e2317c41da23476c8780446e84 | [
"Apache-2.0"
] | null | null | null | coreapi/models/company.py | recentfahim/smartbusinessbd | 61a74ae629f2c6e2317c41da23476c8780446e84 | [
"Apache-2.0"
] | null | null | null | from generic.models import BaseModel
from django.db import models
from .city import City
from .country import Country
class Company(BaseModel):
name = models.CharField(max_length=55)
website = models.CharField(max_length=50, null=True, blank=True)
email = models.EmailField(max_length=30, null=True, blank=True)
address = models.CharField(max_length=100, blank=True, null=True)
city = models.ForeignKey(City, on_delete=models.CASCADE, blank=True, null=True)
region = models.CharField(max_length=20, blank=True, null=True)
postcode = models.IntegerField(blank=True, null=True)
country = models.ForeignKey(Country, on_delete=models.CASCADE, blank=True, null=True)
phone = models.CharField(max_length=15, null=True, blank=True)
fax = models.CharField(max_length=15, null=True, blank=True)
image = models.CharField(max_length=50, blank=True, null=True)
logo = models.CharField(max_length=50, blank=True, null=True)
class Meta:
db_table = 'company'
verbose_name_plural = 'companies'
def __str__(self):
return self.name
| 39.25 | 89 | 0.728844 | 153 | 1,099 | 5.117647 | 0.313725 | 0.112388 | 0.183908 | 0.245211 | 0.349936 | 0.316731 | 0.316731 | 0.316731 | 0.219668 | 0 | 0 | 0.020541 | 0.158326 | 1,099 | 27 | 90 | 40.703704 | 0.825946 | 0 | 0 | 0 | 0 | 0 | 0.014572 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.045455 | false | 0 | 0.181818 | 0.045455 | 0.909091 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
902b9d0df569aa4f0d47943405288ecd48de946d | 3,137 | py | Python | fpbox/types.py | AN3223/fpbox | e0780afc207ffc958151c8e7aacb5fa1da39b8f4 | [
"MIT"
] | null | null | null | fpbox/types.py | AN3223/fpbox | e0780afc207ffc958151c8e7aacb5fa1da39b8f4 | [
"MIT"
] | null | null | null | fpbox/types.py | AN3223/fpbox | e0780afc207ffc958151c8e7aacb5fa1da39b8f4 | [
"MIT"
] | null | null | null | from collections.abc import Sequence
from inspect import isgenerator
from builtins import map as lazymap, filter as lazyfilter
from itertools import takewhile, dropwhile
from .funcs import *
class FPboxException(Exception):
pass
class Stream:
"""
Takes any iterable, returns a Stream object that gives access to
a set of lazy (FP-related) methods. Some things to note: no methods
mutate the iterable, most methods return a Stream object, and the
Stream objects themselves are generators that yield the contents
of the original iterable
"""
def __init__(self, xs):
self.xs = xs
def __iter__(self):
return (x for x in self.xs)
def map(self, f):
return Stream(lazymap(f, self))
def filter(self, f):
return Stream(lazyfilter(f, self))
def reduce(self, f):
return Stream(lazy_reduce(f, self))
def takewhile(self, f):
return Stream(takewhile(f, self))
def dropwhile(self, f):
return Stream(dropwhile(f, self))
def list(self):
"""Packs the stream up into a list"""
return list(self)
def tuple(self):
"""Packs the stream up into a tuple"""
return tuple(self)
class Array(Sequence):
"""
Immutable homogenous collection. It can be initialized with either a
single list/tuple/generator (which will return an Array consisting of the
contents of said list/tuple/generator) or it can just be given multiple
arguments to initialize the Array with
"""
def __init__(self, *items):
self.items = collect(items)
self.type = type(head(self.items))
if False in (isinstance(x, self.type) for x in self.items):
raise FPboxException("You can't mix types in an Array")
def __repr__(self):
if self.type == Char: # Creates a representation of [Char]
unpacked_chars = [x.char for x in self.items]
return '"{}"'.format(sum(unpacked_chars))
else:
return str(list(self.items))
def __str__(self):
if self.type == Char:
return self.__repr__()[1:-1]
return self.__repr__()
def __add__(self, other):
if isinstance(other, Array):
other = other.items
return Array(self.items + tuple(other))
def __getitem__(self, item):
return self.items[item]
def __len__(self):
return len(self.items)
class Char:
"""Holds a single character"""
def __init__(self, char):
if isinstance(char, str) and len(char) == 1:
self.char = char
else:
raise FPboxException("Invalid input, Chars must be str with a length of 1")
def __repr__(self):
return "'{}'".format(self.char)
def __str__(self):
return self.char
def __add__(self, other):
return self.char + other
def chars(string):
"""
Helper function that returns an array of characters from a string
"""
return Array(map(Char, list(string)))
| 27.761062 | 88 | 0.607587 | 404 | 3,137 | 4.571782 | 0.321782 | 0.043855 | 0.029778 | 0.046021 | 0.062805 | 0.027071 | 0.027071 | 0 | 0 | 0 | 0 | 0.001821 | 0.299649 | 3,137 | 112 | 89 | 28.008929 | 0.838871 | 0.233982 | 0 | 0.15625 | 0 | 0 | 0.040872 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3125 | false | 0.015625 | 0.078125 | 0.171875 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
9049fb94644a38d29a83c2a5a9a49977d2420e9d | 734 | py | Python | APPS/MEMBER/models.py | RockhoRockho/Project_FG | 362c75ebfdfcc8f1a8c88236279fefe24dfbd2c7 | [
"MIT"
] | 1 | 2022-03-25T12:45:24.000Z | 2022-03-25T12:45:24.000Z | APPS/MEMBER/models.py | RockhoRockho/Project_FG | 362c75ebfdfcc8f1a8c88236279fefe24dfbd2c7 | [
"MIT"
] | null | null | null | APPS/MEMBER/models.py | RockhoRockho/Project_FG | 362c75ebfdfcc8f1a8c88236279fefe24dfbd2c7 | [
"MIT"
] | null | null | null | from django.db import models
class Member(models.Model):
member_id = models.AutoField(primary_key=True, verbose_name='회원ID')
username = models.CharField(max_length=30, verbose_name='아이디')
pw = models.CharField(max_length=30, verbose_name='비밀번호')
name = models.CharField(max_length=30, verbose_name='이름')
gender = models.CharField(max_length=2, verbose_name='성별')
email = models.EmailField(max_length=30, verbose_name='이메일')
phoneNum = models.IntegerField(verbose_name='폰번호')
birth = models.DateField(verbose_name='생년월일')
class Meta:
db_table = 'member'
verbose_name='회원'
verbose_name_plural='회원들'
def __str__(self):
return f'{self.pk} : {self.username}' | 38.631579 | 71 | 0.694823 | 97 | 734 | 5.020619 | 0.494845 | 0.225873 | 0.147844 | 0.197125 | 0.273101 | 0.227926 | 0.227926 | 0 | 0 | 0 | 0 | 0.014876 | 0.175749 | 734 | 19 | 72 | 38.631579 | 0.790083 | 0 | 0 | 0 | 0 | 0 | 0.085714 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.0625 | false | 0 | 0.0625 | 0.0625 | 0.8125 | 0 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
5f4d7e30e21d1a010842299bdfc97771cf1b1abc | 131 | py | Python | consumo_energia/cons_energia.py | Arthurnevs/E1 | 17de7fe2852a93d90dfb3fa61fdefda16e8b7938 | [
"Apache-2.0"
] | null | null | null | consumo_energia/cons_energia.py | Arthurnevs/E1 | 17de7fe2852a93d90dfb3fa61fdefda16e8b7938 | [
"Apache-2.0"
] | null | null | null | consumo_energia/cons_energia.py | Arthurnevs/E1 | 17de7fe2852a93d90dfb3fa61fdefda16e8b7938 | [
"Apache-2.0"
] | null | null | null | potencia = int(input())
tempo = int(input())
qw = potencia / 1000
hr = tempo / 60
kwh = hr * qw
print('{:.1f} kWh'.format(kwh))
| 13.1 | 31 | 0.59542 | 20 | 131 | 3.9 | 0.6 | 0.205128 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.066667 | 0.198473 | 131 | 9 | 32 | 14.555556 | 0.67619 | 0 | 0 | 0 | 0 | 0 | 0.076336 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.166667 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
5f4ed23cf61983d79a566a4d2accdeb355de7d38 | 53 | py | Python | login.py | khalil-ben-khalifa/awesome-for-beginners | 9a51ae39a509e2dbcfb1431e2a313b2a0805992e | [
"CC0-1.0"
] | null | null | null | login.py | khalil-ben-khalifa/awesome-for-beginners | 9a51ae39a509e2dbcfb1431e2a313b2a0805992e | [
"CC0-1.0"
] | null | null | null | login.py | khalil-ben-khalifa/awesome-for-beginners | 9a51ae39a509e2dbcfb1431e2a313b2a0805992e | [
"CC0-1.0"
] | null | null | null | zweite feature
erste feature
weiter programieren ...
| 13.25 | 23 | 0.811321 | 6 | 53 | 7.166667 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.132075 | 53 | 3 | 24 | 17.666667 | 0.934783 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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 | 3 |
5f661188aa39ecc0ba1f5e6c06621f3b4635b8a7 | 117 | py | Python | web_scraping/ec2files/ec2file68.py | nikibhatt/Groa | fc2d4ae87cb825e6d54a0831c72be16541eebe61 | [
"MIT"
] | 1 | 2020-04-08T19:44:30.000Z | 2020-04-08T19:44:30.000Z | web_scraping/ec2files/ec2file68.py | cmgospod/Groa | 31b3624bfe61e772b55f8175b4e95d63c9e67966 | [
"MIT"
] | null | null | null | web_scraping/ec2files/ec2file68.py | cmgospod/Groa | 31b3624bfe61e772b55f8175b4e95d63c9e67966 | [
"MIT"
] | 1 | 2020-09-12T07:07:41.000Z | 2020-09-12T07:07:41.000Z | from scraper import *
s = Scraper(start=121176, end=122957, max_iter=30, scraper_instance=68)
s.scrape_letterboxd() | 39 | 72 | 0.777778 | 18 | 117 | 4.888889 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.152381 | 0.102564 | 117 | 3 | 73 | 39 | 0.685714 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
5f75a9ec5d509ab1934c8fa592a02b7b9eef88c1 | 143 | py | Python | powrap/__init__.py | deronnax/powrap | dc9f814ae99acb3582afe1e6f502b23d0726f236 | [
"MIT"
] | 5 | 2020-07-18T21:45:48.000Z | 2020-10-12T16:25:44.000Z | powrap/__init__.py | deronnax/powrap | dc9f814ae99acb3582afe1e6f502b23d0726f236 | [
"MIT"
] | 64 | 2018-11-17T10:46:34.000Z | 2020-10-28T08:24:35.000Z | powrap/__init__.py | deronnax/powrap | dc9f814ae99acb3582afe1e6f502b23d0726f236 | [
"MIT"
] | 9 | 2019-02-27T11:45:54.000Z | 2020-10-15T11:10:02.000Z | """Script to fix indentation of given ``.po`` files."""
__author__ = """Julien Palard"""
__email__ = "julien@palard.fr"
__version__ = "1.0.0"
| 23.833333 | 55 | 0.664336 | 19 | 143 | 4.368421 | 0.842105 | 0.289157 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.024194 | 0.132867 | 143 | 5 | 56 | 28.6 | 0.645161 | 0.342657 | 0 | 0 | 0 | 0 | 0.386364 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
5f7f0a471d2369df27a887c06c3a9fbd04848767 | 629 | py | Python | botx/dependencies/injection_params.py | ExpressApp/pybotx | 97c8b1ce5d45a05567ed01d545cb43174a2dcbb9 | [
"MIT"
] | 13 | 2021-01-21T12:43:10.000Z | 2022-03-23T11:11:59.000Z | botx/dependencies/injection_params.py | ExpressApp/pybotx | 97c8b1ce5d45a05567ed01d545cb43174a2dcbb9 | [
"MIT"
] | 259 | 2020-02-26T08:51:03.000Z | 2022-03-23T11:08:36.000Z | botx/dependencies/injection_params.py | ExpressApp/pybotx | 97c8b1ce5d45a05567ed01d545cb43174a2dcbb9 | [
"MIT"
] | 5 | 2019-12-02T16:19:22.000Z | 2021-11-22T20:33:34.000Z | """Wrappers around param classes that are used in handlers or dependencies."""
from typing import Any, Callable
from botx.dependencies import models
def Depends(dependency: Callable, *, use_cache: bool = True) -> Any: # noqa: N802
"""Wrap Depends param for using in handlers.
Arguments:
dependency: callable object that will be used in handlers or other dependencies
instances.
use_cache: use cache for dependency.
Returns:
[Depends][botx.dependencies.models.Depends] that wraps passed callable.
"""
return models.Depends(dependency=dependency, use_cache=use_cache)
| 31.45 | 87 | 0.712242 | 78 | 629 | 5.692308 | 0.512821 | 0.09009 | 0.063063 | 0.072072 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006036 | 0.209857 | 629 | 19 | 88 | 33.105263 | 0.887324 | 0.585056 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.5 | 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 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
5fb5adf34b13dab338394a0f753d269a93d933a8 | 2,755 | py | Python | mysite/scrapy/migrations/0006_auto_20200807_1150.py | prnake/search_engine_demo | 57122052f63bbd054e0ca84d3c6832e6ecb00ec8 | [
"MIT"
] | 3 | 2020-08-08T04:44:29.000Z | 2020-09-10T07:38:11.000Z | mysite/scrapy/migrations/0006_auto_20200807_1150.py | prnake/search_engine_demo | 57122052f63bbd054e0ca84d3c6832e6ecb00ec8 | [
"MIT"
] | null | null | null | mysite/scrapy/migrations/0006_auto_20200807_1150.py | prnake/search_engine_demo | 57122052f63bbd054e0ca84d3c6832e6ecb00ec8 | [
"MIT"
] | null | null | null | # Generated by Django 3.0.3 on 2020-08-07 11:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('scrapy', '0005_auto_20200807_1124'),
]
operations = [
migrations.AddField(
model_name='post',
name='a12',
field=models.TextField(blank=True, verbose_name='本科生课容量'),
),
migrations.AddField(
model_name='post',
name='a13',
field=models.TextField(blank=True, verbose_name='研究生课容量'),
),
migrations.AddField(
model_name='post',
name='a14',
field=models.TextField(blank=True, verbose_name='上课时间'),
),
migrations.AddField(
model_name='post',
name='a15',
field=models.TextField(blank=True, verbose_name='选课文字说明'),
),
migrations.AddField(
model_name='post',
name='a16',
field=models.TextField(blank=True, verbose_name='课程特色'),
),
migrations.AddField(
model_name='post',
name='a17',
field=models.TextField(blank=True, verbose_name='年级'),
),
migrations.AddField(
model_name='post',
name='a18',
field=models.TextField(blank=True, verbose_name='是否二级选课'),
),
migrations.AddField(
model_name='post',
name='a19',
field=models.TextField(blank=True, verbose_name='实验信息'),
),
migrations.AddField(
model_name='post',
name='a20',
field=models.TextField(blank=True, verbose_name='重修是否占容量'),
),
migrations.AddField(
model_name='post',
name='a21',
field=models.TextField(blank=True, verbose_name='是否选课时限制'),
),
migrations.AddField(
model_name='post',
name='a22',
field=models.TextField(blank=True, verbose_name='本科文化素质课组'),
),
migrations.AddField(
model_name='post',
name='department',
field=models.TextField(default='未知', verbose_name='开课院系'),
),
migrations.AddField(
model_name='post',
name='teacher',
field=models.TextField(default='未知', verbose_name='主讲教师'),
),
migrations.AlterField(
model_name='post',
name='class_id',
field=models.CharField(blank=True, max_length=20, verbose_name='课序号'),
),
migrations.AlterField(
model_name='post',
name='study_credit',
field=models.IntegerField(default=0, verbose_name='学分'),
),
]
| 30.955056 | 82 | 0.532849 | 259 | 2,755 | 5.528958 | 0.281853 | 0.094274 | 0.136173 | 0.178073 | 0.732542 | 0.732542 | 0.363128 | 0 | 0 | 0 | 0 | 0.030601 | 0.335753 | 2,755 | 88 | 83 | 31.306818 | 0.751913 | 0.016334 | 0 | 0.54878 | 1 | 0 | 0.087149 | 0.008493 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.012195 | 0 | 0.04878 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 1 | 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 | 3 |
5fc8780c52ffdfdd5ff84bd24014c621d65227fa | 151 | py | Python | website_google_tag_manager/models/website.py | ogecko/odoo_sale_addons | 1ef6babcb25f9c05644f0718ab2ee2b9886de446 | [
"MIT"
] | 3 | 2019-09-06T02:15:30.000Z | 2022-02-26T04:08:59.000Z | website_google_tag_manager/models/website.py | ogecko/odoo_sale_addons | 1ef6babcb25f9c05644f0718ab2ee2b9886de446 | [
"MIT"
] | null | null | null | website_google_tag_manager/models/website.py | ogecko/odoo_sale_addons | 1ef6babcb25f9c05644f0718ab2ee2b9886de446 | [
"MIT"
] | 5 | 2020-04-19T02:12:25.000Z | 2022-02-26T04:09:02.000Z | from odoo import fields, models
class Website(models.Model):
_inherit = 'website'
google_tag_manager_key = fields.Char("Container ID")
| 16.777778 | 56 | 0.708609 | 19 | 151 | 5.421053 | 0.842105 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.198676 | 151 | 9 | 57 | 16.777778 | 0.85124 | 0 | 0 | 0 | 0 | 0 | 0.125 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
395d786239cf39a1c6dcfbf9d02a9a5540a7818d | 255 | py | Python | weather-app.py | iqthetester/intermediate-python-course | bf6f3156be983e09e8c79b563225d25a3f523f85 | [
"Unlicense",
"MIT"
] | null | null | null | weather-app.py | iqthetester/intermediate-python-course | bf6f3156be983e09e8c79b563225d25a3f523f85 | [
"Unlicense",
"MIT"
] | 2 | 2021-12-30T00:22:08.000Z | 2021-12-30T02:33:21.000Z | weather-app.py | iqthetester/intermediate-python-course | bf6f3156be983e09e8c79b563225d25a3f523f85 | [
"Unlicense",
"MIT"
] | null | null | null | import time
WeatherData = {'Date': '2021-04-14', 'Temperature': 80, 'Units': 'Fahrenheit'}
print('Date: ' + WeatherData['Date'])
time.sleep(1)
print('Temperature: ' + str(WeatherData['Temperature']))
time.sleep(1)
print('Units: ' + WeatherData['Units'])
| 31.875 | 78 | 0.67451 | 30 | 255 | 5.733333 | 0.5 | 0.174419 | 0.116279 | 0.174419 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.052174 | 0.098039 | 255 | 7 | 79 | 36.428571 | 0.695652 | 0 | 0 | 0.285714 | 0 | 0 | 0.337255 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.142857 | 0 | 0.142857 | 0.428571 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
397c2355dc04b60cd318b756913594c11c5f20ba | 14,362 | py | Python | server_for_unity.py | skywolf829/ProceduralContentGeneration-FinalProject | 5c0d185f69e85e82dc630a2a29109e86c82919c0 | [
"MIT"
] | 1 | 2022-03-24T01:01:33.000Z | 2022-03-24T01:01:33.000Z | server_for_unity.py | skywolf829/ProceduralContentGeneration-FinalProject | 5c0d185f69e85e82dc630a2a29109e86c82919c0 | [
"MIT"
] | null | null | null | server_for_unity.py | skywolf829/ProceduralContentGeneration-FinalProject | 5c0d185f69e85e82dc630a2a29109e86c82919c0 | [
"MIT"
] | 1 | 2021-01-27T00:20:56.000Z | 2021-01-27T00:20:56.000Z | from sampling import *
import time
import zmq
import base64
import imageio
def optimize_one_step(model, optimizer, noise,
img_noises, losses, masks, heightmap_full_resolution):
imgs_over_time, noise, optimizer = \
optimize_with(model, optimizer, noise, img_noises,
losses, masks, 1, heightmap_full_resolution)
img_to_send = imgs_over_time[-1].copy()
img_to_send = bytearray(img_to_send)
img_to_send = base64.b64encode(img_to_send)
return noise, img_to_send, imgs_over_time[-1], optimizer
def optimize_one_step_multinoise(model, optimizer, noises, freeze_styles,
img_noises, losses, masks, heightmap_full_resolution):
imgs_over_time, noises, optimizer = \
optimize_with_multistyle(model, optimizer, noises, freeze_styles,
img_noises,
losses, masks, 1, heightmap_full_resolution)
img_to_send = imgs_over_time[-1].copy()
img_to_send = bytearray(img_to_send)
img_to_send = base64.b64encode(img_to_send)
return noises, img_to_send, imgs_over_time[-1], optimizer
def request_and_masks_to_losses_and_masks(request_list):
losses = []
masks = []
if(len(request_list) == 0 or request_list[0] == ''):
print("Error with request list, no elements")
losses.append(lower_heightmap_loss)
masks.append(torch.ones([num_images, 1, img_resolution, img_resolution],
device="cuda:0"))
else:
spot = 0
while(spot < len(request_list)):
mask = torch.zeros([num_images, 1, img_resolution, img_resolution],
device="cuda:0")
if(request_list[spot] == "Raise"):
losses.append(higher_heightmap_loss)
elif(request_list[spot] == "Lower"):
losses.append(lower_heightmap_loss)
elif(request_list[spot] == "Exact height"):
losses.append(exact_height_loss)
elif(request_list[spot] == "Decrease vertical alignment"):
losses.append(decrease_x_slope_loss)
elif(request_list[spot] == "Increase vertical alignment"):
losses.append(increase_x_slope_loss)
elif(request_list[spot] == "Decrease horizontal alignment"):
losses.append(decrease_y_slope_loss)
elif(request_list[spot] == "Increase horizontal alignment"):
losses.append(increase_y_slope_loss)
elif(request_list[spot] == "Smooth"):
losses.append(smoothness_loss)
elif(request_list[spot] == "Ridged" or \
request_list[spot] == "Ridges"):
losses.append(ridgidness_loss)
else:
print("Loss " + str(request_list[spot]) + " not recognized.")
spot += 1
m = torch.tensor(np.array(request_list[ \
spot:spot+img_resolution*img_resolution], dtype=np.float32)).to("cuda:0") / 255.0
m = m.reshape([img_resolution, img_resolution])
mask[:,:,:,:] = m
masks.append(mask)
spot += img_resolution*img_resolution
return losses, masks
def request_to_losses_and_masks(request_list):
losses = []
masks = []
if(len(request_list) == 0 or request_list[0] == ''):
print("Error with request list, no elements")
losses.append(lower_heightmap_loss)
masks.append(torch.ones([num_images, 1, img_resolution, img_resolution],
device="cuda:0"))
else:
spot = 0
while(spot < len(request_list)):
mask = torch.zeros([num_images, 1, img_resolution, img_resolution],
device="cuda:0")
if(request_list[spot] == "Raise"):
losses.append(higher_heightmap_loss)
elif(request_list[spot] == "Lower"):
losses.append(lower_heightmap_loss)
elif(request_list[spot] == "Decrease vertical alignment"):
losses.append(decrease_vertical_orientation_loss)
elif(request_list[spot] == "Increase vertical alignment"):
losses.append(increase_vertical_orientation_loss)
elif(request_list[spot] == "Decrease horizontal alignment"):
losses.append(decrease_horizontal_orientation_loss)
elif(request_list[spot] == "Increase horizontal alignment"):
losses.append(increase_horizontal_orientation_loss)
elif(request_list[spot] == "Smooth"):
losses.append(smoothness_loss)
elif(request_list[spot] == "Ridged"):
losses.append(ridgidness_loss)
else:
print("Loss " + str(request_list[spot]) + " not recognized.")
mask[:,:,int(request_list[spot+3]):int(request_list[spot+4]),
int(request_list[spot+1]):int(request_list[spot+2])] = 1
masks.append(mask.clone())
spot += 5
return losses, masks
def append_new_noise_list(new_noises, new_image_noises, recent_noise_list,
recent_image_noise_list, maxI=1000):
new_ns = []
for i in range(len(new_noises)):
new_ns.append(new_noises[i].clone())
recent_noise_list.append(new_ns)
while(len(recent_noise_list) > maxI):
recent_noise_list.pop(0)
recent_image_noise_list.append(new_image_noises.clone())
while(len(recent_image_noise_list) > maxI):
recent_image_noise_list.pop(0)
print(len(new_noises))
print(len(recent_noise_list))
print(len(recent_image_noise_list))
return recent_noise_list, recent_image_noise_list
if __name__ == '__main__':
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5555")
model = load_latest_model()
num_image_tiles = 8
results_dir = './results'
name = 'default'
iterations_to_save = 1500
iterations = 100
num_images = 1
img_resolution = 128
heightmap_full_resolution = 128
use_multistyles = False
training_heightmap = False
curr_iter = 0
freeze_style = []
multinoises = []
for i in range(6):
multinoises.append(torch.randn(num_images, 512).cuda())
freeze_style.append(False)
noise = torch.randn(num_images, 512).cuda()
img_noises = image_noise(1, 128, device = 0)
noise.requires_grad = True
recent_noises = []
recent_img_noises = []
#last_noise = noise.clone()
#last_img_noises = img_noises.clone()
try:
while True:
# Wait for next request from client
message = socket.recv()
message = message.decode('ascii').split(",")
print("Received " + str(message[0]))
if(message[0] == "requesting_heightmap"):
if(not training_heightmap):
training_heightmap = True
curr_iter = 0
img_seq = []
losses, masks = request_to_losses_and_masks(message[1:])
multinoises, img_to_send, img_to_save, optimizer = \
optimize_one_step_multinoise(model, None, multinoises,
freeze_style, img_noises,
losses, masks, heightmap_full_resolution)
recent_noises, recent_img_noises = append_new_noise_list(multinoises,
img_noises, recent_noises, recent_img_noises, maxI=iterations_to_save)
socket.send(img_to_send)
img_seq.append(img_to_save)
curr_iter += 1
print("Sent image")
elif(curr_iter < iterations):
multinoises, img_to_send, img_to_save, optimizer = \
optimize_one_step_multinoise(model, optimizer, multinoises,
freeze_style,
img_noises, losses, masks, heightmap_full_resolution)
recent_noises, recent_img_noises = append_new_noise_list(multinoises,
img_noises, recent_noises, recent_img_noises, maxI=iterations_to_save)
socket.send(img_to_send)
img_seq.append(img_to_save)
curr_iter += 1
print("Sent image")
else:
training_heightmap = False
imageio.imwrite("sentimage.png", img_seq[-1])
imageio.mimwrite("imgseq.gif", img_seq)
socket.send_string("finished")
if(message[0] == "requesting_heightmap_with_masks"):
if(not training_heightmap):
training_heightmap = True
curr_iter = 0
img_seq = []
losses, masks = request_and_masks_to_losses_and_masks(message[1:])
multinoises, img_to_send, img_to_save, optimizer = \
optimize_one_step_multinoise(model, None, multinoises, freeze_style,
img_noises,
losses, masks, heightmap_full_resolution)
recent_noises, recent_img_noises = append_new_noise_list(multinoises,
img_noises, recent_noises, recent_img_noises, maxI=iterations_to_save)
socket.send(img_to_send)
img_seq.append(img_to_save)
curr_iter += 1
print("Sent image")
elif(curr_iter < iterations):
multinoises, img_to_send, img_to_save, optimizer = \
optimize_one_step_multinoise(model, optimizer, multinoises, freeze_style,
img_noises, losses, masks, heightmap_full_resolution)
recent_noises, recent_img_noises = append_new_noise_list(multinoises,
img_noises, recent_noises, recent_img_noises, maxI=iterations_to_save)
socket.send(img_to_send)
img_seq.append(img_to_save)
curr_iter += 1
print("Sent image")
else:
training_heightmap = False
imageio.imwrite("sentimage.png", img_seq[-1])
imageio.mimwrite("imgseq.gif", img_seq)
socket.send_string("finished")
if(message[0] == "new_noise"):
img_noises = image_noise(1, 128, device = 0)
img = feed_forward_multistyle(model,
multinoises, img_noises, heightmap_full_resolution)
recent_noises, recent_img_noises = append_new_noise_list(multinoises,
img_noises, recent_noises, recent_img_noises, maxI=iterations_to_save)
img_to_send = img.copy()
img_to_send = bytearray(img_to_send)
img_to_send = base64.b64encode(img_to_send)
imageio.imwrite("sentimage.png", img)
socket.send(img_to_send)
if(message[0] == "update_locked_styles"):
for i in range(len(message[1:])):
freeze_style[i] = int(message[1+i]) == 1
socket.send_string("finished")
if(message[0] == "all_new_styles"):
multinoises[0] = torch.randn(num_images, 512).cuda()
multinoises[0].requires_grad = True
for res in range(1,len(multinoises)):
multinoises[res] = multinoises[0].detach().clone()
multinoises[res].requires_grad = True
img = feed_forward_multistyle(model,
multinoises, img_noises, heightmap_full_resolution)
recent_noises, recent_img_noises = append_new_noise_list(multinoises,
img_noises, recent_noises, recent_img_noises, maxI=iterations_to_save)
img_to_send = img.copy()
img_to_send = bytearray(img_to_send)
img_to_send = base64.b64encode(img_to_send)
imageio.imwrite("sentimage.png", img)
socket.send(img_to_send)
if(message[0] == "new_style_for_resolution"):
res = int(message[1])
multinoises[res] = torch.randn(num_images, 512).cuda()
multinoises[res].requires_grad = True
img = feed_forward_multistyle(model,
multinoises, img_noises, heightmap_full_resolution)
recent_noises, recent_img_noises = append_new_noise_list(multinoises,
img_noises, recent_noises, recent_img_noises, maxI=iterations_to_save)
img_to_send = img.copy()
img_to_send = bytearray(img_to_send)
img_to_send = base64.b64encode(img_to_send)
imageio.imwrite("sentimage.png", img)
socket.send(img_to_send)
if(message[0] == "iterations"):
socket.send_string(str(len(recent_img_noises)))
if(message[0] == "undo"):
iteration_to_use = int(message[1])
for i in range(len(multinoises)):
multinoises[i] = recent_noises[iteration_to_use][i].detach().clone()
multinoises[i].requires_grad = True
img_noises = recent_img_noises[iteration_to_use].clone()
img = feed_forward_multistyle(model,
multinoises, img_noises, heightmap_full_resolution)
img_to_send = img.copy()
img_to_send = bytearray(img_to_send)
img_to_send = base64.b64encode(img_to_send)
imageio.imwrite("sentimage.png", img)
socket.send(img_to_send)
if(message[0] == "stop"):
print("Stopping")
socket.send_string("stopping")
quit()
if(message[0] == "update_resolution"):
heightmap_full_resolution = int(message[1])
img = feed_forward_multistyle(model,
multinoises, img_noises, heightmap_full_resolution)
img_to_send = img.copy()
img_to_send = bytearray(img_to_send)
img_to_send = base64.b64encode(img_to_send)
imageio.imwrite("sentimage.png", img)
socket.send(img_to_send)
except KeyboardInterrupt:
print("Ctrl-C - terminated")
| 41.75 | 94 | 0.589611 | 1,596 | 14,362 | 4.964286 | 0.113409 | 0.036602 | 0.056797 | 0.030292 | 0.767007 | 0.734065 | 0.724347 | 0.682444 | 0.674871 | 0.65821 | 0 | 0.014645 | 0.315346 | 14,362 | 343 | 95 | 41.87172 | 0.791112 | 0.006754 | 0 | 0.577465 | 0 | 0 | 0.059178 | 0.003856 | 0 | 0 | 0 | 0 | 0 | 1 | 0.017606 | false | 0 | 0.017606 | 0 | 0.052817 | 0.049296 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3982cf6a3f09f93318fcf1ea1e48f77c36114e0c | 44 | py | Python | gaconverter/constants.py | vaskinyy/gaconverter | bb276f17b5ca0dec9fc34f1820b9eac7cb8a8dfd | [
"MIT"
] | null | null | null | gaconverter/constants.py | vaskinyy/gaconverter | bb276f17b5ca0dec9fc34f1820b9eac7cb8a8dfd | [
"MIT"
] | null | null | null | gaconverter/constants.py | vaskinyy/gaconverter | bb276f17b5ca0dec9fc34f1820b9eac7cb8a8dfd | [
"MIT"
] | null | null | null | ALLELE_COLUMNS_START = 5
NUMBERS_COLUMN = 2
| 14.666667 | 24 | 0.818182 | 7 | 44 | 4.714286 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.052632 | 0.136364 | 44 | 2 | 25 | 22 | 0.815789 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3987410674a3293718f5341ebe8a09d0da077bd1 | 1,099 | py | Python | modules/common/crlf.py | abdallah-elsharif/WRock | 7cfd4bf29e932bf0048ee357c16cf6c021e7fb81 | [
"MIT"
] | 14 | 2022-03-13T19:51:24.000Z | 2022-03-18T07:36:39.000Z | modules/common/crlf.py | abdallah-elsharif/WRock | 7cfd4bf29e932bf0048ee357c16cf6c021e7fb81 | [
"MIT"
] | null | null | null | modules/common/crlf.py | abdallah-elsharif/WRock | 7cfd4bf29e932bf0048ee357c16cf6c021e7fb81 | [
"MIT"
] | 3 | 2022-03-14T05:58:06.000Z | 2022-03-14T11:46:47.000Z |
from core.scan.module import *
class CRLF(CommonScanner):
def __init__(self, config) -> None:
CommonScanner.__init__(self, config)
def check(self) -> bool:
return True
def GetPayloads(self) -> list:
payloads = list()
ESCAPE_CHARS = ['%0d','%0a', '%0d%0a', '%23%0d', '%23%0a', '%23%0d%0a']
INJECTED_HEADERS = [f"wrock: {rockVERSION()}"] #, f"Set-Cookie:wrock={rockVERSION()}"]
for header in INJECTED_HEADERS:
for char in ESCAPE_CHARS:
payloads.append(f"{unquote(char)}{header}")
return payloads
def is_vulnerable(self, response) -> bool:
return 'wrock' in response.headers
def SetPayloadInParams(self, payload) -> dict:
# reinit request to add the payloads at the end of the url
# and we don't encode the payload when the url has params because
# GetUrl() method will encode params and the payload.
self.request = Get(self.url + (payload if self.request.GetUrlParams() else quote(payload)), headers = self.config.GetHeaders())
| 33.30303 | 135 | 0.616924 | 136 | 1,099 | 4.889706 | 0.522059 | 0.045113 | 0.042105 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017178 | 0.258417 | 1,099 | 32 | 136 | 34.34375 | 0.798773 | 0.193813 | 0 | 0 | 0 | 0 | 0.094211 | 0.026107 | 0 | 0 | 0 | 0 | 0 | 1 | 0.277778 | false | 0 | 0.055556 | 0.111111 | 0.555556 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
39948b00e77ca259d690169dff0f47aca129d291 | 656 | py | Python | sovi/api/teams/models.py | husseinm/Saly | e656e4e30e696cc7b425f272424dc3c1db2ae92a | [
"MIT"
] | null | null | null | sovi/api/teams/models.py | husseinm/Saly | e656e4e30e696cc7b425f272424dc3c1db2ae92a | [
"MIT"
] | null | null | null | sovi/api/teams/models.py | husseinm/Saly | e656e4e30e696cc7b425f272424dc3c1db2ae92a | [
"MIT"
] | null | null | null | from django.db import models
class Team(models.Model):
number = models.IntegerField(primary_key=True, unique=True,
verbose_name="Team #")
name = models.CharField(max_length=255, blank=True)
website = models.URLField(blank=True)
country = models.CharField(max_length=64, blank=True)
region = models.CharField(max_length=64, blank=True)
locality = models.CharField(max_length=64, blank=True)
def __str__(self):
return ("{0} - {1} ({2}, {3}, {4}, {5})"
.format(str(self.number), self.name, self.website,
self.country, self.region, self.locality))
| 38.588235 | 66 | 0.618902 | 81 | 656 | 4.888889 | 0.469136 | 0.113636 | 0.181818 | 0.242424 | 0.265152 | 0.265152 | 0.265152 | 0 | 0 | 0 | 0 | 0.030181 | 0.242378 | 656 | 16 | 67 | 41 | 0.7666 | 0 | 0 | 0 | 0 | 0 | 0.054878 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.076923 | false | 0 | 0.076923 | 0.076923 | 0.769231 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
39b9e091b27ff9e1455167d6bf66bb1e321c666f | 292 | py | Python | vstreamer_utils/networking/Request.py | artudi54/video-streamer | 66e5e722ed66abe5877488f177c0ac4f13325382 | [
"MIT"
] | 2 | 2019-10-08T10:49:52.000Z | 2021-10-01T11:26:31.000Z | vstreamer_utils/networking/Request.py | artudi54/video-streamer | 66e5e722ed66abe5877488f177c0ac4f13325382 | [
"MIT"
] | 1 | 2019-05-16T13:48:29.000Z | 2019-05-16T13:48:49.000Z | vstreamer_utils/networking/Request.py | artudi54/video-streamer | 66e5e722ed66abe5877488f177c0ac4f13325382 | [
"MIT"
] | 1 | 2019-10-08T10:49:56.000Z | 2019-10-08T10:49:56.000Z |
class Request:
pass
class DirectoryInfoRequest(Request):
def __init__(self, path):
super().__init__()
self.path = path
class AdditionalEntryPropertiesRequest(Request):
def __init__(self, filepath):
super().__init__()
self.filepath = filepath
| 17.176471 | 48 | 0.657534 | 27 | 292 | 6.518519 | 0.407407 | 0.181818 | 0.159091 | 0.204545 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.243151 | 292 | 16 | 49 | 18.25 | 0.79638 | 0 | 0 | 0.2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0.1 | 0 | 0 | 0.5 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
39c48c681eec8afb1170441d146ebba2d5726e57 | 14,049 | py | Python | amino/tree.py | tek/amino | 51b314933e047a45587a24ecff02c836706d27ff | [
"MIT"
] | 33 | 2016-12-21T07:05:46.000Z | 2020-04-29T04:26:46.000Z | amino/tree.py | tek/amino | 51b314933e047a45587a24ecff02c836706d27ff | [
"MIT"
] | 1 | 2019-04-19T17:15:52.000Z | 2019-04-20T18:28:23.000Z | amino/tree.py | tek/amino | 51b314933e047a45587a24ecff02c836706d27ff | [
"MIT"
] | 4 | 2017-09-04T18:46:23.000Z | 2021-11-02T04:18:13.000Z | import abc
from typing import Callable, TypeVar, Generic, Union, cast, Any
from amino.logging import Logging
from amino import LazyList, Boolean, __, _, Either, Right, Maybe, Left, L, Map, curried
from amino.boolean import false, true
from amino.tc.base import Implicits
from amino.tc.flat_map import FlatMap
from amino.func import call_by_name
from amino.lazy_list import LazyLists
def indent(strings: LazyList[str]) -> LazyList[str]:
return strings.map(' ' + _)
Data = TypeVar('Data')
Data1 = TypeVar('Data1')
Sub = TypeVar('Sub')
Sub1 = TypeVar('Sub1')
A = TypeVar('A')
B = TypeVar('B')
Z = TypeVar('Z')
Key = Union[str, int]
class Node(Generic[Data, Sub], Logging, abc.ABC, Implicits, implicits=True, auto=True):
@abc.abstractproperty
def sub(self) -> Sub:
...
@abc.abstractproperty
def sub_l(self) -> LazyList['Node[Data, Any]']:
...
@abc.abstractmethod
def _strings(self) -> LazyList[str]:
...
@property
def strings(self) -> LazyList[str]:
return self._strings()
def _show(self) -> str:
return self._strings().mk_string('\n')
@property
def show(self) -> str:
return self._show()
@abc.abstractmethod
def foreach(self, f: Callable[['Node'], None]) -> None:
...
@abc.abstractmethod
def filter(self, pred: Callable[['Node'], bool]) -> 'Node':
...
def filter_not(self, pred: Callable[['Node'], bool]) -> 'Node':
return self.filter(lambda a: not pred(a))
@abc.abstractproperty
def flatten(self) -> 'LazyList[Any]':
...
@abc.abstractmethod
def contains(self, target: 'Node') -> Boolean:
...
@abc.abstractmethod
def lift(self, key: Key) -> 'SubTree':
...
def __getitem__(self, key: Key) -> 'SubTree':
return self.lift(key)
@abc.abstractproperty
def s(self) -> 'SubTree':
...
@abc.abstractproperty
def empty(self) -> Boolean:
...
@curried
def fold_left(self, z: Z, f: Callable[[Z, 'Node'], Z]) -> Z:
z1 = f(z, self)
return self.sub_l.fold_left(z1)(lambda z2, a: a.fold_left(z2)(f))
@abc.abstractmethod
def replace(self, data: LazyList['Node[Data1, Sub1]']) -> 'Node[Data1, Sub1]':
...
@abc.abstractmethod
def map_nodes(self, f: Callable[['Node[Data, Sub]'], 'Node[Data, Sub]']) -> 'Node[Data, Sub]':
...
class Inode(Generic[Data, Sub], Node[Data, Sub]):
@abc.abstractproperty
def sub(self) -> LazyList[Any]:
...
def foreach(self, f: Callable[[Node], None]) -> None:
f(self)
self.sub_l.foreach(__.foreach(f))
@property
def flatten(self) -> LazyList[Any]:
return self.sub_l.flat_map(_.flatten).cons(self)
def contains(self, target: Node) -> Boolean:
return self.sub_l.contains(target)
@property
def empty(self) -> Boolean:
return self.data.empty
class ListNode(Generic[Data], Inode[Data, LazyList[Node[Data, Any]]]):
def __init__(self, sub: LazyList[Node[Data, Any]]) -> None:
self.data = sub
@property
def sub(self) -> LazyList[Node[Data, Any]]:
return self.data
@property
def sub_l(self) -> LazyList[Node[Data, Any]]:
return self.sub
@property
def _desc(self) -> str:
return '[]'
def _strings(self) -> LazyList[str]:
return indent(self.sub // (lambda a: a._strings())).cons(self._desc)
@property
def head(self) -> 'SubTree':
return self.lift(0)
@property
def last(self) -> 'SubTree':
return self.lift(-1)
def __str__(self) -> str:
return '{}({})'.format(self.__class__.__name__, self.sub.map(str).mk_string(','))
def __repr__(self) -> str:
return str(self)
def lift(self, key: Key) -> 'SubTree':
return (
SubTreeInvalid(key, 'ListNode index must be int')
if isinstance(key, str) else
self.sub.lift(key) / L(SubTree.cons)(_, key) | (lambda: SubTreeInvalid(key, 'ListNode index oob'))
)
def replace(self, sub: LazyList[Any]) -> Node:
return ListNode(sub)
def filter(self, pred: Callable[[Node], bool]) -> Node:
def filt(n: Node) -> bool:
return (
pred(n)
if isinstance(n, LeafNode) else
not n.empty
)
return self.replace(self.sub.map(__.filter(pred)).filter(filt))
@property
def s(self) -> 'SubTree':
return SubTreeList(self, 'root')
def map_nodes(self, f: Callable[['Node[Data, Sub]'], 'Node[Data, Sub]']) -> 'Node[Data, Sub]':
return f(ListNode(self.sub.map(lambda a: a.map_nodes(f))))
class MapNode(Generic[Data], Inode[Data, Map[str, Node[Data, Any]]]):
def __init__(self, data: Map[str, Node[Data, Any]]) -> None:
self.data = data
@property
def sub(self) -> Map[str, Node[Data, Any]]:
return self.data
@property
def sub_l(self) -> LazyList[Node[Data, Any]]:
return LazyList(self.data.v)
@property
def _desc(self) -> str:
return '{}'
def _strings(self) -> LazyList[str]:
return indent(self.sub_l // (lambda a: a._strings())).cons(self._desc)
def __str__(self) -> str:
return '{}({})'.format(self.__class__.__name__, self.sub_l)
def __repr__(self) -> str:
return str(self)
# TODO allow int indexes into sub_l
def lift(self, key: Key) -> 'SubTree':
def err() -> 'SubTree':
keys = ', '.join(self.data.keys())
return SubTreeInvalid(key, f'MapNode({self.rule}) invalid key ({keys})')
return (
self.data.lift(key) /
L(SubTree.cons)(_, key) |
err
)
def replace(self, sub: Map[str, Node]) -> Node:
return MapNode(sub)
def filter(self, pred: Callable[[Node], bool]) -> Node:
def filt(n: Node) -> bool:
return (
pred(n)
if isinstance(n, LeafNode) else
not n.empty
)
return self.replace(self.data.valmap(__.filter(pred)).valfilter(filt))
@property
def s(self) -> 'SubTree':
return SubTreeMap(self, 'root')
def map_nodes(self, f: Callable[['Node[Data, Sub]'], 'Node[Data, Sub]']) -> 'Node[Data, Sub]':
return f(MapNode(self.sub.valmap(lambda a: a.map_nodes(f))))
class LeafNode(Generic[Data], Node[Data, None]):
def __init__(self, data: Data) -> None:
self.data = data
def _strings(self) -> LazyList[Data]:
return LazyLists.cons(self.data)
@property
def sub(self) -> None:
pass
@property
def sub_l(self) -> LazyList[Node[Data, Any]]:
return LazyList([])
def foreach(self, f: Callable[[Node], None]) -> None:
f(self)
def filter(self, pred: Callable[[Node], bool]) -> Node:
return self
@property
def flatten(self) -> LazyList[Any]:
return LazyLists.cons(self)
def contains(self, target: Node) -> Boolean:
return false
def lift(self, key: Key) -> 'SubTree':
return SubTreeInvalid(key, 'LeafNode cannot be indexed')
def __str__(self) -> str:
return '{}({})'.format(self.__class__.__name__, self.data)
def __repr__(self) -> str:
return str(self)
@property
def empty(self) -> Boolean:
return false
@property
def s(self) -> 'SubTree':
return SubTreeLeaf(self, 'root')
def replace(self, sub: Data) -> Node:
return LeafNode(sub)
def map_nodes(self, f: Callable[['Node[Data, Sub]'], 'Node[Data, Sub]']) -> 'Node[Data, Sub]':
return f(self)
class TreeFlatMap(FlatMap, tpe=Node):
def flat_map(self, fa: Node[A, Any], f: Callable[[A], Node[B, Any]]) -> Node[B, Any]:
return (
self.flat_map_inode(fa, f)
if isinstance(fa, Inode) else
self.flat_map_leaf(fa, f)
)
def flat_map_inode(self, fa: Inode[A, Any], f: Callable[[A], Node[B, Any]]) -> Node[B, Any]:
def err() -> Inode[A, Any]:
raise Exception(f'invalid sub for `TreeFlatMap.flat_map_inode`: {fa}')
return (
self.flat_map_map(fa, f)
if isinstance(fa, MapNode) else
self.flat_map_list(fa, f)
if isinstance(fa, ListNode) else
err()
)
def flat_map_map(self, fa: MapNode[A], f: Callable[[A], Node[B, Any]]) -> Node[B, Any]:
return MapNode(fa.sub.valmap(lambda a: self.flat_map(a, f)))
def flat_map_list(self, fa: ListNode[A], f: Callable[[A], Node[B, Any]]) -> Node[B, Any]:
return ListNode(fa.sub.map(lambda a: self.flat_map(a, f)))
def flat_map_leaf(self, fa: LeafNode[A], f: Callable[[A], Node[B, Any]]) -> Node[B, Any]:
return f(fa.data)
def map(self, fa: Node[A, Any], f: Callable[[A], B]) -> Node[B, Any]:
return (
self.map_inode(fa, f)
if isinstance(fa, Inode) else
self.map_leaf(fa, f)
)
def map_inode(self, fa: Inode[A, Any], f: Callable[[A], B]) -> Node[B, Any]:
def err() -> Inode[A, Any]:
raise Exception(f'invalid sub for `TreeFlatMap.map_inode`: {fa}')
return (
self.map_map(fa, f)
if isinstance(fa, MapNode) else
self.map_list(fa, f)
if isinstance(fa, ListNode) else
err()
)
def map_map(self, fa: MapNode[A], f: Callable[[A], B]) -> Node[B, Any]:
return MapNode(fa.data.valmap(lambda a: self.map(a, f)))
def map_list(self, fa: ListNode[A], f: Callable[[A], B]) -> Node[B, Any]:
return ListNode(fa.sub.map(lambda a: self.map(a, f)))
def map_leaf(self, fa: LeafNode[A], f: Callable[[A], B]) -> Node[B, Any]:
return LeafNode(f(fa.data))
class SubTree(Implicits, implicits=True, auto=True):
@staticmethod
def cons(fa: Node, key: Key) -> 'SubTree':
return ( # type: ignore
cast(SubTree, SubTreeList(fa, key))
if isinstance(fa, ListNode) else
SubTreeLeaf(fa, key)
if isinstance(fa, LeafNode) else
SubTreeMap(fa, key)
)
@staticmethod
def from_maybe(data: Maybe[Node], key: Key, err: str) -> 'SubTree':
return data.cata(SubTree.cons, SubTreeInvalid(key, err))
def __getattr__(self, key: Key) -> 'SubTree':
try:
return super().__getattr__(key)
except AttributeError:
return self._getattr(key)
@abc.abstractmethod
def _getattr(self, key: Key) -> 'SubTree':
...
def __getitem__(self, key: Key) -> 'SubTree':
return self._getitem(key)
@abc.abstractmethod
def _getitem(self, key: Key) -> 'SubTree':
...
def cata(self, f: Callable[[Node], A], b: Union[A, Callable[[], A]]) -> A:
return (
f(self.data)
if isinstance(self, SubTreeValid)
else call_by_name(b)
)
@abc.abstractproperty
def e(self) -> Either[str, Node]:
...
@abc.abstractproperty
def valid(self) -> Boolean:
...
@abc.abstractproperty
def strings(self) -> LazyList[str]:
...
@abc.abstractproperty
def show(self) -> LazyList[str]:
...
@property
def rule(self) -> Either[str, str]:
return self.e.map(_.rule)
class SubTreeValid(SubTree):
def __init__(self, data: Node, key: Key) -> None:
self.data = data
self._key = key
def __str__(self) -> str:
return '{}({})'.format(self.__class__.__name__, self.data)
@property
def e(self) -> Either[str, Node]:
return Right(self.data)
@property
def valid(self) -> Boolean:
return true
@property
def strings(self) -> LazyList[str]:
return self.data.strings
@property
def show(self) -> str:
return self.data.show
class SubTreeList(SubTreeValid):
@property
def head(self) -> SubTree:
return self[0]
@property
def last(self) -> SubTree:
return self[-1]
def _getattr(self, key: Key) -> SubTree:
return SubTreeInvalid(key, 'cannot access attrs in SubTreeList')
def _getitem(self, key: Key) -> SubTree:
return self.data.lift(key)
def __str__(self) -> str:
return '{}({})'.format(self.__class__.__name__, self.data.sub_l.drain.join_comma)
@property
def _keys(self) -> LazyList[str]:
return self.data.k
class SubTreeLeaf(SubTreeValid):
def err(self, key: Key) -> SubTree:
return SubTreeInvalid(key, 'cannot access attrs in SubTreeLeaf')
def _getattr(self, key: Key) -> SubTree:
return self.err(key)
def _getitem(self, key: Key) -> SubTree:
return self.err(key)
class SubTreeMap(SubTreeValid):
def _getattr(self, key: Key) -> SubTree:
return self.data.lift(key)
def _getitem(self, key: Key) -> SubTree:
return self.data.lift(key)
@property
def _keys(self) -> LazyList[str]:
return self.data.k
class SubTreeInvalid(SubTree):
def __init__(self, key: Key, reason: str) -> None:
self.key = key
self.reason = reason
def __str__(self) -> str:
s = 'SubTreeInvalid({}, {})'
return s.format(self.key, self.reason)
def __repr__(self) -> str:
return str(self)
@property
def valid(self) -> Boolean:
return false
@property
def _error(self) -> str:
return 'no subtree `{}`: {}'.format(self.key, self.reason)
def _getattr(self, key: Key) -> SubTree:
return self
def _getitem(self, key: Key) -> SubTree:
return self
@property
def e(self) -> Either[str, Node]:
return Left(self._error)
@property
def strings(self) -> LazyList[str]:
return LazyList([])
@property
def show(self) -> LazyList[str]:
return str(self)
__all__ = ('Node', 'Inode', 'LeafNode', 'MapNode', 'LeafNode', 'ListNode')
| 26.709125 | 110 | 0.575699 | 1,769 | 14,049 | 4.443188 | 0.085359 | 0.048346 | 0.026718 | 0.038931 | 0.632061 | 0.569593 | 0.503053 | 0.435496 | 0.366412 | 0.293639 | 0 | 0.001561 | 0.270482 | 14,049 | 525 | 111 | 26.76 | 0.765343 | 0.003274 | 0 | 0.523684 | 0 | 0 | 0.058714 | 0.003786 | 0 | 0 | 0 | 0.001905 | 0 | 1 | 0.315789 | false | 0.002632 | 0.023684 | 0.215789 | 0.613158 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.