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
c308240a78da5b79377a090d53b2e1a1d3561544
405
py
Python
tests/cpydiff/syntax_spaces.py
sebastien-riou/micropython
116c15842fd48ddb77b0bc016341d936a0756573
[ "MIT" ]
13,648
2015-01-01T01:34:51.000Z
2022-03-31T16:19:53.000Z
tests/cpydiff/syntax_spaces.py
sebastien-riou/micropython
116c15842fd48ddb77b0bc016341d936a0756573
[ "MIT" ]
7,092
2015-01-01T07:59:11.000Z
2022-03-31T23:52:18.000Z
tests/cpydiff/syntax_spaces.py
sebastien-riou/micropython
116c15842fd48ddb77b0bc016341d936a0756573
[ "MIT" ]
4,942
2015-01-02T11:48:50.000Z
2022-03-31T19:57:10.000Z
""" categories: Syntax,Spaces description: uPy requires spaces between literal numbers and keywords, CPy doesn't cause: Unknown workaround: Unknown """ try: print(eval("1and 0")) except SyntaxError: print("Should have worked") try: print(eval("1or 0")) except SyntaxError: print("Should have worked") try: print(eval("1if 1else 0")) except SyntaxError: print("Should have worked")
21.315789
82
0.711111
53
405
5.433962
0.566038
0.083333
0.125
0.239583
0.489583
0.489583
0.489583
0.354167
0.354167
0.354167
0
0.020772
0.167901
405
18
83
22.5
0.833828
0.353086
0
0.75
0
0
0.299213
0
0
0
0
0
0
1
0
true
0
0
0
0
0.5
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
1
0
4
c3171f8f7b64bc09d0c2463f4ac7d2b115640dc7
148
py
Python
cvservices/utils.py
amabdallah/ControlledVocabulariesTemplate
751e5a87da0bc036311b4e8aa8408eb69bee716b
[ "BSD-3-Clause" ]
null
null
null
cvservices/utils.py
amabdallah/ControlledVocabulariesTemplate
751e5a87da0bc036311b4e8aa8408eb69bee716b
[ "BSD-3-Clause" ]
null
null
null
cvservices/utils.py
amabdallah/ControlledVocabulariesTemplate
751e5a87da0bc036311b4e8aa8408eb69bee716b
[ "BSD-3-Clause" ]
null
null
null
import re def upper_splitted(string): return " ".join(re.findall('[A-Z][a-z]*', string)) lfirst = lambda s: s[:1].lower() + s[1:] if s else ''
24.666667
54
0.601351
26
148
3.384615
0.692308
0.045455
0
0
0
0
0
0
0
0
0
0.016129
0.162162
148
6
55
24.666667
0.693548
0
0
0
0
0
0.080537
0
0
0
0
0
0
1
0.25
false
0
0.25
0.25
0.75
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
0
0
0
4
c31fd53c6cdb42af847400bb7ac4bf0f29c69d39
779
py
Python
0x04-python-more_data_structures/dev/103-tests.py
johncoleman83/bootcampschool-higher_level_programming
a83c3b7092cfe893c87e495f8d8eec9228c9b808
[ "MIT" ]
null
null
null
0x04-python-more_data_structures/dev/103-tests.py
johncoleman83/bootcampschool-higher_level_programming
a83c3b7092cfe893c87e495f8d8eec9228c9b808
[ "MIT" ]
null
null
null
0x04-python-more_data_structures/dev/103-tests.py
johncoleman83/bootcampschool-higher_level_programming
a83c3b7092cfe893c87e495f8d8eec9228c9b808
[ "MIT" ]
1
2020-09-25T17:54:36.000Z
2020-09-25T17:54:36.000Z
import ctypes lib = ctypes.CDLL('./libPython.so') lib.print_python_list.argtypes = [ctypes.py_object] lib.print_python_bytes.argtypes = [ctypes.py_object] s = b"Hello" lib.print_python_bytes(s); b = b'\xff\xf8\x00\x00\x00\x00\x00\x00'; lib.print_python_bytes(b); b = b'What does the \'b\' character do in front of a string literal?'; lib.print_python_bytes(b); l = [b'Hello', b'World'] lib.print_python_list(l) del l[1] lib.print_python_list(l) l = l + [4, 5, 6.0, (9, 8), [9, 8, 1024], b"Bootcamp", "Betty"] lib.print_python_list(l) l = [] lib.print_python_list(l) l.append(0) lib.print_python_list(l) l.append(1) l.append(2) l.append(3) l.append(4) lib.print_python_list(l) l.pop() lib.print_python_list(l) l = ["Bootcamp"] lib.print_python_list(l) lib.print_python_bytes(l);
24.34375
70
0.71887
152
779
3.486842
0.309211
0.211321
0.369811
0.30566
0.430189
0.249057
0.098113
0
0
0
0
0.044097
0.097561
779
31
71
25.129032
0.709815
0
0
0.333333
0
0
0.179718
0.041078
0
0
0
0
0
1
0
false
0
0.033333
0
0.033333
0.466667
0
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
4
c3629383fd3178fc6a763b1cb630241593cd88b1
234
py
Python
qmpy/web/serializers/composition.py
tachyontraveler/qmpy
f024de3aa85d4367cd31775bd53eede30c74c083
[ "MIT" ]
103
2015-02-13T16:51:59.000Z
2022-03-24T22:08:54.000Z
qmpy/web/serializers/composition.py
tachyontraveler/qmpy
f024de3aa85d4367cd31775bd53eede30c74c083
[ "MIT" ]
59
2015-12-02T22:43:21.000Z
2022-03-28T03:54:44.000Z
qmpy/web/serializers/composition.py
tachyontraveler/qmpy
f024de3aa85d4367cd31775bd53eede30c74c083
[ "MIT" ]
62
2015-02-24T21:58:59.000Z
2022-03-21T16:49:09.000Z
from rest_framework import serializers from qmpy.materials.composition import Composition class CompositionSerializer(serializers.ModelSerializer): class Meta: model = Composition fields = ("formula", "generic")
26
57
0.75641
22
234
8
0.727273
0
0
0
0
0
0
0
0
0
0
0
0.175214
234
8
58
29.25
0.911917
0
0
0
0
0
0.059829
0
0
0
0
0
0
1
0
false
0
0.333333
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
c373c955dc7a9429567a953bc6f8a1c419f2f066
193
py
Python
lib/__init__.py
Qwokka/SMBCommander
3123fe2a584a5d917f8cc25484d52ded1fac99a3
[ "Apache-2.0" ]
6
2019-03-13T08:36:32.000Z
2021-02-12T23:46:32.000Z
lib/__init__.py
Qwokka/SMBCommander
3123fe2a584a5d917f8cc25484d52ded1fac99a3
[ "Apache-2.0" ]
4
2019-01-13T20:42:21.000Z
2019-01-13T20:44:59.000Z
lib/__init__.py
Qwokka/SMBCommander
3123fe2a584a5d917f8cc25484d52ded1fac99a3
[ "Apache-2.0" ]
1
2020-08-28T05:11:52.000Z
2020-08-28T05:11:52.000Z
#!/usr/bin/env python # # Author: Jack Baker (https://github.com/qwokka/smbcommander) # # This product includes software developed by # SecureAuth Corporation (https://www.secureauth.com/)." #
24.125
61
0.735751
24
193
5.916667
0.875
0
0
0
0
0
0
0
0
0
0
0
0.108808
193
7
62
27.571429
0.825581
0.927461
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
c38004bffcd388467eb50a6a5b17185aa9a55a9b
576
py
Python
engine/browser.py
pjkostrzewski/kanonierzy
9b5cc95d5a6ddcb7fc647b16373f54f9c0bca21d
[ "MIT" ]
null
null
null
engine/browser.py
pjkostrzewski/kanonierzy
9b5cc95d5a6ddcb7fc647b16373f54f9c0bca21d
[ "MIT" ]
null
null
null
engine/browser.py
pjkostrzewski/kanonierzy
9b5cc95d5a6ddcb7fc647b16373f54f9c0bca21d
[ "MIT" ]
null
null
null
from abc import ABC, abstractmethod class Browser(ABC): """ Abstract class for browser engines """ @abstractmethod def get(self, url): pass @abstractmethod def get_cookies(self): pass @abstractmethod def add_cookie(self, cookie): pass @abstractmethod def execute_script(self, script): pass @abstractmethod def find_elements_by_class_name(self, class_name): pass @abstractmethod def add_argument(self, option): pass @abstractmethod def run(self): pass
16.941176
54
0.626736
62
576
5.677419
0.419355
0.338068
0.357955
0.136364
0
0
0
0
0
0
0
0
0.298611
576
33
55
17.454545
0.871287
0.059028
0
0.608696
0
0
0
0
0
0
0
0
0
1
0.304348
false
0.304348
0.043478
0
0.391304
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
1
0
1
0
0
0
0
0
4
c380bf35207f5126207771a202f6a22a5b04d868
8
py
Python
Project 10/img_rc.py
ingwant/Python-Programs
3022bb3bce70fe59ccd638f407ee36b0a1c71ad9
[ "MIT" ]
null
null
null
Project 10/img_rc.py
ingwant/Python-Programs
3022bb3bce70fe59ccd638f407ee36b0a1c71ad9
[ "MIT" ]
null
null
null
Project 10/img_rc.py
ingwant/Python-Programs
3022bb3bce70fe59ccd638f407ee36b0a1c71ad9
[ "MIT" ]
null
null
null
# Qt图片资源
8
8
0.75
1
8
6
1
0
0
0
0
0
0
0
0
0
0
0
0.125
8
1
8
8
0.857143
0.75
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
5efb288124340bcebc5731a0c821dbfbcfe0a8d7
161
py
Python
apps/mark/forms.py
edilsonlonC/Data_Music
8bb814e750cd8f407653ed6e255957cb92f0f19b
[ "MIT" ]
null
null
null
apps/mark/forms.py
edilsonlonC/Data_Music
8bb814e750cd8f407653ed6e255957cb92f0f19b
[ "MIT" ]
null
null
null
apps/mark/forms.py
edilsonlonC/Data_Music
8bb814e750cd8f407653ed6e255957cb92f0f19b
[ "MIT" ]
null
null
null
from django.forms import ModelForm from apps.mark.models import Mark class form_marks (ModelForm): class Meta: model=Mark fields='__all__'
17.888889
34
0.701863
21
161
5.142857
0.714286
0
0
0
0
0
0
0
0
0
0
0
0.229814
161
8
35
20.125
0.870968
0
0
0
0
0
0.043478
0
0
0
0
0
0
1
0
false
0
0.333333
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
6f06c303003bbc68158ac009450089ae4250d32a
24,071
py
Python
pickle_vs_json.py
Arvind2222/pickle-vs-json
01b94548a1eceff965f6ec8489a7ff167cbf7da6
[ "MIT" ]
null
null
null
pickle_vs_json.py
Arvind2222/pickle-vs-json
01b94548a1eceff965f6ec8489a7ff167cbf7da6
[ "MIT" ]
null
null
null
pickle_vs_json.py
Arvind2222/pickle-vs-json
01b94548a1eceff965f6ec8489a7ff167cbf7da6
[ "MIT" ]
1
2021-08-25T11:14:23.000Z
2021-08-25T11:14:23.000Z
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ pickle vs JSON serialization. """ __author__ = "Arvind Mishra" __version__ = "1.0" __status__ = "Development" __credit__ = "https://github.com/kovshenin/pickle-vs-json" """ Feel free to use this code as you wish Discussions: https://medium.com/@mishraarvind2222/pickle-vs-json-which-is-faster-in-python3-6b39b9010a99 """ import pickle import json """ Other things to try: # Marshal vs JSON: import marshal as pickle import json # Marshal vs Pickle: import marshal as json import pickle # Marshal vs cPickle: import marshal as json import cPickle as pickle # JSON vs cPickle import json import cPickle as pickle """ import timeit import random source = [] json_result = [] pickle_result = [] def main(): # Need access to these outside our functions. global source, pickle_result, json_result # Let's generate some junky source - lists, dictionaries and nested dictionaries. for i in range(10): l, d, nd = get_data(50) source.append(l) source.append(d) source.append(nd) # We'll use timeit to track the time of our function calls json_time = timeit.Timer('test_json()', 'from __main__ import test_json, source, json_result') pickle_time = timeit.Timer('test_pickle()', 'from __main__ import test_pickle, source, pickle_result') json_load_time = timeit.Timer('test_json_load()', 'from __main__ import test_json_load, source, json_result') pickle_load_time = timeit.Timer('test_pickle_load()', 'from __main__ import test_pickle_load, source, pickle_result') print("Dir\tEntries\tMethod\tTime\tLength") print() # Feel free to try 500 and 1000 but beware that they could take.. Hours! for i in (50, 100): print(f"dump\t{i}\tJSON\t{json_time.timeit(i)}\t{len(json_result)}") print(f"load\t{i}\tJSON\t{json_load_time.timeit(i)}\t-") print(f"dump\t{i}\tPickle\t{pickle_time.timeit(i)}\t{len(pickle_result)}") print(f"load\t{i}\tPickle\t{pickle_load_time.timeit(i)}\t-") # Clear the results after each run since we need to measure size. json_result = [] pickle_result = [] return def test_json(): """ Runs the dumps JSON test. """ for entry in source: json_result.append(json.dumps(entry)) def test_pickle(): """ Runs the dumps Pickle test. """ for entry in source: pickle_result.append(pickle.dumps(entry)) def test_json_load(): """ Runs the loads JSON test. """ for entry in json_result: json.loads(entry) def test_pickle_load(): """ Runs the loads Pickle test. """ for entry in pickle_result: pickle.loads(entry) def get_data(count): """ Use this function to generate data, returns a touple containing a list, a dictionary and a nested dictionary. """ l = [] d = {} nd = {} for i in range(count): d[lipsum(1)] = lipsum(10) l.append(lipsum(3)) nd[lipsum(1)] = {i: lipsum(1), i + 1: [lipsum(2), lipsum(4), lipsum(3)], i + 2: {i: lipsum(3), i + 1: lipsum(4), i + 2: [lipsum(2), lipsum(3)]}} return l, d, nd def lipsum(count=50): """ This function generates lorem ipsum junk, use with caution ;) """ lipsum = """ Donec ultrices ultricies libero, et tristique dolor euismod et. Cras volutpat nulla in turpis consequat et dignissim nunc rhoncus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed sit amet odio dolor. Mauris fermentum, quam vel volutpat lobortis, tellus eros tempus est, varius elementum arcu lectus volutpat felis. Duis aliquam justo eget neque lacinia vitae dictum urna mollis. Praesent id congue ligula. Maecenas vehicula faucibus mauris, id auctor velit mattis nec. Nulla facilisi. In a mauris quis orci malesuada tempor. Etiam molestie consequat tortor, nec vestibulum enim feugiat ac. Aenean vehicula laoreet mauris, eget tristique urna ultrices vitae. Morbi enim orci, consectetur et ornare eu, sollicitudin in libero. Phasellus nisl nunc, iaculis sed scelerisque non, pretium vel mauris. Curabitur sit amet augue sit amet lacus pellentesque facilisis. Nam in ipsum nulla, eu molestie mi. Praesent eget elementum erat. Vivamus ornare suscipit lectus, auctor eleifend mauris congue ut. Aenean vel ullamcorper ipsum. Aliquam erat volutpat. Fusce varius mollis nibh ut vestibulum. Nullam turpis velit, luctus id bibendum eu, commodo id lacus. Maecenas libero tortor, pretium at elementum et, pellentesque vitae magna. Morbi eu nulla eu dolor fermentum faucibus eu congue dui. Etiam eu nibh vitae neque rhoncus ultricies. Nunc vitae diam ligula, sit amet mollis libero. Ut fermentum nisl non sem commodo imperdiet. Morbi in mi vitae nunc eleifend varius eget sed nulla. Ut laoreet lacinia mi rhoncus luctus. Mauris blandit pretium ipsum, interdum gravida libero porttitor ut. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin commodo, leo elementum gravida iaculis, urna leo imperdiet elit, ac congue dolor ante ornare tortor. Proin dapibus ultricies lorem, imperdiet posuere purus scelerisque et. Morbi nulla eros, mattis nec egestas sed, imperdiet eu nibh. In hac habitasse platea dictumst. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Curabitur pellentesque urna non diam dictum adipiscing. Duis vestibulum nibh mi, ac faucibus tortor. Fusce blandit diam eu odio viverra bibendum. Morbi a nunc tortor. Donec id odio dolor, vitae pulvinar massa. In aliquam congue felis at varius. Sed a erat elit, quis cursus sapien. Aenean venenatis urna et tellus posuere ut tempus neque imperdiet. Mauris a adipiscing massa. Fusce in dolor sem, eu iaculis nunc. Maecenas massa neque, scelerisque pellentesque posuere in, dignissim eget est. Donec sed ligula quis erat faucibus bibendum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Pellentesque neque leo, feugiat ac dapibus nec, vestibulum sed est. Vivamus porta mi a erat facilisis eleifend. Duis vel dolor arcu, non mollis risus. Aenean commodo egestas dolor, a rhoncus sapien vestibulum et. Aenean dignissim, dui nec lacinia dapibus, mauris eros pharetra mi, eu varius dui dolor id urna. Aenean vitae nisi eu risus convallis lobortis in ac erat. Integer quis risus quam, nec commodo ligula. Suspendisse sit amet nibh nulla. Ut a nisi est. Phasellus in imperdiet risus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce ultrices faucibus pretium. Nam viverra, tortor vitae mollis adipiscing, elit nulla dapibus leo, non egestas massa lacus vel libero. Duis luctus magna eget tortor sollicitudin viverra. Donec id diam felis, sit amet bibendum metus. Sed bibendum feugiat fermentum. Sed eleifend ultricies vehicula. Nulla velit massa, sagittis eget vestibulum eu, semper sed lacus. Fusce non vehicula ipsum. Nullam ipsum orci, pharetra at aliquam sagittis, accumsan ac urna. Duis convallis luctus neque non adipiscing. Proin auctor congue arcu id cursus. Morbi nec turpis auctor neque porttitor malesuada in a ipsum. Phasellus gravida, augue non mattis suscipit, ligula arcu placerat mauris, quis consectetur erat velit sed nisi. In tincidunt, elit in scelerisque condimentum, tellus arcu pellentesque massa, a imperdiet justo leo id nibh. Nunc ligula lectus, rutrum non blandit nec, pellentesque et nunc. Suspendisse tellus tellus, sollicitudin eu faucibus et, mattis eget ipsum. Donec et aliquam nisl. Nulla vel felis lacus, id iaculis diam. Ut sed massa ipsum. Nulla facilisi. Donec a urna eu eros lobortis tempor vel nec mi. Maecenas rutrum sodales molestie. Curabitur consectetur condimentum nisl, id accumsan leo viverra id. Duis facilisis pellentesque ultricies. Duis a ipsum lorem, id feugiat sem. Nulla mattis lectus quis nisi sollicitudin sit amet volutpat libero tristique. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In id nunc purus. Fusce sapien ligula, pulvinar in mollis id, blandit sed elit. Sed id nunc rhoncus purus consequat aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer purus est, gravida et ornare eget, aliquam ac leo. Ut suscipit faucibus massa eget commodo. Suspendisse posuere erat id dolor tempor facilisis. Nunc at eleifend mi. Vestibulum a felis eu ligula sodales luctus at ac mi. Proin pellentesque convallis leo sit amet dictum. Vivamus consequat, quam ac pharetra venenatis, sapien ligula bibendum orci, quis consequat mauris ipsum ac magna. Aliquam at purus augue, consequat faucibus leo. Nulla metus lorem, interdum ut mollis a, tempor eget quam. Nulla sed tortor quis odio tempus scelerisque. Morbi consequat vestibulum erat porttitor euismod. Nullam nec tortor ante. Sed non diam non mi lacinia egestas. Nunc commodo faucibus tortor eget bibendum. Donec nec eros quam, sit amet iaculis libero. Morbi in metus nec ante malesuada semper sed ac tellus. Fusce pellentesque urna orci. Aliquam vitae diam vel nunc dictum egestas. Fusce suscipit, nibh et viverra tincidunt, diam magna interdum tellus, vitae porttitor magna arcu vitae odio. In sit amet nibh leo, ac tristique leo. Duis mauris ante, tempor bibendum malesuada vel, dictum quis odio. Mauris id dolor sed ligula ultricies aliquet. Donec eget quam quam, id congue neque. Nullam sit amet commodo nulla. Proin lobortis, sapien ut semper suscipit, erat nibh viverra turpis, vitae dignissim quam ipsum sed tellus. Sed pellentesque malesuada augue id aliquet. Aenean ac velit est. Praesent bibendum gravida pharetra. Integer pulvinar, lacus a pretium pellentesque, nulla dui blandit nunc, eget egestas turpis velit sed enim. Morbi laoreet neque sed eros blandit eu volutpat erat fringilla. In vitae est metus. Nulla lectus turpis, dignissim non adipiscing ut, malesuada a elit. Sed et pulvinar mi. Duis sed nibh velit. Pellentesque posuere hendrerit ligula in tempus. Maecenas sed mollis eros. Nulla purus velit, convallis et imperdiet sed, interdum faucibus felis. Morbi rhoncus magna a velit condimentum non consectetur leo facilisis. Sed aliquam fringilla cursus. Cras nibh libero, condimentum sit amet placerat nec, elementum eget metus. Fusce a neque purus, quis ullamcorper elit. Morbi vitae est id diam pretium ultricies. Duis nec turpis non nisl suscipit ultrices. Phasellus tristique ornare porta. Pellentesque hendrerit nisl id mauris sollicitudin id pellentesque sem sagittis. Ut libero libero, suscipit quis pulvinar a, semper sit amet metus. Morbi sit amet urna nunc, eget ullamcorper metus. Donec imperdiet tempus vulputate. Proin ornare, augue et condimentum vehicula, felis libero eleifend purus, non placerat est sapien ut sapien. Aenean a gravida lorem. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean iaculis velit eget est congue et posuere risus ultrices. Cras dictum luctus turpis, quis posuere tellus hendrerit mollis. Nulla sed lacus nec mauris sodales viverra. Donec ligula arcu, viverra a bibendum eu, dignissim in felis. Sed consectetur erat mollis risus blandit quis ornare nisl scelerisque. Vivamus sed risus a nulla dictum euismod id et dolor. Nam id pharetra nunc. Nunc ullamcorper varius leo, nec fermentum lacus sodales vel. Duis scelerisque dapibus mi, vel eleifend eros bibendum sit amet. Cras tristique justo id justo bibendum a elementum tortor volutpat. Maecenas ligula nibh, consectetur id malesuada sit amet, suscipit non risus. Proin faucibus pellentesque vehicula. Praesent iaculis malesuada erat. Fusce ac elit nec lorem sodales hendrerit. Phasellus diam sapien, cursus nec mattis tempor, facilisis ut odio. Maecenas felis eros, rhoncus eget dignissim quis, vulputate ut orci. Fusce posuere fringilla odio ut cursus. Suspendisse a adipiscing justo. Donec posuere varius mollis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc tempor elit eget quam euismod hendrerit feugiat a augue. Vivamus molestie consectetur urna sed condimentum. Fusce luctus consequat laoreet. Nulla facilisi. Suspendisse gravida laoreet odio, non bibendum magna facilisis et. Suspendisse at egestas metus. Nullam condimentum malesuada ultrices. Donec posuere hendrerit erat, non commodo lacus varius non. Sed sodales viverra sagittis. Duis congue scelerisque nunc, ut fermentum tellus adipiscing sit amet. Morbi ut eros neque. Aliquam semper, mauris ac cursus cursus, tortor sem pulvinar magna, non tristique purus mauris nec nisl. Sed eget adipiscing magna. Aliquam ullamcorper sollicitudin dolor, vitae mollis eros mattis quis. Cras gravida tristique nibh id fermentum. Sed accumsan vehicula metus, non imperdiet eros auctor sit amet. In facilisis justo et sem cursus dictum. Fusce consectetur, est nec suscipit vulputate, nisi urna sodales ante, id viverra urna ligula nec odio. Donec eu neque nulla, sed sodales augue. Duis eget magna elit. Vestibulum dolor lorem, fermentum ac condimentum sit amet, malesuada eget elit. Quisque justo odio, consequat ut blandit id, ullamcorper quis massa. Aliquam lectus augue, commodo eu pharetra vitae, luctus nec est. In accumsan consectetur commodo. Vivamus nec massa lacus, sed lobortis erat. Quisque non pharetra leo. In et arcu odio. Sed fringilla elementum mauris, lacinia adipiscing est accumsan a. Aliquam erat volutpat. Ut nisi massa, ultrices eu congue ut, consectetur sed mauris. Integer arcu nunc, mattis mollis imperdiet tincidunt, ultrices eget neque. Curabitur rhoncus viverra ipsum, ac iaculis dolor rutrum at. Cras ac pharetra arcu. Nulla felis justo, venenatis ut molestie id, ultricies vel ante. Nam non lacus libero. Nulla posuere molestie tincidunt. Nulla nec tristique justo. Pellentesque nec condimentum eros. Nulla nec turpis id urna fermentum porttitor ut ut velit. In placerat odio porta augue facilisis ut sagittis ipsum volutpat. Morbi urna quam, fringilla eu facilisis eu, aliquet rutrum ipsum. Mauris feugiat justo id tellus rhoncus sit amet mattis lacus imperdiet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In at nunc quis nisl interdum feugiat vel a lectus. Proin sed arcu at lectus dictum mattis vel vel mauris. Suspendisse sollicitudin rhoncus tempor. Praesent massa nunc, consectetur sit amet pellentesque vitae, faucibus quis urna. In ut metus non orci consectetur aliquam. Nullam congue, mi et egestas vulputate, nibh leo ullamcorper dui, eget fermentum diam nisl id nulla. Donec dapibus dapibus justo, in pretium magna interdum et. In vitae mi non tortor gravida pulvinar at ac arcu. In hac habitasse platea dictumst. Proin pretium, tortor placerat suscipit auctor, lacus mi vestibulum lectus, vel accumsan arcu diam nec lectus. Aenean euismod fringilla purus vel tincidunt. Donec dignissim posuere mollis. Pellentesque convallis ipsum et nibh facilisis interdum. Nullam velit mauris, mattis et eleifend a, molestie tempor elit. Cras hendrerit, arcu at faucibus bibendum, ante diam pulvinar sapien, non viverra purus leo sed risus. Aliquam tempor rutrum augue, in ultrices lorem ultrices quis. Donec auctor laoreet cursus. Integer non elit lorem, nec pulvinar justo. Cras sagittis eleifend semper. Cras at lobortis tortor. Nam quis mi eget purus semper lobortis posuere vel magna. Sed porta, felis ac auctor fringilla, urna magna iaculis justo, at ullamcorper libero lectus vel tortor. Praesent at nunc tortor, vel fringilla lorem. Etiam quis rhoncus magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin ac libero tortor. Aenean ut orci at orci rhoncus aliquet. Proin feugiat, diam sed sodales aliquam, diam sem tincidunt urna, non viverra massa orci quis urna. Quisque tincidunt felis ut elit pretium ac posuere mi cursus. Vivamus quis dapibus ligula. Suspendisse potenti. Praesent ac diam ac nisl congue posuere. Nam sit amet risus faucibus orci vulputate porta et suscipit magna. Vivamus at quam quis lectus vehicula commodo eu vitae leo. Nunc dolor purus, ornare sed congue ac, feugiat et purus. In mi lorem, ultrices non varius sed, dapibus posuere eros. Sed faucibus venenatis risus vel elementum. Duis eget ornare mi. Phasellus iaculis nulla eget lacus vehicula venenatis. Pellentesque non tellus quis lorem congue pellentesque. Suspendisse vestibulum, nulla sed hendrerit tincidunt, quam nunc cursus libero, a feugiat arcu enim at odio. Ut vestibulum imperdiet tellus id imperdiet. Aliquam et dolor libero, a tempor erat. Cras sagittis venenatis interdum. Mauris nec consequat diam. Etiam condimentum, odio at fermentum elementum, risus elit malesuada magna, et fringilla massa ante et tellus. Cras ut leo quis mauris imperdiet fringilla in et augue. Vivamus vestibulum metus sed enim faucibus id pharetra sem ornare. Suspendisse eget justo nibh, eu auctor mi. Aliquam accumsan egestas mollis. Sed semper hendrerit enim vel pellentesque. Praesent vehicula turpis at ipsum faucibus non feugiat libero volutpat. Etiam sed dolor eu arcu porttitor lobortis nec non magna. Morbi sit amet viverra orci. Mauris sagittis erat sed diam ullamcorper facilisis. Donec purus neque, vestibulum ut ullamcorper eget, placerat in est. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus id diam turpis. Sed vestibulum, felis sed venenatis tempus, libero enim molestie ante, vel luctus nibh nisl a tortor. Mauris fermentum, quam eget rutrum sodales, tortor velit fringilla leo, id cursus purus nisi sed turpis. Nulla nibh mauris, pulvinar placerat ornare id, dapibus non ante. Mauris pretium viverra quam, eu tristique nisl sodales non. Nam sit amet dolor eros. Nulla facilisi. Nulla facilisi. Ut ultrices hendrerit consequat. Nam ligula orci, scelerisque varius tempor vel, convallis et nunc. Proin ullamcorper tempor posuere. Aenean et mi a sapien hendrerit mollis vel ornare ante. Suspendisse porta, velit sit amet dignissim placerat, ipsum lectus semper ligula, in bibendum felis urna a tortor. Suspendisse potenti. Fusce pretium, nunc quis varius viverra, sapien sem eleifend purus, sed tempus tortor sapien ut nisl. Suspendisse posuere venenatis risus vitae facilisis. Vestibulum consectetur metus lacus. Sed aliquam augue nisl. Suspendisse non purus in erat sodales dictum. Sed condimentum pellentesque gravida. Quisque vulputate, mi quis fringilla auctor, leo tellus porttitor eros, sed commodo enim metus vel mi. Phasellus in nulla lacinia lorem aliquam pretium in et justo. Nulla ac venenatis nisi. Praesent interdum pretium velit, et pulvinar ante consectetur quis. Morbi ut elit id orci tempor semper. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam porta accumsan tempus. Duis tellus sapien, commodo ut dapibus commodo, ornare id dui. Mauris at arcu neque, nec pretium nunc. Suspendisse nec nulla et erat malesuada varius. Pellentesque varius nisi ac metus egestas vitae ultricies mi porttitor. Praesent luctus adipiscing nunc, eu ornare metus gravida eget. Sed vel justo lorem, vitae tincidunt eros. Aliquam eleifend felis ac libero lobortis nec suscipit orci facilisis. Quisque convallis, velit non sodales hendrerit, risus odio sollicitudin nisl, sed porttitor mi dolor non turpis. Sed ac est quis felis lobortis porttitor. Nulla volutpat ipsum sodales magna commodo ut commodo metus convallis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur vestibulum sapien ac erat volutpat ultrices. In dignissim luctus leo sit amet mollis. Integer eget sagittis nunc. Cras felis turpis, pretium aliquet fringilla in, dapibus ut justo. Mauris sit amet pharetra leo. Nulla lectus elit, laoreet nec scelerisque eu, bibendum eget diam. Nunc vehicula blandit sem vel ultricies. Praesent sollicitudin eleifend imperdiet. Sed eget lectus vel sapien varius facilisis. Cras felis nisl, vehicula vitae feugiat nec, tincidunt a lacus. Aliquam enim neque, scelerisque et euismod non, ornare ut ipsum. Donec lectus lorem, sodales ac porta id, condimentum a metus. Nullam et lobortis augue. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum mollis tortor non diam sodales tincidunt. Mauris vestibulum lorem a lectus lobortis commodo. Sed tempor, libero ac dictum posuere, leo massa hendrerit libero, at sodales eros enim in diam. Praesent tincidunt ligula eget augue ornare sit amet vehicula tellus tristique. Etiam vel pretium felis. Cras aliquam auctor auctor. Duis dictum sapien non urna posuere feugiat. Aliquam rutrum sem non metus auctor placerat. Nulla laoreet, erat eu sodales imperdiet, nisl arcu condimentum augue, sed dictum nisl tortor sit amet elit. Suspendisse ullamcorper magna ac dolor convallis sed aliquet quam commodo. Pellentesque eget magna tortor, non rhoncus est. Suspendisse malesuada vestibulum commodo. Maecenas venenatis, lacus sed venenatis convallis, lectus dolor gravida libero, porttitor ultrices urna purus ut lectus. Praesent mollis vulputate nibh, nec interdum tortor elementum id. Aenean lacinia accumsan purus, nec sodales enim tempus eget. Pellentesque aliquam tempor nisl, at volutpat orci dignissim in. Fusce sit amet sapien nec justo commodo auctor id sed augue. Aliquam ultricies consectetur lorem, eu accumsan dui facilisis at. Sed tristique porttitor nunc, at auctor diam gravida sit amet. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed eget nibh odio. Nullam et ipsum eu tortor dictum viverra. Sed et mauris ante, nec commodo quam. Proin purus mi, tristique eu lacinia quis, tincidunt sit amet dolor. Quisque congue fermentum sem, et ultricies lorem pharetra at. Pellentesque tincidunt placerat odio tempus semper. Mauris pretium tempor diam, eget fermentum elit aliquet at. Aenean pulvinar lorem eget arcu ultrices sodales. Maecenas elementum, enim ut aliquet tincidunt, neque diam convallis felis, eu tempus justo leo a nunc. Phasellus iaculis lobortis ullamcorper. Aenean posuere faucibus porttitor. Pellentesque dapibus dictum ornare. Suspendisse quis varius ipsum. Etiam porta, ante vitae sodales elementum, dui urna dapibus tellus, vel accumsan lacus odio et lorem. Aliquam elementum accumsan purus vitae elementum. Aenean non bibendum lacus. Nunc hendrerit blandit posuere. Curabitur sed tortor et orci facilisis ullamcorper. Suspendisse et ipsum sem, ac porttitor nisl. Phasellus tempor egestas tellus, vitae dictum lorem pellentesque ac. Donec ut dictum magna. Mauris fringilla sapien a elit pulvinar et aliquam diam aliquam. Suspendisse congue imperdiet risus non hendrerit. Vestibulum tristique quam eget ipsum gravida ultricies. Aliquam dui tortor, elementum ut tristique vel, euismod at libero. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam est metus, euismod in condimentum eu, porttitor et nisl. Aliquam eu vestibulum massa. Ut ac aliquam mauris. Donec ultrices bibendum nunc sit amet faucibus. Sed erat lacus, rhoncus at pharetra quis, semper eget nunc. Praesent luctus ligula in urna convallis viverra. Sed et faucibus elit. Aenean eleifend, dolor vel ultricies egestas, turpis tortor pharetra purus, non malesuada dolor lectus et quam. Proin et est ligula. Suspendisse faucibus placerat tincidunt. Nulla condimentum dictum magna. Nullam dignissim, dui at vulputate vulputate, urna libero porta mauris, pharetra viverra mi odio eget enim. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per. """ words = lipsum.split() max_start = len(words) - count start = random.randrange(0, max_start) output = ' '.join(words[start:start + count]).capitalize() return output if __name__ == "__main__": main()
137.548571
1,160
0.782934
3,507
24,071
5.348161
0.095238
0.013809
0.007997
0.010877
0.095543
0.065046
0.063126
0.063126
0.053103
0.053103
0
0.002707
0.171326
24,071
174
1,161
138.33908
0.937585
0.027793
0
0.067416
0
0.292135
0.92174
0.011061
0
0
0
0
0
1
0.078652
false
0
0.089888
0
0.202247
0.067416
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
6f0a9db7e0330d57e22fd36e1f753e215650d101
82
py
Python
Complete-Python-3-Bootcamp-master/07-Errors and Exception Handling/cap.py
davidMartinVergues/PYTHON
dd39d3aabfc43b3cb09aadb2919e51d03364117d
[ "DOC" ]
8
2020-09-02T03:59:02.000Z
2022-01-08T23:36:19.000Z
07-Errors and Exception Handling/cap.py
AkshitOstwal/Python_Bootcamp
ce810d0d9e5f9b04d7795f3b1024c8b4b1ad3bc8
[ "MIT" ]
1
2021-06-13T20:24:47.000Z
2021-06-13T20:24:47.000Z
07-Errors and Exception Handling/cap.py
AkshitOstwal/Python_Bootcamp
ce810d0d9e5f9b04d7795f3b1024c8b4b1ad3bc8
[ "MIT" ]
6
2019-11-13T13:33:30.000Z
2021-10-06T09:56:43.000Z
def cap_text(text): return text.title() # replace .capitalize() with .title()
41
62
0.682927
11
82
5
0.727273
0
0
0
0
0
0
0
0
0
0
0
0.158537
82
2
62
41
0.797101
0.426829
0
0
0
0
0
0
0
0
0
0
0
1
0.5
false
0
0
0.5
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
0
0
0
4
6f17a056fcde5dfff4e48761f4013d1b4fdb72e0
2,269
py
Python
RESTProject/accounts/models.py
rzhvn1/REST-API
6bb6620eebff9fa3c53fbaf7569283e4472719c1
[ "MIT" ]
null
null
null
RESTProject/accounts/models.py
rzhvn1/REST-API
6bb6620eebff9fa3c53fbaf7569283e4472719c1
[ "MIT" ]
null
null
null
RESTProject/accounts/models.py
rzhvn1/REST-API
6bb6620eebff9fa3c53fbaf7569283e4472719c1
[ "MIT" ]
null
null
null
from django.contrib.auth.models import User from django.db import models #TODO order_count class RestaurantProfile(models.Model): #id full_name = models.CharField(max_length=50) age = models.PositiveIntegerField(default=0) date_start = models.DateField(auto_now_add=True) date_end = models.DateField(auto_now_add=True) salary = models.PositiveIntegerField(default=0) schedule = models.CharField(choices=( ('2/2', '2/2'), ('5/2', '5/2') ), max_length=50) user = models.OneToOneField(User, on_delete=models.CASCADE, null=True) order_count = models.PositiveIntegerField(default=0) class Table(models.Model): area = models.CharField(choices=( ('Main', 'Main'), ('Street', 'Street'), ('VIP', 'VIP'), ), max_length=50) status = models.CharField(choices=( ('Reserved', 'Reserved'), ('Free', 'Free'), ), max_length=50) class UserProfile(models.Model): user = models.OneToOneField(User, on_delete = models.CASCADE, null=True) full_name = models.CharField(max_length=50) phone = models.PositiveIntegerField(default=0) street = models.CharField(max_length=50) house = models.CharField(max_length=10) email = models.EmailField() bonuses = models.PositiveIntegerField(default=0, blank=True) order_count = models.PositiveIntegerField(default=0, blank=True) class Card(models.Model): profile = models.ForeignKey(UserProfile, on_delete=models.CASCADE, related_name='cards') number = models.PositiveIntegerField(default=0) holder_name = models.CharField(max_length=50) date = models.DateField() code = models.IntegerField(default=0) balance = models.PositiveIntegerField(default=0) status = models.CharField(choices= ( ('default', 'default'), ('non active', 'non active'), ), max_length=15, default='non active')
34.907692
92
0.574262
224
2,269
5.705357
0.321429
0.105634
0.206573
0.212833
0.339593
0.319249
0.212833
0.087637
0.087637
0.087637
0
0.022422
0.312032
2,269
64
93
35.453125
0.796284
0.007933
0
0.155556
0
0
0.049642
0
0
0
0
0.015625
0
1
0
false
0
0.044444
0
0.688889
0
0
0
0
null
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
1
0
0
4
6f1b00505f65058ea29dc68f23694fac92651aa2
316
py
Python
tests/tests.py
nickjevershed/Reportermate-Lib
2ab2eee166b85f3e5e24dfaacf6179ecf68fdc1e
[ "MIT" ]
60
2019-02-01T04:55:15.000Z
2021-11-30T06:44:11.000Z
tests/tests.py
nickjevershed/Reportermate-Lib
2ab2eee166b85f3e5e24dfaacf6179ecf68fdc1e
[ "MIT" ]
9
2017-02-26T05:14:30.000Z
2019-09-16T03:30:23.000Z
tests/tests.py
nickjevershed/Reportermate-Lib
2ab2eee166b85f3e5e24dfaacf6179ecf68fdc1e
[ "MIT" ]
8
2019-02-07T10:19:12.000Z
2021-01-08T16:09:20.000Z
import reportermate print(reportermate.analyseAndRender('expenses.csv', 'expenses-template.txt', 'expenses-replace.json')) print(reportermate.analyseAndRender('unemployment.csv', 'unemployment-template.txt')) print(reportermate.analyseAndRender('donations.csv', 'donations-template.txt', 'donations-replace.json'))
52.666667
105
0.810127
32
316
8
0.375
0.199219
0.386719
0
0
0
0
0
0
0
0
0
0.03481
316
5
106
63.2
0.839344
0
0
0
0
0
0.481013
0.351266
0
0
0
0
0
1
0
true
0
0.25
0
0.25
0.75
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
1
0
0
0
0
1
0
4
6f48f5389c2fc0c14de5d6990a5f9d2cbf965f9e
797
py
Python
backend/api/apps/core/permissions.py
Jeffallan/timekeeper
ecad4dba84781a9f5b592cd639ad43dc35708e11
[ "Apache-2.0" ]
1
2022-02-13T21:13:10.000Z
2022-02-13T21:13:10.000Z
backend/api/apps/core/permissions.py
Jeffallan/timekeeper
ecad4dba84781a9f5b592cd639ad43dc35708e11
[ "Apache-2.0" ]
8
2021-11-14T20:00:25.000Z
2021-12-04T18:52:18.000Z
backend/api/apps/core/permissions.py
Jeffallan/timekeeper
ecad4dba84781a9f5b592cd639ad43dc35708e11
[ "Apache-2.0" ]
null
null
null
from rest_framework import permissions class IsUserOrReadOnly(permissions.BasePermission): """ Object-level permission to only allow owners of an object to edit it. """ def has_object_permission(self, request, view, obj): if request.method in permissions.SAFE_METHODS: return True if request.user.is_staff: return True return obj == request.user class IsAdmin(permissions.BasePermission): def has_permission(self, request, view): return request.user.role == 1 class IsStaff(permissions.BasePermission): def has_permission(self, request, view): return request.user.role == 2 class IsUser(permissions.BasePermission): def has_permission(self, request, view): return request.user.role == 3
25.709677
73
0.692597
95
797
5.726316
0.442105
0.101103
0.154412
0.183824
0.424632
0.424632
0.424632
0.424632
0.424632
0.424632
0
0.004854
0.224592
797
31
74
25.709677
0.875405
0.086575
0
0.294118
0
0
0
0
0
0
0
0
0
1
0.235294
false
0
0.058824
0.176471
0.882353
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
1
1
0
0
4
6f52e79f0e1f767cfbe1b57e960ee84bf28c346c
164
py
Python
heroku3/compat.py
simlun/heroku3.py
398e6436b2e9e90277384e97e43416c19abb32d9
[ "MIT" ]
1
2019-03-15T16:54:32.000Z
2019-03-15T16:54:32.000Z
heroku3/compat.py
fabianheredia/heroku3.py
7d6e82050c8ae35052b81b94597292d74dc4ab40
[ "MIT" ]
null
null
null
heroku3/compat.py
fabianheredia/heroku3.py
7d6e82050c8ae35052b81b94597292d74dc4ab40
[ "MIT" ]
null
null
null
# -*- coding: utf-8 -*- """ heroku3.compat ~~~~~~~~~~~~~ Compatiblity for heroku3.py. """ try: import json except ImportError: import simplejson as json
11.714286
29
0.603659
18
164
5.5
0.833333
0
0
0
0
0
0
0
0
0
0
0.022727
0.195122
164
13
30
12.615385
0.727273
0.493902
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.75
0
0.75
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
4
6f603b7e2a9689e5dea9b419717c4a587c4fc63a
276
py
Python
instagram_api/response/challenge.py
Yuego/instagram_api
b53f72db36c505a2eb24ebac1ba8267a0cc295bb
[ "MIT" ]
13
2019-08-07T21:24:34.000Z
2020-12-12T12:23:50.000Z
instagram_api/response/challenge.py
Yuego/instagram_api
b53f72db36c505a2eb24ebac1ba8267a0cc295bb
[ "MIT" ]
null
null
null
instagram_api/response/challenge.py
Yuego/instagram_api
b53f72db36c505a2eb24ebac1ba8267a0cc295bb
[ "MIT" ]
null
null
null
from .mapper import ApiResponse, ApiResponseInterface from .mapper.types import Timestamp, AnyType __all__ = ['ChallengeResponse'] class ChallengeResponseInterface(ApiResponseInterface): pass class ChallengeResponse(ApiResponse, ChallengeResponseInterface): pass
21.230769
65
0.818841
22
276
10.090909
0.590909
0.09009
0
0
0
0
0
0
0
0
0
0
0.119565
276
12
66
23
0.91358
0
0
0.285714
0
0
0.061594
0
0
0
0
0
0
1
0
false
0.285714
0.285714
0
0.571429
0
1
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
1
0
0
1
0
0
4
6f62a51bd53bf880f680e4f7813ef4df5890ffd1
145
py
Python
awsrek/faced/forms.py
PDahal2871/AWS_Rekognition
b83a8e4608c0976e108956caffe67240cd3e0adb
[ "MIT" ]
null
null
null
awsrek/faced/forms.py
PDahal2871/AWS_Rekognition
b83a8e4608c0976e108956caffe67240cd3e0adb
[ "MIT" ]
null
null
null
awsrek/faced/forms.py
PDahal2871/AWS_Rekognition
b83a8e4608c0976e108956caffe67240cd3e0adb
[ "MIT" ]
null
null
null
from django.forms import ModelForm from .models import * class AWSForm(ModelForm): class Meta: model=Aws fields = '__all__'
18.125
34
0.668966
17
145
5.470588
0.764706
0
0
0
0
0
0
0
0
0
0
0
0.255172
145
7
35
20.714286
0.861111
0
0
0
0
0
0.048276
0
0
0
0
0
0
1
0
false
0
0.333333
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
48ac7aa5008ecb13434865950fad6b18c235f320
72
py
Python
tools/report-converter/tests/unit/pylint_output_test_files/files/simple.py
ryankurte/codechecker
737424ee77c181304f242d5a2adef3e6d9369998
[ "Apache-2.0" ]
1,601
2015-07-22T20:01:32.000Z
2022-03-31T03:04:36.000Z
tools/report-converter/tests/unit/pylint_output_test_files/files/simple.py
ryankurte/codechecker
737424ee77c181304f242d5a2adef3e6d9369998
[ "Apache-2.0" ]
2,056
2015-07-20T09:39:25.000Z
2022-03-31T10:18:08.000Z
tools/report-converter/tests/unit/pylint_output_test_files/files/simple.py
ryankurte/codechecker
737424ee77c181304f242d5a2adef3e6d9369998
[ "Apache-2.0" ]
288
2015-07-15T18:57:18.000Z
2022-03-30T13:40:13.000Z
#!/usr/bin/env python3 import json def foo(x): return 1 foo(0)
6.545455
22
0.611111
13
72
3.384615
0.923077
0
0
0
0
0
0
0
0
0
0
0.055556
0.25
72
10
23
7.2
0.759259
0.291667
0
0
0
0
0
0
0
0
0
0
0
1
0.25
false
0
0.25
0.25
0.75
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
1
0
0
4
48c7808843e1460ed164957184546c6954407447
160
py
Python
picamera/picam_lib/__init__.py
suet-lee/mycelium
db83cd3ab00697f28b2def2cebcdef52698fdd92
[ "Apache-2.0" ]
6
2021-05-23T17:36:02.000Z
2022-01-21T20:34:17.000Z
picamera/picam_lib/__init__.py
suet-lee/mycelium
db83cd3ab00697f28b2def2cebcdef52698fdd92
[ "Apache-2.0" ]
null
null
null
picamera/picam_lib/__init__.py
suet-lee/mycelium
db83cd3ab00697f28b2def2cebcdef52698fdd92
[ "Apache-2.0" ]
1
2021-06-17T20:35:10.000Z
2021-06-17T20:35:10.000Z
from .filter import FilterPosWheel, FilterContWheel from .picam_impl import PicamImpl from .mission import FilterMissionExec, WaypointMissionExec, FilterCapture
53.333333
74
0.875
16
160
8.6875
0.75
0
0
0
0
0
0
0
0
0
0
0
0.0875
160
3
74
53.333333
0.952055
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
48d438293a6c395ec043a2b3162ba0f55314ec79
601
py
Python
ugd/markov_walk/constraint_violation_check.py
bryangraham/ugd
5ea6535a2a32385232a47a0739377162f9461c77
[ "MIT" ]
1
2021-12-01T09:43:00.000Z
2021-12-01T09:43:00.000Z
ugd/markov_walk/constraint_violation_check.py
bryangraham/ugd
5ea6535a2a32385232a47a0739377162f9461c77
[ "MIT" ]
null
null
null
ugd/markov_walk/constraint_violation_check.py
bryangraham/ugd
5ea6535a2a32385232a47a0739377162f9461c77
[ "MIT" ]
3
2021-02-23T16:34:27.000Z
2021-11-29T22:14:15.000Z
import numpy as np # from ugd.markov_walk.markov_walk_util import is_feasible , set_elm_to_non_exept from itertools import combinations ''' no_violations checks whether all partition constraint are fulfilled. no_violation is a interface, which can be customized. Examples are if you are only interested in the restriction of edges between two specific groups. In this case only the specific element in the matrix has to be checked. Another example is fixing the number of triads in the graph. ''' def no_violations(violation_matrix, graph = None): return np.all(violation_matrix==0)
25.041667
119
0.792013
95
601
4.873684
0.673684
0.032397
0
0
0
0
0
0
0
0
0
0.001992
0.164725
601
23
120
26.130435
0.920319
0.131448
0
0
0
0
0
0
0
0
0
0
0
1
0.25
false
0
0.5
0.25
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
1
1
1
0
0
4
48d5382fa6630e62193f68c855a3df2bdea5dd07
202,198
py
Python
chb/mips/simulation/MIPSimStubs.py
sipma/CodeHawk-Binary
3d4a0c2958266571f8f660cb48f29339b253c07f
[ "MIT" ]
null
null
null
chb/mips/simulation/MIPSimStubs.py
sipma/CodeHawk-Binary
3d4a0c2958266571f8f660cb48f29339b253c07f
[ "MIT" ]
null
null
null
chb/mips/simulation/MIPSimStubs.py
sipma/CodeHawk-Binary
3d4a0c2958266571f8f660cb48f29339b253c07f
[ "MIT" ]
null
null
null
# ------------------------------------------------------------------------------ # CodeHawk Binary Analyzer # Author: Henny Sipma # ------------------------------------------------------------------------------ # The MIT License (MIT) # # Copyright (c) 2020-2021 Henny Sipma # Copyright (c) 2021 Aarno Labs LLC # # 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. # ------------------------------------------------------------------------------ """Simulation code for library functions.""" from typing import ( Any, BinaryIO, Callable, cast, Dict, IO, List, Optional, Tuple, Type, TYPE_CHECKING) import datetime import ipaddress import os import time from chb.mips.simulation.MIPSimMemory import MIPSimStackMemory, MIPSimGlobalMemory from chb.simulation.SimBaseMemory import SimBaseMemory from chb.simulation.SimSharedMemory import SimSharedMemory from chb.simulation.SimMappedMemory import SimMappedMemory import chb.simulation.SimFileUtil as SFU from chb.simulation.SimStub import SimStub import chb.simulation.SimSymbolicValue as SSV import chb.simulation.SimValue as SV import chb.simulation.SimUtil as SU import chb.util.fileutil as UF if TYPE_CHECKING: from chb.mips.MIPSAccess import MIPSAccess from chb.simulation.SimulationState import SimulationState def stubbed_libc_functions() -> Dict[str, "MIPSimStub"]: return { "accept": MIPStub_accept(), "access": MIPStub_access(), "atoi": MIPStub_atoi(), "atol": MIPStub_atol(), "basename": MIPStub_basename(), "bind": MIPStub_bind(), "bsearch": MIPStub_bsearch(), "calculate_checksum": MIPStub_calculate_checksum(), "calloc": MIPStub_calloc(), "chdir": MIPStub_chdir(), "clock_gettime": MIPStub_clock_gettime(), "close": MIPStub_close(), "closelog": MIPStub_closelog(), "connect": MIPStub_connect(), "daemon": MIPStub_daemon(), "dlopen": MIPStub_dlopen(), "dlsym": MIPStub_dlsym(), "dprintf": MIPStub_dprintf(), "dup": MIPStub_dup(), "dup2": MIPStub_dup2(), "epoll_create": MIPStub_epoll_create(), "epoll_ctl": MIPStub_epoll_ctl(), "epoll_wait": MIPStub_epoll_wait(), "__errno_location": MIPStub___errno_location(), "execve": MIPStub_execve(), "exit": MIPStub_exit(), "_exit": MIPStub_exit(), "fclose": MIPStub_fclose(), "fcntl": MIPStub_fcntl(), "fcntl64": MIPStub_fcntl64(), "fdopen": MIPStub_fdopen(), "feof": MIPStub_feof(), "__fgetc_unlocked": MIPStub___fgetc_unlocked(), "fflush": MIPStub_fflush(), "fgets": MIPStub_fgets(), "fileno": MIPStub_fileno(), "fopen": MIPStub_fopen(), "fopen64": MIPStub_fopen64(), "fork": MIPStub_fork(), "fprintf": MIPStub_fprintf(), "fputs": MIPStub_fputs(), "fread": MIPStub_fread(), "free": MIPStub_free(), "freeaddrinfo": MIPStub_freeaddrinfo(), "fscanf": MIPStub_fscanf(), "fstat": MIPStub_fstat(), "fstat64": MIPStub_fstat64(), "fwrite": MIPStub_fwrite(), "getaddrinfo": MIPStub_getaddrinfo(), "get_current_dir_name": MIPStub_get_current_dir_name(), "getcwd": MIPStub_getcwd(), "getenv": MIPStub_getenv(), "gethostname": MIPStub_gethostname(), "getline": MIPStub_getline(), "getopt": MIPStub_getopt(), "getopt_long": MIPStub_getopt_long(), "getpeername": MIPStub_getpeername(), "getpid": MIPStub_getpid(), "getpwnam": MIPStub_getpwnam(), "getpwuid": MIPStub_getpwuid(), "getrlimit64": MIPStub_getrlimit64(), "getsockname": MIPStub_getsockname(), "gettimeofday": MIPStub_gettimeofday(), "getuid": MIPStub_getuid(), "index": MIPStub_index(), "inet_addr": MIPStub_inet_addr(), "inet_aton": MIPStub_inet_aton(), "inet_ntoa": MIPStub_inet_ntoa(), "inet_pton": MIPStub_inet_pton(), "ioctl": MIPStub_ioctl(), "isatty": MIPStub_isatty(), "__libc_current_sigrtmax": MIPStub___libc_current_sigrtmax(), "__libc_current_sigrtmin": MIPStub___libc_current_sigrtmin(), "listen": MIPStub_listen(), "localtime": MIPStub_localtime(), "lockf": MIPStub_lockf(), "longjmp": MIPStub_longjmp(), "malloc": MIPStub_malloc(), "mallopt": MIPStub_mallopt(), "memcmp": MIPStub_memcmp(), "memcpy": MIPStub_memcpy(), "memmove": MIPStub_memmove(), "memset": MIPStub_memset(), "mkdir": MIPStub_mkdir(), "mktemp": MIPStub_mktemp(), "mmap": MIPStub_mmap(), "msgget": MIPStub_msgget(), "open": MIPStub_open(), "open64": MIPStub_open64(), "openlog": MIPStub_openlog(), "pclose": MIPStub_pclose(), "perror": MIPStub_perror(), "popen": MIPStub_popen(), "printf": MIPStub_printf(), "pthread_attr_init": MIPStub_pthread_attr_init(), "pthread_attr_setschedparam": MIPStub_pthread_attr_setschedparam(), "pthread_attr_setschedpolicy": MIPStub_pthread_attr_setschedpolicy(), "pthread_cond_init": MIPStub_pthread_cond_init(), "pthread_cond_signal": MIPStub_pthread_cond_signal(), "pthread_create": MIPStub_pthread_create(), "pthread_mutex_init": MIPStub_pthread_mutex_init(), "pthread_mutex_lock": MIPStub_pthread_mutex_lock(), "pthread_mutex_unlock": MIPStub_pthread_mutex_unlock(), "pthread_self": MIPStub_pthread_self(), "putenv": MIPStub_putenv(), "puts": MIPStub_puts(), "rand": MIPStub_rand(), "random": MIPStub_random(), "read": MIPStub_read(), "realloc": MIPStub_realloc(), "realpath": MIPStub_realpath(), "reboot": MIPStub_reboot(), "recv": MIPStub_recv(), "recvfrom": MIPStub_recvfrom(), "rt_sigaction": MIPStub_sigaction(name="rt_sigaction"), "sched_get_priority_max": MIPStub_sched_get_priority_max(), "sched_get_priority_min": MIPStub_sched_get_priority_max(), "sched_yield": MIPStub_sched_yield(), "select": MIPStub_select(), "semctl": MIPStub_semctl(), "semget": MIPStub_semget(), "semop": MIPStub_semop(), "send": MIPStub_send(), "sendto": MIPStub_sendto(), "setenv": MIPStub_setenv(), "_setjmp": MIPStub__setjmp(), "setlogmask": MIPStub_setlogmask(), "setrlimit": MIPStub_setrlimit(), "setrlimit64": MIPStub_setrlimit(), "setsid": MIPStub_setsid(), "setsockopt": MIPStub_setsockopt(), "shmat": MIPStub_shmat(), "shmctl": MIPStub_shmctl(), "shmdt": MIPStub_shmdt(), "shmget": MIPStub_shmget(), "sigaction": MIPStub_sigaction(), "sigaddset": MIPStub_sigaddset(), "sigemptyset": MIPStub_sigemptyset(), "signal": MIPStub_signal(), "sigprocmask": MIPStub_sigprocmask(), "sleep": MIPStub_sleep(), "snprintf": MIPStub_snprintf(), "socket": MIPStub_socket(), "sprintf": MIPStub_sprintf(), "srand": MIPStub_srand(), "sscanf": MIPStub_sscanf(), "stat": MIPStub_stat(), "strcasecmp": MIPStub_strcasecmp(), "strcat": MIPStub_strcat(), "strchr": MIPStub_strchr(), "strcmp": MIPStub_strcmp(), "strcpy": MIPStub_strcpy(), "strdup": MIPStub_strdup(), "strerror": MIPStub_strerror(), "stristr": MIPStub_stristr(), "strlen": MIPStub_strlen(), "strncasecmp": MIPStub_strncasecmp(), "strncat": MIPStub_strncat(), "strncmp": MIPStub_strncmp(), "strncpy": MIPStub_strncpy(), "strrchr": MIPStub_strrchr(), "strsep": MIPStub_strsep(), "strstr": MIPStub_strstr(), "strtof": MIPStub_strtof(), "strtok": MIPStub_strtok(), "strtok_r": MIPStub_strtok_r(), "strtol": MIPStub_strtol(), "strtoul": MIPStub_strtoul(), "syslog": MIPStub_syslog(), "system": MIPStub_system(), "tcgetattr": MIPStub_tcgetattr(), "tcsetattr": MIPStub_tcsetattr(), "time": MIPStub_time(), "tolower": MIPStub_tolower(), "umask": MIPStub_umask(), "unlink": MIPStub_unlink(), "unsetenv": MIPStub_unsetenv(), "usleep": MIPStub_usleep(), "vfork": MIPStub_vfork(), "vsnprintf": MIPStub_vsnprintf(), "vsprintf": MIPStub_vsprintf(), "waitpid": MIPStub_waitpid(), "write": MIPStub_write(), "isLanSubnet": MIPStub_isLanSubnet(), "msglogd": MIPStub_msglogd() # libmsglog.so } fcntl_cmds = { "0x0": "F_DUPFD", "0x1": "F_GETFD", "0x2": "F_SETFD", "0x3": "F_GETFL", "0x4": "F_SETFL" } class MIPSimStub(SimStub): def __init__(self, name: str) -> None: SimStub.__init__(self, name) def get_arg_val( self, iaddr: str, simstate: "SimulationState", arg: str) -> SV.SimValue: """Returns a SimValue; arg must be a MIPS register.""" return simstate.regval(iaddr, arg) def get_arg_deref_val( self, iaddr: str, simstate: "SimulationState", arg: str) -> SV.SimValue: """Returns a SimValue, pointed to by the arg-val.""" saddr = self.get_arg_val(iaddr, simstate, arg) if saddr.is_address: saddr = cast(SSV.SimAddress, saddr) return simstate.memval(iaddr, saddr, 4) else: return SV.simUndefinedDW def get_stack_arg_val( self, iaddr: str, simstate: "SimulationState", argindex: int) -> SV.SimValue: """Returns a SimValue for an argument on the stack.""" sp = simstate.regval(iaddr, "sp") if sp.is_address: sp = cast(SSV.SimAddress, sp) if sp.is_stack_address: sp = cast(SSV.SimStackAddress, sp) stackaddr = sp.add_offset(4 * argindex) return simstate.memval(iaddr, stackaddr, 4) return SV.simUndefinedDW def get_arg_string( self, iaddr: str, simstate: "SimulationState", arg: str) -> str: """Returns a string; arg must be a MIPS register.""" saddr = self.get_arg_val(iaddr, simstate, arg) return self.get_string_at_address(iaddr, simstate, saddr) def get_string_at_address( self, iaddr: str, simstate: "SimulationState", saddr: SV.SimValue) -> str: result = '' offset = 0 if saddr.is_string_address: saddr = cast(SSV.SimStringAddress, saddr) return saddr.stringval elif saddr.is_symbol: saddr = cast(SSV.SimSymbol, saddr) return 'symbol:' + saddr.name elif saddr.is_literal and not saddr.is_defined: return '*****address-not-defined*****' elif saddr.is_address: gaddr = cast(SSV.SimGlobalAddress, saddr) elif saddr.is_literal and saddr.is_defined: saddr = cast(SV.SimLiteralValue, saddr) gaddr = simstate.resolve_literal_address(iaddr, saddr.value) if not gaddr.is_defined: raise SU.CHBSimError( simstate, iaddr, "String argument is not a valid address: " + str(saddr)) else: gaddr = cast(SSV.SimGlobalAddress, saddr) while True: srcaddr = gaddr.add_offset(offset) srcval = simstate.memval(iaddr, srcaddr, 1) if srcval.is_literal and srcval.is_defined: srcval = cast(SV.SimLiteralValue, srcval) if srcval.value == 0: break result += chr(srcval.value) offset += 1 else: break return result def get_stack_arg_string( self, iaddr: str, simstate: "SimulationState", argindex: int) -> str: sp = simstate.regval(iaddr, "sp") if sp.is_address: sp = cast(SSV.SimAddress, sp) if sp.is_stack_address: sp = cast(SSV.SimStackAddress, sp) stackaddr = sp.add_offset(4 * argindex) return self.get_string_at_address(iaddr, simstate, stackaddr) return "******stack-address-not-defined*******" def get_arg_deref_string( self, iaddr: str, simstate: "SimulationState", arg: str) -> str: """Returns a string; arg must be a MIPS register.""" saddrptr = self.get_arg_val(iaddr, simstate, arg) if saddrptr.is_address: saddrptr = cast(SSV.SimAddress, saddrptr) saddr = simstate.memval(iaddr, saddrptr, 4) if saddr.is_address: saddr = cast(SSV.SimAddress, saddr) result = "" offset = 0 while True: srcaddr = saddr.add_offset(offset) srcval = simstate.memval(iaddr, srcaddr, 1) if srcval.is_literal and srcval.is_defined: srcval = cast(SV.SimLiteralValue, srcval) if srcval.value == 0: break result += chr(srcval.value) offset += 1 else: break return result else: raise SU.CHBSimError( simstate, iaddr, ("Pointed to value in arg_deref_string " + " is not an address: " + str(saddr))) else: raise SU.CHBSimError( simstate, iaddr, ("Argument is not an address in arg_deref_string: " + str(saddrptr))) def is_error_operation(self) -> bool: return False def is_io_operation(self) -> bool: return False def is_network_operation(self) -> bool: return False def is_string_operation(self) -> bool: return False def is_environment_operation(self) -> bool: return False def is_thread_operation(self) -> bool: return False def is_process_operation(self) -> bool: return False def is_memalloc_operation(self) -> bool: return False def is_sharedmem_operation(self) -> bool: return False def is_system_operation(self) -> bool: return False def is_domain_call(self) -> Optional[str]: return None def add_logmsg( self, iaddr: str, simstate: "SimulationState", arguments: str, returnval: str = "") -> str: preturn = 'return value: ' + returnval if returnval else '' msg = self.name + '(' + arguments + ') ' + preturn simstate.add_logmsg('stub:' + self.name, msg) if self.is_error_operation(): simstate.add_logmsg('error:', msg) if self.is_io_operation(): simstate.add_logmsg('i/o:', msg) if self.is_network_operation(): simstate.add_logmsg('network:', msg) if self.is_string_operation(): simstate.add_logmsg('string:', msg) if self.is_thread_operation(): simstate.add_logmsg('thread:', msg) if self.is_process_operation(): simstate.add_logmsg('process:', msg) if self.is_memalloc_operation(): simstate.add_logmsg('memory allocation:', msg) if self.is_sharedmem_operation(): simstate.add_logmsg('shared memory:', msg) if self.is_system_operation(): simstate.add_logmsg('system', msg) if self.is_domain_call(): domain = cast(str, self.is_domain_call()) simstate.add_logmsg('domain:' + domain, msg) return msg def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Dummy function.""" raise SU.CHBSimError( simstate, iaddr, "Simulation not implemented for " + self.name) def __str__(self) -> str: return self.name class MIPStub_accept(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "accept") self.count = 0 def is_io_operation(self) -> bool: return True def is_network_operation(self) -> bool: return True # a new file descriptor shall be allocated for the socket def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a2deref = self.get_arg_deref_val(iaddr, simstate, "a2") pargs = ( ','.join(str(a) for a in [a0, a1]) + ',' + str(a2) + ':' + str(a2deref)) if self.count == 0: simstate.set_register(iaddr, "v0", SV.mk_simvalue(4)) rv = "4" self.count += 1 if a1.is_address: a1 = cast(SSV.SimAddress, a1) if a2deref.is_literal and a2deref.is_defined: a2deref = cast(SV.SimLiteralValue, a2deref) if a2deref.value == 16: simstate.set_memval( iaddr, a1, SV.mk_simvalue(0, size=2)) simstate.set_memval( iaddr, a1.add_offset(2), SV.mk_simvalue(80, size=2)) simstate.set_memval( iaddr, a1.add_offset(4), SV.mk_simvalue(444)) simstate.set_memval( iaddr, a1.add_offset(8), SV.mk_simvalue(0)) simstate.set_memval( iaddr, a1.add_offset(12), SV.mk_simvalue(0)) else: simstate.set_register(iaddr, "v0", SV.mk_simvalue(-1)) rv = "-1" return self.add_logmsg(iaddr, simstate, pargs, returnval=rv) class MIPStub_access(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "access") def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = str(a0) + ':' + a0str + ',' + str(a1) simstate.set_register(iaddr, 'v0', SV.mk_simvalue(-1)) return self.add_logmsg(iaddr, simstate, pargs, returnval="-1") class MIPStub_atoi(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "atoi") def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') try: a0str = self.get_arg_string(iaddr, simstate, "a0") except Exception as e: raise SU.CHBSimError( simstate, iaddr, "atoi: " + str(a0) + " is not a string. (" + str(e) + ")") pargs = str(a0) + ":" + a0str try: result = int(a0str) except Exception as e: print('String ' + a0str + " cannot be converted to int: " + str(e)) simstate.add_logmsg( "error:", "Conversion to int failed in atoi: " + a0str) result = -1 simstate.set_register(iaddr, "v0", SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_atol(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "atol") def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') try: a0str = self.get_arg_string(iaddr, simstate, 'a0') except Exception as e: raise SU.CHBSimError( simstate, iaddr, "atol: " + str(a0) + " is not a string. (" + str(e) + ")") pargs = str(a0) + ':' + a0str try: result = int(a0str) except Exception as e: print('String ' + a0str + ' cannot be converted to long: ' + str(e)) simstate.add_logmsg( 'error:', 'Conversion to long failed in atol: ' + a0str) result = -1 simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_basename(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'basename') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Returns (in v0) the basename set in simstate, expressed as SimString.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SSV.mk_string_address(simstate.modulename)) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_bind(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'bind') def is_io_operation(self) -> bool: return True def is_network_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') if a1.is_address: a1 = cast(SSV.SimAddress, a1) safamily = simstate.memval(iaddr, a1, 2) sapath = simstate.get_string_from_memaddr(iaddr, a1.add_offset(2)) pargs = ( str(a0) + "," + str(a1) + ":{" + str(safamily) + "," + sapath + "}," + str(a2)) else: pargs = ','.join(str(a) for a in [a0, a1, a2]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_bsearch(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "bsearch") def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") a1 = self.get_arg_val(iaddr, simstate, "a1") a2 = self.get_arg_val(iaddr, simstate, "a2") a3 = self.get_arg_val(iaddr, simstate, "a3") a4 = self.get_stack_arg_val(iaddr, simstate, 4) pargs = ", ".join(str(a) for a in [a0, a1, a2, a3, a4]) simstate.set_register(iaddr, "v0", SV.simZero) return self.add_logmsg(iaddr, simstate, pargs, returnval="0") class MIPStub_calculate_checksum(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'calculate_checksum') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """No computation; returns -1 in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') simstate.set_register(iaddr, 'v0', SV.SimDoubleWordValue(-1)) pargs = ','.join(str(a) for a in [a0, a1, a2]) return self.add_logmsg(iaddr, simstate, pargs, returnval='-1') class MIPStub_calloc(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'calloc') def is_memalloc_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Initializes the memory to 0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') base = 'calloc_' + iaddr if a0.is_literal and a0.is_defined and a1.is_literal and a1.is_defined: a0 = cast(SV.SimLiteralValue, a0) a1 = cast(SV.SimLiteralValue, a1) buffersize = a0.value * a1.value address = SSV.mk_base_address(base, 0, buffersize=buffersize) for i in range(0, buffersize): tgtaddr = address.add_offset(i) simstate.set_memval(iaddr, tgtaddr, SV.SimByteValue(0)) simstate.set_register(iaddr, "v0", address) returnval: str = str(address) else: simstate.set_register(iaddr, 'v0', SV.simZero) returnval = "0" pargs = str(a0) + ',' + str(a1) return self.add_logmsg(iaddr, simstate, pargs, returnval=returnval) class MIPStub_chdir(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'chdir') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') pargs = str(a0) + ':' + str(a0str) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_clock_gettime(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'clock_gettime') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) if a1.is_address: a1 = cast(SSV.SimAddress, a1) simstate.set_memval(iaddr, a1, SV.mk_simvalue(int(time.time()))) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_close(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'close') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_closelog(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'closelog') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Logs i/o; no return value.""" return self.add_logmsg(iaddr, simstate, '') class MIPStub_connect(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'connect') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = ','.join(str(a) for a in [a0, a1, a2]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_daemon(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'daemon') def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = str(a0) + ',' + str(a1) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_dlopen(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'dlopen') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = str(a0) + ':' + a0str + ',' + str(a1) result = SSV.mk_symboltablehandle(a0str) simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_dlsym(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'dlsym') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # void *restrict handle a1 = self.get_arg_val(iaddr, simstate, "a1") # const char *restrict name a1str = self.get_arg_string(iaddr, simstate, "a1") pargs = str(a0) + ',' + str(a1) + ':' + a1str if a0.is_undefined or a1.is_undefined: raise SU.CHBSimError( simstate, iaddr, "dlsym: some argument is undefined: " + pargs) result: SV.SimValue if a0.is_symbol_table_handle: a0 = cast(SSV.SimSymbolTableHandle, a0) importsym = simstate.resolve_import_symbol(a1str) if importsym.is_defined: result = SSV.mk_dynamic_link_symbol(a0, a1str, importsym) a0.set_value(a1str, result) else: result = SV.simNegOne else: result = SV.simNegOne simstate.set_register(iaddr, "v0", result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_dprintf(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'dprintf') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') pargs = str(a0) + ',' + str(a1) + ':' + a1str return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_dup(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'dup') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.mk_simvalue(15)) return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(a0)) class MIPStub_dup2(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'dup2') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) simstate.set_register(iaddr, 'v0', a1) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(a1)) class MIPStub_epoll_create(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'epoll_create') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') result = SV.mk_simvalue(1) simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(result)) class MIPStub_epoll_ctl(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'epoll_ctl') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a3 = self.get_arg_val(iaddr, simstate, 'a3') pargs = ','.join(str(a) for a in [a0, a1, a2, a3]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_epoll_wait(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'epoll_wait') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a3 = self.get_arg_val(iaddr, simstate, 'a3') pargs = ','.join(str(a) for a in [a0, a1, a2, a3]) simstate.set_register(iaddr, 'v0', SV.simOne) return self.add_logmsg(iaddr, simstate, pargs, returnval='1') class MIPStub___errno_location(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, '__errno_location') def is_error_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: result = SSV.mk_string_address('error-string') simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, str(result)) class MIPStub_execve(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "execve") def is_process_operation(self) -> bool: return True def retrieve_strings( self, iaddr: str, simstate: "SimulationState", addr: SSV.SimAddress) -> List[str]: result: List[str] = [] saddr = simstate.memval(iaddr, addr, 4) if saddr.is_literal and saddr.is_defined: saddr = cast(SV.SimLiteralValue, saddr) while saddr.value > 0: s = self.get_string_at_address(iaddr, simstate, saddr) result.append(s) addr = addr.add_offset(4) saddrp = simstate.memval(iaddr, addr, 4) if saddrp.is_literal and saddrp.is_defined: saddr = cast(SV.SimLiteralValue, saddrp) else: break else: pass else: pass return result def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") a0str = self.get_arg_string(iaddr, simstate, "a0") a1 = self.get_arg_val(iaddr, simstate, "a1") a2 = self.get_arg_val(iaddr, simstate, "a2") if a1.is_address: a1 = cast(SSV.SimAddress, a1) a1strings = self.retrieve_strings(iaddr, simstate, a1) a1p = str(a1) + ":[" + ", ".join(str(s) for s in a1strings) + "]" else: a1p = str(a1) if a2.is_address: a2 = cast(SSV.SimAddress, a2) a2strings = self.retrieve_strings(iaddr, simstate, a2) a2p = str(a2) + ":[" + ", ".join(str(s) for s in a2strings) + "]" else: a2p = str(a2) pargs = str(a0) + ":" + a0str + ", " + str(a1p) + ", " + str(a2p) simstate.set_register(iaddr, "v0", SV.mk_simvalue(-1)) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_exit(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'exit') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') raise SU.CHBSimExitException(simstate, iaddr, str(a0)) class MIPStub_fclose(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fclose') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') if a0.is_symbol: a0 = cast(SSV.SimSymbol, a0) if a0.is_file_descriptor: try: a0 = cast(SSV.SimSymbolicFileDescriptor, a0) a0.filedescriptor.close() simstate.add_logmsg('i/o', 'Successfully closed ' + str(a0)) except Exception as e: simstate.add_logmsg( 'i/o', 'Error in closing ' + str(a0) + ': ' + str(e)) elif a0.is_file_pointer: try: a0 = cast(SSV.SimSymbolicFilePointer, a0) a0.fp.close() simstate.add_logmsg('i/o', 'Successfully closed ' + str(a0)) except Exception as e: simstate.add_logmsg( 'i/o', 'Error in closing ' + str(a0) + ': ' + str(e)) else: simstate.add_logmsg('i/o', self.name + '(' + str(a0) + ')') else: pass simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_fcntl(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fcntl') def is_io_operation(self) -> bool: return True def get_cmd_name(self, i: SV.SimLiteralValue) -> str: if str(i) in fcntl_cmds: return fcntl_cmds[str(i)] else: return str(i) def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') if a1.is_literal: a1 = cast(SV.SimLiteralValue, a1) a1cmd = self.get_cmd_name(a1) if a1cmd == "F_SETFL": a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = str(a0) + ',' + a1cmd + ',' + str(a2) else: pargs = str(a0) + ',' + a1cmd else: pargs = str(a0) + "," + str(a1) simstate.set_register(iaddr, 'v0', SV.SimDoubleWordValue(0)) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_fcntl64(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fcntl64') def is_io_operation(self) -> bool: return True def get_cmd_name(self, i: SV.SimLiteralValue) -> str: if str(i) in fcntl_cmds: return fcntl_cmds[str(i)] else: return str(i) def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') if a1.is_literal: a1 = cast(SV.SimLiteralValue, a1) a1cmd = self.get_cmd_name(a1) if a1cmd == "F_SETFL": a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = str(a0) + ',' + a1cmd + ',' + str(a2) else: pargs = str(a0) + ',' + a1cmd else: pargs = str(a0) + str(a1) simstate.set_register(iaddr, 'v0', SV.SimDoubleWordValue(0)) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_fdopen(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fdopen') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') pargs = str(a0) + ',' + str(a1) + ':' + a1str simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs, returnval='0') class MIPStub_feof(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'feof') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Returns false by default.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') if a0.is_symbol: a0 = cast(SSV.SimSymbol, a0) if a0.is_file_pointer: a0 = cast(SSV.SimSymbolicFilePointer, a0) try: fp = a0.fp s = fp.read() if s == '': result = 1 else: result = 0 except Exception: result = 0 else: result = 0 else: result = 0 simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result)) simstate.add_logmsg('i/o', self.name + '(' + str(a0) + ')') return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(result)) class MIPStub___fgetc_unlocked(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, '__fgetc_unlocked') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Return a tainted value in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SSV.SimTaintedValue('fgetc', -1, 255)) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_fflush(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fflush') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_fgets(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fgets') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Inputs tainted characters.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = str(a0) + ',' + str(a1) + ',' + str(a2) simstate.set_register(iaddr, 'v0', a0) if not a0.is_address: return self.add_logmsg(iaddr, simstate, pargs) a0 = cast(SSV.SimAddress, a0) if a2.is_symbolic: a2 = cast(SSV.SimSymbol, a2) if a2.is_file_pointer: a2 = cast(SSV.SimSymbolicFilePointer, a2) if a1.is_literal and a1.is_defined: a1 = cast(SV.SimLiteralValue, a1) for i in range(0, a1.value - 1): c = a2.fp.read(1) if c == '': if i == 0: simstate.set_register(iaddr, 'v0', SV.simZero) break srcval = SV.SimByteValue(255) tgtaddr = a0.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) break else: srcval = SV.SimByteValue(ord(c)) tgtaddr = a0.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_memval( iaddr, a0.add_offset(a1.value - 1), SV.SimByteValue(0)) elif a1.is_literal and a1.is_defined: a1 = cast(SV.SimLiteralValue, a1) for i in range(0, a1.value - 1): srcval = SV.SimByteValue(ord('t')) tgtaddr = a0.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_memval( iaddr, a0.add_offset(a1.value - 1), SV.SimByteValue(0)) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_fputs(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fputs') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # const char *restrict s a1 = self.get_arg_val(iaddr, simstate, "a1") # FILE *restrict stream a0str = self.get_arg_string(iaddr, simstate, "a0") pargs = str(a0) + ':' + a0str + ',' + str(a1) if simstate.simsupport.file_operations_enabled: if a1.is_file_pointer: a1 = cast(SSV.SimSymbolicFilePointer, a1) a1.fp.write(a0str) returnval = 1 else: returnval = -1 else: returnval = -1 simstate.set_register(iaddr, 'v0', SV.mk_simvalue(returnval)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval)) class MIPStub_fileno(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fileno') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Returns a symbolic value in v0""" a0 = self.get_arg_val(iaddr, simstate, 'a0') if a0.is_symbolic: a0 = cast(SSV.SimSymbol, a0) if a0.is_file_pointer: a0 = cast(SSV.SimSymbolicFilePointer, a0) fpresult = SSV.mk_filedescriptor(a0.filename, a0.fp) simstate.set_register(iaddr, "v0", fpresult) returnval = str(fpresult) elif a0.is_symbol: a0 = cast(SSV.SimSymbol, a0) symresult = SSV.SimSymbol(a0.name + '_fildes') simstate.set_register(iaddr, "v0", symresult) returnval = str(symresult) else: simstate.set_register(iaddr, "v0", SV.SimDoubleWordValue(-1)) returnval = "-1" else: simstate.set_register(iaddr, "v0", SV.SimDoubleWordValue(-1)) returnval = "-1" return self.add_logmsg(iaddr, simstate, str(a0), returnval=returnval) class MIPStub_fopen(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fopen') def is_io_operation(self) -> bool: return True def simulate_success( self, iaddr: str, simstate: "SimulationState", pargs: str, filename: str, filepointer: IO[Any], comment: str = "") -> str: returnval = SSV.mk_filepointer(filename, filepointer) simstate.set_register(iaddr, 'v0', returnval) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval)) def simulate_failure( self, iaddr: str, simstate: "SimulationState", pargs: str, comment: str = "") -> str: returnval = SV.simZero simstate.set_register(iaddr, 'v0', returnval) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval)) def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Logs i/o; returns 0 in v0.""" a0 = self.get_arg_val(iaddr, simstate, "a0") # const char *restrict pathname a1 = self.get_arg_val(iaddr, simstate, "a1") # const char *restrict mode a0str = self.get_arg_string(iaddr, simstate, "a0") a1str = self.get_arg_string(iaddr, simstate, "a1") pargs = ( ",".join(str(a) + ':' + str(s) for (a, s) in [(a0, a0str), (a1, a1str)])) if simstate.simsupport.file_operations_enabled: if SFU.sim_file_exists(a0str) or a1str.startswith("w"): fp = SFU.sim_openfile(a0str, a1str) simstate.set_register(iaddr, "v0", fp) return self.add_logmsg( iaddr, simstate, pargs, returnval=str(fp)) else: return self.simulate_failure(iaddr, simstate, pargs, "file not found") else: return self.simulate_failure(iaddr, simstate, pargs) class MIPStub_fopen64(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fopen64') def is_io_operation(self) -> bool: return True def simulate_success( self, iaddr: str, simstate: "SimulationState", pargs: str, filename: str, filepointer: IO[Any], comment: str = "") -> str: returnval = SSV.mk_filepointer(filename, filepointer) simstate.set_register(iaddr, 'v0', returnval) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval)) def simulate_failure( self, iaddr: str, simstate: "SimulationState", pargs: str, comment: str = "") -> str: returnval = SV.simZero simstate.set_register(iaddr, 'v0', returnval) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval)) def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Logs i/o; returns 0 in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a0str = self.get_arg_string(iaddr, simstate, 'a0') a1str = self.get_arg_string(iaddr, simstate, 'a1') pargs = ( ','.join(str(a) + ':' + str(s) for (a, s) in [(a0, a0str), (a1, a1str)])) if a0str == '/dev/console': fpconsole = open('devconsole', 'w') return self.simulate_success( iaddr, simstate, pargs, 'devconsole', fpconsole, comment='assume access to /dev/console is always enabled') else: return self.simulate_failure(iaddr, simstate, pargs) class MIPStub_freeaddrinfo(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'freeaddrinfo') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_fscanf(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fscanf') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') pargs = str(a0) + ',' + str(a1) + ':' + a1str result = -1 simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_fstat(MIPSimStub): """Partially fills in the file information in the provided buffer. Currently only the file size is set at offset 52. From MIPS ABI supplement: struct stat { dev_t st_dev; 0 long st_pad1[3]; 4 ino_t st_ino; 16 mode_t st_mode; nlink_t st_nlink; uid_t st_uid; 32 gid_t st_gid; 36 dev_t st_rdev; 40 long st_pad2[2]; 44 off_t st_size; 52 long st_pad3; 56 timestruc_t st_atim; timestruc_t st_mtim; timestruc_t st_ctim; long st_blksize; long st_blocks; char st_fstype[_ST_FSTYPSZ]; long st_pad4[8]; } """ def __init__(self) -> None: MIPSimStub.__init__(self, "fstat") def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # int fildes a1 = self.get_arg_val(iaddr, simstate, "a1") # struct stat *buf pargs = str(a0) + ", " + str(a1) if a0.is_undefined or a1.is_undefined: raise SU.CHBSimError( simstate, iaddr, "fstat: some arguments are undefined: " + pargs) if a1.is_address: buf = cast(SSV.SimAddress, a1) elif a1.is_literal: buf = simstate.resolve_literal_address(iaddr, a1.literal_value) if buf.is_undefined: raise SU.CHBSimError( simstate, iaddr, "fstat: address of buf cannot be resolved: " + str(a1)) pargs = str(a0) + ", " + str(buf) if a0.is_file_descriptor: a0 = cast(SSV.SimSymbolicFileDescriptor, a0) fd = a0.filedescriptor fdstat = os.stat(a0.filename) simstate.set_memval( iaddr, buf.add_offset(52), SV.mk_simvalue(fdstat.st_size)) result = 0 else: result = -1 simstate.set_register(iaddr, "v0", SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_fstat64(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fstat64') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = str(a0) + ',' + str(a1) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_fwrite(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fwrite') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Logs i/o, returns 1 in v0 for now.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a3 = self.get_arg_val(iaddr, simstate, 'a3') simstate.set_register(iaddr, 'v0', SV.simOne) pargs = ','.join(str(a) for a in [a0, a1, a2, a3]) return self.add_logmsg(iaddr, simstate, pargs, returnval='1') class MIPStub_fread(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fread') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # void *restrict ptr a1 = self.get_arg_val(iaddr, simstate, "a1") # size_t size a2 = self.get_arg_val(iaddr, simstate, "a2") # size_t nitems a3 = self.get_arg_val(iaddr, simstate, "a3") # FILE *restrict stream pargs = ','.join(str(a) for a in [a0, a1, a2, a3]) if ( a0.is_undefined or a1.is_undefined or a2.is_undefined or a3.is_undefined): raise SU.CHBSimError( simstate, iaddr, "some arguments to fread are undefined") if a0.is_address: ptr = cast(SSV.SimAddress, a0) elif a0.is_literal: ptr = simstate.resolve_literal_address(iaddr, a0.literal_value) if ptr.is_undefined: raise SU.CHBSimError( simstate, iaddr, "fread: dstaddr: " + str(a0) + " cannot be resolved") if a3.is_file_pointer: fp = cast(SSV.SimSymbolicFilePointer, a3).fp else: raise SU.CHBSimError( simstate, iaddr, "fread: stream: " + str(a3) + " is not a file pointer") if a1.is_literal: size = a1.literal_value else: raise SU.CHBSimError( simstate, iaddr, "fread: size: " + str(a1) + " is not a literal value") if a2.is_literal: nitems = a2.literal_value else: raise SU.CHBSimError( simstate, iaddr, "fread: nitems: " + str(a2) + " is not a literal value") for i in range(0, size * nitems): c = fp.read(1) simstate.set_memval(iaddr, ptr.add_offset(i), SV.mk_simcharvalue(c)) returnval = size * nitems simstate.set_register(iaddr, "v0", SV.mk_simvalue(returnval)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval)) class MIPStub_free(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'free') def is_memalloc_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_fork(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'fork') def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: if iaddr in simstate.simsupport.forkchoices: result = simstate.simsupport.forkchoices[iaddr] else: result = 0 simresult = SV.mk_simvalue(result) simstate.set_register(iaddr, 'v0', simresult) return self.add_logmsg(iaddr, simstate, '', returnval=str(result)) class MIPStub_fprintf(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "fprintf") def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # FILE *restrict stream a1 = self.get_arg_val(iaddr, simstate, "a1") # const char *restrict format a1str = self.get_arg_string(iaddr, simstate, "a1") if simstate.simsupport.file_operations_enabled: if a0.is_file_pointer: a0 = cast(SSV.SimSymbolicFilePointer, a0) a0.fp.write(a1str) returnval = len(a1str) else: returnval = -1 else: returnval = -1 simstate.set_register(iaddr, "v0", SV.mk_simvalue(returnval)) pargs = str(a0) + ',' + str(a1) + ':' + a1str return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval)) class MIPStub_getaddrinfo(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'getaddrinfo') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') # a0str = self.get_arg_string(iaddr, simstate,'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a3 = self.get_arg_val(iaddr, simstate, 'a3') simstate.set_register(iaddr, 'v0', SV.simZero) if a3.is_address: a3 = cast(SSV.SimAddress, a3) simstate.set_memval(iaddr, a3, a2) else: simstate.add_logmsg(iaddr, "Not able to set side effect of getaddrinfo") pargs = ( str(a0) + ',' + str(a1) + ':' + a1str + ',' + str(a2) + ',' + str(a3)) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_get_current_dir_name(MIPSimStub): """Allocates memory on the heap to hold the absolute path name. Doc: https://man7.org/linux/man-pages/man3/getcwd.3.html get_current_dir_name() will malloc(3) an array big enough to hold the absolute pathname of the current working directory. If the environment variable PWD is set, and its value is correct, then that value will be returned. The caller should free(3) the returned buffer. """ def __init__(self) -> None: MIPSimStub.__init__(self, "get_current_dir_name") def is_memalloc_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: cwd = simstate.simsupport.cwd() a0 = self.get_arg_val(iaddr, simstate, "a0") a1 = self.get_arg_val(iaddr, simstate, "a1") pargs = str(a0) + ", " + str(a1) if a0.is_literal and a0.is_defined and a1.is_literal and a1.is_defined: a0 = cast(SV.SimLiteralValue, a0) a1 = cast(SV.SimLiteralValue, a1) if a0.value == 0 and a1.value == 0: base = "get_current_dir_name_" + iaddr buffersize = len(cwd) + 1 address = SSV.mk_base_address(base, 0, buffersize=buffersize) for i in range(0, buffersize - 1): tgtaddr = address.add_offset(i) simstate.set_memval(iaddr, tgtaddr, SV.mk_simcharvalue(cwd[i])) simstate.set_memval(iaddr, address.add_offset(len(cwd)), SV.simZerobyte) simstate.set_register(iaddr, "v0", address) returnval: str = str(address) else: simstate.set_register(iaddr, "v0", SV.simZero) returnval = "0" else: simstate.set_register(iaddr, "v0", SV.simZero) returnval = "0" return self.add_logmsg(iaddr, simstate, pargs, returnval=returnval) class MIPStub_getcwd(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'getcwd') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: cwd = simstate.simsupport.cwd() a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') if a0.is_address: a0 = cast(SSV.SimAddress, a0) i = 0 for c in cwd: simstate.set_memval( iaddr, a0.add_offset(i), SV.mk_simbytevalue(ord(c))) i += 1 pargs = ','.join(str(a) for a in [a0, a1]) simstate.set_register(iaddr, 'v0', a0) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(a0)) class MIPStub_getenv(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'getenv') def is_environment_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Logs getenv request, returns environment variable from simstate.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') if simstate.simsupport.has_environment_variable(a0str): envvalue = simstate.simsupport.get_environment_variable(a0str) result: SV.SimValue = SSV.mk_string_address(envvalue) envmsg = 'retrieved: ' + str(result) + ' for ' + a0str else: result = SV.simZero envmsg = 'no environment value found for ' + a0str simstate.set_register(iaddr, 'v0', result) simstate.add_logmsg('getenv', envmsg) pargs = str(a0) + ':' + a0str return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_gethostname(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'gethostname') def is_network_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') simstate.set_register(iaddr, 'v0', SV.simZero) pargs = ','.join(str(a) for a in [a0, a1]) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_getline(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'getline') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1deref = self.get_arg_deref_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = str(a0) + ',' + str(a1) + ':' + str(a1deref) + ',' + str(a2) if a2.is_file_pointer and a0.is_address: a0 = cast(SSV.SimAddress, a0) a2 = cast(SSV.SimSymbolicFilePointer, a2) line = a2.fp.readline() result = len(line) if result > 0: sval = SSV.mk_string_address(line) simstate.set_memval(iaddr, a0, sval) simstate.add_logmsg('i/o', 'Read line: ' + line + ' from ' + str(a2)) else: simstate.add_logmsg('i/o', 'Reached eof of ' + str(a2)) result = -1 else: simstate.add_logmsg('i/o', 'No input read from ' + str(a2)) result = -1 simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_getopt(MIPSimStub): """int getopt(int argc, char * const argv[], const char *optstring); This stub depends on the address where optarg is stored. This address should be set in the simsupport module. """ def __init__(self) -> None: MIPSimStub.__init__(self, 'getopt') self.optarg = SV.simZero self.optind = 1 # keeps track of the current option self.optopt: SV.SimValue = SV.simZero # points to current cmdline argument def is_io_operation(self) -> bool: return True def has_argument(self, cmdstr: str, c: str) -> bool: cindex = cmdstr.find(c) if cindex < 0: return False else: return cmdstr[cindex+1] == ':' def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # int argc a1 = self.get_arg_val(iaddr, simstate, "a1") # char *const argv[] a2 = self.get_arg_val(iaddr, simstate, "a2") # const char *optstring a2str = self.get_arg_string(iaddr, simstate, "a2") pargs = ','.join(str(a) for a in [a0, a1]) + ',' + str(a2) + ':' + a2str result: int = -1 optargaddr = simstate.simsupport.optargaddr if not optargaddr.is_address: simstate.add_logmsg("warning", "getopt: optargaddress has not been set") simstate.set_register(iaddr, "v0", SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) else: optargaddr = cast(SSV.SimAddress, optargaddr) if a0.is_undefined or a1.is_undefined or a2.is_undefined: raise SU.CHBSimError( simstate, iaddr, "some arguments to getopt are undefined: " + pargs) if not a0.is_literal: raise SU.CHBSimError( simstate, iaddr, "getopt: expected a0 to be a literal: " + str(a0)) else: argc = a0.literal_value if not a1.is_address: raise SU.CHBSimError( simstate, iaddr, "getopt: expected a1 to be an address: " + str(a1)) else: argv = cast(SSV.SimAddress, a1) if not a2.is_address: raise SU.CHBSimError( simstate, iaddr, "getopt: expected a2 to be an address: " + str(a2)) else: optstring = a2str if self.optind < argc: argaddr = argv.add_offset(self.optind * 4) self.optopt = simstate.memval(iaddr, argaddr, 4) if self.optopt.is_address: option = self.get_string_at_address(iaddr, simstate, self.optopt) if option.startswith("-") and len(option) == 2: option = option[1] if self.has_argument(a2str, option): self.optind += 1 argvaladdr = argv.add_offset(self.optind * 4) nextargaddr = simstate.memval(iaddr, argvaladdr, 4) if nextargaddr.is_address: nextarg = self.get_string_at_address(iaddr, simstate, nextargaddr) if nextarg.startswith("-"): emptyarg = SSV.mk_string_address(":") simstate.set_memval(iaddr, optargaddr, emptyarg) else: simstate.set_memval(iaddr, optargaddr, argvaladdr) self.optind += 1 else: simstate.add_logmsg( "warning", "getopt: nextarg is not an address") else: # there is no argument self.optind += 1 result = ord(option) else: # option does not start with "-" pass else: raise SU.CHBSimError( simstate, iaddr, "getopt: optopt is not an address: " + str(self.optopt)) else: # no more arguments to process pass simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_getopt_long(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'getopt_long') self.optarg: SV.SimValue = SV.simZero self.optind = 1 self.optopt: SV.SimValue = SV.simZero def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Logs i/o, returns -1 in v0.""" print("Simulate getopt_long") a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a2str = self.get_arg_string(iaddr, simstate, 'a2') if a0.is_literal and a0.is_defined and a1.is_address: a0 = cast(SV.SimLiteralValue, a0) a1 = cast(SSV.SimAddress, a1) if self.optind < a0.value: argaddr = a1.add_offset(self.optind * 4) self.optopt = simstate.memval(iaddr, argaddr, 4) if self.optopt.is_string_address: self.optopt = cast(SSV.SimStringAddress, self.optopt) if self.optopt.stringval.startswith('-'): result = ord(self.optopt.stringval[1]) self.optind += 1 else: result = -1 else: result = -1 else: result = -1 else: result = -1 simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result)) pargs = ','.join(str(a) for a in [a0, a1]) + ',' + str(a0) + ':' + a2str return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_getpeername(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'getpeername') def is_network_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = ','.join(str(a) for a in [a0, a1, a2]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs, returnval='0') class MIPStub_getpid(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "getpid") def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: simstate.set_register(iaddr, 'v0', SV.simOne) return self.add_logmsg(iaddr, simstate, "") class MIPStub_getpwnam(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "getpwnam") def simulate(self, iaddr: str, simstate: "SimulationState") -> str: simstate.set_register(iaddr, "v0", SV.simZero) a0str = self.get_arg_string(iaddr, simstate, "a0") return self.add_logmsg(iaddr, simstate, a0str, returnval="0") class MIPStub_getpwuid(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "getpwuid") def simulate(self, iaddr: str, simstate: "SimulationState") -> str: simstate.set_register(iaddr, "v0", SV.simZero) a0 = self.get_arg_val(iaddr, simstate, "a0") return self.add_logmsg(iaddr, simstate, str(a0), returnval="0") class MIPStub_getrlimit64(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'getrlimit64') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') if a1.is_address: a1 = cast(SSV.SimAddress, a1) simstate.set_memval(iaddr, a1, SV.simZero) simstate.set_memval(iaddr, a1.add_offset(4), SV.simZero) simstate.set_memval(iaddr, a1.add_offset(8), SV.simZero) simstate.set_memval(iaddr, a1.add_offset(12), SV.simZero) pargs = str(a0) + ',' + str(a1) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_getsockname(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'getsockname') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = ','.join(str(a) for a in [a0, a1, a2]) simstate.set_register(iaddr, 'v0', SV.simNegOne) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_gettimeofday(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'gettimeofday') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: t = int(time.time()) a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) if a0.is_address: a0 = cast(SSV.SimAddress, a0) simstate.set_memval(iaddr, a0, SV.mk_simvalue(t)) simstate.set_memval(iaddr, a0.add_offset(4), SV.simZero) # simstate.set_memval(iaddr, a0.add_offset(8), SV.simZero) # simstate.set_memval(iaddr, a0.add_offset(12), SV.simZero) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_getuid(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'getuid') def get_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: simstate.set_register(iaddr, 'v0', SV.simOne) return self.add_logmsg(iaddr, simstate, '') class MIPStub_index(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'index') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') if a1.is_literal and a1.is_defined: a1 = cast(SV.SimLiteralValue, a1) a1value = str(chr(a1.value)) else: a1value = "?" pargs = str(a0) + ':' + a0str + ',' + str(a1) + ' {' + a1value + '}' index = a0str.find(a1value) if index >= 0 and a0.is_address: a0 = cast(SSV.SimAddress, a0) result: SV.SimValue = a0.add_offset(index) else: result = SV.simZero simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_inet_addr(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'inet_addr') def is_network_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') result = int(ipaddress.IPv4Address(a0str)) xresult = SV.mk_simvalue(result) pargs = str(a0) + ':' + a0str simstate.set_register(iaddr, 'v0', xresult) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(xresult)) class MIPStub_inet_aton(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'inet_aton') def is_network_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Returns 0 by default.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a0str = self.get_arg_string(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) pargs = str(a0) + ':' + a0str + ',' + str(a1) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_inet_ntoa(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'inet_ntoa') def is_network_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SSV.mk_string_address('0.0.0')) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_inet_pton(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'inet_pton') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Fails by default.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a1str = self.get_arg_string(iaddr, simstate, 'a1') simstate.set_register(iaddr, 'v0', SV.simZero) pargs = str(a0) + ',' + str(a1) + ':' + a1str + ',' + str(a2) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_ioctl(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'ioctl') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Returns 0 in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') simstate.set_register(iaddr, 'v0', SV.simZero) pargs = ','.join(str(a) for a in [a0, a1, a2]) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_isatty(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "isatty") def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") simstate.set_register(iaddr, "v0", SV.simOne) return self.add_logmsg(iaddr, simstate, str(a0), returnval="1") class MIPStub___libc_current_sigrtmax(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, '__libc_current_sigrtmax') def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: simstate.set_register(iaddr, 'v0', SV.simOne) return self.add_logmsg(iaddr, simstate, '') class MIPStub___libc_current_sigrtmin(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, '__libc_current_sigrtmin') def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: simstate.set_register(iaddr, 'v0', SV.simOne) return self.add_logmsg(iaddr, simstate, '') class MIPStub_listen(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'listen') def is_network_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_localtime(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'localtime') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') base = 'localtime_' address = SSV.mk_base_address(base, 0, buffersize=36) t = time.localtime() print('time: ' + str(t)) def set_tm(off, tmval): simstate.set_memval( iaddr, address.add_offset(off), SV.mk_simvalue(tmval)) set_tm(0, t.tm_sec) set_tm(4, t.tm_min) set_tm(8, t.tm_hour) set_tm(12, t.tm_mday) set_tm(16, t.tm_mon) set_tm(20, t.tm_year) set_tm(24, t.tm_wday) set_tm(28, t.tm_yday) set_tm(32, t.tm_isdst) simstate.set_register(iaddr, 'v0', address) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_lockf(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'lockf') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = ','.join(str(a) for a in [a0, a1, a2]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_longjmp(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'longjmp') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) simstate.set_register(iaddr, 'v0', a1) if a0.is_address: a0 = cast(SSV.SimAddress, a0) newpc = simstate.memval(iaddr, a0, 4) newsp = simstate.memval(iaddr, a0.add_offset(4), 4) newra = simstate.memval(iaddr, a0.add_offset(8), 4) context = simstate.memval(iaddr, a0.add_offset(12), 4) if context.is_string_address: context = cast(SSV.SimStringAddress, context) contextstr = context.stringval else: contextstr = "?" simstate.set_register(iaddr, 'sp', newsp) simstate.set_register(iaddr, 'ra', newra) # simstate.restore_context(contextstr) if newpc.is_address: newpc = cast(SSV.SimAddress, newpc) if newpc.is_global_address: newpc = cast(SSV.SimGlobalAddress, newpc) simstate.set_programcounter(newpc) return self.add_logmsg( iaddr, simstate, pargs, returnval=( str(a1) + ' (jmpaddr:' + str(newpc) + '; sp:' + str(newsp) + '; ra:' + str(newra) + ')')) else: return "newpc is not a global address: " + str(newpc) else: return "newpc is not an address: " + str(newpc) else: return "longjmp: argument is not an address: " + str(a0) class MIPStub_malloc(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'malloc') self._sitecounters: Dict[str, int] = {} @property def sitecounters(self) -> Dict[str, int]: return self._sitecounters def sitecounter(self, site: str) -> int: self.sitecounters.setdefault(site, 0) self.sitecounters[site] += 1 return self.sitecounters[site] def is_memalloc_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Returns a symbolic address to a heap buffer in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') site = "malloc_" + iaddr base = site + ":" + str(self.sitecounter(site)) if a0.is_defined and a0.is_literal: buffersize: Optional[int] = a0.literal_value else: buffersize = None address = SSV.mk_base_address(base, 0, buffersize=buffersize) simstate.basemem[base] = SimBaseMemory( simstate, base, buffersize=buffersize) simstate.set_register(iaddr, 'v0', address) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_mallopt(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "mallopt") def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") a1 = self.get_arg_val(iaddr, simstate, "a1") pargs = str(a0) + ", " + str(a1) simstate.set_register(iaddr, "v0", SV.simOne) return self.add_logmsg(iaddr, simstate, pargs, returnval="1") class MIPStub_memcmp(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'memcmp') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # const void *s1 a1 = self.get_arg_val(iaddr, simstate, "a1") # const void *s2 a2 = self.get_arg_val(iaddr, simstate, "a2") # size_t n pargs = ", ".join(str(a) for a in [a0, a1, a2]) if a0.is_undefined or a1.is_undefined or a2.is_undefined: raise SU.CHBSimError( simstate, iaddr, "memcmp: some arguments are undefined: " + pargs) if a2.is_literal: n = a2.literal_value else: raise SU.CHBSimError( simstate, iaddr, "memcmp: size argument is not a literal value: " + str(a2)) if a0.is_string_address: str1 = cast(SSV.SimStringAddress, a0).stringval parg0 = str1 if len(str1) + 1 < n: raise SU.CHBSimError( simstate, iaddr, "memcmp: s1 string is too short: " + str1) s1 = [ord(c) for c in str1] if len(s1) < n: s1 = s1 + [0] else: if a0.is_address: s1addr = cast(SSV.SimAddress, a0) elif a0.is_literal: s1addr = simstate.resolve_literal_address(iaddr, a0.literal_value) if s1addr.is_undefined: raise SU.CHBSimError( simstate, iaddr, "memcmp: address of s1 cannot be resolved: " + str(a0)) else: raise SU.CHBSimError( simstate, iaddr, "memcmp: invalid address for s1: " + str(a0)) parg0 = str(s1addr) s1 = [] for i in range(0, n): addr = s1addr.add_offset(i) s1val = simstate.memval(iaddr, addr, 1) if s1val.is_defined and s1val.is_literal: s1.append(s1val.literal_value) else: raise SU.CHBSimError( simstate, iaddr, "memcmp: value for comparison in s1 at i=" + str(i) + " is undefined") if a1.is_string_address: str2 = cast(SSV.SimStringAddress, a1).stringval parg1 = str2 if len(str2) + 1 < n: raise SU.CHBSimError( simstate, iaddr, "memcmp: s2 string is too short: " + str2) s2 = [ord(c) for c in str2] if len(s2) < n: s2 = s2 + [0] else: if a1.is_address: s2addr = cast(SSV.SimAddress, a1) elif a1.is_literal: s2addr = simstate.resolve_literal_address(iaddr, a1.literal_value) if s2addr.is_undefined: raise SU.CHBSimError( simstate, iaddr, "memcmp: address of s2 cannot be resolved: " + str(a1)) else: raise SU.CHBSimError( simstate, iaddr, "memcmp: invalid address for s2: " + str(a1)) parg1 = str(s2addr) s2 = [] for i in range(0, n): addr = s2addr.add_offset(i) s2val = simstate.memval(iaddr, addr, 1) if s2val.is_defined and s2val.is_literal: s2.append(s2val.literal_value) else: raise SU.CHBSimError( simstate, iaddr, "memcmp: value for comparison in s2 at i=" + str(i) + " is undefined") for i in range(0, n): if s1[i] < s2[i]: result = -1 break elif s1[i] > s2[i]: result = 1 break else: result = 0 simstate.set_register(iaddr, "v0", SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_memcpy(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'memcpy') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Copies count bytes from src to dst; returns a0 in v0.""" a0 = self.get_arg_val(iaddr, simstate, "a0") # dst a1 = self.get_arg_val(iaddr, simstate, "a1") # src a2 = self.get_arg_val(iaddr, simstate, "a2") # count pargs = ", ".join(str(a) for a in [a0, a1, a2]) simstate.set_register(iaddr, "v0", a0) if (a0.is_undefined or a1.is_undefined or a2.is_undefined): simstate.add_logmsg( "warning", iaddr + ": memcpy: some arguments are undefined; nothing copied") simstate.set_register return self.add_logmsg(iaddr, simstate, pargs, returnval="nothing copied") if a0.is_address: dstaddr = cast(SSV.SimAddress, a0) elif a0.is_literal: dstaddr = cast( SSV.SimAddress, simstate.resolve_literal_address(iaddr, a0.literal_value)) else: raise SU.CHBSimError( simstate, iaddr, "memcpy: destination is not a valid address: " + str(a0)) if a1.is_address: srcaddr = a1 elif a1.is_literal: srcaddr = cast( SV.SimValue, simstate.resolve_literal_address(iaddr, a1.literal_value)) else: srcaddr = a1 if not (srcaddr.is_address or srcaddr.is_string_address): raise SU.CHBSimError( simstate, iaddr, "memcpy: source is not a valid address: " + str(a1)) if a2.is_literal: count = a2.literal_value else: raise SU.CHBSimError( simstate, iaddr, "memcpy: count is not a literal: " + str(a2)) if srcaddr.is_string_address: srcaddr = cast(SSV.SimStringAddress, srcaddr) srcstr = srcaddr.stringval if len(srcstr) >= count: for i in range(0, count): srcval = SV.mk_simcharvalue(srcstr[i]) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) elif len(srcstr) + 1 == count: # include null terminator for i in range(0, count-1): srcval = SV.mk_simcharvalue(srcstr[i]) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_memval( iaddr, dstaddr.add_offset(count-1), SV.simZerobyte) else: raise SU.CHBSimError( simstate, iaddr, "memcpy with source string of length: " + str(len(srcstr)) + " and length argument " + str(count)) else: srcaddr = cast(SSV.SimAddress, srcaddr) for i in range(0, count): srcval = cast( SV.SimByteValue, simstate.memval( iaddr, srcaddr.add_offset(i), 1)) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_memmove(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'memmove') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Copies count bytes from src to dst; returns a0 in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') # dst a1 = self.get_arg_val(iaddr, simstate, 'a1') # src a2 = self.get_arg_val(iaddr, simstate, 'a2') # count if a0.is_address: dstaddr = cast(SSV.SimAddress, a0) elif a0.is_literal and a0.is_defined: a0 = cast(SV.SimLiteralValue, a0) raise SU.CHBSimError( simstate, iaddr, 'memmove: illegal destination address: ' + str(a0)) if a2.is_defined and a2.is_literal: a2 = cast(SV.SimLiteralValue, a2) if a1.is_string_address: a1 = cast(SSV.SimStringAddress, a1) srcstr = a1.stringval for i in range(0, a2.value): srcval: SV.SimValue = SV.mk_simvalue(ord(srcstr[i]), 1) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) else: pass elif a1.is_literal and a1.is_defined: a1 = cast(SV.SimLiteralValue, a1) raise UF.CHBError("Illegal address in memmove: " + str(a1)) elif a1.is_address: a1 = cast(SSV.SimAddress, a1) for i in range(0, a2.value): srcaddr = a1.add_offset(i) srcval = simstate.memval(iaddr, srcaddr, 1) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) else: raise UF.CHBError("Illegal address in memmove: " + str(a1)) else: raise UF.CHBError("Length not known in memmove: " + str(a2)) simstate.set_register(iaddr, 'v0', dstaddr) pargs = ','.join(str(a) for a in [dstaddr, a1, a2]) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_memset(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'memset') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Sets count bytes in dst to char. returns a0 in v0""" a0 = self.get_arg_val(iaddr, simstate, 'a0') # dst a1 = self.get_arg_val(iaddr, simstate, 'a1') # char a2 = self.get_arg_val(iaddr, simstate, 'a2') # count pargs = ','.join(str(a) for a in [a0, a1, a2]) def result(returnval: SV.SimValue) -> str: simstate.set_register(iaddr, "v0", returnval) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval)) if a0.is_undefined or a1.is_undefined or a2.is_undefined: simstate.add_logmsg( "warning", iaddr + ": Unable to perform memset; some value is undefined") return result(SV.simUndefinedDW) if a0.is_address and a1.is_literal and a2.is_literal: a0 = cast(SSV.SimAddress, a0) a1byte = SV.mk_simvalue(a1.literal_value, size=1) for i in range(0, a2.literal_value): address = a0.add_offset(i) simstate.set_memval(iaddr, address, a1byte) return result(a0) simstate.add_logmsg("warning", iaddr + ": Unable to perform memset") return result(SV.simUndefinedDW) class MIPStub_mkdir(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'mkdir') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # const char *path a1 = self.get_arg_val(iaddr, simstate, "a1") # mode_t mode a0str = self.get_arg_string(iaddr, simstate, "a0") pargs = str(a0) + ':' + a0str + ',' + str(a1) if simstate.simsupport.file_operations_enabled: result = SFU.sim_mkdir(a0str) if result == 0: simstate.trace.add("mkdir: " + a0str + " successfully created") else: simstate.trace.add("mkdir: " + a0str + " failed") else: result = -1 simstate.trace.add("mkdir: " + a0str + " not attempted") simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_mktemp(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'mktemp') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') pargs = str(a0) + ':' + a0str simstate.set_register(iaddr, 'v0', a0) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_msgget(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'msgget') def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) simstate.set_register(iaddr, 'v0', SV.simOne) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_mmap(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'mmap') def is_process_operation(self) -> bool: return True def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # void *addr a1 = self.get_arg_val(iaddr, simstate, "a1") # size_t len a2 = self.get_arg_val(iaddr, simstate, "a2") # int prot a3 = self.get_arg_val(iaddr, simstate, "a3") # int flags a4 = self.get_stack_arg_val(iaddr, simstate, 4) # int fildes a5 = self.get_stack_arg_val(iaddr, simstate, 5) # off_t off base = "mmap_" + iaddr if a1.is_literal and a1.is_defined and a5.is_literal and a5.is_defined: a1 = cast(SV.SimLiteralValue, a1) a5 = cast(SV.SimLiteralValue, a5) address = SSV.mk_mapped_address(base, a5.value, a1.value) simstate.mappedmem[base] = SimMappedMemory( simstate, base, buffersize=a1.value, offset=a5.value) simstate.set_register(iaddr, "v0", address) returnval = str(address) else: simstate.set_register(iaddr, "v0", SV.mk_simvalue(-1)) returnval = "-1" pargs = ','.join(str(a) for a in [a0, a1, a2, a3, a4, a5]) return self.add_logmsg(iaddr, simstate, pargs, returnval=returnval) class MIPStub_open(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'open') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a0str = self.get_arg_string(iaddr, simstate, 'a0') pargs = str(a0) + ':' + a0str + ',' + str(a1) simstate.set_register(iaddr, 'v0', SV.mk_simvalue(-1)) simstate.add_logmsg('warning', 'File ' + a0str + ' was not opened') return self.add_logmsg(iaddr, simstate, pargs, returnval='-1') class MIPStub_open64(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'open64') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a0str = self.get_arg_string(iaddr, simstate, 'a0') pargs = str(a0) + ':' + a0str + ',' + str(a1) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_openlog(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'openlog') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Logs i/o.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = ','.join(str(a) for a in [a0, a1, a2]) simstate.add_logmsg('i/o', self.name + '(' + pargs + ')') return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_pclose(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'pclose') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simNegOne) simstate.add_logmsg('i/o', self.name + '(' + str(a0) + ')') return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_perror(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'perror') def is_error_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') pargs = str(a0) + ':' + a0str simstate.add_logmsg('error', self.name + '(' + pargs + ')') return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_popen(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'popen') def is_io_operation(self) -> bool: return True def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a0str = self.get_arg_string(iaddr, simstate, 'a0') a1str = self.get_arg_string(iaddr, simstate, 'a1') pargs = str(a0) + ':' + a0str + ',' + str(a1) + ':' + a1str simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_printf(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'printf') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Logs i/o; returns 1 in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simOne) pargs = str(a0) + ':' + a0str if '%s' in a0str: a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') pargs += ',' + str(a1) + ':' + a1str return self.add_logmsg(iaddr, simstate, pargs) class MIPStub__setjmp(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, '_setjmp') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) setval = SSV.mk_global_address(int(iaddr, 16) + 4, simstate.modulename) if a0.is_address: a0 = cast(SSV.SimAddress, a0) simstate.set_memval(iaddr, a0, setval) simstate.set_memval(iaddr, a0.add_offset(4), simstate.registers['sp']) simstate.set_memval(iaddr, a0.add_offset(8), simstate.registers['ra']) # simstate.set_memval( # iaddr, # a0.add_offset(12), # SSV.SimStringAddress(simstate.context.peek())) else: raise SU.CHBSimError( simstate, iaddr, "Illegal address in setjmp: " + str(a0)) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_setlogmask(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'setlogmask') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_setrlimit(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'setrlimit') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_setrlimit64(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'setrlimit64') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_setsid(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "setsid") def simulate(self, iaddr: str, simstate: "SimulationState") -> str: simstate.set_register(iaddr, "v0", SV.simOne) return self.add_logmsg(iaddr, simstate, "", returnval="1") class MIPStub_setsockopt(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'setsockopt') def is_network_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a3 = self.get_arg_val(iaddr, simstate, 'a3') a4 = self.get_stack_arg_val(iaddr, simstate, 4) pargs = ','.join(str(a) for a in [a0, a1, a2, a3, a4]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_shmat(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "shmat") def is_sharedmem_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # int shmid a1 = self.get_arg_val(iaddr, simstate, "a1") # const void *shmaddr a2 = self.get_arg_val(iaddr, simstate, "a2") # int shmflg pargs = ','.join(str(a) for a in [a0, a1, a2]) if ( a0.is_defined and a1.is_defined and a2.is_defined and a0.is_literal and a1.is_literal and a2.is_literal): addrval = a1.literal_value shmid = a0.literal_value memname = "shared:" + str(shmid) if addrval == 0: addr = cast(SSV.SimGlobalAddress, SSV.nullpointer) else: addr = SSV.mk_global_address(addrval, memname) result = simstate.simsupport.sharedmem_shmat( iaddr, simstate, a0.literal_value, addr, a2.literal_value) else: result = SSV.mk_undefined_global_address(memname) if result.is_defined and shmid in simstate.sharedmem: simstate.sharedmem[shmid].set_baseoffset(result.literal_value) else: simstate.add_logmsg( "warning", iaddr + ": attaching shared memory for shmid=" + str(a0.literal_value) + " failure") simstate.set_register(iaddr, "v0", result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_shmctl(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "shmctl") def is_sharedmem_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # int shmid a1 = self.get_arg_val(iaddr, simstate, "a1") # int cmd a2 = self.get_arg_val(iaddr, simstate, "a2") # struct shmid_ds *buf pargs = ",".join(str(a) for a in [a0, a1, a2]) if ( a0.is_defined and a1.is_defined and a2.is_defined and a0.is_literal and a1.is_literal and a2.is_address): a2 = cast(SSV.SimAddress, a2) returnval = simstate.simsupport.sharedmem_shmctl( iaddr, simstate, a0.literal_value, a1.literal_value, a2) else: returnval = -1 simstate.set_register(iaddr, "v0", SV.mk_simvalue(returnval)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval)) class MIPStub_shmdt(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "shmdt") def is_sharedmem_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # const void *shmaddr if a0.is_defined and a0.is_global_address: a0 = cast(SSV.SimGlobalAddress, a0) returnval = simstate.simsupport.sharedmem_shmdt( iaddr, simstate, a0) else: returnval = -1 simstate.set_register(iaddr, "v0", SV.mk_simvalue(returnval)) return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(returnval)) class MIPStub_shmget(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'shmget') self.counter = 0 def is_sharedmem_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # key_t key a1 = self.get_arg_val(iaddr, simstate, "a1") # size_t size a2 = self.get_arg_val(iaddr, simstate, "a2") # int shmflg pargs = ",".join(str(a) for a in [a0, a1, a2]) if ( a0.is_defined and a1.is_defined and a2.is_defined and a0.is_literal and a1.is_literal and a2.is_literal): shmid = simstate.simsupport.sharedmem_shmget( iaddr, simstate, a0.literal_value, a1.literal_value, a2.literal_value) if shmid in simstate.sharedmem: simstate.add_logmsg( "warning", iaddr + ": Shared memory already exists for shmid=" + str(shmid)) else: simstate.sharedmem[shmid] = SimSharedMemory( simstate, shmid, hex(a0.literal_value), a1.literal_value) else: shmid = -1 simstate.add_logmsg( "warning", iaddr + ": Attempt to gain access to shared memory failed") simstate.set_register(iaddr, "v0", SV.mk_simvalue(shmid)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(shmid)) class MIPStub_sigaction(MIPSimStub): def __init__(self, name: str = 'sigaction') -> None: MIPSimStub.__init__(self, name) def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = ','.join(str(a) for a in [a0, a1, a2]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_sigaddset(MIPSimStub): def __init__(self, name: str = 'sigaddset'): MIPSimStub.__init__(self, name) def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = '.'.join(str(a) for a in [a0, a1]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_sigemptyset(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'sigemptyset') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_signal(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'signal') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = str(a0) + ',' + str(a1) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_sigprocmask(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'sigprocmask') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = ','.join(str(a) for a in [a0, a1, a2]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_sleep(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'sleep') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_socket(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'socket') def is_network_operation(self) -> bool: return True def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Returns a symbolic value in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') # returnval = SSV.mk_symbol('socket-fd',minval=0) returnval = SV.mk_simvalue(113) # notable, recognizable value simstate.set_register(iaddr, 'v0', returnval) pargs = ','.join(str(a) for a in [a0, a1, a2]) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_pthread_cond_init(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'pthread_cond_init') def is_thread_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_pthread_cond_signal(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'pthread_cond_signal') def is_thread_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_pthread_create(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'pthread_create') def is_thread_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a3 = self.get_arg_val(iaddr, simstate, 'a3') pargs = ','.join(str(a) for a in [a0, a1, a2, a3]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_pthread_attr_init(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'pthread_attr_init') def is_thread_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_pthread_attr_setschedparam(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'pthread_attr_setschedparam') def is_thread_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_pthread_attr_setschedpolicy(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'pthread_attr_setschedpolicy') def is_thread_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_pthread_mutex_init(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'pthread_mutex_init') def is_thread_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_pthread_mutex_lock(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'pthread_mutex_lock') def is_thread_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_pthread_mutex_unlock(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'pthread_mutex_unlock') def is_thread_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_pthread_self(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'pthread_self') def is_thread_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: simstate.set_register(iaddr, 'v0', SV.simOne) return self.add_logmsg(iaddr, simstate, '') class MIPStub_putenv(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "putenv") def is_environment_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") a0str = self.get_arg_string(iaddr, simstate, "a0") pargs = str(a0) + ":" + a0str simstate.set_register(iaddr, "v0", SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_puts(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'puts') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') pargs = str(a0) + ':' + a0str simstate.set_register(iaddr, 'v0', SV.simOne) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_rand(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'rand') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: simstate.set_register(iaddr, 'v0', SV.mk_simvalue(0x4321)) return self.add_logmsg(iaddr, simstate, '') class MIPStub_random(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'random') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: simstate.set_register(iaddr, 'v0', SV.mk_simvalue(0x87654321)) return self.add_logmsg(iaddr, simstate, '') class MIPStub_read(MIPSimStub): """ssize_t read(int fildes, void *buf, size_t nbyte)""" def __init__(self) -> None: MIPSimStub.__init__(self, 'read') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1v = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') if a1v.is_literal and a1v.is_defined: a1v = cast(SV.SimLiteralValue, a1v) a1 = SSV.mk_global_address(a1v.value, simstate.modulename) if ( a0.is_literal and a0.is_defined and a1.is_address and a2.is_literal and a2.is_defined): a2 = cast(SV.SimLiteralValue, a2) a0 = cast(SV.SimLiteralValue, a0) inputbytes = simstate.simsupport.read_input( iaddr, a0.value, a1, a2.value) pargs = ','.join(str(a) for a in [a0, a1, a2]) if len(inputbytes) > 0: for i in range(0, len(inputbytes)): tgtaddr = a1.add_offset(i) simstate.set_memval( iaddr, tgtaddr, SV.mk_simbytevalue(inputbytes[i])) result = SV.mk_simvalue(len(inputbytes)) simstate.set_register(iaddr, 'v0', result) return self.add_logmsg( iaddr, simstate, pargs, returnval=str(result)) else: raise SU.CHBSimError( simstate, iaddr, "Illegal address in read: " + str(a1v)) class MIPStub_realloc(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'realloc') def is_memalloc_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') base = 'realloc_' + iaddr if a1.is_literal and a1.is_defined: a1 = cast(SV.SimLiteralValue, a1) buffersize: Optional[int] = a1.value else: buffersize = None address = SSV.mk_base_address(base, 0, buffersize=buffersize) if a0.is_address: a0 = cast(SSV.SimAddress, a0) if a0.is_base_address: a0 = cast(SSV.SimBaseAddress, a0) if a0.has_buffer_size(): a0buffersize = cast(int, a0.buffersize) a0 = cast(SSV.SimBaseAddress, a0) for i in range(0, a0buffersize): srcaddr = a0.add_offset(i) tgtaddr = address.add_offset(i) srcval = simstate.memval(iaddr, srcaddr, size=1) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_register(iaddr, 'v0', address) pargs = str(a0) + ',' + str(a1) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(address)) class MIPStub_realpath(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'realpath') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = str(a0) + ':' + a0str + ',' + str(a1) simstate.set_register(iaddr, 'v0', a0) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_reboot(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "reboot") def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") simstate.set_register(iaddr, "v0", SV.mk_simvalue(-1)) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_recv(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'recv') self.buffer: Optional[str] = None def is_io_operation(self) -> bool: return True def is_network_operation(self) -> bool: return True def get_network_input( self, iaddr: str, simstate: "SimulationState", size: int) -> str: if self.buffer is None: if simstate.simsupport.has_network_input(iaddr): self.buffer = simstate.simsupport.network_input( iaddr, simstate, size) if self.buffer and len(self.buffer) > 0 and len(self.buffer) <= size: recv = self.buffer[:] self.buffer = '' return recv elif self.buffer and len(self.buffer) > 0: recv = self.buffer[:size] self.buffer = self.buffer[size:] return recv else: return '' def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a3 = self.get_arg_val(iaddr, simstate, 'a3') pargs = ','.join(str(a) for a in [a0, a1, a2, a3]) if self.buffer and len(self.buffer) == 0: simstate.set_register(iaddr, 'v0', SV.simOne) simstate.add_logmsg('i/o', self.name + '(' + pargs + '):1') return self.add_logmsg(iaddr, simstate, pargs, returnval='1') elif simstate.simsupport.has_network_input(iaddr): if a1.is_literal and a1.is_defined: a1 = cast(SV.SimLiteralValue, a1) a1 = SSV.mk_global_address(a1.value, simstate.modulename) elif a1.is_address: a1 = cast(SSV.SimAddress, a1) else: raise SU.CHBSimError( simstate, iaddr, "Argument a1 is not an address: " + str(a1)) if a2.is_literal and a2.is_defined: a2 = cast(SV.SimLiteralValue, a2) else: raise SU.CHBSimError( simstate, iaddr, "Lenght argument is not a literal: " + str(a0)) networkinput = self.get_network_input(iaddr, simstate, a2.value) for i in range(0, len(networkinput)): tgtaddr = a1.add_offset(i) simstate.set_memval( iaddr, tgtaddr, SV.mk_simvalue(ord(networkinput[i]), 1)) simstate.set_register(iaddr, 'v0', SV.mk_simvalue(len(networkinput))) return self.add_logmsg( iaddr, simstate, pargs, returnval=str(len(networkinput))) else: simstate.set_register(iaddr, 'v0', SV.mk_simvalue(-1)) return self.add_logmsg(iaddr, simstate, pargs, returnval='-1') class MIPStub_recvfrom(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'recvfrom') self.buffer: Optional[str] = None def is_network_operation(self) -> bool: return True def is_io_operation(self) -> bool: return True def get_network_input( self, iaddr: str, simstate: "SimulationState", size: int) -> str: if self.buffer is None: if simstate.simsupport.has_network_input(iaddr): self.buffer = simstate.simsupport.network_input( iaddr, simstate, size) self.buffer = cast(str, self.buffer) if len(self.buffer) > 0 and len(self.buffer) <= size: recv = self.buffer self.buffer = None return recv elif len(self.buffer) > 0: recv = self.buffer[:size] self.buffer = self.buffer[size:] return recv else: return '' def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a3 = self.get_arg_val(iaddr, simstate, 'a3') a4 = self.get_stack_arg_val(iaddr, simstate, 4) a5 = self.get_stack_arg_val(iaddr, simstate, 5) pargs = ','.join(str(a) for a in [a0, a1, a2, a3, a4, a5]) if self.buffer and len(self.buffer) == 0: simstate.set_register(iaddr, 'v0', SV.simOne) simstate.add_logmsg('i/o', self.name + '(' + pargs + '):1') return self.add_logmsg(iaddr, simstate, pargs, returnval='1') elif (simstate.simsupport.has_network_input(iaddr) and a1.is_address and a2.is_literal and a2.is_defined): a1 = cast(SSV.SimAddress, a1) a2 = cast(SV.SimLiteralValue, a2) networkinput = self.get_network_input(iaddr, simstate, a2.value) for i in range(0, len(networkinput)): tgtaddr = a1.add_offset(i) simstate.set_memval( iaddr, tgtaddr, SV.mk_simvalue(ord(networkinput[i]), 1)) simstate.set_register(iaddr, 'v0', SV.mk_simvalue(len(networkinput))) return self.add_logmsg( iaddr, simstate, pargs, returnval=str(len(networkinput))) else: simstate.set_register(iaddr, 'v0', SV.mk_simvalue(-1)) return self.add_logmsg(iaddr, simstate, pargs, returnval='-1') class MIPStub_sched_get_priority_max(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'sched_get_priority_max') def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simOne) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_sched_get_priority_min(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'sched_get_priority_min') def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_sched_yield(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'sched_yield') def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, '') class MIPStub_select(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'select') self.count = 0 def is_network_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Returns the total number of bits set.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a3 = self.get_arg_val(iaddr, simstate, 'a3') a4 = self.get_stack_arg_val(iaddr, simstate, 4) pargs = ','.join(str(a) for a in [a0, a1, a2, a3, a4]) if self.count == 0 or self.count == 1: result = SV.simOne self.count += 1 else: result = SV.simZero simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_semctl(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "semctl") def is_sharedmem_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # int semid a1 = self.get_arg_val(iaddr, simstate, "a1") # int semnum a2 = self.get_arg_val(iaddr, simstate, "a2") # int cmd, ... pargs = ", ".join(str(a) for a in [a0, a1, a2]) if ( a0.is_defined and a1.is_defined and a2.is_defined and a0.is_literal and a1.is_literal and a2.is_literal): semid = a0.literal_value semnum = a1.literal_value cmd = a2.literal_value result = simstate.simsupport.semaphore_semctl( iaddr, simstate, semid, semnum, cmd) else: simstate.add_logmsg("warning", iaddr + ": semctl arguments undefined") simstate.set_register(iaddr, "v0", SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_semget(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "semget") def is_sharedmem_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # key_t key a1 = self.get_arg_val(iaddr, simstate, "a1") # int nsems a2 = self.get_arg_val(iaddr, simstate, "a2") # int semflg pargs = ','.join(str(a) for a in [a0, a1, a2]) if ( a0.is_defined and a1.is_defined and a2.is_defined and a0.is_literal and a1.is_literal and a2.is_literal): key = a0.literal_value nsems = a1.literal_value semflg = a2.literal_value result = simstate.simsupport.semaphore_semget( iaddr, simstate, key, nsems, semflg) else: simstate.add_logmsg("warning", iaddr + ": semget arguments undefined") result = -1 simstate.set_register(iaddr, "v0", SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_semop(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'semop') def is_sharedmem_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # int semid a1 = self.get_arg_val(iaddr, simstate, "a1") # struct sembuf *sops a2 = self.get_arg_val(iaddr, simstate, "a2") # size_t nsops pargs = ','.join(str(a) for a in [a0, a1, a2]) if ( a0.is_defined and a1.is_defined and a2.is_defined and a0.is_literal and (a1.is_literal or a1.is_address) and a2.is_literal): semid = a0.literal_value if a1.is_literal: sops = cast( SSV.SimAddress, simstate.resolve_literal_address(iaddr, a1.literal_value)) else: sops = cast(SSV.SimAddress, a1) nsops = a2.literal_value result = simstate.simsupport.semaphore_semop( iaddr, simstate, semid, sops, nsops) else: simstate.add_logmsg( "warning", iaddr + ": semop: some arguments are undefined") result = -1 simstate.set_register(iaddr, "v0", SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_send(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'send') def is_io_operation(self) -> bool: return True def is_network_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a3 = self.get_arg_val(iaddr, simstate, 'a3') pargs = ','.join(str(a) for a in [a0, a1, a2, a3]) simstate.set_register(iaddr, 'v0', a2) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(a2)) class MIPStub_sendto(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'sendto') def is_io_operation(self) -> bool: return True def is_network_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a3 = self.get_arg_val(iaddr, simstate, 'a3') a4 = self.get_stack_arg_val(iaddr, simstate, 4) a5 = self.get_stack_arg_val(iaddr, simstate, 5) pargs = ','.join(str(a) for a in [a0, a1, a2, a3, a4, a5]) simstate.set_register(iaddr, 'v0', SV.simOne) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_setenv(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'setenv') def is_environment_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Logs i/o; returns 0 in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = ( str(a0) + ':' + a0str + ',' + str(a1) + ':' + a1str + ',' + str(a2)) simstate.simsupport.set_environment_variable(a0str, a1str) return self.add_logmsg(iaddr, simstate, pargs) class MIPSimStub_sprintf_like(MIPSimStub): def __init__(self, name: str) -> None: MIPSimStub.__init__(self, name) def write_string_to_buffer( self, iaddr: str, simstate: "SimulationState", s: str) -> None: a0 = self.get_arg_val(iaddr, simstate, 'a0') if a0.is_symbol: simstate.add_logmsg( 'free sprintf', ' to dst: ' + str(a0) + '; str: ' + str(s)) return elif a0.is_literal and a0.is_defined: a0 = cast(SV.SimLiteralValue, a0) dstaddr = cast( SSV.SimAddress, simstate.resolve_literal_address(iaddr, a0.value)) if not dstaddr.is_defined: raise SU.CHBSimError( simstate, iaddr, "sprintf: Address not recognized as a global: " + str(a0)) elif a0.is_address: dstaddr = cast(SSV.SimAddress, a0) else: raise SU.CHBSimError( simstate, iaddr, 'Illegal destination address in sprintf: ' + str(a0)) for i in range(0, len(s)): srcval = SV.SimByteValue(ord(s[i])) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_memval(iaddr, dstaddr.add_offset(len(s)), SV.SimByteValue(0)) def get_logmsg( self, iaddr: str, simstate: "SimulationState", varargs: List[str], s: str) -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') pargs = str(a0) + ',' + str(a1) + ':' + a1str + ',' + ','.join(varargs) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(len(s))) def set_returnval( self, iaddr: str, simstate: "SimulationState", s: str) -> None: simstate.set_register(iaddr, 'v0', SV.mk_simvalue(len(s))) def substitute_formatstring( self, iaddr: str, simstate: "SimulationState", a1str: str) -> Tuple[str, List[str]]: """Return substituted string and arguments used (as a string).""" result = simstate.simsupport.substitute_formatstring( self, iaddr, simstate, a1str) if result is not None: return result if a1str == '%s': a2 = self.get_arg_val(iaddr, simstate, 'a2') a2str = self.get_arg_string(iaddr, simstate, 'a2') printstring = a2str varargs = [str(a2) + ':' + a2str] return (printstring, varargs) elif a1str == '%d': a2 = self.get_arg_val(iaddr, simstate, 'a2') if a2.is_literal and a2.is_defined: a2 = cast(SV.SimLiteralValue, a2) printstring = str(a2.value) varargs = [str(a2)] return (printstring, varargs) else: raise SU.CHBSimError( simstate, iaddr, "Argument a2 not recognized: " + str(a2)) else: simstate.add_logmsg('warning', self.name + " without substitution") return (a1str, []) def simulate(self, iaddr: str, simstate: "SimulationState") -> str: return "to be overridden" class MIPStub_snprintf(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "snprintf") def write_string_to_buffer( self, iaddr: str, simstate: "SimulationState", s: str) -> None: a0 = self.get_arg_val(iaddr, simstate, 'a0') if a0.is_symbol: simstate.add_logmsg( 'free sprintf', ' to dst: ' + str(a0) + '; str: ' + str(s)) elif a0.is_literal and a0.is_defined: a0 = cast(SV.SimLiteralValue, a0) dstaddr = cast( SSV.SimAddress, simstate.resolve_literal_address(iaddr, a0.value)) if not dstaddr.is_defined: raise SU.CHBSimError( simstate, iaddr, "sprintf: Address not recognized as a global: " + str(a0)) elif a0.is_address: dstaddr = cast(SSV.SimAddress, a0) else: raise SU.CHBSimError( simstate, iaddr, 'Illegal destination address in sprintf: ' + str(a0)) for i in range(0, len(s)): srcval = SV.SimByteValue(ord(s[i])) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_memval(iaddr, dstaddr.add_offset(len(s)), SV.SimByteValue(0)) def set_returnval( self, iaddr: str, simstate: "SimulationState", s: str) -> None: simstate.set_register(iaddr, 'v0', SV.mk_simvalue(len(s))) def get_logmsg( self, iaddr: str, simstate: "SimulationState", varargs: List[str], s: str) -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") a1 = self.get_arg_val(iaddr, simstate, "a1") a2 = self.get_arg_val(iaddr, simstate, "a2") a2str = self.get_arg_string(iaddr, simstate, "a2") pargs = str(a0) + ',' + str(a1) + "," + str(a2) + ':' + a2str + ',' + ','.join(varargs) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(len(s))) def substitute_formatstring( self, iaddr: str, simstate: "SimulationState", a2str: str) -> Tuple[str, List[str]]: """Return substituted string and arguments used (as a string).""" result = simstate.simsupport.substitute_formatstring( self, iaddr, simstate, a2str) if result is None: simstate.add_logmsg("warning", self.name + " without substitution") return (a2str, []) else: return result def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a2str = self.get_arg_string(iaddr, simstate, 'a2') (printstring, varargs) = self.substitute_formatstring( iaddr, simstate, a2str) self.write_string_to_buffer(iaddr, simstate, printstring) self.set_returnval(iaddr, simstate, printstring) pvarargs = ", ".join(varargs) # pargs = ','.join(str(a) for a in [a0, a1, a2]) return self.get_logmsg(iaddr, simstate, varargs, printstring) class MIPStub_sprintf(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "sprintf") def write_string_to_buffer( self, iaddr: str, simstate: "SimulationState", s: str) -> None: a0 = self.get_arg_val(iaddr, simstate, "a0") if a0.is_symbol: simstate.add_logmsg( 'free sprintf', ' to dst: ' + str(a0) + '; str: ' + str(s)) return if a0.is_address: dstaddr = cast(SSV.SimAddress, a0) elif a0.is_literal: dstaddr = simstate.resolve_literal_address(iaddr, a0.literal_value) if dstaddr.is_undefined: raise SU.CHBSimError( simstate, iaddr, "sprintf: Destination address cannot be resolved: " + str(a0)) for i in range(0, len(s)): srcval = SV.mk_simcharvalue(s[i]) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_memval(iaddr, dstaddr.add_offset(len(s)), SV.simZerobyte) def substitute_formatstring( self, iaddr: str, simstate: "SimulationState", formatstr: str) -> Tuple[str, List[str]]: """Return substituted string and arguments used (as a string).""" result = simstate.simsupport.substitute_formatstring( self, iaddr, simstate, formatstr) if result is None: simstate.add_logmsg( "warning", self.name + " without substitution for formatstring " + formatstr) return (formatstr, []) else: return result def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # char *restrict s a1 = self.get_arg_val(iaddr, simstate, "a1") # const char *restrict format a1str = self.get_arg_string(iaddr, simstate, "a1") if a0.is_undefined or a1.is_undefined: raise SU.CHBSimError( simstate, iaddr, "some argument to sprintf is undefined") (printstring, varargs) = self.substitute_formatstring( iaddr, simstate, a1str) self.write_string_to_buffer(iaddr, simstate, printstring) simstate.set_register(iaddr, "v0", SV.mk_simvalue(len(printstring))) pargs = ', '.join([str(a0), a1str] + varargs) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(len(printstring))) class MIPStub_srand(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'srand') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.mk_simvalue(0x12345678)) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_sscanf(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'sscanf') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') pargs = str(a0) + ',' + str(a1) + ':' + a1str result = -1 simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_stat(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'stat') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a0str = self.get_arg_string(iaddr, simstate, 'a0') pargs = str(a0) + ':' + a0str + ',' + str(a1) simstate.set_register(iaddr, 'v0', SV.mk_simvalue(-1)) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_strcasecmp(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strcasecmp') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') try: a0str = self.get_arg_string(iaddr, simstate, 'a0') a0strlc = a0str.lower() a1strlc = a1str.lower() if a0strlc == a1strlc: result = 0 elif a0strlc < a1strlc: result = -1 else: result = 1 except Exception as e: result = 1 print('Error in strcasecmp') a0str = '*** error ****' if iaddr == '0x403948': result = 0 resultval = SV.mk_simvalue(result) simstate.set_register(iaddr, 'v0', resultval) pargs = ','.join(str(a) + ':' + str(v) for (a, v) in [(a0, a0str), (a1, a1str)]) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(resultval)) class MIPStub_strchr(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strchr') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Returns pointer to the first character that matches the second argument.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = ','.join(str(a) for a in [a0, a1]) if a0.is_string_address and a1.is_literal and a1.is_defined: a1 = cast(SV.SimLiteralValue, a1) a0str = self.get_arg_string(iaddr, simstate, 'a0') if not (chr(a1.value) in a0str): returnval: SV.SimValue = SV.simZero else: index = a0str.find(str(chr(a1.value))) returnval = SSV.mk_string_address(a0str[index:]) elif a0.is_address and a1.is_literal and a1.is_defined: a0 = cast(SSV.SimAddress, a0) a1 = cast(SV.SimLiteralValue, a1) i = 0 while True: c = simstate.memval(iaddr, a0.add_offset(i), 1) if c.is_literal and c.is_defined: c = cast(SV.SimLiteralValue, c) if c.value == a1.value: returnval = a0.add_offset(i) break elif c.value == 0: returnval = SV.simZero break else: i += 1 else: returnval = SV.simUndefinedDW break simstate.set_register(iaddr, 'v0', returnval) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval)) else: returnval = SV.simZero if a1.is_literal and a1.is_defined: a1 = cast(SV.SimLiteralValue, a1) pa1 = "'" + chr(a1.value) + "'" else: pa1 = str(a1) pargs = str(a0) + ',' + pa1 simstate.set_register(iaddr, 'v0', returnval) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval)) class MIPStub_strncasecmp(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strncasecmp') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Compares the two strings up to count, and returns the result in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a0str = self.get_arg_string(iaddr, simstate, 'a0') a1str = self.get_arg_string(iaddr, simstate, 'a1') if a2.is_literal and a2.is_defined: a2 = cast(SV.SimLiteralValue, a2) count = a2.value if a0str.lower()[:count] == a1str.lower()[:count]: result = 0 elif a0str.lower()[:count] < a1str.lower()[:count]: result = -1 else: result = 1 resultval = SV.SimDoubleWordValue(result) else: resultval = SV.simUndefinedDW simstate.set_register(iaddr, 'v0', resultval) pargs = ( str(a0) + ': "' + a0str + '", ' + str(a1) + ': "' + a1str + '", ' + 'count:' + str(a2)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(resultval)) class MIPStub_strcmp(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strcmp') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Compares the two arguments and returns the result in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') # str1 a1 = self.get_arg_val(iaddr, simstate, 'a1') # str2 a0str = self.get_arg_string(iaddr, simstate, 'a0') a1str = self.get_arg_string(iaddr, simstate, 'a1') if a0str == a1str: result = 0 elif a0str < a1str: result = -1 else: result = 1 simstate.set_register(iaddr, 'v0', SV.SimDoubleWordValue(result)) pargs = ','.join(str(a) + ':' + str(v) for (a, v) in [(a0, a0str), (a1, a1str)]) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_strncmp(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strncmp') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Compares the two strings up to count and returns the result in v0.""" a0 = self.get_arg_val(iaddr, simstate, "a0") # const char *s1 a1 = self.get_arg_val(iaddr, simstate, "a1") # const char *s2 a2 = self.get_arg_val(iaddr, simstate, "a2") # size_t n pargs = ", ".join(str(a) for a in [a0, a1, a2]) if a0.is_undefined or a1.is_undefined or a2.is_undefined: raise SU.CHBSimError( simstate, iaddr, "strncmp: some arguments are undefined: " + pargs) if a2.is_literal: n = a2.literal_value else: raise SU.CHBSimError( simstate, iaddr, "strncmp: size argument is not a literal: " + str(a2)) s1 = self.get_arg_string(iaddr, simstate, "a0") s2 = self.get_arg_string(iaddr, simstate, "a1") pargs = s1 + ", " + s2 + ", " + str(n) if len(s1) >= n and len(s2) >= n: if s1[:n] == s2[:n]: result = 0 elif s1[:n] < s2[:n]: result = -1 else: result = 1 elif len(s1) == len(s2): if s1 == s2: result = 0 elif s1 < s2: result = -1 else: result = 1 else: if len(s1) < len(s2): result = -1 else: result = 1 simstate.set_register(iaddr, "v0", SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_strcat(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strcat') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") a1 = self.get_arg_val(iaddr, simstate, "a1") a0str = self.get_arg_string(iaddr, simstate, "a0") a1str = self.get_arg_string(iaddr, simstate, "a1") pargs = str(a0) + "," + a0str + ", " + str(a1) + ":" + a1str if a0.is_address and a1.is_address: a0 = cast(SSV.SimAddress, a0) a1 = cast(SSV.SimAddress, a1) dstaddr = a0.add_offset(len(a0str)) for i in range(0, len(a1str)): srcval = SV.SimByteValue(ord(a1str[i])) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_memval( iaddr, dstaddr.add_offset(len(a1str)), SV.SimByteValue(0)) simstate.set_register(iaddr, 'v0', a0) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_strcpy(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strcpy') def get_dst_arg_index(self) -> int: return 0 def get_src_arg_index(self) -> int: return 1 def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Copies characters from src to dst up to and including null terminator.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') returnmsg = "" if a0.is_undefined or a1.is_undefined: raise SU.CHBSimError( simstate, iaddr, "strcpy: some arguments are undefined") if a0.is_address: dstaddr = cast(SSV.SimAddress, a0) elif a0.is_literal: dstaddr = simstate.resolve_literal_address(iaddr, a0.literal_value) if dstaddr.is_undefined: raise SU.CHBSimError( simstate, iaddr, "strcpy: illegal destination address: " + str(a0)) else: raise SU.CHBSimError( simstate, iaddr, 'strcpy: illegal destination address: ' + str(a0)) if a1.is_string_address: for i in range(0, len(a1str)): srcval = SV.SimByteValue(ord(a1str[i])) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_memval( iaddr, dstaddr.add_offset(len(a1str)), SV.SimByteValue(0)) elif a1.is_symbol: simstate.add_logmsg( 'free strcpy', 'src:' + str(a1) + ' to dst: ' + str(a0)) else: for i in range(0, len(a1str)): srcval = SV.SimByteValue(ord(a1str[i])) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_memval( iaddr, dstaddr.add_offset(len(a1str)), SV.SimByteValue(0)) returnmsg = "copied " + str(len(a1str)) + " to " + str(dstaddr) simstate.set_register(iaddr, "v0", dstaddr) pargs = str(dstaddr) + ',' + str(a1) + ':' + a1str return self.add_logmsg(iaddr, simstate, pargs, returnval=returnmsg) class MIPStub_strdup(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strdup') def is_string_operation(self) -> bool: return True def is_memalloc_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Returns a pointer to a duplicated string in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') if a0.is_string_address: a0 = cast(SSV.SimStringAddress, a0) s = a0.stringval base = 'strdup_' + iaddr buffersize = len(s) + 1 address = SSV.mk_base_address(base, 0, buffersize=buffersize) simstate.basemem[base] = SimBaseMemory( simstate, base, buffersize=buffersize) for i in range(0, buffersize-1): simstate.set_memval( iaddr, address.add_offset(i), SV.mk_simvalue(ord(s[i]), size=1)) simstate.set_memval(iaddr, address.add_offset(buffersize - 1), SV.simZero) result = address elif a0.is_symbol: a0 = cast(SSV.SimSymbol, a0) base = 'strdup_' + iaddr contents = a0.name + '_duplicate' buffersize = len(contents) + 1 address = SSV.mk_base_address(base, 0, buffersize=buffersize) simstate.basemem[base] = SimBaseMemory( simstate, base, buffersize=buffersize) for i in range(0, buffersize-1): simstate.set_memval( iaddr, address.add_offset(i), SV.mk_simvalue(ord(contents[i]), size=1)) result = address else: a0str = self.get_arg_string(iaddr, simstate, 'a0') base = 'strdup_' + iaddr address = SSV.mk_base_address(base, 0, buffersize=len(a0str)) for i in range(0, len(a0str)): simstate.set_memval( iaddr, address.add_offset(i), SV.mk_simbytevalue(ord(a0str[i]))) simstate.set_memval( iaddr, address.add_offset(len(a0str)), SV.mk_simbytevalue(0)) result = address simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(result)) class MIPStub_strerror(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strerror') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') rval = SSV.mk_string_address('strerror-' + str(a0)) simstate.set_register(iaddr, 'v0', rval) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_stristr(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'stristr') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a0str = self.get_arg_string(iaddr, simstate, 'a0') a1str = self.get_arg_string(iaddr, simstate, 'a1') pargs = ','.join(str(a) + ':' + s for (a, s) in [(a0, a0str), (a1, a1str)]) index = a0str.lower().find(a1str.lower()) if index >= 0 and a0.is_address: a0 = cast(SSV.SimAddress, a0) result: SV.SimValue = a0.add_offset(index) else: result = SV.simZero simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_strlen(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strlen') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Returns the length of the first argument in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') result = SV.SimDoubleWordValue(len(a0str)) simstate.set_register(iaddr, 'v0', result) return self.add_logmsg( iaddr, simstate, str(a0) + ':' + a0str, returnval=str(result)) class MIPStub_strncat(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strncat') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = ','.join(str(a) for a in [a0, a1, a2]) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_strncpy(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strncpy') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # char *restrict s1 a1 = self.get_arg_val(iaddr, simstate, "a1") # const char *restrict s2 a2 = self.get_arg_val(iaddr, simstate, "a2") # size_t n parglist = [str(a) for a in [a0, a1, a2]] if a0.is_undefined or a1.is_undefined or a2.is_undefined: raise SU.CHBSimError( simstate, iaddr, "strncpy: some arguments are undefined (" + ", ".join(parglist) + ")") if a0.is_address: dstaddr = cast(SSV.SimAddress, a0) elif a0.is_literal: dstaddr = simstate.resolve_literal_address(iaddr, a0.literal_value) if dstaddr.is_undefined: raise SU.CHBSimError( simstate, iaddr, "strncpy: invalid destination address: " + str(a0)) else: raise SU.CHBSimError( simstate, iaddr, "strncpy: destination address not recognized: " + str(a0)) if a2.is_literal: count = a2.literal_value else: raise SU.CHBSimError( simstate, iaddr, "strncpy: size is not valid: " + str(a2)) a1str = self.get_arg_string(iaddr, simstate, "a1") pargs = ( str(dstaddr) + ", " + str(a1) + ":" + a1str + ", " + str(a2) + ")") if a1.is_string_address: a1 = cast(SSV.SimStringAddress, a1) if len(a1str) < count: for i in range(0, len(a1str)): srcval = SV.mk_simcharvalue(a1str[i]) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_memval( iaddr, dstaddr.add_offset(len(a1str)), SV.simZerobyte) else: for i in range(0, count): srcval = SV.mk_simcharvalue(a1str[i]) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) elif a1.is_address: a1 = cast(SSV.SimAddress, a1) for i in range(0, count): srcaddr = a1.add_offset(i) srcval = cast( SV.SimByteValue, simstate.memval(iaddr, srcaddr, 1)) tgtaddr = dstaddr.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) if srcval.value == 0: break else: raise SU.CHBSimError( simstate, iaddr, "strncpy: invalid source address: " + str(a1)) simstate.set_register(iaddr, "v0", dstaddr) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_strrchr(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strrchr') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') if a0.is_string_address and a1.is_literal and a1.is_defined: a0 = cast(SSV.SimStringAddress, a0) a1 = cast(SV.SimLiteralValue, a1) if not (chr(a1.value) in a0str): returnval: SV.SimValue = SV.simZero else: index = a0str.rfind(str(chr(a1.value))) returnval = SSV.mk_string_address(a0.stringval[index:]) elif a0.is_address and a1.is_literal and a1.is_defined: a0 = cast(SSV.SimAddress, a0) a1 = cast(SV.SimLiteralValue, a1) i = len(a0str) while i >= 0: c = simstate.memval(iaddr, a0.add_offset(i), 1) if c.is_literal and c.is_defined: c = cast(SV.SimLiteralValue, c) print(str(i) + ": " + str(c) + " vs " + str(a1.value)) if c.value == a1.value: break else: i -= 1 else: break if i >= 0: returnval = a0.add_offset(i) else: returnval = SV.simZero else: returnval = SV.simZero simstate.set_register(iaddr, 'v0', returnval) if a1.is_literal and a1.is_defined: a1 = cast(SV.SimLiteralValue, a1) pa1 = "'" + chr(a1.value) + "'" else: pa1 = str(a1) pargs = str(a0) + ':' + a0str + ',' + pa1 return self.add_logmsg(iaddr, simstate, pargs, returnval=str(returnval)) class MIPStub_strsep(MIPSimStub): """extract token from string char *strsep(char **stringp, const char *delim); Description: If *stringp is NULL, the strsep() function returns NULL and does nothing else. Otherwise, this function finds the first token in the string *stringp that is delimited by one of the bytes in the string delim. This token is terminated by overwriting the delimiter with a null byte ('\0'), and *stringp is updated to point past the token. In case no delimiter was found, the token is taken to be the entire string *stringp, and *stringp is made NULL. """ def __init__(self) -> None: MIPSimStub.__init__(self, 'strsep') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') a0derefstr = 'NULL' if a0.is_address: a0 = cast(SSV.SimAddress, a0) a0deref = self.get_arg_deref_val(iaddr, simstate, 'a0') a0derefstr = self.get_arg_deref_string(iaddr, simstate, 'a0') if a0deref.is_address: a0deref = cast(SSV.SimAddress, a0deref) for c in a1str: index = a0derefstr.find(c) if index >= 0: tokenptr = a0deref.add_offset(index+1) simstate.set_memval( iaddr, a0deref.add_offset(index), SV.mk_simvalue(0, size=1)) simstate.set_memval(iaddr, a0, tokenptr) break else: simstate.set_memval(iaddr, a0, SV.simZero) else: simstate.set_memval(iaddr, a0, SV.simZero) a1ordstr = '{' + ','.join(str(ord(c)) for c in a1str) + '}' pargs = str(a0) + ':&' + a0derefstr + ',' + str(a1) + ':' + a1str + a1ordstr simstate.set_register(iaddr, 'v0', a0) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_strstr(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strstr') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a0str = self.get_arg_string(iaddr, simstate, 'a0') a1str = self.get_arg_string(iaddr, simstate, 'a1') pargs = ','.join(str(a) + ':' + s for (a, s) in [(a0, a0str), (a1, a1str)]) if a0.is_undefined or a1.is_undefined: raise SU.CHBSimError( simstate, iaddr, "some argument to strstr is undefined") if a0.is_address: addr = cast(SSV.SimAddress, a0) elif a0.is_literal: addr = simstate.resolve_literal_address(iaddr, a0.literal_value) if addr.is_undefined: raise SU.CHBSimError( simstate, iaddr, "src string address could not be resolved: " + str(a0)) index = a0str.find(a1str) if index >= 0: if a0.is_string_address: result: SV.SimValue = SSV.mk_string_address(a0str[index:]) else: result = addr.add_offset(index) else: result = SV.simZero simstate.set_register(iaddr, "v0", result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_strtof(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strtof') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') pargs = str(a0) + ':' + a0str + str(a1) fstr = '' for c in a0str: if c.isdigit() or c == '.': fstr += c else: break result = SV.mk_floatvalue(float(fstr)) simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_strtok(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strtok') self.state: Optional[str] = None def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') if a0.is_literal and a0.is_defined: a0 = cast(SV.SimLiteralValue, a0) if a0.value == 0: pargs = str(a0) + ',' + str(a1) + ':' + a1str a0str = self.state else: a0str = self.get_arg_string(iaddr, simstate, 'a0') pargs = str(a0) + ':' + a0str + ',' + str(a1) + ':' + a1str else: raise SU.CHBSimError( simstate, iaddr, "Undefined value in strtok: " + str(a0)) if a0str: index = a0str.find(a1str) if index > 0: result: SV.SimValue = SSV.mk_string_address(a0str[index:]) self.state = a0str[index+1:] else: result = a0 self.state = None else: result = SV.simZero simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_strtok_r(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strtok_r') def is_string_operation(self) -> bool: return True def simulate_first_token( self, iaddr: str, simstate: "SimulationState", srcaddr: SSV.SimAddress, s: str, sep: str, stateaddr: SSV.SimAddress) -> str: minpos = len(s) for c in sep: pos = s.find(c) if pos == -1: continue if pos < minpos: minpos = pos if minpos == len(s): result = srcaddr simstate.set_memval(iaddr, stateaddr, SV.simZero) pargs = str(srcaddr) + ':' + s + ',' + sep + ',' + str(stateaddr) simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) else: result = srcaddr simstate.set_memval( iaddr, srcaddr.add_offset(minpos), SV.SimByteValue(0)) simstate.set_memval(iaddr, stateaddr, srcaddr.add_offset(minpos + 1)) pargs = str(srcaddr) + ':' + s + ',' + sep + ',' + str(stateaddr) simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) def simulate_next_token( self, iaddr: str, simstate: "SimulationState", sep: str, a2: SSV.SimAddress) -> str: s = self.get_arg_deref_string(iaddr, simstate, 'a2') minpos = len(s) for c in sep: pos = s.find(c) if pos == -1: continue if pos < minpos: minpos = pos if minpos == len(s): result = self.get_arg_deref_val(iaddr, simstate, 'a2') simstate.set_memval(iaddr, a2, SV.SimByteValue(0)) pargs = '0, ' + sep + ',' + str(a2) simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) else: result = self.get_arg_deref_val(iaddr, simstate, 'a2') if result.is_address: result = cast(SSV.SimAddress, result) simstate.set_memval(iaddr, result.add_offset(minpos), SV.SimByteValue(0)) simstate.set_memval(iaddr, a2, result.add_offset(minpos+1)) else: simstate.add_logmsg(iaddr, "strtok: result is not an address") pargs = '0, ' + sep + ', ' + str(a2) simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Returns 0 in v0.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a1str = self.get_arg_string(iaddr, simstate, 'a1') if a0.is_literal and a0.is_defined and a2.is_address: a0 = cast(SV.SimLiteralValue, a0) a2 = cast(SSV.SimAddress, a2) if a0.value == 0: return self.simulate_next_token(iaddr, simstate, a1str, a2) else: raise SU.CHBSimError( simstate, iaddr, "Unexpected literal value in strtok: " + str(a0)) elif a0.is_address and a2.is_address: a0 = cast(SSV.SimAddress, a0) a2 = cast(SSV.SimAddress, a2) a0str = self.get_arg_string(iaddr, simstate, 'a0') return self.simulate_first_token(iaddr, simstate, a0, a0str, a1str, a2) else: a0str = self.get_arg_string(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) pargs = (str(a0) + ': "' + a0str + '", ' + str(a1) + ': "' + a1str + '", ' + str('state:' + str(a2))) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_strtol(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "strtol") def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # const char *restrict nptr a1 = self.get_arg_val(iaddr, simstate, "a1") # char **restrict endptr a2 = self.get_arg_val(iaddr, simstate, "a2") # int base parglist = [str(a) for a in [a0, a1, a2]] if a0.is_undefined or a1.is_undefined or a2.is_undefined: raise SU.CHBSimError( simstate, iaddr, "strtol: some arguments are undefined: " + ", ".join(parglist)) a0str = self.get_arg_string(iaddr, simstate, "a0") pargs = str(a0) + ":" + a0str + ", " + ", ".join(parglist[1:]) if ( len(a0str) > 0 and a1.is_literal and a2.is_literal and a1.literal_value == 0 # no endptr and (a2.literal_value == 0 or a2.literal_value == 10)): negate = False if a0str.startswith("+"): a0str = a0str[1:] if a0str.startswith("-"): a0str = a0str[1:] negate = True if a0str.isdecimal(): result = int(a0str) elif a0str.startswith("0x") or a0str.startswith("0X"): result = int(a0str, 16) elif a0str.startswith("0"): result = int("0o" + a0str[1:], 8) else: raise SU.CHBSimError( simstate, iaddr, "strtol: representation not recognized: " + a0str) if negate: result = -result else: pass else: raise SU.CHBSimError( simstate, iaddr, "strtol: argument combination not implemented for " + "(" + ", ".join(pargs) + ")") simstate.set_register(iaddr, "v0", SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_strtoul(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'strtoul') def is_string_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") # const char *restrict str a1 = self.get_arg_val(iaddr, simstate, "a1") # char **restring endptr a2 = self.get_arg_val(iaddr, simstate, 'a2') # int base parglist = [str(a) for a in [a0, a1, a2]] if a0.is_undefined or a1.is_undefined or a2.is_undefined: raise SU.CHBSimError( simstate, iaddr, "strtoul: some arguments are undefined " + "(" + ", ".join(parglist) + ")") a0str = self.get_arg_string(iaddr, simstate, "a0") pargs = str(a0) + ":" + a0str + ", " + ", ".join(parglist[1:]) if ( len(a0str) > 0 and a1.is_literal and a2.is_literal and a1.literal_value == 0 # no endptr and (a2.literal_value == 0 or a2.literal_value == 10)): negate = False if a0str.startswith("+"): a0str = a0str[1:] if a0str.startswith("-"): a0str = a0str[1:] negate = True if a0str.isdecimal(): result = int(a0str) elif a0str.startswith("0x") or a0str.startswith("0X"): result = int(a0str, 16) elif a0str.startswith("0"): result = int("0o" + a0str[1:], 8) else: raise SU.CHBSimError( simstate, iaddr, "strtol: representation not recognized: " + a0str) if negate: result = SU.max32 - result else: pass else: raise SU.CHBSimError( simstate, iaddr, "strtol: argument combination not implemented for " + "(" + ", ".join(pargs) + ")") simstate.set_register(iaddr, "v0", SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_syslog(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'syslog') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') pargs = str(a0) + ',' + str(a1) + ':' + a1str if a1str == '%s': a2 = self.get_arg_val(iaddr, simstate, 'a2') a2str = self.get_arg_string(iaddr, simstate, 'a2') pargs += ',' + str(a2) + ':' + a2str simstate.add_logmsg('i/o', self.name + '(' + pargs + ')') return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_system(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'system') def is_system_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') # cmdline string if a0.is_literal and a0.is_defined: a0val = a0.literal_value if a0val == 0: pargs = 'NULL' else: pargs = self.get_arg_string(iaddr, simstate, 'a0') else: pargs = self.get_arg_string(iaddr, simstate, "a0") simstate.set_register(iaddr, "v0", SV.simZero) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_tcgetattr(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "tcgetattr") def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") a1 = self.get_arg_val(iaddr, simstate, "a1") pargs = str(a0) + ", " + str(a1) simstate.set_register(iaddr, "v0", SV.simZero) if a1.is_address: a1 = cast(SSV.SimAddress, a1) simstate.set_memval(iaddr, a1, SV.simZero) simstate.set_memval(iaddr, a1.add_offset(4), SV.simZero) simstate.set_memval(iaddr, a1.add_offset(8), SV.simZero) simstate.set_memval(iaddr, a1.add_offset(12), SV.simZero) return self.add_logmsg(iaddr, simstate, pargs, returnval="0") class MIPStub_tcsetattr(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "tcsetattr") def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") a1 = self.get_arg_val(iaddr, simstate, "a1") a2 = self.get_arg_val(iaddr, simstate, "a2") pargs = ", ".join(str(a) for a in [a0, a1, a2]) simstate.set_register(iaddr, "v0", SV.simZero) return self.add_logmsg(iaddr, simstate, pargs, returnval="0") class MIPStub_time(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'time') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') result = int(time.time()) simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(result)) class MIPStub_tolower(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'tolower') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') if a0.is_literal and a0.is_defined: a0 = cast(SV.SimLiteralValue, a0) result = ord(str(chr(a0.value)).lower()[0]) simstate.set_register(iaddr, 'v0', SV.mk_simvalue(result)) return self.add_logmsg(iaddr, simstate, str(a0), returnval=str(result)) else: return self.add_logmsg(iaddr, simstate, str(a0), returnval="?") class MIPStub_umask(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'umask') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_unlink(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'unlink') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a0str = self.get_arg_string(iaddr, simstate, 'a0') pargs = str(a0) + ':' + a0str simstate.set_register(iaddr, 'v0', SV.mk_simvalue(0)) return self.add_logmsg(iaddr, simstate, pargs) class MIPStub_unsetenv(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "unsetenv") def is_environment_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, "a0") a0str = self.get_arg_string(iaddr, simstate, "a0") simstate.set_register(iaddr, "v0", SV.simZero) pargs = str(a0) + ":" + a0str return self.add_logmsg(iaddr, simstate, pargs, returnval="0") class MIPStub_usleep(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'usleep') def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_vfork(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, "vfork") def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: if iaddr in simstate.simsupport.forkchoices: result = simstate.simsupport.forkchoices[iaddr] else: result = 0 simresult = SV.mk_simvalue(result) simstate.set_register(iaddr, 'v0', simresult) return self.add_logmsg(iaddr, simstate, '', returnval=str(result)) class MIPStub_vsnprintf(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'vsnprintf') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Copies the string of the second argument to the dst argument.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') a2str = self.get_arg_string(iaddr, simstate, 'a2') a3 = self.get_arg_val(iaddr, simstate, 'a3') printstring = a2str if a0.is_symbol: simstate.add_logmsg( 'free vsprintf', ' to dst: ' + str(a0) + '; str: ' + printstring) elif a0.is_address: a0 = cast(SSV.SimAddress, a0) for i in range(0, len(printstring)): srcval = SV.SimByteValue(ord(printstring[i])) tgtaddr = a0.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_memval( iaddr, a0.add_offset(len(printstring)), SV.mk_simvalue(0, size=1)) else: simstate.add_logmsg( iaddr, "No address to write to in vsnprintf: " + str(a0)) simstate.set_register(iaddr, 'v0', SV.SimDoubleWordValue(len(printstring))) pargs = ( str(a0) + ',' + str(a1) + ',' + str(a2) + ':' + a2str + ',' + str(a3)) return self.add_logmsg( iaddr, simstate, pargs, returnval=str(len(printstring))) class MIPStub_vsprintf(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'vsprintf') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Copies the string of the second argument to the dst argument.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a1str = self.get_arg_string(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') printstring = a1str if a0.is_symbol: simstate.add_logmsg( 'free vsprintf', ' to dst: ' + str(a0) + '; str: ' + printstring) elif a0.is_address: a0 = cast(SSV.SimAddress, a0) for i in range(0, len(printstring)): srcval = SV.SimByteValue(ord(printstring[i])) tgtaddr = a0.add_offset(i) simstate.set_memval(iaddr, tgtaddr, srcval) simstate.set_memval( iaddr, a0.add_offset(len(printstring)), SV.mk_simvalue(0, size=1)) simstate.set_register(iaddr, 'v0', SV.SimDoubleWordValue(len(printstring))) pargs = (str(a0) + ',' + str(a1) + ':' + a1str + ',' + str(a2)) return self.add_logmsg( iaddr, simstate, pargs, returnval=str(len(printstring))) class MIPStub_waitpid(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'waitpid') def is_process_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = ','.join(str(a) for a in [a0, a1, a2]) simstate.set_register(iaddr, 'v0', a0) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(a0)) class MIPStub_write(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'write') def is_io_operation(self) -> bool: return True def simulate(self, iaddr: str, simstate: "SimulationState") -> str: """Logs i/o, returns a2 in v0 for now.""" a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = ','.join(str(a) for a in [a0, a1, a2]) if a0.is_literal: simstate.add_logmsg('i/o', 'Not a valid file descriptor: ' + str(a0)) result: SV.SimValue = SV.mk_simvalue(-1) else: a0 = cast(SSV.SimSymbolicValue, a0) if ( a0.is_file_descriptor and a2.is_literal and a2.is_defined and a1.is_address): a0 = cast(SSV.SimSymbolicFileDescriptor, a0) a1 = cast(SSV.SimAddress, a1) a2 = cast(SV.SimLiteralValue, a2) for i in range(0, a2.value): tgtaddr = a1.add_offset(i) srcval = simstate.memval(iaddr, tgtaddr, 1) if srcval.is_literal and srcval.is_defined: srcval = cast(SV.SimLiteralValue, srcval) a0.filedescriptor.write(chr(srcval.value)) else: simstate.add_logmsg(iaddr, "No values written to file") result = a2 simstate.add_logmsg( 'i/o', 'Successfully wrote ' + str(a2) + ' bytes to ' + str(a0)) else: result = SV.mk_simvalue(-1) simstate.set_register(iaddr, 'v0', result) return self.add_logmsg(iaddr, simstate, pargs, returnval=str(result)) class MIPStub_isLanSubnet(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'isLanSubnet') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, str(a0)) class MIPStub_uloop_init(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'uloop_init') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: simstate.set_register(iaddr, 'v0', SV.simZero) return self.add_logmsg(iaddr, simstate, '') class MIPStub_msglogd(MIPSimStub): def __init__(self) -> None: MIPSimStub.__init__(self, 'msglogd') def simulate(self, iaddr: str, simstate: "SimulationState") -> str: a0 = self.get_arg_val(iaddr, simstate, 'a0') a1 = self.get_arg_val(iaddr, simstate, 'a1') a2 = self.get_arg_val(iaddr, simstate, 'a2') pargs = ','.join(str(a) for a in [a0, a1, a2]) simstate.add_logmsg('i/o', self.name + '(' + pargs + ')') return self.add_logmsg(iaddr, simstate, pargs)
36.524205
95
0.573057
23,439
202,198
4.737617
0.038611
0.083002
0.042055
0.065874
0.795795
0.771768
0.751443
0.725247
0.641776
0.602972
0
0.022756
0.306482
202,198
5,535
96
36.530804
0.769133
0.034733
0
0.678687
0
0
0.065086
0.001922
0.000231
0
0.000252
0
0
1
0.127369
false
0.001849
0.004623
0.033981
0.26699
0.014794
0
0
0
null
0
0
0
0
1
1
1
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
4
48eb55540e3b665d75b93cdcbceaa3fd6eb83557
81
py
Python
test.py
xor2k/stream_shuffle
d4869bc5a01537ce53068902f68e6bdd3ee77609
[ "MIT" ]
null
null
null
test.py
xor2k/stream_shuffle
d4869bc5a01537ce53068902f68e6bdd3ee77609
[ "MIT" ]
null
null
null
test.py
xor2k/stream_shuffle
d4869bc5a01537ce53068902f68e6bdd3ee77609
[ "MIT" ]
null
null
null
from data_source import data_source ds = data_source() ds.enable() ds.shuffle()
13.5
35
0.765432
13
81
4.538462
0.538462
0.508475
0.40678
0
0
0
0
0
0
0
0
0
0.123457
81
6
36
13.5
0.830986
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0.25
0
0.25
0
1
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
48ecaa5f39a24c2b5cc564f10f3356e24bae72d2
623
py
Python
reviewboard/admin/__init__.py
klpyang/reviewboard
d7dabf36e5b492f18048dd7084026bf99d6933c5
[ "MIT" ]
1
2018-08-23T09:19:02.000Z
2018-08-23T09:19:02.000Z
reviewboard/admin/__init__.py
klpyang/reviewboard
d7dabf36e5b492f18048dd7084026bf99d6933c5
[ "MIT" ]
null
null
null
reviewboard/admin/__init__.py
klpyang/reviewboard
d7dabf36e5b492f18048dd7084026bf99d6933c5
[ "MIT" ]
null
null
null
from __future__ import unicode_literals from django.db.models.signals import post_save, post_delete from reviewboard.admin.widgets import increment_sync_num from reviewboard.reviews.models import Group from reviewboard.scmtools.models import Repository def _delete_widget_cache(*args, **kwargs): """Clear the cache to keep the admin dashboard up to date.""" increment_sync_num() post_save.connect(_delete_widget_cache, sender=Group) post_save.connect(_delete_widget_cache, sender=Repository) post_delete.connect(_delete_widget_cache, sender=Group) post_delete.connect(_delete_widget_cache, sender=Repository)
32.789474
65
0.833066
87
623
5.62069
0.413793
0.122699
0.173824
0.196319
0.380368
0.380368
0.339468
0
0
0
0
0
0.093098
623
18
66
34.611111
0.865487
0.088283
0
0
0
0
0
0
0
0
0
0
0
1
0.090909
true
0
0.454545
0
0.545455
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
1
0
1
0
0
4
5b22346f5da923b910a6385290ba4f326e9d2d29
59
py
Python
containment/test_cli/__init__.py
zancas/protoenv
4f7e2c2338e0ca7c107a7b3a9913bb5e6e07245f
[ "MIT" ]
null
null
null
containment/test_cli/__init__.py
zancas/protoenv
4f7e2c2338e0ca7c107a7b3a9913bb5e6e07245f
[ "MIT" ]
3
2017-03-11T23:16:15.000Z
2017-03-11T23:24:19.000Z
containment/test_cli/__init__.py
zancas/protoenv
4f7e2c2338e0ca7c107a7b3a9913bb5e6e07245f
[ "MIT" ]
null
null
null
# -*- coding: utf-8 -*- """Top-level package for tests."""
19.666667
34
0.559322
8
59
4.125
1
0
0
0
0
0
0
0
0
0
0
0.02
0.152542
59
2
35
29.5
0.64
0.864407
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
d2a5f3344df7a7dbb59dcccc23531d734128dc94
127
py
Python
pacote-download/Mundo1/ex010.py
ariadne-pereira/cev-python
b2c6bbebb5106bb0152c9127c04c83f23e9d7757
[ "MIT" ]
null
null
null
pacote-download/Mundo1/ex010.py
ariadne-pereira/cev-python
b2c6bbebb5106bb0152c9127c04c83f23e9d7757
[ "MIT" ]
null
null
null
pacote-download/Mundo1/ex010.py
ariadne-pereira/cev-python
b2c6bbebb5106bb0152c9127c04c83f23e9d7757
[ "MIT" ]
null
null
null
din = float(input('Quantos reais você tem? ')) print('Com {:.2f} reais você pode comprar {:.2f} doláres'.format(din, din/3.27))
63.5
80
0.677165
21
127
4.095238
0.761905
0.209302
0
0
0
0
0
0
0
0
0
0.044643
0.11811
127
2
80
63.5
0.723214
0
0
0
0
0
0.570313
0
0
0
0
0
0
1
0
false
0
0
0
0
0.5
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
4
d2c558e278cd98f4f482e55b03190ebd80a57643
146
py
Python
WeatherPy/working_code/api_keys.py
troyyoungblood/20201219Homework_TDY
e3533e63cce9d10971ed585c67f32236a8429d07
[ "MIT" ]
null
null
null
WeatherPy/working_code/api_keys.py
troyyoungblood/20201219Homework_TDY
e3533e63cce9d10971ed585c67f32236a8429d07
[ "MIT" ]
null
null
null
WeatherPy/working_code/api_keys.py
troyyoungblood/20201219Homework_TDY
e3533e63cce9d10971ed585c67f32236a8429d07
[ "MIT" ]
null
null
null
# OpenWeatherMap API Key weather_api_key = "bfabad3eec079b77cd6e28110d3ad22f" # Google API Key g_key = "AIzaSyBKZyrmnIxatibyVFhiPyCHD87TQW0ulAA"
24.333333
52
0.842466
13
146
9.230769
0.615385
0.15
0
0
0
0
0
0
0
0
0
0.137405
0.10274
146
5
53
29.2
0.778626
0.253425
0
0
0
0
0.669811
0.669811
0
0
0
0
0
1
0
false
0
0
0
0
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
961cd436d8d3b05f0a7d335bdc2df79241a3aa19
375
py
Python
examples/dagster_examples/bay_bikes/repository.py
JPeer264/dagster-fork
32cc87a36134be7c442fa85d6867eb1d3301aea0
[ "Apache-2.0" ]
1
2020-08-10T23:03:37.000Z
2020-08-10T23:03:37.000Z
examples/dagster_examples/bay_bikes/repository.py
JPeer264/dagster-fork
32cc87a36134be7c442fa85d6867eb1d3301aea0
[ "Apache-2.0" ]
null
null
null
examples/dagster_examples/bay_bikes/repository.py
JPeer264/dagster-fork
32cc87a36134be7c442fa85d6867eb1d3301aea0
[ "Apache-2.0" ]
1
2020-08-20T14:20:31.000Z
2020-08-20T14:20:31.000Z
from dagster import repository from .pipelines import daily_weather_pipeline, generate_training_set_and_train_model @repository def bay_bikes_demo(): return { 'pipelines': { 'generate_training_set_and_train_model': lambda: generate_training_set_and_train_model, 'daily_weather_pipeline': lambda: daily_weather_pipeline, } }
26.785714
99
0.738667
43
375
5.906977
0.465116
0.141732
0.23622
0.259843
0.377953
0.377953
0
0
0
0
0
0
0.2
375
13
100
28.846154
0.846667
0
0
0
1
0
0.181333
0.157333
0
0
0
0
0
1
0.1
true
0
0.2
0.1
0.4
0
0
0
0
null
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
8260aa9aec443d2c56980c07815df88bd5b3e4a3
398
py
Python
shake/skeletons/project/settings/__init__.py
lucuma/Shake
b54082c9d217059ef02317aa043c3690d2e601d7
[ "MIT" ]
4
2015-02-15T17:35:12.000Z
2016-07-21T06:35:12.000Z
shake/skeletons/project/settings/__init__.py
lucuma/Shake
b54082c9d217059ef02317aa043c3690d2e601d7
[ "MIT" ]
null
null
null
shake/skeletons/project/settings/__init__.py
lucuma/Shake
b54082c9d217059ef02317aa043c3690d2e601d7
[ "MIT" ]
null
null
null
# coding=utf-8 """ Project settings ------------------------------- """ import shake if shake.env_is('production'): import settings.production as settings elif shake.env_is('testing'): import settings.testing as settings else: import settings.development as settings # # Import local settings # try: # import settings.local as settings # except ImportError: # pass
17.304348
43
0.645729
45
398
5.666667
0.466667
0.219608
0.078431
0
0
0
0
0
0
0
0
0.003106
0.190955
398
22
44
18.090909
0.78882
0.394472
0
0
0
0
0.077982
0
0
0
0
0
0
1
0
true
0
0.571429
0
0.571429
0
0
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
4
82741da60eba0efeb8f40fba6356c1599b91a821
244
py
Python
city_housing_index/local_auth/serializers.py
Sinope-Nanto/city_house
73589bb07c415b1deecf8a0618b79d376d5a6e88
[ "MIT" ]
null
null
null
city_housing_index/local_auth/serializers.py
Sinope-Nanto/city_house
73589bb07c415b1deecf8a0618b79d376d5a6e88
[ "MIT" ]
null
null
null
city_housing_index/local_auth/serializers.py
Sinope-Nanto/city_house
73589bb07c415b1deecf8a0618b79d376d5a6e88
[ "MIT" ]
1
2021-05-05T13:13:56.000Z
2021-05-05T13:13:56.000Z
from rest_framework import serializers from .models import UserProfile class UserProfileSerializer(serializers.ModelSerializer): class Meta: model = UserProfile fields = ['id', 'user_id', 'name', 'mobile', 'city', 'role']
27.111111
68
0.704918
25
244
6.8
0.76
0
0
0
0
0
0
0
0
0
0
0
0.184426
244
8
69
30.5
0.854271
0
0
0
0
0
0.110656
0
0
0
0
0
0
1
0
false
0
0.333333
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
82bb377c23520e249c41ff86b244f8037d95efce
15,637
py
Python
kubernetes_asyncio/client/models/v1_certificate_signing_request_spec.py
icamposrivera/kubernetes_asyncio
f028cc793e3a2c519be6a52a49fb77ff0b014c9b
[ "Apache-2.0" ]
null
null
null
kubernetes_asyncio/client/models/v1_certificate_signing_request_spec.py
icamposrivera/kubernetes_asyncio
f028cc793e3a2c519be6a52a49fb77ff0b014c9b
[ "Apache-2.0" ]
null
null
null
kubernetes_asyncio/client/models/v1_certificate_signing_request_spec.py
icamposrivera/kubernetes_asyncio
f028cc793e3a2c519be6a52a49fb77ff0b014c9b
[ "Apache-2.0" ]
null
null
null
# coding: utf-8 """ Kubernetes No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 The version of the OpenAPI document: v1.19.15 Generated by: https://openapi-generator.tech """ import pprint import re # noqa: F401 import six from kubernetes_asyncio.client.configuration import Configuration class V1CertificateSigningRequestSpec(object): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ """ Attributes: openapi_types (dict): The key is attribute name and the value is attribute type. attribute_map (dict): The key is attribute name and the value is json key in definition. """ openapi_types = { 'extra': 'dict(str, list[str])', 'groups': 'list[str]', 'request': 'str', 'signer_name': 'str', 'uid': 'str', 'usages': 'list[str]', 'username': 'str' } attribute_map = { 'extra': 'extra', 'groups': 'groups', 'request': 'request', 'signer_name': 'signerName', 'uid': 'uid', 'usages': 'usages', 'username': 'username' } def __init__(self, extra=None, groups=None, request=None, signer_name=None, uid=None, usages=None, username=None, local_vars_configuration=None): # noqa: E501 """V1CertificateSigningRequestSpec - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() self.local_vars_configuration = local_vars_configuration self._extra = None self._groups = None self._request = None self._signer_name = None self._uid = None self._usages = None self._username = None self.discriminator = None if extra is not None: self.extra = extra if groups is not None: self.groups = groups self.request = request self.signer_name = signer_name if uid is not None: self.uid = uid if usages is not None: self.usages = usages if username is not None: self.username = username @property def extra(self): """Gets the extra of this V1CertificateSigningRequestSpec. # noqa: E501 extra contains extra attributes of the user that created the CertificateSigningRequest. Populated by the API server on creation and immutable. # noqa: E501 :return: The extra of this V1CertificateSigningRequestSpec. # noqa: E501 :rtype: dict(str, list[str]) """ return self._extra @extra.setter def extra(self, extra): """Sets the extra of this V1CertificateSigningRequestSpec. extra contains extra attributes of the user that created the CertificateSigningRequest. Populated by the API server on creation and immutable. # noqa: E501 :param extra: The extra of this V1CertificateSigningRequestSpec. # noqa: E501 :type: dict(str, list[str]) """ self._extra = extra @property def groups(self): """Gets the groups of this V1CertificateSigningRequestSpec. # noqa: E501 groups contains group membership of the user that created the CertificateSigningRequest. Populated by the API server on creation and immutable. # noqa: E501 :return: The groups of this V1CertificateSigningRequestSpec. # noqa: E501 :rtype: list[str] """ return self._groups @groups.setter def groups(self, groups): """Sets the groups of this V1CertificateSigningRequestSpec. groups contains group membership of the user that created the CertificateSigningRequest. Populated by the API server on creation and immutable. # noqa: E501 :param groups: The groups of this V1CertificateSigningRequestSpec. # noqa: E501 :type: list[str] """ self._groups = groups @property def request(self): """Gets the request of this V1CertificateSigningRequestSpec. # noqa: E501 request contains an x509 certificate signing request encoded in a \"CERTIFICATE REQUEST\" PEM block. When serialized as JSON or YAML, the data is additionally base64-encoded. # noqa: E501 :return: The request of this V1CertificateSigningRequestSpec. # noqa: E501 :rtype: str """ return self._request @request.setter def request(self, request): """Sets the request of this V1CertificateSigningRequestSpec. request contains an x509 certificate signing request encoded in a \"CERTIFICATE REQUEST\" PEM block. When serialized as JSON or YAML, the data is additionally base64-encoded. # noqa: E501 :param request: The request of this V1CertificateSigningRequestSpec. # noqa: E501 :type: str """ if self.local_vars_configuration.client_side_validation and request is None: # noqa: E501 raise ValueError("Invalid value for `request`, must not be `None`") # noqa: E501 if (self.local_vars_configuration.client_side_validation and request is not None and not re.search(r'^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$', request)): # noqa: E501 raise ValueError(r"Invalid value for `request`, must be a follow pattern or equal to `/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/`") # noqa: E501 self._request = request @property def signer_name(self): """Gets the signer_name of this V1CertificateSigningRequestSpec. # noqa: E501 signerName indicates the requested signer, and is a qualified name. List/watch requests for CertificateSigningRequests can filter on this field using a \"spec.signerName=NAME\" fieldSelector. Well-known Kubernetes signers are: 1. \"kubernetes.io/kube-apiserver-client\": issues client certificates that can be used to authenticate to kube-apiserver. Requests for this signer are never auto-approved by kube-controller-manager, can be issued by the \"csrsigning\" controller in kube-controller-manager. 2. \"kubernetes.io/kube-apiserver-client-kubelet\": issues client certificates that kubelets use to authenticate to kube-apiserver. Requests for this signer can be auto-approved by the \"csrapproving\" controller in kube-controller-manager, and can be issued by the \"csrsigning\" controller in kube-controller-manager. 3. \"kubernetes.io/kubelet-serving\" issues serving certificates that kubelets use to serve TLS endpoints, which kube-apiserver can connect to securely. Requests for this signer are never auto-approved by kube-controller-manager, and can be issued by the \"csrsigning\" controller in kube-controller-manager. More details are available at https://k8s.io/docs/reference/access-authn-authz/certificate-signing-requests/#kubernetes-signers Custom signerNames can also be specified. The signer defines: 1. Trust distribution: how trust (CA bundles) are distributed. 2. Permitted subjects: and behavior when a disallowed subject is requested. 3. Required, permitted, or forbidden x509 extensions in the request (including whether subjectAltNames are allowed, which types, restrictions on allowed values) and behavior when a disallowed extension is requested. 4. Required, permitted, or forbidden key usages / extended key usages. 5. Expiration/certificate lifetime: whether it is fixed by the signer, configurable by the admin. 6. Whether or not requests for CA certificates are allowed. # noqa: E501 :return: The signer_name of this V1CertificateSigningRequestSpec. # noqa: E501 :rtype: str """ return self._signer_name @signer_name.setter def signer_name(self, signer_name): """Sets the signer_name of this V1CertificateSigningRequestSpec. signerName indicates the requested signer, and is a qualified name. List/watch requests for CertificateSigningRequests can filter on this field using a \"spec.signerName=NAME\" fieldSelector. Well-known Kubernetes signers are: 1. \"kubernetes.io/kube-apiserver-client\": issues client certificates that can be used to authenticate to kube-apiserver. Requests for this signer are never auto-approved by kube-controller-manager, can be issued by the \"csrsigning\" controller in kube-controller-manager. 2. \"kubernetes.io/kube-apiserver-client-kubelet\": issues client certificates that kubelets use to authenticate to kube-apiserver. Requests for this signer can be auto-approved by the \"csrapproving\" controller in kube-controller-manager, and can be issued by the \"csrsigning\" controller in kube-controller-manager. 3. \"kubernetes.io/kubelet-serving\" issues serving certificates that kubelets use to serve TLS endpoints, which kube-apiserver can connect to securely. Requests for this signer are never auto-approved by kube-controller-manager, and can be issued by the \"csrsigning\" controller in kube-controller-manager. More details are available at https://k8s.io/docs/reference/access-authn-authz/certificate-signing-requests/#kubernetes-signers Custom signerNames can also be specified. The signer defines: 1. Trust distribution: how trust (CA bundles) are distributed. 2. Permitted subjects: and behavior when a disallowed subject is requested. 3. Required, permitted, or forbidden x509 extensions in the request (including whether subjectAltNames are allowed, which types, restrictions on allowed values) and behavior when a disallowed extension is requested. 4. Required, permitted, or forbidden key usages / extended key usages. 5. Expiration/certificate lifetime: whether it is fixed by the signer, configurable by the admin. 6. Whether or not requests for CA certificates are allowed. # noqa: E501 :param signer_name: The signer_name of this V1CertificateSigningRequestSpec. # noqa: E501 :type: str """ if self.local_vars_configuration.client_side_validation and signer_name is None: # noqa: E501 raise ValueError("Invalid value for `signer_name`, must not be `None`") # noqa: E501 self._signer_name = signer_name @property def uid(self): """Gets the uid of this V1CertificateSigningRequestSpec. # noqa: E501 uid contains the uid of the user that created the CertificateSigningRequest. Populated by the API server on creation and immutable. # noqa: E501 :return: The uid of this V1CertificateSigningRequestSpec. # noqa: E501 :rtype: str """ return self._uid @uid.setter def uid(self, uid): """Sets the uid of this V1CertificateSigningRequestSpec. uid contains the uid of the user that created the CertificateSigningRequest. Populated by the API server on creation and immutable. # noqa: E501 :param uid: The uid of this V1CertificateSigningRequestSpec. # noqa: E501 :type: str """ self._uid = uid @property def usages(self): """Gets the usages of this V1CertificateSigningRequestSpec. # noqa: E501 usages specifies a set of key usages requested in the issued certificate. Requests for TLS client certificates typically request: \"digital signature\", \"key encipherment\", \"client auth\". Requests for TLS serving certificates typically request: \"key encipherment\", \"digital signature\", \"server auth\". Valid values are: \"signing\", \"digital signature\", \"content commitment\", \"key encipherment\", \"key agreement\", \"data encipherment\", \"cert sign\", \"crl sign\", \"encipher only\", \"decipher only\", \"any\", \"server auth\", \"client auth\", \"code signing\", \"email protection\", \"s/mime\", \"ipsec end system\", \"ipsec tunnel\", \"ipsec user\", \"timestamping\", \"ocsp signing\", \"microsoft sgc\", \"netscape sgc\" # noqa: E501 :return: The usages of this V1CertificateSigningRequestSpec. # noqa: E501 :rtype: list[str] """ return self._usages @usages.setter def usages(self, usages): """Sets the usages of this V1CertificateSigningRequestSpec. usages specifies a set of key usages requested in the issued certificate. Requests for TLS client certificates typically request: \"digital signature\", \"key encipherment\", \"client auth\". Requests for TLS serving certificates typically request: \"key encipherment\", \"digital signature\", \"server auth\". Valid values are: \"signing\", \"digital signature\", \"content commitment\", \"key encipherment\", \"key agreement\", \"data encipherment\", \"cert sign\", \"crl sign\", \"encipher only\", \"decipher only\", \"any\", \"server auth\", \"client auth\", \"code signing\", \"email protection\", \"s/mime\", \"ipsec end system\", \"ipsec tunnel\", \"ipsec user\", \"timestamping\", \"ocsp signing\", \"microsoft sgc\", \"netscape sgc\" # noqa: E501 :param usages: The usages of this V1CertificateSigningRequestSpec. # noqa: E501 :type: list[str] """ self._usages = usages @property def username(self): """Gets the username of this V1CertificateSigningRequestSpec. # noqa: E501 username contains the name of the user that created the CertificateSigningRequest. Populated by the API server on creation and immutable. # noqa: E501 :return: The username of this V1CertificateSigningRequestSpec. # noqa: E501 :rtype: str """ return self._username @username.setter def username(self, username): """Sets the username of this V1CertificateSigningRequestSpec. username contains the name of the user that created the CertificateSigningRequest. Populated by the API server on creation and immutable. # noqa: E501 :param username: The username of this V1CertificateSigningRequestSpec. # noqa: E501 :type: str """ self._username = username def to_dict(self): """Returns the model properties as a dict""" result = {} for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, value.items() )) else: result[attr] = value return result def to_str(self): """Returns the string representation of the model""" return pprint.pformat(self.to_dict()) def __repr__(self): """For `print` and `pprint`""" return self.to_str() def __eq__(self, other): """Returns true if both objects are equal""" if not isinstance(other, V1CertificateSigningRequestSpec): return False return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" if not isinstance(other, V1CertificateSigningRequestSpec): return True return self.to_dict() != other.to_dict()
52.827703
1,945
0.675769
1,891
15,637
5.535167
0.14807
0.03363
0.098978
0.082259
0.756377
0.720455
0.710805
0.645362
0.619757
0.576001
0
0.019079
0.229072
15,637
295
1,946
53.00678
0.849191
0.628957
0
0.085938
1
0.015625
0.106873
0.028919
0
0
0
0
0
1
0.15625
false
0
0.03125
0
0.320313
0.015625
0
0
0
null
0
0
0
0
1
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
82be749c890892e164a6152eacaf8030caae848f
74
py
Python
python/testData/completion/percentStringDictWithDictLiteralArg.py
jnthn/intellij-community
8fa7c8a3ace62400c838e0d5926a7be106aa8557
[ "Apache-2.0" ]
2
2019-04-28T07:48:50.000Z
2020-12-11T14:18:08.000Z
python/testData/completion/percentStringDictWithDictLiteralArg.py
Cyril-lamirand/intellij-community
60ab6c61b82fc761dd68363eca7d9d69663cfa39
[ "Apache-2.0" ]
173
2018-07-05T13:59:39.000Z
2018-08-09T01:12:03.000Z
python/testData/completion/percentStringDictWithDictLiteralArg.py
Cyril-lamirand/intellij-community
60ab6c61b82fc761dd68363eca7d9d69663cfa39
[ "Apache-2.0" ]
2
2020-03-15T08:57:37.000Z
2020-04-07T04:48:14.000Z
print("Other string %(<caret>)d" % dict({'three': 3, 'one': 1, 'two': 2}))
74
74
0.540541
12
74
3.333333
1
0
0
0
0
0
0
0
0
0
0
0.046154
0.121622
74
1
74
74
0.569231
0
0
0
0
0
0.466667
0
0
0
0
0
0
1
0
true
0
0
0
0
1
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
1
0
4
82c5a0e0021a09b44c2ae6a502b49ca6f105ee8e
305
py
Python
Season 06 - Files in Python/Episode 11 - Python Relative Imports : Parent/Episode 11 - Python Relative Imports : Parent.py
Pythobit/Python-tutorial
b0743eaa9c237c3578131ead1b3f2c295f11b7ee
[ "MIT" ]
3
2021-02-19T18:33:00.000Z
2021-08-03T14:56:50.000Z
Season 06 - Files in Python/Episode 11 - Python Relative Imports : Parent/Episode 11 - Python Relative Imports : Parent.py
barawalojas/Python-tutorial
3f4b2b073e421888b3d62ff634658317d9abcb9b
[ "MIT" ]
1
2021-07-10T14:37:57.000Z
2021-07-20T09:51:39.000Z
Season 06 - Files in Python/Episode 11 - Python Relative Imports : Parent/Episode 11 - Python Relative Imports : Parent.py
barawalojas/Python-tutorial
3f4b2b073e421888b3d62ff634658317d9abcb9b
[ "MIT" ]
1
2021-08-02T05:39:38.000Z
2021-08-02T05:39:38.000Z
# Python relative imports : Parents """ if you want to import the parent, we need to use two dots instead of one as shown as below """ # `file_operations.py` from ..find import NotFoundError # ---^^ these two dots tells python to go the main import directory from where the project starts (i.e: utils)
27.727273
110
0.731148
50
305
4.44
0.78
0.063063
0
0
0
0
0
0
0
0
0
0
0.186885
305
10
111
30.5
0.895161
0.836066
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
4
82c8cfb6f9210a4aa63627b822b4e90b5749df7f
83
py
Python
run.py
SokKanaTorajd/flask-socmed-scraping
1c1c78001eced50a01601949d70ad0d9b1784f37
[ "MIT" ]
null
null
null
run.py
SokKanaTorajd/flask-socmed-scraping
1c1c78001eced50a01601949d70ad0d9b1784f37
[ "MIT" ]
null
null
null
run.py
SokKanaTorajd/flask-socmed-scraping
1c1c78001eced50a01601949d70ad0d9b1784f37
[ "MIT" ]
null
null
null
from app import app if __name__=='__main__': app.run('localhost', port='5000')
20.75
37
0.686747
12
83
4.083333
0.833333
0
0
0
0
0
0
0
0
0
0
0.056338
0.144578
83
4
37
20.75
0.633803
0
0
0
0
0
0.25
0
0
0
0
0
0
1
0
true
0
0.333333
0
0.333333
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
82d6ea6b73e9d0a28163bf0f1d1a03681d423e5d
191
py
Python
tests/processdef/test_module.py
asyncee/pycamunda
f4834d224ff99fcf80874efeaedf68a8a2efa926
[ "MIT" ]
null
null
null
tests/processdef/test_module.py
asyncee/pycamunda
f4834d224ff99fcf80874efeaedf68a8a2efa926
[ "MIT" ]
null
null
null
tests/processdef/test_module.py
asyncee/pycamunda
f4834d224ff99fcf80874efeaedf68a8a2efa926
[ "MIT" ]
null
null
null
# -*- coding: utf-8 -*- def test_all_contains_only_valid_names(): import pycamunda.processdef for name in pycamunda.processdef.__all__: getattr(pycamunda.processdef, name)
21.222222
45
0.717277
23
191
5.565217
0.73913
0.445313
0
0
0
0
0
0
0
0
0
0.006369
0.17801
191
8
46
23.875
0.808917
0.109948
0
0
0
0
0
0
0
0
0
0
0
1
0.25
false
0
0.25
0
0.5
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
0
0
0
4
82e95995186fc21444fe946377319792168dcfd2
170
py
Python
Chapter04/06_button_beep.py
PacktPublishing/MicroPython-Cookbook
ffd6aa15c303459570a89ba31b5bc734f05cb387
[ "MIT" ]
16
2019-07-01T16:24:22.000Z
2022-03-03T06:54:57.000Z
Chapter04/06_button_beep.py
ccwu0918/MicroPython-Cookbook
ffd6aa15c303459570a89ba31b5bc734f05cb387
[ "MIT" ]
null
null
null
Chapter04/06_button_beep.py
ccwu0918/MicroPython-Cookbook
ffd6aa15c303459570a89ba31b5bc734f05cb387
[ "MIT" ]
19
2019-04-17T08:30:12.000Z
2022-01-14T03:05:37.000Z
from adafruit_circuitplayground.express import cpx while True: if cpx.button_a: cpx.play_tone(500, 0.2) if cpx.button_b: cpx.play_tone(900, 0.2)
21.25
50
0.676471
28
170
3.928571
0.642857
0.090909
0.2
0
0
0
0
0
0
0
0
0.076336
0.229412
170
7
51
24.285714
0.763359
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.166667
0
0.166667
0
1
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
7d67d740863bf634451ed4ca19c9d87eee39569c
137
py
Python
jetbot/apps/remotecamera.py
frank26080115/jetbot
19354e5f8b2e3e4853f7b197b5e2714502822c3d
[ "MIT" ]
null
null
null
jetbot/apps/remotecamera.py
frank26080115/jetbot
19354e5f8b2e3e4853f7b197b5e2714502822c3d
[ "MIT" ]
null
null
null
jetbot/apps/remotecamera.py
frank26080115/jetbot
19354e5f8b2e3e4853f7b197b5e2714502822c3d
[ "MIT" ]
null
null
null
import jetbot.apps.remotecontrol as remotecontrol if __name__ == '__main__': remotecontrol.run(remotecontrol=False, cameracapture=True)
34.25
59
0.824818
15
137
7
0.8
0
0
0
0
0
0
0
0
0
0
0
0.080292
137
4
59
34.25
0.833333
0
0
0
0
0
0.057971
0
0
0
0
0
0
1
0
true
0
0.333333
0
0.333333
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
7d69bc1844b9c8dd5ea7945ef6e2323893ccd3b7
140
py
Python
reservations/apps.py
luisza/vcl_django
43d04f7951cb8805502e51f6f6360c7ec63215cc
[ "Apache-2.0" ]
null
null
null
reservations/apps.py
luisza/vcl_django
43d04f7951cb8805502e51f6f6360c7ec63215cc
[ "Apache-2.0" ]
null
null
null
reservations/apps.py
luisza/vcl_django
43d04f7951cb8805502e51f6f6360c7ec63215cc
[ "Apache-2.0" ]
null
null
null
from __future__ import unicode_literals from django.apps import AppConfig class ReservationsConfig(AppConfig): name = 'reservations'
17.5
39
0.807143
15
140
7.2
0.8
0
0
0
0
0
0
0
0
0
0
0
0.142857
140
7
40
20
0.9
0
0
0
0
0
0.085714
0
0
0
0
0
0
1
0
false
0
0.5
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
7d95dca6bf4f5e023729debbc9fdf7d458eac044
1,726
py
Python
project_euler/solutions/problem_8.py
cryvate/project-euler
6ed13880d7916c34554559f5f71662a863735eda
[ "MIT" ]
null
null
null
project_euler/solutions/problem_8.py
cryvate/project-euler
6ed13880d7916c34554559f5f71662a863735eda
[ "MIT" ]
9
2017-02-20T23:41:40.000Z
2017-04-16T15:36:54.000Z
project_euler/solutions/problem_8.py
cryvate/project-euler
6ed13880d7916c34554559f5f71662a863735eda
[ "MIT" ]
null
null
null
problem_string = '73167176531330624919225119674426574742355349194934'\ '96983520312774506326239578318016984801869478851843'\ '85861560789112949495459501737958331952853208805511'\ '12540698747158523863050715693290963295227443043557'\ '66896648950445244523161731856403098711121722383113'\ '62229893423380308135336276614282806444486645238749'\ '30358907296290491560440772390713810515859307960866'\ '70172427121883998797908792274921901699720888093776'\ '65727333001053367881220235421809751254540594752243'\ '52584907711670556013604839586446706324415722155397'\ '53697817977846174064955149290862569321978468622482'\ '83972241375657056057490261407972968652414535100474'\ '82166370484403199890008895243450658541227588666881'\ '16427171479924442928230863465674813919123162824586'\ '17866458359124566529476545682848912883142607690042'\ '24219022671055626321111109370544217506941658960408'\ '07198403850962455444362981230987879927244284909188'\ '84580156166097919133875499200524063689912560717606'\ '05886116467109405077541002256983155200055935729725'\ '71636269561882670428252483600823257530420752963450' def solve(string: str=problem_string, amount: int=13) -> int: highest = 0 for i in range(len(string) + 1 - amount): product = 1 for digit in string[i: i + amount]: product *= int(digit) if product >= highest: highest = product return highest
49.314286
70
0.685979
61
1,726
19.377049
0.655738
0.021997
0
0
0
0
0
0
0
0
0
0.787618
0.260718
1,726
34
71
50.764706
0.138715
0
0
0
0
0
0.579374
0.579374
0
0
0
0
0
1
0.034483
false
0
0
0
0.068966
0
0
0
1
null
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
7de4193d8bbbd38fd5ca58cc36ba0a91c62d5661
73
py
Python
src/FLANNEL/models/proposedModels/models/__init__.py
mannbiher/DeepLearningForHealthCareProject
4692031591bd88c489c9b905e7c340ac76a5366b
[ "MIT" ]
1
2021-09-15T04:59:05.000Z
2021-09-15T04:59:05.000Z
FLANNEL/FLANNEL/models/proposedModels/models/__init__.py
tlbybee/COVID-Classification
0c26a79ff1d2d79cb84b5e155dc611aef1549fe2
[ "MIT" ]
14
2021-05-10T18:00:58.000Z
2021-05-12T00:29:41.000Z
FLANNEL/FLANNEL/models/proposedModels/models/__init__.py
tlbybee/COVID-Classification
0c26a79ff1d2d79cb84b5e155dc611aef1549fe2
[ "MIT" ]
null
null
null
from __future__ import absolute_import from .ensemble_learning import *
18.25
38
0.849315
9
73
6.222222
0.666667
0
0
0
0
0
0
0
0
0
0
0
0.123288
73
3
39
24.333333
0.875
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
7deb9918d619ecb68270313f484a2d49d74e88c4
260
py
Python
emu/rom.py
en0/emu
3891184a17e8f827acba48f523f270842a1dc025
[ "MIT" ]
null
null
null
emu/rom.py
en0/emu
3891184a17e8f827acba48f523f270842a1dc025
[ "MIT" ]
null
null
null
emu/rom.py
en0/emu
3891184a17e8f827acba48f523f270842a1dc025
[ "MIT" ]
null
null
null
from typing import List from emu.contract import IRom class Rom(IRom): def __init__(self, data: List[int]): self._data = data def get(self, offset) -> int: ## TODO: Deal with memory reference error return self._data[offset]
20
49
0.646154
36
260
4.5
0.638889
0.148148
0
0
0
0
0
0
0
0
0
0
0.257692
260
12
50
21.666667
0.839378
0.146154
0
0
0
0
0
0
0
0
0
0.083333
0
1
0.285714
false
0
0.285714
0.142857
0.857143
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
0
1
0
0
0
1
1
0
0
4
8150ed23810d4da1debf503e729c4f2fe85b9f0b
178
py
Python
strings_12/check_if_a_string_has_unique_characters.py
njoroge33/py_learn
6ad55f37789045bc5c03f3dd668cf1ea497f4e84
[ "MIT" ]
null
null
null
strings_12/check_if_a_string_has_unique_characters.py
njoroge33/py_learn
6ad55f37789045bc5c03f3dd668cf1ea497f4e84
[ "MIT" ]
2
2019-04-15T06:29:55.000Z
2019-04-19T17:34:32.000Z
strings_12/check_if_a_string_has_unique_characters.py
njoroge33/py_learn
6ad55f37789045bc5c03f3dd668cf1ea497f4e84
[ "MIT" ]
1
2019-11-19T04:51:18.000Z
2019-11-19T04:51:18.000Z
# Write a program to check if a string has unique characters or not (ignore case) # for more info on this quiz, go to this url: http://www.programmr.com/unique-characters-string
89
95
0.764045
32
178
4.25
0.8125
0.235294
0
0
0
0
0
0
0
0
0
0
0.157303
178
2
95
89
0.906667
0.977528
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
0
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
816e2644ad859b97c4291394ada2d8f272c4c59e
512
py
Python
snorkel/slicing/__init__.py
melonwater211/snorkel
c5d00629e087130d1946bb6a85c58827790af425
[ "Apache-2.0" ]
2,906
2016-07-12T11:11:21.000Z
2019-08-12T20:38:19.000Z
snorkel/slicing/__init__.py
melonwater211/snorkel
c5d00629e087130d1946bb6a85c58827790af425
[ "Apache-2.0" ]
1,080
2016-07-12T21:07:22.000Z
2019-08-12T19:33:54.000Z
snorkel/slicing/__init__.py
melonwater211/snorkel
c5d00629e087130d1946bb6a85c58827790af425
[ "Apache-2.0" ]
609
2016-07-13T16:03:55.000Z
2019-08-08T17:47:54.000Z
"""Programmatic data set slicing: SF creation, monitoring utilities, and representation learning for slices.""" from .apply.core import PandasSFApplier, SFApplier # noqa: F401 from .modules.slice_combiner import SliceCombinerModule # noqa: F401 from .monitor import slice_dataframe # noqa: F401 from .sf.core import SlicingFunction, slicing_function # noqa: F401 from .sliceaware_classifier import SliceAwareClassifier # noqa: F401 from .utils import add_slice_labels, convert_to_slice_tasks # noqa: F401
56.888889
111
0.806641
64
512
6.3125
0.59375
0.118812
0.148515
0
0
0
0
0
0
0
0
0.040268
0.126953
512
8
112
64
0.863535
0.335938
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
4
81781c836820c9d47a64d7680224f6eaa55b1ff2
2,506
py
Python
tests/numbers_test.py
uceul/arabic-tacotron-tts
289ff54f91b77b0a352313bd62b5c4418c23786d
[ "MIT" ]
92
2018-10-14T14:33:52.000Z
2022-03-04T08:54:12.000Z
tests/numbers_test.py
CODE-BR3AKER/arabic-tacotron-tts
7e0f35389ae30a6329cf659f46749483be2917e6
[ "MIT" ]
17
2019-03-04T09:05:15.000Z
2022-02-16T08:41:49.000Z
tests/numbers_test.py
CODE-BR3AKER/arabic-tacotron-tts
7e0f35389ae30a6329cf659f46749483be2917e6
[ "MIT" ]
41
2018-10-31T13:41:33.000Z
2022-03-01T14:39:48.000Z
# from text.numbers import normalize_numbers # def test_normalize_numbers(): # assert normalize_numbers('1') == 'one' # assert normalize_numbers('15') == 'fifteen' # assert normalize_numbers('24') == 'twenty-four' # assert normalize_numbers('100') == 'one hundred' # assert normalize_numbers('101') == 'one hundred one' # assert normalize_numbers('456') == 'four hundred fifty-six' # assert normalize_numbers('1000') == 'one thousand' # assert normalize_numbers('1800') == 'eighteen hundred' # assert normalize_numbers('2,000') == 'two thousand' # assert normalize_numbers('3000') == 'three thousand' # assert normalize_numbers('18000') == 'eighteen thousand' # assert normalize_numbers('24,000') == 'twenty-four thousand' # assert normalize_numbers('124,001') == 'one hundred twenty-four thousand one' # assert normalize_numbers('6.4 sec') == 'six point four sec' # def test_normalize_ordinals(): # assert normalize_numbers('1st') == 'first' # assert normalize_numbers('2nd') == 'second' # assert normalize_numbers('9th') == 'ninth' # assert normalize_numbers('243rd place') == 'two hundred and forty-third place' # def test_normalize_dates(): # assert normalize_numbers('1400') == 'fourteen hundred' # assert normalize_numbers('1901') == 'nineteen oh one' # assert normalize_numbers('1999') == 'nineteen ninety-nine' # assert normalize_numbers('2000') == 'two thousand' # assert normalize_numbers('2004') == 'two thousand four' # assert normalize_numbers('2010') == 'twenty ten' # assert normalize_numbers('2012') == 'twenty twelve' # assert normalize_numbers('2025') == 'twenty twenty-five' # assert normalize_numbers('September 11, 2001') == 'September eleven, two thousand one' # assert normalize_numbers('July 26, 1984.') == 'July twenty-six, nineteen eighty-four.' # def test_normalize_money(): # assert normalize_numbers('$0.00') == 'zero dollars' # assert normalize_numbers('$1') == 'one dollar' # assert normalize_numbers('$10') == 'ten dollars' # assert normalize_numbers('$.01') == 'one cent' # assert normalize_numbers('$0.25') == 'twenty-five cents' # assert normalize_numbers('$5.00') == 'five dollars' # assert normalize_numbers('$5.01') == 'five dollars, one cent' # assert normalize_numbers('$135.99.') == 'one hundred thirty-five dollars, ninety-nine cents.' # assert normalize_numbers('$40,000') == 'forty thousand dollars' # assert normalize_numbers('for £2500!') == 'for twenty-five hundred pounds!'
48.192308
97
0.69593
301
2,506
5.641196
0.312292
0.376914
0.492344
0.106007
0.142521
0
0
0
0
0
0
0.06
0.142059
2,506
51
98
49.137255
0.729302
0.962091
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
0
0
0
null
1
1
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
4
81784e4f0bd41fecd1f51541f1434f7387ab6624
79
py
Python
app.py
davidedelpapa/pydevenv
de3524f0a3d3a62dffd54e5154f02d1d6ec3046e
[ "Unlicense" ]
null
null
null
app.py
davidedelpapa/pydevenv
de3524f0a3d3a62dffd54e5154f02d1d6ec3046e
[ "Unlicense" ]
null
null
null
app.py
davidedelpapa/pydevenv
de3524f0a3d3a62dffd54e5154f02d1d6ec3046e
[ "Unlicense" ]
null
null
null
from app import hello if __name__ == "__main__": print(hello.say_hello())
15.8
28
0.696203
11
79
4.181818
0.818182
0
0
0
0
0
0
0
0
0
0
0
0.177215
79
4
29
19.75
0.707692
0
0
0
0
0
0.101266
0
0
0
0
0
0
1
0
true
0
0.333333
0
0.333333
0.333333
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
0
0
0
4
8198641d39ad66b90f4a88788716ab2ed2e605f0
94
py
Python
codes_auto/277.find-the-celebrity.py
smartmark-pro/leetcode_record
6504b733d892a705571eb4eac836fb10e94e56db
[ "MIT" ]
null
null
null
codes_auto/277.find-the-celebrity.py
smartmark-pro/leetcode_record
6504b733d892a705571eb4eac836fb10e94e56db
[ "MIT" ]
null
null
null
codes_auto/277.find-the-celebrity.py
smartmark-pro/leetcode_record
6504b733d892a705571eb4eac836fb10e94e56db
[ "MIT" ]
null
null
null
# # @lc app=leetcode.cn id=277 lang=python3 # # [277] find-the-celebrity # None # @lc code=end
13.428571
41
0.670213
16
94
3.9375
0.875
0
0
0
0
0
0
0
0
0
0
0.0875
0.148936
94
7
42
13.428571
0.7
0.819149
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0
0
0
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
819a058ae7f0331c6ea996860526d280aceac964
453
py
Python
run.py
StefanoGitHub/SampleApp
333c4ea8b3ec504ea2ebefe27e7ceeab49fccf0e
[ "MIT" ]
null
null
null
run.py
StefanoGitHub/SampleApp
333c4ea8b3ec504ea2ebefe27e7ceeab49fccf0e
[ "MIT" ]
null
null
null
run.py
StefanoGitHub/SampleApp
333c4ea8b3ec504ea2ebefe27e7ceeab49fccf0e
[ "MIT" ]
null
null
null
from samplesapp import app import os app.run(debug = True) # ------------------- # to run on Heroku # - create project: # $ heroku # - install the GrapheneDB add-on: # $ heroku addons:add graphenedb:chalk # - create Procfile with "web: python run.py" # ------------------- # app.secret_key = os.urandom(24) # port = int(os.environ.get('PORT', 5000)) # get PORT from Heroku server # app.run(host='0.0.0.0', port=port, debug = True)
25.166667
73
0.596026
63
453
4.269841
0.571429
0.022305
0.022305
0
0
0
0
0
0
0
0
0.027322
0.192053
453
17
74
26.647059
0.70765
0.810155
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.666667
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
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
4
81ab2d2215bd22a35b0ad1b78fdcea9c43dd58f7
3,453
py
Python
quidel/tests/test_geo_maps.py
benjaminysmith/covidcast-indicators
b1474cd68a1497166fefe4beffd4d5ff867b9a61
[ "MIT" ]
null
null
null
quidel/tests/test_geo_maps.py
benjaminysmith/covidcast-indicators
b1474cd68a1497166fefe4beffd4d5ff867b9a61
[ "MIT" ]
null
null
null
quidel/tests/test_geo_maps.py
benjaminysmith/covidcast-indicators
b1474cd68a1497166fefe4beffd4d5ff867b9a61
[ "MIT" ]
null
null
null
import pytest from os.path import join import pandas as pd import numpy as np from delphi_quidel.geo_maps import geo_map map_df = pd.read_csv( join("../static", "fips_prop_pop.csv"), dtype={"fips": int} ) class TestGeoMap: def test_county(self): df = pd.DataFrame( { "zip": [1607, 1740, 98661, 76010, 76012, 76016], "timestamp": ["2020-06-15", "2020-06-15", "2020-06-15", "2020-06-15", "2020-06-15", "2020-06-15"], "totalTest": [100, 50, 200, 200, 250, 500], "positiveTest": [10, 8, 15, 5, 20, 50], } ) new_df, res_key = geo_map("county", df, map_df) assert res_key == 'fips' assert set(new_df["fips"].values) == set(['25027', '53011', '48439']) assert set(new_df["timestamp"].values) == set(df["timestamp"].values) assert set(new_df["totalTest"].values) == set([150, 200, 950]) assert set(new_df["positiveTest"].values) == set([18, 15, 75]) def test_state(self): df = pd.DataFrame( { "zip": [1607, 1740, 98661, 76010, 76012, 76016], "timestamp": ["2020-06-15", "2020-06-15", "2020-06-15", "2020-06-15", "2020-06-15", "2020-06-15"], "totalTest": [100, 50, 200, 200, 250, 500], "positiveTest": [10, 8, 15, 5, 20, 50], } ) new_df = geo_map("state", df, map_df) assert set(new_df["state_id"].values) == set(['ma', 'tx', 'wa']) assert set(new_df["timestamp"].values) == set(df["timestamp"].values) assert set(new_df["totalTest"].values) == set([150, 200, 950]) assert set(new_df["positiveTest"].values) == set([18, 15, 75]) def test_hrr(self): df = pd.DataFrame( { "zip": [1607, 98661, 76010, 76012, 74435, 74936], "timestamp": ["2020-06-15", "2020-06-15", "2020-06-15", "2020-06-15", "2020-06-15", "2020-06-15"], "totalTest": [100, 50, 200, 200, 250, 500], "positiveTest": [10, 8, 15, 5, 20, 50], } ) new_df, res_key = geo_map("hrr", df, map_df) assert set(new_df["hrrnum"].values) == set([16, 231, 340, 344, 394]) assert set(new_df["timestamp"].values) == set(df["timestamp"].values) assert set(new_df["totalTest"].values) == set([500, 100, 250, 50, 400]) assert set(new_df["positiveTest"].values) == set([50, 10, 20, 8, 20]) def test_msa(self): df = pd.DataFrame( { "zip": [1607, 73716, 73719, 76010, 74435, 74936], "timestamp": ["2020-06-15", "2020-06-15", "2020-06-15", "2020-06-15", "2020-06-15", "2020-06-15"], "totalTest": [100, 50, 200, 200, 250, 500], "positiveTest": [10, 8, 15, 5, 20, 50], } ) new_df, res_key = geo_map("msa", df, map_df) assert res_key == 'cbsa_id' assert set(new_df["cbsa_id"].values) == set(['19100', '22900', '49340']) assert set(new_df["timestamp"].values) == set(df["timestamp"].values) assert set(new_df["totalTest"].values) == set([200, 750, 100]) assert set(new_df["positiveTest"].values) == set([5, 70, 10])
36.734043
80
0.494063
442
3,453
3.753394
0.205882
0.086799
0.115732
0.144665
0.740205
0.740205
0.688366
0.620856
0.620856
0.620856
0
0.223785
0.320591
3,453
93
81
37.129032
0.483376
0
0
0.422535
0
0
0.187373
0
0
0
0
0
0.253521
1
0.056338
false
0
0.070423
0
0.140845
0
0
0
0
null
0
0
0
0
1
0
0
0
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
81b32038acbd8abc7d535cbcb5a8d1ee573a0145
39
py
Python
speid/commands/__init__.py
OsvaldoRino/speid
b4725bdee4abc019d4c2de4517f67a28f18c91ab
[ "MIT" ]
22
2019-08-23T03:17:42.000Z
2022-03-17T21:28:06.000Z
speid/commands/__init__.py
cuenca-mx/speid
157a6f9a81e4f7a3a93765ebff940a01adf4c93a
[ "MIT" ]
268
2018-09-24T15:13:10.000Z
2022-03-30T17:06:39.000Z
speid/commands/__init__.py
OsvaldoRino/speid
b4725bdee4abc019d4c2de4517f67a28f18c91ab
[ "MIT" ]
8
2019-09-22T03:41:11.000Z
2022-01-24T22:16:51.000Z
__all__ = ['spei'] from . import spei
9.75
18
0.641026
5
39
4.2
0.8
0
0
0
0
0
0
0
0
0
0
0
0.205128
39
3
19
13
0.677419
0
0
0
0
0
0.102564
0
0
0
0
0
0
1
0
false
0
0.5
0
0.5
0
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
4
81c04b1a1de1c2ae655428ad10fdeae82109511f
224
py
Python
api/urls.py
caocmai/renting-out-space-v2
6a61b48cd3514e0fc6e287fb58e0709befdf6fbe
[ "MIT" ]
1
2019-12-14T03:08:56.000Z
2019-12-14T03:08:56.000Z
api/urls.py
caocmai/renting-out-space-v2
6a61b48cd3514e0fc6e287fb58e0709befdf6fbe
[ "MIT" ]
7
2019-12-17T21:26:30.000Z
2021-06-10T17:59:56.000Z
api/urls.py
caocmai/renting-out-space-v2
6a61b48cd3514e0fc6e287fb58e0709befdf6fbe
[ "MIT" ]
null
null
null
from django.urls import path from api.views import ListingList, ListingDetail urlpatterns = [ path('', ListingList.as_view(), name='listing_list'), path('<int:pk>', ListingDetail.as_view(), name='listing_detail') ]
28
68
0.723214
28
224
5.642857
0.642857
0.075949
0.126582
0.21519
0
0
0
0
0
0
0
0
0.125
224
8
69
28
0.806122
0
0
0
0
0
0.151111
0
0
0
0
0
0
1
0
false
0
0.333333
0
0.333333
0
1
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
4
c4cb513e73cd403691c8937af301626a58a084c6
109
py
Python
Python-Scripts/clock3/boot.py
j1fvandenbosch/Code-WorkSpace-Storage
939fdb864fd0df497ecb726cda5c1baca69c2da1
[ "MIT" ]
null
null
null
Python-Scripts/clock3/boot.py
j1fvandenbosch/Code-WorkSpace-Storage
939fdb864fd0df497ecb726cda5c1baca69c2da1
[ "MIT" ]
null
null
null
Python-Scripts/clock3/boot.py
j1fvandenbosch/Code-WorkSpace-Storage
939fdb864fd0df497ecb726cda5c1baca69c2da1
[ "MIT" ]
null
null
null
# This file is executed on every boot (including wake-boot from deepsleep) # notify print('RUN: boot.py')
15.571429
74
0.724771
17
109
4.647059
0.882353
0
0
0
0
0
0
0
0
0
0
0
0.174312
109
6
75
18.166667
0.877778
0.724771
0
0
0
0
0.48
0
0
0
0
0
0
1
0
true
0
0
0
0
1
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
1
0
4
c4d000b5bde40b8bd2740ae001a5e81af4a9800e
395
py
Python
nfv/nfv-vim/nfv_vim/api/controllers/v1/orchestration/sw_update/__init__.py
SidneyAn/nfv
5f0262a5b6ea4be59f977b9c587c483cbe0e373d
[ "Apache-2.0" ]
null
null
null
nfv/nfv-vim/nfv_vim/api/controllers/v1/orchestration/sw_update/__init__.py
SidneyAn/nfv
5f0262a5b6ea4be59f977b9c587c483cbe0e373d
[ "Apache-2.0" ]
null
null
null
nfv/nfv-vim/nfv_vim/api/controllers/v1/orchestration/sw_update/__init__.py
SidneyAn/nfv
5f0262a5b6ea4be59f977b9c587c483cbe0e373d
[ "Apache-2.0" ]
null
null
null
# # Copyright (c) 2015-2020 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # from nfv_vim.api.controllers.v1.orchestration.sw_update._fw_update import FwUpdateAPI # noqa: F401 from nfv_vim.api.controllers.v1.orchestration.sw_update._sw_patch import SwPatchAPI # noqa: F401 from nfv_vim.api.controllers.v1.orchestration.sw_update._sw_upgrade import SwUpgradeAPI # noqa: F401
43.888889
101
0.805063
59
395
5.186441
0.542373
0.068627
0.098039
0.127451
0.526144
0.526144
0.526144
0.526144
0.526144
0.372549
0
0.061625
0.096203
395
8
102
49.375
0.795518
0.296203
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
1
0
1
0
0
4
c4d7ba41de4557668a52513c0b91db663d375112
392
py
Python
prob_mbrl/models/activations.py
joshholla/prob_mbrl
f905c5440fed41b8f36e7b2f3f7c340d3f0eb47a
[ "MIT" ]
null
null
null
prob_mbrl/models/activations.py
joshholla/prob_mbrl
f905c5440fed41b8f36e7b2f3f7c340d3f0eb47a
[ "MIT" ]
null
null
null
prob_mbrl/models/activations.py
joshholla/prob_mbrl
f905c5440fed41b8f36e7b2f3f7c340d3f0eb47a
[ "MIT" ]
null
null
null
import torch class Swish(torch.nn.Module): def forward(self, x): return x*x.sigmoid() class Sin(torch.nn.Module): def forward(self, x): return x.sin() class SinLU(torch.nn.Module): def __init__(self): super(SinLU, self).__init__() self.thr = torch.nn.Threshold(0, 0) def forward(self, x): return self.thr(x) - self.thr(-x).sin()
18.666667
47
0.59949
58
392
3.913793
0.327586
0.123348
0.171806
0.211454
0.400881
0.30837
0.30837
0.30837
0.30837
0
0
0.006757
0.244898
392
20
48
19.6
0.760135
0
0
0.230769
0
0
0
0
0
0
0
0
0
1
0.307692
false
0
0.076923
0.230769
0.846154
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
1
1
0
0
4
c4f4b9c2e114b1c596fa1c525fc7bfe965973a20
76
py
Python
wikipedia/__init__.py
davidedmundson/Wikipedia
0b6c67d152e1a4a2c28d9793dda674213b0071d8
[ "MIT" ]
1
2020-05-06T08:17:23.000Z
2020-05-06T08:17:23.000Z
wikipedia/__init__.py
jhoelzl/Wikipedia
9d4459fd64ab6c0b93eb706292d827488532db0c
[ "MIT" ]
null
null
null
wikipedia/__init__.py
jhoelzl/Wikipedia
9d4459fd64ab6c0b93eb706292d827488532db0c
[ "MIT" ]
null
null
null
from .wikipedia import * from .exceptions import * __version__ = (1, 4, 1)
15.2
25
0.697368
10
76
4.9
0.7
0
0
0
0
0
0
0
0
0
0
0.048387
0.184211
76
4
26
19
0.741935
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0.666667
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
c4f6afe5594880aa007dbf35c572a4d620679427
88
py
Python
beacons/portal/__init__.py
rajatguptarg/beacons
cef2a135c7bb244413cf6d12d423e24ebb373741
[ "MIT" ]
1
2016-12-07T02:06:04.000Z
2016-12-07T02:06:04.000Z
beacons/portal/__init__.py
rajatguptarg/beacons
cef2a135c7bb244413cf6d12d423e24ebb373741
[ "MIT" ]
29
2015-12-15T09:10:17.000Z
2021-06-01T21:47:22.000Z
beacons/portal/__init__.py
rajatguptarg/beacons
cef2a135c7bb244413cf6d12d423e24ebb373741
[ "MIT" ]
4
2015-12-14T12:09:02.000Z
2015-12-30T09:28:18.000Z
import controller import models import view __all__ = ['controller', 'models', 'view']
14.666667
42
0.738636
10
88
6.1
0.5
0
0
0
0
0
0
0
0
0
0
0
0.136364
88
5
43
17.6
0.802632
0
0
0
0
0
0.227273
0
0
0
0
0
0
1
0
false
0
0.75
0
0.75
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
c4f72f80606845bdf0cdd3831f661192a30e6f6b
541
py
Python
conference/messages.py
zevaverbach/epcon
8352c030ee0d4197f559cdb58a54ee45c7a4471a
[ "BSD-2-Clause" ]
null
null
null
conference/messages.py
zevaverbach/epcon
8352c030ee0d4197f559cdb58a54ee45c7a4471a
[ "BSD-2-Clause" ]
null
null
null
conference/messages.py
zevaverbach/epcon
8352c030ee0d4197f559cdb58a54ee45c7a4471a
[ "BSD-2-Clause" ]
null
null
null
from django.contrib.messages.storage.cookie import CookieStorage from django.contrib.messages.storage.session import SessionStorage from django.contrib.messages.storage.fallback import FallbackStorage class CustomCookieStorage(CookieStorage): """ Storing messages in a different cookie to drop all preceeding messages. TODO umgelurgel: remove this after ep2019 and before ep2020 """ cookie_name = "ep-messages" class CustomFallbackStorage(FallbackStorage): storage_classes = (CustomCookieStorage, SessionStorage)
33.8125
75
0.802218
58
541
7.448276
0.603448
0.069444
0.118056
0.173611
0.222222
0
0
0
0
0
0
0.017094
0.134935
541
15
76
36.066667
0.905983
0.242144
0
0
0
0
0.028205
0
0
0
0
0.066667
0
1
0
false
0
0.428571
0
1
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
0
0
0
0
1
0
1
0
0
4
c4f8369243a28403eb502c8bab0dd7302190b846
140
py
Python
task8/SimpleDecorator.py
p0l0satik/pyprak
3f1f11bb622476e225db09e3dcc9d9ee6397b654
[ "Apache-2.0" ]
null
null
null
task8/SimpleDecorator.py
p0l0satik/pyprak
3f1f11bb622476e225db09e3dcc9d9ee6397b654
[ "Apache-2.0" ]
null
null
null
task8/SimpleDecorator.py
p0l0satik/pyprak
3f1f11bb622476e225db09e3dcc9d9ee6397b654
[ "Apache-2.0" ]
null
null
null
def nonify(func): def newAnB(*args, **arg): res = func(*args, **arg) return None if not res else res return newAnB
20
39
0.571429
20
140
4
0.6
0.175
0
0
0
0
0
0
0
0
0
0
0.307143
140
6
40
23.333333
0.824742
0
0
0
0
0
0
0
0
0
0
0
0
1
0.4
false
0
0
0
0.8
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
1
0
0
4
c4f9578c8b17129eb2e5ae870a17180dacf685b3
12,414
py
Python
build/ARM/python/swig/debug.py
Jakgn/gem5_test
0ba7cc5213cf513cf205af7fc995cf679ebc1a3f
[ "BSD-3-Clause" ]
null
null
null
build/ARM/python/swig/debug.py
Jakgn/gem5_test
0ba7cc5213cf513cf205af7fc995cf679ebc1a3f
[ "BSD-3-Clause" ]
null
null
null
build/ARM/python/swig/debug.py
Jakgn/gem5_test
0ba7cc5213cf513cf205af7fc995cf679ebc1a3f
[ "BSD-3-Clause" ]
null
null
null
# This file was automatically generated by SWIG (http://www.swig.org). # Version 2.0.11 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead. from sys import version_info if version_info >= (2,6,0): def swig_import_helper(): from os.path import dirname import imp fp = None try: fp, pathname, description = imp.find_module('_debug', [dirname(__file__)]) except ImportError: import _debug return _debug if fp is not None: try: _mod = imp.load_module('_debug', fp, pathname, description) finally: fp.close() return _mod _debug = swig_import_helper() del swig_import_helper else: import _debug del version_info try: _swig_property = property except NameError: pass # Python < 2.2 doesn't have 'property'. def _swig_setattr_nondynamic(self,class_type,name,value,static=1): if (name == "thisown"): return self.this.own(value) if (name == "this"): if type(value).__name__ == 'SwigPyObject': self.__dict__[name] = value return method = class_type.__swig_setmethods__.get(name,None) if method: return method(self,value) if (not static): self.__dict__[name] = value else: raise AttributeError("You cannot add attributes to %s" % self) def _swig_setattr(self,class_type,name,value): return _swig_setattr_nondynamic(self,class_type,name,value,0) def _swig_getattr(self,class_type,name): if (name == "thisown"): return self.this.own() method = class_type.__swig_getmethods__.get(name,None) if method: return method(self) raise AttributeError(name) def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except: strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) try: _object = object _newclass = 1 except AttributeError: class _object : pass _newclass = 0 def _swig_setattr_nondynamic_method(set): def set_attr(self,name,value): if (name == "thisown"): return self.this.own(value) if hasattr(self,name) or (name == "this"): set(self,name,value) else: raise AttributeError("You cannot add attributes to %s" % self) return set_attr class SwigPyIterator(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract") __repr__ = _swig_repr __swig_destroy__ = _debug.delete_SwigPyIterator __del__ = lambda self : None; def value(self): return _debug.SwigPyIterator_value(self) def incr(self, n=1): return _debug.SwigPyIterator_incr(self, n) def decr(self, n=1): return _debug.SwigPyIterator_decr(self, n) def distance(self, *args): return _debug.SwigPyIterator_distance(self, *args) def equal(self, *args): return _debug.SwigPyIterator_equal(self, *args) def copy(self): return _debug.SwigPyIterator_copy(self) def next(self): return _debug.SwigPyIterator_next(self) def __next__(self): return _debug.SwigPyIterator___next__(self) def previous(self): return _debug.SwigPyIterator_previous(self) def advance(self, *args): return _debug.SwigPyIterator_advance(self, *args) def __eq__(self, *args): return _debug.SwigPyIterator___eq__(self, *args) def __ne__(self, *args): return _debug.SwigPyIterator___ne__(self, *args) def __iadd__(self, *args): return _debug.SwigPyIterator___iadd__(self, *args) def __isub__(self, *args): return _debug.SwigPyIterator___isub__(self, *args) def __add__(self, *args): return _debug.SwigPyIterator___add__(self, *args) def __sub__(self, *args): return _debug.SwigPyIterator___sub__(self, *args) def __iter__(self): return self SwigPyIterator_swigregister = _debug.SwigPyIterator_swigregister SwigPyIterator_swigregister(SwigPyIterator) def breakpoint(): return _debug.breakpoint() breakpoint = _debug.breakpoint class Flag(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract") __repr__ = _swig_repr __swig_destroy__ = _debug.delete_Flag __del__ = lambda self : None; def name(self): return _debug.Flag_name(self) def desc(self): return _debug.Flag_desc(self) def kids(self): return _debug.Flag_kids(self) def enable(self): return _debug.Flag_enable(self) def disable(self): return _debug.Flag_disable(self) def sync(self): return _debug.Flag_sync(self) Flag_swigregister = _debug.Flag_swigregister Flag_swigregister(Flag) class SimpleFlag(Flag): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self, *args): this = _debug.new_SimpleFlag(*args) try: self.this.append(this) except: self.this = this def status(self): return _debug.SimpleFlag_status(self) def __nonzero__(self): return _debug.SimpleFlag___nonzero__(self) __bool__ = __nonzero__ def enable(self): return _debug.SimpleFlag_enable(self) def disable(self): return _debug.SimpleFlag_disable(self) def sync(self): return _debug.SimpleFlag_sync(self) enableAll = staticmethod(_debug.SimpleFlag_enableAll) disableAll = staticmethod(_debug.SimpleFlag_disableAll) __swig_destroy__ = _debug.delete_SimpleFlag __del__ = lambda self : None; SimpleFlag_swigregister = _debug.SimpleFlag_swigregister SimpleFlag_swigregister(SimpleFlag) def SimpleFlag_enableAll(): return _debug.SimpleFlag_enableAll() SimpleFlag_enableAll = _debug.SimpleFlag_enableAll def SimpleFlag_disableAll(): return _debug.SimpleFlag_disableAll() SimpleFlag_disableAll = _debug.SimpleFlag_disableAll class CompoundFlag(Flag): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self, *args): this = _debug.new_CompoundFlag(*args) try: self.this.append(this) except: self.this = this def kids(self): return _debug.CompoundFlag_kids(self) def enable(self): return _debug.CompoundFlag_enable(self) def disable(self): return _debug.CompoundFlag_disable(self) __swig_destroy__ = _debug.delete_CompoundFlag __del__ = lambda self : None; CompoundFlag_swigregister = _debug.CompoundFlag_swigregister CompoundFlag_swigregister(CompoundFlag) def allFlags(): return _debug.allFlags() allFlags = _debug.allFlags def findFlag(*args): return _debug.findFlag(*args) findFlag = _debug.findFlag def changeFlag(*args): return _debug.changeFlag(*args) changeFlag = _debug.changeFlag def setDebugFlag(*args): return _debug.setDebugFlag(*args) setDebugFlag = _debug.setDebugFlag def clearDebugFlag(*args): return _debug.clearDebugFlag(*args) clearDebugFlag = _debug.clearDebugFlag def dumpDebugFlags(): return _debug.dumpDebugFlags() dumpDebugFlags = _debug.dumpDebugFlags class Cycles(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self, *args): this = _debug.new_Cycles(*args) try: self.this.append(this) except: self.this = this __swig_destroy__ = _debug.delete_Cycles __del__ = lambda self : None; Cycles_swigregister = _debug.Cycles_swigregister Cycles_swigregister(Cycles) cvar = _debug.cvar All = cvar.All MaxTick = cvar.MaxTick def romMicroPC(*args): return _debug.romMicroPC(*args) romMicroPC = _debug.romMicroPC def normalMicroPC(*args): return _debug.normalMicroPC(*args) normalMicroPC = _debug.normalMicroPC def isRomMicroPC(*args): return _debug.isRomMicroPC(*args) isRomMicroPC = _debug.isRomMicroPC class AtomicOpFunctor(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract") __repr__ = _swig_repr def __call__(self, *args): return _debug.AtomicOpFunctor___call__(self, *args) __swig_destroy__ = _debug.delete_AtomicOpFunctor __del__ = lambda self : None; AtomicOpFunctor_swigregister = _debug.AtomicOpFunctor_swigregister AtomicOpFunctor_swigregister(AtomicOpFunctor) MicroPCRomBit = cvar.MicroPCRomBit MaxAddr = cvar.MaxAddr InvalidThreadID = cvar.InvalidThreadID InvalidContextID = cvar.InvalidContextID InvalidPortID = cvar.InvalidPortID BigEndianByteOrder = _debug.BigEndianByteOrder LittleEndianByteOrder = _debug.LittleEndianByteOrder def schedBreak(*args): return _debug.schedBreak(*args) schedBreak = _debug.schedBreak def schedRelBreak(*args): return _debug.schedRelBreak(*args) schedRelBreak = _debug.schedRelBreak def breakAtKernelFunction(*args): return _debug.breakAtKernelFunction(*args) breakAtKernelFunction = _debug.breakAtKernelFunction def takeCheckpoint(*args): return _debug.takeCheckpoint(*args) takeCheckpoint = _debug.takeCheckpoint def eventqDump(): return _debug.eventqDump() eventqDump = _debug.eventqDump def getRemoteGDBPort(): return _debug.getRemoteGDBPort() getRemoteGDBPort = _debug.getRemoteGDBPort def setRemoteGDBPort(*args): return _debug.setRemoteGDBPort(*args) setRemoteGDBPort = _debug.setRemoteGDBPort class AllFlags(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def iterator(self): return _debug.AllFlags_iterator(self) def __iter__(self): return self.iterator() def __nonzero__(self): return _debug.AllFlags___nonzero__(self) def __bool__(self): return _debug.AllFlags___bool__(self) def __len__(self): return _debug.AllFlags___len__(self) def pop(self): return _debug.AllFlags_pop(self) def __getslice__(self, *args): return _debug.AllFlags___getslice__(self, *args) def __setslice__(self, *args): return _debug.AllFlags___setslice__(self, *args) def __delslice__(self, *args): return _debug.AllFlags___delslice__(self, *args) def __delitem__(self, *args): return _debug.AllFlags___delitem__(self, *args) def __getitem__(self, *args): return _debug.AllFlags___getitem__(self, *args) def __setitem__(self, *args): return _debug.AllFlags___setitem__(self, *args) def append(self, *args): return _debug.AllFlags_append(self, *args) def empty(self): return _debug.AllFlags_empty(self) def size(self): return _debug.AllFlags_size(self) def clear(self): return _debug.AllFlags_clear(self) def swap(self, *args): return _debug.AllFlags_swap(self, *args) def get_allocator(self): return _debug.AllFlags_get_allocator(self) def begin(self): return _debug.AllFlags_begin(self) def end(self): return _debug.AllFlags_end(self) def rbegin(self): return _debug.AllFlags_rbegin(self) def rend(self): return _debug.AllFlags_rend(self) def pop_back(self): return _debug.AllFlags_pop_back(self) def erase(self, *args): return _debug.AllFlags_erase(self, *args) def __init__(self, *args): this = _debug.new_AllFlags(*args) try: self.this.append(this) except: self.this = this def push_back(self, *args): return _debug.AllFlags_push_back(self, *args) def front(self): return _debug.AllFlags_front(self) def back(self): return _debug.AllFlags_back(self) def assign(self, *args): return _debug.AllFlags_assign(self, *args) def resize(self, *args): return _debug.AllFlags_resize(self, *args) def insert(self, *args): return _debug.AllFlags_insert(self, *args) def reserve(self, *args): return _debug.AllFlags_reserve(self, *args) def capacity(self): return _debug.AllFlags_capacity(self) __swig_destroy__ = _debug.delete_AllFlags __del__ = lambda self : None; AllFlags_swigregister = _debug.AllFlags_swigregister AllFlags_swigregister(AllFlags) def getAllFlagsVersion(): return _debug.getAllFlagsVersion() getAllFlagsVersion = _debug.getAllFlagsVersion def getAllFlags(): return _debug.getAllFlags() getAllFlags = _debug.getAllFlags
38.433437
107
0.736185
1,527
12,414
5.56647
0.134905
0.108706
0.063529
0.053647
0.350941
0.229882
0.222588
0.188235
0.169882
0.161176
0
0.001438
0.159497
12,414
322
108
38.552795
0.813207
0.018527
0
0.1875
1
0
0.032444
0
0
0
0
0
0
1
0.363971
false
0.007353
0.033088
0.316176
0.643382
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
1
0
0
0
1
1
0
0
4
c4fdf430fc37d16fc1d3491d6f7d28f6b875a20e
73
py
Python
Week1/main.py
EricCharnesky/CIS2001-Winter2021
a633e32026726f985eea1fe7dd0da3497fff45aa
[ "MIT" ]
3
2021-02-04T22:56:48.000Z
2021-07-17T05:47:24.000Z
Week1/main.py
EricCharnesky/CIS2001-Winter2021
a633e32026726f985eea1fe7dd0da3497fff45aa
[ "MIT" ]
null
null
null
Week1/main.py
EricCharnesky/CIS2001-Winter2021
a633e32026726f985eea1fe7dd0da3497fff45aa
[ "MIT" ]
1
2021-02-07T01:40:24.000Z
2021-02-07T01:40:24.000Z
print("Hello world!") print("Happy Thursday!") print("Is it Friday yet?")
24.333333
26
0.69863
11
73
4.636364
0.818182
0
0
0
0
0
0
0
0
0
0
0
0.09589
73
3
26
24.333333
0.772727
0
0
0
0
0
0.594595
0
0
0
0
0
0
1
0
true
0
0
0
0
1
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
1
0
4
f208dbb18a3510f0ca3284567a4ffb8d3bba06d2
1,614
py
Python
cana/datasets/bools.py
leonardogian/CANA
f070d6da5358f17f55eb80d6bc9185afaee91142
[ "MIT" ]
1
2021-01-08T22:04:05.000Z
2021-01-08T22:04:05.000Z
cana/datasets/bools.py
leonardogian/CANA
f070d6da5358f17f55eb80d6bc9185afaee91142
[ "MIT" ]
null
null
null
cana/datasets/bools.py
leonardogian/CANA
f070d6da5358f17f55eb80d6bc9185afaee91142
[ "MIT" ]
null
null
null
# -*- coding: utf-8 -*- """ Boolean Nodes ================================= Commonly used boolean node functions. """ # Copyright (C) 2017 by # Alex Gates <ajgates42@gmail.com> # Rion Brattig Correia <rionbr@gmail.com> # All rights reserved. # MIT license. from .. boolean_network import BooleanNode def AND(): """AND boolean node. .. code:: 00 : 0 01 : 0 10 : 0 11 : 1 """ return BooleanNode.from_output_list(outputs=[0,0,0,1], name="AND") def OR(): """OR boolean node. .. code:: 00 : 0 01 : 1 10 : 1 11 : 1 """ return BooleanNode.from_output_list(outputs=[0,1,1,1], name="OR") def XOR(): """XOR boolean node. .. code:: 00 : 0 01 : 1 10 : 1 11 : 0 """ return BooleanNode.from_output_list(outputs=[0,1,1,0], name="XOR") def COPYx1(): """COPY :math:`x_1` boolean node. .. code:: 00 : 0 01 : 0 10 : 1 11 : 1 """ return BooleanNode.from_output_list(outputs=[0,0,1,1], name="COPY x_1") def CONTRADICTION(): """Contradiction boolean node. .. code:: 00 : 0 01 : 0 10 : 0 11 : 0 """ return BooleanNode.from_output_list(outputs=[0,0,0,0], name="CONTRADICTION") def RULE90(): """RULE 90 celular automata node. .. code:: 000 : 0 001 : 1 010 : 0 011 : 1 100 : 1 101 : 0 110 : 1 111 : 0 """ return BooleanNode.from_output_list(outputs=[0,1,0,1,1,0,1,0], name="RULE 90") def RULE110(): """RULE 110 celular automata node. .. code:: 000 : 0 001 : 1 010 : 1 011 : 1 100 : 0 101 : 1 110 : 1 111 : 0 """ return BooleanNode.from_output_list(outputs=[0,1,1,1,0,1,1,0], name="RULE 110")
13.229508
80
0.574349
252
1,614
3.611111
0.261905
0.01978
0.161538
0.207692
0.574725
0.556044
0.556044
0.556044
0.532967
0.410989
0
0.150162
0.236679
1,614
121
81
13.338843
0.588474
0.658612
0
0
0
0
0.063953
0
0
0
0
0
0
1
0.466667
true
0
0.066667
0
1
0
0
0
0
null
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
1
0
0
0
1
0
0
4
f2114994260955ffe0107915cd7295768da1e94e
95
py
Python
symkalaweb/apps.py
geoffrey-p-morgan/symkala
4127232d10797a95f21b1693c50d5875ca778112
[ "Apache-2.0" ]
null
null
null
symkalaweb/apps.py
geoffrey-p-morgan/symkala
4127232d10797a95f21b1693c50d5875ca778112
[ "Apache-2.0" ]
null
null
null
symkalaweb/apps.py
geoffrey-p-morgan/symkala
4127232d10797a95f21b1693c50d5875ca778112
[ "Apache-2.0" ]
null
null
null
from django.apps import AppConfig class SymkalawebConfig(AppConfig): name = 'symkalaweb'
15.833333
34
0.768421
10
95
7.3
0.9
0
0
0
0
0
0
0
0
0
0
0
0.157895
95
5
35
19
0.9125
0
0
0
0
0
0.105263
0
0
0
0
0
0
1
0
false
0
0.333333
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
f215c08b53ffb2bfe859117ca6871a7d86290687
1,056
py
Python
openapi-python-client/test/test_task_identity_link_api.py
yanavasileva/camunda-bpm-examples
051f8f28c62845e68ce4059ab64264c5a0bdc009
[ "Apache-2.0" ]
null
null
null
openapi-python-client/test/test_task_identity_link_api.py
yanavasileva/camunda-bpm-examples
051f8f28c62845e68ce4059ab64264c5a0bdc009
[ "Apache-2.0" ]
null
null
null
openapi-python-client/test/test_task_identity_link_api.py
yanavasileva/camunda-bpm-examples
051f8f28c62845e68ce4059ab64264c5a0bdc009
[ "Apache-2.0" ]
null
null
null
# coding: utf-8 """ Camunda BPM REST API OpenApi Spec for Camunda BPM REST API. # noqa: E501 The version of the OpenAPI document: 7.13.0 Generated by: https://openapi-generator.tech """ from __future__ import absolute_import import unittest import openapi_client from openapi_client.api.task_identity_link_api import TaskIdentityLinkApi # noqa: E501 from openapi_client.rest import ApiException class TestTaskIdentityLinkApi(unittest.TestCase): """TaskIdentityLinkApi unit test stubs""" def setUp(self): self.api = openapi_client.api.task_identity_link_api.TaskIdentityLinkApi() # noqa: E501 def tearDown(self): pass def test_add_identity_link(self): """Test case for add_identity_link """ pass def test_delete_identity_link(self): """Test case for delete_identity_link """ pass def test_get_identity_links(self): """Test case for get_identity_links """ pass if __name__ == '__main__': unittest.main()
20.307692
96
0.683712
130
1,056
5.261538
0.415385
0.105263
0.048246
0.065789
0.248538
0.181287
0.102339
0
0
0
0
0.017327
0.234848
1,056
51
97
20.705882
0.829208
0.347538
0
0.222222
1
0
0.012442
0
0
0
0
0
0
1
0.277778
false
0.222222
0.277778
0
0.611111
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
1
0
1
0
0
1
0
0
4
1ef1664ffd5f5f954ca8d2fd63927bce83ce2b36
114
py
Python
app/domain/user.py
yntonfon/dashboard
287e7b2d895916102236243c1051da1e5ee3756e
[ "MIT" ]
null
null
null
app/domain/user.py
yntonfon/dashboard
287e7b2d895916102236243c1051da1e5ee3756e
[ "MIT" ]
null
null
null
app/domain/user.py
yntonfon/dashboard
287e7b2d895916102236243c1051da1e5ee3756e
[ "MIT" ]
null
null
null
class UserDomain: def is_active(self, user): return user.email_confirmed user_domain = UserDomain()
16.285714
35
0.710526
14
114
5.571429
0.785714
0
0
0
0
0
0
0
0
0
0
0
0.210526
114
6
36
19
0.866667
0
0
0
0
0
0
0
0
0
0
0
0
1
0.25
false
0
0
0.25
0.75
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
1
0
0
0
4
1efba0c5489c4a17513fea2dfa8a71c870307295
302
py
Python
gofri/lib/http/filter.py
ThomasKenyeres/Gofri
155fef1714ea71c35cf33dd926cad819e8cee042
[ "MIT" ]
null
null
null
gofri/lib/http/filter.py
ThomasKenyeres/Gofri
155fef1714ea71c35cf33dd926cad819e8cee042
[ "MIT" ]
null
null
null
gofri/lib/http/filter.py
ThomasKenyeres/Gofri
155fef1714ea71c35cf33dd926cad819e8cee042
[ "MIT" ]
null
null
null
FILTERS = [] ENDP_COUNT = 0 class Filter(object): def __init__(self): self.urls = [] self.filter_all = False self.order = 0 def filter(self, request, response): pass def _continue(self, request, response): return {"request": request, "response": response}
23.230769
57
0.615894
35
302
5.114286
0.542857
0.251397
0.212291
0
0
0
0
0
0
0
0
0.008969
0.261589
302
13
57
23.230769
0.793722
0
0
0
0
0
0.049505
0
0
0
0
0
0
1
0.3
false
0.1
0
0.1
0.5
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
1
0
1
0
0
0
0
0
4
48325abefe6fad99d15ced9146d6dd522657ff62
468
py
Python
courses/admin.py
Aga-Ma/django-projects-e-learning-portal
b565ded17947b54e96c73d249d6f9ad7a936ec7d
[ "MIT" ]
16
2020-03-27T12:43:58.000Z
2022-01-01T23:39:46.000Z
courses/admin.py
Aga-Ma/django-projects-e-learning-portal
b565ded17947b54e96c73d249d6f9ad7a936ec7d
[ "MIT" ]
9
2020-02-02T20:49:10.000Z
2021-09-22T17:38:21.000Z
courses/admin.py
Frank-hooder/elearn-educa
451aca1676836507cd5ca71d611ce9307872b348
[ "MIT" ]
16
2020-02-27T07:36:24.000Z
2021-09-08T08:35:42.000Z
from django.contrib import admin from courses.models import Course, Section, Question, Answer class CourseAdmin(admin.ModelAdmin): pass admin.site.register(Course, CourseAdmin) class SectionAdmin(admin.ModelAdmin): pass admin.site.register(Section, SectionAdmin) class QuestionAdmin(admin.ModelAdmin): pass admin.site.register(Question, QuestionAdmin) class AnswerAdmin(admin.ModelAdmin): pass admin.site.register(Answer, AnswerAdmin)
14.625
60
0.775641
53
468
6.849057
0.377358
0.165289
0.209366
0.264463
0.396694
0.396694
0
0
0
0
0
0
0.136752
468
31
61
15.096774
0.898515
0
0
0.285714
0
0
0
0
0
0
0
0
0
1
0
true
0.285714
0.142857
0
0.428571
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
1
1
0
0
0
0
0
4
483980be8f7f9ed04d1ac0186be767db5ed19156
10,779
py
Python
corehq/pillows/mappings/reportcase_mapping.py
dslowikowski/commcare-hq
ad8885cf8dab69dc85cb64f37aeaf06106124797
[ "BSD-3-Clause" ]
1
2017-02-10T03:14:51.000Z
2017-02-10T03:14:51.000Z
corehq/pillows/mappings/reportcase_mapping.py
dslowikowski/commcare-hq
ad8885cf8dab69dc85cb64f37aeaf06106124797
[ "BSD-3-Clause" ]
1
2022-03-12T01:03:25.000Z
2022-03-12T01:03:25.000Z
corehq/pillows/mappings/reportcase_mapping.py
johan--/commcare-hq
86ee99c54f55ee94e4c8f2f6f30fc44e10e69ebd
[ "BSD-3-Clause" ]
null
null
null
REPORT_CASE_INDEX="report_cases_czei39du507m9mmpqk3y01x72a3ux4p0" REPORT_CASE_MAPPING={'_meta': {'comment': '2013-11-05 dmyung', 'created': None}, 'date_detection': False, 'date_formats': ['yyyy-MM-dd', "yyyy-MM-dd'T'HH:mm:ssZZ", "yyyy-MM-dd'T'HH:mm:ss.SSSSSS", "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'", "yyyy-MM-dd'T'HH:mm:ss'Z'", "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ssZZ'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSSZZ", "yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd' 'HH:mm:ss", "yyyy-MM-dd' 'HH:mm:ss.SSSSSS", "mm/dd/yy' 'HH:mm:ss"], 'dynamic': True, 'dynamic_templates': [{'everything_else': {'mapping': {'{name}': {'index': 'not_analyzed', 'type': 'string'}}, 'match': '*', 'match_mapping_type': 'string'}}], 'ignore_malformed': True, 'properties': {'actions': {'dynamic': True, 'properties': {'action_type': {'type': 'string'}, 'attachments': {'dynamic': False, 'properties': {'attachment_from': {'type': 'string'}, 'attachment_name': {'type': 'string'}, 'attachment_properties': {'dynamic': False, 'type': 'object'}, 'attachment_size': {'type': 'long'}, 'attachment_src': {'type': 'string'}, 'doc_type': {'index': 'not_analyzed', 'type': 'string'}, 'identifier': {'type': 'string'}, 'server_md5': {'type': 'string'}, 'server_mime': {'type': 'string'}}, 'type': 'object'}, 'date': {'format': "yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'doc_type': {'index': 'not_analyzed', 'type': 'string'}, 'indices': {'dynamic': False, 'properties': {'doc_type': {'index': 'not_analyzed', 'type': 'string'}, 'identifier': {'type': 'string'}, 'referenced_id': {'type': 'string'}, 'referenced_type': {'type': 'string'}}, 'type': 'object'}, 'server_date': {'format': "yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'sync_log_id': {'type': 'string'}, 'updated_known_properties': {'dynamic': False, 'type': 'object'}, 'updated_unknown_properties': {'dynamic': False, 'type': 'object'}, 'user_id': {'type': 'string'}, 'xform_id': {'type': 'string'}, 'xform_name': {'type': 'string'}, 'xform_xmlns': {'type': 'string'}}, 'type': 'nested'}, 'case_attachments': {'dynamic': True, 'properties': {'attachment_from': {'type': 'string'}, 'attachment_name': {'type': 'string'}, 'attachment_properties': {'dynamic': False, 'type': 'object'}, 'attachment_size': {'type': 'long'}, 'attachment_src': {'type': 'string'}, 'doc_type': {'index': 'not_analyzed', 'type': 'string'}, 'identifier': {'type': 'string'}, 'server_md5': {'type': 'string'}, 'server_mime': {'type': 'string'}}, 'type': 'object'}, 'closed': {'type': 'boolean'}, 'closed_by': {'type': 'string'}, 'closed_on': {'format': "yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'computed_': {'enabled': False, 'type': 'object'}, 'computed_modified_on_': {'format': "yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'doc_type': {'index': 'not_analyzed', 'type': 'string'}, 'domain': {'fields': {'domain': {'index': 'analyzed', 'type': 'string'}, 'exact': {'index': 'not_analyzed', 'type': 'string'}}, 'type': 'multi_field'}, 'export_tag': {'type': 'string'}, 'external_id': {'fields': {'exact': {'index': 'not_analyzed', 'type': 'string'}, 'external_id': {'index': 'analyzed', 'type': 'string'}}, 'type': 'multi_field'}, 'indices': {'dynamic': True, 'properties': {'doc_type': {'index': 'not_analyzed', 'type': 'string'}, 'identifier': {'type': 'string'}, 'referenced_id': {'type': 'string'}, 'referenced_type': {'type': 'string'}}, 'type': 'object'}, 'initial_processing_complete': {'type': 'boolean'}, 'location_id': {'type': 'string'}, 'modified_on': {'format': "yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'name': {'fields': {'exact': {'index': 'not_analyzed', 'type': 'string'}, 'name': {'index': 'analyzed', 'type': 'string'}}, 'type': 'multi_field'}, 'opened_by': {'type': 'string'}, 'opened_on': {'format': "yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'owner_id': {'type': 'string'}, 'referrals': {'enabled': False, 'type': 'object'}, 'server_modified_on': {'format': "yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ssZZ||yyyy-MM-dd'T'HH:mm:ss.SSSSSS||yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ssZZ'Z'||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss||yyyy-MM-dd' 'HH:mm:ss.SSSSSS||mm/dd/yy' 'HH:mm:ss", 'type': 'date'}, 'type': {'fields': {'exact': {'index': 'not_analyzed', 'type': 'string'}, 'type': {'index': 'analyzed', 'type': 'string'}}, 'type': 'multi_field'}, 'user_id': {'type': 'string'}, 'version': {'type': 'string'}, 'xform_ids': {'index': 'not_analyzed', 'type': 'string'}}}
86.232
374
0.358568
1,070
10,779
3.530841
0.088785
0.101641
0.186342
0.152462
0.772102
0.741398
0.738751
0.669666
0.669666
0.669666
0
0.004149
0.463308
10,779
124
375
86.927419
0.64892
0
0
0.504065
0
0.056911
0.423787
0.224232
0
0
0
0
0
1
0
false
0
0
0
0
0
0
0
0
null
0
1
0
0
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
483e0d8854ea263e9f25056831763f830fcfe012
111
py
Python
Diena_1_4_thonny/enumerate2.py
edzya/Python_RTU_08_20
d2921d998c611c18328dd523daf976a27ce858c1
[ "MIT" ]
8
2020-08-31T16:10:54.000Z
2021-11-24T06:37:37.000Z
Diena_1_4_thonny/enumerate2.py
edzya/Python_RTU_08_20
d2921d998c611c18328dd523daf976a27ce858c1
[ "MIT" ]
8
2021-06-08T22:30:29.000Z
2022-03-12T00:48:55.000Z
Diena_1_4_thonny/enumerate2.py
edzya/Python_RTU_08_20
d2921d998c611c18328dd523daf976a27ce858c1
[ "MIT" ]
12
2020-09-28T17:06:52.000Z
2022-02-17T12:12:46.000Z
# enumerate my_food = "kartupelis" for i, c in enumerate(my_food,start=1001): print(f"Char no. {i} is {c}")
27.75
42
0.666667
20
111
3.6
0.75
0.305556
0.416667
0
0
0
0
0
0
0
0
0.043011
0.162162
111
4
43
27.75
0.731183
0.081081
0
0
0
0
0.287129
0
0
0
0
0
0
1
0
false
0
0
0
0
0.333333
1
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
48594f5f66274e4bd30689338227161e13bd7fc4
476
py
Python
weasyl/compat.py
sl1-1/weasyl
d4f6bf3e33b85a2289a451d95d5b90ff24f5d539
[ "Apache-2.0" ]
1
2019-02-15T04:21:48.000Z
2019-02-15T04:21:48.000Z
weasyl/compat.py
sl1-1/weasyl
d4f6bf3e33b85a2289a451d95d5b90ff24f5d539
[ "Apache-2.0" ]
254
2017-12-23T19:36:43.000Z
2020-04-14T21:46:13.000Z
weasyl/compat.py
greysteil/wzl-test
0f863b9e7c58e5861437618bd590126ca323140c
[ "Apache-2.0" ]
1
2017-12-23T18:42:16.000Z
2017-12-23T18:42:16.000Z
from __future__ import absolute_import import posixpath # TODO: Delete this. Use the real request. Need to replace 'path_for' in templates. class FakePyramidRequest(object): def resource_path(self, rsrc, *parts): if rsrc is not None: raise NotImplementedError("can't do resource_path for non-None resources", rsrc) return '/' + posixpath.join(*parts) def path_for(self, obj, *a, **kw): return obj.canonical_path(self, *a, **kw)
31.733333
92
0.686975
65
476
4.876923
0.676923
0.066246
0
0
0
0
0
0
0
0
0
0
0.210084
476
14
93
34
0.843085
0.170168
0
0
0
0
0.117048
0
0
0
0
0.071429
0
1
0.222222
false
0
0.222222
0.111111
0.777778
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
1
0
0
1
0
0
0
1
1
0
0
4
487ce1b31f73d849d4a7f3c9f344c4bb6e389873
165
py
Python
python/blazingdb/messages/blazingdb/protocol/io/DriverType.py
HubBucket-Team/blazingdb-protocol
bf3cdc83b60d30cecb6b906f11d8a194e73119c1
[ "Apache-2.0" ]
1
2019-08-13T17:17:54.000Z
2019-08-13T17:17:54.000Z
python/blazingdb/messages/blazingdb/protocol/io/DriverType.py
VonRosenchild/blazingdb-protocol
bf3cdc83b60d30cecb6b906f11d8a194e73119c1
[ "Apache-2.0" ]
null
null
null
python/blazingdb/messages/blazingdb/protocol/io/DriverType.py
VonRosenchild/blazingdb-protocol
bf3cdc83b60d30cecb6b906f11d8a194e73119c1
[ "Apache-2.0" ]
1
2019-08-13T17:17:59.000Z
2019-08-13T17:17:59.000Z
# automatically generated by the FlatBuffers compiler, do not modify # namespace: io class DriverType(object): UNDEFINED = 0 LIBHDFS = 1 LIBHDFS3 = 2
16.5
68
0.70303
20
165
5.8
1
0
0
0
0
0
0
0
0
0
0
0.031746
0.236364
165
9
69
18.333333
0.888889
0.484848
0
0
1
0
0
0
0
0
0
0
0
1
0
false
0
0
0
1
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
null
0
0
0
0
0
0
0
0
0
0
1
0
0
4
6f85723cc93c815030e867d7ac9c1b55b95976fd
653
py
Python
frontends/pytorch/test/builder/get_registered_ops.py
cathyzhyi/mlir-npcomp
79a3f639bfb449ba1409ff6dff161badf5a11b44
[ "Apache-2.0" ]
null
null
null
frontends/pytorch/test/builder/get_registered_ops.py
cathyzhyi/mlir-npcomp
79a3f639bfb449ba1409ff6dff161badf5a11b44
[ "Apache-2.0" ]
6
2020-10-21T18:18:10.000Z
2021-04-02T20:38:28.000Z
frontends/pytorch/test/builder/get_registered_ops.py
cathyzhyi/mlir-npcomp
79a3f639bfb449ba1409ff6dff161badf5a11b44
[ "Apache-2.0" ]
null
null
null
# -*- Python -*- # This file is licensed under a pytorch-style license # See frontends/pytorch/LICENSE for license information. # RUN: %PYTHON %s | FileCheck %s import _torch_mlir # This check is just for a built-in op that is unlikely to change (and is # otherwise insignificant). # CHECK: {'name': ('aten::mul', 'Tensor'), 'is_vararg': False, 'is_varret': False, 'is_mutable': False, 'arguments': [{'name': 'self', 'type': 'Tensor', 'pytype': 'Tensor'}, {'name': 'other', 'type': 'Tensor', 'pytype': 'Tensor'}], 'returns': [{'name': '', 'type': 'Tensor', 'pytype': 'Tensor'}]} print('\n\n'.join([repr(r) for r in _torch_mlir.get_registered_ops()]))
54.416667
296
0.656968
90
653
4.666667
0.6
0.071429
0.114286
0.157143
0
0
0
0
0
0
0
0
0.130168
653
11
297
59.363636
0.739437
0.834609
0
0
0
0
0.04
0
0
0
0
0
0
1
0
true
0
0.5
0
0.5
0.5
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
1
0
0
1
0
4
6fb1625fa6741440e2af98fac2a01648c2481bf0
121
py
Python
ee/clickhouse/sql/cohort.py
zegl/posthog
62846fd565e9eb6ff299bb81dd3b91f219bd0eeb
[ "MIT" ]
1
2021-11-13T15:47:23.000Z
2021-11-13T15:47:23.000Z
ee/clickhouse/sql/cohort.py
zegl/posthog
62846fd565e9eb6ff299bb81dd3b91f219bd0eeb
[ "MIT" ]
1
2022-03-20T12:09:26.000Z
2022-03-20T12:09:26.000Z
ee/clickhouse/sql/cohort.py
zegl/posthog
62846fd565e9eb6ff299bb81dd3b91f219bd0eeb
[ "MIT" ]
4
2021-02-16T20:39:01.000Z
2022-03-19T17:00:05.000Z
CALCULATE_COHORT_PEOPLE_SQL = """ SELECT distinct_id FROM person_distinct_id where {query} AND team_id = %(team_id)s """
30.25
82
0.77686
19
121
4.526316
0.736842
0.232558
0
0
0
0
0
0
0
0
0
0
0.115702
121
3
83
40.333333
0.803738
0
0
0
0
0
0.694215
0
0
0
0
0
0
1
0
false
0
0
0
0
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
6fb1c8b7f66e85cf9656bcd1d20d4d911152960d
2,464
py
Python
Vitis-AI-Quantizer/vai_q_tensorflow/tensorflow/contrib/decent_q/__init__.py
dendisuhubdy/Vitis-AI
524f65224c52314155dafc011d488ed30e458fcb
[ "Apache-2.0" ]
848
2019-12-03T00:16:17.000Z
2022-03-31T22:53:17.000Z
tools/Vitis-AI-Quantizer/vai_q_tensorflow1.x/tensorflow/contrib/decent_q/__init__.py
wangyifan778/Vitis-AI
f61061eef7550d98bf02a171604c9a9f283a7c47
[ "Apache-2.0" ]
656
2019-12-03T00:48:46.000Z
2022-03-31T18:41:54.000Z
tools/Vitis-AI-Quantizer/vai_q_tensorflow1.x/tensorflow/contrib/decent_q/__init__.py
wangyifan778/Vitis-AI
f61061eef7550d98bf02a171604c9a9f283a7c47
[ "Apache-2.0" ]
506
2019-12-03T00:46:26.000Z
2022-03-30T10:34:56.000Z
# Copyright 2019 Xilinx Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # 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. """decent_q module""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.contrib.decent_q.python.ops.fix_neuron_ops import fix_neuron from tensorflow.contrib.decent_q.utils import DecentQTransform from tensorflow.contrib.decent_q.python import utils from tensorflow.contrib.decent_q.python.quantize_graph import QuantizeConfig from tensorflow.contrib.decent_q.python.quantize_graph import ConvertConstantsToVariables from tensorflow.contrib.decent_q.python.quantize_graph import CreateOptimizedGraphDef from tensorflow.contrib.decent_q.python.quantize_graph import CreateQuantizeTrainingGraphDef from tensorflow.contrib.decent_q.python.quantize_graph import CreateQuantizeCalibrationGraphDef from tensorflow.contrib.decent_q.python.quantize_graph import CreateQuantizeEvaluationGraphDef from tensorflow.contrib.decent_q.python.quantize_graph import CreateQuantizeDeployGraphDef from tensorflow.contrib.decent_q.python.quantize_graph import CreateQuantizeTrainingGraph from tensorflow.contrib.decent_q.python.quantize_graph import CreateQuantizeEvaluationGraph from tensorflow.contrib.decent_q.python.quantize_graph import ConvertFoldedBatchnorms from tensorflow.contrib.decent_q.python.quantize_graph import CreateQuantizeDeployGraph from tensorflow.contrib.decent_q.python.decent_q import inspect from tensorflow.contrib.decent_q.python.decent_q import quantize_frozen from tensorflow.contrib.decent_q.python.decent_q import quantize_train from tensorflow.contrib.decent_q.python.decent_q import quantize_evaluate from tensorflow.contrib.decent_q.python.decent_q import deploy_checkpoint from tensorflow.contrib.decent_q.python.decent_q import quantize_frozen from tensorflow.contrib.decent_q.python.decent_q import quantize_train from tensorflow.contrib.decent_q.python.decent_q import check_float_graph
53.565217
95
0.861607
334
2,464
6.155689
0.305389
0.105545
0.224708
0.288911
0.543288
0.529669
0.496595
0.496595
0.496595
0.167315
0
0.003549
0.085227
2,464
45
96
54.755556
0.908607
0.230519
0
0.16
0
0
0
0
0
0
0
0
0
1
0
true
0
1
0
1
0.04
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
1
0
1
0
0
0
0
4
6fb89530285072d9bca592f70b226bd2298d34d1
237
py
Python
tape/task_models/FreezeWeights.py
nickbhat/tape-1
96778d1a3bb35acf966c6b32b4df1d738fa19ffd
[ "MIT" ]
42
2019-12-09T12:44:45.000Z
2022-03-13T19:46:41.000Z
tape/task_models/FreezeWeights.py
nickbhat/tape-1
96778d1a3bb35acf966c6b32b4df1d738fa19ffd
[ "MIT" ]
11
2019-12-16T08:59:56.000Z
2022-01-26T21:13:25.000Z
tape/task_models/FreezeWeights.py
nickbhat/tape-1
96778d1a3bb35acf966c6b32b4df1d738fa19ffd
[ "MIT" ]
7
2019-12-16T09:58:42.000Z
2020-12-04T06:58:19.000Z
import tensorflow.keras.backend as K from tensorflow.keras.layers import Layer class FreezeWeights(Layer): def call(self, inputs): inputs['encoder_output'] = K.stop_gradient(inputs['encoder_output']) return inputs
23.7
76
0.729958
30
237
5.666667
0.666667
0.176471
0.223529
0
0
0
0
0
0
0
0
0
0.172996
237
9
77
26.333333
0.867347
0
0
0
0
0
0.118143
0
0
0
0
0
0
1
0.166667
false
0
0.333333
0
0.833333
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
6fc0990f2e2e83f5382a5943311e346cf6d7d709
41
py
Python
mamonsu/lib/senders/__init__.py
dan-aksenov/mamonsu
c4822b48974e870af91910515fd7f11e4b8b41b3
[ "BSD-3-Clause" ]
188
2016-01-31T09:05:59.000Z
2022-03-22T16:49:12.000Z
mamonsu/lib/senders/__init__.py
dan-aksenov/mamonsu
c4822b48974e870af91910515fd7f11e4b8b41b3
[ "BSD-3-Clause" ]
162
2016-02-02T13:49:14.000Z
2022-02-22T08:45:42.000Z
mamonsu/lib/senders/__init__.py
dan-aksenov/mamonsu
c4822b48974e870af91910515fd7f11e4b8b41b3
[ "BSD-3-Clause" ]
46
2016-01-31T21:23:37.000Z
2022-02-07T10:59:54.000Z
__all__ = ['zbx', 'log'] from . import *
13.666667
24
0.560976
5
41
3.8
1
0
0
0
0
0
0
0
0
0
0
0
0.195122
41
2
25
20.5
0.575758
0
0
0
0
0
0.146341
0
0
0
0
0
0
1
0
false
0
0.5
0
0.5
0
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
4
6fcdbfa698aedb39eea3d016f169db3d9d2cb349
1,454
py
Python
encuestas/views.py
Leoguzmand/crud-django
d01920182bcff4dd94d25ee708357c314d7d77d1
[ "MIT" ]
1
2021-07-19T17:55:17.000Z
2021-07-19T17:55:17.000Z
encuestas/views.py
Leoguzmand/crud-django
d01920182bcff4dd94d25ee708357c314d7d77d1
[ "MIT" ]
null
null
null
encuestas/views.py
Leoguzmand/crud-django
d01920182bcff4dd94d25ee708357c314d7d77d1
[ "MIT" ]
2
2021-07-19T02:15:21.000Z
2021-07-19T16:14:15.000Z
from django.shortcuts import render from django.http import HttpResponse from .models import User # Create your views here. def jhonathan(request): return HttpResponse("Respuesta creada por Jhonathan") def miguel(request): return HttpResponse("Respuesta creada por Miguel Royett") def gaston(request): return HttpResponse("Respuesta creada por Gaston") #gaston este es un PR apruebalo def leonardo (request): return HttpResponse("Respuesta creada por Leonardo") def create(data): pass def delete(data): pass def read(data): return HttpResponse("READ Hello world from Django for Codo a Codo 4.0:" ) def gretting(request): print(dict(request.GET)) # Que hacemos si un GET? # vamos a escribir un IF para determinar si es GET la respuesta devuelve datos. # myUsers = User.objects.all() # output = [] # for user in myUsers: # print(user.username) # output.append(user.username) # Que hacemos si es un POST? #modificar la data #myNewUser = User() # Que hacemos si myResponse = HttpResponse("Hello world from Django for Codo a Codo 4.0:" ) if request.method == "GET": myResponse = read(request) elif request.method == "UPDATE": myResponse = update(request) elif request.method == "QUE VA?": myResponse = delete(request) else: # Que method es? myResponse = create(request) return myResponse
24.644068
83
0.671939
184
1,454
5.309783
0.38587
0.06653
0.102354
0.139202
0.24565
0.24565
0.069601
0.069601
0.069601
0.069601
0
0.00361
0.237964
1,454
58
84
25.068966
0.878159
0.257221
0
0.068966
0
0
0.215023
0
0
0
0
0
0
1
0.275862
false
0.068966
0.103448
0.172414
0.586207
0.034483
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
1
0
1
1
0
0
4
6fe91ff28b7e87e8ece7e045270e88a41799863d
482
py
Python
mundo1/aula07g.py
dilsonm/CeV
8043be36b2da187065691d23ed5cb40fd65f806f
[ "MIT" ]
null
null
null
mundo1/aula07g.py
dilsonm/CeV
8043be36b2da187065691d23ed5cb40fd65f806f
[ "MIT" ]
null
null
null
mundo1/aula07g.py
dilsonm/CeV
8043be36b2da187065691d23ed5cb40fd65f806f
[ "MIT" ]
null
null
null
#Leia um numero inteiro e monte sua tabuada n1 = int(input('Digite um numero inteiro: ')) print('Tabuada do numero : '.format(n1)) print(' 1 x {} = {}'.format(n1, n1*1)) print(' 2 x {} = {}'.format(n1, n1*2)) print(' 3 x {} = {}'.format(n1, n1*3)) print(' 4 x {} = {}'.format(n1, n1*4)) print(' 5 x {} = {}'.format(n1, n1*5)) print(' 6 x {} = {}'.format(n1, n1*6)) print(' 7 x {} = {}'.format(n1, n1*7)) print(' 8 x {} = {}'.format(n1, n1*8)) print(' 9 x {} = {}'.format(n1, n1*9))
37.076923
45
0.53112
84
482
3.047619
0.297619
0.3125
0.316406
0.386719
0
0
0
0
0
0
0
0.095238
0.172199
482
12
46
40.166667
0.546366
0.087137
0
0
0
0
0.350797
0
0
0
0
0
0
1
0
false
0
0
0
0
0.909091
0
0
0
null
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
4
6ff9ee6d419a83d363c18b4969fd89ff28852a57
123
py
Python
dispike/register/models/__init__.py
Squidtoon99/dispike
db4b1a12268afcc87a96003923e6f56139872f0e
[ "MIT" ]
null
null
null
dispike/register/models/__init__.py
Squidtoon99/dispike
db4b1a12268afcc87a96003923e6f56139872f0e
[ "MIT" ]
null
null
null
dispike/register/models/__init__.py
Squidtoon99/dispike
db4b1a12268afcc87a96003923e6f56139872f0e
[ "MIT" ]
null
null
null
from .options import ( DiscordCommand, CommandChoice, CommandOption, SubcommandOption, CommandTypes, )
15.375
22
0.691057
8
123
10.625
1
0
0
0
0
0
0
0
0
0
0
0
0.243902
123
7
23
17.571429
0.913978
0
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0
0.142857
0
0.142857
0
1
0
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
6ffa85619dca5f4edc308180ad1b2f4f3dbd309d
2,999
py
Python
locker.py
Brayooh/password-locker
497efbab28b5d31562350a22739aaa0fc566e616
[ "MIT" ]
null
null
null
locker.py
Brayooh/password-locker
497efbab28b5d31562350a22739aaa0fc566e616
[ "MIT" ]
null
null
null
locker.py
Brayooh/password-locker
497efbab28b5d31562350a22739aaa0fc566e616
[ "MIT" ]
null
null
null
import pyperclip import random class Credential: """ Class that generates new instance of user's credentials """ credentials_list = [] def __init__(self, view_password, account, login, password): self.view_password = view_password self.account = account self.login = login self.password = password def save_credential(self): """ save_credential method saves credential objects into the credential_list """ Credential.credentials_list.append(self) def del_credential(self): ''' delete_credential method deletes a saved credential from the credential_list ''' Credential.credentials_list.remove(self) @classmethod def find_by_account(cls, account): ''' Method that takes in a number and returns a credential that matches that account name. Args: account: Account name to search for Returns : Credential of account that matches the account name. ''' for credential in cls.credentials_list: if credential.account == account: return credential @classmethod def credential_exist(cls, account): ''' Method that checks if a credential exists from the credential list. Args: account: Account name to search if it exists Returns : Boolean: True or false depending if the credential exists ''' for credential in cls.credentials_list: if credential.account == account: return True return False @classmethod def display_credentials(cls): """ display_credentials method that returns the credential list """ return cls.credentials_list class User: """ Class that generates new instance of users """ user_list = [] def __init__(self, username, password): self.username = username self.password = password def save_user(self): """ save_user method saves user objects into the user_list """ User.user_list.append(self) @classmethod def find_by_number(cls, username): ''' Method that takes in a username and returns a user matched that username. Args: username: username to search for Returns: user that matched the username. ''' for user in cls.user_list: if user.username == username: return user @classmethod def user_exist(cls, characters): """ user_exists method that checks is a user exists from the user list args: characters:password to search is nthe user exists returns: boolean:true or false depending on the condition """ for user in cls.user_list: if user.password == characters: return True return False
27.018018
94
0.606202
331
2,999
5.374622
0.21148
0.05059
0.038224
0.023609
0.340641
0.263069
0.147274
0.102305
0.073075
0.073075
0
0
0.333111
2,999
110
95
27.263636
0.8895
0.36879
0
0.377778
1
0
0
0
0
0
0
0
0
1
0.222222
false
0.133333
0.044444
0
0.511111
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
1
0
1
0
0
1
0
0
4
82eaea6be91ec691e37013811c389046824f8821
65
py
Python
zerovl/core/optimizer/builder.py
zerovl/ZeroVL
b48794e74fed0f80adf5fa3010481064411c4182
[ "MIT" ]
14
2022-01-19T08:08:29.000Z
2022-03-10T05:55:36.000Z
zerovl/core/optimizer/builder.py
zerovl/ZeroVL
b48794e74fed0f80adf5fa3010481064411c4182
[ "MIT" ]
2
2022-02-25T14:35:47.000Z
2022-03-01T03:11:13.000Z
zerovl/core/optimizer/builder.py
zerovl/ZeroVL
b48794e74fed0f80adf5fa3010481064411c4182
[ "MIT" ]
3
2022-02-09T01:23:11.000Z
2022-02-15T11:45:30.000Z
from zerovl.utils import Registry LR = Registry('LR scheduler')
16.25
33
0.769231
9
65
5.555556
0.777778
0.4
0
0
0
0
0
0
0
0
0
0
0.138462
65
3
34
21.666667
0.892857
0
0
0
0
0
0.184615
0
0
0
0
0
0
1
0
false
0
0.5
0
0.5
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
0
0
0
4
82f26892f70ea8956090bdd5b5e1b0feaeb76d6d
48
py
Python
py200_062.py
JaeGyu/PythonEx_1
e67053db6ca7431c3dd66351c190c53229e3f141
[ "MIT" ]
null
null
null
py200_062.py
JaeGyu/PythonEx_1
e67053db6ca7431c3dd66351c190c53229e3f141
[ "MIT" ]
null
null
null
py200_062.py
JaeGyu/PythonEx_1
e67053db6ca7431c3dd66351c190c53229e3f141
[ "MIT" ]
null
null
null
a = 100 b = 3 print(a % b) print(divmod(a, b))
8
19
0.541667
11
48
2.363636
0.545455
0.153846
0
0
0
0
0
0
0
0
0
0.111111
0.25
48
5
20
9.6
0.611111
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0
0
0
0.5
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
4
d20eea55d8f06a0e5f4a4ed9581847ae1dc42f0c
20
py
Python
Copycat.py
IsratIJK/Toph-Problem-Solve
95ca634eb778b15c9fa13662ec1604de9fc3225b
[ "Apache-2.0" ]
null
null
null
Copycat.py
IsratIJK/Toph-Problem-Solve
95ca634eb778b15c9fa13662ec1604de9fc3225b
[ "Apache-2.0" ]
null
null
null
Copycat.py
IsratIJK/Toph-Problem-Solve
95ca634eb778b15c9fa13662ec1604de9fc3225b
[ "Apache-2.0" ]
null
null
null
n = input() print(n)
10
11
0.6
4
20
3
0.75
0
0
0
0
0
0
0
0
0
0
0
0.15
20
2
12
10
0.705882
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0
0
0
0.5
1
1
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
4
d21e050ae1ff4c267bc5d4e2cad30f4b817ed353
34
py
Python
nssrc/com/citrix/netscaler/nitro/resource/config/router/__init__.py
benfinke/ns_python
d651d7aa01d7dc63c1cd435c7b3314d7f5b26659
[ "Apache-2.0" ]
2
2020-08-24T18:04:22.000Z
2020-08-24T18:04:47.000Z
nssrc/com/citrix/netscaler/nitro/resource/config/router/__init__.py
benfinke/ns_python
d651d7aa01d7dc63c1cd435c7b3314d7f5b26659
[ "Apache-2.0" ]
1
2017-01-20T22:56:58.000Z
2017-01-20T22:56:58.000Z
nssrc/com/citrix/netscaler/nitro/resource/config/router/__init__.py
benfinke/ns_python
d651d7aa01d7dc63c1cd435c7b3314d7f5b26659
[ "Apache-2.0" ]
6
2015-04-21T13:14:08.000Z
2020-12-03T07:27:52.000Z
__all__ = ['routerdynamicrouting']
34
34
0.794118
2
34
11.5
1
0
0
0
0
0
0
0
0
0
0
0
0.058824
34
1
34
34
0.71875
0
0
0
0
0
0.571429
0
0
0
0
0
0
1
0
false
0
0
0
0
0
1
1
1
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
d22090320ce0c4f87ab7b7bc1f37dd5544b62f83
100
py
Python
nomad-rpi/test/__init__.py
attackle/nomad
fa5bf289ccc983ac8a2aab5e6cecc3c202941f2d
[ "MIT" ]
null
null
null
nomad-rpi/test/__init__.py
attackle/nomad
fa5bf289ccc983ac8a2aab5e6cecc3c202941f2d
[ "MIT" ]
3
2018-03-26T22:52:24.000Z
2018-04-23T08:40:02.000Z
test/__init__.py
attackle/nomad-rpi
1099a950fe67df97bb04b513417d5b3a9bad82f1
[ "MIT" ]
5
2018-03-18T06:08:50.000Z
2018-04-09T21:46:16.000Z
#!/usr/bin/python3 # -*- coding: utf-8 -*- '''\ Nomad-RPi testing modules. since: 23-APR-2018 '''
11.111111
26
0.59
14
100
4.214286
1
0
0
0
0
0
0
0
0
0
0
0.094118
0.15
100
8
27
12.5
0.6
0.86
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
d23e3fc71a11a3be52a3403e567335aa6c6f9b29
141
py
Python
lesson01/xiaochong/homework/99.py
herrywen-nanj/51reboot
1130c79a360e1b548a6eaad176eb60f8bed22f40
[ "Apache-2.0" ]
null
null
null
lesson01/xiaochong/homework/99.py
herrywen-nanj/51reboot
1130c79a360e1b548a6eaad176eb60f8bed22f40
[ "Apache-2.0" ]
null
null
null
lesson01/xiaochong/homework/99.py
herrywen-nanj/51reboot
1130c79a360e1b548a6eaad176eb60f8bed22f40
[ "Apache-2.0" ]
null
null
null
""" 1: 打印乘法口诀 """ for i in range(1,10): for j in range(1,i+1): print("{} * {} = {}\t".format(i,j,i * j),end="") print()
10.846154
56
0.41844
24
141
2.458333
0.5
0.237288
0.271186
0
0
0
0
0
0
0
0
0.06
0.29078
141
12
57
11.75
0.53
0.06383
0
0
0
0
0.116667
0
0
0
0
0
0
1
0
false
0
0
0
0
0.5
1
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
1
0
4
d264ea8204572b2abfdc76657539e4af0d692ab7
393
py
Python
psutils/tests/test_extensions.py
avilieber/psutils
86f56ed7c67e66de242315965ccc6ed6f5653636
[ "BSD-3-Clause" ]
null
null
null
psutils/tests/test_extensions.py
avilieber/psutils
86f56ed7c67e66de242315965ccc6ed6f5653636
[ "BSD-3-Clause" ]
null
null
null
psutils/tests/test_extensions.py
avilieber/psutils
86f56ed7c67e66de242315965ccc6ed6f5653636
[ "BSD-3-Clause" ]
null
null
null
import pytest # noqa: F401 def test_accessor_register(): # extension hasnt been imported yet, # so DataFrame should not be decorated from pyspark.sql import DataFrame assert not hasattr(DataFrame, "withColumns") # we should now be able to import the module and get all accessors import psutils.extensions # noqa: 401 assert hasattr(DataFrame, "withColumns")
26.2
70
0.725191
51
393
5.54902
0.745098
0.113074
0.190813
0
0
0
0
0
0
0
0
0.019481
0.216285
393
14
71
28.071429
0.899351
0.399491
0
0
0
0
0.095652
0
0
0
0
0
0.333333
1
0.166667
true
0
0.5
0
0.666667
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
1
0
1
0
0
4
963560251771e6e388d31fda94121081545eb3ad
3,278
py
Python
tests/test_multiple_configured.py
mwbutcher/flake8-pytest-mark
5dee18225d980cbc830773dc18a30b84fa2eb294
[ "Apache-2.0" ]
null
null
null
tests/test_multiple_configured.py
mwbutcher/flake8-pytest-mark
5dee18225d980cbc830773dc18a30b84fa2eb294
[ "Apache-2.0" ]
null
null
null
tests/test_multiple_configured.py
mwbutcher/flake8-pytest-mark
5dee18225d980cbc830773dc18a30b84fa2eb294
[ "Apache-2.0" ]
null
null
null
# -*- coding: utf-8 -*- import pytest # args to only use checks that raise an 'M' prefixed error extra_args = ['--select', 'M'] four_marks_config = """ [flake8] pytest_mark1 = name=test_id regex=[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12} autofix=uuid pytest_mark2 = name=foo pytest_mark3 = name=test_name pytest_mark4 = name=bla_bla """ def test_some_tests_marked(flake8dir): flake8dir.make_setup_cfg(four_marks_config) flake8dir.make_example_py(""" @pytest.mark.test_id('b360c12d-0d47-4cfc-9f9e-5d86c315b1e4') def test_1(): pass @pytest.mark.test_name('I am a test name') def test_2(): pass """) result = flake8dir.run_flake8(extra_args) observed = result.out_lines expected = ['./example.py:1:1: M502 test definition not marked with foo', './example.py:1:1: M503 test definition not marked with test_name', './example.py:1:1: M504 test definition not marked with bla_bla', './example.py:5:1: M501 test definition not marked with test_id', './example.py:5:1: M502 test definition not marked with foo', './example.py:5:1: M504 test definition not marked with bla_bla'] pytest.helpers.assert_lines(expected, observed) def test_no_tests_marked(flake8dir): flake8dir.make_setup_cfg(four_marks_config) flake8dir.make_example_py(""" def test_happy_path(): pass """) result = flake8dir.run_flake8(extra_args) expected = ['./example.py:1:1: M503 test definition not marked with test_name', './example.py:1:1: M502 test definition not marked with foo', './example.py:1:1: M504 test definition not marked with bla_bla', './example.py:1:1: M501 test definition not marked with test_id'] observed = result.out_lines pytest.helpers.assert_lines(expected, observed) def test_asc_517(flake8dir): c = """ [flake8] pytest_mark1 = name=test_id,value_match=uuid pytest_mark2 = name=jira,value_regex=[a-zA-Z]+-\d+ """ flake8dir.make_setup_cfg(c) flake8dir.make_example_py(""" @pytest.mark.test_id('bogus') @pytest.mark.jira('ASC-567') def test_my_feature(host): pass """) result = flake8dir.run_flake8(extra_args) assert result.out_lines == [u"./example.py:1:1: M601 the mark values '['bogus']' do not match the configuration specified by pytest_mark1, badly formed hexadecimal UUID string"] # noqa def test_asc_517_both_values_bad(flake8dir): c = """ [flake8] pytest_mark1 = name=test_id,value_match=uuid pytest_mark2 = name=jira,value_regex=[a-zA-Z]+-\d+ """ flake8dir.make_setup_cfg(c) flake8dir.make_example_py(""" @pytest.mark.test_id('bogus') @pytest.mark.jira('jira-ticket') def test_my_feature(host): pass """) result = flake8dir.run_flake8(extra_args) observed = result.out_lines expected = ["./example.py:1:1: M601 the mark values '['bogus']' do not match the configuration specified by pytest_mark1, badly formed hexadecimal UUID string", # noqa "./example.py:1:1: M602 the mark values '['jira-ticket']' do not match the configuration specified by pytest_mark2, Configured regex: '[a-zA-Z]+-\d+'"] # noqa pytest.helpers.assert_lines(expected, observed)
35.630435
189
0.682123
489
3,278
4.388548
0.231084
0.071295
0.046598
0.051258
0.776328
0.76794
0.736719
0.719478
0.648183
0.595061
0
0.055473
0.180598
3,278
91
190
36.021978
0.743485
0.028371
0
0.592105
0
0.052632
0.59547
0.141554
0
0
0
0
0.052632
1
0.052632
false
0.065789
0.013158
0
0.065789
0
0
0
0
null
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
4
967333f8640726c464c37cdece00442ade5732b9
257
py
Python
GmailWrapper_JE/venv/Lib/site-packages/pyasn1/type/error.py
JE-Chen/je_old_repo
a8b2f1ac2eec25758bd15b71c64b59b27e0bcda5
[ "MIT" ]
2
2022-01-06T11:52:57.000Z
2022-01-09T01:53:56.000Z
GmailWrapper_JE/venv/Lib/site-packages/pyasn1/type/error.py
JE-Chen/je_old_repo
a8b2f1ac2eec25758bd15b71c64b59b27e0bcda5
[ "MIT" ]
null
null
null
GmailWrapper_JE/venv/Lib/site-packages/pyasn1/type/error.py
JE-Chen/je_old_repo
a8b2f1ac2eec25758bd15b71c64b59b27e0bcda5
[ "MIT" ]
null
null
null
# # This file is part of pyasn1 software. # # Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> # License: http://snmplabs.com/pyasn1/license.html # from pyasn1.error import PyAsn1Error class ValueConstraintError(PyAsn1Error): pass
21.416667
60
0.719844
32
257
5.78125
0.8125
0
0
0
0
0
0
0
0
0
0
0.061321
0.175097
257
11
61
23.363636
0.811321
0.560311
0
0
0
0
0
0
0
0
0
0
0
1
0
true
0.333333
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
1
1
1
0
1
0
0
4
96922cb35039afc11aff4ee6047b5b91c98ac268
248
py
Python
table/coffee/forms.py
deltaGPhys/CNCCoffeeTable
412b1d788a86f78ba3ad57885143f8121508c1fb
[ "MIT" ]
null
null
null
table/coffee/forms.py
deltaGPhys/CNCCoffeeTable
412b1d788a86f78ba3ad57885143f8121508c1fb
[ "MIT" ]
null
null
null
table/coffee/forms.py
deltaGPhys/CNCCoffeeTable
412b1d788a86f78ba3ad57885143f8121508c1fb
[ "MIT" ]
null
null
null
from django import forms from .models import * from django.forms.widgets import * class PatternAddForm(forms.ModelForm): class Meta: model = Pattern fields = ('Name','Blueprint','Photo','Gcode','Duration','Description','Type')
27.555556
85
0.689516
28
248
6.107143
0.714286
0.116959
0
0
0
0
0
0
0
0
0
0
0.173387
248
8
86
31
0.834146
0
0
0
0
0
0.185484
0
0
0
0
0
0
1
0
false
0
0.428571
0
0.714286
0.142857
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
96ac35073ee28ad15548bbc5cf6d8009b8c84b48
140
py
Python
Lemmatizer.py
CharlesG12/IndexCompression
ca897de6e68bd12f1e068645a1ce6b0d0c6ff309
[ "MIT" ]
null
null
null
Lemmatizer.py
CharlesG12/IndexCompression
ca897de6e68bd12f1e068645a1ce6b0d0c6ff309
[ "MIT" ]
null
null
null
Lemmatizer.py
CharlesG12/IndexCompression
ca897de6e68bd12f1e068645a1ce6b0d0c6ff309
[ "MIT" ]
null
null
null
from nltk.stem import WordNetLemmatizer def lemmatizing(word): lemmatizer = WordNetLemmatizer() return lemmatizer.lemmatize(word)
20
39
0.778571
14
140
7.785714
0.785714
0
0
0
0
0
0
0
0
0
0
0
0.15
140
6
40
23.333333
0.915966
0
0
0
0
0
0
0
0
0
0
0
0
1
0.25
false
0
0.25
0
0.75
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
1
0
0
0
0
1
0
0
4
96b077a1469cda934625659cc43b12a05e83bd05
156
py
Python
api/serializers.py
macav/ideas-platform
bc65355b9cd5164d6b2d640bf275e55ae8dd843e
[ "MIT" ]
null
null
null
api/serializers.py
macav/ideas-platform
bc65355b9cd5164d6b2d640bf275e55ae8dd843e
[ "MIT" ]
null
null
null
api/serializers.py
macav/ideas-platform
bc65355b9cd5164d6b2d640bf275e55ae8dd843e
[ "MIT" ]
null
null
null
from api.models import Idea from rest_framework import serializers class IdeaSerializer(serializers.ModelSerializer): class Meta: model = Idea
22.285714
50
0.775641
18
156
6.666667
0.722222
0
0
0
0
0
0
0
0
0
0
0
0.179487
156
7
51
22.285714
0.9375
0
0
0
0
0
0
0
0
0
0
0
0
1
0
false
0
0.4
0
0.8
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
96b327385009578698623914c409b889b56e017b
403
py
Python
tgapi/exceptions.py
azakharau/tg_bot_api
55e7af07beee27d5dac6197a7e03c051bff41562
[ "MIT" ]
null
null
null
tgapi/exceptions.py
azakharau/tg_bot_api
55e7af07beee27d5dac6197a7e03c051bff41562
[ "MIT" ]
null
null
null
tgapi/exceptions.py
azakharau/tg_bot_api
55e7af07beee27d5dac6197a7e03c051bff41562
[ "MIT" ]
null
null
null
class FunctionNotAllowed(Exception): ... class TelegramBaseException(Exception): ... class TelegramAPIException(TelegramBaseException): ... class TelegramDataObjectException(TelegramBaseException): ... class HandlerException(TelegramBaseException): ... class HandlerCloseException(TelegramBaseException): ... class DispatcherException(TelegramBaseException): ...
14.925926
57
0.744417
21
403
14.285714
0.428571
0.346667
0
0
0
0
0
0
0
0
0
0
0.151365
403
26
58
15.5
0.877193
0
0
0.5
0
0
0
0
0
0
0
0
0
1
0
true
0
0
0
0.5
0
1
0
1
null
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
737d6352a3ecc85e4cfef77cf098d84085e55a65
85
py
Python
backend/data/discordance/bheat/blob/2d1dd9c22663887e8b0f55ce6f547507da7d7e8f/generate/variation_seq2seq.py
zhiiker/neural_complete
9338a23aee405f2280faeca1a8ad567602257678
[ "MIT" ]
1,237
2017-04-02T01:25:04.000Z
2022-03-27T15:09:01.000Z
backend/data/discordance/bheat/blob/2d1dd9c22663887e8b0f55ce6f547507da7d7e8f/generate/variation_seq2seq.py
zhiiker/neural_complete
9338a23aee405f2280faeca1a8ad567602257678
[ "MIT" ]
6
2017-04-18T01:51:34.000Z
2021-10-09T06:06:50.000Z
backend/data/discordance/bheat/blob/2d1dd9c22663887e8b0f55ce6f547507da7d7e8f/generate/variation_seq2seq.py
zhiiker/neural_complete
9338a23aee405f2280faeca1a8ad567602257678
[ "MIT" ]
161
2017-04-04T13:52:00.000Z
2022-02-02T19:51:12.000Z
# https://github.com/codekansas/keras-language-modeling/blob/master/attention_lstm.py
85
85
0.835294
12
85
5.833333
1
0
0
0
0
0
0
0
0
0
0
0
0.011765
85
1
85
85
0.833333
0.976471
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
737e3ce0635df52bc0e2fbdec522b30beebc345f
343
py
Python
algorithms_explained/algo_explained/apps.py
Zamy97/Algorithms_Explained
048022903da4199b3d245997e95c172cfbea508f
[ "MIT" ]
1
2020-09-22T14:29:46.000Z
2020-09-22T14:29:46.000Z
algorithms_explained/algo_explained/apps.py
Zamy97/Algorithms_Explained
048022903da4199b3d245997e95c172cfbea508f
[ "MIT" ]
null
null
null
algorithms_explained/algo_explained/apps.py
Zamy97/Algorithms_Explained
048022903da4199b3d245997e95c172cfbea508f
[ "MIT" ]
null
null
null
from django.apps import AppConfig class AlgoExplainedConfig(AppConfig): name = 'algorithms_explained.algo_explained' verbose_name = "ALGORITHMS_EXPLAINED" def ready(self): try: # noinspection PyUnresolvedReferences from . import signals # noqa F401 except ImportError: pass
22.866667
49
0.661808
31
343
7.193548
0.774194
0.125561
0.206278
0
0
0
0
0
0
0
0
0.012195
0.282799
343
14
50
24.5
0.894309
0.131195
0
0
0
0
0.186441
0.118644
0
0
0
0
0
1
0.111111
false
0.111111
0.333333
0
0.777778
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
1
0
1
0
0
4
73bbce4146d9f15ba7ad1ef9132f6008059b669e
233
py
Python
pyuhoo/consts.py
csacca/pyuhoo
9b18b0beed5a3164d145c1bf35f3ffc4fa74a3de
[ "MIT" ]
1
2021-08-23T15:13:38.000Z
2021-08-23T15:13:38.000Z
pyuhoo/consts.py
csacca/pyuhoo
9b18b0beed5a3164d145c1bf35f3ffc4fa74a3de
[ "MIT" ]
41
2021-08-30T08:18:47.000Z
2022-03-31T08:25:33.000Z
pyuhoo/consts.py
csacca/pyuhoo
9b18b0beed5a3164d145c1bf35f3ffc4fa74a3de
[ "MIT" ]
1
2022-01-20T21:56:40.000Z
2022-01-20T21:56:40.000Z
USER_AGENT_PRODUCT: str = "uHoo" USER_AGENT_PRODUCT_VERSION: str = "10.3.1" USER_AGENT_SYSTEM_INFORMATION: str = "iPhone;13.3; iOS 14.7.1; Scale/3.00" APP_VERSION: int = 93 CLIENT_ID: str = "0000000000000000000|0000000000000000000"
33.285714
74
0.772532
37
233
4.594595
0.648649
0.158824
0.188235
0
0
0
0
0
0
0
0
0.258373
0.103004
233
6
75
38.833333
0.555024
0
0
0
0
0
0.360515
0.167382
0
0
0
0
0
1
0
true
0
0
0
0
0
0
0
0
null
0
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
1
0
0
0
0
0
0
4
73bc4a9244f4267618f398348750e7d631897eee
113
py
Python
commands/sweet_brown.py
dannydenenberg/Starlight
e7fc946760a41449acd10d0d092fe8a898fdb96c
[ "MIT" ]
1
2019-06-07T07:10:59.000Z
2019-06-07T07:10:59.000Z
commands/sweet_brown.py
dannydenenberg/Starlight
e7fc946760a41449acd10d0d092fe8a898fdb96c
[ "MIT" ]
null
null
null
commands/sweet_brown.py
dannydenenberg/Starlight
e7fc946760a41449acd10d0d092fe8a898fdb96c
[ "MIT" ]
null
null
null
sweet brown os.chdir('..') # Playing the converted file os.system("mpg123 sweet_brown.mp3") os.chdir('commands')
18.833333
35
0.734513
17
113
4.823529
0.705882
0.243902
0
0
0
0
0
0
0
0
0
0.039216
0.097345
113
5
36
22.6
0.764706
0.230089
0
0
0
0
0.376471
0
0
0
0
0
0
0
null
null
0
0
null
null
0
1
0
0
null
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
1
0
0
0
0
0
0
0
0
4
73c8f89438ad9a19e3a6861b48cd3065f48ebc69
96
py
Python
pyCreate2/__init__.py
USC-ACTLab/pyCreate2
5c64b8c0b04a426003beabe837455fe1d698720e
[ "MIT" ]
4
2019-08-10T01:25:00.000Z
2021-01-11T08:29:44.000Z
pyCreate2/__init__.py
USC-ACTLab/pyCreate2
5c64b8c0b04a426003beabe837455fe1d698720e
[ "MIT" ]
null
null
null
pyCreate2/__init__.py
USC-ACTLab/pyCreate2
5c64b8c0b04a426003beabe837455fe1d698720e
[ "MIT" ]
2
2017-02-16T23:22:59.000Z
2019-06-16T22:21:34.000Z
from .create2 import * from .factory import * __all__ = ["FactoryCreate", "FactorySimulation"]
19.2
48
0.739583
9
96
7.444444
0.777778
0
0
0
0
0
0
0
0
0
0
0.012048
0.135417
96
4
49
24
0.795181
0
0
0
0
0
0.3125
0
0
0
0
0
0
1
0
false
0
0.666667
0
0.666667
0
1
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
1
0
1
0
0
4
73d0897e8e0314094ecf2304f53ef6f49ef9eaaa
31,844
py
Python
beacon/utils/db.py
crs4/beacon-2.x
649821f03e18b820c972fb427e25111e9e614c90
[ "Apache-2.0" ]
6
2020-01-30T17:29:40.000Z
2022-03-18T05:27:50.000Z
beacon/utils/db.py
crs4/beacon-2.x
649821f03e18b820c972fb427e25111e9e614c90
[ "Apache-2.0" ]
43
2019-12-05T14:28:04.000Z
2022-03-11T12:10:35.000Z
beacon/utils/db.py
crs4/beacon-2.x
649821f03e18b820c972fb427e25111e9e614c90
[ "Apache-2.0" ]
14
2020-01-14T09:51:48.000Z
2022-02-17T13:53:46.000Z
# -*- coding: utf-8 -*- """Database Connection.""" import logging from contextlib import asynccontextmanager from functools import wraps import traceback from itertools import chain # import inspect import asyncpg from .. import conf from .exceptions import BeaconServerError from .json import jsonb, json_encoder, json_decoder LOG = logging.getLogger(__name__) class DBConnection(): """Databse connection setup.""" db_pool = None async def connect(self, force=False): """Get the database connection (which encapsulates a database session). Upon success, the connection is cached. """ if force: await self.close() if self.db_pool: return LOG.info("Creating a connection pool to %s:%s", conf.database_url, conf.database_port) # Connection pool handles reconnections and keeps some expensive connections open for reuse self.db_pool = await asyncpg.create_pool(host=conf.database_url, port=conf.database_port, user=conf.database_user, password=conf.database_password, database=conf.database_name, server_settings={'search_path': conf.database_schema, 'application_name': conf.database_app_name}, min_size=0, # initializing with 0 connections allows the web server to # start and also continue to live max_queries=getattr(conf, 'database_max_queries', 50000), max_size=10, # for now limiting the number of connections in the pool timeout=getattr(conf, 'database_timeout', 120), command_timeout=getattr(conf, 'database_command_timeout', 180), max_cached_statement_lifetime=0, max_inactive_connection_lifetime=180) # Ping the db async with self.db_pool.acquire() as conn: try: conn.execute('SELECT 1;') LOG.debug('Ping successful') except (asyncpg.exceptions._base.InterfaceError, asyncpg.exceptions._base.PostgresError) as e: LOG.error('DB Error: %s', e) raise ValueError(f'DB Error: {e}') # not using a beacon error. We can ping _before_ the server starts. def asyncgen_execute(self, func): async def inner(*args, **kwargs): async with self.connection() as connection: async for obj in func(connection, *args, **kwargs): yield obj return inner def coroutine_execute(self, func): async def inner(*args, **kwargs): async with self.connection() as connection: return await func(connection, *args, **kwargs) return inner @asynccontextmanager async def connection(self): if self.db_pool is None: await self.connect() LOG.debug('----------- acquiring connection') conn = await self.db_pool.acquire() try: await conn.set_type_codec('jsonb', encoder=json_encoder, decoder=json_decoder, schema='pg_catalog') yield conn except (asyncpg.exceptions._base.InterfaceError, asyncpg.exceptions._base.PostgresError, asyncpg.exceptions.UndefinedFunctionError) as e: LOG.error('DB Error: %s', e) # traceback.print_exc() raise BeaconServerError(f'DB Error: {e}') finally: LOG.debug('----------- releasing connection') await self.db_pool.release(conn) async def close(self): """Close DB Connection.""" LOG.debug("Closing the database") if self.db_pool: self.db_pool.terminate() self.db_pool = None ###################################### # Business logic # ###################################### # Instantiate the global connection pool = DBConnection() async def close(): await pool.close() # Get the latest modification data of a DB dataset @pool.coroutine_execute async def get_last_modified_date(connection): LOG.info('Retrieving last modified date') query = f"""SELECT MAX(updated_at) FROM {conf.database_schema}.dataset;""" LOG.debug("QUERY: %s", query) return await connection.fetchval(query) @pool.coroutine_execute async def _fetch_assemblyids(connection): """ Return Assembly IDs from the dataset. """ LOG.info('Retrieving assembly IDs (once)') query = f"""SELECT DISTINCT reference_genome FROM {conf.database_schema}.dataset;""" LOG.debug("QUERY: %s", query) response = await connection.fetch(query) return [r['reference_genome'] for r in response] async def fetch_assemblyids(): """ Return Assembly IDs from the dataset. We cache the result in the conf module. """ assemblyIDs = getattr(conf, 'assemblyIDs', None) if assemblyIDs is None: assemblyIDs = await _fetch_assemblyids() setattr(conf, 'assemblyIDs', assemblyIDs) else: LOG.debug('Using cached assemblyIDs: %s', assemblyIDs) return assemblyIDs # @pool.coroutine_execute # async def _fetch_dataset_partitions(connection): # """ # Return Assembly IDs from the dataset. # """ # LOG.info('Retrieving assembly IDs (once)') # query = f"""SELECT access_type, # array_agg(stable_id) AS datasets # FROM {conf.database_schema}.dataset # GROUP BY access_type;""" # LOG.debug("QUERY: %s", query) # response = await connection.fetch(query) # partitions = {} # datasets = set() # for r in response: # d = set(r['datasets']) # list/array -> set # partitions[r['access_type']] = d # datasets.update(d) # return (partitions, datasets) # async def fetch_dataset_partitions(): # """ # Return the Datasets. # We cache the result in the conf module. # """ # datasets = getattr(conf, 'datasets', None) # if datasets is None: # datasets = await _fetch_datasets() # setattr(conf, 'datasets', datasets) # else: # LOG.debug('Using cached datasets: %s', datasets) # return datasets # We might be able to use postgres partitioning # https://www.postgresql.org/docs/12/ddl-partitioning.html # We can use the 3 access types: PUBLIC, REGISTERED and CONTROLLED # # Returns a generator of record, make sure to consume them before the connection is closed @pool.asyncgen_execute async def fetch_datasets_access(connection, datasets=None): """ Retrieve available datasets as triples (access_type::str, id::int, datasetId::str) In this case, any error executing the database request is captured and an empty list is returned. """ LOG.info('Retrieving info about the available datasets (id and access type).') LOG.debug('Originally selecting datasets: %s', datasets) #async with connection.transaction(): where_clause = ' WHERE stable_id = ANY($1)' if datasets else '' query = f"""SELECT access_type, id, stable_id FROM {conf.database_schema}.dataset{where_clause};""" LOG.debug("QUERY datasets access: %s", query) try: statement = await connection.prepare(query) coro = statement.fetch(datasets) if datasets else statement.fetch() response = await coro for record in response: yield (record['access_type'], record['id'], record['stable_id']) # not using record: copy except Exception as e: LOG.error("DB error while retrieving datasets: %s", e) @pool.asyncgen_execute async def filter_out_non_public_datasets(connection, datasets): """ Retrieve available datasets as triples (access_type::str, id::int, datasetId::str) In this case, any error executing the database request is captured and an empty list is returned. """ LOG.info('Retrieving info about the available datasets (id and access type).') LOG.debug('Originally selecting datasets: %s', datasets) if not datasets: return query = f"""SELECT stable_id FROM {conf.database_schema}.dataset WHERE stable_id = ANY($1) AND access_type = 'PUBLIC';""" LOG.debug("QUERY datasets access: %s", query) statement = await connection.prepare(query) response = await statement.fetch(datasets) for record in response: yield record['stable_id'] # Returns a generator of record, make sure to consume them before the connection is closed @pool.asyncgen_execute async def fetch_datasets_metadata(connection, transform=None): """ Execute query for returning dataset metadata. """ LOG.info('Retrieving datasets metadata') query = f"""SELECT * FROM {conf.database_schema}.dataset;""" LOG.debug("QUERY: %s", query) response = await connection.fetch(query) for record in response: yield record # Returns a generator of record, make sure to consume them before the connection is closed @pool.asyncgen_execute async def fetch_filtering_terms(connection): """ Execute query for returning the filtering terms. """ # async with connection.transaction(): query = "SELECT DISTINCT ontology, term, label FROM ontology_term ORDER BY ontology, term;" response = await connection.fetch(query) for record in response: yield record # Returns a generator of record, make sure to consume them before the connection is closed @pool.asyncgen_execute async def access_levels_datasets(connection): """ Fetch the special datasets (with different access levels). They are stored in the dataset_access_level_table in the DB. Return two dicts prepared to be shown in the response (one for displayDatasetDifferences=false, the other for true). """ LOG.debug('fetch special datasets access levels info') query = """SELECT dt.stable_id AS dataset_id, al.parent_field AS parent_field, al.field AS field, al.access_level AS access_level FROM dataset_access_level_table al JOIN dataset dt ON al.dataset_id=dt.id;""" LOG.debug("QUERY: %s", query) response = await connection.fetch(query) for record in response: yield record # Returns a generator of record, make sure to consume them before the connection is closed @pool.asyncgen_execute async def _fetch_variants(connection, qparams_db, datasets, authenticated, variant_id=None, biosample_stable_id=None, individual_stable_id=None): LOG.info('Retrieving viral variant information') # We want just the names, not the formatting functions requested_schemas = [qparams_db.requestedSchema[0], qparams_db.requestedAnnotationSchema[0]] dollars = ", ".join([ f"${i}" for i in range(1, 22)]) # 1..21 LOG.debug("dollars: %s", dollars) query = f"SELECT * FROM {conf.database_schema}.fetch_gvariants({dollars});" LOG.debug("QUERY: %s", query) statement = await connection.prepare(query) response = await statement.fetch(qparams_db.variantType, # _variant_type text, qparams_db.start[0] if len(qparams_db.start) == 1 else None, # _start integer, qparams_db.start[0] if len(qparams_db.start) > 1 else None, # _start_min integer, qparams_db.start[1] if len(qparams_db.start) > 1 else None, # _start_max integer, qparams_db.end[0] if len(qparams_db.end) == 1 else None, # _end integer, qparams_db.end[0] if len(qparams_db.end) > 1 else None, # _end_min integer, qparams_db.end[1] if len(qparams_db.end) > 1 else None, # _end_max integer, qparams_db.referenceName, # qparams_db.referenceName, # _chromosome character varying, qparams_db.referenceBases, # _reference_bases text, qparams_db.alternateBases, # _alternate_bases text, qparams_db.assemblyId.lower() if qparams_db.assemblyId else None, #qparams_db.assemblyId, # _reference_genome text, qparams_db.includeDatasetResponses, # _include_dataset_responses datasets, #qparams_db.datasets[0], # _dataset_ids text[], authenticated, #qparams_db.datasets[1], # _is_authenticated bool, biosample_stable_id, # _biosample_stable_id text, individual_stable_id, # _individual_stable_id text, int(variant_id) if variant_id else None, # _gvariant_id qparams_db.filters, # filters as-is, # _filters text[], qparams_db.skip * qparams_db.limit, # _skip qparams_db.limit, # _limit integer requested_schemas) # requestedSchemas for record in response: yield record def fetch_variants_by_variant(qparams_db, datasets, authenticated): return _fetch_variants(qparams_db, datasets, authenticated, variant_id=qparams_db.targetIdReq) def fetch_variants_by_biosample(qparams_db, datasets, authenticated): return _fetch_variants(qparams_db, datasets, authenticated, biosample_stable_id=qparams_db.targetIdReq) def fetch_variants_by_individual(qparams_db, datasets, authenticated): return _fetch_variants(qparams_db, datasets, authenticated, individual_stable_id=qparams_db.targetIdReq) # Returns a generator of record, make sure to consume them before the connection is closed @pool.asyncgen_execute async def _fetch_individuals(connection, qparams_db, datasets, authenticated, variant_id=None, biosample_stable_id=None, individual_stable_id=None): """ Contacts the DB to fetch the info. Returns a pd.DataFrame with the response. """ # connection.add_log_listener(simple_listener) dollars = ", ".join([f"${i}" for i in range(1, 21)]) # 1..20 query = f"SELECT * FROM {conf.database_schema}.fetch_individuals({dollars});" LOG.debug("QUERY: %s", query) statement = await connection.prepare(query) response = await statement.fetch(qparams_db.variantType, # _variant_type text, qparams_db.start[0] if len(qparams_db.start) == 1 else None, # _start integer, qparams_db.start[0] if len(qparams_db.start) > 1 else None, # _start_min integer, qparams_db.start[1] if len(qparams_db.start) > 1 else None, # _start_max integer, qparams_db.end[0] if len(qparams_db.end) == 1 else None, # _end integer, qparams_db.end[0] if len(qparams_db.end) > 1 else None, # _end_min integer, qparams_db.end[1] if len(qparams_db.end) > 1 else None, # _end_max integer, qparams_db.referenceName, # reference_name qparams_db.referenceBases, qparams_db.alternateBases, qparams_db.assemblyId.lower() if qparams_db.assemblyId else None, # assembly_id datasets, # dataset_stable_ids authenticated, #is_authenticated biosample_stable_id, individual_stable_id, # individual_stable_id int(variant_id) if variant_id else None, qparams_db.filters, # filters qparams_db.skip * qparams_db.limit, # _skip qparams_db.limit, # _limit integer # we keep a list for the moment [qparams_db.requestedSchema[0]]) # requestedSchemas for record in response: yield record def fetch_individuals_by_variant(qparams_db, datasets, authenticated): return _fetch_individuals(qparams_db, datasets, authenticated, variant_id=qparams_db.targetIdReq) def fetch_individuals_by_biosample(qparams_db, datasets, authenticated): return _fetch_individuals(qparams_db, datasets, authenticated, biosample_stable_id=qparams_db.targetIdReq) def fetch_individuals_by_individual(qparams_db, datasets, authenticated): return _fetch_individuals(qparams_db, datasets, authenticated, individual_stable_id=qparams_db.targetIdReq) # Returns a generator of record, make sure to consume them before the connection is closed @pool.asyncgen_execute async def _fetch_biosamples(connection, qparams_db, datasets, authenticated, variant_id=None, biosample_stable_id=None, individual_stable_id=None): LOG.info('Retrieving viral biosample information') dollars = ", ".join([ f"${i}" for i in range(1, 21)]) # 1..20 # LOG.debug("dollars: %s", dollars) query = f"SELECT * FROM {conf.database_schema}.fetch_samples({dollars});" LOG.debug("QUERY: %s", query) statement = await connection.prepare(query) response = await statement.fetch(qparams_db.variantType, # _variant_type text, qparams_db.start[0] if len(qparams_db.start) == 1 else None, # _start integer, qparams_db.start[0] if len(qparams_db.start) > 1 else None, # _start_min integer, qparams_db.start[1] if len(qparams_db.start) > 1 else None, # _start_max integer, qparams_db.end[0] if len(qparams_db.end) == 1 else None, # _end integer, qparams_db.end[0] if len(qparams_db.end) > 1 else None, # _end_min integer, qparams_db.end[1] if len(qparams_db.end) > 1 else None, # _end_max integer, qparams_db.referenceName, # reference_name qparams_db.referenceBases, qparams_db.alternateBases, qparams_db.assemblyId.lower() if qparams_db.assemblyId else None, # assembly_id datasets, # dataset_stable_ids authenticated, #is_authenticated biosample_stable_id, individual_stable_id, # individual_stable_id int(variant_id) if variant_id else None, qparams_db.filters, # filters qparams_db.skip * qparams_db.limit, # _skip qparams_db.limit, # limit # we keep a list for the moment [qparams_db.requestedSchema[0]]) # requestedSchemas for record in response: yield record def fetch_biosamples_by_variant(qparams_db, datasets, authenticated): return _fetch_biosamples(qparams_db, datasets, authenticated, variant_id=qparams_db.targetIdReq) def fetch_biosamples_by_biosample(qparams_db, datasets, authenticated): return _fetch_biosamples(qparams_db, datasets, authenticated, biosample_stable_id=qparams_db.targetIdReq) def fetch_biosamples_by_individual(qparams_db, datasets, authenticated): return _fetch_biosamples(qparams_db, datasets, authenticated, individual_stable_id=qparams_db.targetIdReq) def count_variants_by_variant(qparams_db, datasets, authenticated): return _count_variants(qparams_db, datasets, authenticated, variant_id=qparams_db.targetIdReq) def count_variants_by_biosample(qparams_db, datasets, authenticated): return _count_variants(qparams_db, datasets, authenticated, biosample_stable_id=qparams_db.targetIdReq) def count_variants_by_individual(qparams_db, datasets, authenticated): return _count_variants(qparams_db, datasets, authenticated, individual_stable_id=qparams_db.targetIdReq) def count_individuals_by_variant(qparams_db, datasets, authenticated): return _count_individuals(qparams_db, datasets, authenticated, variant_id=qparams_db.targetIdReq) def count_individuals_by_biosample(qparams_db, datasets, authenticated): return _count_individuals(qparams_db, datasets, authenticated, biosample_stable_id=qparams_db.targetIdReq) def count_individuals_by_individual(qparams_db, datasets, authenticated): return _count_individuals(qparams_db, datasets, authenticated, individual_stable_id=qparams_db.targetIdReq) def count_biosamples_by_variant(qparams_db, datasets, authenticated): return _count_biosamples(qparams_db, datasets, authenticated, variant_id=qparams_db.targetIdReq) def count_biosamples_by_biosample(qparams_db, datasets, authenticated): return _count_biosamples(qparams_db, datasets, authenticated, biosample_stable_id=qparams_db.targetIdReq) def count_biosamples_by_individual(qparams_db, datasets, authenticated): return _count_biosamples(qparams_db, datasets, authenticated, individual_stable_id=qparams_db.targetIdReq) @pool.coroutine_execute async def _count_variants(connection, qparams_db, datasets, authenticated, variant_id=None, biosample_stable_id=None, individual_stable_id=None): LOG.info('Retrieving viral variant count') # We want just the names, not the formatting functions requested_schemas = [qparams_db.requestedSchema[0], qparams_db.requestedAnnotationSchema[0]] dollars = ", ".join([ f"${i}" for i in range(1, 18)]) # 1..16 LOG.debug("dollars: %s", dollars) query = f"SELECT * FROM {conf.database_schema}.count_gvariants({dollars});" LOG.debug("QUERY: %s", query) statement = await connection.prepare(query) return await statement.fetchval(qparams_db.variantType, # _variant_type text, qparams_db.start[0] if len(qparams_db.start) == 1 else None, # _start integer, qparams_db.start[0] if len(qparams_db.start) > 1 else None, # _start_min integer, qparams_db.start[1] if len(qparams_db.start) > 1 else None, # _start_max integer, qparams_db.end[0] if len(qparams_db.end) == 1 else None, # _end integer, qparams_db.end[0] if len(qparams_db.end) > 1 else None, # _end_min integer, qparams_db.end[1] if len(qparams_db.end) > 1 else None, # _end_max integer, qparams_db.referenceName, # qparams_db.referenceName, # _chromosome character varying, qparams_db.referenceBases, # _reference_bases text, qparams_db.alternateBases, # _alternate_bases text, qparams_db.assemblyId.lower() if qparams_db.assemblyId else None, #qparams_db.assemblyId, # _reference_genome text, datasets, #qparams_db.datasets[0], # _dataset_ids text[], authenticated, #qparams_db.datasets[1], # _is_authenticated bool, biosample_stable_id, # _biosample_stable_id text, individual_stable_id, # _individual_stable_id text, int(variant_id) if variant_id else None, # _gvariant_id qparams_db.filters, # requestedSchemas column=0) @pool.coroutine_execute async def _count_individuals(connection, qparams_db, datasets, authenticated, variant_id=None, biosample_stable_id=None, individual_stable_id=None): """ Contacts the DB to fetch the info. Returns a pd.DataFrame with the response. """ LOG.info('Retrieving viral individuals count') # connection.add_log_listener(simple_listener) dollars = ", ".join([f"${i}" for i in range(1, 18)]) # 1..16 query = f"SELECT * FROM {conf.database_schema}.count_individuals({dollars});" LOG.debug("QUERY: %s", query) statement = await connection.prepare(query) return await statement.fetchval(qparams_db.variantType, # _variant_type text, qparams_db.start[0] if len(qparams_db.start) == 1 else None, # _start integer, qparams_db.start[0] if len(qparams_db.start) > 1 else None, # _start_min integer, qparams_db.start[1] if len(qparams_db.start) > 1 else None, # _start_max integer, qparams_db.end[0] if len(qparams_db.end) == 1 else None, # _end integer, qparams_db.end[0] if len(qparams_db.end) > 1 else None, # _end_min integer, qparams_db.end[1] if len(qparams_db.end) > 1 else None, # _end_max integer, qparams_db.referenceName, # reference_name qparams_db.referenceBases, qparams_db.alternateBases, qparams_db.assemblyId.lower() if qparams_db.assemblyId else None, # assembly_id datasets, # dataset_stable_ids authenticated, #is_authenticated biosample_stable_id, individual_stable_id, # individual_stable_id int(variant_id) if variant_id else None, qparams_db.filters, # requestedSchemas column=0) @pool.coroutine_execute async def _count_biosamples(connection, qparams_db, datasets, authenticated, variant_id=None, biosample_stable_id=None, individual_stable_id=None): LOG.info('Retrieving viral biosample count') dollars = ", ".join([ f"${i}" for i in range(1, 18)]) # 1..17 # LOG.debug("dollars: %s", dollars) query = f"SELECT * FROM {conf.database_schema}.count_samples({dollars});" LOG.debug("QUERY: %s", query) statement = await connection.prepare(query) return await statement.fetchval(qparams_db.variantType, # _variant_type text, qparams_db.start[0] if len(qparams_db.start) == 1 else None, # _start integer, qparams_db.start[0] if len(qparams_db.start) > 1 else None, # _start_min integer, qparams_db.start[1] if len(qparams_db.start) > 1 else None, # _start_max integer, qparams_db.end[0] if len(qparams_db.end) == 1 else None, # _end integer, qparams_db.end[0] if len(qparams_db.end) > 1 else None, # _end_min integer, qparams_db.end[1] if len(qparams_db.end) > 1 else None, # _end_max integer, qparams_db.referenceName, # reference_name qparams_db.referenceBases, qparams_db.alternateBases, qparams_db.assemblyId.lower() if qparams_db.assemblyId else None, # assembly_id datasets, # dataset_stable_ids authenticated, #is_authenticated biosample_stable_id, individual_stable_id, # individual_stable_id int(variant_id) if variant_id else None, qparams_db.filters, # requestedSchemas column=0) def fetch_cohorts_by_cohort(qparams_db, datasets, authenticated): return _fetch_cohort(qparams_db, datasets, authenticated, cohort_id=qparams_db.targetIdReq) @pool.asyncgen_execute async def _fetch_cohort(connection, qparams_db, datasets, authenticated, cohort_id=None): LOG.info('Retrieving cohort information') if cohort_id is None: # Build query query = f"SELECT * FROM {conf.database_schema}.cohort" # Execute statement = await connection.prepare(query) response = await statement.fetch() # requestedSchemas for record in response: yield record else: # Build query query = f"SELECT * FROM {conf.database_schema}.cohort WHERE id = $1;" # Execute statement = await connection.prepare(query) response = await statement.fetch(int(cohort_id)) # requestedSchemas for record in response: yield record LOG.debug("QUERY: %s", query) @pool.coroutine_execute async def _count_cohorts(connection, qparams_db, datasets, authenticated, cohort_id=None): LOG.info('Counting cohorts fetched') if cohort_id is None: # Build query query = f"SELECT COUNT(*) FROM {conf.database_schema}.cohort" LOG.debug("QUERY: %s", query) # Execute statement = await connection.prepare(query) return await statement.fetchval(column=0) else: # Build query query = f"SELECT COUNT(*) FROM {conf.database_schema}.cohort WHERE id = $1;" LOG.debug("QUERY: %s", query) # Execute statement = await connection.prepare(query) return await statement.fetchval(int(cohort_id), column=0) def count_cohorts_by_cohort(qparams_db, datasets, authenticated): return _count_cohorts(qparams_db, datasets, authenticated, cohort_id=qparams_db.targetIdReq)
50.306477
153
0.587897
3,402
31,844
5.285126
0.104938
0.103115
0.049166
0.080089
0.765851
0.748943
0.732202
0.723081
0.685373
0.663682
0
0.007078
0.330078
31,844
632
154
50.386076
0.835747
0.153216
0
0.589862
0
0
0.103944
0.024953
0
0
0
0
0
1
0.050691
false
0.002304
0.020737
0.046083
0.152074
0
0
0
0
null
0
0
0
0
1
1
1
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
4
73e00f6413bda8ae21e75eca5fe50abd11d4725b
467
py
Python
push_tester/utils/errors.py
DBeath/push-tester
1851e28f5bdadc4d0f94ab2f88b0d39660196e02
[ "MIT" ]
null
null
null
push_tester/utils/errors.py
DBeath/push-tester
1851e28f5bdadc4d0f94ab2f88b0d39660196e02
[ "MIT" ]
null
null
null
push_tester/utils/errors.py
DBeath/push-tester
1851e28f5bdadc4d0f94ab2f88b0d39660196e02
[ "MIT" ]
null
null
null
from flask import render_template def add_errorhandlers(app): """Adds default errorhandlers to app""" @app.errorhandler(404) def not_found(e): return render_template("errors/404.html"), 404 @app.errorhandler(403) def forbidden(e): return render_template("errors/403.html"), 403 @app.errorhandler(500) def internal_server_error(e): app.logger.exception(e) return render_template("errors/500.html"), 500
24.578947
54
0.678801
60
467
5.15
0.466667
0.18123
0.126214
0.203884
0.262136
0
0
0
0
0
0
0.072581
0.203426
467
18
55
25.944444
0.758065
0.070664
0
0
0
0
0.10514
0
0
0
0
0
0
1
0.333333
false
0
0.083333
0.166667
0.666667
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
1
1
0
0
4
73e4e080c6725b3666a23f9dec9b5a30e90748d2
171
py
Python
Lista5_02.py
neet1810/Lista5_Python
aee33c8f304a737587d28fa48b04be3c93cdafd3
[ "MIT" ]
1
2018-09-16T22:36:58.000Z
2018-09-16T22:36:58.000Z
Lista5_02.py
NormanDeveloper/Lista5_Python
eb4ef7f51a185216f97d70ef46bdf4b238ce2f75
[ "MIT" ]
null
null
null
Lista5_02.py
NormanDeveloper/Lista5_Python
eb4ef7f51a185216f97d70ef46bdf4b238ce2f75
[ "MIT" ]
1
2020-09-30T16:42:23.000Z
2020-09-30T16:42:23.000Z
def executar(n, lista): for i in range(n): lista += str(i + 1) + "\t" print(lista) lista = '' n = int(input("Digite n: ")) executar(n, lista)
21.375
36
0.497076
25
171
3.4
0.6
0.211765
0.329412
0
0
0
0
0
0
0
0
0.008547
0.315789
171
7
37
24.428571
0.717949
0
0
0
0
0
0.073171
0
0
0
0
0
0
1
0.142857
false
0
0
0
0.142857
0.142857
1
0
0
null
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
0
0
0
0
0
0
4
73f5eeac46dd0be37181acf08d03a98b1c034f6b
333
py
Python
src/main/contribution_stats.py
ferzerkerx/git-greenseer
5e5a054a366ac6295a0d7b977bc44f7923da7291
[ "MIT" ]
3
2015-10-02T19:37:44.000Z
2016-11-01T19:06:13.000Z
src/main/contribution_stats.py
ferzerkerx/git-greenseer
5e5a054a366ac6295a0d7b977bc44f7923da7291
[ "MIT" ]
null
null
null
src/main/contribution_stats.py
ferzerkerx/git-greenseer
5e5a054a366ac6295a0d7b977bc44f7923da7291
[ "MIT" ]
null
null
null
__author__ = 'fmontes' class ContributionStats: def __init__(self, contributor_name, line_count): self.contributor_name = contributor_name self.contributed_lines = line_count def average(self, total_lines_to_consider=1): return float(self.contributed_lines) / float(total_lines_to_consider) * 100
27.75
83
0.744745
40
333
5.675
0.525
0.198238
0.167401
0.176211
0
0
0
0
0
0
0
0.014652
0.18018
333
11
84
30.272727
0.81685
0
0
0
0
0
0.021021
0
0
0
0
0
0
1
0.285714
false
0
0
0.142857
0.571429
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
1
1
0
0
4
fb6a32ae1ef5d7b5d0d5821c7c9b4244fbc7b9a7
489
py
Python
01_Data_Types_And_Variables/05_dirty_dictionaries.py
DetainedDeveloper/Pimp-My-Python
8c0749013581bebd65b3df67f92605c4ecd8e685
[ "MIT" ]
1
2021-07-01T10:54:45.000Z
2021-07-01T10:54:45.000Z
01_Data_Types_And_Variables/05_dirty_dictionaries.py
DetainedDeveloper/Pimp-My-Python
8c0749013581bebd65b3df67f92605c4ecd8e685
[ "MIT" ]
null
null
null
01_Data_Types_And_Variables/05_dirty_dictionaries.py
DetainedDeveloper/Pimp-My-Python
8c0749013581bebd65b3df67f92605c4ecd8e685
[ "MIT" ]
null
null
null
# print({"1": "one", "2": "two", "3": "three"}) # print({1: "one", 2: "two", 3: "three"}) # print({"1": "one", 2: "two", True: "three"}) # START # my_dict = {"1": "one", 2: "two", True: "three", False: "four"} # print(my_dict["1"]) # print(my_dict[2]) # print(my_dict[True]) # print(my_dict[1]) # print(my_dict[0]) # print(my_dict.items()) # print(my_dict.keys()) # print(my_dict.values()) # my_dict["1"] = "Jay" # print(my_dict) # my_dict.pop(2) # print(my_dict) # END
12.868421
64
0.543967
79
489
3.202532
0.253165
0.3083
0.434783
0.126482
0.486166
0.486166
0.383399
0.201581
0.201581
0.201581
0
0.039216
0.165644
489
37
65
13.216216
0.580882
0.885481
0
null
0
null
0
0
null
0
0
0
null
1
null
true
0
0
null
null
null
0
0
0
null
1
1
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
4
fbd87a48a59d3a6d0baf4c5a02113c5586a4eb76
357
py
Python
solutions/airline_trend.py
dianequillao/timeseries
f5d91394c1944f4c03b30bf16a4c3bf3a8269c62
[ "MIT" ]
null
null
null
solutions/airline_trend.py
dianequillao/timeseries
f5d91394c1944f4c03b30bf16a4c3bf3a8269c62
[ "MIT" ]
null
null
null
solutions/airline_trend.py
dianequillao/timeseries
f5d91394c1944f4c03b30bf16a4c3bf3a8269c62
[ "MIT" ]
null
null
null
stats = airline[['Year', 'Passengers']].groupby('Year').mean() stats['Max'] = airline[['Year', 'Passengers']].groupby('Year').max() stats['Min'] = airline[['Year', 'Passengers']].groupby('Year').min() stats['Range'] = stats['Max']-stats['Min'] ax = stats.plot(y='Passengers', yerr='Range', legend=False) ax.set_ylabel(r'$\langle Passengers\rangle$') stats
39.666667
68
0.658263
46
357
5.086957
0.434783
0.141026
0.269231
0.358974
0.410256
0
0
0
0
0
0
0
0.067227
357
9
69
39.666667
0.702703
0
0
0
0
0
0.315642
0
0
0
0
0
0
1
0
false
0.714286
0
0
0
0
0
0
0
null
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
null
0
0
0
0
0
0
0
1
0
0
0
0
0
4