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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
569bca5e9f06ca0a171a66b8d109f6f8633f9322 | 482 | py | Python | tech_project/lib/python2.7/site-packages/djangocms_link/fields.py | priyamshah112/Project-Descripton-Blog | 8e01016c6be79776c4f5ca75563fa3daa839e39e | [
"MIT"
] | null | null | null | tech_project/lib/python2.7/site-packages/djangocms_link/fields.py | priyamshah112/Project-Descripton-Blog | 8e01016c6be79776c4f5ca75563fa3daa839e39e | [
"MIT"
] | null | null | null | tech_project/lib/python2.7/site-packages/djangocms_link/fields.py | priyamshah112/Project-Descripton-Blog | 8e01016c6be79776c4f5ca75563fa3daa839e39e | [
"MIT"
] | null | null | null | from django.conf import settings
ENABLE_SELECT2 = getattr(settings, 'DJANGOCMS_LINK_USE_SELECT2', False)
if ENABLE_SELECT2 and 'django_select2' in settings.INSTALLED_APPS:
try:
from djangocms_link.fields_select2 import Select2PageSearchField as PageSearchField
except ImportError:
from djangocms_link.fields_select2_legacy import Select2LegacyPageSearchField as PageSearchField
else:
from cms.forms.fields import PageSelectFormField as PageSearchField
| 40.166667 | 104 | 0.821577 | 55 | 482 | 6.981818 | 0.545455 | 0.101563 | 0.088542 | 0.119792 | 0.15625 | 0 | 0 | 0 | 0 | 0 | 0 | 0.019277 | 0.139004 | 482 | 11 | 105 | 43.818182 | 0.906024 | 0 | 0 | 0 | 0 | 0 | 0.082988 | 0.053942 | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
56a89b65f0ff87271d05f1e879445cd9c29b6b11 | 1,176 | py | Python | main.py | kusenabdullah-123/backend-gomagame | a13276f9129d82dfce67262491ff57f65657d117 | [
"MIT"
] | 2 | 2022-02-08T05:21:22.000Z | 2022-02-08T07:05:55.000Z | main.py | kusenabdullah-123/backend-gomagame | a13276f9129d82dfce67262491ff57f65657d117 | [
"MIT"
] | null | null | null | main.py | kusenabdullah-123/backend-gomagame | a13276f9129d82dfce67262491ff57f65657d117 | [
"MIT"
] | null | null | null | from flask import Flask
from flask_restful import Api, Resource
from flask_cors import CORS
from model.galleryModel import getGalleryById
from model.ArticleModel import getArticleById
from resources.GallerysApi import GallerysApi
from resources.GameApi import GameApi
from resources.images import Image
from resources.LoginApi import LoginApi
from resources.ArticleApi import ArticleApi
app = Flask(__name__)
api = Api(app)
CORS(app)
version = "v1"
class GalleryApi(Resource):
def get(self, idGallery):
gallery = getGalleryById(idGallery)
return {'gallery': gallery}
class Article(Resource):
def get(self, idArticle):
article = getArticleById(idArticle)
return {'article': article}
api.add_resource(GallerysApi, f'/{version}/gallery/')
api.add_resource(GameApi, f'/{version}/game/')
api.add_resource(LoginApi, f'/{version}/login/')
api.add_resource(ArticleApi, f'/{version}/article/')
api.add_resource(Article, f'/{version}/article/<int:idArticle>')
api.add_resource(GalleryApi, f'/{version}/gallery/<int:idGallery>')
api.add_resource(Image, f'/{version}/images/', endpoint="images")
if __name__ == '__main__':
app.run()
| 27.348837 | 67 | 0.751701 | 146 | 1,176 | 5.910959 | 0.287671 | 0.048667 | 0.113557 | 0.041715 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.000973 | 0.12585 | 1,176 | 42 | 68 | 28 | 0.838521 | 0 | 0 | 0 | 0 | 0 | 0.159014 | 0.057823 | 0 | 0 | 0 | 0 | 0 | 1 | 0.064516 | false | 0 | 0.322581 | 0 | 0.516129 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
3b1eb870911426c7170f695ac7b10cf7361e6f44 | 1,438 | py | Python | push_swap_gui/push_swap_stacks.py | shikarukitake/push_swap_gui | 9026e2c675e42742caaecd792dff9aa0531e21a1 | [
"MIT"
] | 28 | 2020-02-22T02:21:29.000Z | 2022-03-17T19:28:43.000Z | push_swap_gui/push_swap_stacks.py | shikarukitake/push_swap_gui | 9026e2c675e42742caaecd792dff9aa0531e21a1 | [
"MIT"
] | 1 | 2020-07-13T16:04:39.000Z | 2020-07-14T10:34:38.000Z | push_swap_gui/push_swap_stacks.py | shikarukitake/push_swap_gui | 9026e2c675e42742caaecd792dff9aa0531e21a1 | [
"MIT"
] | 1 | 2020-07-13T13:57:26.000Z | 2020-07-13T13:57:26.000Z | from collections import deque
class PushSwapStacks:
"""
describe stacks for push-swap algorithm
"""
def __init__(self, initstate):
""" initstate: Iterable[_T]=..."""
self.stack_a = deque()
self.stack_b = deque()
self.new_data(initstate)
self.cmd = {
'pa': self.pa,
'pb': self.pb,
'sa': self.sa,
'sb': self.sb,
'ss': self.ss,
'ra': self.ra,
'rb': self.rb,
'rr': self.rr,
'rra': self.rra,
'rrb': self.rrb,
'rrr': self.rrr
}
def new_data(self, initstate):
self.stack_a.clear()
self.stack_b.clear()
tmp = sorted(initstate)
self.stack_a.extend([tmp.index(x) + 1 for x in initstate])
def do_cmd(self, op):
self.cmd[op]()
return op
def pa(self):
if len(self.stack_b):
self.stack_a.appendleft(self.stack_b.popleft())
def pb(self):
if len(self.stack_a):
self.stack_b.appendleft(self.stack_a.popleft())
def ra(self):
if len(self.stack_a):
self.stack_a.rotate(-1)
def rb(self):
if len(self.stack_b):
self.stack_b.rotate(-1)
def rr(self):
self.ra()
self.rb()
def rra(self):
if len(self.stack_a):
self.stack_a.rotate(1)
def rrb(self):
if len(self.stack_b):
self.stack_b.rotate(1)
def rrr(self):
self.rra()
self.rrb()
def sa(self):
self.stack_a[0], self.stack_a[1] = self.stack_a[1], self.stack_a[0]
def sb(self):
self.stack_b[0], self.stack_b[1] = self.stack_b[1], self.stack_b[0]
def ss(self):
self.sa()
self.sb()
| 18.202532 | 69 | 0.630042 | 247 | 1,438 | 3.526316 | 0.210526 | 0.27899 | 0.160735 | 0.089552 | 0.316877 | 0.316877 | 0.316877 | 0.243398 | 0.179104 | 0.179104 | 0 | 0.011083 | 0.184284 | 1,438 | 78 | 70 | 18.435897 | 0.731458 | 0.046592 | 0 | 0.103448 | 0 | 0 | 0.01845 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.241379 | false | 0 | 0.017241 | 0 | 0.293103 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3b25b2ef36c83a3898ea60889cbaf79f68a98677 | 401 | py | Python | tests/common.py | BuzzniAILab/mlserving | 8b8add9dbe5cdd6392e0c87ee789492de0a1c70e | [
"MIT"
] | 13 | 2020-08-23T17:35:53.000Z | 2022-02-10T14:14:03.000Z | tests/common.py | orlevi111/ganesha | 137cc388806fc98f7768298da01ebeddf03f9464 | [
"MIT"
] | 3 | 2020-08-20T21:09:01.000Z | 2021-06-25T15:33:54.000Z | tests/common.py | orlevi111/ganesha | 137cc388806fc98f7768298da01ebeddf03f9464 | [
"MIT"
] | 3 | 2021-04-12T01:56:22.000Z | 2021-10-05T12:50:12.000Z | import logging
from random import randint
from unittest.mock import MagicMock
from wsgiref import simple_server
from wsgiref.simple_server import WSGIRequestHandler
logging.getLogger('mlserving').disabled = True
def create_test_server(app):
port = randint(1000, 9999)
httpd = simple_server.make_server('0.0.0.0', port, app)
WSGIRequestHandler.log_message = MagicMock()
return httpd
| 26.733333 | 59 | 0.783042 | 53 | 401 | 5.792453 | 0.54717 | 0.117264 | 0.019544 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.034783 | 0.139651 | 401 | 14 | 60 | 28.642857 | 0.855072 | 0 | 0 | 0 | 0 | 0 | 0.0399 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0 | 0.454545 | 0 | 0.636364 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
3b498d3a88bb9d50bfee7c5f0a9a3f9c5a85fb11 | 372 | py | Python | modules/ambient/ambient.py | FlameOfIgnis/spotify-sync | 9a237b81ac65d555e8b87edfe919254beb7585e8 | [
"MIT"
] | 13 | 2021-01-31T21:53:35.000Z | 2021-04-15T17:19:27.000Z | modules/ambient/ambient.py | ignis-sec/spotify-sync | 9a237b81ac65d555e8b87edfe919254beb7585e8 | [
"MIT"
] | null | null | null | modules/ambient/ambient.py | ignis-sec/spotify-sync | 9a237b81ac65d555e8b87edfe919254beb7585e8 | [
"MIT"
] | 2 | 2021-06-14T00:30:23.000Z | 2021-08-24T08:55:33.000Z | import subprocess
from ctypes import *
# I know, i know, this is probably the worst solution to a trivial challenge. Still, if it aint broke...
class Ambient:
def __init__(self):
self.user32 = WinDLL("user32.dll")
def change_color(self, r,g,b):
rgb = r + (g<<8) + (b<<16)
self.user32.SetSysColors(1, byref(c_int(1)), byref(c_int(rgb)))
| 26.571429 | 104 | 0.642473 | 59 | 372 | 3.932203 | 0.711864 | 0.043103 | 0.060345 | 0.086207 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.037931 | 0.22043 | 372 | 13 | 105 | 28.615385 | 0.762069 | 0.274194 | 0 | 0 | 0 | 0 | 0.037453 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.25 | 0 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
3b4d477a61538433f6801669cf11863660d5ef46 | 3,407 | py | Python | linuxOperation/app/review/constants.py | zhouli121018/core | f9700204349ecb22d45e700e9e27e79412829199 | [
"MIT"
] | null | null | null | linuxOperation/app/review/constants.py | zhouli121018/core | f9700204349ecb22d45e700e9e27e79412829199 | [
"MIT"
] | 1 | 2021-06-10T20:45:55.000Z | 2021-06-10T20:45:55.000Z | linuxOperation/app/review/constants.py | zhouli121018/core | f9700204349ecb22d45e700e9e27e79412829199 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
'''
常量
'''
from django.utils.translation import ugettext_lazy as _
# ------审核规则 ReviewRule --------
REVIEWRULE_WORKMODE = (
(u'outbound', _(u'外发')),
(u'allsend', _(u'所有')),
)
REVIEWRULE_LOGIC = (
(u'all', _(u'满足所有条件')),
(u'one', _(u'满足一条即可')),
)
REVIEWRULE_PREACTION = (
(u'', _(u'人工')),
(u'permit', _(u'批准')),
(u'reject', _(u'拒绝')),
)
REVIEWRULE_HASATTACH = (
(-1, _(u'否')),
(1, _(u'是')),
)
REVIEWRULE_DISABLED = (
(-1, _(u'启用')),
(1, _(u'禁用')),
)
REVIEWRULE_OPTION_TYPE = (
(u'subject', _(u'主题')),
(u'date', _(u'邮件时间')),
(u'recipient', _(u'收件人')),
(u'sender', _(u'发件人')),
(u'content', _(u'邮件内容')),
(u'mail_size', _(u'邮件大小')),
(u'attachment', _(u'附件名')),
(u'has_attach', _(u'拥有附件')),
(u'all_mail',_(u'所有邮件')),
(u"sender_dept", _(u'发信人部门')),
(u"rcpt_dept", _(u'收信人部门')),
(u"sender_ip", _(u'发信人IP')),
(u"header_received", _(u'邮件头Received')),
(u"is_proxy_out", _(u'设置了外发代理')),
(u"is_proxy_in", _(u'设置了接收代理')),
)
REVIEWRULE_OPTION_NO_INPUT = (
(u'has_attach', _(u'拥有附件')),
(u'all_mail', _(u'所有邮件')),
(u"is_proxy_out", _(u'设置了外发代理')),
(u"is_proxy_in", _(u'设置了接收代理')),
)
REVIEWRULE_OPTION_CONDITION_CONTAIN = (
(u'contains', _(u'包含')),
(u'not_contains', _(u'不包含')),
(u'==', _(u'等于')),
)
REVIEWRULE_OPTION_CONDITION_COMPARE = (
(u'==', _(u'等于')),
(u'>=', _(u'大于等于')),
(u'<=', _(u'小于等于')),
)
REVIEWRULE_OPTION_CONDITION_EQ = (
(u'==', _(u'等于')),
)
REVIEWRULE_OPTION_CONDITION_BELONG = (
(u'in', _(u'属于')),
(u'not_in', _(u'不属于')),
)
REVIEWRULE_OPTION_CONDITION_ACTION_ALL = REVIEWRULE_OPTION_CONDITION_CONTAIN \
+ REVIEWRULE_OPTION_CONDITION_COMPARE \
+ REVIEWRULE_OPTION_CONDITION_EQ \
+ REVIEWRULE_OPTION_CONDITION_BELONG \
REVIEWRULE_OPTION_CONDITION = (
(u'subject', REVIEWRULE_OPTION_CONDITION_CONTAIN),
(u'date', REVIEWRULE_OPTION_CONDITION_COMPARE),
(u'recipient', REVIEWRULE_OPTION_CONDITION_CONTAIN),
(u'sender', REVIEWRULE_OPTION_CONDITION_CONTAIN),
(u'content', REVIEWRULE_OPTION_CONDITION_CONTAIN),
(u'mail_size', REVIEWRULE_OPTION_CONDITION_COMPARE),
(u'attachment', REVIEWRULE_OPTION_CONDITION_CONTAIN),
(u'has_attach', REVIEWRULE_OPTION_CONDITION_EQ),
(u'all_mail', REVIEWRULE_OPTION_CONDITION_EQ),
(u'sender_dept', REVIEWRULE_OPTION_CONDITION_BELONG),
(u'rcpt_dept', REVIEWRULE_OPTION_CONDITION_BELONG),
(u"sender_ip", REVIEWRULE_OPTION_CONDITION_CONTAIN),
(u"header_received", REVIEWRULE_OPTION_CONDITION_CONTAIN),
(u"is_proxy_out", REVIEWRULE_OPTION_CONDITION_EQ),
(u"is_proxy_in", REVIEWRULE_OPTION_CONDITION_EQ),
)
# ------审核进度 ReviewProcess --------
REVIEWPROCESS_STATUS = (
(u'wait', _(u'等待')),
(u'permit', _(u'通过')),
(u'reject', _(u'拒绝'))
)
# ------审核配置 ReviewConfig --------
REVIEWCONFIG_RESULT_NOTIFY_OPTION = (
(u'1', _(u'拒绝才发送审核结果邮件')),
(u'2', _(u'通过才发送审核结果邮件')),
(u'3', _(u'不发送审核结果邮件')),
(u'4', _(u'发送审核结果邮件')),
)
#这里的开关没反,涉及与旧版兼容的问题
REVIEWCONFIG_REVIEWER_NOTIFY_OPTION = (
(u'0', _(u'发送通知邮件给审核人')),
(u'1', _(u'不发送通知邮件给审核人')),
)
#审核结果邮件的默认值
REVIEWCONFIG_RESULT_NOTIFY_DEFAULT = u'4'
REVIEWCONFIG_REVIEWER_NOTIFY_DEFAULT = u'0' | 27.256 | 83 | 0.599354 | 402 | 3,407 | 4.636816 | 0.288557 | 0.23176 | 0.3353 | 0.154506 | 0.39324 | 0.157189 | 0.087446 | 0.087446 | 0.087446 | 0.087446 | 0 | 0.004746 | 0.196067 | 3,407 | 125 | 84 | 27.256 | 0.675794 | 0.044321 | 0 | 0.11 | 0 | 0 | 0.19143 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.01 | 0 | 0.01 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3b80fd6b953946cc48998980ddd1c9c0a2e863e8 | 522 | py | Python | materialsdatabank/r1/__init__.py | OpenChemistry/materialsdatabank | f690f367920a1ff7f00f7c312d5a692b9f393131 | [
"BSD-3-Clause"
] | 6 | 2017-10-24T12:59:21.000Z | 2020-04-24T09:57:48.000Z | materialsdatabank/r1/__init__.py | OpenChemistry/materialsdatabank | f690f367920a1ff7f00f7c312d5a692b9f393131 | [
"BSD-3-Clause"
] | 46 | 2017-10-06T14:23:17.000Z | 2020-06-11T20:44:59.000Z | materialsdatabank/r1/__init__.py | OpenChemistry/materialsdatabank | f690f367920a1ff7f00f7c312d5a692b9f393131 | [
"BSD-3-Clause"
] | 2 | 2017-10-09T14:25:29.000Z | 2019-08-07T01:07:13.000Z | import numpy as np
import scipy.io as spio
from . import calc_R1_function_python_GEN
def calculate_r1_factor(proj, proj_angles, atom_positions, atomic_spec, atomic_numbers,
resolution,z_direction, b_factor, h_factor, axis_convention):
Result = calc_R1_function_python_GEN.calc_R1_function_indivFA_python(atom_positions,
atomic_spec, proj, proj_angles, resolution, np.array(b_factor), np.array(h_factor), np.array(axis_convention), atomic_numbers, z_direction)
return Result[1]
| 37.285714 | 147 | 0.772031 | 76 | 522 | 4.907895 | 0.460526 | 0.048257 | 0.112601 | 0.107239 | 0.123324 | 0 | 0 | 0 | 0 | 0 | 0 | 0.011338 | 0.155172 | 522 | 13 | 148 | 40.153846 | 0.834467 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.375 | 0 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
3b83b6b80ba52e59c6491379d0e45302e580a411 | 1,064 | py | Python | ERAutomation/environment.py | dboudreau4/ReimbursementSystemAutomation | 57d8c322ac80dd26679000f8d9d67e16fd865804 | [
"MIT"
] | null | null | null | ERAutomation/environment.py | dboudreau4/ReimbursementSystemAutomation | 57d8c322ac80dd26679000f8d9d67e16fd865804 | [
"MIT"
] | null | null | null | ERAutomation/environment.py | dboudreau4/ReimbursementSystemAutomation | 57d8c322ac80dd26679000f8d9d67e16fd865804 | [
"MIT"
] | null | null | null | from behave.runner import Context
from selenium import webdriver
from selenium.webdriver.chrome.webdriver import WebDriver
from poms.employee_form import EmployeeForm
from poms.employee_login import EmployeeLogin
from poms.employee_portal import EmployeePortal
from poms.manager_form import ManagerForm
from poms.manager_login import ManagerLogin
from poms.manager_portal import ManagerPortal
from poms.manager_stats import ManagerStats
def before_all(context: Context):
context.driver = webdriver.Chrome('C:\\Users\\david\\Desktop\\Drivers\\chromedriver.exe')
context.driver.implicitly_wait(10)
context.employee_login = EmployeeLogin(context.driver)
context.employee_portal = EmployeePortal(context.driver)
context.employee_form = EmployeeForm(context.driver)
context.manager_login = ManagerLogin(context.driver)
context.manager_portal = ManagerPortal(context.driver)
context.manager_form = ManagerForm(context.driver)
context.manager_stats = ManagerStats(context.driver)
def after_all(context):
context.driver.quit()
| 38 | 93 | 0.815789 | 128 | 1,064 | 6.648438 | 0.296875 | 0.152761 | 0.141011 | 0.12691 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00211 | 0.109023 | 1,064 | 27 | 94 | 39.407407 | 0.89557 | 0 | 0 | 0 | 0 | 0 | 0.048872 | 0.048872 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0 | 0.454545 | 0 | 0.545455 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
3b8839600d0ca4310f06804414adafc0d3c0af6c | 337 | py | Python | regular-expressions-fun/re-fun.py | diegopacheco/python-playground | 8e6ba427df6922fb578c2328babbf3466687ccbf | [
"Unlicense"
] | null | null | null | regular-expressions-fun/re-fun.py | diegopacheco/python-playground | 8e6ba427df6922fb578c2328babbf3466687ccbf | [
"Unlicense"
] | null | null | null | regular-expressions-fun/re-fun.py | diegopacheco/python-playground | 8e6ba427df6922fb578c2328babbf3466687ccbf | [
"Unlicense"
] | null | null | null | import re
txt = "The rain in Spain"
x = re.findall("^The.*Spain$", txt)
print(x)
txt = "The rain in Spain"
x = re.findall("Portugal", txt)
print(x)
txt = "The rain in Spain"
x = re.search("\s", txt)
print("The first white-space character is located in position:", x.start())
txt = "The rain in Spain"
x = re.split("\s", txt)
print(x) | 19.823529 | 75 | 0.646884 | 61 | 337 | 3.57377 | 0.360656 | 0.110092 | 0.183486 | 0.220183 | 0.513761 | 0.513761 | 0.513761 | 0.422018 | 0.266055 | 0.266055 | 0 | 0 | 0.169139 | 337 | 17 | 76 | 19.823529 | 0.778571 | 0 | 0 | 0.538462 | 0 | 0 | 0.434911 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.076923 | 0 | 0.076923 | 0.307692 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3b892744a60f286e36ebdd9c315239ecc2e2aaa3 | 389 | py | Python | aioinject/__init__.py | ThirVondukr/aioinject | 0415c5efe0f619758cc3cb6a07397be8d38b8365 | [
"MIT"
] | 4 | 2022-01-08T05:23:52.000Z | 2022-01-25T12:02:29.000Z | aioinject/__init__.py | ThirVondukr/dependency-depression | b34bfcfda03e3c5f4e148aeeb3293c7d4b83c853 | [
"MIT"
] | null | null | null | aioinject/__init__.py | ThirVondukr/dependency-depression | b34bfcfda03e3c5f4e148aeeb3293c7d4b83c853 | [
"MIT"
] | null | null | null | from .containers import Container
from .context import InjectionContext, SyncInjectionContext
from .decorators import inject
from .markers import Inject
from .providers import Callable, Object, Provider, Singleton
__all__ = [
"Container",
"InjectionContext",
"SyncInjectionContext",
"inject",
"Inject",
"Callable",
"Provider",
"Singleton",
"Object",
]
| 21.611111 | 60 | 0.709512 | 34 | 389 | 8 | 0.470588 | 0.264706 | 0.117647 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.190231 | 389 | 17 | 61 | 22.882353 | 0.863492 | 0 | 0 | 0 | 0 | 0 | 0.226221 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.3125 | 0 | 0.3125 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
3b89590f0065a014fc3ad14bafd30275fe01d8a5 | 15,409 | py | Python | XcomLAN/node_manager/node_observer.py | Mustafa-Abu-Ghazy/XcomLAN | 5695a53baedbd3cb3c533aaa48e9a195eee2eb28 | [
"MIT"
] | null | null | null | XcomLAN/node_manager/node_observer.py | Mustafa-Abu-Ghazy/XcomLAN | 5695a53baedbd3cb3c533aaa48e9a195eee2eb28 | [
"MIT"
] | null | null | null | XcomLAN/node_manager/node_observer.py | Mustafa-Abu-Ghazy/XcomLAN | 5695a53baedbd3cb3c533aaa48e9a195eee2eb28 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
This file contains definition/implementation of a NodeObserver Class that Receives device notifications if NodeManager
finds Studer devices.
Inspired from and Based on hesso-valais/scom : devicesubscriber.py
<https://github.com/hesso-valais/scom/blob/0.7.3/src/sino/scom/dman/devicesubscriber.py>
"""
import logging
from ..device import BSP_DEVICE_ID
from ..device import RCC_1_DEVICE_ID
from ..device import XCOM232i_DEVICE_ID
from ..device import RCC_2_DEVICE_ID
from ..device import RCC_3_DEVICE_ID
from ..device import RCC_4_DEVICE_ID
from ..device import RCC_5_DEVICE_ID
from ..device import RCC_GROUP_DEVICE_ID
from ..device import VS_10_DEVICE_ID
from ..device import VS_11_DEVICE_ID
from ..device import VS_12_DEVICE_ID
from ..device import VS_13_DEVICE_ID
from ..device import VS_14_DEVICE_ID
from ..device import VS_15_DEVICE_ID
from ..device import VS_1_DEVICE_ID
from ..device import VS_2_DEVICE_ID
from ..device import VS_3_DEVICE_ID
from ..device import VS_4_DEVICE_ID
from ..device import VS_5_DEVICE_ID
from ..device import VS_6_DEVICE_ID
from ..device import VS_7_DEVICE_ID
from ..device import VS_8_DEVICE_ID
from ..device import VS_9_DEVICE_ID
from ..device import VS_GROUP_DEVICE_ID
from ..device import VT_10_DEVICE_ID
from ..device import VT_11_DEVICE_ID
from ..device import VT_12_DEVICE_ID
from ..device import VT_13_DEVICE_ID
from ..device import VT_14_DEVICE_ID
from ..device import VT_15_DEVICE_ID
from ..device import VT_1_DEVICE_ID
from ..device import VT_2_DEVICE_ID
from ..device import VT_3_DEVICE_ID
from ..device import VT_4_DEVICE_ID
from ..device import VT_5_DEVICE_ID
from ..device import VT_6_DEVICE_ID
from ..device import VT_7_DEVICE_ID
from ..device import VT_8_DEVICE_ID
from ..device import VT_9_DEVICE_ID
from ..device import VT_GROUP_DEVICE_ID
from ..device import XT_1_DEVICE_ID
from ..device import XT_2_DEVICE_ID
from ..device import XT_3_DEVICE_ID
from ..device import XT_4_DEVICE_ID
from ..device import XT_5_DEVICE_ID
from ..device import XT_6_DEVICE_ID
from ..device import XT_7_DEVICE_ID
from ..device import XT_8_DEVICE_ID
from ..device import XT_9_DEVICE_ID
from ..device import XT_GROUP_DEVICE_ID
# -------------------------------------------------------------------------------------------------------------------- #
# ----------------------------------------------- NodeObserver Class ----------------------------------------------- #
# -------------------------------------------------------------------------------------------------------------------- #
class NodeObserver(object):
"""
Receives device notifications if NodeManager finds Studer devices.
(get notified about an SCOM device of interest.)
"""
def __init__(self, node_manager):
super(NodeObserver, self).__init__()
assert node_manager, 'To create NodeObserver object, node_manager must be giving!'
self._node_manager = node_manager
self.log = logging.getLogger(__name__ + ":" + self.node_name)
self._connected_devices = {}
self._node_manager.subscribe(self)
def __del__(self):
self._node_manager.unsubscribe(self)
@property
def node_manager(self):
"""Returns the NodeManager object related to this observer"""
return self._node_manager
@property
def node_name(self):
"""
Returns the Node Name.
:return:
"""
return self.node_manager.node_name
@property
def connected_devices(self):
"""
Returns list of the currently connected device.
:return:
"""
return self._connected_devices
# ---------------------------------------------------------------------------------------------------------------- #
# --------------------------------- Subscriber's Notification Functions/Methods -------------------------------- #
# ---------------------------------------------------------------------------------------------------------------- #
def on_device_connected(self, device):
"""
Called whenever the DeviceManager detects a new SCOM device (of interest).
:param device:
:type device ScomDevice
:return: None
"""
self._connected_devices[device.device_address] = device
def on_device_disconnected(self, device):
"""
Called whenever the DeviceManager detects the disappearance of an SCOM device (of interest).
:param device:
:type device ScomDevice
:return: None
"""
self._connected_devices.pop(device.device_address)
# ---------------------------------------------------------------------------------------------------------------- #
# -------------------------------------- Getters Properties for Xtenders -------------------------------------- #
# ---------------------------------------------------------------------------------------------------------------- #
@property
def xt_all(self):
"""Returns the All Xtenders (Multicast) device if exist else returns None"""
return self._connected_devices.get(XT_GROUP_DEVICE_ID)
@property
def xt1(self):
"""Returns the 1st Xtender device if exist else returns None"""
return self._connected_devices.get(XT_1_DEVICE_ID)
@property
def xt2(self):
"""Returns the 2nd Xtender device if exist else returns None"""
return self._connected_devices.get(XT_2_DEVICE_ID)
@property
def xt3(self):
"""Returns the 3rd Xtender device if exist else returns None"""
return self._connected_devices.get(XT_3_DEVICE_ID)
@property
def xt4(self):
"""Returns the 4th Xtender device if exist else returns None"""
return self._connected_devices.get(XT_4_DEVICE_ID)
@property
def xt5(self):
"""Returns the 5th Xtender device if exist else returns None"""
return self._connected_devices.get(XT_5_DEVICE_ID)
@property
def xt6(self):
"""Returns the 6th Xtender device if exist else returns None"""
return self._connected_devices.get(XT_6_DEVICE_ID)
@property
def xt7(self):
"""Returns the 7th Xtender device if exist else returns None"""
return self._connected_devices.get(XT_7_DEVICE_ID)
@property
def xt8(self):
"""Returns the 8th Xtender device if exist else returns None"""
return self._connected_devices.get(XT_8_DEVICE_ID)
@property
def xt9(self):
"""Returns the 9th Xtender device if exist else returns None"""
return self._connected_devices.get(XT_9_DEVICE_ID)
# ---------------------------------------------------------------------------------------------------------------- #
# ------------------------------------- Getters Properties for VarioTracks ------------------------------------ #
# ---------------------------------------------------------------------------------------------------------------- #
@property
def vt_all(self):
"""Returns the All VarioTracks (Multicast) device if exist else returns None"""
return self._connected_devices.get(VT_GROUP_DEVICE_ID)
@property
def vt1(self):
"""Returns the 1st VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_1_DEVICE_ID)
@property
def vt2(self):
"""Returns the 2nd VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_2_DEVICE_ID)
@property
def vt3(self):
"""Returns the 3rd VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_3_DEVICE_ID)
@property
def vt4(self):
"""Returns the 4th VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_4_DEVICE_ID)
@property
def vt5(self):
"""Returns the 5th VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_5_DEVICE_ID)
@property
def vt6(self):
"""Returns the 6th VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_6_DEVICE_ID)
@property
def vt7(self):
"""Returns the 7th VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_7_DEVICE_ID)
@property
def vt8(self):
"""Returns the 8th VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_8_DEVICE_ID)
@property
def vt9(self):
"""Returns the 9th VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_9_DEVICE_ID)
@property
def vt10(self):
"""Returns the 9th VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_10_DEVICE_ID)
@property
def vt11(self):
"""Returns the 9th VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_11_DEVICE_ID)
@property
def vt12(self):
"""Returns the 9th VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_12_DEVICE_ID)
@property
def vt13(self):
"""Returns the 9th VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_13_DEVICE_ID)
@property
def vt14(self):
"""Returns the 9th VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_14_DEVICE_ID)
@property
def vt15(self):
"""Returns the 9th VarioTrack device if exist else returns None"""
return self._connected_devices.get(VT_15_DEVICE_ID)
# ---------------------------------------------------------------------------------------------------------------- #
# ------------------------------------ Getters Properties for VarioStrings ------------------------------------ #
# ---------------------------------------------------------------------------------------------------------------- #
@property
def vs_all(self):
"""Returns the All VarioStrings (Multicast) device if exist else returns None"""
return self._connected_devices.get(VS_GROUP_DEVICE_ID)
@property
def vs1(self):
"""Returns the 1st VarioString device if exist else returns None"""
return self._connected_devices.get(VS_1_DEVICE_ID)
@property
def vs2(self):
"""Returns the 2nd VarioString device if exist else returns None"""
return self._connected_devices.get(VS_2_DEVICE_ID)
@property
def vs3(self):
"""Returns the 3rd VarioString device if exist else returns None"""
return self._connected_devices.get(VS_3_DEVICE_ID)
@property
def vs4(self):
"""Returns the 4th VarioString device if exist else returns None"""
return self._connected_devices.get(VS_4_DEVICE_ID)
@property
def vs5(self):
"""Returns the 5th VarioString device if exist else returns None"""
return self._connected_devices.get(VS_5_DEVICE_ID)
@property
def vs6(self):
"""Returns the 6th VarioString device if exist else returns None"""
return self._connected_devices.get(VS_6_DEVICE_ID)
@property
def vs7(self):
"""Returns the 7th VarioString device if exist else returns None"""
return self._connected_devices.get(VS_7_DEVICE_ID)
@property
def vs8(self):
"""Returns the 8th VarioString device if exist else returns None"""
return self._connected_devices.get(VS_8_DEVICE_ID)
@property
def vs9(self):
"""Returns the 9th VarioString device if exist else returns None"""
return self._connected_devices.get(VS_9_DEVICE_ID)
@property
def vs10(self):
"""Returns the 9th VarioString device if exist else returns None"""
return self._connected_devices.get(VS_10_DEVICE_ID)
@property
def vs11(self):
"""Returns the 9th VarioString device if exist else returns None"""
return self._connected_devices.get(VS_11_DEVICE_ID)
@property
def vs12(self):
"""Returns the 9th VarioString device if exist else returns None"""
return self._connected_devices.get(VS_12_DEVICE_ID)
@property
def vs13(self):
"""Returns the 9th VarioString device if exist else returns None"""
return self._connected_devices.get(VS_13_DEVICE_ID)
@property
def vs14(self):
"""Returns the 9th VarioString device if exist else returns None"""
return self._connected_devices.get(VS_14_DEVICE_ID)
@property
def vs15(self):
"""Returns the 9th VarioString device if exist else returns None"""
return self._connected_devices.get(VS_15_DEVICE_ID)
# ---------------------------------------------------------------------------------------------------------------- #
# ---------------------------------------- Getters Properties for BSPs ---------------------------------------- #
# ---------------------------------------------------------------------------------------------------------------- #
@property
def bsp(self):
"""Returns the only BSP device if exist else returns None"""
return self._connected_devices.get(BSP_DEVICE_ID)
# ---------------------------------------------------------------------------------------------------------------- #
# ----------------------------- Getters Properties for (RCC, Xcom-232i, Xcom-CAN)s ---------------------------- #
# ---------------------------------------------------------------------------------------------------------------- #
@property
def rcc_all(self):
"""Returns the All (RCC, Xcom-232i, Xcom-CAN)s (Multicast) device if exist else returns None"""
return self._connected_devices.get(RCC_GROUP_DEVICE_ID)
@property
def rcc1(self):
"""Returns the 1st (RCC, Xcom-232i, Xcom-CAN) device if exist else returns None"""
return self._connected_devices.get(RCC_1_DEVICE_ID)
@property
def xcom232i(self):
"""Returns the Xcom-232i device to which you speak with RS-232 if exist else returns None"""
return self._connected_devices.get(XCOM232i_DEVICE_ID)
@property
def rcc2(self):
"""Returns the 2nd (RCC, Xcom-232i, Xcom-CAN) device if exist else returns None"""
return self._connected_devices.get(RCC_2_DEVICE_ID)
@property
def rcc3(self):
"""Returns the 3rd (RCC, Xcom-232i, Xcom-CAN) device if exist else returns None"""
return self._connected_devices.get(RCC_3_DEVICE_ID)
@property
def rcc4(self):
"""Returns the 4th (RCC, Xcom-232i, Xcom-CAN) device if exist else returns None"""
return self._connected_devices.get(RCC_4_DEVICE_ID)
@property
def rcc5(self):
"""Returns the 5th (RCC, Xcom-232i, Xcom-CAN) device if exist else returns None"""
return self._connected_devices.get(RCC_5_DEVICE_ID)
# -------------------------------------------------------------------------------------------------------------------- #
# -------------------------------------------- End of NodeObserver Class ------------------------------------------- #
# -------------------------------------------------------------------------------------------------------------------- #
| 38.911616 | 120 | 0.582387 | 1,804 | 15,409 | 4.726164 | 0.10643 | 0.093831 | 0.126671 | 0.155524 | 0.770936 | 0.645907 | 0.47619 | 0.465165 | 0.45156 | 0.45156 | 0 | 0.020209 | 0.190733 | 15,409 | 395 | 121 | 39.010127 | 0.663512 | 0.442663 | 0 | 0.236607 | 0 | 0 | 0.007406 | 0 | 0 | 0 | 0 | 0 | 0.004464 | 1 | 0.254464 | false | 0 | 0.227679 | 0 | 0.723214 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
3b8ca4f8e057d80e334b5691ca3ccf82435e863f | 2,624 | py | Python | norse/main_script.py | t3ddezz/norse | 65e3f23dffb49abdb96a5d05b0c8c4026af69fe7 | [
"MIT"
] | 2 | 2021-04-20T10:54:39.000Z | 2021-04-20T14:23:21.000Z | norse/main_script.py | t3ddezz/norse | 65e3f23dffb49abdb96a5d05b0c8c4026af69fe7 | [
"MIT"
] | 3 | 2021-10-18T09:12:52.000Z | 2022-02-04T09:10:58.000Z | norse/main_script.py | t3ddezz/norse | 65e3f23dffb49abdb96a5d05b0c8c4026af69fe7 | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
import sys
import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5)
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtWidgets import QApplication, QMainWindow, QInputDialog, QFileDialog, QFrame, QMessageBox
from PyQt5.QtGui import QPalette, QColor, QIcon, QPixmap
from PyQt5.QtCore import Qt, QFileInfo
import pandas as pd
import io
import requests
import os.path
from datetime import datetime
import paramiko
import socket
import time
import os
import argparse
from .norse_module.MainWindow_libraries import MyWindow
version = "0.3.2"
program = "norse"
def main(sysargs = sys.argv[1:]):#main function to run script and see version
parser = argparse.ArgumentParser(prog = program,
description='norse, nanopoore sequencing data transfer',
usage='''norse [options]''')
parser.add_argument("-v","--version", action='version', version=f"norse= {version}")
parser.add_argument("-r","--run",action='store_true', help=f"run {program}")
if len(sysargs)<1:#if nothing typed show all arguments which avaible
parser.print_help()
sys.exit(-1)
else:
args = parser.parse_args(sysargs)
args = parser.parse_args()
if args.run:
window()#function to show GUI
def window():# func to show GUI and exit correctly
app = QApplication(sys.argv)
# dark mode pallette
app.setStyle('Fusion')
dark_palette = QtGui.QPalette()
dark_palette.setColor(QtGui.QPalette.Window, QtGui.QColor(53, 53, 53))
dark_palette.setColor(QtGui.QPalette.WindowText, QtCore.Qt.white)
dark_palette.setColor(QtGui.QPalette.Base, QtGui.QColor(25, 25, 25))
dark_palette.setColor(QtGui.QPalette.AlternateBase, QtGui.QColor(53, 53, 53))
dark_palette.setColor(QtGui.QPalette.ToolTipBase, QtCore.Qt.white)
dark_palette.setColor(QtGui.QPalette.ToolTipText, QtCore.Qt.white)
dark_palette.setColor(QtGui.QPalette.Text, QtCore.Qt.white)
dark_palette.setColor(QtGui.QPalette.Button, QtGui.QColor(53, 53, 53))
dark_palette.setColor(QtGui.QPalette.ButtonText, QtCore.Qt.white)
dark_palette.setColor(QtGui.QPalette.BrightText, QtCore.Qt.red)
dark_palette.setColor(QtGui.QPalette.Link, QtGui.QColor(42, 130, 218))
dark_palette.setColor(QtGui.QPalette.Highlight, QtGui.QColor(42, 130, 218))
dark_palette.setColor(QtGui.QPalette.HighlightedText, QtCore.Qt.black)
app.setPalette(dark_palette)
win = MyWindow()
win.show()
sys.exit(app.exec_())
if __name__ == '__main__':#to clarify this has to be mainscript and not a importet module
main()
#window() | 33.21519 | 102 | 0.727134 | 349 | 2,624 | 5.375358 | 0.389685 | 0.087953 | 0.131663 | 0.166311 | 0.303838 | 0.252665 | 0.252665 | 0.252665 | 0.132729 | 0.132729 | 0 | 0.023529 | 0.157774 | 2,624 | 79 | 103 | 33.21519 | 0.825339 | 0.098323 | 0 | 0 | 0 | 0 | 0.061043 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.035714 | false | 0 | 0.303571 | 0 | 0.339286 | 0.017857 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
3b905c364616e876045042fe48faba3d6b4d4232 | 1,487 | py | Python | supriya/commands/GroupQueryTreeRequest.py | deeuu/supriya | 14fcb5316eccb4dafbe498932ceff56e1abb9d27 | [
"MIT"
] | null | null | null | supriya/commands/GroupQueryTreeRequest.py | deeuu/supriya | 14fcb5316eccb4dafbe498932ceff56e1abb9d27 | [
"MIT"
] | null | null | null | supriya/commands/GroupQueryTreeRequest.py | deeuu/supriya | 14fcb5316eccb4dafbe498932ceff56e1abb9d27 | [
"MIT"
] | null | null | null | import supriya.osc
from supriya.commands.Request import Request
from supriya.enums import RequestId
class GroupQueryTreeRequest(Request):
"""
A /g_queryTree request.
::
>>> import supriya.commands
>>> request = supriya.commands.GroupQueryTreeRequest(
... node_id=0,
... include_controls=True,
... )
>>> request
GroupQueryTreeRequest(
include_controls=True,
node_id=0,
)
::
>>> request.to_osc()
OscMessage('/g_queryTree', 0, 1)
"""
### CLASS VARIABLES ###
request_id = RequestId.GROUP_QUERY_TREE
### INITIALIZER ###
def __init__(self, node_id=None, include_controls=False):
Request.__init__(self)
self._node_id = node_id
self._include_controls = bool(include_controls)
### PUBLIC METHODS ###
def to_osc(self, *, with_placeholders=False):
request_id = self.request_name
node_id = int(self.node_id)
include_controls = int(self.include_controls)
message = supriya.osc.OscMessage(request_id, node_id, include_controls)
return message
### PUBLIC PROPERTIES ###
@property
def include_controls(self):
return self._include_controls
@property
def node_id(self):
return self._node_id
@property
def response_patterns(self):
return ["/g_queryTree.reply", int(self.include_controls), self.node_id], None
| 23.603175 | 85 | 0.619368 | 157 | 1,487 | 5.566879 | 0.292994 | 0.075515 | 0.057208 | 0.032037 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003704 | 0.273705 | 1,487 | 62 | 86 | 23.983871 | 0.805556 | 0.28581 | 0 | 0.125 | 0 | 0 | 0.018653 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.208333 | false | 0 | 0.125 | 0.125 | 0.583333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
3b935268c7ce804d76a25c98789ae691ed264906 | 819 | py | Python | tests/test_cluster.py | TheCodeEngine/server-compose | af309d96509be46be1815c4d3bbff971dca83822 | [
"MIT"
] | null | null | null | tests/test_cluster.py | TheCodeEngine/server-compose | af309d96509be46be1815c4d3bbff971dca83822 | [
"MIT"
] | 10 | 2015-06-16T20:05:37.000Z | 2015-06-21T12:38:38.000Z | tests/test_cluster.py | TheCodeEngine/server-compose | af309d96509be46be1815c4d3bbff971dca83822 | [
"MIT"
] | null | null | null | from pkg import Cluster, Node
from mock import patch, Mock, MagicMock
def test_init():
cluster = Cluster()
assert cluster is not None
def helper_create_cluster():
cluster = Cluster(('127.0.0.1', '127.0.0.2', '127.0.0.3'), user='root', password='123456')
return cluster
def test_init_with_node():
cluster = Cluster()
assert cluster is not None
assert cluster.count() is 1
def test_init_with_nodes():
cluster = helper_create_cluster()
assert cluster is not None
assert cluster.count() is 3
def test_get_vars_from_nodes():
mock = Cluster
mock._create_node = MagicMock(return_value=Node(host='127.0.0.1', user='root', password='123456', dbname='name'))
mock = helper_create_cluster()
def test_wsrep_vars_values():
cluster = helper_create_cluster()
rv = cluster.wsrep_vars_values()
assert len(rv) is 10 | 27.3 | 114 | 0.742369 | 130 | 819 | 4.469231 | 0.315385 | 0.060241 | 0.130809 | 0.113597 | 0.242685 | 0.242685 | 0.242685 | 0.168675 | 0.168675 | 0.168675 | 0 | 0.05618 | 0.130647 | 819 | 30 | 115 | 27.3 | 0.759831 | 0 | 0 | 0.291667 | 0 | 0 | 0.073171 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0.25 | false | 0.083333 | 0.083333 | 0 | 0.375 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
3b93a015bbbe2d868d56fb72f3fddc1b0e804c63 | 405 | py | Python | torchtext/vocab/__init__.py | parmeet/text | 1fb2aedb48b5ecc5e81741e7c8504486b91655c6 | [
"BSD-3-Clause"
] | 3,172 | 2017-01-18T19:47:03.000Z | 2022-03-27T17:06:03.000Z | torchtext/vocab/__init__.py | parmeet/text | 1fb2aedb48b5ecc5e81741e7c8504486b91655c6 | [
"BSD-3-Clause"
] | 1,228 | 2017-01-18T20:09:16.000Z | 2022-03-31T04:42:35.000Z | torchtext/vocab/__init__.py | parmeet/text | 1fb2aedb48b5ecc5e81741e7c8504486b91655c6 | [
"BSD-3-Clause"
] | 850 | 2017-01-19T03:19:54.000Z | 2022-03-29T15:29:52.000Z | from .vocab import Vocab
from .vectors import (
GloVe,
FastText,
CharNGram,
pretrained_aliases,
Vectors,
)
from .vocab_factory import (
vocab,
build_vocab_from_iterator,
)
__all__ = ["Vocab",
"vocab",
"build_vocab_from_iterator",
"GloVe",
"FastText",
"CharNGram",
"pretrained_aliases",
"Vectors"]
| 16.875 | 39 | 0.558025 | 35 | 405 | 6.085714 | 0.371429 | 0.126761 | 0.206573 | 0.300469 | 0.685446 | 0.431925 | 0 | 0 | 0 | 0 | 0 | 0 | 0.34321 | 405 | 23 | 40 | 17.608696 | 0.800752 | 0 | 0 | 0 | 0 | 0 | 0.202469 | 0.061728 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.15 | 0 | 0.15 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
3ba19067061706432def37e08eb633818b45637e | 980 | py | Python | huxley/api/views/delegate.py | Erice59/hmunc-huxley | c3be528cb94123743a6d548688900c8a41c21437 | [
"BSD-3-Clause"
] | null | null | null | huxley/api/views/delegate.py | Erice59/hmunc-huxley | c3be528cb94123743a6d548688900c8a41c21437 | [
"BSD-3-Clause"
] | null | null | null | huxley/api/views/delegate.py | Erice59/hmunc-huxley | c3be528cb94123743a6d548688900c8a41c21437 | [
"BSD-3-Clause"
] | null | null | null | # Copyright (c) 2011-2015 Berkeley Model United Nations. All rights reserved.
# Use of this source code is governed by a BSD License (see LICENSE).
from rest_framework import generics, status
from rest_framework.authentication import SessionAuthentication
from rest_framework.response import Response
from huxley.api.permissions import IsSchoolDelegateAdvisorOrSuperuser, IsPostOrSuperuserOnly
from huxley.api.serializers import DelegateSerializer
from huxley.core.models import Delegate
class DelegateList(generics.CreateAPIView):
authentication_classes = (SessionAuthentication,)
queryset = Delegate.objects.all()
permission_classes = (IsPostOrSuperuserOnly,)
serializer_class = DelegateSerializer
class DelegateDetail(generics.RetrieveUpdateDestroyAPIView):
authentication_classes = (SessionAuthentication,)
queryset = Delegate.objects.all()
permission_classes = (IsSchoolDelegateAdvisorOrSuperuser,)
serializer_class = DelegateSerializer
| 39.2 | 92 | 0.823469 | 95 | 980 | 8.4 | 0.547368 | 0.030075 | 0.06391 | 0.125313 | 0.213033 | 0.213033 | 0.213033 | 0.213033 | 0.213033 | 0 | 0 | 0.00927 | 0.119388 | 980 | 24 | 93 | 40.833333 | 0.915411 | 0.145918 | 0 | 0.375 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.375 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
8e5ad2fadcadf916a9c545c4a82b17dc7015c28c | 2,469 | py | Python | W-CF/counterfactual_utils.py | e-delaney/Instance-Based_CFE_TSC | 2541b7be69c474b5fb6bc5521b3cab5e5f5481c7 | [
"BSD-2-Clause"
] | 4 | 2021-06-07T21:06:01.000Z | 2022-01-10T18:02:27.000Z | W-CF/counterfactual_utils.py | e-delaney/Instance-Based_CFE_TSC | 2541b7be69c474b5fb6bc5521b3cab5e5f5481c7 | [
"BSD-2-Clause"
] | null | null | null | W-CF/counterfactual_utils.py | e-delaney/Instance-Based_CFE_TSC | 2541b7be69c474b5fb6bc5521b3cab5e5f5481c7 | [
"BSD-2-Clause"
] | null | null | null | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import tensorflow as tf
tf.get_logger().setLevel(40) # suppress deprecation messages
tf.compat.v1.disable_v2_behavior() # disable TF2 behaviour as alibi code still relies on TF1 constructs
from tensorflow.keras.layers import Dense, Input
from tensorflow.keras.models import Model, load_model
from tensorflow.keras.utils import to_categorical
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Activation, Conv1D, GlobalAveragePooling1D, BatchNormalization, Conv2D
from tensorflow.keras.layers import GlobalAveragePooling1D
from tensorflow.keras.utils import to_categorical
from tensorflow.keras.backend import function
import matplotlib
get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
import seaborn as sns
from sklearn.datasets import load_iris
from alibi.explainers import CEM
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn.linear_model import LogisticRegression
from scipy.optimize import minimize
from scipy.spatial.distance import cdist, pdist
from scipy import stats
from sklearn.neighbors import DistanceMetric
from tslearn.datasets import UCR_UEA_datasets
from tslearn.neighbors import NearestNeighbors, KNeighborsTimeSeries
from sklearn.metrics import accuracy_score
from sklearn import preprocessing
print('TF version: ', tf.__version__)
print('Eager execution enabled: ', tf.executing_eagerly()) # False
# In[2]:
from tensorflow import keras
import time
# In[3]:
def ucr_data_loader(dataset):
X_train, y_train, X_test, y_test = UCR_UEA_datasets().load_dataset(dataset)
return X_train, y_train, X_test, y_test
# In[4]:
def label_encoder(training_labels, testing_labels):
le = preprocessing.LabelEncoder()
le.fit(np.concatenate((training_labels, testing_labels), axis=0))
y_train = le.transform(training_labels)
y_test = le.transform(testing_labels)
return y_train, y_test
def native_guide_retrieval(query, predicted_label, distance, n_neighbors):
knn = KNeighborsTimeSeries(n_neighbors=n_neighbors, metric = distance)
knn.fit(X_train[list(df[df['label'] != predicted_label].index.values)])
dist,ind = knn.kneighbors(query.reshape(1,ts_length), return_distance=True)
return dist[0], df[df['label'] != predicted_label].index[ind[0][:]]
| 28.709302 | 113 | 0.784933 | 341 | 2,469 | 5.516129 | 0.439883 | 0.066986 | 0.080808 | 0.039872 | 0.196704 | 0.157363 | 0.089314 | 0.089314 | 0.065922 | 0.065922 | 0 | 0.00887 | 0.132442 | 2,469 | 85 | 114 | 29.047059 | 0.869281 | 0.066829 | 0 | 0.040816 | 0 | 0 | 0.027463 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.061224 | false | 0 | 0.612245 | 0 | 0.734694 | 0.040816 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
8e5ef768ec629da53210a6381235544967d58fef | 402 | py | Python | articles/models.py | Mayank250199/Django | cc51e2d60cb4d10646e5b88c4d721ac13a06b30c | [
"MIT"
] | null | null | null | articles/models.py | Mayank250199/Django | cc51e2d60cb4d10646e5b88c4d721ac13a06b30c | [
"MIT"
] | null | null | null | articles/models.py | Mayank250199/Django | cc51e2d60cb4d10646e5b88c4d721ac13a06b30c | [
"MIT"
] | null | null | null | from django.db import models
class Article(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField()
body = models.TextField()
date = models.DateTimeField(auto_now_add=True)
thumb = models.ImageField(default='deafult.png',blank=True)
def __str__(self):
return self.title
def snippet(self):
return self.body[0:100] + '...'
| 26.8 | 63 | 0.659204 | 50 | 402 | 5.16 | 0.7 | 0.077519 | 0.108527 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.022222 | 0.216418 | 402 | 15 | 64 | 26.8 | 0.796825 | 0 | 0 | 0 | 0 | 0 | 0.034739 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.181818 | false | 0 | 0.090909 | 0.181818 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
8e6079db95e0e3c256a3ed3b4f733e919831f7df | 400 | py | Python | python/cours/cours1.py | M0n0xy2/mpsi_python_cours | 9c02ca52f7db8f995e20cba4ce3fd5e7866ae11e | [
"MIT"
] | 1 | 2019-10-26T13:16:59.000Z | 2019-10-26T13:16:59.000Z | python/cours/cours1.py | M0n0xy2/mpsi_python_cours | 9c02ca52f7db8f995e20cba4ce3fd5e7866ae11e | [
"MIT"
] | null | null | null | python/cours/cours1.py | M0n0xy2/mpsi_python_cours | 9c02ca52f7db8f995e20cba4ce3fd5e7866ae11e | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
# probleme des 8 dames
def printGrid(grid):
for y in range(8):
print(8 - y, end=" |")
for x in range(8):
print(grid[x][y], "", end="")
print()
print("------------------")
print("X |A B C D E F G H")
grid = [[0] * 8 for _ in range(8)]
for j in range(8):
for i in range(8):
grid[i][j] = (i + j) % 10
printGrid(grid)
| 21.052632 | 41 | 0.465 | 67 | 400 | 2.761194 | 0.447761 | 0.189189 | 0.216216 | 0.140541 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.043478 | 0.31 | 400 | 18 | 42 | 22.222222 | 0.626812 | 0.105 | 0 | 0 | 0 | 0 | 0.106742 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.076923 | false | 0 | 0 | 0 | 0.076923 | 0.538462 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
8e732b30f3af5291fdacb5a1240d402fe9fbc822 | 541 | py | Python | POO-USP/Lista11_Python/Ex03_PegadaDeCarbono/bicicleta.py | MateusBCC020/Java-Development | 380c4a2c989fc0f691d220eebb7191335d5b716b | [
"MIT"
] | null | null | null | POO-USP/Lista11_Python/Ex03_PegadaDeCarbono/bicicleta.py | MateusBCC020/Java-Development | 380c4a2c989fc0f691d220eebb7191335d5b716b | [
"MIT"
] | null | null | null | POO-USP/Lista11_Python/Ex03_PegadaDeCarbono/bicicleta.py | MateusBCC020/Java-Development | 380c4a2c989fc0f691d220eebb7191335d5b716b | [
"MIT"
] | null | null | null | class Bicicleta:
def __init__(self, marca, aro, calibragem):
self.marca = marca;
self.aro = aro;
self.calibragem = calibragem;
def __str__(self):
string = "Marca: "+self.marca+"\nAro: "+str(self.aro)+"\nCalibragem: "+str(self.calibragem)
return string
def getMarca(self):
return self.marca
def getAro(self):
return self.aro
def getCalibragem(self):
return self.calibragem
def getPegadaCarbono(self):
pegCarb = 0
return pegCarb
| 22.541667 | 99 | 0.597043 | 59 | 541 | 5.338983 | 0.322034 | 0.114286 | 0.133333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002618 | 0.2939 | 541 | 23 | 100 | 23.521739 | 0.82199 | 0 | 0 | 0 | 0 | 0 | 0.051756 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.352941 | false | 0 | 0 | 0.176471 | 0.705882 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
8e7c8209c036d73da37ab2987448aa9b90661f66 | 234 | py | Python | Networking/Packets/Outgoing/__init__.py | jeui123/pyrelay | 43203343217c784183342dead933e0dc88c161d0 | [
"MIT"
] | 26 | 2020-07-24T05:47:02.000Z | 2022-03-31T16:03:13.000Z | Networking/Packets/Outgoing/__init__.py | jeui123/pyrelay | 43203343217c784183342dead933e0dc88c161d0 | [
"MIT"
] | 17 | 2020-07-27T08:11:19.000Z | 2022-03-29T05:26:16.000Z | Networking/Packets/Outgoing/__init__.py | jeui123/pyrelay | 43203343217c784183342dead933e0dc88c161d0 | [
"MIT"
] | 16 | 2021-01-20T14:30:37.000Z | 2022-03-18T05:31:51.000Z | import os
import importlib
path = __file__.replace("__init__.py", "")
for file in os.listdir(path):
if "__" not in file:
globals()[file[:-3]] = getattr(importlib.import_module(__name__+"."+file[:-3]), file[:-3])
| 26 | 99 | 0.623932 | 31 | 234 | 4.225806 | 0.580645 | 0.114504 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015707 | 0.183761 | 234 | 8 | 100 | 29.25 | 0.670157 | 0 | 0 | 0 | 0 | 0 | 0.061947 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
8e8f92c2d00b425af0a53c0ab5f59d24865796ff | 251 | py | Python | xiuren/middleware/__init__.py | sujianqingfeng/scrapy_xiuren | a05d8fe05777aca26667c5b40573ef0431bcff06 | [
"Apache-2.0"
] | 49 | 2018-04-18T03:48:48.000Z | 2021-12-21T03:14:07.000Z | xiuren/middleware/__init__.py | sujianqingfeng/xiuren | a05d8fe05777aca26667c5b40573ef0431bcff06 | [
"Apache-2.0"
] | null | null | null | xiuren/middleware/__init__.py | sujianqingfeng/xiuren | a05d8fe05777aca26667c5b40573ef0431bcff06 | [
"Apache-2.0"
] | 21 | 2018-05-10T03:35:20.000Z | 2021-08-15T18:19:54.000Z | #!/usr/bin/env python
# encoding: utf-8
"""
@author: su jian
@contact: 121116111@qq.com
@file: __init__.py.py
@time: 2017/8/16 17:43
"""
def func():
pass
class Main():
def __init__(self):
pass
if __name__ == '__main__':
pass | 11.409091 | 26 | 0.605578 | 37 | 251 | 3.675676 | 0.810811 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.107692 | 0.223108 | 251 | 22 | 27 | 11.409091 | 0.589744 | 0.498008 | 0 | 0.428571 | 0 | 0 | 0.067797 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0.428571 | 0 | 0 | 0.428571 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
8eb116fa48651e3bf83eae218c0f312eca9f7766 | 1,192 | py | Python | test/helpers/fake_config.py | fossabot/jasmine-py | bd24fe81dacae12eb5364bcc21d4f61518f15ccf | [
"MIT"
] | 87 | 2015-02-10T00:27:48.000Z | 2022-01-07T02:11:39.000Z | test/helpers/fake_config.py | fossabot/jasmine-py | bd24fe81dacae12eb5364bcc21d4f61518f15ccf | [
"MIT"
] | 34 | 2015-01-19T10:10:45.000Z | 2022-01-01T19:28:11.000Z | test/helpers/fake_config.py | fossabot/jasmine-py | bd24fe81dacae12eb5364bcc21d4f61518f15ccf | [
"MIT"
] | 28 | 2015-02-05T16:08:39.000Z | 2022-02-26T14:06:38.000Z | class FakeConfig(object):
def __init__(
self,
src_dir=None,
spec_dir=None,
stylesheet_urls=None,
script_urls=None,
stop_spec_on_expectation_failure=False,
stop_on_spec_failure=False,
random=True
):
self._src_dir = src_dir
self._spec_dir = spec_dir
self._stylesheet_urls = stylesheet_urls
self._script_urls = script_urls
self._stop_spec_on_expectation_failure = stop_spec_on_expectation_failure
self._stop_on_spec_failure = stop_on_spec_failure
self._random = random
self.reload_call_count = 0
def src_dir(self):
return self._src_dir
def spec_dir(self):
return self._spec_dir
def stylesheet_urls(self):
return self._stylesheet_urls
def script_urls(self):
return self._script_urls
def stop_spec_on_expectation_failure(self):
return self._stop_spec_on_expectation_failure
def stop_on_spec_failure(self):
return self._stop_on_spec_failure
def random(self):
return self._random
def reload(self):
self.reload_call_count += 1
| 26.488889 | 81 | 0.653523 | 151 | 1,192 | 4.649007 | 0.172185 | 0.099715 | 0.139601 | 0.149573 | 0.353276 | 0.182336 | 0 | 0 | 0 | 0 | 0 | 0.002356 | 0.287752 | 1,192 | 44 | 82 | 27.090909 | 0.824499 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.257143 | false | 0 | 0 | 0.2 | 0.485714 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
8ebbbc9bac5895a39d344ae6d0fe09042eeabb9f | 354 | py | Python | example-bot/bot/util/timer.py | Vilsepi/sc2-spectator | 5ad082de74272b054a7da343537d392a98c7a5ef | [
"MIT"
] | 1 | 2019-05-28T20:55:34.000Z | 2019-05-28T20:55:34.000Z | bot/util/timer.py | Vilsepi/sc2-landlubber | 9f44aecee715b526d8ae520e60dfee75ef7c8de2 | [
"MIT"
] | null | null | null | bot/util/timer.py | Vilsepi/sc2-landlubber | 9f44aecee715b526d8ae520e60dfee75ef7c8de2 | [
"MIT"
] | 2 | 2019-07-27T21:27:54.000Z | 2019-12-02T13:31:10.000Z |
class Timer:
def __init__(self, bot, ring_every=1.0):
self.bot = bot
self.last_ring = 0.0
self.ring_every = ring_every
@property
def rings(self):
if (self.bot.time - self.last_ring) >= self.ring_every:
self.last_ring = self.bot.time
return True
else:
return False
| 23.6 | 63 | 0.559322 | 48 | 354 | 3.895833 | 0.395833 | 0.149733 | 0.192513 | 0.171123 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017241 | 0.344633 | 354 | 14 | 64 | 25.285714 | 0.788793 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0 | 0 | 0.416667 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
8ebbc16b38033fd598ec16206b8a462c66581c35 | 2,071 | py | Python | enot/packages/application_config.py | comtihon/valrus | d01c380348a18b67dbb73f429464b454165a7ec3 | [
"Apache-2.0"
] | 16 | 2018-02-14T00:22:41.000Z | 2022-02-04T23:38:52.000Z | enot/packages/application_config.py | comtihon/valrus | d01c380348a18b67dbb73f429464b454165a7ec3 | [
"Apache-2.0"
] | 36 | 2017-04-26T20:15:23.000Z | 2018-02-13T16:45:32.000Z | enot/packages/application_config.py | comtihon/valrus | d01c380348a18b67dbb73f429464b454165a7ec3 | [
"Apache-2.0"
] | 2 | 2019-02-14T07:57:12.000Z | 2019-03-28T17:30:01.000Z | """
Application config .app.src or .app
"""
from logging import warning
from os.path import join
from tarfile import TarFile
from enot.utils.erl_file_utils import parse_app_config, contains_app_file, parse_app_config_content
class AppConfig:
def __init__(self, name: str, vsn: str, apps: list, template: bool, compose=True) -> None:
self._name = name
self._vsn = vsn
self._applications = apps
self._is_template = template
self._compose_app_file = compose
@classmethod
# Find and parse src/Name.app.src. If none - find and parse ebin/Name.app. If none - return None
def from_path(cls, path: str) -> 'AppConfig' or None:
src_path = join(path, 'src')
if contains_app_file(src_path): # Check .app.src
name, vsn, apps, template = parse_app_config(src_path)
return cls(name, vsn, apps, template)
ebin_path = join(path, 'ebin') # Check .app
if contains_app_file(ebin_path, suffix='.app'):
name, vsn, apps, template = parse_app_config(ebin_path, suffix='.app')
return cls(name, vsn, apps, template, False)
warning('No app in path ' + path)
return None
@classmethod
def from_package(cls, file: str, package: TarFile, compose=False):
f = package.extractfile(file)
(name, vsn, apps, is_template) = parse_app_config_content(f.read())
# when calling from content - project was already built. No need to compose app file.
return cls(name, vsn, apps, is_template, compose=compose)
@property
def name(self) -> str:
return self._name
@property
def applications(self) -> list:
return self._applications
@property
def vsn(self) -> str:
return self._vsn
@property
def is_template(self) -> bool: # If app config contains jinja2 templates.
return self._is_template
@property
def compose_app_file(self) -> bool: # If there is a need to create ebin/<Name>.app during compilation
return self._compose_app_file
| 35.101695 | 106 | 0.65717 | 282 | 2,071 | 4.638298 | 0.244681 | 0.037462 | 0.050459 | 0.058104 | 0.132263 | 0.093272 | 0.050459 | 0 | 0 | 0 | 0 | 0.000641 | 0.246741 | 2,071 | 58 | 107 | 35.706897 | 0.837821 | 0.167069 | 0 | 0.162791 | 0 | 0 | 0.02278 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.186047 | false | 0 | 0.093023 | 0.116279 | 0.511628 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
8ebd86851798a509c314fe4ee3b2a7d422e366af | 972 | py | Python | SmartCar/SmartCarServer/web_server.py | m3rik/nn | 96d630cbb9894957d17ca8291900ff3802a30637 | [
"Apache-2.0"
] | null | null | null | SmartCar/SmartCarServer/web_server.py | m3rik/nn | 96d630cbb9894957d17ca8291900ff3802a30637 | [
"Apache-2.0"
] | null | null | null | SmartCar/SmartCarServer/web_server.py | m3rik/nn | 96d630cbb9894957d17ca8291900ff3802a30637 | [
"Apache-2.0"
] | null | null | null | import cherrypy
from cherrypy.process import servers
from motor_controller import start_motor_controller
class CarControlAPI:
def __init__(self, motor_controller):
self.motor_controller = motor_controller
cherrypy.engine.subscribe('stop', self.stop)
def stop(self):
self.motor_controller.stop()
@cherrypy.expose
def index(self):
return "OK"
@cherrypy.expose
def control(self, speed=0, balance=0):
ts = self.motor_controller.control_motors(speed, balance)
return str(speed) + ' ' + str(balance) + ' ' + str(ts)
def fake_wait_for_occupied_port(host, port): return
def start_webserver(motor_controller):
cherrypy.server.socket_host = '0.0.0.0'
cherrypy.server.socket_port = 8082
servers.wait_for_occupied_port = fake_wait_for_occupied_port
cherrypy.quickstart(CarControlAPI(motor_controller))
if __name__ == '__main__':
mc = start_motor_controller()
start_webserver(mc)
| 27.771429 | 65 | 0.720165 | 122 | 972 | 5.409836 | 0.344262 | 0.227273 | 0.115152 | 0.086364 | 0.069697 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012594 | 0.183128 | 972 | 34 | 66 | 28.588235 | 0.81864 | 0 | 0 | 0.08 | 0 | 0 | 0.023663 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.24 | false | 0 | 0.12 | 0.08 | 0.48 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
8ed9274239b22b61833193cdb51bfd8b516a15c2 | 4,004 | py | Python | deploy.py | schollz/flask-wiki | deabcb71e4240bfb4e45fbeb1c1c54da842dc9aa | [
"BSD-3-Clause"
] | 14 | 2016-03-31T08:07:02.000Z | 2021-12-28T16:13:29.000Z | deploy.py | schollz/flask-wiki | deabcb71e4240bfb4e45fbeb1c1c54da842dc9aa | [
"BSD-3-Clause"
] | null | null | null | deploy.py | schollz/flask-wiki | deabcb71e4240bfb4e45fbeb1c1c54da842dc9aa | [
"BSD-3-Clause"
] | 9 | 2018-04-25T15:08:20.000Z | 2022-02-05T05:54:56.000Z | import sys
import os
import socket
import multiprocessing
APP_NAME = 'zwiki'
APP_URL = 'www.zwiki.duckdns.org'
APP_PORT = 8013
mainIP = [(s.connect(('8.8.8.8', 80)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]
curDir = os.getcwd()
workers = multiprocessing.cpu_count() * 2 + 1
workers = 1
init_conf = """
# This should be placed in /etc/init.d directory
# start with
# sudo /etc/init.d/%(appname)s start
# stop with
# sudo /etc/init.d/%(appname)s start
dir="%(dir)s"
user="nobody"
cmd="gunicorn -b %(ip)s:%(port)s -w %(workers)s -t 600 app:app"
name=`basename $0`
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"
get_pid() {
cat "$pid_file"
}
is_running() {
[ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
}
case "$1" in
start)
if is_running; then
echo "Already started"
else
echo "Starting $name"
cd "$dir"
sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
echo $! > "$pid_file"
if ! is_running; then
echo "Unable to start, see $stdout_log and $stderr_log"
exit 1
fi
fi
;;
stop)
if is_running; then
echo -n "Stopping $name.."
kill `get_pid`
for i in {1..10}
do
if ! is_running; then
break
fi
echo -n "."
sleep 1
done
echo
if is_running; then
echo "Not stopped; may still be shutting down or shutdown may have failed"
exit 1
else
echo "Stopped"
if [ -f "$pid_file" ]; then
rm "$pid_file"
fi
fi
else
echo "Not running"
fi
;;
restart)
$0 stop
if is_running; then
echo "Unable to stop, will not attempt to start"
exit 1
fi
$0 start
;;
status)
if is_running; then
echo "Running"
else
echo "Stopped"
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
""" % {'port':APP_PORT,'dir':curDir,'appname':APP_NAME.replace(' ',''),'ip':mainIP, 'workers':str(workers)}
nginx_block = """
server {
# SERVER BLOCK FOR %(appname)s
listen 80; ## listen for ipv4; this line is default and implied
root %(dir)s;
index index.html index.htm;
access_log /etc/nginx/logs/access-%(appname)s.log;
error_log /etc/nginx/logs/error-%(appname)s.log;
server_name %(url)s;
location / {
proxy_pass http://%(ip)s:%(port)s;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
}
""" % {'port':APP_PORT,'dir':curDir,'appname':APP_NAME.replace(' ',''),'url':APP_URL + ' ' + APP_URL.replace('www.',''),'ip':mainIP}
####################
print 'generating init.d configuration file'
with open('/etc/init.d/'+APP_NAME,'w') as f:
f.write(init_conf)
os.system('chmod +x /etc/init.d/'+APP_NAME)
os.system('/etc/init.d/' + APP_NAME + ' restart')
print 'generating nginx server block'
with open('/etc/nginx/sites-available/'+APP_NAME,'w') as f:
f.write(nginx_block)
os.system('mkdir /etc/nginx/logs/')
os.system('rm /etc/nginx/sites-enabled/%(app)s' % {'app':APP_NAME})
print('ln -s /etc/nginx/sites-available/%(app)s /etc/nginx/sites-enabled/%(app)s' % {'app':APP_NAME})
os.system('ln -s /etc/nginx/sites-available/%(app)s /etc/nginx/sites-enabled/%(app)s' % {'app':APP_NAME})
os.system('/etc/init.d/nginx reload && service nginx restart')
print "-"*30
print "To activate:"
print '/etc/init.d/' + APP_NAME + ' [start|stop|restart]'
print 'Currently running on ' + str(mainIP) + ':'+str(APP_PORT)
print "-"*30
| 25.341772 | 137 | 0.574675 | 574 | 4,004 | 3.891986 | 0.296167 | 0.037601 | 0.028648 | 0.047001 | 0.259176 | 0.206804 | 0.194718 | 0.14145 | 0.115488 | 0.063563 | 0 | 0.014925 | 0.263736 | 4,004 | 157 | 138 | 25.503185 | 0.742877 | 0 | 0 | 0.267176 | 0 | 0.022901 | 0.754638 | 0.125686 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.007634 | 0.030534 | null | null | 0.061069 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d9279cfb584f328f2b3c10dc1ddb08b1a6c6eabe | 514 | py | Python | fhirstorm/resource/conformance.py | Arborian/fhirstorm | 08c8505ca568dd491f91d3ad74a4ca0c2c90eda6 | [
"Apache-2.0"
] | 8 | 2017-12-11T15:04:22.000Z | 2021-11-22T00:28:05.000Z | fhirstorm/resource/conformance.py | Arborian/fhirstorm | 08c8505ca568dd491f91d3ad74a4ca0c2c90eda6 | [
"Apache-2.0"
] | 7 | 2019-05-01T15:49:21.000Z | 2021-06-01T22:07:29.000Z | fhirstorm/resource/conformance.py | Arborian/fhirstorm | 08c8505ca568dd491f91d3ad74a4ca0c2c90eda6 | [
"Apache-2.0"
] | null | null | null | from ..util import reify
from .base_resource import Resource
from .service import Service
@Resource.register_resource('Conformance')
class Conformance(Resource):
@property
def rest(self):
return [
Service(it, _bind=self.bind)
for it in self['rest']]
@Resource.register_resource('CapabilityStatement')
class CapabilityStatement(Resource):
@property
def rest(self):
return [
Service(it, _bind=self.bind)
for it in self['rest']]
| 19.769231 | 50 | 0.649805 | 57 | 514 | 5.77193 | 0.350877 | 0.097264 | 0.145897 | 0.139818 | 0.419453 | 0.419453 | 0.419453 | 0.419453 | 0.419453 | 0.419453 | 0 | 0 | 0.249027 | 514 | 25 | 51 | 20.56 | 0.852332 | 0 | 0 | 0.588235 | 0 | 0 | 0.074074 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.117647 | false | 0 | 0.176471 | 0.117647 | 0.529412 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
d938e6a53a01cfa491eb35113f5fb982ca3c0c63 | 781 | py | Python | covid_api/views/catalogos/__init__.py | jmbarrios/covid-mexico-19 | 6872d55830e2a6cd6987a4ee517cd016dd853edf | [
"MIT"
] | null | null | null | covid_api/views/catalogos/__init__.py | jmbarrios/covid-mexico-19 | 6872d55830e2a6cd6987a4ee517cd016dd853edf | [
"MIT"
] | null | null | null | covid_api/views/catalogos/__init__.py | jmbarrios/covid-mexico-19 | 6872d55830e2a6cd6987a4ee517cd016dd853edf | [
"MIT"
] | 2 | 2020-05-11T15:32:31.000Z | 2020-05-13T19:12:20.000Z | from covid_api.views.catalogos.nacionalidad import CatalogoNacionalidadVista
from covid_api.views.catalogos.origen import CatalogoOrigenVista
from covid_api.views.catalogos.pais import CatalogoPaisVista
from covid_api.views.catalogos.resultado import CatalogoResultadoVista
from covid_api.views.catalogos.sector import CatalogoSectorVista
from covid_api.views.catalogos.sexo import CatalogoSexoVista
from covid_api.views.catalogos.si_no import CatalogoSiNoVista
from covid_api.views.catalogos.tipo_paciente import CatalogoTipoPacienteVista
__all__ = [
'CatalogoNacionalidadVista',
'CatalogoOrigenVista',
'CatalogoPaisVista',
'CatalogoResultadoVista',
'CatalogoSectorVista',
'CatalogoSexoVista',
'CatalogoSiNoVista',
'CatalogoTipoPacienteVista',
]
| 37.190476 | 77 | 0.834827 | 75 | 781 | 8.506667 | 0.333333 | 0.112853 | 0.15047 | 0.213166 | 0.326019 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.099872 | 781 | 20 | 78 | 39.05 | 0.907539 | 0 | 0 | 0 | 0 | 0 | 0.206146 | 0.09219 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.444444 | 0 | 0.444444 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
d9474bf52b46491b660db3fd62f16c87a759e676 | 1,694 | py | Python | pytorch_toolkit/object_detection/tests/export_tests_person_vehicle_bike_detection.py | morkovka1337/openvino_training_extensions | 846db45c264d6b061505213f51763520b9432ba9 | [
"Apache-2.0"
] | null | null | null | pytorch_toolkit/object_detection/tests/export_tests_person_vehicle_bike_detection.py | morkovka1337/openvino_training_extensions | 846db45c264d6b061505213f51763520b9432ba9 | [
"Apache-2.0"
] | null | null | null | pytorch_toolkit/object_detection/tests/export_tests_person_vehicle_bike_detection.py | morkovka1337/openvino_training_extensions | 846db45c264d6b061505213f51763520b9432ba9 | [
"Apache-2.0"
] | null | null | null | # Copyright (C) 2020 Intel Corporation
#
# 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 common.test_case import export_test_case
class PersonVehicleBikeDetection2000TestCase(
export_test_case('person-vehicle-bike-detection',
'person-vehicle-bike-detection-2000',
'vehicle-person-bike-detection-2000-1.pth',
alt_ssd_export=True)):
""" Test case for person-vehicle-bike-detection-2000 export. """
class PersonVehicleBikeDetection2001TestCase(
export_test_case('person-vehicle-bike-detection',
'person-vehicle-bike-detection-2001',
'vehicle-person-bike-detection-2001-1.pth',
alt_ssd_export=True)):
""" Test case for person-vehicle-bike-detection-2001 export. """
class PersonVehicleBikeDetection2002TestCase(
export_test_case('person-vehicle-bike-detection',
'person-vehicle-bike-detection-2002',
'vehicle-person-bike-detection-2002-1.pth',
alt_ssd_export=True)):
""" Test case for person-vehicle-bike-detection-2002 export. """
| 41.317073 | 76 | 0.66647 | 201 | 1,694 | 5.542289 | 0.427861 | 0.140036 | 0.137343 | 0.210054 | 0.352783 | 0.331239 | 0.331239 | 0.331239 | 0.331239 | 0.331239 | 0 | 0.045879 | 0.24085 | 1,694 | 40 | 77 | 42.35 | 0.820373 | 0.430342 | 0 | 0.375 | 0 | 0 | 0.330835 | 0.330835 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.0625 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d95ce3d57edb7cbc12a5767cf16a9997b0c2be96 | 1,306 | py | Python | PasswordManagerFunctions.py | bdchappel/PasswordGenerator | 84997ae8b6593ad420725ea3e768fef5e137e55b | [
"MIT"
] | null | null | null | PasswordManagerFunctions.py | bdchappel/PasswordGenerator | 84997ae8b6593ad420725ea3e768fef5e137e55b | [
"MIT"
] | null | null | null | PasswordManagerFunctions.py | bdchappel/PasswordGenerator | 84997ae8b6593ad420725ea3e768fef5e137e55b | [
"MIT"
] | null | null | null | import csv
import os
def menu_call():
user_selection = ""
while user_selection not in range(1, 4):
print("Please chose an option from the menu below:")
print("1: Generate a Password | 2: Create Entry | 3: Edit Entry | 4: Delete Entry.")
user_selection = int(input(">:"))
return user_selection
def create_entry():
user_answer = ""
while user_answer != 'y':
entry_user_website_url = input(
"Please enter the website this is for: ")
entry_user_name = input(
"Please enter the username you would like to store: ")
entry_user_password = input(
"Please enter the password you would like to store: ")
print(
f"Does the following information look correct? website: {entry_user_website_url} Username:{entry_user_name} password: {entry_user_password}")
user_answer = input(
"Please type 'Y' for yes, or any key to redo continue: ")
with open(os.path.dirname(__file__) + "\\" + "PasswordManagerUserFile.csv", 'w', newline='') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerow(entry_user_website_url +
entry_user_name + entry_user_password)
print(os.path.dirname(__file__) + 'PasswordManagerUserFile.csv')
| 40.8125 | 153 | 0.64242 | 164 | 1,306 | 4.884146 | 0.457317 | 0.123596 | 0.059925 | 0.071161 | 0.154806 | 0.107366 | 0 | 0 | 0 | 0 | 0 | 0.006192 | 0.25804 | 1,306 | 31 | 154 | 42.129032 | 0.820433 | 0 | 0 | 0 | 1 | 0.074074 | 0.38974 | 0.095712 | 0 | 0 | 0 | 0 | 0 | 1 | 0.074074 | false | 0.259259 | 0.074074 | 0 | 0.185185 | 0.148148 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
d966b40f7c79c645d11eeebe5e9cfc77f499c2fc | 446 | py | Python | scripts/gen_classic_policies.py | Zhaoxing-Li/zhaoxing.github.io | 5ff97e241a6bfa7ff0beb8b853f9d38a4d9afa34 | [
"CC-BY-3.0",
"MIT"
] | 662 | 2016-06-16T18:11:38.000Z | 2022-03-29T08:31:06.000Z | scripts/gen_classic_policies.py | etarakci-hvl/imitation | 8a2ed905e2ac54bda0f71e5ee364e90568e6d031 | [
"MIT"
] | 10 | 2016-06-29T06:53:11.000Z | 2020-05-01T03:53:42.000Z | scripts/gen_classic_policies.py | etarakci-hvl/imitation | 8a2ed905e2ac54bda0f71e5ee364e90568e6d031 | [
"MIT"
] | 187 | 2016-06-16T18:50:14.000Z | 2022-02-25T11:50:47.000Z | import os, os.path
outdir = 'classic_policies'
cmd_template = 'python scripts/run_rl_mj.py --env_name {env} --tiny_policy --min_total_sa 5000 --sim_batch_size 1 --max_iter 101 --log {out}'
try: os.mkdir(outdir)
except OSError: pass
for env in ['CartPole-v0', 'Acrobot-v0', 'MountainCar-v0', 'InvertedPendulum-v1']:
cmd = cmd_template.format(env=env, out=os.path.join(outdir, env+'.h5'))
print cmd
os.system(cmd)
print '\n\n\n'
| 31.857143 | 141 | 0.697309 | 73 | 446 | 4.09589 | 0.684932 | 0.040134 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033854 | 0.139013 | 446 | 13 | 142 | 34.307692 | 0.744792 | 0 | 0 | 0 | 0 | 0.1 | 0.455157 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.1 | 0.1 | null | null | 0.2 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
d96715b031d87c856b1e8f96b01ec98b0b3fa2cc | 1,300 | py | Python | Tencent/kg_LQ_smoking/excel.py | orange-eng/internship | c8c566df453d3a4bdf692338f74916ae15792fa1 | [
"Apache-2.0"
] | 2 | 2021-11-14T14:09:47.000Z | 2022-02-08T22:04:50.000Z | Tencent/kg_LQ_smoking/excel.py | orange-eng/internship | c8c566df453d3a4bdf692338f74916ae15792fa1 | [
"Apache-2.0"
] | null | null | null | Tencent/kg_LQ_smoking/excel.py | orange-eng/internship | c8c566df453d3a4bdf692338f74916ae15792fa1 | [
"Apache-2.0"
] | null | null | null |
import openpyxl
#data = openpyxl.load_workbook('./inference/output/smoke_true_img123.xlsx')
# print(data.get_named_ranges()) # 输出工作页索引范围
# print(data.get_sheet_names()) # 输出所有工作页的名称
# # 取第一张表
# sheetnames = data.get_sheet_names()
# table = data.get_sheet_by_name(sheetnames[0])
# table = data.active
# print(table.title) # 输出表名
# #nrows = table.max_row # 获得行数
# nrows = 0
# ncolumns = table.max_column # 获得行数
# print(nrows,ncolumns)
# values = ['E','X','C','E','L']
# for value in values:
# table.cell(nrows+1,6).value = value
# nrows = nrows + 1
# data.save('./inference/output/smoke_true_img.xlsx')
import xlsxwriter
# Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('Expenses02.xlsx')
worksheet = workbook.add_worksheet()
# # Some data we want to write to the worksheet.
# expenses = (
# ['Rent', 1000],
# ['Gas', 100],
# ['Food', 300],
# ['Gym', 50],
# )
# # Start from the first cell. Rows and columns are zero indexed.
# row = 0
# col = 0
# # Iterate over the data and write it out row by row.
# for item, cost in (expenses):
# worksheet.write(row, col, item)
# worksheet.write(row, col + 1, cost)
# row += 1
# # Write a total using a formula.
# worksheet.write(row, 0, 'Total')
# worksheet.write(row, 1, '=SUM(B1:B4)')
workbook.close()
| 28.888889 | 75 | 0.666154 | 188 | 1,300 | 4.515957 | 0.484043 | 0.03298 | 0.080094 | 0.056537 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.027829 | 0.170769 | 1,300 | 44 | 76 | 29.545455 | 0.75974 | 0.827692 | 0 | 0 | 0 | 0 | 0.085227 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
d96f5bdb9c19c171541408b83fa3b3f4b1bd3232 | 424 | py | Python | tests/test_models.py | marcovolpato00/sen-api | 01318930576f44fe7e76b6f5d0d7eb76c096a75f | [
"MIT"
] | 1 | 2020-12-02T13:46:00.000Z | 2020-12-02T13:46:00.000Z | tests/test_models.py | marcovolpato00/sen-api | 01318930576f44fe7e76b6f5d0d7eb76c096a75f | [
"MIT"
] | 2 | 2020-10-26T15:37:47.000Z | 2020-11-09T16:13:49.000Z | tests/test_models.py | marcovolpato00/sen-api | 01318930576f44fe7e76b6f5d0d7eb76c096a75f | [
"MIT"
] | null | null | null | from sen_api import IntervalReading
def test_interval_reading():
reading = IntervalReading('01/10/2020', '04/10/2020', 55)
assert reading.interval_days == 4
assert reading.avg_consumption == 14
reading = IntervalReading('01/03/2020', '31/03/2020', 341)
assert reading.interval_days == 31
assert reading.avg_consumption == 11
assert IntervalReading('01/03/2020', '31/03/2020', 341) == reading
| 30.285714 | 70 | 0.705189 | 57 | 424 | 5.122807 | 0.421053 | 0.178082 | 0.164384 | 0.171233 | 0.232877 | 0.232877 | 0.232877 | 0.232877 | 0 | 0 | 0 | 0.177966 | 0.165094 | 424 | 13 | 71 | 32.615385 | 0.646893 | 0 | 0 | 0 | 0 | 0 | 0.141509 | 0 | 0 | 0 | 0 | 0 | 0.555556 | 1 | 0.111111 | false | 0 | 0.111111 | 0 | 0.222222 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
d975b77aa87e436650fc83d7710520001df882fb | 1,044 | py | Python | snorkel/learning/tensorflow/rnn/text_rnn.py | Conengmo/snorkel | 36868e8a84de19b94e1c4b8eceaa64969a61a46b | [
"Apache-2.0"
] | 30 | 2019-08-22T19:27:59.000Z | 2022-03-13T22:03:15.000Z | snorkel/learning/tensorflow/rnn/text_rnn.py | Conengmo/snorkel | 36868e8a84de19b94e1c4b8eceaa64969a61a46b | [
"Apache-2.0"
] | 2 | 2019-08-22T16:51:58.000Z | 2022-03-21T02:59:18.000Z | snorkel/learning/tensorflow/rnn/text_rnn.py | Conengmo/snorkel | 36868e8a84de19b94e1c4b8eceaa64969a61a46b | [
"Apache-2.0"
] | 31 | 2019-08-22T19:28:08.000Z | 2022-03-23T12:50:49.000Z | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from builtins import *
import numpy as np
from .rnn_base import RNNBase
from .utils import SymbolTable
class TextRNN(RNNBase):
"""TextRNN for strings of text."""
def _preprocess_data(self, candidates, extend=False):
"""Convert candidate sentences to lookup sequences
:param candidates: candidates to process
:param extend: extend symbol table for tokens (train), or lookup (test)?
"""
if not hasattr(self, 'word_dict'):
self.word_dict = SymbolTable()
data, ends = [], []
for candidate in candidates:
toks = candidate.get_contexts()[0].text.split()
# Either extend word table or retrieve from it
f = self.word_dict.get if extend else self.word_dict.lookup
data.append(np.array(list(map(f, toks))))
ends.append(len(toks))
return data, ends
| 33.677419 | 80 | 0.664751 | 130 | 1,044 | 5.130769 | 0.523077 | 0.05997 | 0.095952 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.001282 | 0.252874 | 1,044 | 30 | 81 | 34.8 | 0.853846 | 0.227011 | 0 | 0 | 0 | 0 | 0.011796 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.052632 | false | 0 | 0.421053 | 0 | 0.578947 | 0.052632 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
d978f138e9c5056ecff47fae973d74caf777da83 | 640 | py | Python | oops_fhir/r4/value_set/v3_relational_operator.py | Mikuana/oops_fhir | 77963315d123756b7d21ae881f433778096a1d25 | [
"MIT"
] | null | null | null | oops_fhir/r4/value_set/v3_relational_operator.py | Mikuana/oops_fhir | 77963315d123756b7d21ae881f433778096a1d25 | [
"MIT"
] | null | null | null | oops_fhir/r4/value_set/v3_relational_operator.py | Mikuana/oops_fhir | 77963315d123756b7d21ae881f433778096a1d25 | [
"MIT"
] | null | null | null | from pathlib import Path
from fhir.resources.valueset import ValueSet as _ValueSet
from oops_fhir.utils import ValueSet
from oops_fhir.r4.code_system.v3_relational_operator import (
v3RelationalOperator as v3RelationalOperator_,
)
__all__ = ["v3RelationalOperator"]
_resource = _ValueSet.parse_file(Path(__file__).with_suffix(".json"))
class v3RelationalOperator(v3RelationalOperator_):
"""
v3 Code System RelationalOperator
**** MISSING DEFINITIONS ****
Status: active - Version: 2018-08-12
http://terminology.hl7.org/ValueSet/v3-RelationalOperator
"""
class Meta:
resource = _resource
| 20.645161 | 69 | 0.746875 | 68 | 640 | 6.720588 | 0.573529 | 0.061269 | 0.070022 | 0.087527 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033582 | 0.1625 | 640 | 30 | 70 | 21.333333 | 0.81903 | 0.251563 | 0 | 0 | 0 | 0 | 0.055432 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.363636 | 0 | 0.545455 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
d986b9637b1763f1fd0e373848f30e8608e95845 | 1,238 | py | Python | benchexec/tools/spf.py | franck44/benchexec | f929a277aa9f38e3b6bbf2561e3951532ce0d84e | [
"Apache-2.0"
] | null | null | null | benchexec/tools/spf.py | franck44/benchexec | f929a277aa9f38e3b6bbf2561e3951532ce0d84e | [
"Apache-2.0"
] | null | null | null | benchexec/tools/spf.py | franck44/benchexec | f929a277aa9f38e3b6bbf2561e3951532ce0d84e | [
"Apache-2.0"
] | null | null | null | """
BenchExec is a framework for reliable benchmarking.
This file is part of BenchExec.
Copyright (C) 2007-2018 Dirk Beyer
All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import logging
import benchexec.util as util
import benchexec.tools.jpf
class Tool(benchexec.tools.jpf.Tool):
"""
Tool info for JPF with symbolic extension (SPF)
(https://github.com/symbolicpathfinder).
"""
REQUIRED_PATHS = [
"jpf-core/bin/jpf",
"jpf-core/build",
"jpf-symbc/lib",
"jpf-symbc/build",
"jpf-sv-comp"
]
def executable(self):
return util.find_executable('jpf-sv-comp')
def name(self):
return 'SPF'
| 30.95 | 72 | 0.672859 | 170 | 1,238 | 4.888235 | 0.6 | 0.072202 | 0.031288 | 0.038508 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012807 | 0.243134 | 1,238 | 39 | 73 | 31.74359 | 0.874066 | 0.606624 | 0 | 0 | 0 | 0 | 0.180435 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.133333 | false | 0 | 0.2 | 0.133333 | 0.6 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
d9872948b16d53c6cc496b00d3cab058312f9cbe | 497 | py | Python | bot/requestors/requestor.py | adamtache/duke-campus-bot | 1a61cfd8a898af589a12d5948686c8a07a7976f3 | [
"Apache-2.0"
] | 2 | 2017-11-08T14:01:23.000Z | 2019-10-09T16:05:14.000Z | bot/requestors/requestor.py | adamtache/duke-campus-bot | 1a61cfd8a898af589a12d5948686c8a07a7976f3 | [
"Apache-2.0"
] | null | null | null | bot/requestors/requestor.py | adamtache/duke-campus-bot | 1a61cfd8a898af589a12d5948686c8a07a7976f3 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
import json
import urllib
from util.requests import http_requestor
class Requestor(object):
def __init__(self, request_url):
self.request_url = request_url
def post(self, params, headers, payload):
url = self._get_url(params)
return http_requestor.post(url, headers, payload)
def get(self, params, headers=None):
url = self._get_url(params)
return http_requestor.get(url)
def _get_url(self, params):
return self.request_url + urllib.urlencode(params)
| 22.590909 | 52 | 0.744467 | 72 | 497 | 4.902778 | 0.361111 | 0.113314 | 0.11898 | 0.073654 | 0.215297 | 0.215297 | 0.215297 | 0.215297 | 0 | 0 | 0 | 0.002347 | 0.142857 | 497 | 21 | 53 | 23.666667 | 0.826291 | 0.042254 | 0 | 0.142857 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.214286 | 0.071429 | 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 | 0 | 1 | 0 | 0 | 2 |
d996e3c54b7560f8ec55345b649a9b66a8b7532d | 1,510 | py | Python | DB_connect/DM.py | AndyZ-Salz/Database_Conn | fdb22bcc3d0df1adf9edc0368975c6fcba1a12af | [
"MIT"
] | null | null | null | DB_connect/DM.py | AndyZ-Salz/Database_Conn | fdb22bcc3d0df1adf9edc0368975c6fcba1a12af | [
"MIT"
] | null | null | null | DB_connect/DM.py | AndyZ-Salz/Database_Conn | fdb22bcc3d0df1adf9edc0368975c6fcba1a12af | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
---------------------------------------
@file : DM
@Version : ??
@Author : Andy Zang
@software: PyCharm
@For : Data Management
---------------------------------------
"""
# History:
# 2021/8/31: Create
import psycopg2
from psycopg2 import sql
def select_sql(what, table: str, where=None):
if what == '*': # select *
if where is None: # No Where
SQL_query = sql.SQL("SELECT * FROM {tbl}").format(
tbl=sql.Identifier(table)
)
else: # Where
# TODO consider to support multi-paras
raw_SQL = "SELECT * FROM {tbl} WHERE "
raw_SQL += where
SQL_query = sql.SQL(raw_SQL).format(
tbl=sql.Identifier(table)
)
else: # select not *
if where is None: # No Where
SQL_query = sql.SQL("SELECT {col} FROM {tbl}").format(
col=sql.Identifier(what),
tbl=sql.Identifier(table)
)
else: # Where
# TODO consider to support multi-paras
raw_SQL = "SELECT {col} FROM {tbl} WHERE "
raw_SQL += where
SQL_query = sql.SQL(raw_SQL).format(
col=sql.Identifier(what),
tbl=sql.Identifier(table)
)
return SQL_query
def insert_sql():
pass
def update_sql():
pass
def delete_sql():
pass
if __name__ == '__main__':
print(select_sql('*', 'ec_type_d', "type_g = '电容'"))
| 22.205882 | 66 | 0.494702 | 168 | 1,510 | 4.285714 | 0.35119 | 0.108333 | 0.072222 | 0.088889 | 0.604167 | 0.586111 | 0.543056 | 0.543056 | 0.543056 | 0.45 | 0 | 0.01 | 0.337748 | 1,510 | 67 | 67 | 22.537313 | 0.71 | 0.231788 | 0 | 0.5 | 0 | 0 | 0.113835 | 0 | 0 | 0 | 0 | 0.014925 | 0 | 1 | 0.111111 | false | 0.083333 | 0.055556 | 0 | 0.194444 | 0.027778 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
79422c2ea05a3e109616ee3fb82e1ee907b49d7e | 5,542 | py | Python | web.py | legoktm/mass-rename | 3f9b923c53b7ff66ffbd2a2052528f6f3a623386 | [
"MIT"
] | 1 | 2021-07-28T11:41:06.000Z | 2021-07-28T11:41:06.000Z | web.py | legoktm/mass-rename | 3f9b923c53b7ff66ffbd2a2052528f6f3a623386 | [
"MIT"
] | null | null | null | web.py | legoktm/mass-rename | 3f9b923c53b7ff66ffbd2a2052528f6f3a623386 | [
"MIT"
] | null | null | null | #!/data/project/legobot/python/bin/python
"""
Copyright (C) 2013 Legoktm
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""
print "Content-type: text/html\n\n"
import cgitb
cgitb.enable()
import cgi
import os
import requests
import subprocess
import hashlib
environ = {'INSTANCEPROJECT': 'tools',
'LOGNAME': 'local-legobot',
'USER': 'local-legobot',
'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin',
'HOME': '/data/project/legobot/',
'LANG': 'en_US.UTF-8',
'TERM': 'xterm-256color',
'SHELL': '/bin/bash',
'SHLVL': '1',
'PYWIKIBOT2_DIR': '/data/project/legobot/.pywikibot/',
'SUDO_USER': 'legoktm',
'USERNAME': 'local-legobot',
'SUDO_UID': '2552',
'INSTANCENAME': 'tools-login',
'_': '/usr/bin/python',
'SUDO_COMMAND': '/bin/bash',
'SUDO_GID': '500',
'OLDPWD': '/data/project/legobot/cgi-bin',
'NODE_PATH': '/usr/lib/nodejs:/usr/share/javascript',
'PWD': '/data/project/legobot/cgi-bin/massrename',
'MAIL': '/var/mail/local-legobot',
}
def TUSC(username, password, lang, project):
headers = {'User-agent': 'Commons mass-rename tool by User:Legoktm'}
# http://tools.wikimedia.de/~magnus/tusc.php?check=1&botmode=1&user=USERNAME&language=LANGUAGE&project=PROJECT&password=TUSC_PASSWORD
params = {'check': 1,
'botmode': 1,
'user': username,
'language': lang,
'project': project,
'password': password,
}
url = 'http://tools-webproxy/tusc/tusc.php'
r = requests.post(url, params, headers=headers)
try:
if int(r.text) == 1:
return True
except Exception:
pass
return False
def authusers(username):
with open(os.path.expanduser('~/.whitelist')) as f:
t = f.read()
for line in t:
if line == username:
return True
return False
def wrap(thing):
return '<html><head><title>The Super Rename Tool!</title></head><body>{0}</body></html>'.format(thing)
def start():
form = """<form action="/legobot/cgi-bin/massrename/web.py" method="post">
<input type="text" name="cat" placeholder="Category:Blah"><br />
<input type="text" name="find" placeholder="Thing to find"><br />
<input type="text" name="replace" placeholder="Thing to replace it with"><br />
<input type="text" name="reason" placeholder="Move reason"><br />
<input type="text" name="username" placeholder="TUSC: username"><br />
<input type="password" name="password" placeholder="TUSC: password"><br />
<input type="text" name="lang" placeholder="TUSC: language"><br />
<input type="text" name="project" placeholder="TUSC: project"><br />
<button type="submit">Go!</button>
</form>
"""
return wrap(form)
def tuscfailure():
return wrap('Could not authenticate with TUSC.')
def notanadmin():
return wrap('Unfortunately this tool can only be used by Commons administrators.')
def jobnotsent():
return wrap('There was an error sending your job. Please contact Legoktm with details of what you were trying '
'to do.')
def succeeded(val):
return wrap('Your job has been sent. Legobot will process it shortly. If there are any issues, please let Legoktm '
'know, and provide the ID for your job, which is: ' + val + '.')
form = cgi.FieldStorage()
if not 'cat' in form:
print start()
quit()
cat = form['cat'].value
username = form['username'].value
password = form['password'].value
lang = form['lang'].value
project = form['project'].value
find = form['find'].value
replace = form['replace'].value
reason = form['reason'].value
summary = reason + ". On behalf of " + username
t = TUSC(username, password, lang, project)
if not t:
print tuscfailure()
quit()
if not authusers(username):
print notanadmin()
quit()
h = hashlib.md5()
h.update(username)
h.update(cat)
h.update(find)
h.update(replace)
val = h.hexdigest()
#we all good?
#try:
x = subprocess.check_output('qsub -N {0} -l h_vmem=256M -j y -o $HOME/renamelogs/{0} /data/project/legobot/cgi-bin/massrename/rename.py "{1}" "{2}" "{3}" "{4}"'.format(
val, cat, find, replace, summary), stderr=subprocess.STDOUT, shell=True, env=environ)
#except subprocess.CalledProcessError:
# print jobnotsent()
# quit()
print succeeded(val) | 35.075949 | 168 | 0.64742 | 729 | 5,542 | 4.906722 | 0.40192 | 0.024602 | 0.02544 | 0.033268 | 0.093933 | 0.038021 | 0.01901 | 0 | 0 | 0 | 0 | 0.008249 | 0.212559 | 5,542 | 158 | 169 | 35.075949 | 0.811412 | 0.046373 | 0 | 0.06422 | 0 | 0.036697 | 0.491353 | 0.112296 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.055046 | 0.055046 | null | null | 0.045872 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
794bdd5493e56574a7c73df526cf88841cd102bb | 300 | py | Python | RecoLuminosity/LumiProducer/python/lumiProducer_cfi.py | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 852 | 2015-01-11T21:03:51.000Z | 2022-03-25T21:14:00.000Z | RecoLuminosity/LumiProducer/python/lumiProducer_cfi.py | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 30,371 | 2015-01-02T00:14:40.000Z | 2022-03-31T23:26:05.000Z | RecoLuminosity/LumiProducer/python/lumiProducer_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
lumiProducer=cms.EDProducer("LumiProducer",
connect=cms.string(''),
lumiversion=cms.untracked.string(''),
ncacheEntries=cms.untracked.uint32(5)
)
| 37.5 | 65 | 0.496667 | 22 | 300 | 6.772727 | 0.681818 | 0.161074 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.016854 | 0.406667 | 300 | 7 | 66 | 42.857143 | 0.820225 | 0 | 0 | 0 | 0 | 0 | 0.040134 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.166667 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
796637263993cf874162c2c439b23930bf4e6e78 | 1,177 | py | Python | setup.py | ahawker/decorstate | 50d666b0e5a258a74c2d58442bb51ca034a7e809 | [
"Apache-2.0"
] | 9 | 2017-06-09T18:16:53.000Z | 2021-10-10T06:36:02.000Z | setup.py | ahawker/decorstate | 50d666b0e5a258a74c2d58442bb51ca034a7e809 | [
"Apache-2.0"
] | 1 | 2017-06-13T19:08:35.000Z | 2017-06-13T19:08:35.000Z | setup.py | ahawker/decorstate | 50d666b0e5a258a74c2d58442bb51ca034a7e809 | [
"Apache-2.0"
] | null | null | null | """
decorstate
~~~~~~~~~~
Simple "state machines" with Python decorators.
:copyright: (c) 2015-2017 Andrew Hawker
:license: Apache 2.0, see LICENSE for more details.
"""
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(
name='decorstate',
version='0.0.3',
description='Simple "state machines" with Python decorators',
long_description=open('README.md').read(),
author='Andrew Hawker',
author_email='andrew.r.hawker@gmail.com',
url='https://github.com/ahawker/decorstate',
license='Apache 2.0',
py_modules=['decorstate'],
classifiers=(
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Natural Language :: English',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
)
)
| 29.425 | 65 | 0.617672 | 125 | 1,177 | 5.792 | 0.536 | 0.183702 | 0.241713 | 0.143646 | 0.18232 | 0.107735 | 0 | 0 | 0 | 0 | 0 | 0.028986 | 0.237893 | 1,177 | 39 | 66 | 30.179487 | 0.778149 | 0.138488 | 0 | 0 | 0 | 0 | 0.558824 | 0.025355 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.107143 | 0 | 0.107143 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
7966d96e0d8c0f4d48dd2e8327060f16d6646552 | 1,155 | py | Python | libs/colorprint.py | thiagodasilva/runway | a5455e885302df534fcfff0470881fbd2ad8eed5 | [
"Apache-2.0"
] | null | null | null | libs/colorprint.py | thiagodasilva/runway | a5455e885302df534fcfff0470881fbd2ad8eed5 | [
"Apache-2.0"
] | null | null | null | libs/colorprint.py | thiagodasilva/runway | a5455e885302df534fcfff0470881fbd2ad8eed5 | [
"Apache-2.0"
] | null | null | null | import datetime
import platform
if platform.system() == 'Windows':
from colorama import init
init()
class bcolors:
PINK = '\033[95m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def colorize(text, color):
return "{}{}{}".format(color, text, bcolors.ENDC)
def debug(text, logfile_path=None):
print(colorize(text, bcolors.BLUE))
log(text, logfile_path)
def error(text, logfile_path=None):
print(colorize(text, bcolors.RED))
log(text, logfile_path)
def info(text, logfile_path=None):
print(colorize(text, bcolors.BOLD))
log(text, logfile_path)
def success(text, logfile_path=None):
print(colorize(text, bcolors.GREEN))
log(text, logfile_path)
def warning(text, logfile_path=None):
print(colorize(text, bcolors.YELLOW))
log(text, logfile_path)
def log(text, logfile_path):
if logfile_path is not None:
with open(logfile_path, "a") as logfile:
logfile.write("[{}] {}\n".format(
datetime.datetime.now().strftime("%F %H:%M:%S"), text))
| 21.388889 | 71 | 0.635498 | 155 | 1,155 | 4.651613 | 0.374194 | 0.198336 | 0.228849 | 0.149792 | 0.443828 | 0.298197 | 0.298197 | 0.298197 | 0 | 0 | 0 | 0.040437 | 0.207792 | 1,155 | 53 | 72 | 21.792453 | 0.747541 | 0 | 0 | 0.138889 | 0 | 0 | 0.082251 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.194444 | false | 0 | 0.083333 | 0.027778 | 0.555556 | 0.138889 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
7969cf7c6b543f120d4758df108ef9c0b25fc36f | 4,802 | py | Python | backend/pah_fm/settings.py | w1stler/pah-fm | e69600ba602715ae0b61dfa0bead934a0ed7f36f | [
"MIT"
] | 8 | 2019-08-09T11:06:16.000Z | 2021-10-05T14:56:31.000Z | backend/pah_fm/settings.py | w1stler/pah-fm | e69600ba602715ae0b61dfa0bead934a0ed7f36f | [
"MIT"
] | 382 | 2018-10-17T19:05:30.000Z | 2022-02-10T07:09:45.000Z | backend/pah_fm/settings.py | w1stler/pah-fm | e69600ba602715ae0b61dfa0bead934a0ed7f36f | [
"MIT"
] | 45 | 2018-10-17T17:04:04.000Z | 2021-10-05T14:30:35.000Z | import os
import datetime
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Base URL without trailing slash
BASE_URL = os.environ.get("BASE_URL")
SECRET_KEY = os.environ.get("SECRET_KEY")
DEBUG = os.environ.get("DEBUG", "0") == "1"
ALLOWED_HOSTS = [
"localhost",
"127.0.0.1",
"52.232.62.212",
".pahfm.codeforpoznan.pl",
".execute-api.eu-west-1.amazonaws.com",
]
USE_X_FORWARDED_HOST = True
CSRF_COOKIE_SECURE = True
CSRF_COOKIE_DOMAIN = BASE_URL
# Application definition
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"import_export",
# 3rd party apps
"corsheaders",
"djmoney",
"rest_framework",
# local apps
"fleet_management",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"fleet_management.middleware.UpdateLastSeenMiddleware",
]
CORS_ORIGIN_WHITELIST = ("localhost:8080", "127.0.0.1:8080")
ROOT_URLCONF = "pah_fm.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "templates")],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
WSGI_APPLICATION = "pah_fm.wsgi.application"
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"USER": os.environ.get("PAH_FM_DB_USER", "pah-fm"),
"NAME": os.environ.get("PAH_FM_DB_NAME", "pah-fm"),
"PASSWORD": os.environ.get("PAH_FM_DB_PASS", "pah-fm"),
"HOST": os.environ.get("PAH_FM_DB_HOST", "localhost"),
"PORT": os.environ.get("PAH_FM_DB_PORT", "5432"),
}
}
# DRF settings
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework_jwt.authentication.JSONWebTokenAuthentication",
"rest_framework.authentication.SessionAuthentication",
"rest_framework.authentication.BasicAuthentication",
),
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
"DEFAULT_RENDERER_CLASSES": (
"djangorestframework_camel_case.render.CamelCaseJSONRenderer",
),
"DEFAULT_PARSER_CLASSES": (
"djangorestframework_camel_case.parser.CamelCaseJSONParser",
),
"DEFAULT_FILTER_BACKENDS": ("django_filters.rest_framework.DjangoFilterBackend",),
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation"
".UserAttributeSimilarityValidator",
},
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
]
# Custom user model
AUTH_USER_MODEL = "fleet_management.User"
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATICFILES_DIRS = [os.path.join(BASE_DIR, "pah_fm/static")]
# Email settings
EMAIL_HOST = "localhost"
EMAIL_PORT = 25
EMAIL_USE_TLS = False
EMAIL_ADDRESS = "hello@cfp.com"
if DEBUG:
EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
EMAIL_FILE_PATH = os.path.join(BASE_DIR, "emails")
# verify if it's required for registering user
AUTHENTICATION_BACKENDS = ("django.contrib.auth.backends.AllowAllUsersModelBackend",)
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = "/media/"
JWT_AUTH = {
"JWT_EXPIRATION_DELTA": datetime.timedelta(days=30),
}
RSA_PUBLIC_EXP = 257
RSA_BIT_LENGTH = 19
| 27.757225 | 86 | 0.70429 | 539 | 4,802 | 6.061224 | 0.387755 | 0.063667 | 0.029385 | 0.025712 | 0.164677 | 0.144475 | 0.033364 | 0.024487 | 0.024487 | 0 | 0 | 0.01532 | 0.157226 | 4,802 | 172 | 87 | 27.918605 | 0.791945 | 0.11995 | 0 | 0.025862 | 0 | 0 | 0.533524 | 0.415359 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.051724 | 0.025862 | 0 | 0.025862 | 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 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
798085ae1e1e177aef74528c45d9fad6986df195 | 994 | py | Python | src/socialite/drivers/__init__.py | corentinalcoy/masonite-socialite | 32184820705b1aedc3ac7a5c61c507fc3314441a | [
"MIT"
] | null | null | null | src/socialite/drivers/__init__.py | corentinalcoy/masonite-socialite | 32184820705b1aedc3ac7a5c61c507fc3314441a | [
"MIT"
] | null | null | null | src/socialite/drivers/__init__.py | corentinalcoy/masonite-socialite | 32184820705b1aedc3ac7a5c61c507fc3314441a | [
"MIT"
] | null | null | null | from masonite.request import Request
from .SocialiteBaseDriver import SocialiteBaseDriver
AVAILABLE_PROVIDERS = [
'github', 'facebook',
'twitter', 'google',
'linkedin',
]
class SocialiteFacebookDriver(SocialiteBaseDriver):
def __init__(self, request: Request):
self.name = 'facebook'
super().__init__(request)
class SocialiteTwitterDriver(SocialiteBaseDriver):
def __init__(self, request: Request):
self.name = 'twitter'
super().__init__(request)
class SocialiteGoogleDriver(SocialiteBaseDriver):
def __init__(self, request: Request):
self.name = 'google-oauth2'
super().__init__(request)
class SocialiteLinkedinDriver(SocialiteBaseDriver):
def __init__(self, request: Request):
self.name = 'linkedin-oauth2'
super().__init__(request)
class SocialiteGithubDriver(SocialiteBaseDriver):
def __init__(self, request: Request):
self.name = 'github'
super().__init__(request)
| 24.85 | 52 | 0.700201 | 88 | 994 | 7.443182 | 0.272727 | 0.167939 | 0.198473 | 0.229008 | 0.479389 | 0.396947 | 0.396947 | 0.396947 | 0 | 0 | 0 | 0.002491 | 0.192153 | 994 | 39 | 53 | 25.487179 | 0.813201 | 0 | 0 | 0.37037 | 0 | 0 | 0.084507 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.185185 | false | 0 | 0.074074 | 0 | 0.444444 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
798ed74b42a1653e63364aede571d8a59dcb2ee0 | 1,588 | py | Python | packages/py/lodash/math.py | hieudoanm/lodash | 81e97419bd6e9fa4e5330eca30c0eb1d9fbfc1a2 | [
"MIT"
] | null | null | null | packages/py/lodash/math.py | hieudoanm/lodash | 81e97419bd6e9fa4e5330eca30c0eb1d9fbfc1a2 | [
"MIT"
] | null | null | null | packages/py/lodash/math.py | hieudoanm/lodash | 81e97419bd6e9fa4e5330eca30c0eb1d9fbfc1a2 | [
"MIT"
] | null | null | null | import math
def add(a, b):
return a + b
def ceil(number):
return math.ceil(number)
def divide(a, b):
return a / b
def floor(number):
return math.floor(number)
def max(numbers):
if len(numbers) == 0:
return
max = float('-inf')
for number in numbers:
if number > max:
max = number
return max
def maxBy(objects, iteratee):
if len(objects) == 0:
return
numbers = []
for obj in objects:
number = obj[iteratee]
numbers.append(number)
return max(numbers)
def mean(numbers):
length = len(numbers)
if length == 0:
return 0
_sum = sum(numbers)
return _sum / length
def meanBy(objects, iteratee):
if len(objects) == 0:
return
numbers = []
for obj in objects:
number = obj[iteratee]
numbers.append(number)
return mean(numbers)
def min(numbers):
if len(numbers) == 0:
return
min = float('inf')
for number in numbers:
if number < min:
min = number
return min
def minBy(objects, iteratee):
if len(objects) == 0:
return
numbers = []
for obj in objects:
number = obj[iteratee]
numbers.append(number)
return min(numbers)
def multiply(a, b):
return a * b
def roundNumber(number, precision = 0):
return round(number, precision)
def subtract(a, b):
return a - b
# Recursion
def sum(numbers):
if len(numbers) == 0:
return 0
first = numbers.pop(0);
return first + sum(numbers);
def sumBy(objects, iteratee):
if len(objects) == 0:
return
numbers = []
for obj in objects:
number = obj[iteratee]
numbers.append(number)
return sum(numbers)
| 17.450549 | 39 | 0.63728 | 224 | 1,588 | 4.508929 | 0.178571 | 0.069307 | 0.031683 | 0.035644 | 0.581188 | 0.571287 | 0.455446 | 0.455446 | 0.388119 | 0.388119 | 0 | 0.009983 | 0.243073 | 1,588 | 90 | 40 | 17.644444 | 0.830283 | 0.005668 | 0 | 0.445946 | 0 | 0 | 0.004439 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.202703 | false | 0 | 0.013514 | 0.094595 | 0.527027 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
79945eb84bd32be4238d4737485b2212b450bf55 | 463 | py | Python | src/talk.py | srobo-legacy/comp-poltergeist | 15a3605257246455152ea1d4d0281329269c06f2 | [
"MIT"
] | null | null | null | src/talk.py | srobo-legacy/comp-poltergeist | 15a3605257246455152ea1d4d0281329269c06f2 | [
"MIT"
] | null | null | null | src/talk.py | srobo-legacy/comp-poltergeist | 15a3605257246455152ea1d4d0281329269c06f2 | [
"MIT"
] | null | null | null |
import yaml
import control
# Import the relevant command modules.
# These self-subscribe to the control hanlder, but need to get imported
import schedule_commands
import team_commands
import scores_commands
import match_commands
def command(cmd):
responses = []
control.handle(cmd, responses.append)
return "\n".join(responses)
def command_yaml(cmd):
cmd += ' --yaml'
raw_data = command(cmd)
data = yaml.load(raw_data)
return data
| 21.045455 | 71 | 0.734341 | 63 | 463 | 5.285714 | 0.507937 | 0.126126 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.183585 | 463 | 21 | 72 | 22.047619 | 0.880952 | 0.228942 | 0 | 0 | 0 | 0 | 0.025496 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.133333 | false | 0 | 0.4 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
79b9c9287f4c19bfb6c85370e3eee3ddff145cc0 | 318 | py | Python | libs/mysql.py | 536/database-converter | aeaea7742a4906e4f962e75833232594ed706b90 | [
"MIT"
] | null | null | null | libs/mysql.py | 536/database-converter | aeaea7742a4906e4f962e75833232594ed706b90 | [
"MIT"
] | null | null | null | libs/mysql.py | 536/database-converter | aeaea7742a4906e4f962e75833232594ed706b90 | [
"MIT"
] | null | null | null | # !/usr/bin/env python3
# coding: utf-8
import pymysql
import settings
conn = pymysql.connect(
host=settings.MYSQL_HOST,
port=int(settings.MYSQL_PORT),
user=settings.MYSQL_USERNAME,
password=settings.MYSQL_PASSWORD,
db=settings.MYSQL_DB,
charset=settings.MYSQL_CHARSET,
)
__all__ = ['conn']
| 18.705882 | 37 | 0.726415 | 41 | 318 | 5.390244 | 0.536585 | 0.352941 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.007463 | 0.157233 | 318 | 16 | 38 | 19.875 | 0.817164 | 0.110063 | 0 | 0 | 0 | 0 | 0.014286 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.090909 | 0.181818 | 0 | 0.181818 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
79bf2146e412a244b9f82cde24fbe7aeecffe929 | 2,988 | py | Python | insights/parsers/config_file_perms.py | lhuett/insights-core | 1c84eeffc037f85e2bbf60c9a302c83aa1a50cf8 | [
"Apache-2.0"
] | 121 | 2017-05-30T20:23:25.000Z | 2022-03-23T12:52:15.000Z | insights/parsers/config_file_perms.py | lhuett/insights-core | 1c84eeffc037f85e2bbf60c9a302c83aa1a50cf8 | [
"Apache-2.0"
] | 1,977 | 2017-05-26T14:36:03.000Z | 2022-03-31T10:38:53.000Z | insights/parsers/config_file_perms.py | lhuett/insights-core | 1c84eeffc037f85e2bbf60c9a302c83aa1a50cf8 | [
"Apache-2.0"
] | 244 | 2017-05-30T20:22:57.000Z | 2022-03-26T10:09:39.000Z | """
Configuration File Permissions parsers
======================================
Parsers included in this module are:
SshdConfigPerms - command ``/bin/ls -l /etc/ssh/sshd_config``
-------------------------------------------------------------
Grub1ConfigPerms - command ``/bin/ls -l /boot/grub/grub.conf``
--------------------------------------------------------------
Grub2ConfigPerms - command ``/bin/ls -l /boot/grub2/grub.cfg``
--------------------------------------------------------------
"""
from insights.core import CommandParser
from insights.core.plugins import parser
from insights.specs import Specs
from insights.util.file_permissions import FilePermissions
class FilePermissionsParser(CommandParser, FilePermissions):
"""
Base class for ``SshdConfigPerms``, ``Grub1ConfigPerms`` and ``Grub2ConfigPerms`` classes.
Attributes:
line (string): the line from the command output
"""
def __init__(self, context):
self.line = ""
CommandParser.__init__(self, context)
FilePermissions.__init__(self, self.line)
def parse_content(self, content):
non_empty_lines = [line for line in content if line] # get rid of blank lines
self.line = non_empty_lines[0]
@parser(Specs.sshd_config_perms)
class SshdConfigPerms(FilePermissionsParser):
"""
Class for parsing ``/bin/ls -l /etc/ssh/sshd_config`` command.
Sample output of this command is::
-rw-------. 1 root root 4179 Dec 1 2014 /etc/ssh/sshd_config
Examples:
>>> type(sshd_perms)
<class 'insights.parsers.config_file_perms.SshdConfigPerms'>
>>> sshd_perms.line
'-rw-------. 1 root root 4179 Dec 1 2014 /etc/ssh/sshd_config'
"""
def __init__(self, context):
super(SshdConfigPerms, self).__init__(context)
@parser(Specs.grub1_config_perms)
class Grub1ConfigPerms(FilePermissionsParser):
"""
Class for parsing ``/bin/ls -l /boot/grub/grub.conf`` command.
Sample output of this command is::
-rw-r--r--. 1 root root 4179 Dec 1 2014 /boot/grub/grub.conf
Examples:
>>> type(grub1_perms)
<class 'insights.parsers.config_file_perms.Grub1ConfigPerms'>
>>> grub1_perms.line
'-rw-r--r--. 1 root root 4179 Dec 1 2014 /boot/grub/grub.conf'
"""
def __init__(self, context):
super(Grub1ConfigPerms, self).__init__(context)
@parser(Specs.grub_config_perms)
class Grub2ConfigPerms(FilePermissionsParser):
"""
Class for parsing ``/bin/ls -l /boot/grub2/grub.cfg`` command.
Sample output of this command is::
-rw-r--r--. 1 root root 4179 Dec 1 2014 /boot/grub2/grub.cfg
Examples:
>>> type(grub2_perms)
<class 'insights.parsers.config_file_perms.Grub2ConfigPerms'>
>>> grub2_perms.line
'-rw-r--r--. 1 root root 4179 Dec 1 2014 /boot/grub2/grub.cfg'
"""
def __init__(self, context):
super(Grub2ConfigPerms, self).__init__(context)
| 30.804124 | 94 | 0.619478 | 346 | 2,988 | 5.16474 | 0.219653 | 0.016788 | 0.020146 | 0.043649 | 0.479575 | 0.404029 | 0.404029 | 0.254057 | 0.183548 | 0.183548 | 0 | 0.03314 | 0.192102 | 2,988 | 96 | 95 | 31.125 | 0.707125 | 0.589357 | 0 | 0.166667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.208333 | false | 0 | 0.166667 | 0 | 0.541667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
79ddcf4131e81cda66fa73e09fad88127246c119 | 1,495 | py | Python | config/conf.d/02-service-announcements.py | possiblyMikeB/davidson-jupyter | 8980c1249756d421b70950b9895b75e16d7e68c0 | [
"BSD-3-Clause"
] | null | null | null | config/conf.d/02-service-announcements.py | possiblyMikeB/davidson-jupyter | 8980c1249756d421b70950b9895b75e16d7e68c0 | [
"BSD-3-Clause"
] | null | null | null | config/conf.d/02-service-announcements.py | possiblyMikeB/davidson-jupyter | 8980c1249756d421b70950b9895b75e16d7e68c0 | [
"BSD-3-Clause"
] | null | null | null | ## IMPORTANT: Must be loaded after `02-service-common.py
## announcement service
service_env = dict()
service_url = f'{hub_hostname}:{service_port}'
if c.JupyterHub.internal_ssl:
# if we are using end-to-end mTLS, then pass
# certs to service and set scheme to `https`
# TODO: Generate certs automatically
PKI_STORE=c.JupyterHub.internal_certs_location
service_env = {
'JUPYTERHUB_SSL_CERTFILE':
f'{PKI_STORE}/hub-internal/hub-internal.crt',
'JUPYTERHUB_SSL_KEYFILE':
f'{PKI_STORE}/hub-internal/hub-internal.key',
'JUPYTERHUB_SSL_CLIENT_CA':
f'{PKI_STORE}/hub-ca_trust.crt',
}
service_url = f'https://{service_url}'
else:
# if not, set schema to `http`
service_url = f'http://{service_url}'
pass
# NOTE: you must generate certs for services
c.JupyterHub.services += [
{ # Hub-wide announcments service
'name': 'announcement',
'url': service_url,
'command': [
sys.executable, '-m', 'jupyterhub_announcement',
f'--AnnouncementService.fixed_message="Welcome to the {hub_id} JupyterHub server!"',
f'--AnnouncementService.port={service_port}',
f'--AnnouncementQueue.persist_path=announcements.json',
f'--AnnouncementService.template_paths=["{hub_path}/share/jupyterhub/templates","{hub_path}/templates"]'
],
'environment': service_env
}
]
# increment service port
service_port += 1
| 31.808511 | 116 | 0.652174 | 178 | 1,495 | 5.280899 | 0.460674 | 0.06383 | 0.035106 | 0.038298 | 0.065957 | 0.065957 | 0.065957 | 0 | 0 | 0 | 0 | 0.002577 | 0.221405 | 1,495 | 46 | 117 | 32.5 | 0.804983 | 0.216054 | 0 | 0 | 0 | 0 | 0.503448 | 0.403448 | 0 | 0 | 0 | 0.021739 | 0 | 1 | 0 | false | 0.032258 | 0 | 0 | 0 | 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 | 1 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
8db5f1088c029b82e2d44b85e4e2ef8219b0c718 | 713 | py | Python | project/randomupperletters.py | he-is-bryan/code_generator_to_boxes_of_medicines | d96cb59cea7f7f4b343526ba8a2598ac42d55986 | [
"MIT"
] | 1 | 2020-06-19T19:29:38.000Z | 2020-06-19T19:29:38.000Z | project/randomupperletters.py | aceBryan/code_generator_to_boxes_of_medicines | d96cb59cea7f7f4b343526ba8a2598ac42d55986 | [
"MIT"
] | 2 | 2021-09-08T02:05:48.000Z | 2022-03-12T00:32:47.000Z | project/randomupperletters.py | aceBryan/code_generator_to_boxes_of_medicines | d96cb59cea7f7f4b343526ba8a2598ac42d55986 | [
"MIT"
] | null | null | null | """
|================================================================================|
|This program returns random letters. |
|================================================================================|
"""
from random import choice
def upper_letter_generator():
upper_letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
capital = capital_letters(upper_letters)
return capital
def capital_letters(upper_letters):
upper = choice(upper_letters)
return upper
if __name__ == "__main__":
upper_letter_generator() | 35.65 | 86 | 0.380084 | 65 | 713 | 3.892308 | 0.661538 | 0.189723 | 0.158103 | 0.205534 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.238429 | 713 | 20 | 87 | 35.65 | 0.46593 | 0.347826 | 0 | 0 | 0 | 0 | 0.077449 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.181818 | false | 0 | 0.090909 | 0 | 0.454545 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
8dc5fb29114d77bce36c8930aeea5146d7af608a | 12,742 | py | Python | pybind/nos/v7_1_0/hardware/flexport/flexport_type/__init__.py | shivharis/pybind | 4e1c6d54b9fd722ccec25546ba2413d79ce337e6 | [
"Apache-2.0"
] | null | null | null | pybind/nos/v7_1_0/hardware/flexport/flexport_type/__init__.py | shivharis/pybind | 4e1c6d54b9fd722ccec25546ba2413d79ce337e6 | [
"Apache-2.0"
] | null | null | null | pybind/nos/v7_1_0/hardware/flexport/flexport_type/__init__.py | shivharis/pybind | 4e1c6d54b9fd722ccec25546ba2413d79ce337e6 | [
"Apache-2.0"
] | 1 | 2021-11-05T22:15:42.000Z | 2021-11-05T22:15:42.000Z |
from operator import attrgetter
import pyangbind.lib.xpathhelper as xpathhelper
from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType, RestrictedClassType, TypedListType
from pyangbind.lib.yangtypes import YANGBool, YANGListType, YANGDynClass, ReferenceType
from pyangbind.lib.base import PybindBase
from decimal import Decimal
from bitarray import bitarray
import __builtin__
class flexport_type(PybindBase):
"""
This class was auto-generated by the PythonClass plugin for PYANG
from YANG module brocade-hardware - based on the path /hardware/flexport/flexport_type. Each member element of
the container is represented as a class variable - with a specific
YANG type.
"""
__slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_rest_name', '_extmethods', '__type','__instance','__skip_deconfig',)
_yang_name = 'flexport_type'
_rest_name = ''
_pybind_generated_by = 'container'
def __init__(self, *args, **kwargs):
path_helper_ = kwargs.pop("path_helper", None)
if path_helper_ is False:
self._path_helper = False
elif path_helper_ is not None and isinstance(path_helper_, xpathhelper.YANGPathHelper):
self._path_helper = path_helper_
elif hasattr(self, "_parent"):
path_helper_ = getattr(self._parent, "_path_helper", False)
self._path_helper = path_helper_
else:
self._path_helper = False
extmethods = kwargs.pop("extmethods", None)
if extmethods is False:
self._extmethods = False
elif extmethods is not None and isinstance(extmethods, dict):
self._extmethods = extmethods
elif hasattr(self, "_parent"):
extmethods = getattr(self._parent, "_extmethods", None)
self._extmethods = extmethods
else:
self._extmethods = False
self.__instance = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['-2147483648..2147483647']}, int_size=32), is_leaf=True, yang_name="instance", rest_name="instance", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'The instance to which the port should be configured.', u'hidden': u'debug'}}, namespace='urn:brocade.com:mgmt:brocade-hardware', defining_module='brocade-hardware', yang_type='int32', is_config=True)
self.__type = YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'ethernet': {'value': 1}, u'fibre-channel': {'value': 0}},), is_leaf=True, yang_name="type", rest_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'The type to be configured.'}}, namespace='urn:brocade.com:mgmt:brocade-hardware', defining_module='brocade-hardware', yang_type='port-type', is_config=True)
self.__skip_deconfig = YANGDynClass(base=YANGBool, is_leaf=True, yang_name="skip_deconfig", rest_name="skip_deconfig", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Skip Plugin deconfig errors.', u'hidden': u'debug'}}, namespace='urn:brocade.com:mgmt:brocade-hardware', defining_module='brocade-hardware', yang_type='empty', is_config=True)
load = kwargs.pop("load", None)
if args:
if len(args) > 1:
raise TypeError("cannot create a YANG container with >1 argument")
all_attr = True
for e in self._pyangbind_elements:
if not hasattr(args[0], e):
all_attr = False
break
if not all_attr:
raise ValueError("Supplied object did not have the correct attributes")
for e in self._pyangbind_elements:
nobj = getattr(args[0], e)
if nobj._changed() is False:
continue
setmethod = getattr(self, "_set_%s" % e)
if load is None:
setmethod(getattr(args[0], e))
else:
setmethod(getattr(args[0], e), load=load)
def _path(self):
if hasattr(self, "_parent"):
return self._parent._path()+[self._yang_name]
else:
return [u'hardware', u'flexport', u'flexport_type']
def _rest_path(self):
if hasattr(self, "_parent"):
if self._rest_name:
return self._parent._rest_path()+[self._rest_name]
else:
return self._parent._rest_path()
else:
return [u'hardware', u'flexport']
def _get_type(self):
"""
Getter method for type, mapped from YANG variable /hardware/flexport/flexport_type/type (port-type)
YANG Description: The type to be configured.
"""
return self.__type
def _set_type(self, v, load=False):
"""
Setter method for type, mapped from YANG variable /hardware/flexport/flexport_type/type (port-type)
If this variable is read-only (config: false) in the
source YANG file, then _set_type is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_type() directly.
YANG Description: The type to be configured.
"""
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'ethernet': {'value': 1}, u'fibre-channel': {'value': 0}},), is_leaf=True, yang_name="type", rest_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'The type to be configured.'}}, namespace='urn:brocade.com:mgmt:brocade-hardware', defining_module='brocade-hardware', yang_type='port-type', is_config=True)
except (TypeError, ValueError):
raise ValueError({
'error-string': """type must be of a type compatible with port-type""",
'defined-type': "brocade-hardware:port-type",
'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'ethernet': {'value': 1}, u'fibre-channel': {'value': 0}},), is_leaf=True, yang_name="type", rest_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'The type to be configured.'}}, namespace='urn:brocade.com:mgmt:brocade-hardware', defining_module='brocade-hardware', yang_type='port-type', is_config=True)""",
})
self.__type = t
if hasattr(self, '_set'):
self._set()
def _unset_type(self):
self.__type = YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'ethernet': {'value': 1}, u'fibre-channel': {'value': 0}},), is_leaf=True, yang_name="type", rest_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'The type to be configured.'}}, namespace='urn:brocade.com:mgmt:brocade-hardware', defining_module='brocade-hardware', yang_type='port-type', is_config=True)
def _get_instance(self):
"""
Getter method for instance, mapped from YANG variable /hardware/flexport/flexport_type/instance (int32)
YANG Description: The instance to which the port should be configured.
"""
return self.__instance
def _set_instance(self, v, load=False):
"""
Setter method for instance, mapped from YANG variable /hardware/flexport/flexport_type/instance (int32)
If this variable is read-only (config: false) in the
source YANG file, then _set_instance is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_instance() directly.
YANG Description: The instance to which the port should be configured.
"""
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=RestrictedClassType(base_type=long, restriction_dict={'range': ['-2147483648..2147483647']}, int_size=32), is_leaf=True, yang_name="instance", rest_name="instance", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'The instance to which the port should be configured.', u'hidden': u'debug'}}, namespace='urn:brocade.com:mgmt:brocade-hardware', defining_module='brocade-hardware', yang_type='int32', is_config=True)
except (TypeError, ValueError):
raise ValueError({
'error-string': """instance must be of a type compatible with int32""",
'defined-type': "int32",
'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['-2147483648..2147483647']}, int_size=32), is_leaf=True, yang_name="instance", rest_name="instance", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'The instance to which the port should be configured.', u'hidden': u'debug'}}, namespace='urn:brocade.com:mgmt:brocade-hardware', defining_module='brocade-hardware', yang_type='int32', is_config=True)""",
})
self.__instance = t
if hasattr(self, '_set'):
self._set()
def _unset_instance(self):
self.__instance = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['-2147483648..2147483647']}, int_size=32), is_leaf=True, yang_name="instance", rest_name="instance", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'The instance to which the port should be configured.', u'hidden': u'debug'}}, namespace='urn:brocade.com:mgmt:brocade-hardware', defining_module='brocade-hardware', yang_type='int32', is_config=True)
def _get_skip_deconfig(self):
"""
Getter method for skip_deconfig, mapped from YANG variable /hardware/flexport/flexport_type/skip_deconfig (empty)
YANG Description: Skip plugin notification Errors.
"""
return self.__skip_deconfig
def _set_skip_deconfig(self, v, load=False):
"""
Setter method for skip_deconfig, mapped from YANG variable /hardware/flexport/flexport_type/skip_deconfig (empty)
If this variable is read-only (config: false) in the
source YANG file, then _set_skip_deconfig is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_skip_deconfig() directly.
YANG Description: Skip plugin notification Errors.
"""
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=YANGBool, is_leaf=True, yang_name="skip_deconfig", rest_name="skip_deconfig", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Skip Plugin deconfig errors.', u'hidden': u'debug'}}, namespace='urn:brocade.com:mgmt:brocade-hardware', defining_module='brocade-hardware', yang_type='empty', is_config=True)
except (TypeError, ValueError):
raise ValueError({
'error-string': """skip_deconfig must be of a type compatible with empty""",
'defined-type': "empty",
'generated-type': """YANGDynClass(base=YANGBool, is_leaf=True, yang_name="skip_deconfig", rest_name="skip_deconfig", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Skip Plugin deconfig errors.', u'hidden': u'debug'}}, namespace='urn:brocade.com:mgmt:brocade-hardware', defining_module='brocade-hardware', yang_type='empty', is_config=True)""",
})
self.__skip_deconfig = t
if hasattr(self, '_set'):
self._set()
def _unset_skip_deconfig(self):
self.__skip_deconfig = YANGDynClass(base=YANGBool, is_leaf=True, yang_name="skip_deconfig", rest_name="skip_deconfig", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'info': u'Skip Plugin deconfig errors.', u'hidden': u'debug'}}, namespace='urn:brocade.com:mgmt:brocade-hardware', defining_module='brocade-hardware', yang_type='empty', is_config=True)
type = __builtin__.property(_get_type, _set_type)
instance = __builtin__.property(_get_instance, _set_instance)
skip_deconfig = __builtin__.property(_get_skip_deconfig, _set_skip_deconfig)
_pyangbind_elements = {'type': type, 'instance': instance, 'skip_deconfig': skip_deconfig, }
| 62.156098 | 613 | 0.70868 | 1,669 | 12,742 | 5.177951 | 0.110845 | 0.043971 | 0.04536 | 0.01944 | 0.758852 | 0.728535 | 0.697755 | 0.671951 | 0.671951 | 0.660842 | 0 | 0.011078 | 0.164024 | 12,742 | 204 | 614 | 62.460784 | 0.800225 | 0.150133 | 0 | 0.390625 | 0 | 0.023438 | 0.339095 | 0.122581 | 0 | 0 | 0 | 0 | 0 | 1 | 0.09375 | false | 0 | 0.0625 | 0 | 0.289063 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
8dc77ad3aecb6fe02a1eb52d5b4e21e6bab7054f | 337 | py | Python | zooniverse_web/views/static.py | ADACS-Australia/SS18A-JBanfield | 26196091cc83f88f28abdf979276ee439349efa8 | [
"MIT"
] | null | null | null | zooniverse_web/views/static.py | ADACS-Australia/SS18A-JBanfield | 26196091cc83f88f28abdf979276ee439349efa8 | [
"MIT"
] | 15 | 2018-06-05T10:28:03.000Z | 2018-07-03T09:05:11.000Z | zooniverse_web/views/static.py | ADACS-Australia/SS18A-JBanfield | 26196091cc83f88f28abdf979276ee439349efa8 | [
"MIT"
] | null | null | null | """
Distributed under the MIT License. See LICENSE.txt for more info.
"""
from __future__ import unicode_literals
from django.shortcuts import render
def index(request):
return render(
request,
"base/welcome.html",
)
def about(request):
return render(
request,
"about/about.html",
)
| 15.318182 | 65 | 0.643917 | 39 | 337 | 5.435897 | 0.666667 | 0.122642 | 0.179245 | 0.245283 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.261128 | 337 | 21 | 66 | 16.047619 | 0.851406 | 0.192878 | 0 | 0.333333 | 0 | 0 | 0.125 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.166667 | 0.166667 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
8dd1fd5f3985055778576102e880c038eef1630a | 238 | py | Python | #2 Mundo/#12/40.py | Henrique-Navarro/phyton | 26d66847afa2b15c254677a36eb22f7558816b59 | [
"MIT"
] | null | null | null | #2 Mundo/#12/40.py | Henrique-Navarro/phyton | 26d66847afa2b15c254677a36eb22f7558816b59 | [
"MIT"
] | null | null | null | #2 Mundo/#12/40.py | Henrique-Navarro/phyton | 26d66847afa2b15c254677a36eb22f7558816b59 | [
"MIT"
] | null | null | null | nota1= float(input('Digite a primeira nota: '))
nota2= float(input('Digite a segunda nota: '))
med= (nota1+nota2)/2
if med<5:
print('reprovado')
if med>5 and med<6.9:
print('recuperation')
if med>7:
print('parabens espertão') | 23.8 | 47 | 0.668067 | 38 | 238 | 4.184211 | 0.578947 | 0.09434 | 0.201258 | 0.213836 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.05 | 0.159664 | 238 | 10 | 48 | 23.8 | 0.745 | 0 | 0 | 0 | 0 | 0 | 0.355649 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.333333 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
8ddebff593e10d9dae4d49d46eeca037b9df6ece | 2,627 | py | Python | functions/Verifiers.py | fvergaracl/gonsa2_backend | 2e354179cd337e6e98a6f23eb0a5c3f9c5e7b57e | [
"MIT"
] | null | null | null | functions/Verifiers.py | fvergaracl/gonsa2_backend | 2e354179cd337e6e98a6f23eb0a5c3f9c5e7b57e | [
"MIT"
] | 1 | 2019-10-19T21:11:38.000Z | 2019-10-19T21:11:38.000Z | functions/Verifiers.py | fvergaracl/gonsa2_backend | 2e354179cd337e6e98a6f23eb0a5c3f9c5e7b57e | [
"MIT"
] | null | null | null | import re
from models.users import login_user
class config_pass:
def __init__(self):
self.min_length = 6
self.need_number = False
self.need_uppercase = False
self.need_lowercase = False
self.need_symbol = False
def get_min_length(self):
return self.min_length
def get_need_number(self, pass_):
if self.need_number:
return (re.search(r"\d", pass_) is None)
return False
def get_need_uppercase(self, pass_):
if self.need_uppercase:
return (re.search(r"[A-Z]", pass_) is None)
return False
def get_need_lowercase(self, pass_):
if self.need_lowercase:
return (re.search(r"[a-z]", pass_) is None)
return False
def get_need_symbol(self, pass_):
if self.need_symbol:
return (re.search(r"[ !#$%&'()*+,-./[\\\]^_`{|}~"+r'"]', pass_) is None)
return False
def verify_pass_conditions(pass_):
c = config_pass()
if (len(pass_) < c.get_min_length()):
# Checking the length
return False , "The new password contains less than 6 characters"
elif c.get_need_number(pass_):
# Searching for digits
return False , "Must contain at least one number"
elif c.get_need_symbol(pass_):
# Searching for symbols
return False , "Must contain at least one symbol"
elif c.get_need_lowercase(pass_):
# Searching for lowercase
return False , "Must contain at least one lowercase"
elif c.get_need_uppercase(pass_):
# Searching for uppercase
return False , "Must contain at least one uppercase"
else:
# All ok
return True, ""
def verify_new_pass(user_, old_pass, new_pass1, new_pass2):
c = config_pass()
if (new_pass1 != new_pass2):
# Checking the new passwords
return False , "The new passwords doesn't match"
elif not (login_user(user_, old_pass)):
# Checking password
return False , "The old password is not correct"
elif (len(new_pass1) < c.get_min_length()):
# Checking the length
return False , "The new password contains less than 6 characters"
elif c.get_need_number(new_pass1):
# Searching for digits
return False , "Must contain at least one number"
elif c.get_need_symbol(new_pass1):
# Searching for symbols
return False , "Must contain at least one symbol"
elif c.get_need_lowercase(new_pass1):
# Searching for lowercase
return False , "Must contain at least one lowercase"
elif c.get_need_uppercase(new_pass1):
# Searching for uppercase
return False , "Must contain at least one uppercase"
else:
# All ok
return True, ""
def validemail(email):
match = re.match('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', email)
if match == None:
return False
else:
return True | 29.188889 | 100 | 0.703464 | 403 | 2,627 | 4.379653 | 0.181141 | 0.105949 | 0.036261 | 0.054391 | 0.610765 | 0.569972 | 0.556374 | 0.556374 | 0.53881 | 0.53881 | 0 | 0.010199 | 0.178911 | 2,627 | 90 | 101 | 29.188889 | 0.808067 | 0.106966 | 0 | 0.338462 | 0 | 0.015385 | 0.230274 | 0.040738 | 0 | 0 | 0 | 0 | 0 | 1 | 0.138462 | false | 0.446154 | 0.030769 | 0.015385 | 0.569231 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
8de11588af9bdefd23320430df1395c5f36bec5a | 240 | py | Python | tests/class/callable01.py | ktok07b6/polyphony | 657c5c7440520db6b4985970bd50547407693ac4 | [
"MIT"
] | 83 | 2015-11-30T09:59:13.000Z | 2021-08-03T09:12:28.000Z | tests/class/callable01.py | jesseclin/polyphony | 657c5c7440520db6b4985970bd50547407693ac4 | [
"MIT"
] | 4 | 2017-02-10T01:43:11.000Z | 2020-07-14T03:52:25.000Z | tests/class/callable01.py | jesseclin/polyphony | 657c5c7440520db6b4985970bd50547407693ac4 | [
"MIT"
] | 11 | 2016-11-18T14:39:15.000Z | 2021-02-23T10:05:20.000Z | from polyphony import testbench
class C:
def __call__(self, x):
return x
def call01(x):
c = C()
return c(x)
@testbench
def test():
assert 1 == call01(1)
assert 2 == call01(2)
assert 3 == call01(3)
test()
| 13.333333 | 31 | 0.579167 | 36 | 240 | 3.75 | 0.472222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.082353 | 0.291667 | 240 | 17 | 32 | 14.117647 | 0.711765 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.230769 | 1 | 0.230769 | false | 0 | 0.076923 | 0.076923 | 0.538462 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
8df3814e73c4dc30af2ae83e82e470702d937f80 | 714 | py | Python | server/src/tests/samples/overload1.py | jhutchings1/pyright | 2b8593a58a2aecc95dac49cce92fc16678cd4e14 | [
"MIT"
] | 1 | 2020-12-28T16:58:24.000Z | 2020-12-28T16:58:24.000Z | server/src/tests/samples/overload1.py | jhutchings1/pyright | 2b8593a58a2aecc95dac49cce92fc16678cd4e14 | [
"MIT"
] | 1 | 2021-03-03T11:24:14.000Z | 2021-03-03T11:32:45.000Z | server/src/tests/samples/overload1.py | jhutchings1/pyright | 2b8593a58a2aecc95dac49cce92fc16678cd4e14 | [
"MIT"
] | null | null | null | # This sample tests the type checker's handling of the overload decorator.
from typing import overload, Optional
from datetime import datetime, timezone, timedelta
@overload
def from_json_timestamp(ts: int) -> datetime:
...
@overload
def from_json_timestamp(ts: None) -> None:
...
def from_json_timestamp(ts: Optional[int]) -> Optional[datetime]:
return None if ts is None else (datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(milliseconds=ts))
result1: datetime = from_json_timestamp(2418049)
# This should generate an error
result2: datetime = from_json_timestamp(None)
result3: None = from_json_timestamp(None)
# This should generate an error
result4: None = from_json_timestamp(2345)
| 27.461538 | 107 | 0.761905 | 99 | 714 | 5.353535 | 0.434343 | 0.10566 | 0.224528 | 0.113208 | 0.249057 | 0.113208 | 0 | 0 | 0 | 0 | 0 | 0.03437 | 0.144258 | 714 | 25 | 108 | 28.56 | 0.833061 | 0.184874 | 0 | 0.285714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.214286 | false | 0 | 0.142857 | 0.071429 | 0.428571 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
8dfdf5f545123f3283f4dcf1720e792b1443dc0f | 1,167 | py | Python | website/addons/mendeley/tests/test_views.py | DanielSBrown/osf.io | 98dda2ac237377197acacce78274bc0a4ce8f303 | [
"Apache-2.0"
] | null | null | null | website/addons/mendeley/tests/test_views.py | DanielSBrown/osf.io | 98dda2ac237377197acacce78274bc0a4ce8f303 | [
"Apache-2.0"
] | null | null | null | website/addons/mendeley/tests/test_views.py | DanielSBrown/osf.io | 98dda2ac237377197acacce78274bc0a4ce8f303 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
import mock
import urlparse
from website.addons.base.testing import views
from website.addons.base.testing.utils import MockFolder
from website.addons.mendeley.model import Mendeley
from website.addons.mendeley.provider import MendeleyCitationsProvider
from website.addons.mendeley.serializer import MendeleySerializer
from website.addons.mendeley.tests.utils import MendeleyTestCase, mock_responses
API_URL = 'https://api.mendeley.com'
class TestAuthViews(MendeleyTestCase, views.OAuthAddonAuthViewsTestCaseMixin):
pass
class TestConfigViews(MendeleyTestCase, views.OAuthCitationAddonConfigViewsTestCaseMixin):
folder = MockFolder()
Serializer = MendeleySerializer
client = Mendeley
citationsProvider = MendeleyCitationsProvider
foldersApiUrl = urlparse.urljoin(API_URL, 'folders')
documentsApiUrl = urlparse.urljoin(API_URL, 'documents')
mockResponses = mock_responses
@mock.patch('website.addons.mendeley.model.MendeleyNodeSettings._fetch_folder_name', mock.PropertyMock(return_value='Fake Name'))
def test_deauthorize_node(self):
super(TestConfigViews, self).test_deauthorize_node()
| 36.46875 | 133 | 0.806341 | 120 | 1,167 | 7.733333 | 0.466667 | 0.09806 | 0.109914 | 0.107759 | 0.060345 | 0 | 0 | 0 | 0 | 0 | 0 | 0.000964 | 0.111397 | 1,167 | 31 | 134 | 37.645161 | 0.893925 | 0.017995 | 0 | 0 | 0 | 0 | 0.103147 | 0.060315 | 0 | 0 | 0 | 0 | 0 | 1 | 0.045455 | false | 0.045455 | 0.363636 | 0 | 0.818182 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
5c09672fdda2bb532f7abec621322437162206eb | 1,941 | py | Python | peon/tests/test_project/test_file/test_function_def/test_functions/test_set_encapsulated_attribs_line_numbers.py | roch1990/peon | 0e9e40956c05138c0820fe380b354fdd1fe95e01 | [
"MIT"
] | 32 | 2020-05-18T14:02:59.000Z | 2022-02-06T15:00:12.000Z | peon/tests/test_project/test_file/test_function_def/test_functions/test_set_encapsulated_attribs_line_numbers.py | roch1990/peon | 0e9e40956c05138c0820fe380b354fdd1fe95e01 | [
"MIT"
] | 42 | 2020-05-22T20:29:08.000Z | 2021-03-10T21:24:23.000Z | peon/tests/test_project/test_file/test_function_def/test_functions/test_set_encapsulated_attribs_line_numbers.py | roch1990/peon | 0e9e40956c05138c0820fe380b354fdd1fe95e01 | [
"MIT"
] | 4 | 2020-07-02T06:32:42.000Z | 2022-01-24T22:46:02.000Z | import _ast
from peon.src.project.file.function_def.function import FunctionLint
class SetEncapsulatedAttribsLineNumbersFixture:
definition_is_none = None
definition_is_pass = _ast.Pass()
is_constructor = _ast.FunctionDef(name='__init__')
without_assign = _ast.FunctionDef(name='test', body=[_ast.Pass()])
with_assign_without_self = _ast.FunctionDef(
name='test', body=[
_ast.Pass(),
_ast.Assign(targets=[_ast.Attribute(value=(_ast.Name(id='test')), lineno=1)]),
],
)
with_assign_with_self = _ast.FunctionDef(
name='test', body=[
_ast.Pass(),
_ast.Assign(targets=[_ast.Attribute(value=(_ast.Name(id='self')), lineno=1)]),
],
)
def test_function_definition_is_none():
assert FunctionLint(
definition=SetEncapsulatedAttribsLineNumbersFixture.definition_is_none,
).set_encapsulated_attribs_line_numbers() == ()
def test_function_definition_is_pass():
assert FunctionLint(
definition=SetEncapsulatedAttribsLineNumbersFixture.definition_is_pass,
).set_encapsulated_attribs_line_numbers() == ()
def test_function_is_constructor():
assert FunctionLint(
definition=SetEncapsulatedAttribsLineNumbersFixture.is_constructor,
).set_encapsulated_attribs_line_numbers() == ()
def test_function_without_assign():
assert FunctionLint(
definition=SetEncapsulatedAttribsLineNumbersFixture.without_assign,
).set_encapsulated_attribs_line_numbers() == ()
def test_function_with_assign_without_self():
assert FunctionLint(
definition=SetEncapsulatedAttribsLineNumbersFixture.with_assign_without_self,
).set_encapsulated_attribs_line_numbers() == ()
def test_function_with_assign_with_self():
assert FunctionLint(
definition=SetEncapsulatedAttribsLineNumbersFixture.with_assign_with_self,
).set_encapsulated_attribs_line_numbers() == (1,)
| 32.35 | 90 | 0.737249 | 193 | 1,941 | 6.937824 | 0.196891 | 0.053771 | 0.067214 | 0.304705 | 0.638536 | 0.60941 | 0.459298 | 0.312173 | 0.20463 | 0.20463 | 0 | 0.001843 | 0.161257 | 1,941 | 59 | 91 | 32.898305 | 0.820639 | 0 | 0 | 0.395349 | 0 | 0 | 0.014426 | 0 | 0 | 0 | 0 | 0 | 0.139535 | 1 | 0.139535 | false | 0.139535 | 0.046512 | 0 | 0.348837 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
5c0f1ef99183777966d6b9668f8a660ad8296e89 | 216 | py | Python | math/0x00-linear_algebra/100-slice_like_a_ninja.py | kyeeh/holbertonschool-machine_learning | 8e4894c2b036ec7f4750de5bf99b95aee5b94449 | [
"MIT"
] | null | null | null | math/0x00-linear_algebra/100-slice_like_a_ninja.py | kyeeh/holbertonschool-machine_learning | 8e4894c2b036ec7f4750de5bf99b95aee5b94449 | [
"MIT"
] | null | null | null | math/0x00-linear_algebra/100-slice_like_a_ninja.py | kyeeh/holbertonschool-machine_learning | 8e4894c2b036ec7f4750de5bf99b95aee5b94449 | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
"""
Module with function to slice a matrix
"""
def np_slice(matrix, axes={}):
"""
Slices a matrix along a specific axes
Returns the new matrix
"""
return matrix[-3:, -3:]
| 16.615385 | 41 | 0.615741 | 31 | 216 | 4.258065 | 0.709677 | 0.106061 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.018293 | 0.240741 | 216 | 12 | 42 | 18 | 0.786585 | 0.560185 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.5 | false | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
5c218c558c53f5a8e27b41853db27d02b87f2e03 | 193 | py | Python | 6 kyu/Backspaces in string.py | mwk0408/codewars_solutions | 9b4f502b5f159e68024d494e19a96a226acad5e5 | [
"MIT"
] | 6 | 2020-09-03T09:32:25.000Z | 2020-12-07T04:10:01.000Z | 6 kyu/Backspaces in string.py | mwk0408/codewars_solutions | 9b4f502b5f159e68024d494e19a96a226acad5e5 | [
"MIT"
] | 1 | 2021-12-13T15:30:21.000Z | 2021-12-13T15:30:21.000Z | 6 kyu/Backspaces in string.py | mwk0408/codewars_solutions | 9b4f502b5f159e68024d494e19a96a226acad5e5 | [
"MIT"
] | null | null | null | def clean_string(s):
result=[]
for i in s:
if i=="#":
if result:
result.pop(-1)
else:
result.append(i)
return "".join(result) | 21.444444 | 30 | 0.430052 | 23 | 193 | 3.565217 | 0.652174 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009091 | 0.430052 | 193 | 9 | 31 | 21.444444 | 0.736364 | 0 | 0 | 0 | 0 | 0 | 0.005155 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0 | 0 | 0.222222 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
5c28573810ee08d63d10ddc74461c8b5c50ea03d | 189 | py | Python | First_project/travello/models.py | chakrabortysayantan699/Django-projects | f9d03400b7af7262711efa60d065598845e06879 | [
"MIT"
] | null | null | null | First_project/travello/models.py | chakrabortysayantan699/Django-projects | f9d03400b7af7262711efa60d065598845e06879 | [
"MIT"
] | null | null | null | First_project/travello/models.py | chakrabortysayantan699/Django-projects | f9d03400b7af7262711efa60d065598845e06879 | [
"MIT"
] | null | null | null | from django.db import models
# Create your models here.
# head:str
# about:str
class Portfolio(models.Model):
head=models.CharField(max_length=200)
about=models.TextField()
| 17.181818 | 39 | 0.719577 | 26 | 189 | 5.192308 | 0.730769 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.019231 | 0.174603 | 189 | 10 | 40 | 18.9 | 0.846154 | 0.227513 | 0 | 0 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
5c3accf110de9c7a98bc7935b643b399d283209a | 2,022 | py | Python | argo_data_scripts/util/query_rt_info.py | nithinksath96/Small_object_detection | b2ccd29d128487909f92e4fc796f72a0a4458e32 | [
"Apache-2.0"
] | null | null | null | argo_data_scripts/util/query_rt_info.py | nithinksath96/Small_object_detection | b2ccd29d128487909f92e4fc796f72a0a4458e32 | [
"Apache-2.0"
] | null | null | null | argo_data_scripts/util/query_rt_info.py | nithinksath96/Small_object_detection | b2ccd29d128487909f92e4fc796f72a0a4458e32 | [
"Apache-2.0"
] | null | null | null | import pickle
from os.path import join
import numpy as np
import sys; sys.path.insert(0, '..'); sys.path.insert(0, '.')
from util import print_stats
file_path = '/data2/mengtial/Exp/ArgoVerse1.1/output/rt_htc_dconv2_ms_nm_s1.0/val/time_info.pkl'
time_info = pickle.load(open(file_path, 'rb'))
runtime_all_np = np.array(time_info['runtime_all'])
s2ms = lambda x: 1e3*x
# print_stats(det1_runtime, 'det1 (ms)', cvt=s2ms)
# print_stats(det2_runtime, 'det2 (ms)', cvt=s2ms)
print_stats(runtime_all_np, 'overall (ms)', cvt=s2ms)
# file_path = '/data2/mengtial/Exp/ArgoVerse-pgt-gpupre/output/rt_dat_mrcnn50_nm_d15_s0.5/val/time_info.pkl'
# time_info = pickle.load(open(file_path, 'rb'))
# runtime_all_np = np.array(time_info['runtime_all'])
# which_cfg = np.array(time_info['which_cfg_all'], np.bool)
# det1_runtime = runtime_all_np[np.logical_not(which_cfg)]
# det2_runtime = runtime_all_np[which_cfg]
# s2ms = lambda x: 1e3*x
# print_stats(det1_runtime, 'det1 (ms)', cvt=s2ms)
# print_stats(det2_runtime, 'det2 (ms)', cvt=s2ms)
# print_stats(runtime_all_np, 'overall (ms)', cvt=s2ms)
# print('Init (ms): mean: %g; std: %g; min: %g; max: %g' % (
# runtime_all_np.mean(),
# runtime_all_np.std(ddof=1),
# runtime_all_np.min(),
# runtime_all_np.max(),
# ))
# aa = pickle.load(open('/data2/mengtial/Exp/ArgoVerse/output/cv2csrdcf_mrcnn50_d10/s1_val/time_tracker.pkl', 'rb'))
# runtime_all_np = 1e3*np.array(aa['rt_tracker_init'])[100:10101]
# print(len(runtime_all_np))
# print('Init (ms): mean: %g; std: %g; min: %g; max: %g' % (
# runtime_all_np.mean(),
# runtime_all_np.std(ddof=1),
# runtime_all_np.min(),
# runtime_all_np.max(),
# ))
# runtime_all_np = 1e3*np.array(aa['rt_tracker_update'])[100:10101]
# print('Update (ms): mean: %g; std: %g; min: %g; max: %g' % (
# runtime_all_np.mean(),
# runtime_all_np.std(ddof=1),
# runtime_all_np.min(),
# runtime_all_np.max(),
# ))
# status = np.array(aa['tracker_status'])
# print('%d; %g' % (len(status), status.mean()))
| 33.7 | 116 | 0.685955 | 334 | 2,022 | 3.874252 | 0.227545 | 0.177743 | 0.194745 | 0.054096 | 0.614374 | 0.57728 | 0.57728 | 0.57728 | 0.57728 | 0.526275 | 0 | 0.037832 | 0.124135 | 2,022 | 59 | 117 | 34.271186 | 0.692829 | 0.748764 | 0 | 0 | 0 | 0.1 | 0.234043 | 0.174468 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0.2 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
5c3ca88dd98c6426ff85eb938f4914d4958a2bc0 | 1,242 | py | Python | tests/test_trainAndDev.py | wasimaftab/kindred | bb737006843ad1ab4062e5b26864ccda1efd7216 | [
"MIT"
] | 141 | 2017-08-03T15:51:42.000Z | 2022-01-20T05:16:20.000Z | tests/test_trainAndDev.py | wasimaftab/kindred | bb737006843ad1ab4062e5b26864ccda1efd7216 | [
"MIT"
] | 24 | 2017-08-04T12:07:54.000Z | 2021-06-22T12:40:53.000Z | tests/test_trainAndDev.py | wasimaftab/kindred | bb737006843ad1ab4062e5b26864ccda1efd7216 | [
"MIT"
] | 34 | 2017-08-22T21:44:36.000Z | 2022-03-27T11:24:19.000Z | import sys
import kindred
from kindred.datageneration import generateData,generateTestData
def _bionlpst_bb3(swap):
trainCorpus = kindred.bionlpst.load('2016-BB3-event-train')
devCorpus = kindred.bionlpst.load('2016-BB3-event-dev')
if swap:
trainCorpus,devCorpus = devCorpus,trainCorpus
predictionCorpus = devCorpus.clone()
predictionCorpus.removeRelations()
classifier = kindred.RelationClassifier(useBuilder=True)
classifier.train(trainCorpus)
classifier.predict(predictionCorpus)
scores = kindred.evaluate(devCorpus, predictionCorpus, metric='all')
print("bb3 scores:",scores,swap)
def _bionlpst_seedev(swap):
trainCorpus = kindred.bionlpst.load('2016-SeeDev-binary-train')
devCorpus = kindred.bionlpst.load('2016-SeeDev-binary-dev')
if swap:
trainCorpus,devCorpus = devCorpus,trainCorpus
predictionCorpus = devCorpus.clone()
predictionCorpus.removeRelations()
classifier = kindred.RelationClassifier()
classifier.train(trainCorpus)
classifier.predict(predictionCorpus)
scores = kindred.evaluate(devCorpus, predictionCorpus, metric='all')
print("seedev scores:",scores,swap)
if __name__ == '__main__':
_bionlpst_bb3(False)
_bionlpst_bb3(True)
_bionlpst_seedev(False)
_bionlpst_seedev(True)
| 25.346939 | 69 | 0.791465 | 131 | 1,242 | 7.351145 | 0.282443 | 0.062305 | 0.07892 | 0.095535 | 0.745587 | 0.745587 | 0.548287 | 0.548287 | 0.548287 | 0.548287 | 0 | 0.01966 | 0.099034 | 1,242 | 48 | 70 | 25.875 | 0.840929 | 0 | 0 | 0.4375 | 1 | 0 | 0.099114 | 0.037067 | 0 | 0 | 0 | 0 | 0 | 1 | 0.0625 | false | 0 | 0.09375 | 0 | 0.15625 | 0.0625 | 0 | 0 | 0 | null | 0 | 0 | 0 | 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 | 2 |
5c3deedef0242b98334b7e971b358a5b1c92a97f | 9,287 | py | Python | tools/wcloud/wcloud/test/test_wcloud_tasks.py | zstars/weblabdeusto | 09bd9d93d483671bca67ee5c70a9c412eb5d352f | [
"BSD-2-Clause"
] | 15 | 2015-03-12T12:15:41.000Z | 2021-12-20T17:53:24.000Z | tools/wcloud/wcloud/test/test_wcloud_tasks.py | zstars/weblabdeusto | 09bd9d93d483671bca67ee5c70a9c412eb5d352f | [
"BSD-2-Clause"
] | 44 | 2015-01-07T09:22:05.000Z | 2017-01-31T22:44:21.000Z | tools/wcloud/wcloud/test/test_wcloud_tasks.py | zstars/weblabdeusto | 09bd9d93d483671bca67ee5c70a9c412eb5d352f | [
"BSD-2-Clause"
] | 22 | 2015-01-13T13:55:48.000Z | 2021-12-16T17:07:00.000Z | ######################################
#
# UNIT TESTS BELOW
#
######################################
import json
import os
import shutil
import unittest
import time
import subprocess
import requests
from wcloud.tasks.wcloud_tasks import flask_app, prepare_system, create_weblab_environment, configure_web_server, register_and_start_instance, finish_deployment
from weblab.admin.script import Creation
# These tests are meant to be run from the root wcloud folder. Fix the path
# so it is so.
cwd = os.getcwd()
if cwd.endswith(os.path.join("wcloud", "test")):
cwd = cwd[0:len(cwd)-len(os.path.join("wcloud", "test"))]
os.chdir(cwd)
class TestWcloudTasks(unittest.TestCase):
wcloud_settings = {
"DB_USERNAME": "wcloud",
"DB_PASSWORD": "password",
"DB_NAME": "wcloudtest",
"REDIS_FOLDER": "redis_env",
"WEBLAB_STARTUP_TIME": 2
}
def test_prepare_system(self):
"""
Tests that the first step (prepare system) works as expected.
Prerrequisites: mysql running, redis running.
"""
settings = prepare_system("testuser@testuser.com", "admin", "Administrador", "password", "admin@admin.com",
self.wcloud_settings)
self._settings = settings
def test_create_weblab_environment(self):
settings = prepare_system("testuser@testuser.com", "admin", "Administrador", "password", "admin@admin.com",
self.wcloud_settings)
self._settings = settings
base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL])
create_weblab_environment(base_url, settings)
def test_create_weblab_environment_thorough(self):
settings = prepare_system("testuser@testuser.com", "admin", "Administrador", "password", "admin@admin.com",
self.wcloud_settings)
self._settings = settings
base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL])
create_weblab_environment(base_url, settings)
# Start a local server on that config to check whether it works as expected.
from weblab.comm.proxy_server import start as start_proxy
g = globals()
l = locals()
execfile(os.path.join(base_url, 'httpd/simple_server_config.py'), g, l)
print "FILE: " + base_url
p = g.get("PATHS") or l.get("PATHS")
start_proxy(8001, p)
time.sleep(1)
r = requests.get("http://localhost:8001/testentity/weblab/client/index.html")
assert r.status_code == 200
assert "Deusto" in r.text
def test_configure_web_server(self):
"""
Checks whether the Apache server can be configured correctly.
PRERREQUISITE: Apache Reloader script must previously be running.
"""
settings = prepare_system("testuser@testuser.com", "admin", "Administrador", "password", "admin@admin.com",
self.wcloud_settings)
self._settings = settings
base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL])
creation_results = create_weblab_environment(base_url, settings)
configure_web_server(creation_results)
assert os.path.isfile(os.path.join(base_url, "../", "apache.conf"))
content = open(os.path.join(base_url, "../", "apache.conf"), "r").read()
assert "testentity" in content
lines = content.split("\n")
line = [line.strip() for line in lines if "testentity" in line][0]
assert os.path.isfile(line.split("\"")[1])
def test_register_and_start_instance(self):
"""
Test whether the weblab instance can be started successfully.
PRERREQUISITE: weblabstarter script needs to be running in the background.
"""
time.sleep(2)
settings = prepare_system("testuser@testuser.com", "admin", "Administrador", "password", "admin@admin.com",
self.wcloud_settings)
self._settings = settings
base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL])
creation_results = create_weblab_environment(base_url, settings)
configure_web_server(creation_results)
register_and_start_instance("testuser@testuser.com", {})
start_port, end_port = creation_results["start_port"], creation_results["end_port"]
def test_finish_deployment(self):
"""
test_finish_deployment: Tests that every step can be done, and the deployment finished.
PRERREQUISITES: apache-reloader and weblab-starter scripts running.
"""
settings = prepare_system("testuser@testuser.com", "admin", "Administrador", "password", "admin@admin.com",
self.wcloud_settings)
self._settings = settings
base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL])
creation_results = create_weblab_environment(base_url, settings)
configure_web_server(creation_results)
register_and_start_instance("testuser@testuser.com", self.wcloud_settings)
start_port, end_port = creation_results["start_port"], creation_results["end_port"]
finish_deployment("testuser@testuser.com", settings, start_port, end_port, self.wcloud_settings)
pass
def test_finish_deployment_thorough(self):
"""
test_finish_deployment_thorough: Tests that every step can be done, and the deployment finished.
Checks that after being configured, Apache is indeed serving the new instance correctly.
PRERREQUISITES: apache-reloader and weblab-starter scripts running; apache2 configured correctly to load the instances.
"""
settings = prepare_system("testuser@testuser.com", "admin", "Administrador", "password", "admin@admin.com",
self.wcloud_settings)
self._settings = settings
base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL])
creation_results = create_weblab_environment(base_url, settings)
configure_web_server(creation_results)
register_and_start_instance("testuser@testuser.com", self.wcloud_settings)
start_port, end_port = creation_results["start_port"], creation_results["end_port"]
finish_deployment("testuser@testuser.com", settings, start_port, end_port, self.wcloud_settings)
# Check that the new instance is being served correctly.
bot = requests.Session()
r = bot.get("http://localhost/testentity/weblab/client/index.html")
text = r.text
print text
assert "weblabclientlab" in text
assert "input" in text
assert "hiddenPassword" in text
# Check that we can login with admin/password.
r = bot.post("http://localhost/testentity/weblab/login/json/", data="""{"params":{"username":"admin", "password":"password"}, "method":"login"}""")
str = r.text
print "The request returned: " + str
j = json.loads(str)
assert not j["is_exception"]
assert "id" in j["result"]
def setUp(self):
import wcloud.test.prepare as prepare
prepare.prepare_test_database("root", "password")
# Remove running weblab instances.
os.system("kill $(ps aux | grep 'python -OO.*wcloud' | awk '{print $2}')")
def tearDown(self):
# Delete the deployed directory.
try:
pass
#shutil.rmtree("weblabtest")
except:
pass
# Remove running weblab instances.
os.system("kill $(ps aux | grep 'python -OO.*wcloud' | awk '{print $2}')")
# Remove the testentity line if present. Otherwise, the next attempt to start-weblab will fail
# because its folder will be removed.
try:
instances_file = os.path.join(flask_app.config["DIR_BASE"], "instances.txt")
f = file(instances_file)
lines = f.readlines()
lines = [line.replace("\n", "") + "\n" for line in lines if not "testentity" in line]
f.close()
f = file(instances_file, "w")
f.writelines(lines)
f.close()
except:
pass
# Remove the include from apache.conf
apacheconf = os.path.join(flask_app.config["DIR_BASE"], "apache.conf")
lines = open(apacheconf, "r").readlines()
cleared_lines = [line.strip() + "\n" for line in lines if "testentity" not in line]
open(apacheconf, "w").writelines(cleared_lines)
# Make sure all the instances are stopped. DANGEROUS: This will kill all running instances of WebLab.
# This is done, specifically, so that "testentity" instance is killed after being run, so that
# the test can be run again without issues.l
try:
os.system("killall weblab-admin")
except:
pass
# TODO: Careful with this. It is dangerous, in production if configured wrongly it would
# erase the whole deployments directory.
try:
base_url = os.path.join(flask_app.config["DIR_BASE"], self._settings[Creation.BASE_URL])
shutil.rmtree(base_url)
except:
pass
# Give it some time. It seems to be necessary.
time.sleep(1.5)
| 42.406393 | 160 | 0.650587 | 1,127 | 9,287 | 5.193434 | 0.22449 | 0.029899 | 0.023919 | 0.032291 | 0.49496 | 0.474628 | 0.452418 | 0.443192 | 0.413976 | 0.413976 | 0 | 0.003089 | 0.233014 | 9,287 | 218 | 161 | 42.600917 | 0.818616 | 0.104878 | 0 | 0.442857 | 0 | 0 | 0.192793 | 0.046292 | 0 | 0 | 0 | 0.004587 | 0.071429 | 0 | null | null | 0.121429 | 0.078571 | null | null | 0.035714 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
308d121a719023f883a86fa9d86690b3eff766c0 | 239 | py | Python | desafios/desafio 038.py | juaoantonio/curso_video_python | 7520223d8647929530a1cd96f7c7d8c8f264ba1e | [
"MIT"
] | null | null | null | desafios/desafio 038.py | juaoantonio/curso_video_python | 7520223d8647929530a1cd96f7c7d8c8f264ba1e | [
"MIT"
] | null | null | null | desafios/desafio 038.py | juaoantonio/curso_video_python | 7520223d8647929530a1cd96f7c7d8c8f264ba1e | [
"MIT"
] | null | null | null | n1 = float(input('Digite o primeiro número: '))
n2 = float(input('Digite o segundo: '))
if n1 > n2:
print('O primeiro número é maior')
elif n2 > n1:
print('O segundo número é maior')
else:
print('Os dois números são iguais') | 21.727273 | 47 | 0.648536 | 38 | 239 | 4.078947 | 0.526316 | 0.129032 | 0.206452 | 0.219355 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.031915 | 0.213389 | 239 | 11 | 48 | 21.727273 | 0.792553 | 0 | 0 | 0 | 0 | 0 | 0.495833 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.375 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
30952ac8b9c75f825ce880470145c92e97aaf5bd | 2,430 | py | Python | libmuscle/python/libmuscle/test/test_settings_manager.py | DongweiYe/muscle3 | 0c2fcf5f62995b8639fc84ce1b983c8a8e6248d0 | [
"Apache-2.0"
] | 11 | 2018-03-12T10:43:46.000Z | 2020-06-01T10:58:56.000Z | libmuscle/python/libmuscle/test/test_settings_manager.py | DongweiYe/muscle3 | 0c2fcf5f62995b8639fc84ce1b983c8a8e6248d0 | [
"Apache-2.0"
] | 85 | 2018-03-03T15:10:56.000Z | 2022-03-18T14:05:14.000Z | libmuscle/python/libmuscle/test/test_settings_manager.py | DongweiYe/muscle3 | 0c2fcf5f62995b8639fc84ce1b983c8a8e6248d0 | [
"Apache-2.0"
] | 6 | 2018-03-12T10:47:11.000Z | 2022-02-03T13:44:07.000Z | import pytest
from ymmsl import Reference, Settings
from libmuscle.settings_manager import SettingsManager
@pytest.fixture
def settings_manager() -> SettingsManager:
return SettingsManager()
def test_create(settings_manager):
assert len(settings_manager.base) == 0
assert len(settings_manager.overlay) == 0
def test_get_setting(settings_manager):
ref = Reference
settings_manager.base[ref('test')] = 13
assert settings_manager.get_setting(ref('instance'), ref('test')) == 13
settings_manager.overlay[ref('test2')] = 14
assert settings_manager.get_setting(ref('instance'), ref('test2')) == 14
settings_manager.base[ref('test2')] = 'test'
assert settings_manager.get_setting(ref('instance'), ref('test2')) == 14
settings_manager.overlay = Settings()
assert settings_manager.get_setting(ref('instance'), ref('test2')) == \
'test'
settings_manager.base[ref('test3')] = 'base_test3'
settings_manager.base[ref('instance.test3')] = 'base_instance_test3'
assert settings_manager.get_setting(ref('instance'), ref('test3')) == \
'base_instance_test3'
assert settings_manager.get_setting(ref('instance2'), ref('test3')) == \
'base_test3'
settings_manager.overlay[ref('test3')] = 'overlay_test3'
settings_manager.overlay[ref('instance.test3')] = 'overlay_instance_test3'
assert settings_manager.get_setting(ref('instance'), ref('test3')) == \
'overlay_instance_test3'
assert settings_manager.get_setting(ref('instance2'), ref('test3')) == \
'overlay_test3'
settings_manager.base[ref('instance.test4')] = 'base_test4'
settings_manager.overlay[ref('test4')] = 'overlay_test4'
assert settings_manager.get_setting(ref('instance'), ref('test4')) == \
'base_test4'
assert settings_manager.get_setting(ref('instance[10]'), ref('test4')
) == 'base_test4'
settings_manager.base[ref('instance[10].test5')] = 'base_test5'
settings_manager.overlay[ref('test5')] = 'overlay_test5'
assert settings_manager.get_setting(ref('instance'), ref('test5')) == \
'overlay_test5'
assert settings_manager.get_setting(ref('instance[10]'), ref('test5')
) == 'base_test5'
assert settings_manager.get_setting(ref('instance[11]'), ref('test5')
) == 'overlay_test5'
| 39.193548 | 78 | 0.666667 | 275 | 2,430 | 5.643636 | 0.116364 | 0.299613 | 0.175902 | 0.201031 | 0.664304 | 0.606314 | 0.510954 | 0.510954 | 0.416237 | 0.350515 | 0 | 0.030824 | 0.185597 | 2,430 | 61 | 79 | 39.836066 | 0.753411 | 0 | 0 | 0.130435 | 0 | 0 | 0.211523 | 0.018107 | 0 | 0 | 0 | 0 | 0.326087 | 1 | 0.065217 | false | 0 | 0.065217 | 0.021739 | 0.152174 | 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 | 0 | 0 | 0 | 2 |
30db225ddee8472b0d8ffa4465898e2e0d6cfd49 | 2,297 | py | Python | metflix_remake/movies/migrations/0001_initial.py | luismoa/yummy_metflix_remake | bf6e108f9229c12b44e2dc1ea95e6c3d043cb465 | [
"MIT"
] | 1 | 2021-04-11T15:56:34.000Z | 2021-04-11T15:56:34.000Z | metflix_remake/movies/migrations/0001_initial.py | luismoa/yummy_metflix_remake | bf6e108f9229c12b44e2dc1ea95e6c3d043cb465 | [
"MIT"
] | 16 | 2021-04-10T22:46:43.000Z | 2021-06-08T22:21:00.000Z | metflix_remake/movies/migrations/0001_initial.py | luismoa/yummy_metflix_remake | bf6e108f9229c12b44e2dc1ea95e6c3d043cb465 | [
"MIT"
] | null | null | null | # Generated by Django 3.2 on 2021-04-18 12:13
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Actor',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('_name', models.CharField(max_length=35)),
('nationality', models.CharField(max_length=40)),
('born', models.DateField()),
('sex', models.CharField(max_length=1)),
],
),
migrations.CreateModel(
name='Director',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('_name', models.CharField(max_length=35)),
('nationality', models.CharField(max_length=40)),
],
),
migrations.CreateModel(
name='Movie',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('title', models.CharField(max_length=60)),
('nationality', models.CharField(max_length=40)),
('production_company', models.CharField(max_length=35)),
('year_release', models.PositiveIntegerField()),
('budget', models.PositiveBigIntegerField()),
('box_office', models.PositiveBigIntegerField()),
('running_time', models.PositiveSmallIntegerField()),
('id_director', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='movies.director')),
],
),
migrations.CreateModel(
name='MovieActor',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('_role', models.CharField(max_length=35)),
('is_main_character', models.BooleanField()),
('id_actor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='movies.actor')),
('id_movie', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='movies.movie')),
],
),
]
| 39.603448 | 118 | 0.559861 | 208 | 2,297 | 6.038462 | 0.355769 | 0.107484 | 0.128981 | 0.171975 | 0.467357 | 0.403662 | 0.374204 | 0.374204 | 0.374204 | 0.333599 | 0 | 0.019255 | 0.299086 | 2,297 | 57 | 119 | 40.298246 | 0.76087 | 0.01872 | 0 | 0.48 | 1 | 0 | 0.106128 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.04 | 0 | 0.12 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
30e7bdf6497d386889ded56a333a5a5d6baf230c | 1,802 | py | Python | src/tests/_tests_sampler.py | 4theKnowledge/s-vaal | b35292bb7f209093ff907f8fe81e3e9a5b74a67d | [
"MIT"
] | null | null | null | src/tests/_tests_sampler.py | 4theKnowledge/s-vaal | b35292bb7f209093ff907f8fe81e3e9a5b74a67d | [
"MIT"
] | null | null | null | src/tests/_tests_sampler.py | 4theKnowledge/s-vaal | b35292bb7f209093ff907f8fe81e3e9a5b74a67d | [
"MIT"
] | null | null | null | class Tests(unittest.TestCase):
def _sim_model(self, data: Tensor) -> Tensor:
""" Simulated model for generating uncertainity scores. Intention
is to be a placeholder until real models are used and for testing."""
return torch.rand(size=(data.shape[0],))
def setUp(self):
# Init class
self.sampler = Sampler(budget=10)
# Init random tensor
self.data = torch.rand(size=(10,2,2)) # dim (batch, length, features)
# Params
self.budget = 18
# All sample tests are tested for:
# 1. dims (_, length, features) for input and output Tensors
# 2. batch size == sample size
def test_sample_random(self):
self.assertEqual(self.sampler.sample_random(self.data).shape[1:], self.data.shape[1:])
self.assertEqual(self.sampler.sample_random(self.data).shape[0], self.sampler.budget)
def test_sample_least_confidence(self):
self.assertEqual(self.sampler.sample_least_confidence(model=self.sampler._sim_model, data=self.data).shape[1:], self.data.shape[1:])
self.assertEqual(self.sampler.sample_least_confidence(model=self.sampler._sim_model, data=self.data).shape[0], self.sampler.budget)
# def test_sample_bayesian(self):
# self.assertEqual(self.sampler.sample_bayesian(model=self.sampler._sim_model, no_models=3, data=self.data).shape[1:], self.data.shape[1:])
# self.assertEqual(self.sampler.sample_bayesian(model=self.sampler._sim_model, no_models=3, data=self.data).shape[0], self.sampler.budget)
# def test_adversarial_sample(self):
# self.assertEqual(self.sampler.sample_adversarial(self.data).shape[1:], self.data.shape[1:])
# self.assertEqual(self.sampler.sample_adversarial(self.data).shape[0], self.sampler.budget) | 54.606061 | 147 | 0.694784 | 248 | 1,802 | 4.919355 | 0.254032 | 0.153279 | 0.127869 | 0.170492 | 0.615574 | 0.615574 | 0.602459 | 0.587705 | 0.587705 | 0.496721 | 0 | 0.016767 | 0.172586 | 1,802 | 33 | 148 | 54.606061 | 0.801476 | 0.473918 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.307692 | 1 | 0.307692 | false | 0 | 0 | 0 | 0.461538 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
30f50763b862a4d744b986327b455a91d5154091 | 587 | py | Python | couchbase/deprecation.py | djeebus/couchbase-python-client | fee7a4ea368d4d606601821973e5675b90ff0f7c | [
"Apache-2.0"
] | null | null | null | couchbase/deprecation.py | djeebus/couchbase-python-client | fee7a4ea368d4d606601821973e5675b90ff0f7c | [
"Apache-2.0"
] | null | null | null | couchbase/deprecation.py | djeebus/couchbase-python-client | fee7a4ea368d4d606601821973e5675b90ff0f7c | [
"Apache-2.0"
] | null | null | null | import warnings
def deprecate_module_attribute(mod, deprecated):
"""Return a wrapped object that warns about deprecated accesses"""
deprecated = set(deprecated)
class Wrapper(object):
def __getattr__(self, attr):
if attr in deprecated:
warnings.warn("Property %s is deprecated" % attr)
return getattr(mod, attr)
def __setattr__(self, attr, value):
if attr in deprecated:
warnings.warn("Property %s is deprecated" % attr)
return setattr(mod, attr, value)
return Wrapper() | 30.894737 | 70 | 0.623509 | 65 | 587 | 5.476923 | 0.461538 | 0.044944 | 0.044944 | 0.101124 | 0.342697 | 0.342697 | 0.342697 | 0.342697 | 0.342697 | 0.342697 | 0 | 0 | 0.291312 | 587 | 19 | 71 | 30.894737 | 0.855769 | 0.102215 | 0 | 0.307692 | 0 | 0 | 0.095785 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.076923 | 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 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
30f880c0dea83ffb4766dd9101c87ee7251b2a45 | 292 | py | Python | ex004.py | Jordemar-D-Bousquet/Exercicios_Python | 705d4c83720db033841f01aa843e4dbab08f1423 | [
"MIT"
] | null | null | null | ex004.py | Jordemar-D-Bousquet/Exercicios_Python | 705d4c83720db033841f01aa843e4dbab08f1423 | [
"MIT"
] | null | null | null | ex004.py | Jordemar-D-Bousquet/Exercicios_Python | 705d4c83720db033841f01aa843e4dbab08f1423 | [
"MIT"
] | null | null | null | a = input('Digie algo: ')
print('O tipo primitivo è :',type(a))
print('só tem espaços? ',a.isspace())
print('é numérico? ',a.isalnum())
print('è alfanumérico?', a.isalnum())
print('é alfabético? ', a.isalpha())
print('está em maúscilo?',a.isupper())
print('está em minúsculo? ', a.islower())
| 32.444444 | 41 | 0.657534 | 44 | 292 | 4.363636 | 0.590909 | 0.0625 | 0.135417 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.109589 | 292 | 8 | 42 | 36.5 | 0.738462 | 0 | 0 | 0 | 0 | 0 | 0.428082 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.875 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
a502b22d85d2e90a157111fbc685f19a4baa3e9c | 1,037 | py | Python | orc8r/cloud/deploy/orc8r_deployer/docker/root/scripts/testlib/cluster_factory.py | Aitend/magma | 74fe7b437335728219dfbe54733955bdd652eb60 | [
"BSD-3-Clause"
] | 849 | 2020-07-17T09:15:03.000Z | 2022-03-31T17:11:52.000Z | orc8r/cloud/deploy/orc8r_deployer/docker/root/scripts/testlib/cluster_factory.py | Aitend/magma | 74fe7b437335728219dfbe54733955bdd652eb60 | [
"BSD-3-Clause"
] | 8,386 | 2020-06-23T23:35:30.000Z | 2022-03-31T23:31:28.000Z | orc8r/cloud/deploy/orc8r_deployer/docker/root/scripts/testlib/cluster_factory.py | Aitend/magma | 74fe7b437335728219dfbe54733955bdd652eb60 | [
"BSD-3-Clause"
] | 406 | 2020-06-28T17:02:35.000Z | 2022-03-31T22:03:55.000Z | """
Copyright 2021 The Magma Authors.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
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 testlib.awscluster import AWSClusterFactory
from testlib.cluster_definitions import ClusterTemplate, ClusterType
class ClusterFactory():
def create_cluster(
self, typ, template: str = "", **kwargs
):
if typ == ClusterType.AWS:
return AWSClusterFactory().create_cluster(template, **kwargs)
elif typ == ClusterType.LOCAL:
return LocalClusterFactory().create_cluster(template, **kwargs)
class LocalClusterFactory():
def create_cluster(self, template: ClusterTemplate = None):
pass
| 32.40625 | 75 | 0.742527 | 127 | 1,037 | 6.023622 | 0.614173 | 0.052288 | 0.039216 | 0.052288 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004779 | 0.192864 | 1,037 | 31 | 76 | 33.451613 | 0.9092 | 0.450338 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.153846 | false | 0.076923 | 0.153846 | 0 | 0.615385 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
a51624a1a10fb76a1b66087cfd90080d86d64ef4 | 8,190 | py | Python | backend/sales/migrations/0001_initial.py | StichtingIAPC/swipe | d1ea35a40813d2d5e9cf9edde33148c0a825efc4 | [
"BSD-3-Clause-Clear"
] | null | null | null | backend/sales/migrations/0001_initial.py | StichtingIAPC/swipe | d1ea35a40813d2d5e9cf9edde33148c0a825efc4 | [
"BSD-3-Clause-Clear"
] | null | null | null | backend/sales/migrations/0001_initial.py | StichtingIAPC/swipe | d1ea35a40813d2d5e9cf9edde33148c0a825efc4 | [
"BSD-3-Clause-Clear"
] | null | null | null | # -*- coding: utf-8 -*-
# Generated by Django 1.11.9 on 2018-05-29 18:22
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import money.models
class Migration(migrations.Migration):
initial = True
dependencies = [
('money', '0001_initial'),
('crm', '0001_initial'),
('register', '0001_initial'),
('article', '0001_initial'),
('rma', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Payment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('amount_currency', money.models.CurrencyField(max_length=3)),
('amount', money.models.MoneyField(decimal_places=5, max_digits=28, no_currency_field=True)),
('payment_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='register.PaymentType')),
],
),
migrations.CreateModel(
name='PriceOverride',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('reason', models.CharField(max_length=255)),
('original_price_currency', money.models.CurrencyField(max_length=3)),
('original_price_vat', money.models.VATLevelField(decimal_places=6, max_digits=15)),
('original_price', money.models.PriceField(decimal_places=5, max_digits=28, no_currency_field=True, no_vat_field=True)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Transaction',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date_created', models.DateTimeField(auto_now=True)),
('date_modified', models.DateTimeField(auto_now_add=True)),
('customer', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='crm.Customer')),
('salesperiod', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='register.SalesPeriod')),
('user_created', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='sales_transaction_created_by', to=settings.AUTH_USER_MODEL)),
('user_modified', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='sales_transaction_modified_by', to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='TransactionLine',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date_created', models.DateTimeField(auto_now=True)),
('date_modified', models.DateTimeField(auto_now_add=True)),
('num', models.IntegerField()),
('price_currency', money.models.CurrencyField(max_length=3)),
('price_vat', money.models.VATLevelField(decimal_places=6, max_digits=15)),
('price', money.models.PriceField(decimal_places=5, max_digits=28, no_currency_field=True, no_vat_field=True)),
('count', models.IntegerField()),
('isRefunded', models.BooleanField(default=False)),
('text', models.CharField(max_length=128)),
('order', models.IntegerField(null=True)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='OtherCostTransactionLine',
fields=[
('transactionline_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='sales.TransactionLine')),
('other_cost_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='article.OtherCostType')),
],
options={
'abstract': False,
},
bases=('sales.transactionline',),
),
migrations.CreateModel(
name='OtherTransactionLine',
fields=[
('transactionline_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='sales.TransactionLine')),
],
options={
'abstract': False,
},
bases=('sales.transactionline',),
),
migrations.CreateModel(
name='RefundTransactionLine',
fields=[
('transactionline_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='sales.TransactionLine')),
('creates_rma', models.BooleanField(default=False)),
],
options={
'abstract': False,
},
bases=('sales.transactionline',),
),
migrations.CreateModel(
name='SalesTransactionLine',
fields=[
('transactionline_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='sales.TransactionLine')),
('cost_currency', money.models.CurrencyField(max_length=3)),
('cost', money.models.CostField(decimal_places=5, max_digits=28, no_currency_field=True)),
('article', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='article.ArticleType')),
],
options={
'abstract': False,
},
bases=('sales.transactionline',),
),
migrations.AddField(
model_name='transactionline',
name='accounting_group',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='money.AccountingGroup'),
),
migrations.AddField(
model_name='transactionline',
name='original_price',
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, to='sales.PriceOverride'),
),
migrations.AddField(
model_name='transactionline',
name='transaction',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='sales.Transaction'),
),
migrations.AddField(
model_name='transactionline',
name='user_created',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='sales_transactionline_created_by', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='transactionline',
name='user_modified',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='sales_transactionline_modified_by', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='payment',
name='transaction',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='sales.Transaction'),
),
migrations.AddField(
model_name='refundtransactionline',
name='sold_transaction_line',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='sold_line', to='sales.TransactionLine'),
),
migrations.AddField(
model_name='refundtransactionline',
name='test_rma',
field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, to='rma.TestRMA'),
),
]
| 49.636364 | 207 | 0.615018 | 802 | 8,190 | 6.082294 | 0.168329 | 0.03608 | 0.060271 | 0.094711 | 0.752563 | 0.752563 | 0.682452 | 0.628126 | 0.608856 | 0.564781 | 0 | 0.010657 | 0.255311 | 8,190 | 164 | 208 | 49.939024 | 0.789146 | 0.008303 | 0 | 0.557692 | 1 | 0 | 0.170095 | 0.059613 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.032051 | 0 | 0.057692 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 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 | 2 |
a51ad7fcb66fdc7922166e3d95818005f88682f7 | 228 | py | Python | submissions/chokudai_S001/c.py | m-star18/atcoder | 08e475810516602fa088f87daf1eba590b4e07cc | [
"Unlicense"
] | 1 | 2021-05-10T01:16:28.000Z | 2021-05-10T01:16:28.000Z | submissions/chokudai_S001/c.py | m-star18/atcoder | 08e475810516602fa088f87daf1eba590b4e07cc | [
"Unlicense"
] | 3 | 2021-05-11T06:14:15.000Z | 2021-06-19T08:18:36.000Z | submissions/chokudai_S001/c.py | m-star18/atcoder | 08e475810516602fa088f87daf1eba590b4e07cc | [
"Unlicense"
] | null | null | null | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
n = int(readline())
a = readline().rstrip().decode()
print(a.replace(' ', ','))
| 22.8 | 38 | 0.710526 | 31 | 228 | 5.225806 | 0.548387 | 0.148148 | 0.259259 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.014706 | 0.105263 | 228 | 9 | 39 | 25.333333 | 0.779412 | 0 | 0 | 0 | 0 | 0 | 0.008772 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.125 | 0 | 0.125 | 0.125 | 0 | 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 | 2 |
a51c1d1d49abbdf283412761352fd98316e63050 | 834 | py | Python | wtfapi/api/account/__init__.py | luismasuelli/wherethefuck | 6e68543a804c299be4362836c518e34f10029b48 | [
"MIT"
] | 1 | 2019-11-18T15:02:16.000Z | 2019-11-18T15:02:16.000Z | wtfapi/api/account/__init__.py | luismasuelli/wherethefuck | 6e68543a804c299be4362836c518e34f10029b48 | [
"MIT"
] | null | null | null | wtfapi/api/account/__init__.py | luismasuelli/wherethefuck | 6e68543a804c299be4362836c518e34f10029b48 | [
"MIT"
] | null | null | null | """
Account: This clump of functions manage the account features for the API.
Their functions are like:
- Main account management.
- Register with {username} {email} {password} {confirmation}.
- Login with {username} {password}.
- Reset password {recovery key} with {new password} {confirmation}.
- Logout.
- Requires user logged in.
- Close account.
- Requires user logged in.
- Profile management (All of these require user logged in).
- Get profile.
- Change password with {old password} {new password} {confirmation}.
- Rate place {uuid} with {score}.
- Remove rate from place {uuid}.
- Bookmark place {uuid} (it will add the bookmark to the end).
- Unbookmark place {uuid}.
- Move bookmark {uuid} to the end or, if specified {uuid_other}, before {uuid_other}.
"""
| 37.909091 | 89 | 0.672662 | 105 | 834 | 5.32381 | 0.552381 | 0.064401 | 0.064401 | 0.071556 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.223022 | 834 | 21 | 90 | 39.714286 | 0.862654 | 0.989209 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
eb47b887e8e6f358eff4adc77ea07c79f41f355b | 520 | py | Python | auto_pilot/search/route_finder.py | farrellsc/zAutoPilot | 652d93690237dcb21c3cbdbdad95f917b7fec6e3 | [
"MIT"
] | 1 | 2018-03-05T08:27:58.000Z | 2018-03-05T08:27:58.000Z | auto_pilot/search/route_finder.py | farrellsc/zAutoPilot | 652d93690237dcb21c3cbdbdad95f917b7fec6e3 | [
"MIT"
] | null | null | null | auto_pilot/search/route_finder.py | farrellsc/zAutoPilot | 652d93690237dcb21c3cbdbdad95f917b7fec6e3 | [
"MIT"
] | null | null | null | from auto_pilot.data.world_map import WorldMap
from auto_pilot.common.param import Param
from auto_pilot.data.path import Path
from auto_pilot.common.registrable import Registrable
from typing import TypeVar
T = TypeVar('T')
class RouteFinder(Registrable):
def find_route(self, *params) -> Path:
raise NotImplementedError
@classmethod
def from_params(cls, param: Param) -> 'RouteFinder':
class_choice = param.pop("type")
return Registrable.by_name(class_choice).from_params(param)
| 30.588235 | 67 | 0.753846 | 69 | 520 | 5.521739 | 0.463768 | 0.08399 | 0.136483 | 0.089239 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.159615 | 520 | 16 | 68 | 32.5 | 0.871854 | 0 | 0 | 0 | 0 | 0 | 0.030769 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.153846 | false | 0 | 0.384615 | 0 | 0.692308 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
eb515c714103de39ada1805134b7271ad2c45037 | 1,315 | py | Python | var/www/bin/update-repos.py | feurig/redmine-configuration | 1e8db40ecb3b354c3e3ed377f452eded65819c4c | [
"MIT"
] | 1 | 2020-12-08T00:42:16.000Z | 2020-12-08T00:42:16.000Z | var/www/bin/update-repos.py | feurig/redmine-configuration | 1e8db40ecb3b354c3e3ed377f452eded65819c4c | [
"MIT"
] | null | null | null | var/www/bin/update-repos.py | feurig/redmine-configuration | 1e8db40ecb3b354c3e3ed377f452eded65819c4c | [
"MIT"
] | null | null | null | #!/usr/bin/python
"""------------------------------------------------------------------------update-repos.py
update mirror copies of repos from github and bitbucket.
Author: D. Delmar Davis <don@suspectdevices.com>
Copyleft: (c) 2020 D. Delmar Davis <don@suspectdevices.com>
Liscense: mit
"""
from github import Github
import subprocess
username = "feurig"
repodir = "/var/www/git/"
githubrepos=['feurig/arduino-core-105','feurig/Arduino_STM32_MIDI_project',
'feurig/Cohen','feurig/ems-light','feurig/ems2','feurig/failandflail',
'feurig/libmaple','feurig/libmaplemidi-cma','feurig/maple','feurig/maplebacon',
'feurig/midimonster2012','feurig/pubcrawler','feurig/python-dialog',
'feurig/redmine-configuration','feurig/rtmidi','feurig/Suspect-Devices-Open-Hardware',
'feurig/wsgi-bitbucket-mirror',
]
bitbucketrepos=['feurig/ems-light','feurig/musicbox','feurig/straight-from-hell.com',
'feurig/trashterm','feurig/missinglink-hardware','feurig/bnc-proprietary',
'feurig/ems-firmware','feurig/ems-golang','feurig/ems-framework',
'joedumoulin/sesh','suspectdevicesadmin/ansible']
repos=githubrepos+bitbucketrepos
for repo in repos:
d=repodir+repo.split('/')[1]+".git"
print "updating :",d
subprocess.call(["/usr/bin/git", "fetch", "-q", "--all", "-p"], cwd=d)
| 39.848485 | 90 | 0.681369 | 153 | 1,315 | 5.836601 | 0.581699 | 0.050392 | 0.026876 | 0.033595 | 0.071669 | 0.071669 | 0 | 0 | 0 | 0 | 0 | 0.012573 | 0.092776 | 1,315 | 32 | 91 | 41.09375 | 0.73596 | 0.012167 | 0 | 0 | 0 | 0 | 0.614858 | 0.2913 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.1 | null | null | 0.05 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
eb5b8a9ad30c29272cc7ba2bc458d9895fb78501 | 407 | py | Python | Curso_Em_Video_Python/ex014.py | ThallesTorres/Curso_Em_Video_Python | 95ffbff5a03f11fee41df746604dfe435f385a3b | [
"MIT"
] | null | null | null | Curso_Em_Video_Python/ex014.py | ThallesTorres/Curso_Em_Video_Python | 95ffbff5a03f11fee41df746604dfe435f385a3b | [
"MIT"
] | null | null | null | Curso_Em_Video_Python/ex014.py | ThallesTorres/Curso_Em_Video_Python | 95ffbff5a03f11fee41df746604dfe435f385a3b | [
"MIT"
] | null | null | null | print('''
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
--Seja bem-vindo!
--Exercício 014
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
''')
c = float(input('Informe a temperatura em °C: '))
f = c * 9 / 5 + 32
print(f'A temperatura de {c}°C corresponde a {f:.1f}°F')
print('''
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
--Obrigado pelo uso!
--Desenvolvido por Thalles Torres
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-''')
| 23.941176 | 57 | 0.378378 | 42 | 407 | 3.738095 | 0.666667 | 0.152866 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.023121 | 0.149877 | 407 | 16 | 58 | 25.4375 | 0.421965 | 0 | 0 | 0.357143 | 0 | 0 | 0.792839 | 0.358056 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.214286 | 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 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
eb71f362edf162c6139c62e6e7ec20daca6e41b0 | 292 | py | Python | Calculator /app/__init__.py | 18853477039/social | 368b5b492a0fe6c64925a79d3eaf2aa307b2b9b3 | [
"Apache-2.0"
] | null | null | null | Calculator /app/__init__.py | 18853477039/social | 368b5b492a0fe6c64925a79d3eaf2aa307b2b9b3 | [
"Apache-2.0"
] | null | null | null | Calculator /app/__init__.py | 18853477039/social | 368b5b492a0fe6c64925a79d3eaf2aa307b2b9b3 | [
"Apache-2.0"
] | null | null | null | from flask import Flask
from flask_restful import Api
from app import views
from app.apis import Calculator
def create_app():
app = Flask(__name__)
app.debug = True
api = Api(app)
api.add_resource(Calculator, '/cal_num')
app.register_blueprint(views.bp)
return app
| 19.466667 | 44 | 0.719178 | 43 | 292 | 4.674419 | 0.511628 | 0.089552 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.202055 | 292 | 14 | 45 | 20.857143 | 0.862661 | 0 | 0 | 0 | 0 | 0 | 0.027397 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.090909 | false | 0 | 0.363636 | 0 | 0.545455 | 0.090909 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
eb7bb59bb637cc9451a89a099fd0c6ecce5f00ed | 1,579 | py | Python | ckan_cloud_operator/providers/routers/manager.py | mickeyrouash/ckan-cloud-operator | 10e38f13964af30fe57b07e8d8a3b7521ed69cc2 | [
"MIT"
] | null | null | null | ckan_cloud_operator/providers/routers/manager.py | mickeyrouash/ckan-cloud-operator | 10e38f13964af30fe57b07e8d8a3b7521ed69cc2 | [
"MIT"
] | null | null | null | ckan_cloud_operator/providers/routers/manager.py | mickeyrouash/ckan-cloud-operator | 10e38f13964af30fe57b07e8d8a3b7521ed69cc2 | [
"MIT"
] | null | null | null | from ckan_cloud_operator.config import manager as config_manager
from ckan_cloud_operator.infra import CkanInfra
from ckan_cloud_operator.routers import manager as routers_manager
def initialize(interactive=False):
ckan_infra = CkanInfra(required=False)
config_manager.interactive_set(
{
'env-id': ckan_infra.ROUTERS_ENV_ID,
'default-root-domain': ckan_infra.ROUTERS_DEFAULT_ROOT_DOMAIN,
#'cloudflare-email': ckan_infra.ROUTERS_DEFAULT_CLOUDFLARE_EMAIL,
#'cloudflare-api-key': ckan_infra.ROUTERS_DEFAULT_CLOUDFLARE_AUTH_KEY
},
configmap_name='routers-config',
interactive=interactive
)
routers_manager.install_crds()
# routers_manager.create(
# routers_manager.get_default_infra_router_name(),
# routers_manager.get_traefik_router_spec(
# config_manager.get('default-root-domain', configmap_name='routers-config'),
# config_manager.get('cloudflare-email', configmap_name='routers-config'),
# config_manager.get('cloudflare-api-key', configmap_name='routers-config')
# )
# )
def get_env_id():
return config_get('env-id')
def get_default_root_domain():
return config_get('default-root-domain')
def config_get(key):
return config_manager.get(key, configmap_name='routers-config')
def get_cloudflare_credentials():
return (
config_manager.get('cloudflare-email', configmap_name='routers-config'),
config_manager.get('cloudflare-api-key', configmap_name='routers-config')
)
| 34.326087 | 89 | 0.713743 | 186 | 1,579 | 5.725806 | 0.204301 | 0.097653 | 0.131455 | 0.170892 | 0.368075 | 0.278873 | 0.278873 | 0.240376 | 0.215962 | 0.215962 | 0 | 0 | 0.181761 | 1,579 | 45 | 90 | 35.088889 | 0.824303 | 0.322356 | 0 | 0 | 0 | 0 | 0.132075 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.12 | 0.16 | 0.48 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
eb7c7707b52e00164c3f355e971145567b373f8c | 613 | py | Python | python_modules/dagster-graphql/dagster_graphql/schema/roots/execution_plan.py | dbatten5/dagster | d76e50295054ffe5a72f9b292ef57febae499528 | [
"Apache-2.0"
] | 4,606 | 2018-06-21T17:45:20.000Z | 2022-03-31T23:39:42.000Z | python_modules/dagster-graphql/dagster_graphql/schema/roots/execution_plan.py | dbatten5/dagster | d76e50295054ffe5a72f9b292ef57febae499528 | [
"Apache-2.0"
] | 6,221 | 2018-06-12T04:36:01.000Z | 2022-03-31T21:43:05.000Z | python_modules/dagster-graphql/dagster_graphql/schema/roots/execution_plan.py | dbatten5/dagster | d76e50295054ffe5a72f9b292ef57febae499528 | [
"Apache-2.0"
] | 619 | 2018-08-22T22:43:09.000Z | 2022-03-31T22:48:06.000Z | import graphene
from ..errors import GraphenePipelineNotFoundError, GraphenePythonError
from ..execution import GrapheneExecutionPlan
from ..pipelines.config import GraphenePipelineConfigValidationInvalid
from ..pipelines.pipeline_errors import GrapheneInvalidSubsetError
class GrapheneExecutionPlanOrError(graphene.Union):
class Meta:
types = (
GrapheneExecutionPlan,
GraphenePipelineConfigValidationInvalid,
GraphenePipelineNotFoundError,
GrapheneInvalidSubsetError,
GraphenePythonError,
)
name = "ExecutionPlanOrError"
| 32.263158 | 71 | 0.750408 | 36 | 613 | 12.75 | 0.555556 | 0.052288 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.205546 | 613 | 18 | 72 | 34.055556 | 0.942505 | 0 | 0 | 0 | 0 | 0 | 0.032626 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.466667 | 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 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
eb7d099e8e62c70d03b3773f5b901714a1cfa037 | 2,220 | py | Python | loganalysis.py | jerseyhokie/udacity-loganalysis | 2736471e91fa664d78d96382d055cdc369580d0d | [
"MIT"
] | null | null | null | loganalysis.py | jerseyhokie/udacity-loganalysis | 2736471e91fa664d78d96382d055cdc369580d0d | [
"MIT"
] | null | null | null | loganalysis.py | jerseyhokie/udacity-loganalysis | 2736471e91fa664d78d96382d055cdc369580d0d | [
"MIT"
] | null | null | null | import psycopg2
# !/usr/bin/env python2
# Log Analysis Project
# Udacity Nanodegree Program - Full Stack Web Developer
# Written By: Christopher Baines
# Date: Feb 17, 2018
# Connect to an existing database
try:
db = psycopg2.connect("dbname=news")
except:
print "I am unable to connect to the database"
# Open a cursor to perform database operations
cur = db.cursor()
# Query the database "news" to answer the following questions
# 1. What are the most popular 3 articles of all time?
# Answer: "Title" -- ### views
cur.execute('''SELECT b.title, count (*)
FROM articles AS b
JOIN log AS c
ON substring(path,10,length(path)) = b.slug
GROUP BY
b.title
ORDER BY
count(*) DESC
LIMIT 3;''')
top_articles = cur.fetchall()
print ""
print "What are the most popular 3 articles of all time?"
for ele1, ele2 in top_articles:
print '"{:>}" -- {:<6} views'.format(ele1, ele2)
print ""
# 2. Who are the most popular article authors of all time?
# Answer is list sorted with most views at the top
# Answer: Author name -- ### views
cur.execute('''SELECT a.name, count (*)
FROM authors AS a
JOIN articles AS b
ON a.id = b.author
JOIN log AS c
ON substring(path,10,length(path)) = b.slug
GROUP BY
a.name
ORDER BY
count (*) DESC;''')
top_authors = cur.fetchall()
print "Who are the most popular article authors of all time?"
for ele1, ele2 in top_authors:
print '{:>30} -- {:<6} views'.format(ele1, ele2)
print ""
# 3. On which days did more than 1% of requests lead to errors?
# Answer: long date -- #% errors
cur.execute('''SELECT
tot.log_dt,
err.err_count,
tot.total_count,
err.err_count/(tot.total_count/1.0) AS pct_err
FROM
(SELECT
date(time) AS log_dt,
count(*) AS total_count
FROM
log
GROUP BY
date(time)) AS tot
JOIN (SELECT
date(time) AS log_dt,
count(*) AS err_count
FROM
log
WHERE
status != '200 OK'
GROUP BY
date(time)) AS err
ON tot.log_dt=err.log_dt
WHERE err.err_count/(tot.total_count/1.0)>0.01;''')
top_errors = cur.fetchall()
print "On which days did more than 1% of requests lead to errors?"
for ele1, ele2, ele3, ele4 in top_errors:
print ' {:%B-%d-%Y} -- {:.2%} errors'.format(ele1, ele4)
print ""
# Close communication with the database
cur.close()
db.close()
| 22.2 | 77 | 0.697297 | 376 | 2,220 | 4.06383 | 0.335106 | 0.026178 | 0.026178 | 0.044503 | 0.39267 | 0.370419 | 0.32199 | 0.32199 | 0.230366 | 0.230366 | 0 | 0.027322 | 0.175676 | 2,220 | 99 | 78 | 22.424242 | 0.80765 | 0.282883 | 0 | 0.313433 | 0 | 0 | 0.645408 | 0.101403 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.014925 | null | null | 0.164179 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
eb8691eab341c4abb3d5b7bb68deb7e2eaff3d51 | 2,191 | py | Python | mp3player/sliders.py | bezoadam/MUL | 1e2047155454c12222c418e5b97bd71e74929428 | [
"Unlicense"
] | null | null | null | mp3player/sliders.py | bezoadam/MUL | 1e2047155454c12222c418e5b97bd71e74929428 | [
"Unlicense"
] | null | null | null | mp3player/sliders.py | bezoadam/MUL | 1e2047155454c12222c418e5b97bd71e74929428 | [
"Unlicense"
] | null | null | null | from PyQt5 import QtWidgets, QtGui
class JumpSlider(QtWidgets.QSlider):
'''Custom Slider class for click->jump behaviour
Arguments:
QtWidgets {QSlider} -- Base class
'''
def __init__(self, *args):
QtWidgets.QSlider.__init__(self, *args)
def mousePressEvent(self, e):
'''Handle mouse press event
Arguments:
e {QtGui.QMouseEvent} -- event
'''
self.handleEvent(e)
def mouseMoveEvent(self, e):
'''Handle mouse move event
Arguments:
e {QtGui.QMouseEvent} -- event
'''
self.handleEvent(e)
def mouseReleaseEvent(self, e):
'''Handle mouse release event
Arguments:
e {QtGui.QMouseEvent} -- event
'''
self.handleEvent(e)
def handleEvent(self, e):
'''Base function for handling occured mouse events
Arguments:
e {QtGui.QMouseEvent} -- event
'''
self.setSliderPosition(int(self.minimum() + ((self.maximum() - self.minimum()) * e.x()) / float(self.width())))
def handleValueChanged(self, x):
'''Handler for slider value changed
Arguments:
x {int} -- New value of slider
'''
raise NotImplementedError()
def setup(self, mainWindow):
'''Setup function for connecting parent widgets with child widgets
Arguments:
mainWindow {QtWidgets.QMainWindow} -- Main window of whole application
'''
self.mainWindow = mainWindow
self.valueChanged.connect(self.handleValueChanged)
class VolumeSlider(JumpSlider):
'''VolumeSlider class for customized slider handling volume of player
Arguments:
JumpSlider {JumpSlider} -- Base class of slider
'''
def __init__(self, *args):
super(JumpSlider, self).__init__(*args)
def handleValueChanged(self, x):
'''Handler for slider value changed
Arguments:
x {int} -- New value of slider
'''
self.mainWindow.updateVolumeFromSlider()
class TimeSlider(JumpSlider):
'''TimeSlider class for customized slider handling current time of played song
Arguments:
JumpSlider {JumpSlider} -- Base class of slider
'''
def __init__(self, *args):
super(JumpSlider, self).__init__(*args)
def handleValueChanged(self, x):
'''Handler for slider value changed
Arguments:
x {int} -- New value of slider
'''
self.mainWindow.updateTimeFromSlider()
| 20.100917 | 113 | 0.705157 | 252 | 2,191 | 6.035714 | 0.305556 | 0.026298 | 0.031558 | 0.068376 | 0.4714 | 0.429323 | 0.406312 | 0.406312 | 0.406312 | 0.406312 | 0 | 0.000553 | 0.175262 | 2,191 | 108 | 114 | 20.287037 | 0.841173 | 0.513008 | 0 | 0.407407 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.407407 | false | 0 | 0.037037 | 0 | 0.555556 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
eb9ccd100c93204ed4042e6486d99315edb023ec | 690 | py | Python | babelsubs/tests/utils.py | peerspree/babelsubs | 5c417e37f3cdae4b599cec298b52dc11ac1102b6 | [
"BSD-3-Clause"
] | 11 | 2015-12-06T02:44:14.000Z | 2022-01-27T01:40:45.000Z | babelsubs/tests/utils.py | peerspree/babelsubs | 5c417e37f3cdae4b599cec298b52dc11ac1102b6 | [
"BSD-3-Clause"
] | 9 | 2015-01-05T15:58:11.000Z | 2018-04-27T15:02:31.000Z | babelsubs/tests/utils.py | peerspree/babelsubs | 5c417e37f3cdae4b599cec298b52dc11ac1102b6 | [
"BSD-3-Clause"
] | 4 | 2015-07-22T19:54:11.000Z | 2020-05-20T13:38:03.000Z | """
General helpers needed by the other tests.
"""
import difflib
import os
import babelsubs
def get_data_file_path(file_name):
return os.path.join(os.path.dirname(__file__), 'data', file_name)
def get_subs(file_name,language='en'):
return babelsubs.load_from_file(get_data_file_path(file_name), language=language)
def assert_long_text_equal(text1, text2):
if text1 != text2:
diff = difflib.unified_diff(text1.splitlines(True),
text2.splitlines(True),
fromfile="string1",
tofile="string2")
raise AssertionError("strings differ: %s" % ''.join(diff))
| 30 | 85 | 0.623188 | 82 | 690 | 4.987805 | 0.54878 | 0.07824 | 0.05379 | 0.07335 | 0.112469 | 0.112469 | 0 | 0 | 0 | 0 | 0 | 0.015873 | 0.269565 | 690 | 22 | 86 | 31.363636 | 0.795635 | 0.06087 | 0 | 0 | 0 | 0 | 0.059375 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 1 | 0.214286 | false | 0 | 0.214286 | 0.142857 | 0.571429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
eb9f1e8ba3dc2bece469e7b4595e3ca0fe15097c | 326 | py | Python | Task1E.py | Saul-Morrison/group33-floodwarning | d8a73d6b8fab6093cb16a204e6e47bf07ba86113 | [
"MIT"
] | 1 | 2022-01-25T19:52:29.000Z | 2022-01-25T19:52:29.000Z | Task1E.py | Saul-Morrison/group33-floodwarning | d8a73d6b8fab6093cb16a204e6e47bf07ba86113 | [
"MIT"
] | null | null | null | Task1E.py | Saul-Morrison/group33-floodwarning | d8a73d6b8fab6093cb16a204e6e47bf07ba86113 | [
"MIT"
] | 1 | 2022-02-08T14:44:36.000Z | 2022-02-08T14:44:36.000Z | from distutils.command.build import build
from geo import stations_with_river
from geo import stations_by_river
from floodsystem.stationdata import build_station_list
from geo import rivers_by_station_number
stations = build_station_list()
N = 11
station_number = rivers_by_station_number(stations, N)
print (station_number) | 32.6 | 54 | 0.858896 | 49 | 326 | 5.387755 | 0.387755 | 0.19697 | 0.147727 | 0.159091 | 0.219697 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006826 | 0.101227 | 326 | 10 | 55 | 32.6 | 0.894198 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.555556 | 0 | 0.555556 | 0.111111 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
ebad868b80864602bc321691890153e4b9fe6466 | 1,649 | py | Python | biblioteca/libro.py | Mario999X/BibliotecaPython | b98200e1c1fb819c18cc439aca990b09b1e61174 | [
"MIT"
] | null | null | null | biblioteca/libro.py | Mario999X/BibliotecaPython | b98200e1c1fb819c18cc439aca990b09b1e61174 | [
"MIT"
] | null | null | null | biblioteca/libro.py | Mario999X/BibliotecaPython | b98200e1c1fb819c18cc439aca990b09b1e61174 | [
"MIT"
] | null | null | null | # Clase libro | libro() significa heredar de otra clase --> libro(biblioteca) | hijo(padre).
class libro:
# Contructor de libro, con las variables introducidas | __XX = privado
def __init__(self, isbn = "", titulo = "", autor = "", genero = "", portada = "", sinopsis = "", ejemplares = 0):
self.__isbn=isbn
self.__titulo=titulo
self.__autor=autor
self.__genero=genero
self.__portada=portada
self.__sinopsis=sinopsis
self.__ejemplares=ejemplares
# Generación de property y setter de las distintas variables.
@property
def isbn(self):
return self.__isbn
@isbn.setter
def isbn(self,a):
self.__isbn=a
@property
def titulo(self):
return self.__titulo
@titulo.setter
def titulo(self,a):
self.__titulo=a
@property
def autor(self):
return self.__autor
@autor.setter
def autor(self,a):
self.__autor=a
@property
def genero(self):
return self.__genero
@genero.setter
def genero(self,a):
self.__genero=a
@property
def portada(self):
return self.__portada
@portada.setter
def portada(self,a):
self.__portada=a
@property
def sinopsis(self):
return self.__sinopsis
@sinopsis.setter
def sinopsis(self,a):
self.__sinopsis=a
@property
def ejemplares(self):
return self.__ejemplares
@ejemplares.setter
def ejemplares(self,a):
self.__ejemplares=a
| 22.902778 | 118 | 0.571862 | 176 | 1,649 | 5.085227 | 0.198864 | 0.086034 | 0.109497 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.000912 | 0.334748 | 1,649 | 71 | 119 | 23.225352 | 0.81495 | 0.133414 | 0 | 0.137255 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.294118 | false | 0 | 0 | 0.137255 | 0.45098 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
ebaf7e3f9c3dec9d85ba1d8ed0ec61567839cfe3 | 795 | py | Python | util.py | netdude78/python_sqlite_dal | 352f0ee9fb933933aeb75fad1e482acbd4cb0ef2 | [
"MIT"
] | 1 | 2020-05-15T04:45:33.000Z | 2020-05-15T04:45:33.000Z | util.py | netdude78/python_sqlite_dal | 352f0ee9fb933933aeb75fad1e482acbd4cb0ef2 | [
"MIT"
] | null | null | null | util.py | netdude78/python_sqlite_dal | 352f0ee9fb933933aeb75fad1e482acbd4cb0ef2 | [
"MIT"
] | null | null | null | #!/usr/bin/python
def synchronized(func):
"""synchronized decorator function
This method allows the ability to add @synchronized decorator to any method.
This method will wrap the decorated function around a call to threading.Lock
ensuring only a single execution of the decorated method/line of code at a time.
Use for ensuring thread-safe DB operations such as inserts where a last_inserted_id
type action is taking place.
Arguments:
func {*args, **kwargs} -- [anything passed to the func will be passed through]
Returns:
the wrapped method.
"""
import threading
func.__lock__ = threading.Lock()
def synced_func(*args, **kws):
with func.__lock__:
return func(*args, **kws)
return synced_func | 31.8 | 87 | 0.685535 | 107 | 795 | 4.981308 | 0.607477 | 0.045028 | 0.041276 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.246541 | 795 | 25 | 88 | 31.8 | 0.889816 | 0.661635 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.142857 | 0 | 0.714286 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
ebb74e93d9553620a303417e63f11ef7a4f68ab9 | 363 | py | Python | Lection 1. Graphs representation/_gens/traingen.py | gennadiychistyakov/graphs-theory-materials | 191db41634d2bb9a0661963d489a34ba731506f1 | [
"MIT"
] | null | null | null | Lection 1. Graphs representation/_gens/traingen.py | gennadiychistyakov/graphs-theory-materials | 191db41634d2bb9a0661963d489a34ba731506f1 | [
"MIT"
] | null | null | null | Lection 1. Graphs representation/_gens/traingen.py | gennadiychistyakov/graphs-theory-materials | 191db41634d2bb9a0661963d489a34ba731506f1 | [
"MIT"
] | null | null | null | import os
data = [(10, .1), (10, .5), (20, .2), (30, .7), (100, .1), (100, .5), (100, .9), (1000, .1), (1000, .5), (1000, .9)]
os.system("javac GraphsGenerator.java")
for i, j in enumerate(data):
os.system("java GraphsGenerator simplegraph " + str(j[0]) + " " + str(j[1]) + " > " + ("0" + str(i + 1) + ".in")[-5:])
os.system("del GraphsGenerator.class") | 45.375 | 120 | 0.526171 | 56 | 363 | 3.410714 | 0.482143 | 0.125654 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.147651 | 0.179063 | 363 | 8 | 121 | 45.375 | 0.493289 | 0 | 0 | 0 | 0 | 0 | 0.257703 | 0.058824 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.166667 | 0 | 0 | 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 | 2 |
ebb8412939eecb5d0164f65c85d1de06b5cf3e78 | 1,027 | py | Python | rltetris/environments.py | awoh/tetris_game | a43b7f4fa7c6c98be4212d622b81d32bc54d01ce | [
"MIT"
] | 1 | 2019-04-13T21:14:49.000Z | 2019-04-13T21:14:49.000Z | rltetris/environments.py | awoh/tetris_game | a43b7f4fa7c6c98be4212d622b81d32bc54d01ce | [
"MIT"
] | null | null | null | rltetris/environments.py | awoh/tetris_game | a43b7f4fa7c6c98be4212d622b81d32bc54d01ce | [
"MIT"
] | null | null | null | # Environments
# Put all custom environments here
import numpy as np
import gym
import logging
logger = logging.getLogger(__name__)
import sys
sys.path.append("../gym_tetris")
from gym_tetris import TetrisEnvironment
# can just download premade tetris environment online
# to register, look at torchkit (good example of base environment and multiple subtypes)
class FeatureWrapper(object):
def __init__(self,env):
self._env = env
self._terminal = env._terminal
def set_state(self, state):
self._env.set_state(state)
def step(self,action):
s_tp1,r_tp1,terminal,inf = self._env.step(action)
self._terminal = self._env._terminal
board_features = self._env.get_features()
return board_features,r_tp1,terminal,inf
def get_action_set(self):
return self._env.get_action_set()
def reset(self):
self._env.reset()
self._terminal = self._env._terminal
# @property
def state(self):
return self._env.get_features()
| 25.675 | 88 | 0.701071 | 137 | 1,027 | 4.978102 | 0.437956 | 0.102639 | 0.043988 | 0.043988 | 0.13783 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003699 | 0.210321 | 1,027 | 39 | 89 | 26.333333 | 0.837238 | 0.1889 | 0 | 0.08 | 0 | 0 | 0.015719 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.24 | false | 0 | 0.2 | 0.08 | 0.6 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
ebc54d91e8bd6d32639984a0ad190ab7bf741702 | 1,651 | py | Python | rej/backend.py | snickell/rej | c1cd0ebfbc786580ec4b88836be652c7b8bb3564 | [
"MIT"
] | 2 | 2020-04-09T10:28:43.000Z | 2020-04-09T12:46:01.000Z | rej/backend.py | snickell/rej | c1cd0ebfbc786580ec4b88836be652c7b8bb3564 | [
"MIT"
] | null | null | null | rej/backend.py | snickell/rej | c1cd0ebfbc786580ec4b88836be652c7b8bb3564 | [
"MIT"
] | 1 | 2020-04-09T10:28:49.000Z | 2020-04-09T10:28:49.000Z | from ipywidgets import DOMWidget, trait_types
from traitlets import Unicode, Int
from .geotiff_to_png import geotiff_to_png
EXTENSION_VERSION="0.1.0"
class Rej(DOMWidget):
_view_name = Unicode('RejDOMWidget').tag(sync=True)
_model_name = Unicode('RejModel').tag(sync=True)
_view_module = Unicode('ceresimaging-rej').tag(sync=True)
_model_module = Unicode('ceresimaging-rej').tag(sync=True)
_view_module_version = Unicode(EXTENSION_VERSION).tag(sync=True)
_model_module_version = Unicode(EXTENSION_VERSION).tag(sync=True)
# Disabled for now, enable this if we want to pass direct memory access rather than via URL
#imagery = trait_types.CByteMemoryView(help="The media data as a memory view of bytes.").tag(sync=True)
#reference = trait_types.CByteMemoryView(help="The media data as a memory view of bytes.").tag(sync=True)
def __init__(self, img, reference_img, *args, **kwargs):
print("Converting to PNG first...")
super(Rej, self).__init__(*args, **kwargs)
#self.img = img
#self.reference_img = reference_img
# TODO: use self.imagery and self.reference to pass this entirely
# in memory, saving the slowness of writing out to S3!
self.img = geotiff_to_png(img)[0]
self.reference_img = geotiff_to_png(reference_img)[0]
print(f"Loading: {self.img} and {self.reference_img}")
# def __init__(self, img, reference_img, *args, **kwargs):
# super().__init__(*args, **kwargs)
# self.img = img
# self.reference_img = reference_img
def register(img, reference_img):
return Rej(img, reference_img)
| 40.268293 | 109 | 0.697759 | 229 | 1,651 | 4.790393 | 0.344978 | 0.120328 | 0.080219 | 0.043756 | 0.474932 | 0.448496 | 0.448496 | 0.377393 | 0.226071 | 0.226071 | 0 | 0.004478 | 0.188371 | 1,651 | 40 | 110 | 41.275 | 0.814179 | 0.37129 | 0 | 0 | 0 | 0 | 0.123782 | 0 | 0 | 0 | 0 | 0.025 | 0 | 1 | 0.105263 | false | 0 | 0.157895 | 0.052632 | 0.684211 | 0.105263 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
ebca0b16a6dfe49cdb45965f3cce30ebe81a9952 | 369 | py | Python | app/users/models.py | alexandre/flask-rest-template | 206729ea7c229c4ff428dc9161d23fb3e1912026 | [
"Unlicense"
] | 77 | 2015-05-18T11:02:28.000Z | 2019-05-30T09:36:52.000Z | app/users/models.py | alexandre-old/flask-rest-template | 206729ea7c229c4ff428dc9161d23fb3e1912026 | [
"Unlicense"
] | 11 | 2015-05-03T22:12:17.000Z | 2018-03-26T13:17:19.000Z | app/users/models.py | alexandre/flask-rest-template | 206729ea7c229c4ff428dc9161d23fb3e1912026 | [
"Unlicense"
] | 21 | 2015-08-20T02:35:13.000Z | 2019-02-26T04:59:01.000Z | from app.extensions import db
class User(db.Document):
"""User model """
username = db.StringField()
password = db.StringField()
def to_json2(self):
"""Returns a json representantion of the user.
:returns: a json object.
"""
return {
'id': str(self.id),
'username': self.username
}
| 17.571429 | 54 | 0.544715 | 40 | 369 | 5 | 0.65 | 0.13 | 0.12 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004065 | 0.333333 | 369 | 20 | 55 | 18.45 | 0.808943 | 0.216802 | 0 | 0 | 0 | 0 | 0.038462 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0.111111 | 0.111111 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
ebd2cf9bde84855a7e33499b66eff5b05a50be68 | 14,895 | py | Python | Compilador Python/DeuxExMachinaParser.py | xergioalex/python-compiler-academic-project | b99a80a4c2d7241a5ec4eacc8d8486e60aa70e11 | [
"MIT"
] | null | null | null | Compilador Python/DeuxExMachinaParser.py | xergioalex/python-compiler-academic-project | b99a80a4c2d7241a5ec4eacc8d8486e60aa70e11 | [
"MIT"
] | null | null | null | Compilador Python/DeuxExMachinaParser.py | xergioalex/python-compiler-academic-project | b99a80a4c2d7241a5ec4eacc8d8486e60aa70e11 | [
"MIT"
] | null | null | null | #-------------------------------------------------------------------------------
# Nombre: Deus Ex Machine
# Autores: Sergio Alexander Florez Galeano
# Camilo Fernandez Bernal
# Descripcion: Analizador Semantico de nuestro Compilador
#-------------------------------------------------------------------------------
import sys
import DeuxExMachinaLexico
import ply.yacc as yacc
import DeuxExMachinaTablaTiposSimbolos as tabla
# Obtener mapa de tokens
tokens = DeuxExMachinaLexico.tokens
# ---------------------------------------------------------------
# ERRORS
# ---------------------------------------------------------------
# Clase para Errores Semanticos
class ErrorSemantico(Exception):
def __init__(self, valor):
self.valor = valor
def __str__(self):
return repr((self.valor))
# Clase para Errores Sintacticos
class rrorSintactico(Exception):
def __init__(self, valor):
self.valor = valor
def __str__(self):
return repr((self.valor))
# ---------------------------------------------------------------
# PARSER
# ---------------------------------------------------------------
# Diccionario de Simbolos y Tipos
Tabla= tabla.Tabla()
# Listas Auxiliares
librerias=[]
constantes=[]
tempparametros = []
# Precedencia de Operadores
precedence=(
('left','SUMA','MENOS'),
('left','MULT','DIV'),
)
#Programa: Es el no terminal PRINCIPAL que llama toda la gramatica e inicia todo.
def p_programa(p):
#'programa : CIERRELINEA NICK CIERRELINEA importarlibrerias prototipos constantes global principal funciones'
'''programa : CIERRELINEA NICK CIERRELINEA importarlibrerias constantes declaraciones prototipos principal funciones
| CIERRELINEA NICK CIERRELINEA importarlibrerias principal
| CIERRELINEA NICK CIERRELINEA importarlibrerias declaraciones principal
| CIERRELINEA NICK CIERRELINEA principal
| CIERRELINEA NICK CIERRELINEA constantes principal
| CIERRELINEA NICK CIERRELINEA declaraciones principal
| CIERRELINEA NICK CIERRELINEA constantes declaraciones principal
| CIERRELINEA NICK CIERRELINEA importarlibrerias constantes principal
| CIERRELINEA NICK CIERRELINEA importarlibrerias constantes declaraciones principal
| CIERRELINEA NICK CIERRELINEA prototipos principal funciones
| CIERRELINEA NICK CIERRELINEA importarlibrerias prototipos principal funciones
| CIERRELINEA NICK CIERRELINEA importarlibrerias constantes prototipos principal funciones
| CIERRELINEA NICK CIERRELINEA constantes prototipos principal funciones
| CIERRELINEA NICK CIERRELINEA constantes declaraciones prototipos principal funciones
'''
pass
## for i in p:
## print i
#LISTO
#Importar Libreria
def p_importarlibrerias_1(p):
'''importarlibrerias : IMPORTAR CADVALOR CIERRELINEA
| importarlibrerias IMPORTAR CADVALOR CIERRELINEA
'''
if(len(p)==4):
librerias.append(p[2])
else:
librerias.append(p[3])
p[0]=librerias
#Prototipos de funciones
def p_prototipos(p):
'''prototipos : prototipofuncion
| prototipos prototipofuncion '''
pass
def p_prototipofuncion(p):
'''prototipofuncion : tipodato MACRO NICK IZQPAREN DERPAREN
| tipodato MACRO NICK IZQPAREN declaracionparametros DERPAREN'''
pass
def p_declaracionparametros(p):
'''declaracionparametros : nuevoparametro
| declaracionparametros COMA nuevoparametro '''
pass
def p_nuevoparametro(p):
'''nuevoparametro : tipodato NICK
| tipodato IZQCORCHET DERCORCHET NICK'''
pass
#LISTO
#Tipos de dato
def p_tipodato(p):
'''tipodato : ENTERO
| REAL
| CARACTER
| CADENA
| BOOLEANO'''
p[0]=p[1]
#LISTO
#Constantes
def p_constantes(p):
'''constantes : CONSTANTE tipodato ASIGNAR NICK dato CIERRELINEA
| constantes CONSTANTE tipodato ASIGNAR NICK dato CIERRELINEA'''
if(len(p)==7):
if(not(Tabla.existeTipo(p[4])) and p[2]==p[5][1]):
Tabla.addTipo(p[4],p[2],-1,1,-1,-1)
Tabla.addSimbolo(p[4],'constante',p[2],-1,[],p[5][0])
constantes.append(p[4])
else:
raise ErrorSemantico("El simbolo '"+p[4]+"' ya existe o los tipos no coinciden")
else:
if(not(Tabla.existeTipo(p[5])) and p[3]==p[6][1]):
Tabla.addTipo(p[5],p[3],-1,1,-1,-1)
Tabla.addSimbolo(p[5],'constante',p[3],-1,[],p[6][0])
constantes.append(p[5])
else:
raise ErrorSemantico("El simbolo '"+p[5]+"' ya existe o los tipos no coinciden")
p[0]=constantes
#LISTO
#Datos
def p_dato_1(p):
'''dato : ENTVALOR '''
p[0]=[p[1],"entero"]
#LISTO
def p_dato_2(p):
'''dato : REALVALOR '''
p[0]=[p[1],"real"]
#LISTO
def p_dato_3(p):
'''dato : CARVALOR '''
p[0]=[p[1],"caracter"]
#LISTO
def p_dato_4(p):
'''dato : CADVALOR '''
p[0]=[p[1],"cadena"]
#LISTO
def p_dato_5(p):
'''dato : BOOLVALOR '''
p[0]=[p[1],"booleano"]
def p_datofuncion(p):
'datofuncion : NICK IZQPAREN parametros DERPAREN'
pass
def p_parametros(p):
'''parametros : dato
| parametros COMA dato
'''
if(len(p)==2):
tempparametros.append(p[1])
else:
tempparametros.append(p[3])
p[0]=tempparametros
def p_datoarreglo(p):
'''datoarreglo : NICK IZQCORCHET ENTVALOR DERCORCHET '''
if(Tabla.existeTipo(p[1])):
aux = int(p[3])
auxarray=Tabla.getTablaSimbolos()[p[1]]
auxtipo = auxarray.getTipo()
temp = [auxarray.getDireccion()[aux],auxtipo]
p[0]= temp
else:
raise ErrorSemantico("El simbolo '"+p[1]+"' no existe")
#Operador ternario
def p_operadorternario(p):
'operadorternario : IZQPAREN expresion DERPAREN TERNARIO expresion DOSPUNTOS expresion '
pass
def p_expresion(p):
'''expresion : expresionsimple
| expresioncompuesta
'''
p[0]=p[1]
#Expresiones
def p_expresionsimple_1(p):
'''expresionsimple : NICK'''
if(Tabla.existeTipo(p[1])):
temp=Tabla.getTablaTipos()[p[1]]
temp1= Tabla.getTablaSimbolos()[p[1]]
p[0]=[temp1.getDireccion(),temp.getTipoBase()]
else:
raise ErrorSemantico("El simbolo '"+p[1]+"' no existe")
def p_expresionsimple_2(p):
'''expresionsimple : datofuncion'''
pass
#LISTO
def p_expresionsimple_3(p):
'''expresionsimple : dato'''
p[0]=p[1]
def p_expresionsimple_4(p):
'''expresionsimple : operadorternario'''
pass
def p_expresionsimple_5(p):
'''expresionsimple : datoarreglo'''
p[0] = p[1]
def p_expresioncompuesta(p):
'''expresioncompuesta : operador expresion
| IZQPAREN expresion DERPAREN
| operador IZQPAREN expresion DERPAREN IZQPAREN expresion DERPAREN
| operador IZQPAREN expresion DERPAREN dato
| operador dato expresion
'''
pass
#LISTO
#Operadores
def p_operador(p):
'''operador : SUMA
| MENOS
| MASMAS
| MENOSMENOS
| MULT
| DIV
| MODULO
| EXP
| Y
| O
| NEGAR
| MENOR
| MAYOR
| MENORIGUAL
| MAYORIGUAL
| IGUAL
| DIFERENTE'''
p[0]=p[1]
#Variables y Arreglos Globales y Estructuras
def p_declaraciones(p):
'''declaraciones : declaracion
| declaracionestructura
| declaraciones declaracion
| declaraciones declaracionestructura
'''
pass
#Declaracion de variables y arreglos
def p_declaracion(p):
'''declaracion : tipodato restodeclaracion CIERRELINEA'''
if(len(p[2])==3):
pass
elif(len(p[2])==2):
if(not(p[2][1]==p[1])):
mensaje = "Los tipos de dato no coinciden"
raise ErrorSemantico(mensaje)
else:
Tabla.setTipoTablas(p[2],p[1])
#LISTO
def p_restodeclaracion_1(p):
'''restodeclaracion : NICK
| IZQCORCHET DERCORCHET NICK
| IZQCORCHET DERCORCHET ASIGNAR NICK tipodato IZQCORCHET ENTVALOR DERCORCHET
'''
if(len(p)==4):
if(not(Tabla.existeTipo(p[3]))):
Tabla.addTipo(p[3],-1,-1,1,-1,-1)
Tabla.addSimbolo(p[3],'arreglo',-1,-1,[],-1)
p[0]=p[3]
else:
raise ErrorSemantico("El simbolo '"+p[3]+"' ya existe")
elif(len(p)==9):
if(not(Tabla.existeTipo(p[4]))):
aux =int(p[7])-1
Tabla.addTipo(p[4],p[5],-1,p[7],0,aux)
Tabla.addSimbolo(p[4],'arreglo',p[5],-1,[],[0]*int(p[7]))
p[0]=[p[4],p[5]]
else:
raise ErrorSemantico("El simbolo '"+p[4]+"' ya existe")
else:
if(not(Tabla.existeTipo(p[1]))):
Tabla.addTipo(p[1],-1,-1,1,-1,-1)
Tabla.addSimbolo(p[1],'variable',-1,-1,[],-1)
p[0]=p[1]
else:
raise ErrorSemantico("El simbolo '"+p[1]+"' ya existe")
def p_restodeclaracion_2(p):
'''restodeclaracion : asignacion'''
#p[1]=[operador,nick,valor,tipo]
if(p[1][0]=='='):
if(not(Tabla.existeTipo(p[1][1]))):
Tabla.addTipo(p[1][1],p[1][3],-1,1,-1,-1)
Tabla.addSimbolo(p[1][1],'variable',p[1][3],-1,[],p[1][2])
p[0]=[p[1][1],p[1][3]]
else:
raise ErrorSemantico("El simbolo '"+p[1][1]+"' ya existe")
else:
raise ErrorSemantico("El operador '"+p[1][0]+"' no se puede usar en una declaracion debe usarse '='")
def p_restodeclaracion_3(p):
'''restodeclaracion : IZQCORCHET DERCORCHET ASIGNAR NICK IZQCORCHET parametros DERCORCHET'''
parametros=p[6]
tempparametros=[]
tipoaux= parametros[0][1]
lista = []
for i in parametros:
if(tipoaux!=i[1]):
raise ErrorSemantico("Los tipos del array '"+str(p[6])+"' no coinciden")
tipoaux=i[1]
lista.append(i[0])
if(not(Tabla.existeTipo(p[4]))):
Tabla.addTipo(p[4],tipoaux,-1,len(p[6]),0,len(p[6])-1)
Tabla.addSimbolo(p[4],'arreglo',tipoaux,-1,[],lista)
p[0]=[p[4],tipoaux]
else:
raise ErrorSemantico("El simbolo '"+p[4]+"' ya existe")
#print p[6]
def p_declaracionestructura(p):
'declaracionestructura : ESTRUCTURA NICK IZQPAREN declaraciones DERPAREN'
pass
#Funcion Principal
def p_principal(p):
'principal : VACIO MACRO PRINCIPAL IZQPAREN DERPAREN IZQLLAVE bloque DERLLAVE'
pass
#Bloque
def p_bloque(p):
'''bloque : sentencia
| bloque sentencia '''
pass
#Sentencias
def p_sentencia(p):
'''sentencia : asignacion CIERRELINEA
| sentenciasalto
| sentencialeer
| sentenciaescribir
| condicionalsi
| ciclohacer
| ciclomientras
| ciclopara
| selector
'''
pass
#Estructuras De Control
#Ciclo hacer
def p_ciclohacer(p):
'ciclohacer : HACER IZQLLAVE bloque DERLLAVE MIENTRAS IZQPAREN expresion DERPAREN'
pass
#Ciclo mientras
def p_ciclomientras(p):
'ciclomientras : MIENTRAS IZQPAREN expresion DERPAREN IZQLLAVE bloque DERLLAVE'
pass
#Ciclo para
def p_ciclopara(p):
'ciclopara : PARA IZQPAREN declaracion DOSPUNTOS expresion DOSPUNTOS asignacion DERPAREN IZQLLAVE bloque DERLLAVE'
pass
#Estructura Selector
def p_selector(p):
'selector : SELECTOR IZQPAREN variablecontrol DERPAREN IZQLLAVE casos DERLLAVE'
pass
def p_variablecontrol(p):
'variablecontrol : NICK'
pass
def p_casos(p):
'''casos : casoselector
| casoselector casoespecial'''
pass
def p_casoselector(p):
'''casoselector : CASO valorcontrol DOSPUNTOS bloque
| casoselector CASO valorcontrol DOSPUNTOS bloque '''
pass
def p_valorcontrol(p):
'''valorcontrol : ENTVALOR
| CARVALOR'''
pass
def p_casoespecial(p):
'casoespecial : DEFECTO DOSPUNTOS bloque'
pass
def p_condicionalsi (p):
'''condicionalsi : SI IZQPAREN expresion DERPAREN IZQLLAVE bloque DERLLAVE SINO IZQLLAVE bloque DERLLAVE
| SI IZQPAREN expresion DERPAREN IZQLLAVE bloque DERLLAVE'''
pass
#LISTO
#Sentencia Salto
def p_sentenciasalto(p):
'sentenciasalto : tokensalto CIERRELINEA'
p[0]=p[1]
#LISTO
def p_tokensalto(p):
'''tokensalto : ROMPER
| CONTINUE
| RETORNO'''
p[0]=p[1]
#LISTO
def p_sentencialeer(p):
'sentencialeer : LEER IZQPAREN DERPAREN'
pass
#LISTO
def p_sentenciaescribir(p):
'sentenciaescribir : IMPRIMIR IZQPAREN info DERPAREN CIERRELINEA'
print p[4]
def p_info(p):
'''info : dato
| dato COMA dato'''
pass
#Asignacion
def p_asignacion_1(p):
'''asignacion : ASIGNAR NICK expresion'''
#p[0]=[operador,nick,valor,tipo]
p[0]=[p[1],p[2],p[3][0],p[3][1]]
def p_asignacion_2(p):
'''asignacion : operadorasignacion NICK expresion'''
#p[0]=[operador,nick,valor,tipo]
p[0]=[p[1],p[2],p[3][0],p[3][1]]
def p_operadorasignacion(p):
'''operadorasignacion : SUMAIGUAL
| MENOSIGUAL
| MULTIGUAL
| DIVIGUAL'''
p[0]=p[1]
#--------------------------------------------------------------------------------
#Funciones
def p_funciones(p):
'''funciones : declaracionfuncion
| funciones declaracionfuncion '''
pass
#Declaracion de funciones
def p_declaracionfuncion(p):
'''declaracionfuncion : VACIO MACRO NICK IZQPAREN DERPAREN IZQLLAVE bloque DERLLAVE
| tipodato MACRO NICK IZQPAREN DERPAREN IZQLLAVE bloque DERLLAVE
| tipodato MACRO NICK IZQPAREN declaracionparametros DERPAREN IZQLLAVE bloque DERLLAVE'''
pass
# ---------------------------------------------------------------
# ERROR
# ---------------------------------------------------------------
def p_error(p):
mensaje = "Usted tiene un error de sintaxis en alguna parte de su codigo. Este puede estar cerca de la linea %d. " % p.lineno+", y esta cerca de '" + str(p.value)+"'. Buena suerte encontrandolo."
raise ErrorSintactico(mensaje)
# ---------------------------------------------------------------
# CONSTRUIR GRAMATICA
# ---------------------------------------------------------------
import profile
yacc.yacc(method="LALR",debug=1)
#profile.run("yacc.yacc(method='LALR')")
try:
#fle = sys.argv[1]
f= open("ejemplo_1.txt","r")
dato= f.read()
yacc.parse(dato)
f.close()
except EOFError:
sys.exit()
Tabla.imprimir()
| 29.263261 | 200 | 0.580463 | 1,603 | 14,895 | 5.33874 | 0.177792 | 0.025707 | 0.007011 | 0.007946 | 0.344356 | 0.258004 | 0.189647 | 0.09792 | 0.067422 | 0.042884 | 0 | 0.020056 | 0.253508 | 14,895 | 508 | 201 | 29.320866 | 0.749618 | 0.129977 | 0 | 0.315353 | 0 | 0.004149 | 0.195762 | 0.00273 | 0 | 0 | 0 | 0.001969 | 0 | 0 | null | null | 0.124481 | 0.024896 | null | null | 0.004149 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
ebe37bb547eae053e617e5f40e5b40fc9837cb42 | 369 | py | Python | preprocessing/normalization/TokenizeData.py | mrForest13/sentiment-analysis | f747800b78dbf5d9c598d52cbe9f92a44b90cc42 | [
"Apache-2.0"
] | null | null | null | preprocessing/normalization/TokenizeData.py | mrForest13/sentiment-analysis | f747800b78dbf5d9c598d52cbe9f92a44b90cc42 | [
"Apache-2.0"
] | null | null | null | preprocessing/normalization/TokenizeData.py | mrForest13/sentiment-analysis | f747800b78dbf5d9c598d52cbe9f92a44b90cc42 | [
"Apache-2.0"
] | null | null | null | from preprocessing.Processor import Processor
class TokenizeDataProcessor(Processor):
def __init__(self):
super().__init__()
def process(self, data):
data['text'] = self.tokenize(data)
return self.next_processor.process(data)
@staticmethod
def tokenize(data):
return data['text'].swifter.apply(lambda x: x.split())
| 21.705882 | 62 | 0.669377 | 41 | 369 | 5.804878 | 0.536585 | 0.067227 | 0.151261 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.211382 | 369 | 16 | 63 | 23.0625 | 0.817869 | 0 | 0 | 0 | 0 | 0 | 0.02168 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3 | false | 0 | 0.1 | 0.1 | 0.7 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
ccd8880b2298afef87350e3332014fcb6ebb68c9 | 2,087 | py | Python | lib/surface/compute/url_maps/config/export.py | google-cloud-sdk-unofficial/google-cloud-sdk | 2a48a04df14be46c8745050f98768e30474a1aac | [
"Apache-2.0"
] | 2 | 2019-11-10T09:17:07.000Z | 2019-12-18T13:44:08.000Z | lib/surface/compute/url_maps/config/export.py | google-cloud-sdk-unofficial/google-cloud-sdk | 2a48a04df14be46c8745050f98768e30474a1aac | [
"Apache-2.0"
] | null | null | null | lib/surface/compute/url_maps/config/export.py | google-cloud-sdk-unofficial/google-cloud-sdk | 2a48a04df14be46c8745050f98768e30474a1aac | [
"Apache-2.0"
] | 1 | 2020-07-25T01:40:19.000Z | 2020-07-25T01:40:19.000Z | # -*- coding: utf-8 -*- #
# Copyright 2021 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Export Url maps command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import flags as compute_flags
from googlecloudsdk.command_lib.compute import scope as compute_scope
from googlecloudsdk.command_lib.compute.url_maps import flags
from googlecloudsdk.command_lib.util.declarative import python_command_util as declarative_python_util
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Export(base.Command):
"""Export the configuration for a URL map."""
detailed_help = declarative_python_util.BuildHelpText(singular='URL map')
URL_MAP_ARG = None
@classmethod
def Args(cls, parser):
cls.URL_MAP_ARG = flags.UrlMapArgument(
required=False, include_l7_internal_load_balancing=True)
declarative_python_util.RegisterArgs(
parser, cls.URL_MAP_ARG.AddArgument, operation_type='export')
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
resource_ref = str(self.URL_MAP_ARG.ResolveAsResource(
args,
holder.resources,
default_scope=compute_scope.ScopeEnum.GLOBAL,
scope_lister=compute_flags.GetDefaultScopeLister(holder.client)))
return declarative_python_util.RunExport(
args=args, collection='compute.urlMaps', resource_ref=resource_ref)
| 40.134615 | 102 | 0.782463 | 279 | 2,087 | 5.655914 | 0.501792 | 0.038023 | 0.063371 | 0.070976 | 0.121039 | 0.051965 | 0 | 0 | 0 | 0 | 0 | 0.005583 | 0.14183 | 2,087 | 51 | 103 | 40.921569 | 0.875489 | 0.314806 | 0 | 0 | 0 | 0 | 0.019929 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.071429 | false | 0 | 0.321429 | 0 | 0.535714 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
cce22c05e27c866692617079e7f28a4a744f6018 | 367 | py | Python | src/NetworkSimulator/setup.py | zawaki/nara_revision | 28bb42f7ca3a768075748d258c405addc7b28c31 | [
"MIT"
] | null | null | null | src/NetworkSimulator/setup.py | zawaki/nara_revision | 28bb42f7ca3a768075748d258c405addc7b28c31 | [
"MIT"
] | null | null | null | src/NetworkSimulator/setup.py | zawaki/nara_revision | 28bb42f7ca3a768075748d258c405addc7b28c31 | [
"MIT"
] | null | null | null | import setuptools
# setuptools.setup(
# name='NetworkSimulator',
# )
setuptools.setup(
name="NetworkSimulator",
version="0.0.1",
author="Zak Shabka",
author_email="zak@shabka.com",
description="Network Management API",
url="https://github.com/zawaki/NetworkSim",
packages=setuptools.find_packages(),
python_requires='>=3.6',
) | 24.466667 | 47 | 0.673025 | 40 | 367 | 6.1 | 0.7 | 0.122951 | 0.155738 | 0.286885 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.01634 | 0.166213 | 367 | 15 | 48 | 24.466667 | 0.781046 | 0.141689 | 0 | 0 | 0 | 0 | 0.346154 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.090909 | 0 | 0.090909 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
cce98082f607b2d5535937164e87e7b49da9af2e | 3,929 | py | Python | modules/command/commands/gen.py | naskya/testcase-generator | 02765184a275152e1d8c177f2028ca8db315cfee | [
"MIT"
] | 4 | 2020-09-23T07:11:41.000Z | 2022-02-02T09:08:21.000Z | modules/command/commands/gen.py | naskya/testcase-generator | 02765184a275152e1d8c177f2028ca8db315cfee | [
"MIT"
] | 5 | 2021-08-29T18:23:01.000Z | 2021-11-20T03:53:19.000Z | modules/command/commands/gen.py | naskya/testcase-generator | 02765184a275152e1d8c177f2028ca8db315cfee | [
"MIT"
] | null | null | null | from __future__ import annotations
import concurrent.futures
import os
import shutil
import signal
import psutil
from modules.case.saver import save_case
from modules.command.commands.impl.generate_one_case import generate_one_case
from modules.command.definition import Command
from modules.utility.colorizer import Color, colorize
from modules.utility.exit_failure import exit_failure
from modules.utility.printer import info, progress, progress_bar
from modules.variable.definition import Variable
def gen_with_progress_bar(command: Command, variables: dict[str, Variable],
override_statements: str, format: list[list[str]]) -> None:
pad_length = len(str(command.cases)) + 1
progress('Start generating test cases.')
print('-' * shutil.get_terminal_size().columns + '\n')
print(f'Generate #{"1".rjust(pad_length, " ")}')
with concurrent.futures.ProcessPoolExecutor() as executor:
test_number = 0
futures = [executor.submit(generate_one_case, variables, override_statements, format)
for _ in range(command.cases * 2)]
for future in concurrent.futures.as_completed(futures):
success, result = future.result()
if not success:
continue
test_number += 1
save_case(result, test_number, command.cases, command.prefix, command.suffix)
# show progress
print(f'\033[AGenerate #{str(test_number + 1).rjust(pad_length, " ")}')
progress_bar(test_number, command.cases, 50)
if test_number == command.cases:
print('\033[AGenerate: Done!\033[K\n\n')
executor.shutdown(wait=False)
try:
parent = psutil.Process(os.getpid())
for process in parent.children(recursive=True):
process.send_signal(signal.SIGKILL)
except psutil.NoSuchProcess:
pass
break
print('-' * shutil.get_terminal_size().columns)
if test_number != command.cases:
info(f'Failed to generate {command.cases - test_number} cases.')
progress('{} (out of {}) cases have been generated successfully.'.format(
colorize(Color.CODE, test_number),
colorize(Color.CODE, command.cases)
))
if command.is_verification and test_number < command.cases // 2:
exit_failure()
def gen_without_progress_bar(command: Command, variables: dict[str, Variable],
override_statements: str, format: list[list[str]]) -> None:
progress('Start generating test cases.')
with concurrent.futures.ProcessPoolExecutor() as executor:
test_number = 0
futures = [executor.submit(generate_one_case, variables, override_statements, format) for _ in range(command.cases * 2)]
for future in concurrent.futures.as_completed(futures):
success, result = future.result()
if not success:
continue
test_number += 1
save_case(result, test_number, command.cases, command.prefix, command.suffix)
if test_number == command.cases:
executor.shutdown(wait=False)
try:
parent = psutil.Process(os.getpid())
for process in parent.children(recursive=True):
process.send_signal(signal.SIGKILL)
except psutil.NoSuchProcess:
pass
break
if test_number != command.cases:
info(f'Failed to generate {command.cases - test_number} cases.')
progress('{} (out of {}) cases have been generated successfully.'.format(
colorize(Color.CODE, test_number),
colorize(Color.CODE, command.cases)
))
if command.is_verification and test_number < command.cases // 2:
exit_failure()
| 34.769912 | 128 | 0.631458 | 439 | 3,929 | 5.505695 | 0.252847 | 0.074472 | 0.063302 | 0.08192 | 0.741415 | 0.695077 | 0.66777 | 0.66777 | 0.66777 | 0.66777 | 0 | 0.0077 | 0.272843 | 3,929 | 112 | 129 | 35.080357 | 0.838292 | 0.003309 | 0 | 0.683544 | 1 | 0 | 0.104241 | 0.005876 | 0 | 0 | 0 | 0 | 0 | 1 | 0.025316 | false | 0.025316 | 0.164557 | 0 | 0.189873 | 0.075949 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
cced7a9dd7e8aa71f038969c6d3d98cb9c6d7df8 | 415 | py | Python | backend/base/storage.py | uncle-yura/simple_booking | 91a9609ae4521e4b2d52953112607c69db54d0ee | [
"MIT"
] | null | null | null | backend/base/storage.py | uncle-yura/simple_booking | 91a9609ae4521e4b2d52953112607c69db54d0ee | [
"MIT"
] | null | null | null | backend/base/storage.py | uncle-yura/simple_booking | 91a9609ae4521e4b2d52953112607c69db54d0ee | [
"MIT"
] | null | null | null | from django.core.files.storage import FileSystemStorage
import uuid
import os
class UUIDStorage(FileSystemStorage):
def get_available_name(self, name, **kwargs):
filename, file_extension = os.path.splitext(name)
dirname = os.path.dirname(name)
name = os.path.join(dirname, str(uuid.uuid4()) + file_extension)
return super(UUIDStorage, self).get_available_name(name, **kwargs)
| 31.923077 | 74 | 0.722892 | 52 | 415 | 5.653846 | 0.538462 | 0.061224 | 0.108844 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002899 | 0.168675 | 415 | 12 | 75 | 34.583333 | 0.849275 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.333333 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
ccf72b245ff649ecee40e5f7ee82d7d8d805699c | 899 | py | Python | launch/turtlesim_mimic_launch.py | iamrajee/ros2eloquent_catkin_ws | c0d5fa69cd50ba0313cef2bd7ce8d39ae9f990ee | [
"MIT"
] | 15 | 2020-03-03T14:38:27.000Z | 2021-08-17T23:53:31.000Z | launch/turtlesim_mimic_launch.py | iamrajee/ros2eloquent_catkin_ws | c0d5fa69cd50ba0313cef2bd7ce8d39ae9f990ee | [
"MIT"
] | 1 | 2020-03-12T08:10:11.000Z | 2020-03-12T08:10:11.000Z | launch/turtlesim_mimic_launch.py | iamrajee/ros2eloquent_catkin_ws | c0d5fa69cd50ba0313cef2bd7ce8d39ae9f990ee | [
"MIT"
] | 2 | 2020-03-13T09:05:39.000Z | 2021-08-13T08:28:22.000Z | from launch import LaunchDescription #Imports
from launch_ros.actions import Node
def generate_launch_description():
#LaunchDescription([ Node(package='',node_executable='',node_name=''),Node() ])
return LaunchDescription([
Node(
package='turtlesim',
node_namespace='turtlesim1',
node_executable='turtlesim_node',
node_name='sim'
#ros_args=''
),
Node(
package='turtlesim',
node_namespace='turtlesim2',
node_executable='turtlesim_node',
node_name='sim'
),
Node(
package='turtlesim',
node_executable='mimic',
node_name='mimic',
remappings=[
('/input/pose', '/turtlesim1/turtle1/pose'),
('/output/cmd_vel', '/turtlesim2/turtle1/cmd_vel'),
]
)
])
| 29.966667 | 83 | 0.543938 | 75 | 899 | 6.28 | 0.386667 | 0.138004 | 0.127389 | 0.152866 | 0.301486 | 0.161359 | 0.161359 | 0 | 0 | 0 | 0 | 0.009967 | 0.330367 | 899 | 29 | 84 | 31 | 0.772425 | 0.106785 | 0 | 0.461538 | 1 | 0 | 0.21 | 0.06375 | 0 | 0 | 0 | 0 | 0 | 1 | 0.038462 | true | 0 | 0.076923 | 0.038462 | 0.153846 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ccffa8dee2986aea2b8a336fea8b81848361c9f9 | 662 | py | Python | tests/test_utilities.py | bmjjr/draftkings_client | 1e3d0362f0f1860a355482cf65bfa9f0b579ee2b | [
"MIT"
] | null | null | null | tests/test_utilities.py | bmjjr/draftkings_client | 1e3d0362f0f1860a355482cf65bfa9f0b579ee2b | [
"MIT"
] | null | null | null | tests/test_utilities.py | bmjjr/draftkings_client | 1e3d0362f0f1860a355482cf65bfa9f0b579ee2b | [
"MIT"
] | null | null | null | from datetime import datetime
from unittest import TestCase
import pytz
from draft_kings.utilities import dig, translate_formatted_datetime
class TestGet(TestCase):
def test_fallback(self):
self.assertIsNone(dig({}, "a", "b", "c"))
def test_returns_nested_value(self):
self.assertEqual(dig({"foo": {"bar": "baz"}}, "foo", "bar"), "baz")
class TestTranslateDatetime(TestCase):
def test_translate_datetime_string(self):
timestamp = translate_formatted_datetime("/Date(1479258000000)/")
self.assertIsNotNone(timestamp)
self.assertEqual(timestamp, datetime.fromtimestamp(1479258000000 / 1e3, tz=pytz.utc))
| 28.782609 | 93 | 0.719033 | 75 | 662 | 6.186667 | 0.52 | 0.045259 | 0.112069 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.050179 | 0.1571 | 662 | 22 | 94 | 30.090909 | 0.781362 | 0 | 0 | 0 | 0 | 0 | 0.06354 | 0.03177 | 0 | 0 | 0 | 0 | 0.285714 | 1 | 0.214286 | false | 0 | 0.285714 | 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 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
6906c2b28671fa14424dbb8afb1eaefbb852464c | 1,114 | py | Python | torchdiffeq/_impl/fixed_grid.py | luisect/torchdiffeq | 04bd60b9370b7541808823fa8a6871237c204016 | [
"MIT"
] | 1 | 2022-02-22T12:22:48.000Z | 2022-02-22T12:22:48.000Z | torchdiffeq/_impl/fixed_grid.py | luisect/torchdiffeq | 04bd60b9370b7541808823fa8a6871237c204016 | [
"MIT"
] | null | null | null | torchdiffeq/_impl/fixed_grid.py | luisect/torchdiffeq | 04bd60b9370b7541808823fa8a6871237c204016 | [
"MIT"
] | 1 | 2021-05-06T03:07:25.000Z | 2021-05-06T03:07:25.000Z | import torch
from .solvers import FixedGridODESolver
from .rk_common import rk4_alt_step_func
class Euler(FixedGridODESolver):
order = 1
def __init__(self, eps=0., **kwargs):
super(Euler, self).__init__(**kwargs)
self.eps = torch.as_tensor(eps, dtype=self.dtype, device=self.device)
def _step_func(self, func, t, dt, y):
return dt * func(t + self.eps, y)
class Midpoint(FixedGridODESolver):
order = 2
def __init__(self, eps=0., **kwargs):
super(Midpoint, self).__init__(**kwargs)
self.eps = torch.as_tensor(eps, dtype=self.dtype, device=self.device)
def _step_func(self, func, t, dt, y):
half_dt = 0.5 * dt
y_mid = y + func(t + self.eps, y) * half_dt
return dt * func(t + half_dt, y_mid)
class RK4(FixedGridODESolver):
order = 4
def __init__(self, eps=0., **kwargs):
super(RK4, self).__init__(**kwargs)
self.eps = torch.as_tensor(eps, dtype=self.dtype, device=self.device)
def _step_func(self, func, t, dt, y):
return rk4_alt_step_func(func, t + self.eps, dt - 2 * self.eps, y)
| 28.564103 | 77 | 0.638241 | 166 | 1,114 | 4.012048 | 0.216867 | 0.105105 | 0.04955 | 0.063063 | 0.57958 | 0.540541 | 0.540541 | 0.423423 | 0.423423 | 0.423423 | 0 | 0.015081 | 0.226212 | 1,114 | 38 | 78 | 29.315789 | 0.757541 | 0 | 0 | 0.346154 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.230769 | false | 0 | 0.115385 | 0.076923 | 0.692308 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.