uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
b8cff101872ef468415fcaa9
train
function
@pytest.fixture(scope="session", name="test_citibuy") def fixture_citibuy(): """Creates an instance of the CitiBuy class for integration testing""" return CitiBuy()
@pytest.fixture(scope="session", name="test_citibuy") def fixture_citibuy():
"""Creates an instance of the CitiBuy class for integration testing""" return CitiBuy()
import pytest import sqlalchemy from dgs_fiscal.systems import CitiBuy @pytest.fixture(scope="session", name="test_citibuy") def fixture_citibuy():
38
64
40
21
16
department-of-general-services/priority-vendor-aging-report
app/tests/integration_tests/citibuy/test_client.py
Python
fixture_citibuy
fixture_citibuy
7
10
7
8
0cc7337ef4b26ec477fe5ab319cf64c3ae307aa9
bigcode/the-stack
train
961da6496b07785edfb98b9e
train
function
@pytest.fixture def FakeWebscrape(): fake_policy = mock.MagicMock() fake_e = Web_Scraping(fake_policy) fake_e._meta_data['bigip'].tmos_version = '12.0.0' return fake_e
@pytest.fixture def FakeWebscrape():
fake_policy = mock.MagicMock() fake_e = Web_Scraping(fake_policy) fake_e._meta_data['bigip'].tmos_version = '12.0.0' return fake_e
or implied. # See the License for the specific language governing permissions and # limitations under the License. # from f5.bigip.tm.asm.policies.web_scraping import Web_Scraping from f5.sdk_exception import UnsupportedOperation import mock import pytest @pytest.fixture def FakeWebscrape():
64
64
55
9
54
nghia-tran/f5-common-python
f5/bigip/tm/asm/policies/test/unit/test_web_scraping.py
Python
FakeWebscrape
FakeWebscrape
24
29
24
25
7b8e42c0b3322b1b73553113abc478e1fb33f3eb
bigcode/the-stack
train
78cc4773bdcb83af496e5a8a
train
class
class TestWebScraping(object): def test_update_raises(self, FakeWebscrape): with pytest.raises(UnsupportedOperation): FakeWebscrape.update()
class TestWebScraping(object):
def test_update_raises(self, FakeWebscrape): with pytest.raises(UnsupportedOperation): FakeWebscrape.update()
pytest @pytest.fixture def FakeWebscrape(): fake_policy = mock.MagicMock() fake_e = Web_Scraping(fake_policy) fake_e._meta_data['bigip'].tmos_version = '12.0.0' return fake_e class TestWebScraping(object):
64
64
35
7
56
nghia-tran/f5-common-python
f5/bigip/tm/asm/policies/test/unit/test_web_scraping.py
Python
TestWebScraping
TestWebScraping
32
35
32
32
91bbb5fd5ad33f3410058ea8aca083bc7dc02513
bigcode/the-stack
train
9f6854a6c4a1213bc9a1bef3
train
class
class AuditorWorker(object): """Walk through file system to audit object""" def __init__(self, conf, logger, zero_byte_only_at_fps=0): self.conf = conf self.logger = logger self.devices = conf.get('devices', '/srv/node') self.mount_check = config_true_value(conf.get('mount_check...
class AuditorWorker(object):
"""Walk through file system to audit object""" def __init__(self, conf, logger, zero_byte_only_at_fps=0): self.conf = conf self.logger = logger self.devices = conf.get('devices', '/srv/node') self.mount_check = config_true_value(conf.get('mount_check', 'true')) self.max_...
# Copyright (c) 2010-2012 OpenStack, LLC. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to ...
252
256
1,800
5
246
navidshaikh/swift
swift/obj/auditor.py
Python
AuditorWorker
AuditorWorker
33
212
33
33
969676a8b6a5648118753dee3b972ae1fafc159d
bigcode/the-stack
train
59b64e361b00451a77dc970e
train
class
class ObjectAuditor(Daemon): """Audit objects.""" def __init__(self, conf, **options): self.conf = conf self.logger = get_logger(conf, log_route='object-auditor') self.conf_zero_byte_fps = int( conf.get('zero_byte_files_per_second', 50)) def _sleep(self): time.s...
class ObjectAuditor(Daemon):
"""Audit objects.""" def __init__(self, conf, **options): self.conf = conf self.logger = get_logger(conf, log_route='object-auditor') self.conf_zero_byte_fps = int( conf.get('zero_byte_files_per_second', 50)) def _sleep(self): time.sleep(SLEEP_BETWEEN_AUDITS) ...
'be quarantined: %(err)s'), {'obj': path, 'err': err}) diskfile.quarantine_renamer( os.path.join(self.devices, device), path) return except (Exception, Timeout): self.logger.increment('errors') ...
98
98
327
8
89
navidshaikh/swift
swift/obj/auditor.py
Python
ObjectAuditor
ObjectAuditor
215
252
215
215
893da36bd2a49ec32d35765dbc399ba37aff2ae3
bigcode/the-stack
train
df9a24c6e0d8dfcdaea7db82
train
class
class Dialog: def __init__(self, filter=DIALOGFILTER): self.names = [] # DIALOGFILTER = 'Airfoil contour files (*.dat *.txt)' self.filter = filter def saveFilename(self, filename=None): """Summary Args: filename (None, optional): If given, then...
class Dialog:
def __init__(self, filter=DIALOGFILTER): self.names = [] # DIALOGFILTER = 'Airfoil contour files (*.dat *.txt)' self.filter = filter def saveFilename(self, filename=None): """Summary Args: filename (None, optional): If given, then it is displayed ...
from Settings import DIALOGFILTER, OUTPUTDATA, AIRFOILDATA from PySide2 import QtWidgets class Dialog:
27
74
247
3
23
livino/PyAero
src/FileDialog.py
Python
Dialog
Dialog
7
53
7
8
4df827a3000e0a1934576e30854996b4e90e42b5
bigcode/the-stack
train
2a4ebda5234c3512c3fc6ee3
train
class
class PriceMonth(ListView): model=models.Month
class PriceMonth(ListView):
model=models.Month
class PriceHome(ListView): model=models.Hour template_name='bitcoin/spotprice_list.html' class PriceHour(ListView): model=models.Hour class PriceDay(ListView): model=models.Day class PriceWeek(ListView): model=models.Week class PriceMonth(ListView):
64
64
11
6
57
neelarya19/CryptoPrice
bitcoin/views.py
Python
PriceMonth
PriceMonth
20
21
20
20
6a438821d264b3945b5109cc759ec91b80cd6acf
bigcode/the-stack
train
651053937e049751f1ac86c6
train
class
class PriceWeek(ListView): model=models.Week
class PriceWeek(ListView):
model=models.Week
.views.generic import TemplateView,ListView from . import models class PriceHome(ListView): model=models.Hour template_name='bitcoin/spotprice_list.html' class PriceHour(ListView): model=models.Hour class PriceDay(ListView): model=models.Day class PriceWeek(ListView):
64
64
12
6
57
neelarya19/CryptoPrice
bitcoin/views.py
Python
PriceWeek
PriceWeek
17
18
17
17
e357d1a169e4147398ee1fe564d796da74543dcd
bigcode/the-stack
train
6d345279aa97ffbac5ece18b
train
class
class PriceYear(ListView): model=models.Year
class PriceYear(ListView):
model=models.Year
template_name='bitcoin/spotprice_list.html' class PriceHour(ListView): model=models.Hour class PriceDay(ListView): model=models.Day class PriceWeek(ListView): model=models.Week class PriceMonth(ListView): model=models.Month class PriceYear(ListView):
64
64
11
6
57
neelarya19/CryptoPrice
bitcoin/views.py
Python
PriceYear
PriceYear
23
24
23
23
109b5ca18879a3f5f979a63f9ee23268f148fcdf
bigcode/the-stack
train
7080df75e34b984d460e3f22
train
class
class PriceHome(ListView): model=models.Hour template_name='bitcoin/spotprice_list.html'
class PriceHome(ListView):
model=models.Hour template_name='bitcoin/spotprice_list.html'
# Create your views here. from django.shortcuts import render from django.views.generic import TemplateView,ListView from . import models class PriceHome(ListView):
33
64
22
6
26
neelarya19/CryptoPrice
bitcoin/views.py
Python
PriceHome
PriceHome
7
9
7
7
3f1a4c9e7f203948305b77ab167980aa6f91c5f0
bigcode/the-stack
train
81a65c686222565dfb4ebdf1
train
class
class PriceHour(ListView): model=models.Hour
class PriceHour(ListView):
model=models.Hour
# Create your views here. from django.shortcuts import render from django.views.generic import TemplateView,ListView from . import models class PriceHome(ListView): model=models.Hour template_name='bitcoin/spotprice_list.html' class PriceHour(ListView):
55
64
11
6
49
neelarya19/CryptoPrice
bitcoin/views.py
Python
PriceHour
PriceHour
11
12
11
11
669263c7d33991fb8b35830d4492eb22a4910d69
bigcode/the-stack
train
1299353bcbc5eff4505150ab
train
class
class PriceDay(ListView): model=models.Day
class PriceDay(ListView):
model=models.Day
views here. from django.shortcuts import render from django.views.generic import TemplateView,ListView from . import models class PriceHome(ListView): model=models.Hour template_name='bitcoin/spotprice_list.html' class PriceHour(ListView): model=models.Hour class PriceDay(ListView):
64
64
11
6
57
neelarya19/CryptoPrice
bitcoin/views.py
Python
PriceDay
PriceDay
14
15
14
14
07b6242d0d5e7149e5982df16a071e487a3c1480
bigcode/the-stack
train
9581429b9a2d8119305d0956
train
function
def parse_index(): files = [] for file in BASE_DIR.rglob('*.md'): if file not in files: files.append(file) while file.parent != BASE_DIR: file = file.parent if file not in files: files.append(file) with open(BASE_DIR.parent / '_sidebar.md'...
def parse_index():
files = [] for file in BASE_DIR.rglob('*.md'): if file not in files: files.append(file) while file.parent != BASE_DIR: file = file.parent if file not in files: files.append(file) with open(BASE_DIR.parent / '_sidebar.md', 'w', encoding='ut...
/536 from pathlib import Path from urllib import parse BASE_DIR = Path(__file__).with_name('docs') def get_level(p): i = 0 while p.parent != BASE_DIR: p = p.parent i += 1 return i def parse_index():
64
64
180
4
59
536/my-notes
parse_index.py
Python
parse_index
parse_index
19
37
19
19
e41b322761220972d54ac062d3445ef2525b45dc
bigcode/the-stack
train
d7717297349fa3cb5c1bb16c
train
function
def get_level(p): i = 0 while p.parent != BASE_DIR: p = p.parent i += 1 return i
def get_level(p):
i = 0 while p.parent != BASE_DIR: p = p.parent i += 1 return i
# -*- coding: utf-8 -*- # @Date : 2021/7/12 21:14 # @Author : https://github.com/536 from pathlib import Path from urllib import parse BASE_DIR = Path(__file__).with_name('docs') def get_level(p):
64
64
35
5
59
536/my-notes
parse_index.py
Python
get_level
get_level
11
16
11
11
72dac4642e2a85fb218526a6a123c41ed8380655
bigcode/the-stack
train
fb781ed194f9c4c3cae0f978
train
function
def get_mode(collection_type, time_format, start_at): """ 从采集类型和时间格式确定采集模式 :param collection_type: 采集类型 :param time_format: 时间格式 :return: 采集模式 """ # mode 取值范围: timestamp, ts.milliseconds, ts.seconds, ts.minutes, incrementing # 新增 mode 范围: historyAndPeriod.timestamp / historyAndPeriod.inc...
def get_mode(collection_type, time_format, start_at):
""" 从采集类型和时间格式确定采集模式 :param collection_type: 采集类型 :param time_format: 时间格式 :return: 采集模式 """ # mode 取值范围: timestamp, ts.milliseconds, ts.seconds, ts.minutes, incrementing # 新增 mode 范围: historyAndPeriod.timestamp / historyAndPeriod.incrementing if start_at == COLLECTION_TYPE_HISTORY_P...
= "historyAndPeriod.incrementing" MODE_HISTORY_PERIOD_TIMESTAMP = "historyAndPeriod.timestamp" # 时间格式 TIME_FORMAT_UNIX_TIMESTAMP_M = "Unix Time Stamp(mins)" TIME_FORMAT_UNIX_TIMESTAMP_S = "Unix Time Stamp(seconds)" TIME_FORMAT_UNIX_TIMESTAMP_MS = "Unix Time Stamp(mins)" def get_mode(collection_type, time_format, star...
76
77
258
12
64
Chromico/bk-base
src/api/datahub/databus/task/jdbc.py
Python
get_mode
get_mode
48
76
48
48
4ed42dbfcd6599963f232ab1051c6533ef059373
bigcode/the-stack
train
6ae0f45393ece716b017b3ee
train
function
@app.route('/get_related_products', methods=["POST"]) def recommend_products(): data = json.loads(request.get_data()) product_id = data['product_id'] product_ids, similarities = cb_m1_recommend(product_id, 10) return jsonify({'ids': product_ids, 'sims': similarities})
@app.route('/get_related_products', methods=["POST"]) def recommend_products():
data = json.loads(request.get_data()) product_id = data['product_id'] product_ids, similarities = cb_m1_recommend(product_id, 10) return jsonify({'ids': product_ids, 'sims': similarities})
from flask import Flask, request, jsonify import json from recommendation_methods import cb_m1_recommend app = Flask(__name__) @app.route('/get_related_products', methods=["POST"]) def recommend_products():
43
64
65
15
28
asimokby/recommendation-system-Hepsiburada
api_example/flask_api.py
Python
recommend_products
recommend_products
8
13
8
9
031cb0f7d37449c49722f7f39736b3c1e30b3db8
bigcode/the-stack
train
5d291a0208ae3d4afa54525d
train
function
def main(): os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'StoryHub.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on yo...
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'StoryHub.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPAT...
#!/usr/bin/env python """Django's command-line utility for administrative tasks.""" import os import sys def main():
26
64
93
3
22
lbb4511/storyhub
manage.py
Python
main
main
7
17
7
7
19e336715ea7dfefed15364ce72bf260fb2a2e50
bigcode/the-stack
train
705504db401213668f3dd6a5
train
function
def sample_program_configs(draw): in_shape = draw(st.lists(st.integers(min_value=1, max_value=8), min_size=4, max_size=4)) is_test_val = draw(st.sampled_from([True, False])) epsilon = draw(st.floats(min_value=0.00001, max_value=0.001)) momentum = draw(st.floats(min_value=0.1, max_value=0.9)) def ge...
def sample_program_configs(draw):
in_shape = draw(st.lists(st.integers(min_value=1, max_value=8), min_size=4, max_size=4)) is_test_val = draw(st.sampled_from([True, False])) epsilon = draw(st.floats(min_value=0.00001, max_value=0.001)) momentum = draw(st.floats(min_value=0.1, max_value=0.9)) def generate_input(*args, **kwargs): ...
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 per...
163
163
545
6
156
laiou/Paddle-Lite
lite/tests/unittest_py/op/common/test_batch_norm_op_base.py
Python
sample_program_configs
sample_program_configs
27
85
27
27
a958e67ada15bb5a1379b9f6c0faa374217f7e43
bigcode/the-stack
train
d9fd693d1e91b3a1b49b15ce
train
function
def get_session_uids(): if 'i' in session: #TEMPORARY get_session(session['i']) if 'sessions' in session: return [item['uid'] for item in session['sessions'].values()] return []
def get_session_uids():
if 'i' in session: #TEMPORARY get_session(session['i']) if 'sessions' in session: return [item['uid'] for item in session['sessions'].values()] return []
if key_logged is not None: session['sessions'][i]['key_logged'] = key_logged if chatstatus is not None: session['sessions'][i]['chatstatus'] = chatstatus session.modified = True return session['sessions'][i] def get_session_uids():
64
64
53
6
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
get_session_uids
get_session_uids
1,089
1,094
1,089
1,089
494c7b1874faf1efa893616ed311fe04b13ea63a
bigcode/the-stack
train
4d672ed14b23907757588fd3
train
function
def decrypt_object(obj_string, secret): obj_string = bytearray(obj_string, encoding='utf-8') decrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, obj_string[:16]) return fix_pickle_obj(unpad(decrypter.decrypt(codecs.decode(obj_string[16:], 'base64'))))
def decrypt_object(obj_string, secret):
obj_string = bytearray(obj_string, encoding='utf-8') decrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, obj_string[:16]) return fix_pickle_obj(unpad(decrypter.decrypt(codecs.decode(obj_string[16:], 'base64'))))
random_bytes(16) encrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, iv) return (iv + codecs.encode(encrypter.encrypt(pad(pickle.dumps(safe_pickle(obj)))), 'base64')).decode() def decrypt_object(obj_string, secret):
64
64
74
8
56
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
decrypt_object
decrypt_object
467
470
467
467
4ea0e6be156765e4e5173788f51d33f0852f70b6
bigcode/the-stack
train
516ff268636d9a4ab198fc5e
train
function
def directory_for(area, current_project): if current_project == 'default': return area.directory else: return os.path.join(area.directory, current_project)
def directory_for(area, current_project):
if current_project == 'default': return area.directory else: return os.path.join(area.directory, current_project)
True return False def project_name(name): return '' if name == 'default' else name def add_project(filename, current_project): if current_project == 'default': return filename else: return os.path.join(current_project, filename) def directory_for(area, current_project):
64
64
35
8
56
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
directory_for
directory_for
126
130
126
126
d7d7e97cccceab95b2ba99b50cd26b84bd6a2572
bigcode/the-stack
train
8a41b1e83e6a90c22196b386
train
function
def nice_utc_date(timestamp, timezone=tz.tzlocal()): return timestamp.strftime('%F %T')
def nice_utc_date(timestamp, timezone=tz.tzlocal()):
return timestamp.strftime('%F %T')
: return None return the_object def nice_date_from_utc(timestamp, timezone=tz.tzlocal()): return timestamp.replace(tzinfo=tz.tzutc()).astimezone(timezone).strftime('%x %X') def nice_utc_date(timestamp, timezone=tz.tzlocal()):
64
64
23
14
50
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
nice_utc_date
nice_utc_date
562
563
562
562
1791e14f52a05a0e7d1ef7c269d5149a3c51a70b
bigcode/the-stack
train
d6a23d1eff9f695be90c25e4
train
function
def unpack_phrase(phrase_string): return codecs.decode(bytearray(phrase_string, encoding='utf-8'), 'base64').decode('utf-8')
def unpack_phrase(phrase_string):
return codecs.decode(bytearray(phrase_string, encoding='utf-8'), 'base64').decode('utf-8')
8') decrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, phrase_string[:16]) return unpad(decrypter.decrypt(codecs.decode(phrase_string[16:], 'base64'))).decode('utf-8') def unpack_phrase(phrase_string):
64
64
33
7
57
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
unpack_phrase
unpack_phrase
447
448
447
447
21e9414ef9236075dfbab0fec78336f7ad0f98b5
bigcode/the-stack
train
59e67a3d257a419c625a86ea
train
function
def sql_get(key, secret=None): for record in GlobalObjectStorage.query.filter_by(key=key): if record.encrypted: try: result = decrypt_object(record.value, secret) except: raise Exception("Unable to decrypt stored object.") else: try...
def sql_get(key, secret=None):
for record in GlobalObjectStorage.query.filter_by(key=key): if record.encrypted: try: result = decrypt_object(record.value, secret) except: raise Exception("Unable to decrypt stored object.") else: try: result = unpa...
.functions.this_thread.misc: kwargs['_external'] = True if pargs[0] == 'index': kwargs['js_target'] = docassemble.base.functions.this_thread.misc['jsembed'] return base_url_for(*pargs, **kwargs) def sql_get(key, secret=None):
64
64
89
8
56
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
sql_get
sql_get
217
230
217
217
0606f22986c663a85c8bdc3ee09c2ee555ee88bf
bigcode/the-stack
train
4032f0555f7ee7219f3980f8
train
function
def unpack_dictionary(dict_string): dict_string = codecs.decode(bytearray(dict_string, encoding='utf-8'), 'base64') return fix_pickle_dict(dict_string)
def unpack_dictionary(dict_string):
dict_string = codecs.decode(bytearray(dict_string, encoding='utf-8'), 'base64') return fix_pickle_dict(dict_string)
, encoding='utf-8') decrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, dict_string[:16]) return fix_pickle_dict(unpad(decrypter.decrypt(codecs.decode(dict_string[16:], 'base64')))) def unpack_dictionary(dict_string):
64
64
35
6
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
unpack_dictionary
unpack_dictionary
507
509
507
507
2969d201cd06e05475b3668c7810dfc7ac0ead81
bigcode/the-stack
train
ac0dd436537b1fcdd328ff6c
train
function
def is_package_ml(parts): if len(parts) == 3 and parts[0].startswith('docassemble.') and re.match(r'data/sources/.*\.json', parts[1]): return True return False
def is_package_ml(parts):
if len(parts) == 3 and parts[0].startswith('docassemble.') and re.match(r'data/sources/.*\.json', parts[1]): return True return False
playground.fix() try: if write_ml_source(playground, playground_number, current_project, filename, finalize=False): changed = True except: logmessage("Error writing machine learning source file " + str(filename)) if changed: ...
64
64
49
6
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
is_package_ml
is_package_ml
112
115
112
112
3160d921b36a6a4e9761fa6fd55a6ba3c6fb146e
bigcode/the-stack
train
85418b6e3f294747da24771e
train
function
def get_uid_for_filename(i): if 'sessions' not in session: session['sessions'] = dict() if i not in session['sessions']: return None return session['sessions'][i]['uid']
def get_uid_for_filename(i):
if 'sessions' not in session: session['sessions'] = dict() if i not in session['sessions']: return None return session['sessions'][i]['uid']
] delete_obsolete() return None def unattached_uid(): while True: newname = random_alphanumeric(32) existing_key = UserDict.query.filter_by(key=newname).first() if existing_key: continue return newname def get_uid_for_filename(i):
64
64
47
7
56
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
get_uid_for_filename
get_uid_for_filename
1,057
1,062
1,057
1,057
4b3361fee0baf1e396666860249165e93a8bcc38
bigcode/the-stack
train
8dd9c77880cb3e0d53402861
train
function
def pack_dictionary(the_dict): retval = codecs.encode(pickle.dumps(pickleable_objects(the_dict)), 'base64').decode() return retval
def pack_dictionary(the_dict):
retval = codecs.encode(pickle.dumps(pickleable_objects(the_dict)), 'base64').decode() return retval
_object)) return new_set if type(the_object) in [types.ModuleType, types.FunctionType, TypeType, types.BuiltinFunctionType, types.BuiltinMethodType, types.MethodType, types.ClassType, FileType]: return None return the_object def pack_dictionary(the_dict):
64
64
31
6
57
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
pack_dictionary
pack_dictionary
498
500
498
498
98b443d9994f606325d20a49aa97591aad9a2eb5
bigcode/the-stack
train
d689786d450c2c3d229de474
train
function
def get_info_from_file_number_with_uids(*pargs, **kwargs): if 'uids' not in kwargs: kwargs['uids'] = get_session_uids() return get_info_from_file_number(*pargs, **kwargs)
def get_info_from_file_number_with_uids(*pargs, **kwargs):
if 'uids' not in kwargs: kwargs['uids'] = get_session_uids() return get_info_from_file_number(*pargs, **kwargs)
_info_from_file_reference_with_uids(*pargs, **kwargs): if 'uids' not in kwargs: kwargs['uids'] = get_session_uids() return get_info_from_file_reference(*pargs, **kwargs) def get_info_from_file_number_with_uids(*pargs, **kwargs):
64
64
50
16
48
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
get_info_from_file_number_with_uids
get_info_from_file_number_with_uids
271
274
271
271
d996c02ad3b147b0eb32222e8b31c8f618c4d6ba
bigcode/the-stack
train
70aa0c41f5d8aba731ebe7f1
train
function
def nice_date_from_utc(timestamp, timezone=tz.tzlocal()): return timestamp.replace(tzinfo=tz.tzutc()).astimezone(timezone).strftime('%x %X')
def nice_date_from_utc(timestamp, timezone=tz.tzlocal()):
return timestamp.replace(tzinfo=tz.tzutc()).astimezone(timezone).strftime('%x %X')
'attrList']: continue new_dict[key] = safe_json(data, level=level+1) return new_dict try: json.dumps(the_object) except: return None return the_object def nice_date_from_utc(timestamp, timezone=tz.tzlocal()):
64
64
40
15
48
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
nice_date_from_utc
nice_date_from_utc
559
560
559
559
bc54bba293f9788488089802cacb950e75add7a2
bigcode/the-stack
train
3c26a23d8007b4a8a9e680c4
train
function
def clear_specific_session(i, uid): if 'sessions' in session and i in session['sessions']: if session['sessions'][i]['uid'] == uid: del session['sessions'][i]
def clear_specific_session(i, uid):
if 'sessions' in session and i in session['sessions']: if session['sessions'][i]['uid'] == uid: del session['sessions'][i]
== Role.id).filter(UploadsRoleAuth.uploads_indexno == file_number).all(): result.append(auth.name) return result def clear_session(i): if 'sessions' in session and i in session['sessions']: del session['sessions'][i] def clear_specific_session(i, uid):
64
64
43
8
56
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
clear_specific_session
clear_specific_session
1,016
1,019
1,016
1,016
114b0fcd6e111554d19d8211867af158a69ce184
bigcode/the-stack
train
3a79bd4e7d2fcc9f27ef762b
train
function
def unpack_object(the_string): the_string = bytearray(the_string, encoding='utf-8') return fix_pickle_dict(codecs.decode(the_string, 'base64'))
def unpack_object(the_string):
the_string = bytearray(the_string, encoding='utf-8') return fix_pickle_dict(codecs.decode(the_string, 'base64'))
BC, iv) return (iv + codecs.encode(encrypter.encrypt(pad(pickle.dumps(pickleable_objects(the_dict)))), 'base64')).decode() def pack_object(the_object): return codecs.encode(pickle.dumps(safe_pickle(the_object)), 'base64').decode() def unpack_object(the_string):
64
64
36
6
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
unpack_object
unpack_object
458
460
458
458
4ddb3bd058144fdc7ced5702c202f4ceb7af908c
bigcode/the-stack
train
c84452b776edf7794cfcf8e4
train
function
def fetch_user_dict(user_code, filename, secret=None): #logmessage("fetch_user_dict: user_code is " + str(user_code) + " and filename is " + str(filename)) user_dict = None steps = 1 encrypted = True subq = db.session.query(db.func.max(UserDict.indexno).label('indexno'), db.func.count(UserDict.index...
def fetch_user_dict(user_code, filename, secret=None): #logmessage("fetch_user_dict: user_code is " + str(user_code) + " and filename is " + str(filename))
user_dict = None steps = 1 encrypted = True subq = db.session.query(db.func.max(UserDict.indexno).label('indexno'), db.func.count(UserDict.indexno).label('count')).filter(and_(UserDict.key == user_code, UserDict.filename == filename)).subquery() results = [d for d in db.session.query(UserDict.indexn...
.replace(tzinfo=tz.tzutc()).astimezone(timezone).strftime('%x %X') def nice_utc_date(timestamp, timezone=tz.tzlocal()): return timestamp.strftime('%F %T') #@elapsed('fetch_user_dict') def fetch_user_dict(user_code, filename, secret=None): #logmessage("fetch_user_dict: user_code is " + str(user_code) + " and f...
93
93
310
40
53
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
fetch_user_dict
fetch_user_dict
566
589
566
567
2c8db676022d275004db7fc0aa82cda544fc2c6a
bigcode/the-stack
train
be7cb940a57849bd5d400e61
train
function
def elapsed(name_of_function): def elapse_decorator(func): def time_func(*pargs, **kwargs): time_start = time.time() result = func(*pargs, **kwargs) sys.stderr.write(name_of_function + ': ' + str(time.time() - time_start) + "\n") return result return t...
def elapsed(name_of_function):
def elapse_decorator(func): def time_func(*pargs, **kwargs): time_start = time.time() result = func(*pargs, **kwargs) sys.stderr.write(name_of_function + ': ' + str(time.time() - time_start) + "\n") return result return time_func return elapse_deco...
.get('debug', False) #docassemble.base.parse.debug = DEBUG from docassemble.webapp.file_access import get_info_from_file_number, get_info_from_file_reference, reference_exists, url_if_exists from docassemble.webapp.file_number import get_new_file_number import time def elapsed(name_of_function):
64
64
82
6
57
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
elapsed
elapsed
55
63
55
55
9ae943213c4460acea462ed56cea64433194b8f7
bigcode/the-stack
train
cf5ebb4a97edc307daebaf71
train
function
def safe_pickle(the_object): if type(the_object) is list: return [safe_pickle(x) for x in the_object] if type(the_object) is dict: new_dict = dict() for key, value in the_object.items(): new_dict[key] = safe_pickle(value) return new_dict if type(the_object) is set...
def safe_pickle(the_object):
if type(the_object) is list: return [safe_pickle(x) for x in the_object] if type(the_object) is dict: new_dict = dict() for key, value in the_object.items(): new_dict[key] = safe_pickle(value) return new_dict if type(the_object) is set: new_set = set() ...
)([0-9]+)', str(the_user_id)) if m: if m.group(1) == 't': return None, int(m.group(2)) else: return int(m.group(2)), None raise Exception("Invalid user ID") def safe_pickle(the_object):
64
64
157
6
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
safe_pickle
safe_pickle
481
496
481
481
264045046321ec1cad2e2a50a64b5c89d76ca2f2
bigcode/the-stack
train
1017ece379932993a635e464
train
function
def safe_json(the_object, level=0): if level > 20: return None if isinstance(the_object, (str, bool, int, float)): return the_object if isinstance(the_object, list): return [safe_json(x, level=level+1) for x in the_object] if isinstance(the_object, dict): new_dict = dict(...
def safe_json(the_object, level=0):
if level > 20: return None if isinstance(the_object, (str, bool, int, float)): return the_object if isinstance(the_object, list): return [safe_json(x, level=level+1) for x in the_object] if isinstance(the_object, dict): new_dict = dict() for key, value in the_obje...
_dict): retval = codecs.encode(pickle.dumps(pickleable_objects(the_dict)), 'base64').decode() return retval def decrypt_dictionary(dict_string, secret): dict_string = bytearray(dict_string, encoding='utf-8') decrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, dict_string[:16]) re...
146
146
487
10
136
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
safe_json
safe_json
511
557
511
511
88b287d8caf8f493b65dd668d4717f40a29b6d2f
bigcode/the-stack
train
8ea27bc8b55e301921612314
train
function
def pack_phrase(phrase): phrase = bytearray(phrase, encoding='utf-8') return codecs.encode(phrase, 'base64').decode('utf-8')
def pack_phrase(phrase):
phrase = bytearray(phrase, encoding='utf-8') return codecs.encode(phrase, 'base64').decode('utf-8')
utf-8'), AES.MODE_CBC, iv) if isinstance(phrase, str): phrase = bytearray(phrase, 'utf-8') return (iv + codecs.encode(encrypter.encrypt(pad(phrase)), 'base64')).decode('utf-8') def pack_phrase(phrase):
64
64
37
6
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
pack_phrase
pack_phrase
438
440
438
438
9f00c73058f8282c1c3ce0729e36a83c63debd63
bigcode/the-stack
train
2a8b7ae73a7e1a5aaf4dc904
train
function
def add_project(filename, current_project): if current_project == 'default': return filename else: return os.path.join(current_project, filename)
def add_project(filename, current_project):
if current_project == 'default': return filename else: return os.path.join(current_project, filename)
) == 3 and parts[0].startswith('docassemble.') and re.match(r'data/sources/.*\.json', parts[1]): return True return False def project_name(name): return '' if name == 'default' else name def add_project(filename, current_project):
64
64
33
8
55
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
add_project
add_project
120
124
120
120
d5642eea9828b07aa66dca7bd8823718b003ffec
bigcode/the-stack
train
49e64d4b62b8f1fdcaa19920
train
function
def decrypt_dictionary(dict_string, secret): dict_string = bytearray(dict_string, encoding='utf-8') decrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, dict_string[:16]) return fix_pickle_dict(unpad(decrypter.decrypt(codecs.decode(dict_string[16:], 'base64'))))
def decrypt_dictionary(dict_string, secret):
dict_string = bytearray(dict_string, encoding='utf-8') decrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, dict_string[:16]) return fix_pickle_dict(unpad(decrypter.decrypt(codecs.decode(dict_string[16:], 'base64'))))
.BuiltinMethodType, types.MethodType, types.ClassType, FileType]: return None return the_object def pack_dictionary(the_dict): retval = codecs.encode(pickle.dumps(pickleable_objects(the_dict)), 'base64').decode() return retval def decrypt_dictionary(dict_string, secret):
64
64
74
8
55
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
decrypt_dictionary
decrypt_dictionary
502
505
502
502
42da91e619697a7b70696b8d823f9a6c1f25a5d7
bigcode/the-stack
train
4a29dd732ff7aa85e75b7d5c
train
function
def can_access_file_number(file_number, uids=None): upload = Uploads.query.filter(Uploads.indexno == file_number).first() if upload is None: return False if current_user and current_user.is_authenticated and current_user.has_role('admin', 'developer', 'advocate', 'trainer'): return True ...
def can_access_file_number(file_number, uids=None):
upload = Uploads.query.filter(Uploads.indexno == file_number).first() if upload is None: return False if current_user and current_user.is_authenticated and current_user.has_role('admin', 'developer', 'advocate', 'trainer'): return True if not upload.private: return True if ui...
')) and current_user.is_authenticated and not current_user.is_anonymous and current_user.has_role('admin', 'developer') and os.path.dirname(the_file) == os.path.join(UPLOAD_DIRECTORY, 'playground', str(current_user.id)): # return True # return False #docassemble.base.parse.set_absolute_filename(absolute_fi...
98
98
328
12
86
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
can_access_file_number
can_access_file_number
377
400
377
377
5494d149a88da4a048135cdca9f5b1f0bc705df8
bigcode/the-stack
train
7368bab3a34837a3fc08f60d
train
function
def url_for(*pargs, **kwargs): if 'jsembed' in docassemble.base.functions.this_thread.misc: kwargs['_external'] = True if pargs[0] == 'index': kwargs['js_target'] = docassemble.base.functions.this_thread.misc['jsembed'] return base_url_for(*pargs, **kwargs)
def url_for(*pargs, **kwargs):
if 'jsembed' in docassemble.base.functions.this_thread.misc: kwargs['_external'] = True if pargs[0] == 'index': kwargs['js_target'] = docassemble.base.functions.this_thread.misc['jsembed'] return base_url_for(*pargs, **kwargs)
and daconfig['timezone'] is not None: DEFAULT_TIMEZONE = daconfig['timezone'] else: try: DEFAULT_TIMEZONE = tzlocal.get_localzone().zone except: DEFAULT_TIMEZONE = 'America/New_York' def url_for(*pargs, **kwargs):
64
64
78
10
54
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
url_for
url_for
210
215
210
210
64c0ab0b85437596575dac56de65638b5ea3b1d4
bigcode/the-stack
train
af57839ec1d699715c82e537
train
function
def sql_delete(key): GlobalObjectStorage.query.filter_by(key=key).delete() db.session.commit()
def sql_delete(key):
GlobalObjectStorage.query.filter_by(key=key).delete() db.session.commit()
=True, user_id=user_id, temp_user_id=temp_user_id) else: record = GlobalObjectStorage(key=key, value=pack_object(val), encrypted=False, user_id=user_id, temp_user_id=temp_user_id) db.session.add(record) db.session.commit() def sql_delete(key):
64
64
23
5
59
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
sql_delete
sql_delete
258
260
258
258
9e4bd5616af465312d184f844369efaff433355c
bigcode/the-stack
train
a5e523877871ebb9d63d500d
train
function
def project_name(name): return '' if name == 'default' else name
def project_name(name):
return '' if name == 'default' else name
)) if changed: playground.finalize() def is_package_ml(parts): if len(parts) == 3 and parts[0].startswith('docassemble.') and re.match(r'data/sources/.*\.json', parts[1]): return True return False def project_name(name):
64
64
17
5
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
project_name
project_name
117
118
117
117
2a14e7b4e9f25fdee7c2d988ddcb4bc3e3c0b450
bigcode/the-stack
train
9652465575c08ede433fb419
train
function
def user_dict_exists(user_code, filename): result = UserDict.query.filter(and_(UserDict.key == user_code, UserDict.filename == filename)).first() if result: return True return False
def user_dict_exists(user_code, filename):
result = UserDict.query.filter(and_(UserDict.key == user_code, UserDict.filename == filename)).first() if result: return True return False
= unpack_dictionary(d.dictionary) #logmessage("fetch_user_dict: unpacked dictionary") encrypted = False if d.count: steps = d.count break return steps, user_dict, encrypted #@elapsed('user_dict_exists') def user_dict_exists(user_code, filename):
64
64
45
9
55
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
user_dict_exists
user_dict_exists
592
596
592
592
b1b80a9867aa4fbbbbc92938bbb2b7e86c821377
bigcode/the-stack
train
1d36612fdb873aa7a64212aa
train
function
def advance_progress(user_dict, interview): if user_dict['_internal']['progress'] is None: return if hasattr(interview, 'progress_bar_multiplier'): multiplier = interview.progress_bar_multiplier else: multiplier = 0.05 if hasattr(interview, 'progress_bar_method') and interview.pr...
def advance_progress(user_dict, interview):
if user_dict['_internal']['progress'] is None: return if hasattr(interview, 'progress_bar_multiplier'): multiplier = interview.progress_bar_multiplier else: multiplier = 0.05 if hasattr(interview, 'progress_bar_method') and interview.progress_bar_method == 'stepped': next...
Dict.key == user_code, UserDict.filename == filename)).scalar() if max_indexno is not None: UserDict.query.filter_by(indexno=max_indexno).delete() db.session.commit() return fetch_user_dict(user_code, filename, secret=secret) def advance_progress(user_dict, interview):
64
64
158
8
56
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
advance_progress
advance_progress
607
623
607
607
aa91128503b698eab8ab8006818aaca1efb856b3
bigcode/the-stack
train
d767ff7cf668b213a38ec93b
train
function
def clear_session(i): if 'sessions' in session and i in session['sessions']: del session['sessions'][i]
def clear_session(i):
if 'sessions' in session and i in session['sessions']: del session['sessions'][i]
result = list() for auth in db.session.query(UploadsRoleAuth.id, Role.name).join(Role, UploadsRoleAuth.role_id == Role.id).filter(UploadsRoleAuth.uploads_indexno == file_number).all(): result.append(auth.name) return result def clear_session(i):
64
64
27
5
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
clear_session
clear_session
1,012
1,014
1,012
1,012
57008f6581eda427caa85454ee4301470a9ac587
bigcode/the-stack
train
1c7f6cb03a9aca246f50db5e
train
function
def unattached_uid(): while True: newname = random_alphanumeric(32) existing_key = UserDict.query.filter_by(key=newname).first() if existing_key: continue return newname
def unattached_uid():
while True: newname = random_alphanumeric(32) existing_key = UserDict.query.filter_by(key=newname).first() if existing_key: continue return newname
encrypted=session.get('encrypted', True), key_logged=session.get('key_logged', False), chatstatus=session.get('chatstatus', 'off')) if i == session['i']: delete_obsolete() return session['sessions'][i] delete_obsolete() return None def unattached_uid():
64
64
47
5
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
unattached_uid
unattached_uid
1,049
1,055
1,049
1,049
4a254c9a3444569e2b192bd6ca26a5f5f2ee369c
bigcode/the-stack
train
0ec2576eb8112e83b3e9ac5d
train
function
def encrypt_dictionary(the_dict, secret): iv = random_bytes(16) encrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, iv) return (iv + codecs.encode(encrypter.encrypt(pad(pickle.dumps(pickleable_objects(the_dict)))), 'base64')).decode()
def encrypt_dictionary(the_dict, secret):
iv = random_bytes(16) encrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, iv) return (iv + codecs.encode(encrypter.encrypt(pad(pickle.dumps(pickleable_objects(the_dict)))), 'base64')).decode()
crypter.decrypt(codecs.decode(phrase_string[16:], 'base64'))).decode('utf-8') def unpack_phrase(phrase_string): return codecs.decode(bytearray(phrase_string, encoding='utf-8'), 'base64').decode('utf-8') def encrypt_dictionary(the_dict, secret):
64
64
69
8
56
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
encrypt_dictionary
encrypt_dictionary
450
453
450
450
f4c5c842c1cf26b0fd3cb2cd568f68b9fa8605b6
bigcode/the-stack
train
7f18cc8e27840ff7e91f906a
train
function
def encrypt_phrase(phrase, secret): iv = random_bytes(16) encrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, iv) if isinstance(phrase, str): phrase = bytearray(phrase, 'utf-8') return (iv + codecs.encode(encrypter.encrypt(pad(phrase)), 'base64')).decode('utf-8')
def encrypt_phrase(phrase, secret):
iv = random_bytes(16) encrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, iv) if isinstance(phrase, str): phrase = bytearray(phrase, 'utf-8') return (iv + codecs.encode(encrypter.encrypt(pad(phrase)), 'base64')).decode('utf-8')
) % 16), encoding='utf-8') def unpad(the_string): if isinstance(the_string[-1], int): return the_string[0:-the_string[-1]] else: return the_string[0:-ord(the_string[-1])] def encrypt_phrase(phrase, secret):
63
64
87
8
55
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
encrypt_phrase
encrypt_phrase
431
436
431
431
87b48f5ddea821cfb5fab5802b8b211d42c19cc2
bigcode/the-stack
train
9654d2033d186b1af5a86795
train
function
def parse_the_user_id(the_user_id): m = re.match(r'(t?)([0-9]+)', str(the_user_id)) if m: if m.group(1) == 't': return None, int(m.group(2)) else: return int(m.group(2)), None raise Exception("Invalid user ID")
def parse_the_user_id(the_user_id):
m = re.match(r'(t?)([0-9]+)', str(the_user_id)) if m: if m.group(1) == 't': return None, int(m.group(2)) else: return int(m.group(2)), None raise Exception("Invalid user ID")
utf-8') decrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, obj_string[:16]) return fix_pickle_obj(unpad(decrypter.decrypt(codecs.decode(obj_string[16:], 'base64')))) def parse_the_user_id(the_user_id):
64
64
76
9
55
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
parse_the_user_id
parse_the_user_id
472
479
472
472
c87f011490dcb14301021e1a34748cce26ff99ae
bigcode/the-stack
train
044ef686361b31e253064c2a
train
function
def sql_keys(prefix): n = len(prefix) return list(set([y.key[n:] for y in db.session.query(GlobalObjectStorage.key).filter(GlobalObjectStorage.key.like(prefix + '%')).all()]))
def sql_keys(prefix):
n = len(prefix) return list(set([y.key[n:] for y in db.session.query(GlobalObjectStorage.key).filter(GlobalObjectStorage.key.like(prefix + '%')).all()]))
(key=key, value=pack_object(val), encrypted=False, user_id=user_id, temp_user_id=temp_user_id) db.session.add(record) db.session.commit() def sql_delete(key): GlobalObjectStorage.query.filter_by(key=key).delete() db.session.commit() def sql_keys(prefix):
64
64
44
5
59
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
sql_keys
sql_keys
262
264
262
262
cc95e6e436bff6593d76a8a65e1424bff78c9a88
bigcode/the-stack
train
de7d6751dbfd657165b1bd08
train
function
def decrypt_phrase(phrase_string, secret): phrase_string = bytearray(phrase_string, encoding='utf-8') decrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, phrase_string[:16]) return unpad(decrypter.decrypt(codecs.decode(phrase_string[16:], 'base64'))).decode('utf-8')
def decrypt_phrase(phrase_string, secret):
phrase_string = bytearray(phrase_string, encoding='utf-8') decrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, phrase_string[:16]) return unpad(decrypter.decrypt(codecs.decode(phrase_string[16:], 'base64'))).decode('utf-8')
crypter.encrypt(pad(phrase)), 'base64')).decode('utf-8') def pack_phrase(phrase): phrase = bytearray(phrase, encoding='utf-8') return codecs.encode(phrase, 'base64').decode('utf-8') def decrypt_phrase(phrase_string, secret):
64
64
80
9
55
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
decrypt_phrase
decrypt_phrase
442
445
442
442
80159e9549ee0955064fc5efb2b01485a05e7917
bigcode/the-stack
train
966e20b49416dfa12cdabfe8
train
function
def pad(the_string): return the_string + bytearray((16 - len(the_string) % 16) * chr(16 - len(the_string) % 16), encoding='utf-8')
def pad(the_string):
return the_string + bytearray((16 - len(the_string) % 16) * chr(16 - len(the_string) % 16), encoding='utf-8')
_handler) #sys.stderr.write("__name__ is " + str(__name__) + " and __package__ is " + str(__package__) + "\n") def flask_logger(message): #app.logger.warning(message) sys.stderr.write(str(message) + "\n") return def pad(the_string):
64
64
42
5
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
pad
pad
422
423
422
422
a51d6f69003f2f84107374cdda7951edb19f97cf
bigcode/the-stack
train
13ae68ba04aab28f6eb040e7
train
function
def save_numbered_file(filename, orig_path, yaml_file_name=None, uid=None): if uid is None: try: uid = docassemble.base.functions.get_uid() assert uid is not None except: uid = unattached_uid() if uid is None: raise Exception("save_numbered_file: uid n...
def save_numbered_file(filename, orig_path, yaml_file_name=None, uid=None):
if uid is None: try: uid = docassemble.base.functions.get_uid() assert uid is not None except: uid = unattached_uid() if uid is None: raise Exception("save_numbered_file: uid not defined") file_number = get_new_file_number(uid, filename, yaml_file_...
= unpack_object(record.value) return results def delete_record(key, id): ObjectStorage.query.filter_by(key=key, id=id).delete() db.session.commit() #@elapsed('save_numbered_file') def save_numbered_file(filename, orig_path, yaml_file_name=None, uid=None):
64
64
148
18
46
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
save_numbered_file
save_numbered_file
82
96
82
82
85840ef8e10dbb04dc0d8e5d8c12ca09d027fd82
bigcode/the-stack
train
fea9896443d679c493367cb2
train
function
def guess_yaml_filename(): yaml_filename = None if 'i' in session and 'uid' in session: #TEMPORARY yaml_filename = session['i'] if 'sessions' in session: for item in session['sessions']: yaml_filename = item break return yaml_filename
def guess_yaml_filename():
yaml_filename = None if 'i' in session and 'uid' in session: #TEMPORARY yaml_filename = session['i'] if 'sessions' in session: for item in session['sessions']: yaml_filename = item break return yaml_filename
session and i in session['sessions']: del session['sessions'][i] def clear_specific_session(i, uid): if 'sessions' in session and i in session['sessions']: if session['sessions'][i]['uid'] == uid: del session['sessions'][i] def guess_yaml_filename():
64
64
68
5
59
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
guess_yaml_filename
guess_yaml_filename
1,021
1,029
1,021
1,021
1fbd3bdbce2e334a3984187b2d439fbc9b457d7e
bigcode/the-stack
train
0e52d44dbaa89793097033ed
train
function
def get_person(user_id, cache): if user_id in cache: return cache[user_id] for record in UserModel.query.options(db.joinedload('roles')).filter_by(id=user_id): cache[record.id] = record return record return None
def get_person(user_id, cache):
if user_id in cache: return cache[user_id] for record in UserModel.query.options(db.joinedload('roles')).filter_by(id=user_id): cache[record.id] = record return record return None
db.session.commit() # docassemble.base.functions.server.delete_answer_json(user_code, filename, delete_all=True) for file_number in files_to_delete: the_file = SavedFile(file_number) the_file.delete() return #@elapsed('get_person') def get_person(user_id, cache):
64
64
59
8
56
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
get_person
get_person
810
816
810
810
845a12ea7c00cdbbcb1aa78e438e69c5389b42ec
bigcode/the-stack
train
ba3cdf21b7b3c197200dfd64
train
function
def cloud_custom(provider, config): config_id = str(provider) + str(config) if config_id in cloud_cache: return cloud_cache[config_id] the_config = daconfig.get(config, None) if the_config is None or type(the_config) is not dict: logmessage("cloud_custom: invalid cloud configuration") ...
def cloud_custom(provider, config):
config_id = str(provider) + str(config) if config_id in cloud_cache: return cloud_cache[config_id] the_config = daconfig.get(config, None) if the_config is None or type(the_config) is not dict: logmessage("cloud_custom: invalid cloud configuration") return None cloud_cache[co...
daconfig: docassemble.base.functions.update_language_function('*', 'currency_symbol', lambda: daconfig['currency symbol']) import docassemble.webapp.cloud cloud = docassemble.webapp.cloud.get_cloud() import docassemble.webapp.google_api cloud_cache = dict() def cloud_custom(provider, config):
64
64
105
7
57
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
cloud_custom
cloud_custom
344
353
344
344
4d7afcc918da3402b93a638e12e0cb219966871f
bigcode/the-stack
train
c777dbeb5d67db785002e6bb
train
function
def encrypt_object(obj, secret): iv = random_bytes(16) encrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, iv) return (iv + codecs.encode(encrypter.encrypt(pad(pickle.dumps(safe_pickle(obj)))), 'base64')).decode()
def encrypt_object(obj, secret):
iv = random_bytes(16) encrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, iv) return (iv + codecs.encode(encrypter.encrypt(pad(pickle.dumps(safe_pickle(obj)))), 'base64')).decode()
_object): return codecs.encode(pickle.dumps(safe_pickle(the_object)), 'base64').decode() def unpack_object(the_string): the_string = bytearray(the_string, encoding='utf-8') return fix_pickle_dict(codecs.decode(the_string, 'base64')) def encrypt_object(obj, secret):
64
64
66
7
57
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
encrypt_object
encrypt_object
462
465
462
462
c6ccb52218057ab4c304159bc8e5dcdbda817d6e
bigcode/the-stack
train
0baa3e68855a697a19c9b59e
train
function
def da_send_mail(the_message): mail.send(the_message)
def da_send_mail(the_message):
mail.send(the_message)
daconfig['mail']: mail = MailgunMail(app) elif 'sendgrid api key' in daconfig['mail'] and daconfig['mail']['sendgrid api key']: mail = SendgridMail(app) else: mail = FlaskMail(app) def da_send_mail(the_message):
64
64
13
7
57
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
da_send_mail
da_send_mail
192
193
192
192
a61092a9b65ef79245eeca741ac87448796d9b03
bigcode/the-stack
train
bdf4b1833d9737769532bee0
train
function
def absolute_filename(the_file): match = re.match(r'^docassemble.playground([0-9]+)([A-Za-z]?[A-Za-z0-9]*):(.*)', the_file) #logmessage("absolute_filename call: " + the_file) if match: filename = re.sub(r'[^A-Za-z0-9\-\_\. ]', '', match.group(3)) #logmessage("absolute_filename: filename is "...
def absolute_filename(the_file):
match = re.match(r'^docassemble.playground([0-9]+)([A-Za-z]?[A-Za-z0-9]*):(.*)', the_file) #logmessage("absolute_filename call: " + the_file) if match: filename = re.sub(r'[^A-Za-z0-9\-\_\. ]', '', match.group(3)) #logmessage("absolute_filename: filename is " + filename + " and subdir is " +...
= record.dependent if the_dependent is not None: the_dependent = fix_pickle_obj(codecs.decode(bytearray(the_dependent, encoding='utf-8'), 'base64')) the_entry = dict(independent=the_independent, dependent=the_dependent) if record.key is not None: the_...
137
137
457
6
130
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
absolute_filename
absolute_filename
159
183
159
159
b2604bf9098bab15d5e6d852d91b98aa9f894384
bigcode/the-stack
train
7a9e7e2438286d14c21dc2f9
train
function
def get_info_from_file_reference_with_uids(*pargs, **kwargs): if 'uids' not in kwargs: kwargs['uids'] = get_session_uids() return get_info_from_file_reference(*pargs, **kwargs)
def get_info_from_file_reference_with_uids(*pargs, **kwargs):
if 'uids' not in kwargs: kwargs['uids'] = get_session_uids() return get_info_from_file_reference(*pargs, **kwargs)
db.session.commit() def sql_keys(prefix): n = len(prefix) return list(set([y.key[n:] for y in db.session.query(GlobalObjectStorage.key).filter(GlobalObjectStorage.key.like(prefix + '%')).all()])) def get_info_from_file_reference_with_uids(*pargs, **kwargs):
64
64
50
16
48
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
get_info_from_file_reference_with_uids
get_info_from_file_reference_with_uids
266
269
266
266
821512d10f8d4adf7044fbc211d66aed435cb3b3
bigcode/the-stack
train
629795d5c713c5ca5c5748a5
train
function
def unpad(the_string): if isinstance(the_string[-1], int): return the_string[0:-the_string[-1]] else: return the_string[0:-ord(the_string[-1])]
def unpad(the_string):
if isinstance(the_string[-1], int): return the_string[0:-the_string[-1]] else: return the_string[0:-ord(the_string[-1])]
(message) sys.stderr.write(str(message) + "\n") return def pad(the_string): return the_string + bytearray((16 - len(the_string) % 16) * chr(16 - len(the_string) % 16), encoding='utf-8') def unpad(the_string):
64
64
44
6
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
unpad
unpad
425
429
425
425
ce8900d1dc192a2d9eef6c732764b0f91ce97750
bigcode/the-stack
train
77a68038ba1b4d60bb4094bd
train
function
def write_record(key, data): new_record = ObjectStorage(key=key, value=pack_object(data)) db.session.add(new_record) db.session.commit() return new_record.id
def write_record(key, data):
new_record = ObjectStorage(key=key, value=pack_object(data)) db.session.add(new_record) db.session.commit() return new_record.id
time_start = time.time() result = func(*pargs, **kwargs) sys.stderr.write(name_of_function + ': ' + str(time.time() - time_start) + "\n") return result return time_func return elapse_decorator def write_record(key, data):
64
64
41
7
56
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
write_record
write_record
65
69
65
65
1e65e70135b77854eb3b2500466dcf9f9d1d4c11
bigcode/the-stack
train
b9016e59a6480ab494e064d7
train
function
def pack_object(the_object): return codecs.encode(pickle.dumps(safe_pickle(the_object)), 'base64').decode()
def pack_object(the_object):
return codecs.encode(pickle.dumps(safe_pickle(the_object)), 'base64').decode()
random_bytes(16) encrypter = AES.new(bytearray(secret, encoding='utf-8'), AES.MODE_CBC, iv) return (iv + codecs.encode(encrypter.encrypt(pad(pickle.dumps(pickleable_objects(the_dict)))), 'base64')).decode() def pack_object(the_object):
64
64
25
6
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
pack_object
pack_object
455
456
455
455
0c1689af6ed955edbc0cc7767295cfa91e9fd33b
bigcode/the-stack
train
b804716f1e4e6d3144d2e6f5
train
function
def update_session(i, uid=None, encrypted=None, key_logged=None, chatstatus=None): if 'sessions' not in session: session['sessions'] = dict() if i not in session['sessions'] or uid is not None: if uid is None: raise Exception("update_session: cannot create new session without a uid")...
def update_session(i, uid=None, encrypted=None, key_logged=None, chatstatus=None):
if 'sessions' not in session: session['sessions'] = dict() if i not in session['sessions'] or uid is not None: if uid is None: raise Exception("update_session: cannot create new session without a uid") if encrypted is None: encrypted = True if key_logged i...
return newname def get_uid_for_filename(i): if 'sessions' not in session: session['sessions'] = dict() if i not in session['sessions']: return None return session['sessions'][i]['uid'] def update_session(i, uid=None, encrypted=None, key_logged=None, chatstatus=None):
71
71
238
19
52
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
update_session
update_session
1,064
1,087
1,064
1,064
c41fd13eaa2b8a7a39417496a5210bba7c5f7d81
bigcode/the-stack
train
7332bbe647d6b436aeb5b386
train
function
def get_session(i): if 'sessions' not in session: session['sessions'] = dict() if i in session['sessions']: return session['sessions'][i] if 'i' in session and 'uid' in session: #TEMPORARY session['sessions'][session['i']] = dict(uid=session['uid'], encrypted=session.get('encrypted',...
def get_session(i):
if 'sessions' not in session: session['sessions'] = dict() if i in session['sessions']: return session['sessions'][i] if 'i' in session and 'uid' in session: #TEMPORARY session['sessions'][session['i']] = dict(uid=session['uid'], encrypted=session.get('encrypted', True), key_logged=s...
for item in session['sessions']: yaml_filename = item break return yaml_filename def delete_obsolete(): for name in ('i', 'uid', 'key_logged', 'encrypted', 'chatstatus'): if name in session: del session[name] def get_session(i):
64
64
132
5
59
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
get_session
get_session
1,036
1,047
1,036
1,036
a651d3f7d43ac6d6f2d12bb19c1115ab057b30ba
bigcode/the-stack
train
bf266537e00150868c31854f
train
function
def write_ml_source(playground, playground_number, current_project, filename, finalize=True): if re.match(r'ml-.*\.json', filename): output = dict() prefix = 'docassemble.playground' + str(playground_number) + project_name(current_project) + ':data/sources/' + str(filename) for record in [re...
def write_ml_source(playground, playground_number, current_project, filename, finalize=True):
if re.match(r'ml-.*\.json', filename): output = dict() prefix = 'docassemble.playground' + str(playground_number) + project_name(current_project) + ':data/sources/' + str(filename) for record in [record for record in db.session.query(MachineLearning.group_id, MachineLearning.independent, Mac...
): return '' if name == 'default' else name def add_project(filename, current_project): if current_project == 'default': return filename else: return os.path.join(current_project, filename) def directory_for(area, current_project): if current_project == 'default': return area.d...
99
99
333
18
81
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
write_ml_source
write_ml_source
132
157
132
132
b0486a18b344e5944fdb6243da893e524259c6af
bigcode/the-stack
train
00b5ea48ff21758932e8071e
train
function
def delete_temp_user_data(temp_user_id, r): UserDictKeys.query.filter_by(temp_user_id=temp_user_id).delete() db.session.commit() UploadsUserAuth.query.filter_by(temp_user_id=temp_user_id).delete() db.session.commit() ChatLog.query.filter_by(temp_owner_id=temp_user_id).delete() db.session.commit(...
def delete_temp_user_data(temp_user_id, r):
UserDictKeys.query.filter_by(temp_user_id=temp_user_id).delete() db.session.commit() UploadsUserAuth.query.filter_by(temp_user_id=temp_user_id).delete() db.session.commit() ChatLog.query.filter_by(temp_owner_id=temp_user_id).delete() db.session.commit() ChatLog.query.filter_by(temp_user_id=t...
.0 for value in sorted(interview.progress_points): if value > user_dict['_internal']['progress']: next_part = value break user_dict['_internal']['progress'] += multiplier*(next_part-user_dict['_internal']['progress']) else: user_dict['_internal']['...
89
89
297
11
77
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
delete_temp_user_data
delete_temp_user_data
625
652
625
625
d354a2b317c8fed78a36d175fbbfd11b9567dc96
bigcode/the-stack
train
736b94973a784bffaa1b37e8
train
function
def file_privilege_access(file_number, allow=None, disallow=None, disallow_all=False): something_added = False if allow: for privilege in set(allow): existing_role = Role.query.filter_by(name=privilege).first() if not existing_role: logmessage("file_privilege_acce...
def file_privilege_access(file_number, allow=None, disallow=None, disallow_all=False):
something_added = False if allow: for privilege in set(allow): existing_role = Role.query.filter_by(name=privilege).first() if not existing_role: logmessage("file_privilege_access: invalid privilege " + repr(privilege)) continue if Uplo...
Model.id).filter(UploadsUserAuth.uploads_indexno == file_number).all(): if auth.user_id is not None: result['user_ids'].append(auth.user_id) if auth.temp_user_id is not None: result['temp_user_ids'].append(auth.temp_user_id) if auth.email: ...
99
99
332
20
78
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
file_privilege_access
file_privilege_access
981
1,010
981
981
ae404b6e0981ec2e5c029f10a502762ec8ecef26
bigcode/the-stack
train
41e746b606bfce2dc0ac6b90
train
function
def file_set_attributes(file_number, **kwargs): upload = Uploads.query.filter_by(indexno=file_number).with_for_update().first() if upload is None: db.session.commit() raise Exception("file_set_attributes: file number " + str(file_number) + " not found.") if 'private' in kwargs and kwargs['pr...
def file_set_attributes(file_number, **kwargs):
upload = Uploads.query.filter_by(indexno=file_number).with_for_update().first() if upload is None: db.session.commit() raise Exception("file_set_attributes: file number " + str(file_number) + " not found.") if 'private' in kwargs and kwargs['private'] in [True, False] and upload.private != k...
record.temp_owner_id, temp_user_id=record.temp_user_id, owner_id=record.owner_id, user_id=record.user_id, modtime=modtime, message=message, roles=['user'])) return messages #@elapsed('file_set_attributes') def file_set_attributes(file_number, **kwargs):
64
64
182
10
54
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
file_set_attributes
file_set_attributes
912
925
912
912
0eb67ab48990e99e7e338a49f4c1de48021da77d
bigcode/the-stack
train
baa2feb43cc3e6f296e00e04
train
function
def delete_obsolete(): for name in ('i', 'uid', 'key_logged', 'encrypted', 'chatstatus'): if name in session: del session[name]
def delete_obsolete():
for name in ('i', 'uid', 'key_logged', 'encrypted', 'chatstatus'): if name in session: del session[name]
None if 'i' in session and 'uid' in session: #TEMPORARY yaml_filename = session['i'] if 'sessions' in session: for item in session['sessions']: yaml_filename = item break return yaml_filename def delete_obsolete():
64
64
37
5
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
delete_obsolete
delete_obsolete
1,031
1,034
1,031
1,031
7814b640d46d7347220b5d99925df9c05d58e951
bigcode/the-stack
train
c50cdd134d2c0c0b4be799db
train
function
def sql_defined(key): record = GlobalObjectStorage.query.filter_by(key=key).with_entities(GlobalObjectStorage.id).first() if record is None: return False return True
def sql_defined(key):
record = GlobalObjectStorage.query.filter_by(key=key).with_entities(GlobalObjectStorage.id).first() if record is None: return False return True
: result = decrypt_object(record.value, secret) except: raise Exception("Unable to decrypt stored object.") else: try: result = unpack_object(record.value) except: raise Exception("Unable to unpack stored object....
64
64
41
5
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
sql_defined
sql_defined
232
236
232
232
bd8d417bfdaee9a15c5af388d7a1a9c956926a50
bigcode/the-stack
train
95c99c35a087dc69caed4925
train
function
def delete_user_data(user_id, r, r_user): UserDict.query.filter_by(user_id=user_id).delete() db.session.commit() UserDictKeys.query.filter_by(user_id=user_id).delete() db.session.commit() UploadsUserAuth.query.filter_by(user_id=user_id).delete() db.session.commit() ChatLog.query.filter_by(ow...
def delete_user_data(user_id, r, r_user):
UserDict.query.filter_by(user_id=user_id).delete() db.session.commit() UserDictKeys.query.filter_by(user_id=user_id).delete() db.session.commit() UploadsUserAuth.query.filter_by(user_id=user_id).delete() db.session.commit() ChatLog.query.filter_by(owner_id=user_id).delete() db.session.co...
.commit() files_to_delete = list() for short_code_item in Shortener.query.filter_by(temp_user_id=temp_user_id).all(): for email in Email.query.filter_by(short=short_code_item.short).all(): for attachment in EmailAttachment.query.filter_by(email_id=email.id).all(): files_to_de...
196
196
656
12
184
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
delete_user_data
delete_user_data
654
722
654
654
8698e01f7256d9d5854aaa60aac7e495135d481f
bigcode/the-stack
train
23e2778e932d6bed010d8649
train
function
def fix_ml_files(playground_number, current_project): playground = SavedFile(playground_number, section='playgroundsources', fix=False) changed = False for filename in playground.list_of_files(): if re.match(r'^ml-.*\.json', filename): playground.fix() try: if...
def fix_ml_files(playground_number, current_project):
playground = SavedFile(playground_number, section='playgroundsources', fix=False) changed = False for filename in playground.list_of_files(): if re.match(r'^ml-.*\.json', filename): playground.fix() try: if write_ml_source(playground, playground_number, curren...
, mimetype = get_ext_and_mimetype(filename) new_file = SavedFile(file_number, extension=extension, fix=True) new_file.copy_from(orig_path) new_file.save(finalize=True) return(file_number, extension, mimetype) def fix_ml_files(playground_number, current_project):
64
64
115
11
53
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
fix_ml_files
fix_ml_files
98
110
98
98
b6ce165f757ef17fcb6bf795acaf4f1460939221
bigcode/the-stack
train
4a7967bbf23b9e0e150fd2b3
train
function
def delete_record(key, id): ObjectStorage.query.filter_by(key=key, id=id).delete() db.session.commit()
def delete_record(key, id):
ObjectStorage.query.filter_by(key=key, id=id).delete() db.session.commit()
) db.session.commit() return new_record.id def read_records(key): results = dict() for record in ObjectStorage.query.filter_by(key=key).order_by(ObjectStorage.id): results[record.id] = unpack_object(record.value) return results def delete_record(key, id):
64
64
27
7
56
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
delete_record
delete_record
77
79
77
77
8df2dda7c03786f17f1d258fe100d3c2107b28d8
bigcode/the-stack
train
9d856471ee5f241db9ace537
train
function
def flask_logger(message): #app.logger.warning(message) sys.stderr.write(str(message) + "\n") return
def flask_logger(message): #app.logger.warning(message)
sys.stderr.write(str(message) + "\n") return
(filename=LOGFILE) error_file_handler.setLevel(logging.DEBUG) app.logger.addHandler(error_file_handler) #sys.stderr.write("__name__ is " + str(__name__) + " and __package__ is " + str(__package__) + "\n") def flask_logger(message): #app.logger.warning(message)
64
64
26
12
52
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
flask_logger
flask_logger
417
420
417
418
246fb7c4ecaf800390f8a22a8d21eae93e17c895
bigcode/the-stack
train
37a62b38beab3a918f728e34
train
function
def reset_user_dict(user_code, filename, user_id=None, temp_user_id=None, force=False): #logmessage("reset_user_dict called with " + str(user_code) + " and " + str(filename)) if force: the_user_id = None else: if user_id is None and temp_user_id is None: if current_user.is_authen...
def reset_user_dict(user_code, filename, user_id=None, temp_user_id=None, force=False): #logmessage("reset_user_dict called with " + str(user_code) + " and " + str(filename))
if force: the_user_id = None else: if user_id is None and temp_user_id is None: if current_user.is_authenticated and not current_user.is_anonymous: user_type = 'user' the_user_id = current_user.id else: user_type = 'tempuser...
_object.subdivisionthird = '' user_object.organization = '' user_object.timezone = None user_object.language = None user_object.pypi_username = None user_object.pypi_password = None user_object.otp_secret = None user_object.confirmed_at = None user_object....
256
256
902
45
211
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
reset_user_dict
reset_user_dict
725
807
725
726
e33845e3563d87c993036eb1f16b1941f780730f
bigcode/the-stack
train
7098f8d659dcd4d7ecf182a2
train
function
def get_chat_log(chat_mode, yaml_filename, session_id, user_id, temp_user_id, secret, self_user_id, self_temp_id): messages = list() people = dict() if user_id is not None: if get_person(user_id, people) is None: return list() chat_person_type = 'auth' chat_person_id = us...
def get_chat_log(chat_mode, yaml_filename, session_id, user_id, temp_user_id, secret, self_user_id, self_temp_id):
messages = list() people = dict() if user_id is not None: if get_person(user_id, people) is None: return list() chat_person_type = 'auth' chat_person_id = user_id else: chat_person_type = 'anon' chat_person_id = temp_user_id if self_user_id is not ...
.commit() ChatLog.query.filter_by(key=user_code, filename=filename).delete() db.session.commit() for short_code_item in Shortener.query.filter_by(uid=user_code, filename=filename).all(): for email in Email.query.filter_by(short=short_code_item.short).all(): for attach...
256
256
1,115
30
226
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
get_chat_log
get_chat_log
819
909
819
819
1faf9d142649a10a59fdbaf03bdf07c54e6330c7
bigcode/the-stack
train
1c80d3f63255629dbc3e9b39
train
function
def read_records(key): results = dict() for record in ObjectStorage.query.filter_by(key=key).order_by(ObjectStorage.id): results[record.id] = unpack_object(record.value) return results
def read_records(key):
results = dict() for record in ObjectStorage.query.filter_by(key=key).order_by(ObjectStorage.id): results[record.id] = unpack_object(record.value) return results
n") return result return time_func return elapse_decorator def write_record(key, data): new_record = ObjectStorage(key=key, value=pack_object(data)) db.session.add(new_record) db.session.commit() return new_record.id def read_records(key):
64
64
45
5
58
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
read_records
read_records
71
75
71
71
aba65bbde91598337b1576aa22c485b314d80df8
bigcode/the-stack
train
8ee7f249dca166fd7c7d647f
train
function
def fetch_previous_user_dict(user_code, filename, secret): user_dict = None max_indexno = db.session.query(db.func.max(UserDict.indexno)).filter(and_(UserDict.key == user_code, UserDict.filename == filename)).scalar() if max_indexno is not None: UserDict.query.filter_by(indexno=max_indexno).delete()...
def fetch_previous_user_dict(user_code, filename, secret):
user_dict = None max_indexno = db.session.query(db.func.max(UserDict.indexno)).filter(and_(UserDict.key == user_code, UserDict.filename == filename)).scalar() if max_indexno is not None: UserDict.query.filter_by(indexno=max_indexno).delete() db.session.commit() return fetch_user_dict(use...
_dict_exists(user_code, filename): result = UserDict.query.filter(and_(UserDict.key == user_code, UserDict.filename == filename)).first() if result: return True return False #@elapsed('fetch_previous_user_dict') def fetch_previous_user_dict(user_code, filename, secret):
64
64
94
12
52
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
fetch_previous_user_dict
fetch_previous_user_dict
599
605
599
599
00b3f1056a7eb59ff1d390abc7795e98a6b249b8
bigcode/the-stack
train
43adf9d4b75ae5cc430de147
train
function
def sql_set(key, val, encrypted=True, secret=None, the_user_id=None): user_id, temp_user_id = parse_the_user_id(the_user_id) updated = False for record in GlobalObjectStorage.query.filter_by(key=key).with_for_update(): record.user_id = user_id record.temp_user_id = temp_user_id recor...
def sql_set(key, val, encrypted=True, secret=None, the_user_id=None):
user_id, temp_user_id = parse_the_user_id(the_user_id) updated = False for record in GlobalObjectStorage.query.filter_by(key=key).with_for_update(): record.user_id = user_id record.temp_user_id = temp_user_id record.encrypted = encrypted if encrypted: record.value...
return None def sql_defined(key): record = GlobalObjectStorage.query.filter_by(key=key).with_entities(GlobalObjectStorage.id).first() if record is None: return False return True def sql_set(key, val, encrypted=True, secret=None, the_user_id=None):
64
64
199
18
45
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
sql_set
sql_set
238
256
238
238
27e809378dc1a00c649e344681bb7640b0f16d33
bigcode/the-stack
train
6059eca202b338c2df55955b
train
function
def file_user_access(file_number, allow_user_id=None, allow_email=None, disallow_user_id=None, disallow_email=None, disallow_all=False): something_added = False if allow_user_id: for user_id in set(allow_user_id): existing_user = UserModel.query.filter_by(id=user_id).first() if n...
def file_user_access(file_number, allow_user_id=None, allow_email=None, disallow_user_id=None, disallow_email=None, disallow_all=False):
something_added = False if allow_user_id: for user_id in set(allow_user_id): existing_user = UserModel.query.filter_by(id=user_id).first() if not existing_user: logmessage("file_user_access: invalid user ID " + repr(user_id)) continue i...
is None: db.session.commit() raise Exception("file_set_attributes: file number " + str(file_number) + " not found.") if 'private' in kwargs and kwargs['private'] in [True, False] and upload.private != kwargs['private']: upload.private = kwargs['private'] if 'persistent' in kwargs and kw...
182
182
608
32
150
marshallowitz/docassemble
docassemble_webapp/docassemble/webapp/backend.py
Python
file_user_access
file_user_access
927
979
927
927
933d679b8d533b170074653ea8778ad7f84b2fe0
bigcode/the-stack
train
37366b469824fc3322d3afa6
train
function
def _detect_xz(fp): fp.seek(0) return _peek(fp, 6) == b'\xfd7zXZ\x00'
def _detect_xz(fp):
fp.seek(0) return _peek(fp, 6) == b'\xfd7zXZ\x00'
when opening a file for reading") return _SeekableXZFile(fp, close_fp=close_fp) return _LZMAFile(fp, mode=mode, format=format, check=check, close_fp=close_fp, preset=preset, filters=filters) def _detect_xz(fp):
64
64
32
7
57
r3m0t/backports.lzma
lzmaffi/__init__.py
Python
_detect_xz
_detect_xz
651
653
651
651
4224d96035b47475c3b56cd021fcb616571593c3
bigcode/the-stack
train
527f84e51e7fd65c3f39d60f
train
class
class _SeekableXZFile(io.BufferedIOBase): def __init__(self, fp, close_fp=False): self._mode = _MODE_CLOSED self._fp = fp self._closefp = close_fp index = None filesize = fp.seek(0, SEEK_END) checks = [] while fp.tell() > 0: # read one stream ...
class _SeekableXZFile(io.BufferedIOBase):
def __init__(self, fp, close_fp=False): self._mode = _MODE_CLOSED self._fp = fp self._closefp = close_fp index = None filesize = fp.seek(0, SEEK_END) checks = [] while fp.tell() > 0: # read one stream if fp.tell() < 2 * STREAM_HEADER_S...
_buffer()): return b"" if 0 < size < len(self._buffer): data = memoryview_tobytes(self._buffer[:size]) self._buffer = memoryview(self._buffer)[size:] else: data = memoryview_tobytes(self._buffer) self._buffer = None self._pos += len(dat...
256
256
2,224
11
244
r3m0t/backports.lzma
lzmaffi/__init__.py
Python
_SeekableXZFile
_SeekableXZFile
294
575
294
294
3575991728ee5f358d763c666e3af52086ed93c8
bigcode/the-stack
train
4a71933dcd1bedffc6196dc3
train
function
def memoryview_tobytes(buffer): return buffer.tobytes() if isinstance(buffer, memoryview) else buffer
def memoryview_tobytes(buffer):
return buffer.tobytes() if isinstance(buffer, memoryview) else buffer
SEEK_CUR, SEEK_END = 0, 1, 2 _MODE_CLOSED = 0 _MODE_READ = 1 _MODE_READ_EOF = 2 _MODE_WRITE = 3 __version__ = "0.3.0" def memoryview_tobytes(buffer):
64
64
25
8
56
r3m0t/backports.lzma
lzmaffi/__init__.py
Python
memoryview_tobytes
memoryview_tobytes
41
42
41
41
15e6d3dc15429d620c6ef750a120fabd2d808ba7
bigcode/the-stack
train
ebb5d8ad6d23f9d043639843
train
function
def _peek(fp, n): ret = fp.read(n) fp.seek(-len(ret), SEEK_CUR) if len(ret) != n: return False return ret
def _peek(fp, n):
ret = fp.read(n) fp.seek(-len(ret), SEEK_CUR) if len(ret) != n: return False return ret
compressed = self._compressor.compress(data) self._fp.write(compressed) self._pos += len(data) return len(data) def tell(self): """Return the current file position.""" self._check_not_closed() return self._pos def _peek(fp, n):
64
64
40
7
56
r3m0t/backports.lzma
lzmaffi/__init__.py
Python
_peek
_peek
287
292
287
287
cbd7c53af165b02084105a832f6e621c271e537d
bigcode/the-stack
train
948cbeef0563d9d46f2c6fb8
train
function
def open(filename, mode="rb", format=None, check=-1, preset=None, filters=None, encoding=None, errors=None, newline=None, seek=True): """Open an LZMA-compressed file in binary or text mode. filename can be either an actual file name (given as a str or bytes object), in which case the name...
def open(filename, mode="rb", format=None, check=-1, preset=None, filters=None, encoding=None, errors=None, newline=None, seek=True):
"""Open an LZMA-compressed file in binary or text mode. filename can be either an actual file name (given as a str or bytes object), in which case the named file is opened, or it can be an existing file object to read from or write to. The mode argument can be "r", "rb" (default), "w", "wb", "a", ...
("Cannot specify a preset compression " "level when opening a file for reading") return _SeekableXZFile(fp, close_fp=close_fp) return _LZMAFile(fp, mode=mode, format=format, check=check, close_fp=close_fp, preset=preset, filters=filters) def _detect_xz(fp): ...
134
134
447
35
99
r3m0t/backports.lzma
lzmaffi/__init__.py
Python
open
open
655
697
655
657
6a208c0e4032ba99a1cf5c59ccf1182fc77b7bba
bigcode/the-stack
train
b103600ed24f1188db1a319c
train
function
def decompress(data, format=FORMAT_AUTO, memlimit=None, filters=None): """Decompress a block of data. Refer to LZMADecompressor's docstring for a description of the optional arguments *format*, *check* and *filters*. For incremental decompression, use a LZMADecompressor object instead. """ res...
def decompress(data, format=FORMAT_AUTO, memlimit=None, filters=None):
"""Decompress a block of data. Refer to LZMADecompressor's docstring for a description of the optional arguments *format*, *check* and *filters*. For incremental decompression, use a LZMADecompressor object instead. """ results = [] while True: decomp = LZMADecompressor(format, mem...
and *filters*. For incremental compression, use an LZMACompressor object instead. """ comp = LZMACompressor(format, check, preset, filters) return comp.compress(data) + comp.flush() def decompress(data, format=FORMAT_AUTO, memlimit=None, filters=None):
64
64
180
16
48
r3m0t/backports.lzma
lzmaffi/__init__.py
Python
decompress
decompress
712
730
712
712
593d9b39a93e599a485acfa4c19682b9dcc0b680
bigcode/the-stack
train
adc7b74caaa0f027d0e2c81b
train
function
def LZMAFile(filename, mode="r", format=None, check=-1, preset=None, filters=None, seek=True): """Open an LZMA-compressed file in binary mode. filename is a... TODO original docstring mode can be "r" for reading (default), "w" for (over)writing, or "a" for appending. These can equival...
def LZMAFile(filename, mode="r", format=None, check=-1, preset=None, filters=None, seek=True):
"""Open an LZMA-compressed file in binary mode. filename is a... TODO original docstring mode can be "r" for reading (default), "w" for (over)writing, or "a" for appending. These can equivalently be given as "rb", "wb", and "ab" respectively. format specifies the container format to use for t...
def closed(self): return self._mode == _MODE_CLOSED def _check_not_closed(self): if self.closed: raise ValueError("I/O operation on closed file") def close(self): """Flush and close the file. May be called more than once without error. Once the file is ...
230
230
769
28
201
r3m0t/backports.lzma
lzmaffi/__init__.py
Python
LZMAFile
LZMAFile
577
649
577
578
a0b4de214001d92823b7bdc76b6f2254fb1e5c5f
bigcode/the-stack
train
f55f86d9f8e0ebb75bf26b3e
train
function
def compress(data, format=FORMAT_XZ, check=-1, preset=None, filters=None): """Compress a block of data. Refer to LZMACompressor's docstring for a description of the optional arguments *format*, *check*, *preset* and *filters*. For incremental compression, use an LZMACompressor object instead. """ ...
def compress(data, format=FORMAT_XZ, check=-1, preset=None, filters=None):
"""Compress a block of data. Refer to LZMACompressor's docstring for a description of the optional arguments *format*, *check*, *preset* and *filters*. For incremental compression, use an LZMACompressor object instead. """ comp = LZMACompressor(format, check, preset, filters) return comp.c...
preset=preset, filters=filters, seek=seek) if "t" in mode: return io.TextIOWrapper(binary_file, encoding, errors, newline) else: return binary_file def compress(data, format=FORMAT_XZ, check=-1, preset=None, filters=None):
64
64
105
20
43
r3m0t/backports.lzma
lzmaffi/__init__.py
Python
compress
compress
700
709
700
700
625626356e32432e94e451da6ac29fa5099cb3a4
bigcode/the-stack
train
5029910d27d90dfe948fa0e3
train
class
class _LZMAFile(io.BufferedIOBase): """A file object providing transparent LZMA (de)compression. An _LZMAFile acts as a wrapper for an existing file object. To refer directly to a named file on disk, use lzma.open. Note that _LZMAFile provides a *binary* file interface - data read is returned as b...
class _LZMAFile(io.BufferedIOBase):
"""A file object providing transparent LZMA (de)compression. An _LZMAFile acts as a wrapper for an existing file object. To refer directly to a named file on disk, use lzma.open. Note that _LZMAFile provides a *binary* file interface - data read is returned as bytes, and data to be written must be...
_ALONE", "FORMAT_RAW", "MF_HC3", "MF_HC4", "MF_BT2", "MF_BT3", "MF_BT4", "MODE_FAST", "MODE_NORMAL", "PRESET_DEFAULT", "PRESET_EXTREME", "STREAM_HEADER_SIZE", "decode_stream_footer", "decode_index", "LZMACompressor", "LZMADecompressor", "LZMAFile", "LZMAError", "open", "compress", "decompress",...
256
256
1,988
11
244
r3m0t/backports.lzma
lzmaffi/__init__.py
Python
_LZMAFile
_LZMAFile
44
285
44
44
2400b6ba92b385cea3fa58e7cfaa7e7fb99dbc12
bigcode/the-stack
train
1a3be57d125e74d0740e42f0
train
function
def test_get_mines_basic_info_multiple(test_client, auth_headers): new_mine_guid = 'b6e1c212-aa7d-4f30-8c37-f7e3837be561' mine_identity2 = Mine( mine_guid=uuid.UUID(new_mine_guid), mine_no="Bzzz1234", mine_name="test_mine_name", **DUMMY_USER_KWARGS) mine_identity2.save() ...
def test_get_mines_basic_info_multiple(test_client, auth_headers):
new_mine_guid = 'b6e1c212-aa7d-4f30-8c37-f7e3837be561' mine_identity2 = Mine( mine_guid=uuid.UUID(new_mine_guid), mine_no="Bzzz1234", mine_name="test_mine_name", **DUMMY_USER_KWARGS) mine_identity2.save() form_data = {'mine_guids': [TEST_MINE_GUID, new_mine_guid]} po...
', json=form_data, headers=auth_headers['full_auth_header']) post_data = json.loads(post_resp.data.decode()) assert post_resp.status_code == 200, str(post_resp.response) assert len(post_data) == 1 def test_get_mines_basic_info_multiple(test_client, auth_headers):
64
64
180
14
49
MaxWardle/mds
python-backend/tests/mines/resources/test_mine_basicinfo_resource.py
Python
test_get_mines_basic_info_multiple
test_get_mines_basic_info_multiple
24
38
24
24
afc03c76979cf167e06a89d143ee65338de61eff
bigcode/the-stack
train
16413d57e702664cd446930b
train
function
def test_get_mines_basic_info_empty(test_client, auth_headers): form_data = {'mine_guids': []} post_resp = test_client.post( '/mines/basicinfo', json=form_data, headers=auth_headers['full_auth_header']) post_data = json.loads(post_resp.data.decode()) assert post_resp.status_code == 200, str(post...
def test_get_mines_basic_info_empty(test_client, auth_headers):
form_data = {'mine_guids': []} post_resp = test_client.post( '/mines/basicinfo', json=form_data, headers=auth_headers['full_auth_header']) post_data = json.loads(post_resp.data.decode()) assert post_resp.status_code == 200, str(post_resp.response) assert len(post_data) == 0
import json, uuid from tests.constants import TEST_MINE_GUID, DUMMY_USER_KWARGS from app.api.mines.mine.models.mine import Mine def test_get_mines_basic_info_empty(test_client, auth_headers):
46
64
89
14
31
MaxWardle/mds
python-backend/tests/mines/resources/test_mine_basicinfo_resource.py
Python
test_get_mines_basic_info_empty
test_get_mines_basic_info_empty
6
12
6
6
39e9032871572b26f2ed4be7d776c161271443b8
bigcode/the-stack
train
3375500e7f349271c3b10f61
train
function
def test_get_mines_basic_info_single(test_client, auth_headers): form_data = {'mine_guids': [TEST_MINE_GUID]} post_resp = test_client.post( '/mines/basicinfo', json=form_data, headers=auth_headers['full_auth_header']) post_data = json.loads(post_resp.data.decode()) assert post_resp.status_code =...
def test_get_mines_basic_info_single(test_client, auth_headers):
form_data = {'mine_guids': [TEST_MINE_GUID]} post_resp = test_client.post( '/mines/basicinfo', json=form_data, headers=auth_headers['full_auth_header']) post_data = json.loads(post_resp.data.decode()) assert post_resp.status_code == 200, str(post_resp.response) assert len(post_data) == 1
', json=form_data, headers=auth_headers['full_auth_header']) post_data = json.loads(post_resp.data.decode()) assert post_resp.status_code == 200, str(post_resp.response) assert len(post_data) == 0 def test_get_mines_basic_info_single(test_client, auth_headers):
64
64
93
14
49
MaxWardle/mds
python-backend/tests/mines/resources/test_mine_basicinfo_resource.py
Python
test_get_mines_basic_info_single
test_get_mines_basic_info_single
15
21
15
15
ac020d7ce48bb0a2ccacab0532760a53c6758c3f
bigcode/the-stack
train
ddf20d6ace44d73accbb0bbe
train
class
class Migration(migrations.Migration): dependencies = [ ('houses', '0018_auto_20190930_1927'), ] operations = [ migrations.RemoveField( model_name='house', name='is_accessible', ), migrations.RemoveField( model_name='house', n...
class Migration(migrations.Migration):
dependencies = [ ('houses', '0018_auto_20190930_1927'), ] operations = [ migrations.RemoveField( model_name='house', name='is_accessible', ), migrations.RemoveField( model_name='house', name='open_to_students', ), ...
# Generated by Django 2.2.4 on 2019-09-30 23:30 from django.db import migrations class Migration(migrations.Migration):
36
64
94
7
28
josylad/RoomScout
houses/migrations/0019_auto_20190930_1930.py
Python
Migration
Migration
6
25
6
7
3fad5033a89013cf3b67b980e520a934ea658db0
bigcode/the-stack
train
7e4cffeb32d4ea2db19a38f8
train
class
class EmailServiceTests(unittest.TestCase): # Fail any tests which take longer than 15 seconds. timeout = 15 def setUp(self): self.settings = conftests.options.parse_settings("en","tests/test.conf.json") self.sm_client = conftests.Sendmail(self.settings) self.locales = conftests.str...
class EmailServiceTests(unittest.TestCase): # Fail any tests which take longer than 15 seconds.
timeout = 15 def setUp(self): self.settings = conftests.options.parse_settings("en","tests/test.conf.json") self.sm_client = conftests.Sendmail(self.settings) self.locales = conftests.strings.get_locales() def tearDown(self): print("tearDown()") del self.sm_client ...
#!/usr/bin/env python3 import pytest import pytest_twisted import hashlib from datetime import datetime from twisted.trial import unittest from twisted.internet import defer, reactor from twisted.internet import task from . import conftests class EmailServiceTests(unittest.TestCase): # Fail any tests which take l...
72
256
4,375
21
50
torproject/gettor
tests/test_email_service.py
Python
EmailServiceTests
EmailServiceTests
12
347
12
14
758d7a474959d0187eab5563c2bf76ee0309fc4d
bigcode/the-stack
train
fec18b2066744c70502f152e
train
class
class GUNETModel: def __init__(self,num_boost_round=1001,best_iteration=100): self.device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') #self.device = 'cpu' self.num_boost_round = 1000 self.early_stopping_rounds = 50 self.best_iteration = best_iter...
class GUNETModel:
def __init__(self,num_boost_round=1001,best_iteration=100): self.device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') #self.device = 'cpu' self.num_boost_round = 1000 self.early_stopping_rounds = 50 self.best_iteration = best_iteration self...
16 embed_size = 8 dropout = 0.25 self.dropout_p = dropout self.node_emb = Embedding(node_num, embed_size) pool_ratios = [2000 / node_num, 0.5] self.unet = GraphUNet(embed_size+features_num, hidden, num_class, depth=2, pool_...
255
256
1,325
6
249
NehzUx/AutoGraph-KDDCup2020
src/code_submission/1_aister/gunet_model.py
Python
GUNETModel
GUNETModel
53
203
53
53
8e6d199cbc86d80f86d2a9a4dca9598f06f76da6
bigcode/the-stack
train
ff05a340db9ebc785d9204e7
train
class
class GUNET(torch.nn.Module): def __init__(self, features_num=16, num_class=2, node_num=10000, sparse=False): super(GUNET, self).__init__() hidden = 16 embed_size = 8 dropout = 0.25 self.dropout_p = dropout self.node_emb = Embedding(node_num, embed_size) ...
class GUNET(torch.nn.Module):
def __init__(self, features_num=16, num_class=2, node_num=10000, sparse=False): super(GUNET, self).__init__() hidden = 16 embed_size = 8 dropout = 0.25 self.dropout_p = dropout self.node_emb = Embedding(node_num, embed_size) pool_ratios = [20...
-*- import torch import torch.nn.functional as F from torch.nn import Linear, Embedding from torch_geometric.nn import GraphUNet from torch_geometric.utils import dropout_adj from torch_geometric.data import Data from util import timeclass import pandas as pd import numpy as np import random import time import copy ...
88
88
296
8
79
NehzUx/AutoGraph-KDDCup2020
src/code_submission/1_aister/gunet_model.py
Python
GUNET
GUNET
18
50
18
19
1eef499b37bc59310a60481e0849aa452d298b7a
bigcode/the-stack
train
cc947196752199546f3e20c5
train
function
def add_two_numbers(value1: int, value2: int) -> int: """Method to add two add_two_numbers ARGUMENTS: Value1: first value Value2: second value """ try: return value1 + value2 except TypeError as error: print('Error at add_two_numbers()', error) ...
def add_two_numbers(value1: int, value2: int) -> int:
"""Method to add two add_two_numbers ARGUMENTS: Value1: first value Value2: second value """ try: return value1 + value2 except TypeError as error: print('Error at add_two_numbers()', error) raise except: print('General Error at divi...
"""Module to have basic math functions """ import sys def add_two_numbers(value1: int, value2: int) -> int:
29
64
95
17
11
vishipayyallore/learn-python-in-2022
PythonBasics/a1_errordemos/mathmodule.py
Python
add_two_numbers
add_two_numbers
8
22
8
8
aecbd539beb4f09882bc9451bb7178f5b2bf2ed5
bigcode/the-stack
train
19df2a08e1961c3f335b1a0a
train
function
def divide_two_numbers(value1: int, value2: int) -> float: """Method to add two add_two_numbers ARGUMENTS: Value1: first value Value2: second value """ try: return value1 / value2 except ZeroDivisionError as error: print('ZeroDivisionError at divide_two...
def divide_two_numbers(value1: int, value2: int) -> float:
"""Method to add two add_two_numbers ARGUMENTS: Value1: first value Value2: second value """ try: return value1 / value2 except ZeroDivisionError as error: print('ZeroDivisionError at divide_two_numbers()', error) except TypeError as error1: ...
""" try: return value1 + value2 except TypeError as error: print('Error at add_two_numbers()', error) raise except: print('General Error at divide_two_numbers()') def divide_two_numbers(value1: int, value2: int) -> float:
64
64
119
17
47
vishipayyallore/learn-python-in-2022
PythonBasics/a1_errordemos/mathmodule.py
Python
divide_two_numbers
divide_two_numbers
25
40
25
25
1ccd1482f9f3e03286ca7468c7c7747488d20d24
bigcode/the-stack
train