hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c7045759634b4f9e4aa99c10314da8d8ec103ded | RJsingh7/secretBot | handler.py | [
"MIT"
] | Python | update_command_handler | null | def update_command_handler(bot, update):
'''
Handler for the "update" commands
Update user info in database
'''
username = str(update['message']['chat']['id'])
update_user(update, table)
photo = bot.getUserProfilePhotos(update.message.from_user.id)['photos'][0]
update_user_photo(photo, ... |
Handler for the "update" commands
Update user info in database
| Handler for the "update" commands
Update user info in database | [
"Handler",
"for",
"the",
"\"",
"update",
"\"",
"commands",
"Update",
"user",
"info",
"in",
"database"
] | def update_command_handler(bot, update):
username = str(update['message']['chat']['id'])
update_user(update, table)
photo = bot.getUserProfilePhotos(update.message.from_user.id)['photos'][0]
update_user_photo(photo, username, table)
logger.info('update_command_handler') | [
"def",
"update_command_handler",
"(",
"bot",
",",
"update",
")",
":",
"username",
"=",
"str",
"(",
"update",
"[",
"'message'",
"]",
"[",
"'chat'",
"]",
"[",
"'id'",
"]",
")",
"update_user",
"(",
"update",
",",
"table",
")",
"photo",
"=",
"bot",
".",
... | Handler for the "update" commands
Update user info in database | [
"Handler",
"for",
"the",
"\"",
"update",
"\"",
"commands",
"Update",
"user",
"info",
"in",
"database"
] | [
"'''\n Handler for the \"update\" commands\n Update user info in database\n '''"
] | [
{
"param": "bot",
"type": null
},
{
"param": "update",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bot",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "update",
"type": null,
"docstring": null,
"docstring_tokens": ... |
c7045759634b4f9e4aa99c10314da8d8ec103ded | RJsingh7/secretBot | handler.py | [
"MIT"
] | Python | remove_command_handler | <not_specific> | def remove_command_handler(bot, update):
'''
Handler for the "remove" commands
Remove user(s) from the current user following list
'''
chat_id = update['message']['chat']['id']
username = str(update['message']['chat']['id'])
users = get_followers_list(username, table)
if not users:
... |
Handler for the "remove" commands
Remove user(s) from the current user following list
| Handler for the "remove" commands
Remove user(s) from the current user following list | [
"Handler",
"for",
"the",
"\"",
"remove",
"\"",
"commands",
"Remove",
"user",
"(",
"s",
")",
"from",
"the",
"current",
"user",
"following",
"list"
] | def remove_command_handler(bot, update):
chat_id = update['message']['chat']['id']
username = str(update['message']['chat']['id'])
users = get_followers_list(username, table)
if not users:
bot.send_message(chat_id, RESPONSES['empty_remove_command'])
return
logger.info(users)
butt... | [
"def",
"remove_command_handler",
"(",
"bot",
",",
"update",
")",
":",
"chat_id",
"=",
"update",
"[",
"'message'",
"]",
"[",
"'chat'",
"]",
"[",
"'id'",
"]",
"username",
"=",
"str",
"(",
"update",
"[",
"'message'",
"]",
"[",
"'chat'",
"]",
"[",
"'id'",
... | Handler for the "remove" commands
Remove user(s) from the current user following list | [
"Handler",
"for",
"the",
"\"",
"remove",
"\"",
"commands",
"Remove",
"user",
"(",
"s",
")",
"from",
"the",
"current",
"user",
"following",
"list"
] | [
"'''\n Handler for the \"remove\" commands\n Remove user(s) from the current user following list\n '''"
] | [
{
"param": "bot",
"type": null
},
{
"param": "update",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bot",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "update",
"type": null,
"docstring": null,
"docstring_tokens": ... |
c7045759634b4f9e4aa99c10314da8d8ec103ded | RJsingh7/secretBot | handler.py | [
"MIT"
] | Python | remove_user_callback | null | def remove_user_callback(bot, update):
'''
Handler callback from custom keyboard for the "remove" commands
Remove user from the current user following list
'''
logger.info('='*80)
username = str(update['callback_query']['message']['chat']['id'])
unfollower_id = str(update['callback_query']['... |
Handler callback from custom keyboard for the "remove" commands
Remove user from the current user following list
| Handler callback from custom keyboard for the "remove" commands
Remove user from the current user following list | [
"Handler",
"callback",
"from",
"custom",
"keyboard",
"for",
"the",
"\"",
"remove",
"\"",
"commands",
"Remove",
"user",
"from",
"the",
"current",
"user",
"following",
"list"
] | def remove_user_callback(bot, update):
logger.info('='*80)
username = str(update['callback_query']['message']['chat']['id'])
unfollower_id = str(update['callback_query']['data'])
logger.info("remove users %s %s" % (username, unfollower_id))
unfollow_user(username, unfollower_id, table) | [
"def",
"remove_user_callback",
"(",
"bot",
",",
"update",
")",
":",
"logger",
".",
"info",
"(",
"'='",
"*",
"80",
")",
"username",
"=",
"str",
"(",
"update",
"[",
"'callback_query'",
"]",
"[",
"'message'",
"]",
"[",
"'chat'",
"]",
"[",
"'id'",
"]",
"... | Handler callback from custom keyboard for the "remove" commands
Remove user from the current user following list | [
"Handler",
"callback",
"from",
"custom",
"keyboard",
"for",
"the",
"\"",
"remove",
"\"",
"commands",
"Remove",
"user",
"from",
"the",
"current",
"user",
"following",
"list"
] | [
"'''\n Handler callback from custom keyboard for the \"remove\" commands\n Remove user from the current user following list\n '''",
"# update_user_real_follow_count(username, follow=new_follow)"
] | [
{
"param": "bot",
"type": null
},
{
"param": "update",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bot",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "update",
"type": null,
"docstring": null,
"docstring_tokens": ... |
c7045759634b4f9e4aa99c10314da8d8ec103ded | RJsingh7/secretBot | handler.py | [
"MIT"
] | Python | send_command_handler | <not_specific> | def send_command_handler(bot, update):
'''
Handler for the "send" command
Send message to all the followers who has more that 10 real_following
'''
message = update['message']['text'][len('/send'):]
if not message:
chat_id = update['message']['chat']['id']
bot.send_message(chat_i... |
Handler for the "send" command
Send message to all the followers who has more that 10 real_following
| Handler for the "send" command
Send message to all the followers who has more that 10 real_following | [
"Handler",
"for",
"the",
"\"",
"send",
"\"",
"command",
"Send",
"message",
"to",
"all",
"the",
"followers",
"who",
"has",
"more",
"that",
"10",
"real_following"
] | def send_command_handler(bot, update):
message = update['message']['text'][len('/send'):]
if not message:
chat_id = update['message']['chat']['id']
bot.send_message(chat_id, RESPONSES['empty_send_command'])
return
username = str(update['message']['chat']['id'])
users_to_send = t... | [
"def",
"send_command_handler",
"(",
"bot",
",",
"update",
")",
":",
"message",
"=",
"update",
"[",
"'message'",
"]",
"[",
"'text'",
"]",
"[",
"len",
"(",
"'/send'",
")",
":",
"]",
"if",
"not",
"message",
":",
"chat_id",
"=",
"update",
"[",
"'message'",... | Handler for the "send" command
Send message to all the followers who has more that 10 real_following | [
"Handler",
"for",
"the",
"\"",
"send",
"\"",
"command",
"Send",
"message",
"to",
"all",
"the",
"followers",
"who",
"has",
"more",
"that",
"10",
"real_following"
] | [
"'''\n Handler for the \"send\" command\n Send message to all the followers who has more that 10 real_following\n '''",
"# for user in users_to_send:",
"# bot.send_message(int(user['username']), f'Somebody told me, that \"{message}\"')"
] | [
{
"param": "bot",
"type": null
},
{
"param": "update",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bot",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "update",
"type": null,
"docstring": null,
"docstring_tokens": ... |
c7045759634b4f9e4aa99c10314da8d8ec103ded | RJsingh7/secretBot | handler.py | [
"MIT"
] | Python | photo_handler | <not_specific> | def photo_handler(bot, update):
'''
Handler for the photo messages
Send message with photo to all the followers who has more that 10 real_following
'''
photo = update['message']['photo']
username = str(update['message']['chat']['id'])
users_to_send = table.scan(FilterExpression=Attr('follow'... |
Handler for the photo messages
Send message with photo to all the followers who has more that 10 real_following
| Handler for the photo messages
Send message with photo to all the followers who has more that 10 real_following | [
"Handler",
"for",
"the",
"photo",
"messages",
"Send",
"message",
"with",
"photo",
"to",
"all",
"the",
"followers",
"who",
"has",
"more",
"that",
"10",
"real_following"
] | def photo_handler(bot, update):
photo = update['message']['photo']
username = str(update['message']['chat']['id'])
users_to_send = table.scan(FilterExpression=Attr('follow').contains(username))['Items']
if not users_to_send:
return
photo_to_send = photo[-1]['file_id']
with ThreadPoolExec... | [
"def",
"photo_handler",
"(",
"bot",
",",
"update",
")",
":",
"photo",
"=",
"update",
"[",
"'message'",
"]",
"[",
"'photo'",
"]",
"username",
"=",
"str",
"(",
"update",
"[",
"'message'",
"]",
"[",
"'chat'",
"]",
"[",
"'id'",
"]",
")",
"users_to_send",
... | Handler for the photo messages
Send message with photo to all the followers who has more that 10 real_following | [
"Handler",
"for",
"the",
"photo",
"messages",
"Send",
"message",
"with",
"photo",
"to",
"all",
"the",
"followers",
"who",
"has",
"more",
"that",
"10",
"real_following"
] | [
"'''\n Handler for the photo messages\n Send message with photo to all the followers who has more that 10 real_following\n '''"
] | [
{
"param": "bot",
"type": null
},
{
"param": "update",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bot",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "update",
"type": null,
"docstring": null,
"docstring_tokens": ... |
c7045759634b4f9e4aa99c10314da8d8ec103ded | RJsingh7/secretBot | handler.py | [
"MIT"
] | Python | document_handler | <not_specific> | def document_handler(bot, update):
'''
Handler for the document messages
Send message with photo to all the followers who has more that 10 real_following
'''
document = update['message']['document']['file_id']
username = str(update['message']['chat']['id'])
users_to_send = table.scan(Filter... |
Handler for the document messages
Send message with photo to all the followers who has more that 10 real_following
| Handler for the document messages
Send message with photo to all the followers who has more that 10 real_following | [
"Handler",
"for",
"the",
"document",
"messages",
"Send",
"message",
"with",
"photo",
"to",
"all",
"the",
"followers",
"who",
"has",
"more",
"that",
"10",
"real_following"
] | def document_handler(bot, update):
document = update['message']['document']['file_id']
username = str(update['message']['chat']['id'])
users_to_send = table.scan(FilterExpression=Attr('follow').contains(username))['Items']
if not users_to_send:
return
with ThreadPoolExecutor(max_workers=min(... | [
"def",
"document_handler",
"(",
"bot",
",",
"update",
")",
":",
"document",
"=",
"update",
"[",
"'message'",
"]",
"[",
"'document'",
"]",
"[",
"'file_id'",
"]",
"username",
"=",
"str",
"(",
"update",
"[",
"'message'",
"]",
"[",
"'chat'",
"]",
"[",
"'id... | Handler for the document messages
Send message with photo to all the followers who has more that 10 real_following | [
"Handler",
"for",
"the",
"document",
"messages",
"Send",
"message",
"with",
"photo",
"to",
"all",
"the",
"followers",
"who",
"has",
"more",
"that",
"10",
"real_following"
] | [
"'''\n Handler for the document messages\n Send message with photo to all the followers who has more that 10 real_following\n '''"
] | [
{
"param": "bot",
"type": null
},
{
"param": "update",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bot",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "update",
"type": null,
"docstring": null,
"docstring_tokens": ... |
c7045759634b4f9e4aa99c10314da8d8ec103ded | RJsingh7/secretBot | handler.py | [
"MIT"
] | Python | sticker_handler | <not_specific> | def sticker_handler(bot, update):
'''
Handler for the sticker messages
Send message with sticker to all the followers who has more that 10 real_following
'''
def send_message_and_sticker(chat_id):
'''
Just a little handler to be sure that sticker will be send
after the messag... |
Handler for the sticker messages
Send message with sticker to all the followers who has more that 10 real_following
| Handler for the sticker messages
Send message with sticker to all the followers who has more that 10 real_following | [
"Handler",
"for",
"the",
"sticker",
"messages",
"Send",
"message",
"with",
"sticker",
"to",
"all",
"the",
"followers",
"who",
"has",
"more",
"that",
"10",
"real_following"
] | def sticker_handler(bot, update):
def send_message_and_sticker(chat_id):
bot.send_message(chat_id, RESPONSES['before_sticker_send'])
bot.send_sticker(chat_id, sticker)
username = str(update['message']['chat']['id'])
sticker = update['message']['sticker']['file_id']
users_to_send = table.... | [
"def",
"sticker_handler",
"(",
"bot",
",",
"update",
")",
":",
"def",
"send_message_and_sticker",
"(",
"chat_id",
")",
":",
"'''\n Just a little handler to be sure that sticker will be send\n after the message\n '''",
"bot",
".",
"send_message",
"(",
"chat_... | Handler for the sticker messages
Send message with sticker to all the followers who has more that 10 real_following | [
"Handler",
"for",
"the",
"sticker",
"messages",
"Send",
"message",
"with",
"sticker",
"to",
"all",
"the",
"followers",
"who",
"has",
"more",
"that",
"10",
"real_following"
] | [
"'''\n Handler for the sticker messages\n Send message with sticker to all the followers who has more that 10 real_following\n '''",
"'''\n Just a little handler to be sure that sticker will be send\n after the message\n '''"
] | [
{
"param": "bot",
"type": null
},
{
"param": "update",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bot",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "update",
"type": null,
"docstring": null,
"docstring_tokens": ... |
c7045759634b4f9e4aa99c10314da8d8ec103ded | RJsingh7/secretBot | handler.py | [
"MIT"
] | Python | send_message_and_sticker | null | def send_message_and_sticker(chat_id):
'''
Just a little handler to be sure that sticker will be send
after the message
'''
bot.send_message(chat_id, RESPONSES['before_sticker_send'])
bot.send_sticker(chat_id, sticker) |
Just a little handler to be sure that sticker will be send
after the message
| Just a little handler to be sure that sticker will be send
after the message | [
"Just",
"a",
"little",
"handler",
"to",
"be",
"sure",
"that",
"sticker",
"will",
"be",
"send",
"after",
"the",
"message"
] | def send_message_and_sticker(chat_id):
bot.send_message(chat_id, RESPONSES['before_sticker_send'])
bot.send_sticker(chat_id, sticker) | [
"def",
"send_message_and_sticker",
"(",
"chat_id",
")",
":",
"bot",
".",
"send_message",
"(",
"chat_id",
",",
"RESPONSES",
"[",
"'before_sticker_send'",
"]",
")",
"bot",
".",
"send_sticker",
"(",
"chat_id",
",",
"sticker",
")"
] | Just a little handler to be sure that sticker will be send
after the message | [
"Just",
"a",
"little",
"handler",
"to",
"be",
"sure",
"that",
"sticker",
"will",
"be",
"send",
"after",
"the",
"message"
] | [
"'''\n Just a little handler to be sure that sticker will be send\n after the message\n '''"
] | [
{
"param": "chat_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chat_id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0489d98d630763ba4fd78a0d8c9f0279014dc997 | MacQing/models | official/wide_deep/ydq_wide_deep_model.py | [
"Apache-2.0"
] | Python | build_estimator | <not_specific> | def build_estimator(model_dir, model_type, model_column_fn, inter_op, intra_op):
"""Build an estimator appropriate for the given model type."""
wide_columns, deep_columns = model_column_fn()
hidden_units = [100, 75, 50, 25]
return LinearClassifier(model_dir=model_dir, feature_columns=deep_columns, n_classes=2,... | Build an estimator appropriate for the given model type. | Build an estimator appropriate for the given model type. | [
"Build",
"an",
"estimator",
"appropriate",
"for",
"the",
"given",
"model",
"type",
"."
] | def build_estimator(model_dir, model_type, model_column_fn, inter_op, intra_op):
wide_columns, deep_columns = model_column_fn()
hidden_units = [100, 75, 50, 25]
return LinearClassifier(model_dir=model_dir, feature_columns=deep_columns, n_classes=2,config=None) | [
"def",
"build_estimator",
"(",
"model_dir",
",",
"model_type",
",",
"model_column_fn",
",",
"inter_op",
",",
"intra_op",
")",
":",
"wide_columns",
",",
"deep_columns",
"=",
"model_column_fn",
"(",
")",
"hidden_units",
"=",
"[",
"100",
",",
"75",
",",
"50",
"... | Build an estimator appropriate for the given model type. | [
"Build",
"an",
"estimator",
"appropriate",
"for",
"the",
"given",
"model",
"type",
"."
] | [
"\"\"\"Build an estimator appropriate for the given model type.\"\"\""
] | [
{
"param": "model_dir",
"type": null
},
{
"param": "model_type",
"type": null
},
{
"param": "model_column_fn",
"type": null
},
{
"param": "inter_op",
"type": null
},
{
"param": "intra_op",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model_type",
"type": null,
"docstring": null,
"docstring... |
0489d98d630763ba4fd78a0d8c9f0279014dc997 | MacQing/models | official/wide_deep/ydq_wide_deep_model.py | [
"Apache-2.0"
] | Python | run_census | <not_specific> | def run_census(flags_obj):
"""Construct all necessary functions and call run_loop.
Args:
flags_obj: Object containing user specified flags.
"""
if flags_obj.download_if_missing:
census_dataset.download(flags_obj.data_dir)
train_file = os.path.join(flags_obj.data_dir, census_dataset.TRAINING_FILE)
... | Construct all necessary functions and call run_loop.
Args:
flags_obj: Object containing user specified flags.
| Construct all necessary functions and call run_loop. | [
"Construct",
"all",
"necessary",
"functions",
"and",
"call",
"run_loop",
"."
] | def run_census(flags_obj):
if flags_obj.download_if_missing:
census_dataset.download(flags_obj.data_dir)
train_file = os.path.join(flags_obj.data_dir, census_dataset.TRAINING_FILE)
test_file = os.path.join(flags_obj.data_dir, census_dataset.EVAL_FILE)
def train_input_fn():
return census_dataset.input_fn... | [
"def",
"run_census",
"(",
"flags_obj",
")",
":",
"if",
"flags_obj",
".",
"download_if_missing",
":",
"census_dataset",
".",
"download",
"(",
"flags_obj",
".",
"data_dir",
")",
"train_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"flags_obj",
".",
"data_di... | Construct all necessary functions and call run_loop. | [
"Construct",
"all",
"necessary",
"functions",
"and",
"call",
"run_loop",
"."
] | [
"\"\"\"Construct all necessary functions and call run_loop.\n\n Args:\n flags_obj: Object containing user specified flags.\n \"\"\"",
"# Train and evaluate the model every `flags.epochs_between_evals` epochs."
] | [
{
"param": "flags_obj",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "flags_obj",
"type": null,
"docstring": "Object containing user specified flags.",
"docstring_tokens": [
"Object",
"containing",
"user",
"specified",
"flags",
"."
],
"... |
61af94a7a2406e33e282d6395036bb0d58cece70 | joekroese/math-of-revolution | Code/other/boltzmann-wealth/model.py | [
"MIT"
] | Python | step | null | def step(self):
'''Advance the model by one step.'''
# print("New step.")
self.datacollector.collect(self)
self.schedule.step() | Advance the model by one step. | Advance the model by one step. | [
"Advance",
"the",
"model",
"by",
"one",
"step",
"."
] | def step(self):
self.datacollector.collect(self)
self.schedule.step() | [
"def",
"step",
"(",
"self",
")",
":",
"self",
".",
"datacollector",
".",
"collect",
"(",
"self",
")",
"self",
".",
"schedule",
".",
"step",
"(",
")"
] | Advance the model by one step. | [
"Advance",
"the",
"model",
"by",
"one",
"step",
"."
] | [
"'''Advance the model by one step.'''",
"# print(\"New step.\")"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6d0f53f3ba565af627b656c8a21daada5e784800 | hrishikeshathalye/MyServer | requestHandlers.py | [
"MIT"
] | Python | post | <not_specific> | def post(requestDict, *args):
"""
The meaning of the Content-Location header in PUT or POST requests is
undefined; servers are free to ignore it in those cases. (ignored)
"""
if(not utils.compatCheck(requestDict['requestLine']['httpVersion'])):
return badRequest(requestDict, '505')
if('h... |
The meaning of the Content-Location header in PUT or POST requests is
undefined; servers are free to ignore it in those cases. (ignored)
| The meaning of the Content-Location header in PUT or POST requests is
undefined; servers are free to ignore it in those cases. (ignored) | [
"The",
"meaning",
"of",
"the",
"Content",
"-",
"Location",
"header",
"in",
"PUT",
"or",
"POST",
"requests",
"is",
"undefined",
";",
"servers",
"are",
"free",
"to",
"ignore",
"it",
"in",
"those",
"cases",
".",
"(",
"ignored",
")"
] | def post(requestDict, *args):
if(not utils.compatCheck(requestDict['requestLine']['httpVersion'])):
return badRequest(requestDict, '505')
if('host' not in requestDict['requestHeaders']):
return badRequest(requestDict, '400')
requestHeaders = requestDict['requestHeaders']
config = configp... | [
"def",
"post",
"(",
"requestDict",
",",
"*",
"args",
")",
":",
"if",
"(",
"not",
"utils",
".",
"compatCheck",
"(",
"requestDict",
"[",
"'requestLine'",
"]",
"[",
"'httpVersion'",
"]",
")",
")",
":",
"return",
"badRequest",
"(",
"requestDict",
",",
"'505'... | The meaning of the Content-Location header in PUT or POST requests is
undefined; servers are free to ignore it in those cases. | [
"The",
"meaning",
"of",
"the",
"Content",
"-",
"Location",
"header",
"in",
"PUT",
"or",
"POST",
"requests",
"is",
"undefined",
";",
"servers",
"are",
"free",
"to",
"ignore",
"it",
"in",
"those",
"cases",
"."
] | [
"\"\"\"\n The meaning of the Content-Location header in PUT or POST requests is\n undefined; servers are free to ignore it in those cases. (ignored)\n \"\"\"",
"#decoding according to content-encoding",
"#handling according to content-type",
"#log not exactly in json, but avoids reading overhead",
... | [
{
"param": "requestDict",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "requestDict",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67dedba0bcfedced88b5a105dc103e281f27ad05 | hrishikeshathalye/MyServer | server.py | [
"MIT"
] | Python | receive | <not_specific> | def receive(self, clientConnection, bufSize):
"""
receive and decode according to passed scheme
"""
return clientConnection.recv(bufSize) |
receive and decode according to passed scheme
| receive and decode according to passed scheme | [
"receive",
"and",
"decode",
"according",
"to",
"passed",
"scheme"
] | def receive(self, clientConnection, bufSize):
return clientConnection.recv(bufSize) | [
"def",
"receive",
"(",
"self",
",",
"clientConnection",
",",
"bufSize",
")",
":",
"return",
"clientConnection",
".",
"recv",
"(",
"bufSize",
")"
] | receive and decode according to passed scheme | [
"receive",
"and",
"decode",
"according",
"to",
"passed",
"scheme"
] | [
"\"\"\"\n\t\treceive and decode according to passed scheme\n\t\t\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "clientConnection",
"type": null
},
{
"param": "bufSize",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clientConnection",
"type": null,
"docstring": null,
"docstrin... |
67dedba0bcfedced88b5a105dc103e281f27ad05 | hrishikeshathalye/MyServer | server.py | [
"MIT"
] | Python | stop | null | def stop(self):
"""
joins all threads
stops server, then returns 1
"""
#dont accept any new requests
self.status = 0
print("Waiting for all pending requests to complete...")
#serve pending requests
#timeout of 10s for the first hanging thread found
#all others should have completed by then so 0 time... |
joins all threads
stops server, then returns 1
| joins all threads
stops server, then returns 1 | [
"joins",
"all",
"threads",
"stops",
"server",
"then",
"returns",
"1"
] | def stop(self):
self.status = 0
print("Waiting for all pending requests to complete...")
initialWait = self.requestTimeout
for thread in self.threads:
try:
thread.join(initialWait)
if(thread.is_alive()):
initialWait=0
except:
pass
finally:
if(thread.is_alive()):
logging.warnin... | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"status",
"=",
"0",
"print",
"(",
"\"Waiting for all pending requests to complete...\"",
")",
"initialWait",
"=",
"self",
".",
"requestTimeout",
"for",
"thread",
"in",
"self",
".",
"threads",
":",
"try",
":",
... | joins all threads
stops server, then returns 1 | [
"joins",
"all",
"threads",
"stops",
"server",
"then",
"returns",
"1"
] | [
"\"\"\"\n\t\tjoins all threads\n\t\tstops server, then returns 1\n\t\t\"\"\"",
"#dont accept any new requests",
"#serve pending requests",
"#timeout of 10s for the first hanging thread found",
"#all others should have completed by then so 0 timeout for them"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8a2a3a369616458dd8e7955deabc0f0af2fa548f | hrishikeshathalye/MyServer | utils.py | [
"MIT"
] | Python | requestParser | <not_specific> | def requestParser(requestStr):
"""
accept request string, return dictionary
returning None indicates parsing error
"""
requestStr = requestStr.strip()
#According to the RFC, the body starts after a \r\n\r\n sequence
headerBodySplit = requestStr.split("\r\n\r\n".encode(), 1)
reqlineAndHeaders = headerBod... |
accept request string, return dictionary
returning None indicates parsing error
| accept request string, return dictionary
returning None indicates parsing error | [
"accept",
"request",
"string",
"return",
"dictionary",
"returning",
"None",
"indicates",
"parsing",
"error"
] | def requestParser(requestStr):
requestStr = requestStr.strip()
headerBodySplit = requestStr.split("\r\n\r\n".encode(), 1)
reqlineAndHeaders = headerBodySplit[0].decode('utf-8')
requestBody = ''
if(len(headerBodySplit)>1):
requestBody = headerBodySplit[1]
headerFields = reqlineAndHeaders.strip().split('\r... | [
"def",
"requestParser",
"(",
"requestStr",
")",
":",
"requestStr",
"=",
"requestStr",
".",
"strip",
"(",
")",
"headerBodySplit",
"=",
"requestStr",
".",
"split",
"(",
"\"\\r\\n\\r\\n\"",
".",
"encode",
"(",
")",
",",
"1",
")",
"reqlineAndHeaders",
"=",
"head... | accept request string, return dictionary
returning None indicates parsing error | [
"accept",
"request",
"string",
"return",
"dictionary",
"returning",
"None",
"indicates",
"parsing",
"error"
] | [
"\"\"\"\n\t\taccept request string, return dictionary\n\t\treturning None indicates parsing error\n\t\t\"\"\"",
"#According to the RFC, the body starts after a \\r\\n\\r\\n sequence",
"#since the body maybe absent sometimes, this avoids an IndexError",
"#RFC : Request-Line = Method SP Request-URI SP HTTP-Vers... | [
{
"param": "requestStr",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "requestStr",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8a2a3a369616458dd8e7955deabc0f0af2fa548f | hrishikeshathalye/MyServer | utils.py | [
"MIT"
] | Python | rfcDate | <not_specific> | def rfcDate(date):
"""Return a string representation of a date according to RFC 1123
(HTTP/1.1).
"""
dt = date
weekday = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][dt.weekday()]
month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][dt.month - 1]
return "%s, %02d %s %... | Return a string representation of a date according to RFC 1123
(HTTP/1.1).
| Return a string representation of a date according to RFC 1123
(HTTP/1.1). | [
"Return",
"a",
"string",
"representation",
"of",
"a",
"date",
"according",
"to",
"RFC",
"1123",
"(",
"HTTP",
"/",
"1",
".",
"1",
")",
"."
] | def rfcDate(date):
dt = date
weekday = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][dt.weekday()]
month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][dt.month - 1]
return "%s, %02d %s %04d %02d:%02d:%02d GMT" % (weekday, dt.day, month, dt.year, dt.hour, dt.minute, dt.se... | [
"def",
"rfcDate",
"(",
"date",
")",
":",
"dt",
"=",
"date",
"weekday",
"=",
"[",
"\"Mon\"",
",",
"\"Tue\"",
",",
"\"Wed\"",
",",
"\"Thu\"",
",",
"\"Fri\"",
",",
"\"Sat\"",
",",
"\"Sun\"",
"]",
"[",
"dt",
".",
"weekday",
"(",
")",
"]",
"month",
"=",... | Return a string representation of a date according to RFC 1123
(HTTP/1.1). | [
"Return",
"a",
"string",
"representation",
"of",
"a",
"date",
"according",
"to",
"RFC",
"1123",
"(",
"HTTP",
"/",
"1",
".",
"1",
")",
"."
] | [
"\"\"\"Return a string representation of a date according to RFC 1123\n\t(HTTP/1.1).\n\t\"\"\""
] | [
{
"param": "date",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "date",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8a2a3a369616458dd8e7955deabc0f0af2fa548f | hrishikeshathalye/MyServer | utils.py | [
"MIT"
] | Python | prioritizeEncoding | <not_specific> | def prioritizeEncoding(acceptVal):
"""
takes in accept-encoding header value(str) and returns
which encoding to use according to q priority
"""
if(acceptVal == ""):
return "identity"
allEncodings = [
"br",
"compress",
"deflate",
"gzip",
"exi",
"pack200-gzip",
"x-compress",
"x-gzip",
"zstd"
]... |
takes in accept-encoding header value(str) and returns
which encoding to use according to q priority
| takes in accept-encoding header value(str) and returns
which encoding to use according to q priority | [
"takes",
"in",
"accept",
"-",
"encoding",
"header",
"value",
"(",
"str",
")",
"and",
"returns",
"which",
"encoding",
"to",
"use",
"according",
"to",
"q",
"priority"
] | def prioritizeEncoding(acceptVal):
if(acceptVal == ""):
return "identity"
allEncodings = [
"br",
"compress",
"deflate",
"gzip",
"exi",
"pack200-gzip",
"x-compress",
"x-gzip",
"zstd"
]
priority=dict()
tmp = acceptVal.split(',')
starPriority = 0
seenEncodings = []
pflag = 0
for i in tmp:
i ... | [
"def",
"prioritizeEncoding",
"(",
"acceptVal",
")",
":",
"if",
"(",
"acceptVal",
"==",
"\"\"",
")",
":",
"return",
"\"identity\"",
"allEncodings",
"=",
"[",
"\"br\"",
",",
"\"compress\"",
",",
"\"deflate\"",
",",
"\"gzip\"",
",",
"\"exi\"",
",",
"\"pack200-gzi... | takes in accept-encoding header value(str) and returns
which encoding to use according to q priority | [
"takes",
"in",
"accept",
"-",
"encoding",
"header",
"value",
"(",
"str",
")",
"and",
"returns",
"which",
"encoding",
"to",
"use",
"according",
"to",
"q",
"priority"
] | [
"\"\"\"\n\ttakes in accept-encoding header value(str) and returns \n\twhich encoding to use according to q priority\n\t\"\"\""
] | [
{
"param": "acceptVal",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "acceptVal",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8a2a3a369616458dd8e7955deabc0f0af2fa548f | hrishikeshathalye/MyServer | utils.py | [
"MIT"
] | Python | prioritizeMedia | <not_specific> | def prioritizeMedia(acceptVal,extension,path):
"""
takes in accept-media header value(str) and returns
which media type to use according to q priority
"""
if(acceptVal == ""):
return "application/example"
with open('media-types/content-qvals.json','r') as jf:
priority = json.load(jf)
tmp = acceptVal.split('... |
takes in accept-media header value(str) and returns
which media type to use according to q priority
| takes in accept-media header value(str) and returns
which media type to use according to q priority | [
"takes",
"in",
"accept",
"-",
"media",
"header",
"value",
"(",
"str",
")",
"and",
"returns",
"which",
"media",
"type",
"to",
"use",
"according",
"to",
"q",
"priority"
] | def prioritizeMedia(acceptVal,extension,path):
if(acceptVal == ""):
return "application/example"
with open('media-types/content-qvals.json','r') as jf:
priority = json.load(jf)
tmp = acceptVal.split(',')
for i in tmp:
i = i.strip()
pair = i.split(';')
broadtype = pair[0].strip()
mtype = broadtype.split(... | [
"def",
"prioritizeMedia",
"(",
"acceptVal",
",",
"extension",
",",
"path",
")",
":",
"if",
"(",
"acceptVal",
"==",
"\"\"",
")",
":",
"return",
"\"application/example\"",
"with",
"open",
"(",
"'media-types/content-qvals.json'",
",",
"'r'",
")",
"as",
"jf",
":",... | takes in accept-media header value(str) and returns
which media type to use according to q priority | [
"takes",
"in",
"accept",
"-",
"media",
"header",
"value",
"(",
"str",
")",
"and",
"returns",
"which",
"media",
"type",
"to",
"use",
"according",
"to",
"q",
"priority"
] | [
"\"\"\"\n\ttakes in accept-media header value(str) and returns \n\twhich media type to use according to q priority\n\t\"\"\""
] | [
{
"param": "acceptVal",
"type": null
},
{
"param": "extension",
"type": null
},
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "acceptVal",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "extension",
"type": null,
"docstring": null,
"docstring_... |
4dfd436c0b96028eeed4e0dc3dcdb76f5da20afb | hrishikeshathalye/MyServer | multithreadTest.py | [
"MIT"
] | Python | runTest | <not_specific> | def runTest(self):
"""CONFORMANCE TEST - Testing Conditional GET"""
print("\nMaking a Normal GET Request")
try:
headers = dict()
r = requests.get(SERVER_URL + "/")
print(f"Status : {r.status_code} {r.reason}")
lastModified = r.headers['Last-Modifie... | CONFORMANCE TEST - Testing Conditional GET | CONFORMANCE TEST - Testing Conditional GET | [
"CONFORMANCE",
"TEST",
"-",
"Testing",
"Conditional",
"GET"
] | def runTest(self):
print("\nMaking a Normal GET Request")
try:
headers = dict()
r = requests.get(SERVER_URL + "/")
print(f"Status : {r.status_code} {r.reason}")
lastModified = r.headers['Last-Modified']
headers['If-Modified-Since'] = lastModifi... | [
"def",
"runTest",
"(",
"self",
")",
":",
"print",
"(",
"\"\\nMaking a Normal GET Request\"",
")",
"try",
":",
"headers",
"=",
"dict",
"(",
")",
"r",
"=",
"requests",
".",
"get",
"(",
"SERVER_URL",
"+",
"\"/\"",
")",
"print",
"(",
"f\"Status : {r.status_code}... | CONFORMANCE TEST - Testing Conditional GET | [
"CONFORMANCE",
"TEST",
"-",
"Testing",
"Conditional",
"GET"
] | [
"\"\"\"CONFORMANCE TEST - Testing Conditional GET\"\"\"",
"# Stop all running threads"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4dfd436c0b96028eeed4e0dc3dcdb76f5da20afb | hrishikeshathalye/MyServer | multithreadTest.py | [
"MIT"
] | Python | runTest | <not_specific> | def runTest(self):
"""CONFORMANCE TEST - Testing POST Request"""
try:
print("\nMaking a POST Request")
data = dict(
key1='TEST',
value1='TEST DATA'
)
r = requests.post(SERVER_URL + "/test",
data=json.dumps(da... | CONFORMANCE TEST - Testing POST Request | CONFORMANCE TEST - Testing POST Request | [
"CONFORMANCE",
"TEST",
"-",
"Testing",
"POST",
"Request"
] | def runTest(self):
try:
print("\nMaking a POST Request")
data = dict(
key1='TEST',
value1='TEST DATA'
)
r = requests.post(SERVER_URL + "/test",
data=json.dumps(data),
headers={'content-type': 'applica... | [
"def",
"runTest",
"(",
"self",
")",
":",
"try",
":",
"print",
"(",
"\"\\nMaking a POST Request\"",
")",
"data",
"=",
"dict",
"(",
"key1",
"=",
"'TEST'",
",",
"value1",
"=",
"'TEST DATA'",
")",
"r",
"=",
"requests",
".",
"post",
"(",
"SERVER_URL",
"+",
... | CONFORMANCE TEST - Testing POST Request | [
"CONFORMANCE",
"TEST",
"-",
"Testing",
"POST",
"Request"
] | [
"\"\"\"CONFORMANCE TEST - Testing POST Request\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4dfd436c0b96028eeed4e0dc3dcdb76f5da20afb | hrishikeshathalye/MyServer | multithreadTest.py | [
"MIT"
] | Python | runTest | <not_specific> | def runTest(self):
"""CONFORMANCE TEST - Testing HEAD Request"""
print("\nMaking a HEAD Request")
try:
r = requests.head(SERVER_URL + "/")
print(f"Status : {r.status_code} {r.reason}")
print("Headers:", r.headers)
except Exception as ex:
pr... | CONFORMANCE TEST - Testing HEAD Request | CONFORMANCE TEST - Testing HEAD Request | [
"CONFORMANCE",
"TEST",
"-",
"Testing",
"HEAD",
"Request"
] | def runTest(self):
print("\nMaking a HEAD Request")
try:
r = requests.head(SERVER_URL + "/")
print(f"Status : {r.status_code} {r.reason}")
print("Headers:", r.headers)
except Exception as ex:
print('Something went horribly wrong!', ex)
fina... | [
"def",
"runTest",
"(",
"self",
")",
":",
"print",
"(",
"\"\\nMaking a HEAD Request\"",
")",
"try",
":",
"r",
"=",
"requests",
".",
"head",
"(",
"SERVER_URL",
"+",
"\"/\"",
")",
"print",
"(",
"f\"Status : {r.status_code} {r.reason}\"",
")",
"print",
"(",
"\"Hea... | CONFORMANCE TEST - Testing HEAD Request | [
"CONFORMANCE",
"TEST",
"-",
"Testing",
"HEAD",
"Request"
] | [
"\"\"\"CONFORMANCE TEST - Testing HEAD Request\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4dfd436c0b96028eeed4e0dc3dcdb76f5da20afb | hrishikeshathalye/MyServer | multithreadTest.py | [
"MIT"
] | Python | runTest | <not_specific> | def runTest(self):
"""CONFORMANCE TEST - Testing PUT Request"""
print("\nMaking a PUT Request")
try:
data = dict(
key1='TEST',
value1='TEST DATA'
)
r = requests.put(SERVER_URL + f"/test/test{1}.json",
data=json.d... | CONFORMANCE TEST - Testing PUT Request | CONFORMANCE TEST - Testing PUT Request | [
"CONFORMANCE",
"TEST",
"-",
"Testing",
"PUT",
"Request"
] | def runTest(self):
print("\nMaking a PUT Request")
try:
data = dict(
key1='TEST',
value1='TEST DATA'
)
r = requests.put(SERVER_URL + f"/test/test{1}.json",
data=json.dumps(data),
headers={'content-type': ... | [
"def",
"runTest",
"(",
"self",
")",
":",
"print",
"(",
"\"\\nMaking a PUT Request\"",
")",
"try",
":",
"data",
"=",
"dict",
"(",
"key1",
"=",
"'TEST'",
",",
"value1",
"=",
"'TEST DATA'",
")",
"r",
"=",
"requests",
".",
"put",
"(",
"SERVER_URL",
"+",
"f... | CONFORMANCE TEST - Testing PUT Request | [
"CONFORMANCE",
"TEST",
"-",
"Testing",
"PUT",
"Request"
] | [
"\"\"\"CONFORMANCE TEST - Testing PUT Request\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4dfd436c0b96028eeed4e0dc3dcdb76f5da20afb | hrishikeshathalye/MyServer | multithreadTest.py | [
"MIT"
] | Python | runTest | <not_specific> | def runTest(self):
"""CONFORMANCE TEST - Testing DELETE Request"""
print("\nMaking a DELETE Request")
try:
data = dict(
key1='TEST',
value1='TEST DATA'
)
r = requests.delete(SERVER_URL + f"/test/test{1}.json")
print(... | CONFORMANCE TEST - Testing DELETE Request | CONFORMANCE TEST - Testing DELETE Request | [
"CONFORMANCE",
"TEST",
"-",
"Testing",
"DELETE",
"Request"
] | def runTest(self):
print("\nMaking a DELETE Request")
try:
data = dict(
key1='TEST',
value1='TEST DATA'
)
r = requests.delete(SERVER_URL + f"/test/test{1}.json")
print(f"Status : {r.status_code} {r.reason}")
prin... | [
"def",
"runTest",
"(",
"self",
")",
":",
"print",
"(",
"\"\\nMaking a DELETE Request\"",
")",
"try",
":",
"data",
"=",
"dict",
"(",
"key1",
"=",
"'TEST'",
",",
"value1",
"=",
"'TEST DATA'",
")",
"r",
"=",
"requests",
".",
"delete",
"(",
"SERVER_URL",
"+"... | CONFORMANCE TEST - Testing DELETE Request | [
"CONFORMANCE",
"TEST",
"-",
"Testing",
"DELETE",
"Request"
] | [
"\"\"\"CONFORMANCE TEST - Testing DELETE Request\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4dfd436c0b96028eeed4e0dc3dcdb76f5da20afb | hrishikeshathalye/MyServer | multithreadTest.py | [
"MIT"
] | Python | runTest | <not_specific> | def runTest(self):
"""STRESS TEST - Random Request Combination"""
sample = random.sample(range(n_clientThreads), 5)
s = sum(sample)
numRequests = [(i*n_clientThreads)//s for i in sample]
# The number of client threads to create
getThreads = numRequests[0]
headThre... | STRESS TEST - Random Request Combination | STRESS TEST - Random Request Combination | [
"STRESS",
"TEST",
"-",
"Random",
"Request",
"Combination"
] | def runTest(self):
sample = random.sample(range(n_clientThreads), 5)
s = sum(sample)
numRequests = [(i*n_clientThreads)//s for i in sample]
getThreads = numRequests[0]
headThreads = numRequests[1]
postThreads = numRequests[2]
putThreads = numRequests[3]
de... | [
"def",
"runTest",
"(",
"self",
")",
":",
"sample",
"=",
"random",
".",
"sample",
"(",
"range",
"(",
"n_clientThreads",
")",
",",
"5",
")",
"s",
"=",
"sum",
"(",
"sample",
")",
"numRequests",
"=",
"[",
"(",
"i",
"*",
"n_clientThreads",
")",
"//",
"s... | STRESS TEST - Random Request Combination | [
"STRESS",
"TEST",
"-",
"Random",
"Request",
"Combination"
] | [
"\"\"\"STRESS TEST - Random Request Combination\"\"\"",
"# The number of client threads to create",
"# print(f\"Status : {r.status_code} {r.reason}\")",
"# print(f\"Status : {r.status_code} {r.reason}\")",
"# print(f\"Status : {r.status_code} {r.reason}\")",
"# print(f\"Status : {r.status_code} {r.reason}... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
075bb1bebc374b576686e09a8a386cc9867ee7b1 | o-gent/aero_one | ground_station/display.py | [
"MIT"
] | Python | refresh | null | def refresh(self, data):
"""
puts new data in 'raw' sheet for each call
"""
try:
# set latency on main screen
self.raw.range(1,1).value = self.latency
self.data = data
x = self.raw.range
data_sorted = sorted(self.data) # list ... |
puts new data in 'raw' sheet for each call
| puts new data in 'raw' sheet for each call | [
"puts",
"new",
"data",
"in",
"'",
"raw",
"'",
"sheet",
"for",
"each",
"call"
] | def refresh(self, data):
try:
self.raw.range(1,1).value = self.latency
self.data = data
x = self.raw.range
data_sorted = sorted(self.data)
for entry in data_sorted:
x(entry + 1, 2).value = entry
i = 3
... | [
"def",
"refresh",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"self",
".",
"raw",
".",
"range",
"(",
"1",
",",
"1",
")",
".",
"value",
"=",
"self",
".",
"latency",
"self",
".",
"data",
"=",
"data",
"x",
"=",
"self",
".",
"raw",
".",
"rang... | puts new data in 'raw' sheet for each call | [
"puts",
"new",
"data",
"in",
"'",
"raw",
"'",
"sheet",
"for",
"each",
"call"
] | [
"\"\"\"\n puts new data in 'raw' sheet for each call\n \"\"\"",
"# set latency on main screen",
"# list of IDS present",
"# set each row first column with ID ",
"# set column index for next loop",
"# go though the sorted array for ID"
] | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [... |
075bb1bebc374b576686e09a8a386cc9867ee7b1 | o-gent/aero_one | ground_station/display.py | [
"MIT"
] | Python | value_history | null | def value_history(self, id_list):
"""
keeps a history of a variable for use in time graphs
"""
for id_ in id_list:
self.raw.range(id_, 2).value = id_
id_list[id_] = [id_list[id_] , data[id_]['payload']] |
keeps a history of a variable for use in time graphs
| keeps a history of a variable for use in time graphs | [
"keeps",
"a",
"history",
"of",
"a",
"variable",
"for",
"use",
"in",
"time",
"graphs"
] | def value_history(self, id_list):
for id_ in id_list:
self.raw.range(id_, 2).value = id_
id_list[id_] = [id_list[id_] , data[id_]['payload']] | [
"def",
"value_history",
"(",
"self",
",",
"id_list",
")",
":",
"for",
"id_",
"in",
"id_list",
":",
"self",
".",
"raw",
".",
"range",
"(",
"id_",
",",
"2",
")",
".",
"value",
"=",
"id_",
"id_list",
"[",
"id_",
"]",
"=",
"[",
"id_list",
"[",
"id_",... | keeps a history of a variable for use in time graphs | [
"keeps",
"a",
"history",
"of",
"a",
"variable",
"for",
"use",
"in",
"time",
"graphs"
] | [
"\"\"\"\n keeps a history of a variable for use in time graphs\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id_list",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id_list",
"type": null,
"docstring": null,
"docstring_tokens"... |
4c348d30805794f0d2b035373babb2259b48c9bb | o-gent/aero_one | ground_station/datalink.py | [
"MIT"
] | Python | list_to_string | <not_specific> | def list_to_string(the_list):
""" converts list of ints to string """
a = ''
for secondary_list in the_list:
a += ' '
for item in secondary_list:
a += str(item)
a += ','
a += ' '
return a | converts list of ints to string | converts list of ints to string | [
"converts",
"list",
"of",
"ints",
"to",
"string"
] | def list_to_string(the_list):
a = ''
for secondary_list in the_list:
a += ' '
for item in secondary_list:
a += str(item)
a += ','
a += ' '
return a | [
"def",
"list_to_string",
"(",
"the_list",
")",
":",
"a",
"=",
"''",
"for",
"secondary_list",
"in",
"the_list",
":",
"a",
"+=",
"' '",
"for",
"item",
"in",
"secondary_list",
":",
"a",
"+=",
"str",
"(",
"item",
")",
"a",
"+=",
"','",
"a",
"+=",
"' '",
... | converts list of ints to string | [
"converts",
"list",
"of",
"ints",
"to",
"string"
] | [
"\"\"\" converts list of ints to string \"\"\""
] | [
{
"param": "the_list",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "the_list",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4c348d30805794f0d2b035373babb2259b48c9bb | o-gent/aero_one | ground_station/datalink.py | [
"MIT"
] | Python | string_to_list | <not_specific> | def string_to_list(the_string):
""" converts string to list of ints """
l = []
seperate_secondaries = the_string.split()
for secondary in enumerate(seperate_secondaries):
l.append([])
for item in secondary[1].split(',')[:-1]:
l[secondary[0]].append(int(item))
return l | converts string to list of ints | converts string to list of ints | [
"converts",
"string",
"to",
"list",
"of",
"ints"
] | def string_to_list(the_string):
l = []
seperate_secondaries = the_string.split()
for secondary in enumerate(seperate_secondaries):
l.append([])
for item in secondary[1].split(',')[:-1]:
l[secondary[0]].append(int(item))
return l | [
"def",
"string_to_list",
"(",
"the_string",
")",
":",
"l",
"=",
"[",
"]",
"seperate_secondaries",
"=",
"the_string",
".",
"split",
"(",
")",
"for",
"secondary",
"in",
"enumerate",
"(",
"seperate_secondaries",
")",
":",
"l",
".",
"append",
"(",
"[",
"]",
... | converts string to list of ints | [
"converts",
"string",
"to",
"list",
"of",
"ints"
] | [
"\"\"\" converts string to list of ints \"\"\""
] | [
{
"param": "the_string",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "the_string",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
267f1aad3f89e52e11c8083ebd256a30161d5be8 | o-gent/aero_one | pycom/lib/rcio.py | [
"MIT"
] | Python | rc_read_write | <not_specific> | def rc_read_write(conn, rc_write):
"""
get/send new RC data from UART
"""
try:
i = str(rc_write)[1:-1].replace(" ", "") + "\n"
conn.write(i.encode()) # definitly not great performance
rc_read = conn.readline().decode() # example: "0@500@500@0@500@992@\n"
return list(m... |
get/send new RC data from UART
| get/send new RC data from UART | [
"get",
"/",
"send",
"new",
"RC",
"data",
"from",
"UART"
] | def rc_read_write(conn, rc_write):
try:
i = str(rc_write)[1:-1].replace(" ", "") + "\n"
conn.write(i.encode())
rc_read = conn.readline().decode()
return list(map(int,rc_read.split('@')[:-1]))
except Exception as e:
print("exception in rc_read_write: {}".format(e))
... | [
"def",
"rc_read_write",
"(",
"conn",
",",
"rc_write",
")",
":",
"try",
":",
"i",
"=",
"str",
"(",
"rc_write",
")",
"[",
"1",
":",
"-",
"1",
"]",
".",
"replace",
"(",
"\" \"",
",",
"\"\"",
")",
"+",
"\"\\n\"",
"conn",
".",
"write",
"(",
"i",
"."... | get/send new RC data from UART | [
"get",
"/",
"send",
"new",
"RC",
"data",
"from",
"UART"
] | [
"\"\"\"\n get/send new RC data from UART\n \"\"\"",
"# definitly not great performance",
"# example: \"0@500@500@0@500@992@\\n\""
] | [
{
"param": "conn",
"type": null
},
{
"param": "rc_write",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "conn",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rc_write",
"type": null,
"docstring": null,
"docstring_tokens... |
63a7ed440b94a773571d70a0745569d6560ad350 | nigelsmall/cypy | cypy/graph/store.py | [
"Apache-2.0"
] | Python | node_count | <not_specific> | def node_count(self, *n_labels):
""" Count and return the number of nodes in this store.
:param n_labels: count only nodes with all these labels
:return: number of nodes
"""
if not n_labels:
return len(self._nodes)
elif len(n_labels) == 1:
return ... | Count and return the number of nodes in this store.
:param n_labels: count only nodes with all these labels
:return: number of nodes
| Count and return the number of nodes in this store. | [
"Count",
"and",
"return",
"the",
"number",
"of",
"nodes",
"in",
"this",
"store",
"."
] | def node_count(self, *n_labels):
if not n_labels:
return len(self._nodes)
elif len(n_labels) == 1:
return len(self._nodes_by_label.get(n_labels[0], ()))
else:
return sum(1 for _ in self.nodes(*n_labels)) | [
"def",
"node_count",
"(",
"self",
",",
"*",
"n_labels",
")",
":",
"if",
"not",
"n_labels",
":",
"return",
"len",
"(",
"self",
".",
"_nodes",
")",
"elif",
"len",
"(",
"n_labels",
")",
"==",
"1",
":",
"return",
"len",
"(",
"self",
".",
"_nodes_by_label... | Count and return the number of nodes in this store. | [
"Count",
"and",
"return",
"the",
"number",
"of",
"nodes",
"in",
"this",
"store",
"."
] | [
"\"\"\" Count and return the number of nodes in this store.\n\n :param n_labels: count only nodes with all these labels\n :return: number of nodes\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "number of nodes",
"docstring_tokens": [
"number",
"of",
"nodes"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
63a7ed440b94a773571d70a0745569d6560ad350 | nigelsmall/cypy | cypy/graph/store.py | [
"Apache-2.0"
] | Python | nodes | null | def nodes(self, *n_labels):
""" Return an iterator over the node keys in this store,
optionally filtered by label.
"""
if n_labels:
n_ids = ()
n_id_sets = []
for n_label in set(n_labels):
try:
n_id_sets.append(self._... | Return an iterator over the node keys in this store,
optionally filtered by label.
| Return an iterator over the node keys in this store,
optionally filtered by label. | [
"Return",
"an",
"iterator",
"over",
"the",
"node",
"keys",
"in",
"this",
"store",
"optionally",
"filtered",
"by",
"label",
"."
] | def nodes(self, *n_labels):
if n_labels:
n_ids = ()
n_id_sets = []
for n_label in set(n_labels):
try:
n_id_sets.append(self._nodes_by_label[n_label])
except KeyError:
break
else:
... | [
"def",
"nodes",
"(",
"self",
",",
"*",
"n_labels",
")",
":",
"if",
"n_labels",
":",
"n_ids",
"=",
"(",
")",
"n_id_sets",
"=",
"[",
"]",
"for",
"n_label",
"in",
"set",
"(",
"n_labels",
")",
":",
"try",
":",
"n_id_sets",
".",
"append",
"(",
"self",
... | Return an iterator over the node keys in this store,
optionally filtered by label. | [
"Return",
"an",
"iterator",
"over",
"the",
"node",
"keys",
"in",
"this",
"store",
"optionally",
"filtered",
"by",
"label",
"."
] | [
"\"\"\" Return an iterator over the node keys in this store,\n optionally filtered by label.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
63a7ed440b94a773571d70a0745569d6560ad350 | nigelsmall/cypy | cypy/graph/store.py | [
"Apache-2.0"
] | Python | node_labels | <not_specific> | def node_labels(self, n_id=None):
""" Return the set of labels in this store or those for a specific node.
"""
if n_id is None:
return frozenset(self._nodes_by_label.keys())
else:
try:
node_entry = self._nodes[n_id]
except KeyError:
... | Return the set of labels in this store or those for a specific node.
| Return the set of labels in this store or those for a specific node. | [
"Return",
"the",
"set",
"of",
"labels",
"in",
"this",
"store",
"or",
"those",
"for",
"a",
"specific",
"node",
"."
] | def node_labels(self, n_id=None):
if n_id is None:
return frozenset(self._nodes_by_label.keys())
else:
try:
node_entry = self._nodes[n_id]
except KeyError:
return None
else:
return node_entry.labels | [
"def",
"node_labels",
"(",
"self",
",",
"n_id",
"=",
"None",
")",
":",
"if",
"n_id",
"is",
"None",
":",
"return",
"frozenset",
"(",
"self",
".",
"_nodes_by_label",
".",
"keys",
"(",
")",
")",
"else",
":",
"try",
":",
"node_entry",
"=",
"self",
".",
... | Return the set of labels in this store or those for a specific node. | [
"Return",
"the",
"set",
"of",
"labels",
"in",
"this",
"store",
"or",
"those",
"for",
"a",
"specific",
"node",
"."
] | [
"\"\"\" Return the set of labels in this store or those for a specific node.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "n_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n_id",
"type": null,
"docstring": null,
"docstring_tokens": [... |
63a7ed440b94a773571d70a0745569d6560ad350 | nigelsmall/cypy | cypy/graph/store.py | [
"Apache-2.0"
] | Python | relationship_count | <not_specific> | def relationship_count(self, r_type=None, n_ids=()):
""" Count relationships filtered by type and endpoint.
"""
if r_type is None and not n_ids:
return len(self._relationships)
elif not n_ids:
return len(self._relationships_by_type.get(r_type, ()))
else:
... | Count relationships filtered by type and endpoint.
| Count relationships filtered by type and endpoint. | [
"Count",
"relationships",
"filtered",
"by",
"type",
"and",
"endpoint",
"."
] | def relationship_count(self, r_type=None, n_ids=()):
if r_type is None and not n_ids:
return len(self._relationships)
elif not n_ids:
return len(self._relationships_by_type.get(r_type, ()))
else:
return sum(1 for _ in self.relationships(r_type, n_ids)) | [
"def",
"relationship_count",
"(",
"self",
",",
"r_type",
"=",
"None",
",",
"n_ids",
"=",
"(",
")",
")",
":",
"if",
"r_type",
"is",
"None",
"and",
"not",
"n_ids",
":",
"return",
"len",
"(",
"self",
".",
"_relationships",
")",
"elif",
"not",
"n_ids",
"... | Count relationships filtered by type and endpoint. | [
"Count",
"relationships",
"filtered",
"by",
"type",
"and",
"endpoint",
"."
] | [
"\"\"\" Count relationships filtered by type and endpoint.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "r_type",
"type": null
},
{
"param": "n_ids",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r_type",
"type": null,
"docstring": null,
"docstring_tokens":... |
63a7ed440b94a773571d70a0745569d6560ad350 | nigelsmall/cypy | cypy/graph/store.py | [
"Apache-2.0"
] | Python | relationships | <not_specific> | def relationships(self, r_type=None, n_ids=()):
""" Match relationships filtered by type and endpoint.
:param r_type:
:param n_ids:
:return:
"""
if r_type is None:
r_sets = []
else:
r_sets = [self._relationships_by_type.get(r_type, frozens... | Match relationships filtered by type and endpoint.
:param r_type:
:param n_ids:
:return:
| Match relationships filtered by type and endpoint. | [
"Match",
"relationships",
"filtered",
"by",
"type",
"and",
"endpoint",
"."
] | def relationships(self, r_type=None, n_ids=()):
if r_type is None:
r_sets = []
else:
r_sets = [self._relationships_by_type.get(r_type, frozenset())]
if not n_ids or (hasattr(n_ids, "__iter__") and all(n_id is None for n_id in n_ids)):
pass
elif isinsta... | [
"def",
"relationships",
"(",
"self",
",",
"r_type",
"=",
"None",
",",
"n_ids",
"=",
"(",
")",
")",
":",
"if",
"r_type",
"is",
"None",
":",
"r_sets",
"=",
"[",
"]",
"else",
":",
"r_sets",
"=",
"[",
"self",
".",
"_relationships_by_type",
".",
"get",
... | Match relationships filtered by type and endpoint. | [
"Match",
"relationships",
"filtered",
"by",
"type",
"and",
"endpoint",
"."
] | [
"\"\"\" Match relationships filtered by type and endpoint.\n\n :param r_type:\n :param n_ids:\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "r_type",
"type": null
},
{
"param": "n_ids",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
63a7ed440b94a773571d70a0745569d6560ad350 | nigelsmall/cypy | cypy/graph/store.py | [
"Apache-2.0"
] | Python | discard_value | null | def discard_value(collection, key, value):
""" Discard an element from a value set.
For a `collection` that maps `key` to {`value1`, `value2`, ...}, discard
a specific `value` from the value set and drop the entire entry if the
set becomes empty.
"""
try:
values = collection[key]
ex... | Discard an element from a value set.
For a `collection` that maps `key` to {`value1`, `value2`, ...}, discard
a specific `value` from the value set and drop the entire entry if the
set becomes empty.
| Discard an element from a value set. | [
"Discard",
"an",
"element",
"from",
"a",
"value",
"set",
"."
] | def discard_value(collection, key, value):
try:
values = collection[key]
except KeyError:
pass
else:
values.discard(value)
if not values:
del collection[key] | [
"def",
"discard_value",
"(",
"collection",
",",
"key",
",",
"value",
")",
":",
"try",
":",
"values",
"=",
"collection",
"[",
"key",
"]",
"except",
"KeyError",
":",
"pass",
"else",
":",
"values",
".",
"discard",
"(",
"value",
")",
"if",
"not",
"values",... | Discard an element from a value set. | [
"Discard",
"an",
"element",
"from",
"a",
"value",
"set",
"."
] | [
"\"\"\" Discard an element from a value set.\n\n For a `collection` that maps `key` to {`value1`, `value2`, ...}, discard\n a specific `value` from the value set and drop the entire entry if the\n set becomes empty.\n \"\"\""
] | [
{
"param": "collection",
"type": null
},
{
"param": "key",
"type": null
},
{
"param": "value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "collection",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": null,
"docstring": null,
"docstring_token... |
d61937abb9a20003d9da173f6b6d5e460f073be9 | nigelsmall/cypy | cypy/graph/__init__.py | [
"Apache-2.0"
] | Python | view | <not_specific> | def view(cls, graph_structure, n_key):
""" Construct a Node attached to an existing store.
"""
inst = super(Node, cls).__new__(cls)
inst._id = n_key
inst._store = graph_structure.__graph_store__()
return inst | Construct a Node attached to an existing store.
| Construct a Node attached to an existing store. | [
"Construct",
"a",
"Node",
"attached",
"to",
"an",
"existing",
"store",
"."
] | def view(cls, graph_structure, n_key):
inst = super(Node, cls).__new__(cls)
inst._id = n_key
inst._store = graph_structure.__graph_store__()
return inst | [
"def",
"view",
"(",
"cls",
",",
"graph_structure",
",",
"n_key",
")",
":",
"inst",
"=",
"super",
"(",
"Node",
",",
"cls",
")",
".",
"__new__",
"(",
"cls",
")",
"inst",
".",
"_id",
"=",
"n_key",
"inst",
".",
"_store",
"=",
"graph_structure",
".",
"_... | Construct a Node attached to an existing store. | [
"Construct",
"a",
"Node",
"attached",
"to",
"an",
"existing",
"store",
"."
] | [
"\"\"\" Construct a Node attached to an existing store.\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "graph_structure",
"type": null
},
{
"param": "n_key",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "graph_structure",
"type": null,
"docstring": null,
"docstring_... |
d61937abb9a20003d9da173f6b6d5e460f073be9 | nigelsmall/cypy | cypy/graph/__init__.py | [
"Apache-2.0"
] | Python | labels | <not_specific> | def labels(self):
""" Return the set of all labels on this node.
:return: `frozenset` containing labels as strings
"""
labels = self._store.node_labels(self._id)
if labels is None:
raise KeyError("Entity not found in the graph")
return labels | Return the set of all labels on this node.
:return: `frozenset` containing labels as strings
| Return the set of all labels on this node. | [
"Return",
"the",
"set",
"of",
"all",
"labels",
"on",
"this",
"node",
"."
] | def labels(self):
labels = self._store.node_labels(self._id)
if labels is None:
raise KeyError("Entity not found in the graph")
return labels | [
"def",
"labels",
"(",
"self",
")",
":",
"labels",
"=",
"self",
".",
"_store",
".",
"node_labels",
"(",
"self",
".",
"_id",
")",
"if",
"labels",
"is",
"None",
":",
"raise",
"KeyError",
"(",
"\"Entity not found in the graph\"",
")",
"return",
"labels"
] | Return the set of all labels on this node. | [
"Return",
"the",
"set",
"of",
"all",
"labels",
"on",
"this",
"node",
"."
] | [
"\"\"\" Return the set of all labels on this node.\n\n :return: `frozenset` containing labels as strings\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "`frozenset` containing labels as strings",
"docstring_tokens": [
"`",
"frozenset",
"`",
"containing",
"labels",
"as",
"strings"
],
"type": null
}
],
"raises": [],
"params": [
{
"ident... |
d61937abb9a20003d9da173f6b6d5e460f073be9 | nigelsmall/cypy | cypy/graph/__init__.py | [
"Apache-2.0"
] | Python | nodes | <not_specific> | def nodes(self, *labels):
""" Select one or more nodes by label.
:param labels:
:return: an iterable selection of nodes
:rtype: :class:`.NodeSelection`
"""
return NodeSelection(self._store, self._store.nodes(*labels)) | Select one or more nodes by label.
:param labels:
:return: an iterable selection of nodes
:rtype: :class:`.NodeSelection`
| Select one or more nodes by label. | [
"Select",
"one",
"or",
"more",
"nodes",
"by",
"label",
"."
] | def nodes(self, *labels):
return NodeSelection(self._store, self._store.nodes(*labels)) | [
"def",
"nodes",
"(",
"self",
",",
"*",
"labels",
")",
":",
"return",
"NodeSelection",
"(",
"self",
".",
"_store",
",",
"self",
".",
"_store",
".",
"nodes",
"(",
"*",
"labels",
")",
")"
] | Select one or more nodes by label. | [
"Select",
"one",
"or",
"more",
"nodes",
"by",
"label",
"."
] | [
"\"\"\" Select one or more nodes by label.\n\n :param labels:\n :return: an iterable selection of nodes\n :rtype: :class:`.NodeSelection`\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "an iterable selection of nodes",
"docstring_tokens": [
"an",
"iterable",
"selection",
"of",
"nodes"
],
"type": ":class:`.NodeSelection`"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"... |
d61937abb9a20003d9da173f6b6d5e460f073be9 | nigelsmall/cypy | cypy/graph/__init__.py | [
"Apache-2.0"
] | Python | relationships | <not_specific> | def relationships(self, r_type=None, nodes=()):
""" Select one or more relationships by type and endpoints.
"""
if isinstance(nodes, Sequence):
return RelationshipSelection(self._store, self._store.relationships(r_type, [node.id for node in nodes]))
elif isinstance(nodes, Set... | Select one or more relationships by type and endpoints.
| Select one or more relationships by type and endpoints. | [
"Select",
"one",
"or",
"more",
"relationships",
"by",
"type",
"and",
"endpoints",
"."
] | def relationships(self, r_type=None, nodes=()):
if isinstance(nodes, Sequence):
return RelationshipSelection(self._store, self._store.relationships(r_type, [node.id for node in nodes]))
elif isinstance(nodes, Set):
return RelationshipSelection(self._store, self._store.relationshi... | [
"def",
"relationships",
"(",
"self",
",",
"r_type",
"=",
"None",
",",
"nodes",
"=",
"(",
")",
")",
":",
"if",
"isinstance",
"(",
"nodes",
",",
"Sequence",
")",
":",
"return",
"RelationshipSelection",
"(",
"self",
".",
"_store",
",",
"self",
".",
"_stor... | Select one or more relationships by type and endpoints. | [
"Select",
"one",
"or",
"more",
"relationships",
"by",
"type",
"and",
"endpoints",
"."
] | [
"\"\"\" Select one or more relationships by type and endpoints.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "r_type",
"type": null
},
{
"param": "nodes",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r_type",
"type": null,
"docstring": null,
"docstring_tokens":... |
d61937abb9a20003d9da173f6b6d5e460f073be9 | nigelsmall/cypy | cypy/graph/__init__.py | [
"Apache-2.0"
] | Python | graph_order | <not_specific> | def graph_order(graph_structure):
""" Count the number of nodes in a graph structure.
"""
try:
return graph_structure.__graph_order__()
except AttributeError:
raise TypeError("Object is not a graph structure") | Count the number of nodes in a graph structure.
| Count the number of nodes in a graph structure. | [
"Count",
"the",
"number",
"of",
"nodes",
"in",
"a",
"graph",
"structure",
"."
] | def graph_order(graph_structure):
try:
return graph_structure.__graph_order__()
except AttributeError:
raise TypeError("Object is not a graph structure") | [
"def",
"graph_order",
"(",
"graph_structure",
")",
":",
"try",
":",
"return",
"graph_structure",
".",
"__graph_order__",
"(",
")",
"except",
"AttributeError",
":",
"raise",
"TypeError",
"(",
"\"Object is not a graph structure\"",
")"
] | Count the number of nodes in a graph structure. | [
"Count",
"the",
"number",
"of",
"nodes",
"in",
"a",
"graph",
"structure",
"."
] | [
"\"\"\" Count the number of nodes in a graph structure.\n \"\"\""
] | [
{
"param": "graph_structure",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph_structure",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d61937abb9a20003d9da173f6b6d5e460f073be9 | nigelsmall/cypy | cypy/graph/__init__.py | [
"Apache-2.0"
] | Python | graph_size | <not_specific> | def graph_size(graph_structure):
""" Count the number of relationships in a graph structure.
"""
try:
return graph_structure.__graph_size__()
except AttributeError:
raise TypeError("Object is not a graph structure") | Count the number of relationships in a graph structure.
| Count the number of relationships in a graph structure. | [
"Count",
"the",
"number",
"of",
"relationships",
"in",
"a",
"graph",
"structure",
"."
] | def graph_size(graph_structure):
try:
return graph_structure.__graph_size__()
except AttributeError:
raise TypeError("Object is not a graph structure") | [
"def",
"graph_size",
"(",
"graph_structure",
")",
":",
"try",
":",
"return",
"graph_structure",
".",
"__graph_size__",
"(",
")",
"except",
"AttributeError",
":",
"raise",
"TypeError",
"(",
"\"Object is not a graph structure\"",
")"
] | Count the number of relationships in a graph structure. | [
"Count",
"the",
"number",
"of",
"relationships",
"in",
"a",
"graph",
"structure",
"."
] | [
"\"\"\" Count the number of relationships in a graph structure.\n \"\"\""
] | [
{
"param": "graph_structure",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph_structure",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | coerce | <not_specific> | def coerce(cls, value, encoding=None):
""" Coerce a Python value to an appropriate Cypher value.
The supported mappings are:
===================== =============== =========== =====
Python Type Python Versions Cypher Type Notes
===================== ============... | Coerce a Python value to an appropriate Cypher value.
The supported mappings are:
===================== =============== =========== =====
Python Type Python Versions Cypher Type Notes
===================== =============== =========== =====
:py:const:`None` ... | Coerce a Python value to an appropriate Cypher value.
The supported mappings are.
Python Type Python Versions Cypher Type Notes | [
"Coerce",
"a",
"Python",
"value",
"to",
"an",
"appropriate",
"Cypher",
"value",
".",
"The",
"supported",
"mappings",
"are",
".",
"Python",
"Type",
"Python",
"Versions",
"Cypher",
"Type",
"Notes"
] | def coerce(cls, value, encoding=None):
from cypy.graph import Node, Relationship, Path
if value is None:
return cls.coerce_null(value)
elif isinstance(value, bool):
return cls.coerce_boolean(value)
elif isinstance(value, integer_types):
return cls.coer... | [
"def",
"coerce",
"(",
"cls",
",",
"value",
",",
"encoding",
"=",
"None",
")",
":",
"from",
"cypy",
".",
"graph",
"import",
"Node",
",",
"Relationship",
",",
"Path",
"if",
"value",
"is",
"None",
":",
"return",
"cls",
".",
"coerce_null",
"(",
"value",
... | Coerce a Python value to an appropriate Cypher value. | [
"Coerce",
"a",
"Python",
"value",
"to",
"an",
"appropriate",
"Cypher",
"value",
"."
] | [
"\"\"\" Coerce a Python value to an appropriate Cypher value.\n\n The supported mappings are:\n\n ===================== =============== =========== =====\n Python Type Python Versions Cypher Type Notes\n ===================== =============== =========== =====\n ... | [
{
"param": "cls",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "encoding",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": [... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | coerce_null | <not_specific> | def coerce_null(cls, _):
""" Coerce a Python value to a Cypher Null.
:returns: :py:const:`None`
"""
if cls.nullable:
return None
else:
raise ValueError("Null values are not supported") | Coerce a Python value to a Cypher Null.
:returns: :py:const:`None`
| Coerce a Python value to a Cypher Null. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"Null",
"."
] | def coerce_null(cls, _):
if cls.nullable:
return None
else:
raise ValueError("Null values are not supported") | [
"def",
"coerce_null",
"(",
"cls",
",",
"_",
")",
":",
"if",
"cls",
".",
"nullable",
":",
"return",
"None",
"else",
":",
"raise",
"ValueError",
"(",
"\"Null values are not supported\"",
")"
] | Coerce a Python value to a Cypher Null. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"Null",
"."
] | [
"\"\"\" Coerce a Python value to a Cypher Null.\n\n :returns: :py:const:`None`\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "_",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | coerce_boolean | <not_specific> | def coerce_boolean(cls, value):
""" Coerce a Python value to a Cypher Boolean.
:rtype: :py:class:`bool`
"""
return bool(value) | Coerce a Python value to a Cypher Boolean.
:rtype: :py:class:`bool`
| Coerce a Python value to a Cypher Boolean. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"Boolean",
"."
] | def coerce_boolean(cls, value):
return bool(value) | [
"def",
"coerce_boolean",
"(",
"cls",
",",
"value",
")",
":",
"return",
"bool",
"(",
"value",
")"
] | Coerce a Python value to a Cypher Boolean. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"Boolean",
"."
] | [
"\"\"\" Coerce a Python value to a Cypher Boolean.\n\n :rtype: :py:class:`bool`\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "value",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": ":py:class:`bool`"
}
],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optio... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | coerce_integer | <not_specific> | def coerce_integer(cls, value):
""" Coerce a Python value to a Cypher Integer.
:rtype: :py:class:`int`
:raises ValueError: if out of range for a 64-bit signed integer
"""
if (-2 ** 63) <= value < (2 ** 63):
return int(value)
else:
raise ValueError... | Coerce a Python value to a Cypher Integer.
:rtype: :py:class:`int`
:raises ValueError: if out of range for a 64-bit signed integer
| Coerce a Python value to a Cypher Integer. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"Integer",
"."
] | def coerce_integer(cls, value):
if (-2 ** 63) <= value < (2 ** 63):
return int(value)
else:
raise ValueError("Integer value out of range: %s" % value) | [
"def",
"coerce_integer",
"(",
"cls",
",",
"value",
")",
":",
"if",
"(",
"-",
"2",
"**",
"63",
")",
"<=",
"value",
"<",
"(",
"2",
"**",
"63",
")",
":",
"return",
"int",
"(",
"value",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"Integer value out... | Coerce a Python value to a Cypher Integer. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"Integer",
"."
] | [
"\"\"\" Coerce a Python value to a Cypher Integer.\n\n :rtype: :py:class:`int`\n :raises ValueError: if out of range for a 64-bit signed integer\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "value",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": ":py:class:`int`"
}
],
"raises": [
{
"docstring": "if out of range for a 64-bit signed integer",
"docstring_tokens": [
"if",
"out",
"of",
"range",
... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | coerce_float | <not_specific> | def coerce_float(cls, value):
""" Coerce a Python value to a Cypher Float.
:rtype: :py:class:`float`
"""
return float(value) | Coerce a Python value to a Cypher Float.
:rtype: :py:class:`float`
| Coerce a Python value to a Cypher Float. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"Float",
"."
] | def coerce_float(cls, value):
return float(value) | [
"def",
"coerce_float",
"(",
"cls",
",",
"value",
")",
":",
"return",
"float",
"(",
"value",
")"
] | Coerce a Python value to a Cypher Float. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"Float",
"."
] | [
"\"\"\" Coerce a Python value to a Cypher Float.\n\n :rtype: :py:class:`float`\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "value",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": ":py:class:`float`"
}
],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_opti... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | coerce_bytes | <not_specific> | def coerce_bytes(cls, value, encoding=None):
""" Coerce a Python value to Cypher Bytes.
:rtype: :py:class:`bytearray`
"""
return bstr(value, encoding or cls.default_encoding) | Coerce a Python value to Cypher Bytes.
:rtype: :py:class:`bytearray`
| Coerce a Python value to Cypher Bytes. | [
"Coerce",
"a",
"Python",
"value",
"to",
"Cypher",
"Bytes",
"."
] | def coerce_bytes(cls, value, encoding=None):
return bstr(value, encoding or cls.default_encoding) | [
"def",
"coerce_bytes",
"(",
"cls",
",",
"value",
",",
"encoding",
"=",
"None",
")",
":",
"return",
"bstr",
"(",
"value",
",",
"encoding",
"or",
"cls",
".",
"default_encoding",
")"
] | Coerce a Python value to Cypher Bytes. | [
"Coerce",
"a",
"Python",
"value",
"to",
"Cypher",
"Bytes",
"."
] | [
"\"\"\" Coerce a Python value to Cypher Bytes.\n\n :rtype: :py:class:`bytearray`\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "encoding",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": ":py:class:`bytearray`"
}
],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | coerce_string | <not_specific> | def coerce_string(cls, value, encoding=None):
""" Coerce a Python value to a Cypher String.
:rtype: :py:class:`str` (or :py:class:`unicode` in Python 2)
"""
return ustr(value, encoding or cls.default_encoding) | Coerce a Python value to a Cypher String.
:rtype: :py:class:`str` (or :py:class:`unicode` in Python 2)
| Coerce a Python value to a Cypher String. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"String",
"."
] | def coerce_string(cls, value, encoding=None):
return ustr(value, encoding or cls.default_encoding) | [
"def",
"coerce_string",
"(",
"cls",
",",
"value",
",",
"encoding",
"=",
"None",
")",
":",
"return",
"ustr",
"(",
"value",
",",
"encoding",
"or",
"cls",
".",
"default_encoding",
")"
] | Coerce a Python value to a Cypher String. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"String",
"."
] | [
"\"\"\" Coerce a Python value to a Cypher String.\n\n :rtype: :py:class:`str` (or :py:class:`unicode` in Python 2)\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "encoding",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": ":py:class:`str` (or :py:class:`unicode` in Python 2)"
}
],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | coerce_map | <not_specific> | def coerce_map(cls, value, encoding=None):
""" Coerce a Python value to a Cypher Map.
:rtype: :py:class:`dict`
"""
if encoding is None:
encoding = cls.default_encoding
return {cls.coerce(key, encoding): cls.coerce(value, encoding) for key, value in value.items()} | Coerce a Python value to a Cypher Map.
:rtype: :py:class:`dict`
| Coerce a Python value to a Cypher Map. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"Map",
"."
] | def coerce_map(cls, value, encoding=None):
if encoding is None:
encoding = cls.default_encoding
return {cls.coerce(key, encoding): cls.coerce(value, encoding) for key, value in value.items()} | [
"def",
"coerce_map",
"(",
"cls",
",",
"value",
",",
"encoding",
"=",
"None",
")",
":",
"if",
"encoding",
"is",
"None",
":",
"encoding",
"=",
"cls",
".",
"default_encoding",
"return",
"{",
"cls",
".",
"coerce",
"(",
"key",
",",
"encoding",
")",
":",
"... | Coerce a Python value to a Cypher Map. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"Map",
"."
] | [
"\"\"\" Coerce a Python value to a Cypher Map.\n\n :rtype: :py:class:`dict`\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "encoding",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": ":py:class:`dict`"
}
],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optio... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | coerce_list | <not_specific> | def coerce_list(cls, value, encoding=None):
""" Coerce a Python value to a Cypher List.
:rtype: :py:class:`list`
"""
return [cls.coerce(item, encoding or cls.default_encoding) for item in value] | Coerce a Python value to a Cypher List.
:rtype: :py:class:`list`
| Coerce a Python value to a Cypher List. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"List",
"."
] | def coerce_list(cls, value, encoding=None):
return [cls.coerce(item, encoding or cls.default_encoding) for item in value] | [
"def",
"coerce_list",
"(",
"cls",
",",
"value",
",",
"encoding",
"=",
"None",
")",
":",
"return",
"[",
"cls",
".",
"coerce",
"(",
"item",
",",
"encoding",
"or",
"cls",
".",
"default_encoding",
")",
"for",
"item",
"in",
"value",
"]"
] | Coerce a Python value to a Cypher List. | [
"Coerce",
"a",
"Python",
"value",
"to",
"a",
"Cypher",
"List",
"."
] | [
"\"\"\" Coerce a Python value to a Cypher List.\n\n :rtype: :py:class:`list`\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "encoding",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": ":py:class:`list`"
}
],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optio... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | index | <not_specific> | def index(self, item):
""" Return the index of the given item.
"""
if isinstance(item, integer_types):
if 0 <= item < len(self.__keys):
return item
raise IndexError(item)
else:
try:
return self.__keys.index(item)
... | Return the index of the given item.
| Return the index of the given item. | [
"Return",
"the",
"index",
"of",
"the",
"given",
"item",
"."
] | def index(self, item):
if isinstance(item, integer_types):
if 0 <= item < len(self.__keys):
return item
raise IndexError(item)
else:
try:
return self.__keys.index(item)
except ValueError:
raise KeyError(item) | [
"def",
"index",
"(",
"self",
",",
"item",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"integer_types",
")",
":",
"if",
"0",
"<=",
"item",
"<",
"len",
"(",
"self",
".",
"__keys",
")",
":",
"return",
"item",
"raise",
"IndexError",
"(",
"item",
")... | Return the index of the given item. | [
"Return",
"the",
"index",
"of",
"the",
"given",
"item",
"."
] | [
"\"\"\" Return the index of the given item.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "item",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "item",
"type": null,
"docstring": null,
"docstring_tokens": [... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | value | <not_specific> | def value(self, item=0, default=None):
""" Obtain a single value from the record by index or key. If no
index or key is specified, the first value is returned. If the
specified item does not exist, the default value is returned.
:param item:
:param default:
:return:
... | Obtain a single value from the record by index or key. If no
index or key is specified, the first value is returned. If the
specified item does not exist, the default value is returned.
:param item:
:param default:
:return:
| Obtain a single value from the record by index or key. If no
index or key is specified, the first value is returned. If the
specified item does not exist, the default value is returned. | [
"Obtain",
"a",
"single",
"value",
"from",
"the",
"record",
"by",
"index",
"or",
"key",
".",
"If",
"no",
"index",
"or",
"key",
"is",
"specified",
"the",
"first",
"value",
"is",
"returned",
".",
"If",
"the",
"specified",
"item",
"does",
"not",
"exist",
"... | def value(self, item=0, default=None):
try:
index = self.index(item)
except (IndexError, KeyError):
return default
else:
return self[index] | [
"def",
"value",
"(",
"self",
",",
"item",
"=",
"0",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"index",
"=",
"self",
".",
"index",
"(",
"item",
")",
"except",
"(",
"IndexError",
",",
"KeyError",
")",
":",
"return",
"default",
"else",
":",
... | Obtain a single value from the record by index or key. | [
"Obtain",
"a",
"single",
"value",
"from",
"the",
"record",
"by",
"index",
"or",
"key",
"."
] | [
"\"\"\" Obtain a single value from the record by index or key. If no\n index or key is specified, the first value is returned. If the\n specified item does not exist, the default value is returned.\n\n :param item:\n :param default:\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "item",
"type": null
},
{
"param": "default",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | keys | <not_specific> | def keys(self):
""" Return the keys of the record.
:return: tuple of key names
"""
return self.__keys | Return the keys of the record.
:return: tuple of key names
| Return the keys of the record. | [
"Return",
"the",
"keys",
"of",
"the",
"record",
"."
] | def keys(self):
return self.__keys | [
"def",
"keys",
"(",
"self",
")",
":",
"return",
"self",
".",
"__keys"
] | Return the keys of the record. | [
"Return",
"the",
"keys",
"of",
"the",
"record",
"."
] | [
"\"\"\" Return the keys of the record.\n\n :return: tuple of key names\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "tuple of key names",
"docstring_tokens": [
"tuple",
"of",
"key",
"names"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_t... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | values | <not_specific> | def values(self, *items):
""" Return the values of the record, optionally filtering to
include only certain values by index or key.
:param items: indexes or keys of the items to include; if none
are provided, all values will be included
:return: tuple of values... | Return the values of the record, optionally filtering to
include only certain values by index or key.
:param items: indexes or keys of the items to include; if none
are provided, all values will be included
:return: tuple of values
| Return the values of the record, optionally filtering to
include only certain values by index or key. | [
"Return",
"the",
"values",
"of",
"the",
"record",
"optionally",
"filtering",
"to",
"include",
"only",
"certain",
"values",
"by",
"index",
"or",
"key",
"."
] | def values(self, *items):
if items:
d = []
for item in items:
try:
i = self.index(item)
except KeyError:
d.append(None)
else:
d.append(self[i])
return tuple(d)
... | [
"def",
"values",
"(",
"self",
",",
"*",
"items",
")",
":",
"if",
"items",
":",
"d",
"=",
"[",
"]",
"for",
"item",
"in",
"items",
":",
"try",
":",
"i",
"=",
"self",
".",
"index",
"(",
"item",
")",
"except",
"KeyError",
":",
"d",
".",
"append",
... | Return the values of the record, optionally filtering to
include only certain values by index or key. | [
"Return",
"the",
"values",
"of",
"the",
"record",
"optionally",
"filtering",
"to",
"include",
"only",
"certain",
"values",
"by",
"index",
"or",
"key",
"."
] | [
"\"\"\" Return the values of the record, optionally filtering to\n include only certain values by index or key.\n\n :param items: indexes or keys of the items to include; if none\n are provided, all values will be included\n :return: tuple of values\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "tuple of values",
"docstring_tokens": [
"tuple",
"of",
"values"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | items | <not_specific> | def items(self):
""" Return the fields of the record as a list of key and value tuples
:return:
"""
return tuple((self.__keys[i], super(Record, self).__getitem__(i)) for i in range(len(self))) | Return the fields of the record as a list of key and value tuples
:return:
| Return the fields of the record as a list of key and value tuples | [
"Return",
"the",
"fields",
"of",
"the",
"record",
"as",
"a",
"list",
"of",
"key",
"and",
"value",
"tuples"
] | def items(self):
return tuple((self.__keys[i], super(Record, self).__getitem__(i)) for i in range(len(self))) | [
"def",
"items",
"(",
"self",
")",
":",
"return",
"tuple",
"(",
"(",
"self",
".",
"__keys",
"[",
"i",
"]",
",",
"super",
"(",
"Record",
",",
"self",
")",
".",
"__getitem__",
"(",
"i",
")",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",... | Return the fields of the record as a list of key and value tuples | [
"Return",
"the",
"fields",
"of",
"the",
"record",
"as",
"a",
"list",
"of",
"key",
"and",
"value",
"tuples"
] | [
"\"\"\" Return the fields of the record as a list of key and value tuples\n\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
93cf00daf70e474c69fdaea7d16c955fc596261e | nigelsmall/cypy | cypy/data.py | [
"Apache-2.0"
] | Python | data | <not_specific> | def data(self, *items):
""" Return the keys and values of this record as a dictionary,
optionally including only certain values by index or key. Keys
provided in the items that are not in the record will be
inserted with a value of :py:const:`None`; indexes provided
that are out ... | Return the keys and values of this record as a dictionary,
optionally including only certain values by index or key. Keys
provided in the items that are not in the record will be
inserted with a value of :py:const:`None`; indexes provided
that are out of bounds will trigger an :py:`Inde... | Return the keys and values of this record as a dictionary,
optionally including only certain values by index or key. | [
"Return",
"the",
"keys",
"and",
"values",
"of",
"this",
"record",
"as",
"a",
"dictionary",
"optionally",
"including",
"only",
"certain",
"values",
"by",
"index",
"or",
"key",
"."
] | def data(self, *items):
if items:
d = {}
keys = self.__keys
for item in items:
try:
i = self.index(item)
except KeyError:
d[item] = None
else:
d[keys[i]] = self[i]
... | [
"def",
"data",
"(",
"self",
",",
"*",
"items",
")",
":",
"if",
"items",
":",
"d",
"=",
"{",
"}",
"keys",
"=",
"self",
".",
"__keys",
"for",
"item",
"in",
"items",
":",
"try",
":",
"i",
"=",
"self",
".",
"index",
"(",
"item",
")",
"except",
"K... | Return the keys and values of this record as a dictionary,
optionally including only certain values by index or key. | [
"Return",
"the",
"keys",
"and",
"values",
"of",
"this",
"record",
"as",
"a",
"dictionary",
"optionally",
"including",
"only",
"certain",
"values",
"by",
"index",
"or",
"key",
"."
] | [
"\"\"\" Return the keys and values of this record as a dictionary,\n optionally including only certain values by index or key. Keys\n provided in the items that are not in the record will be\n inserted with a value of :py:const:`None`; indexes provided\n that are out of bounds will trigg... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "dictionary of values, keyed by field name",
"docstring_tokens": [
"dictionary",
"of",
"values",
"keyed",
"by",
"field",
"name"
],
"type": null
}
],
"raises": [
{
"docstring": ":py:`Inde... |
803598968a13548beabac654609b9029e66bf24d | nigelsmall/cypy | cypy/collections.py | [
"Apache-2.0"
] | Python | add | null | def add(self, element):
""" Add an element to the set.
:triggers: `on_add`
"""
if element not in self:
set.add(self, element)
if callable(self._on_add):
self._on_add(element) | Add an element to the set.
:triggers: `on_add`
| Add an element to the set. | [
"Add",
"an",
"element",
"to",
"the",
"set",
"."
] | def add(self, element):
if element not in self:
set.add(self, element)
if callable(self._on_add):
self._on_add(element) | [
"def",
"add",
"(",
"self",
",",
"element",
")",
":",
"if",
"element",
"not",
"in",
"self",
":",
"set",
".",
"add",
"(",
"self",
",",
"element",
")",
"if",
"callable",
"(",
"self",
".",
"_on_add",
")",
":",
"self",
".",
"_on_add",
"(",
"element",
... | Add an element to the set. | [
"Add",
"an",
"element",
"to",
"the",
"set",
"."
] | [
"\"\"\" Add an element to the set.\n\n :triggers: `on_add`\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "element",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "element",
"type": null,
"docstring": null,
"docstring_tokens"... |
803598968a13548beabac654609b9029e66bf24d | nigelsmall/cypy | cypy/collections.py | [
"Apache-2.0"
] | Python | remove | null | def remove(self, element):
""" Remove an element from the set.
:triggers: `on_remove`
"""
set.remove(self, element)
if callable(self._on_remove):
self._on_remove(element) | Remove an element from the set.
:triggers: `on_remove`
| Remove an element from the set. | [
"Remove",
"an",
"element",
"from",
"the",
"set",
"."
] | def remove(self, element):
set.remove(self, element)
if callable(self._on_remove):
self._on_remove(element) | [
"def",
"remove",
"(",
"self",
",",
"element",
")",
":",
"set",
".",
"remove",
"(",
"self",
",",
"element",
")",
"if",
"callable",
"(",
"self",
".",
"_on_remove",
")",
":",
"self",
".",
"_on_remove",
"(",
"element",
")"
] | Remove an element from the set. | [
"Remove",
"an",
"element",
"from",
"the",
"set",
"."
] | [
"\"\"\" Remove an element from the set.\n\n :triggers: `on_remove`\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "element",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "element",
"type": null,
"docstring": null,
"docstring_tokens"... |
803598968a13548beabac654609b9029e66bf24d | nigelsmall/cypy | cypy/collections.py | [
"Apache-2.0"
] | Python | discard | null | def discard(self, element):
""" Discard an element from the set.
:triggers: `on_remove`
"""
if element in self:
set.discard(self, element)
if callable(self._on_remove):
self._on_remove(element) | Discard an element from the set.
:triggers: `on_remove`
| Discard an element from the set. | [
"Discard",
"an",
"element",
"from",
"the",
"set",
"."
] | def discard(self, element):
if element in self:
set.discard(self, element)
if callable(self._on_remove):
self._on_remove(element) | [
"def",
"discard",
"(",
"self",
",",
"element",
")",
":",
"if",
"element",
"in",
"self",
":",
"set",
".",
"discard",
"(",
"self",
",",
"element",
")",
"if",
"callable",
"(",
"self",
".",
"_on_remove",
")",
":",
"self",
".",
"_on_remove",
"(",
"element... | Discard an element from the set. | [
"Discard",
"an",
"element",
"from",
"the",
"set",
"."
] | [
"\"\"\" Discard an element from the set.\n\n :triggers: `on_remove`\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "element",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "element",
"type": null,
"docstring": null,
"docstring_tokens"... |
803598968a13548beabac654609b9029e66bf24d | nigelsmall/cypy | cypy/collections.py | [
"Apache-2.0"
] | Python | pop | <not_specific> | def pop(self):
""" Remove an arbitrary element from the set.
:triggers: `on_remove`
"""
element = set.pop(self)
if callable(self._on_remove):
self._on_remove(element)
return element | Remove an arbitrary element from the set.
:triggers: `on_remove`
| Remove an arbitrary element from the set. | [
"Remove",
"an",
"arbitrary",
"element",
"from",
"the",
"set",
"."
] | def pop(self):
element = set.pop(self)
if callable(self._on_remove):
self._on_remove(element)
return element | [
"def",
"pop",
"(",
"self",
")",
":",
"element",
"=",
"set",
".",
"pop",
"(",
"self",
")",
"if",
"callable",
"(",
"self",
".",
"_on_remove",
")",
":",
"self",
".",
"_on_remove",
"(",
"element",
")",
"return",
"element"
] | Remove an arbitrary element from the set. | [
"Remove",
"an",
"arbitrary",
"element",
"from",
"the",
"set",
"."
] | [
"\"\"\" Remove an arbitrary element from the set.\n\n :triggers: `on_remove`\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": [
{
"identifier": "triggers",
"docstring": null,
... |
803598968a13548beabac654609b9029e66bf24d | nigelsmall/cypy | cypy/collections.py | [
"Apache-2.0"
] | Python | clear | null | def clear(self):
""" Remove all elements from the set.
:triggers: `on_remove`
"""
elements = set(self)
set.clear(self)
if callable(self._on_remove):
self._on_remove(*elements) | Remove all elements from the set.
:triggers: `on_remove`
| Remove all elements from the set. | [
"Remove",
"all",
"elements",
"from",
"the",
"set",
"."
] | def clear(self):
elements = set(self)
set.clear(self)
if callable(self._on_remove):
self._on_remove(*elements) | [
"def",
"clear",
"(",
"self",
")",
":",
"elements",
"=",
"set",
"(",
"self",
")",
"set",
".",
"clear",
"(",
"self",
")",
"if",
"callable",
"(",
"self",
".",
"_on_remove",
")",
":",
"self",
".",
"_on_remove",
"(",
"*",
"elements",
")"
] | Remove all elements from the set. | [
"Remove",
"all",
"elements",
"from",
"the",
"set",
"."
] | [
"\"\"\" Remove all elements from the set.\n\n :triggers: `on_remove`\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": [
{
"identifier": "triggers",
"docstring": null,
... |
b4afa8853fc8814be442026f60cff42d70731652 | nigelsmall/cypy | cypy/compat.py | [
"Apache-2.0"
] | Python | bstr | <not_specific> | def bstr(value, encoding="utf-8"):
""" Convert a value to a byte string, held in a Python `bytearray` object.
"""
if isinstance(value, bytearray):
return value
elif isinstance(value, bytes):
return bytearray(value)
elif isinstance(value, str):
... | Convert a value to a byte string, held in a Python `bytearray` object.
| Convert a value to a byte string, held in a Python `bytearray` object. | [
"Convert",
"a",
"value",
"to",
"a",
"byte",
"string",
"held",
"in",
"a",
"Python",
"`",
"bytearray",
"`",
"object",
"."
] | def bstr(value, encoding="utf-8"):
if isinstance(value, bytearray):
return value
elif isinstance(value, bytes):
return bytearray(value)
elif isinstance(value, str):
return bytearray(value.encode(encoding=encoding))
else:
try:
... | [
"def",
"bstr",
"(",
"value",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bytearray",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"bytes",
")",
":",
"return",
"bytearray",
"(",
"value",
... | Convert a value to a byte string, held in a Python `bytearray` object. | [
"Convert",
"a",
"value",
"to",
"a",
"byte",
"string",
"held",
"in",
"a",
"Python",
"`",
"bytearray",
"`",
"object",
"."
] | [
"\"\"\" Convert a value to a byte string, held in a Python `bytearray` object.\n \"\"\""
] | [
{
"param": "value",
"type": null
},
{
"param": "encoding",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "encoding",
"type": null,
"docstring": null,
"docstring_token... |
b4afa8853fc8814be442026f60cff42d70731652 | nigelsmall/cypy | cypy/compat.py | [
"Apache-2.0"
] | Python | ustr | <not_specific> | def ustr(value, encoding="utf-8"):
""" Convert a value to a Unicode string, held in a Python `str` object.
"""
if isinstance(value, str):
return value
elif isinstance(value, (bytes, bytearray)):
return value.decode(encoding=encoding)
else:
try:... | Convert a value to a Unicode string, held in a Python `str` object.
| Convert a value to a Unicode string, held in a Python `str` object. | [
"Convert",
"a",
"value",
"to",
"a",
"Unicode",
"string",
"held",
"in",
"a",
"Python",
"`",
"str",
"`",
"object",
"."
] | def ustr(value, encoding="utf-8"):
if isinstance(value, str):
return value
elif isinstance(value, (bytes, bytearray)):
return value.decode(encoding=encoding)
else:
try:
return value.__str__()
except AttributeError:
r... | [
"def",
"ustr",
"(",
"value",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"(",
"bytes",
",",
"bytearray",
")",
")",
":",
"return",
"va... | Convert a value to a Unicode string, held in a Python `str` object. | [
"Convert",
"a",
"value",
"to",
"a",
"Unicode",
"string",
"held",
"in",
"a",
"Python",
"`",
"str",
"`",
"object",
"."
] | [
"\"\"\" Convert a value to a Unicode string, held in a Python `str` object.\n \"\"\""
] | [
{
"param": "value",
"type": null
},
{
"param": "encoding",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "encoding",
"type": null,
"docstring": null,
"docstring_token... |
b4afa8853fc8814be442026f60cff42d70731652 | nigelsmall/cypy | cypy/compat.py | [
"Apache-2.0"
] | Python | bstr | <not_specific> | def bstr(value, encoding="utf-8"):
""" Convert a value to byte string, held in a Python `bytearray` object.
"""
if isinstance(value, bytearray):
return value
elif isinstance(value, bytes):
return bytearray(value)
elif isinstance(value, unicode):
... | Convert a value to byte string, held in a Python `bytearray` object.
| Convert a value to byte string, held in a Python `bytearray` object. | [
"Convert",
"a",
"value",
"to",
"byte",
"string",
"held",
"in",
"a",
"Python",
"`",
"bytearray",
"`",
"object",
"."
] | def bstr(value, encoding="utf-8"):
if isinstance(value, bytearray):
return value
elif isinstance(value, bytes):
return bytearray(value)
elif isinstance(value, unicode):
return bytearray(value.encode(encoding=encoding))
else:
try:
... | [
"def",
"bstr",
"(",
"value",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bytearray",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"bytes",
")",
":",
"return",
"bytearray",
"(",
"value",
... | Convert a value to byte string, held in a Python `bytearray` object. | [
"Convert",
"a",
"value",
"to",
"byte",
"string",
"held",
"in",
"a",
"Python",
"`",
"bytearray",
"`",
"object",
"."
] | [
"\"\"\" Convert a value to byte string, held in a Python `bytearray` object.\n \"\"\""
] | [
{
"param": "value",
"type": null
},
{
"param": "encoding",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "encoding",
"type": null,
"docstring": null,
"docstring_token... |
b4afa8853fc8814be442026f60cff42d70731652 | nigelsmall/cypy | cypy/compat.py | [
"Apache-2.0"
] | Python | ustr | <not_specific> | def ustr(value, encoding="utf-8"):
""" Convert a value to a Unicode string, held in a Python `unicode` object.
"""
if isinstance(value, unicode):
return value
elif isinstance(value, (bytes, bytearray)):
return value.decode(encoding=encoding)
else:
... | Convert a value to a Unicode string, held in a Python `unicode` object.
| Convert a value to a Unicode string, held in a Python `unicode` object. | [
"Convert",
"a",
"value",
"to",
"a",
"Unicode",
"string",
"held",
"in",
"a",
"Python",
"`",
"unicode",
"`",
"object",
"."
] | def ustr(value, encoding="utf-8"):
if isinstance(value, unicode):
return value
elif isinstance(value, (bytes, bytearray)):
return value.decode(encoding=encoding)
else:
try:
return value.__unicode__()
except AttributeError:
... | [
"def",
"ustr",
"(",
"value",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"unicode",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"(",
"bytes",
",",
"bytearray",
")",
")",
":",
"return",
... | Convert a value to a Unicode string, held in a Python `unicode` object. | [
"Convert",
"a",
"value",
"to",
"a",
"Unicode",
"string",
"held",
"in",
"a",
"Python",
"`",
"unicode",
"`",
"object",
"."
] | [
"\"\"\" Convert a value to a Unicode string, held in a Python `unicode` object.\n \"\"\""
] | [
{
"param": "value",
"type": null
},
{
"param": "encoding",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "encoding",
"type": null,
"docstring": null,
"docstring_token... |
95fa772c12f483931bf5849c83d4a515f3daa509 | nigelsmall/cypy | cypy/encoding.py | [
"Apache-2.0"
] | Python | cypher_str | <not_specific> | def cypher_str(value, **kwargs):
""" Convert a Cypher value to a Python Unicode string.
"""
if isinstance(value, unicode):
return value
elif isinstance(value, bytes):
return value.decode(kwargs.get("encoding", "utf-8"))
else:
return cypher_repr(value, **kwargs) | Convert a Cypher value to a Python Unicode string.
| Convert a Cypher value to a Python Unicode string. | [
"Convert",
"a",
"Cypher",
"value",
"to",
"a",
"Python",
"Unicode",
"string",
"."
] | def cypher_str(value, **kwargs):
if isinstance(value, unicode):
return value
elif isinstance(value, bytes):
return value.decode(kwargs.get("encoding", "utf-8"))
else:
return cypher_repr(value, **kwargs) | [
"def",
"cypher_str",
"(",
"value",
",",
"**",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"unicode",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"bytes",
")",
":",
"return",
"value",
".",
"decode",
"(",
"kwargs"... | Convert a Cypher value to a Python Unicode string. | [
"Convert",
"a",
"Cypher",
"value",
"to",
"a",
"Python",
"Unicode",
"string",
"."
] | [
"\"\"\" Convert a Cypher value to a Python Unicode string.\n \"\"\""
] | [
{
"param": "value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c0bab01a93fa7dccbb6240731060b5860072e3f2 | mysocketio/mysocketctl | mysocketctl/connect.py | [
"Apache-2.0"
] | Python | connect | null | def connect(
ctx,
port,
name,
protected,
username,
password,
host,
type,
engine,
cloudauth,
allowed_email_addresses,
allowed_email_domains,
):
"""Quckly connect, Wrapper around sockets and tunnels"""
if cloudauth:
cloudauth = True
allowed_email_ad... | Quckly connect, Wrapper around sockets and tunnels | Quckly connect, Wrapper around sockets and tunnels | [
"Quckly",
"connect",
"Wrapper",
"around",
"sockets",
"and",
"tunnels"
] | def connect(
ctx,
port,
name,
protected,
username,
password,
host,
type,
engine,
cloudauth,
allowed_email_addresses,
allowed_email_domains,
):
if cloudauth:
cloudauth = True
allowed_email_addresses_list = []
if allowed_email_addresses:
... | [
"def",
"connect",
"(",
"ctx",
",",
"port",
",",
"name",
",",
"protected",
",",
"username",
",",
"password",
",",
"host",
",",
"type",
",",
"engine",
",",
"cloudauth",
",",
"allowed_email_addresses",
",",
"allowed_email_domains",
",",
")",
":",
"if",
"cloud... | Quckly connect, Wrapper around sockets and tunnels | [
"Quckly",
"connect",
"Wrapper",
"around",
"sockets",
"and",
"tunnels"
] | [
"\"\"\"Quckly connect, Wrapper around sockets and tunnels\"\"\"",
"# check if both email and domain list are empty and warn"
] | [
{
"param": "ctx",
"type": null
},
{
"param": "port",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "protected",
"type": null
},
{
"param": "username",
"type": null
},
{
"param": "password",
"type": null
},
{
"param": "host",... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "port",
"type": null,
"docstring": null,
"docstring_tokens": []... |
d1f8fa2fd9cacf8574bcec157dc251816ac855b8 | gstoica27/Swin-Transformer | optimizer.py | [
"MIT"
] | Python | build_optimizer | <not_specific> | def build_optimizer(config, model, whitelisted_params=None, tune_config=None):
"""
Build optimizer, set weight decay of normalization to 0 by default.
"""
skip = {}
skip_keywords = {}
if hasattr(model, 'no_weight_decay'):
skip = model.no_weight_decay()
if hasattr(model, 'no_weight_d... |
Build optimizer, set weight decay of normalization to 0 by default.
| Build optimizer, set weight decay of normalization to 0 by default. | [
"Build",
"optimizer",
"set",
"weight",
"decay",
"of",
"normalization",
"to",
"0",
"by",
"default",
"."
] | def build_optimizer(config, model, whitelisted_params=None, tune_config=None):
skip = {}
skip_keywords = {}
if hasattr(model, 'no_weight_decay'):
skip = model.no_weight_decay()
if hasattr(model, 'no_weight_decay_keywords'):
skip_keywords = model.no_weight_decay_keywords()
parameters ... | [
"def",
"build_optimizer",
"(",
"config",
",",
"model",
",",
"whitelisted_params",
"=",
"None",
",",
"tune_config",
"=",
"None",
")",
":",
"skip",
"=",
"{",
"}",
"skip_keywords",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"model",
",",
"'no_weight_decay'",
")",
... | Build optimizer, set weight decay of normalization to 0 by default. | [
"Build",
"optimizer",
"set",
"weight",
"decay",
"of",
"normalization",
"to",
"0",
"by",
"default",
"."
] | [
"\"\"\"\n Build optimizer, set weight decay of normalization to 0 by default.\n \"\"\"",
"# pdb.set_trace()",
"# pdb.set_trace()"
] | [
{
"param": "config",
"type": null
},
{
"param": "model",
"type": null
},
{
"param": "whitelisted_params",
"type": null
},
{
"param": "tune_config",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "config",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens"... |
d77eb214d58f8d6121d05024fdb53c41d53b5928 | gstoica27/Swin-Transformer | models/csam.py | [
"MIT"
] | Python | apply_local_softmax | <not_specific> | def apply_local_softmax(self, filter_raw, pooling_features):
"""
Apply a softmax filter only over each receptive field.
The logic here closely follows that of approach2.
Please see that documentation for a better understanding of what is happening here.
"""
local_mask =... |
Apply a softmax filter only over each receptive field.
The logic here closely follows that of approach2.
Please see that documentation for a better understanding of what is happening here.
| Apply a softmax filter only over each receptive field.
The logic here closely follows that of approach2.
Please see that documentation for a better understanding of what is happening here. | [
"Apply",
"a",
"softmax",
"filter",
"only",
"over",
"each",
"receptive",
"field",
".",
"The",
"logic",
"here",
"closely",
"follows",
"that",
"of",
"approach2",
".",
"Please",
"see",
"that",
"documentation",
"for",
"a",
"better",
"understanding",
"of",
"what",
... | def apply_local_softmax(self, filter_raw, pooling_features):
local_mask = self.local_mask.flatten(1).transpose(1, 0)
filter_exp = torch.exp(filter_raw - filter_raw.max(dim=1, keepdim=True)[0]).squeeze(-1)
filter_ex... | [
"def",
"apply_local_softmax",
"(",
"self",
",",
"filter_raw",
",",
"pooling_features",
")",
":",
"local_mask",
"=",
"self",
".",
"local_mask",
".",
"flatten",
"(",
"1",
")",
".",
"transpose",
"(",
"1",
",",
"0",
")",
"filter_exp",
"=",
"torch",
".",
"exp... | Apply a softmax filter only over each receptive field. | [
"Apply",
"a",
"softmax",
"filter",
"only",
"over",
"each",
"receptive",
"field",
"."
] | [
"\"\"\"\n Apply a softmax filter only over each receptive field. \n The logic here closely follows that of approach2. \n Please see that documentation for a better understanding of what is happening here.\n \"\"\"",
"# [Nc,HW] -> [HW,Nc]",
"# [B,HW]",
"# [B,Nc]",
"# [B,Nc]",
"#... | [
{
"param": "self",
"type": null
},
{
"param": "filter_raw",
"type": null
},
{
"param": "pooling_features",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filter_raw",
"type": null,
"docstring": null,
"docstring_toke... |
3d1f4f8fcca7a3eb6eb7da316cb52f054838d025 | mrzv/saturn | saturn_notebook/evaluate.py | [
"BSD-3-Clause-LBNL"
] | Python | exec_eval | <not_specific> | def exec_eval(script, globals=None, locals=None, name=''):
'''Execute a script and return the value of the last expression'''
stmts = list(ast.iter_child_nodes(ast.parse(script)))
if not stmts:
return None
if isinstance(stmts[-1], ast.Expr):
# the last one is an expression and we will tr... | Execute a script and return the value of the last expression | Execute a script and return the value of the last expression | [
"Execute",
"a",
"script",
"and",
"return",
"the",
"value",
"of",
"the",
"last",
"expression"
] | def exec_eval(script, globals=None, locals=None, name=''):
stmts = list(ast.iter_child_nodes(ast.parse(script)))
if not stmts:
return None
if isinstance(stmts[-1], ast.Expr):
if len(stmts) > 1:
if sys.version_info >= (3, 8):
mod = ast.Module(stmts[:-1], [])
... | [
"def",
"exec_eval",
"(",
"script",
",",
"globals",
"=",
"None",
",",
"locals",
"=",
"None",
",",
"name",
"=",
"''",
")",
":",
"stmts",
"=",
"list",
"(",
"ast",
".",
"iter_child_nodes",
"(",
"ast",
".",
"parse",
"(",
"script",
")",
")",
")",
"if",
... | Execute a script and return the value of the last expression | [
"Execute",
"a",
"script",
"and",
"return",
"the",
"value",
"of",
"the",
"last",
"expression"
] | [
"'''Execute a script and return the value of the last expression'''",
"# the last one is an expression and we will try to return the results",
"# so we first execute the previous statements",
"# then we eval the last one",
"# otherwise we just execute the entire code"
] | [
{
"param": "script",
"type": null
},
{
"param": "globals",
"type": null
},
{
"param": "locals",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "script",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "globals",
"type": null,
"docstring": null,
"docstring_token... |
84fc0467fc539dd4832371bc700c1e82fb1f87a5 | mrzv/saturn | saturn_notebook/__main__.py | [
"BSD-3-Clause-LBNL"
] | Python | show | null | def show(fn: "input notebook",
html: "save HTML to a file" = '',
debug: "show debugging information" = False):
"""Show the contents of the notebook, without evaluating."""
with open(fn) as f:
cells = c.parse(f, show_only = True)
output = lambda cell: show_console(cell, rule = de... | Show the contents of the notebook, without evaluating. | Show the contents of the notebook, without evaluating. | [
"Show",
"the",
"contents",
"of",
"the",
"notebook",
"without",
"evaluating",
"."
] | def show(fn: "input notebook",
html: "save HTML to a file" = '',
debug: "show debugging information" = False):
with open(fn) as f:
cells = c.parse(f, show_only = True)
output = lambda cell: show_console(cell, rule = debug, verbose = debug)
if html:
f_html = open(html, 'w'... | [
"def",
"show",
"(",
"fn",
":",
"\"input notebook\"",
",",
"html",
":",
"\"save HTML to a file\"",
"=",
"''",
",",
"debug",
":",
"\"show debugging information\"",
"=",
"False",
")",
":",
"with",
"open",
"(",
"fn",
")",
"as",
"f",
":",
"cells",
"=",
"c",
"... | Show the contents of the notebook, without evaluating. | [
"Show",
"the",
"contents",
"of",
"the",
"notebook",
"without",
"evaluating",
"."
] | [
"\"\"\"Show the contents of the notebook, without evaluating.\"\"\""
] | [
{
"param": "fn",
"type": "\"input notebook\""
},
{
"param": "html",
"type": "\"save HTML to a file\""
},
{
"param": "debug",
"type": "\"show debugging information\""
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fn",
"type": "\"input notebook\"",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "html",
"type": "\"save HTML to a file\"",
"docstring"... |
84fc0467fc539dd4832371bc700c1e82fb1f87a5 | mrzv/saturn | saturn_notebook/__main__.py | [
"BSD-3-Clause-LBNL"
] | Python | clean | null | def clean(infn: "input notebook",
outfn: "output notebook (if empty, input modified in place)",
strip_output: "also strip all output" = False):
"""Remove all binary data from the notebook."""
if not outfn:
outfn = infn
if os.path.exists(infn):
with atomic_write(outfn, mo... | Remove all binary data from the notebook. | Remove all binary data from the notebook. | [
"Remove",
"all",
"binary",
"data",
"from",
"the",
"notebook",
"."
] | def clean(infn: "input notebook",
outfn: "output notebook (if empty, input modified in place)",
strip_output: "also strip all output" = False):
if not outfn:
outfn = infn
if os.path.exists(infn):
with atomic_write(outfn, mode='w', overwrite=True) as of:
with open(... | [
"def",
"clean",
"(",
"infn",
":",
"\"input notebook\"",
",",
"outfn",
":",
"\"output notebook (if empty, input modified in place)\"",
",",
"strip_output",
":",
"\"also strip all output\"",
"=",
"False",
")",
":",
"if",
"not",
"outfn",
":",
"outfn",
"=",
"infn",
"if"... | Remove all binary data from the notebook. | [
"Remove",
"all",
"binary",
"data",
"from",
"the",
"notebook",
"."
] | [
"\"\"\"Remove all binary data from the notebook.\"\"\"",
"# Keep the first line, but skip all subsequent lines"
] | [
{
"param": "infn",
"type": "\"input notebook\""
},
{
"param": "outfn",
"type": "\"output notebook (if empty, input modified in place)\""
},
{
"param": "strip_output",
"type": "\"also strip all output\""
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "infn",
"type": "\"input notebook\"",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "outfn",
"type": "\"output notebook (if empty, input modif... |
84fc0467fc539dd4832371bc700c1e82fb1f87a5 | mrzv/saturn | saturn_notebook/__main__.py | [
"BSD-3-Clause-LBNL"
] | Python | image | <not_specific> | def image(infn: "input notebook", i: "image index", out: "output PNG filename"):
"""Extract an image from the notebook."""
if i is not None and not out:
console.print("Must specify output filename, if image is specified")
return
with open(infn) as f:
cells = c.parse(f, show_only = T... | Extract an image from the notebook. | Extract an image from the notebook. | [
"Extract",
"an",
"image",
"from",
"the",
"notebook",
"."
] | def image(infn: "input notebook", i: "image index", out: "output PNG filename"):
if i is not None and not out:
console.print("Must specify output filename, if image is specified")
return
with open(infn) as f:
cells = c.parse(f, show_only = True)
count = 0
for cell in cells:
... | [
"def",
"image",
"(",
"infn",
":",
"\"input notebook\"",
",",
"i",
":",
"\"image index\"",
",",
"out",
":",
"\"output PNG filename\"",
")",
":",
"if",
"i",
"is",
"not",
"None",
"and",
"not",
"out",
":",
"console",
".",
"print",
"(",
"\"Must specify output fil... | Extract an image from the notebook. | [
"Extract",
"an",
"image",
"from",
"the",
"notebook",
"."
] | [
"\"\"\"Extract an image from the notebook.\"\"\""
] | [
{
"param": "infn",
"type": "\"input notebook\""
},
{
"param": "i",
"type": "\"image index\""
},
{
"param": "out",
"type": "\"output PNG filename\""
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "infn",
"type": "\"input notebook\"",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "i",
"type": "\"image index\"",
"docstring": null,
... |
84fc0467fc539dd4832371bc700c1e82fb1f87a5 | mrzv/saturn | saturn_notebook/__main__.py | [
"BSD-3-Clause-LBNL"
] | Python | version | null | def version():
"""Show version of Saturn and its dependencies."""
from importlib_metadata import version as ver
print(f"Saturn {ver('saturn_notebook')}")
for dep in ['wurlitzer', 'rich', 'ptpython',
'dill', 'markdown', 'atomicwrites',
'pygments', 'more_itertools', 'matplo... | Show version of Saturn and its dependencies. | Show version of Saturn and its dependencies. | [
"Show",
"version",
"of",
"Saturn",
"and",
"its",
"dependencies",
"."
] | def version():
from importlib_metadata import version as ver
print(f"Saturn {ver('saturn_notebook')}")
for dep in ['wurlitzer', 'rich', 'ptpython',
'dill', 'markdown', 'atomicwrites',
'pygments', 'more_itertools', 'matplotlib']:
print(f" {dep} {ver(dep)}") | [
"def",
"version",
"(",
")",
":",
"from",
"importlib_metadata",
"import",
"version",
"as",
"ver",
"print",
"(",
"f\"Saturn {ver('saturn_notebook')}\"",
")",
"for",
"dep",
"in",
"[",
"'wurlitzer'",
",",
"'rich'",
",",
"'ptpython'",
",",
"'dill'",
",",
"'markdown'"... | Show version of Saturn and its dependencies. | [
"Show",
"version",
"of",
"Saturn",
"and",
"its",
"dependencies",
"."
] | [
"\"\"\"Show version of Saturn and its dependencies.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
84fc0467fc539dd4832371bc700c1e82fb1f87a5 | mrzv/saturn | saturn_notebook/__main__.py | [
"BSD-3-Clause-LBNL"
] | Python | rehash | null | def rehash(infn: "input notebook",
outfn: "output notebook (if empty, input modified in place)"):
"""Rehash all the code cells, updating the hashes stored with checkpoints and variable cells. (advanced)"""
if not outfn:
outfn = infn
with open(infn) as f:
cells = c.parse(f)
n... | Rehash all the code cells, updating the hashes stored with checkpoints and variable cells. (advanced) | Rehash all the code cells, updating the hashes stored with checkpoints and variable cells. (advanced) | [
"Rehash",
"all",
"the",
"code",
"cells",
"updating",
"the",
"hashes",
"stored",
"with",
"checkpoints",
"and",
"variable",
"cells",
".",
"(",
"advanced",
")"
] | def rehash(infn: "input notebook",
outfn: "output notebook (if empty, input modified in place)"):
if not outfn:
outfn = infn
with open(infn) as f:
cells = c.parse(f)
nb = notebook.Notebook(name = infn)
nb.add(cells)
nb.rehash()
nb.save(outfn) | [
"def",
"rehash",
"(",
"infn",
":",
"\"input notebook\"",
",",
"outfn",
":",
"\"output notebook (if empty, input modified in place)\"",
")",
":",
"if",
"not",
"outfn",
":",
"outfn",
"=",
"infn",
"with",
"open",
"(",
"infn",
")",
"as",
"f",
":",
"cells",
"=",
... | Rehash all the code cells, updating the hashes stored with checkpoints and variable cells. | [
"Rehash",
"all",
"the",
"code",
"cells",
"updating",
"the",
"hashes",
"stored",
"with",
"checkpoints",
"and",
"variable",
"cells",
"."
] | [
"\"\"\"Rehash all the code cells, updating the hashes stored with checkpoints and variable cells. (advanced)\"\"\""
] | [
{
"param": "infn",
"type": "\"input notebook\""
},
{
"param": "outfn",
"type": "\"output notebook (if empty, input modified in place)\""
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "infn",
"type": "\"input notebook\"",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "outfn",
"type": "\"output notebook (if empty, input modif... |
f3f989db01d220ce50146ebea7cea20811fcf88a | zpliulab/PST-PRNA | compute_surface/extract_xyzrn.py | [
"MIT"
] | Python | extract_xyzrn | null | def extract_xyzrn(pdb_id, chain):
"""
pdbfilename: input pdb filename
xyzrnfilename: output in xyzrn format.
"""
pdbfilename = os.path.join(dir_opts['protonated_pdb_dir'],pdb_id+'_'+chain+'.pdb')
# pdbfilename = os.path.join(dir_opts['chain_pdb_dir'],pdb_id+'_'+chain+'.pdb')
xyzrnfi... |
pdbfilename: input pdb filename
xyzrnfilename: output in xyzrn format.
| input pdb filename
xyzrnfilename: output in xyzrn format. | [
"input",
"pdb",
"filename",
"xyzrnfilename",
":",
"output",
"in",
"xyzrn",
"format",
"."
] | def extract_xyzrn(pdb_id, chain):
pdbfilename = os.path.join(dir_opts['protonated_pdb_dir'],pdb_id+'_'+chain+'.pdb')
xyzrnfilename = os.path.join(dir_opts['xyzrn_dir'],pdb_id+'_'+ chain+'.xyzrn')
if not os.path.exists(dir_opts['xyzrn_dir']):
os.makedirs(dir_opts['xyzrn_dir'])
parser = PDBParser(... | [
"def",
"extract_xyzrn",
"(",
"pdb_id",
",",
"chain",
")",
":",
"pdbfilename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dir_opts",
"[",
"'protonated_pdb_dir'",
"]",
",",
"pdb_id",
"+",
"'_'",
"+",
"chain",
"+",
"'.pdb'",
")",
"xyzrnfilename",
"=",
"os",... | pdbfilename: input pdb filename
xyzrnfilename: output in xyzrn format. | [
"pdbfilename",
":",
"input",
"pdb",
"filename",
"xyzrnfilename",
":",
"output",
"in",
"xyzrn",
"format",
"."
] | [
"\"\"\"\n pdbfilename: input pdb filename\n xyzrnfilename: output in xyzrn format.\n \"\"\"",
"# pdbfilename = os.path.join(dir_opts['chain_pdb_dir'],pdb_id+'_'+chain+'.pdb')",
"# Ignore hetatms.",
"#return xyzrnfilename"
] | [
{
"param": "pdb_id",
"type": null
},
{
"param": "chain",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pdb_id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "chain",
"type": null,
"docstring": null,
"docstring_tokens"... |
e63633cd39f9dada9bfe5ff484b23261432d9724 | nvitha/Smart-Cities | django/smartcity/vagent/backups/django_agent.py | [
"MIT"
] | Python | start | null | def start(self, sender, **kwargs):
'''Handle the starting of the agent.
Subscribe to all points in the topics_prefix_to_watch tuple
defined in settings.py.
'''
writer = '~~~~~~~~~~THIS IS SOME TEXT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
sys.stdout.write(writer)
... | Handle the starting of the agent.
Subscribe to all points in the topics_prefix_to_watch tuple
defined in settings.py.
| Handle the starting of the agent.
Subscribe to all points in the topics_prefix_to_watch tuple
defined in settings.py. | [
"Handle",
"the",
"starting",
"of",
"the",
"agent",
".",
"Subscribe",
"to",
"all",
"points",
"in",
"the",
"topics_prefix_to_watch",
"tuple",
"defined",
"in",
"settings",
".",
"py",
"."
] | def start(self, sender, **kwargs):
writer = '~~~~~~~~~~THIS IS SOME TEXT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
sys.stdout.write(writer)
now = datetime.utcnow().isoformat(' ') + 'Z'
headers = {
headers_mod.CONTENT_TYPE: headers_mod.CONTENT_TYPE.PLAIN_TEXT,
headers_mod.DAT... | [
"def",
"start",
"(",
"self",
",",
"sender",
",",
"**",
"kwargs",
")",
":",
"writer",
"=",
"'~~~~~~~~~~THIS IS SOME TEXT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'",
"sys",
".",
"stdout",
".",
"write",
"(",
"writer",
")",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
... | Handle the starting of the agent. | [
"Handle",
"the",
"starting",
"of",
"the",
"agent",
"."
] | [
"'''Handle the starting of the agent.\n \n Subscribe to all points in the topics_prefix_to_watch tuple\n defined in settings.py.\n '''",
"# 'AgentID': self._agent_id,"
] | [
{
"param": "self",
"type": null
},
{
"param": "sender",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sender",
"type": null,
"docstring": null,
"docstring_tokens":... |
846859495cdb0bcaa819c8e47cd0b92e778cfb01 | karry3775/cartographer | scripts/update_configuration_doc.py | [
"Apache-2.0"
] | Python | ParseProtoFile | <not_specific> | def ParseProtoFile(proto_file):
"""Computes the list of Message objects of the option messages in a file."""
line_iter = iter(proto_file)
# We ignore the license header and search for the 'package' line.
for line in line_iter:
line = line.strip()
if line.startswith('package'):
assert line[-1] == ... | Computes the list of Message objects of the option messages in a file. | Computes the list of Message objects of the option messages in a file. | [
"Computes",
"the",
"list",
"of",
"Message",
"objects",
"of",
"the",
"option",
"messages",
"in",
"a",
"file",
"."
] | def ParseProtoFile(proto_file):
line_iter = iter(proto_file)
for line in line_iter:
line = line.strip()
if line.startswith('package'):
assert line[-1] == ';'
package = line[7:-1].strip()
break
else:
assert '}' not in line
message_list = []
while True:
message_comments = [... | [
"def",
"ParseProtoFile",
"(",
"proto_file",
")",
":",
"line_iter",
"=",
"iter",
"(",
"proto_file",
")",
"for",
"line",
"in",
"line_iter",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"line",
".",
"startswith",
"(",
"'package'",
")",
":",
"as... | Computes the list of Message objects of the option messages in a file. | [
"Computes",
"the",
"list",
"of",
"Message",
"objects",
"of",
"the",
"option",
"messages",
"in",
"a",
"file",
"."
] | [
"\"\"\"Computes the list of Message objects of the option messages in a file.\"\"\"",
"# We ignore the license header and search for the 'package' line.",
"# Search for the next options message and capture preceding comments.",
"# The preceding comments were for a different message it seems.",
"# We keep co... | [
{
"param": "proto_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "proto_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
846859495cdb0bcaa819c8e47cd0b92e778cfb01 | karry3775/cartographer | scripts/update_configuration_doc.py | [
"Apache-2.0"
] | Python | ParseProtoFilesRecursively | <not_specific> | def ParseProtoFilesRecursively(root):
"""Recursively parses all proto files into a list of Message objects."""
message_list = []
for dirpath, dirnames, filenames in os.walk(root):
for name in filenames:
if name.endswith('.proto'):
path = os.path.join(dirpath, name)
print("Found '%s'..." ... | Recursively parses all proto files into a list of Message objects. | Recursively parses all proto files into a list of Message objects. | [
"Recursively",
"parses",
"all",
"proto",
"files",
"into",
"a",
"list",
"of",
"Message",
"objects",
"."
] | def ParseProtoFilesRecursively(root):
message_list = []
for dirpath, dirnames, filenames in os.walk(root):
for name in filenames:
if name.endswith('.proto'):
path = os.path.join(dirpath, name)
print("Found '%s'..." % path)
assert not os.path.islink(path)
message_list.extend... | [
"def",
"ParseProtoFilesRecursively",
"(",
"root",
")",
":",
"message_list",
"=",
"[",
"]",
"for",
"dirpath",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"root",
")",
":",
"for",
"name",
"in",
"filenames",
":",
"if",
"name",
".",
"e... | Recursively parses all proto files into a list of Message objects. | [
"Recursively",
"parses",
"all",
"proto",
"files",
"into",
"a",
"list",
"of",
"Message",
"objects",
"."
] | [
"\"\"\"Recursively parses all proto files into a list of Message objects.\"\"\""
] | [
{
"param": "root",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "root",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
846859495cdb0bcaa819c8e47cd0b92e778cfb01 | karry3775/cartographer | scripts/update_configuration_doc.py | [
"Apache-2.0"
] | Python | GenerateDocumentation | null | def GenerateDocumentation(output_file, root):
"""Recursively generates documentation, sorts and writes it."""
message_list = ParseProtoFilesRecursively(root)
resolver = Resolver(message.name for message in message_list)
output_dict = {}
for message in message_list:
content = [message.name, '=' * len(mess... | Recursively generates documentation, sorts and writes it. | Recursively generates documentation, sorts and writes it. | [
"Recursively",
"generates",
"documentation",
"sorts",
"and",
"writes",
"it",
"."
] | def GenerateDocumentation(output_file, root):
message_list = ParseProtoFilesRecursively(root)
resolver = Resolver(message.name for message in message_list)
output_dict = {}
for message in message_list:
content = [message.name, '=' * len(message.name), '']
assert message.name not in output_dict
outpu... | [
"def",
"GenerateDocumentation",
"(",
"output_file",
",",
"root",
")",
":",
"message_list",
"=",
"ParseProtoFilesRecursively",
"(",
"root",
")",
"resolver",
"=",
"Resolver",
"(",
"message",
".",
"name",
"for",
"message",
"in",
"message_list",
")",
"output_dict",
... | Recursively generates documentation, sorts and writes it. | [
"Recursively",
"generates",
"documentation",
"sorts",
"and",
"writes",
"it",
"."
] | [
"\"\"\"Recursively generates documentation, sorts and writes it.\"\"\"",
"# TODO(whess): For now we exclude InitialTrajectoryPose from the",
"# documentation. It is documented itself (since it has no Options suffix)",
"# and is not parsed from the Lua files."
] | [
{
"param": "output_file",
"type": null
},
{
"param": "root",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "output_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "root",
"type": null,
"docstring": null,
"docstring_tok... |
43644e66b0c065f66714589b0437cc5f8f58da41 | vrcunha/db_sql_and_nosql | redis/funcs/crud_redis.py | [
"MIT"
] | Python | update | <not_specific> | def update(name=False, price=False, stock=False):
"""Update an item selected by id."""
conn = connect()
key = input('Enter your product key: ')
if name:
new_name = input('Enter new product name: ')
result = conn.hset(key, "name", new_name)
if result:
print('Product na... | Update an item selected by id. | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | def update(name=False, price=False, stock=False):
conn = connect()
key = input('Enter your product key: ')
if name:
new_name = input('Enter new product name: ')
result = conn.hset(key, "name", new_name)
if result:
print('Product name successfully updated.')
re... | [
"def",
"update",
"(",
"name",
"=",
"False",
",",
"price",
"=",
"False",
",",
"stock",
"=",
"False",
")",
":",
"conn",
"=",
"connect",
"(",
")",
"key",
"=",
"input",
"(",
"'Enter your product key: '",
")",
"if",
"name",
":",
"new_name",
"=",
"input",
... | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Update an item selected by id.\"\"\""
] | [
{
"param": "name",
"type": null
},
{
"param": "price",
"type": null
},
{
"param": "stock",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "price",
"type": null,
"docstring": null,
"docstring_tokens": ... |
43644e66b0c065f66714589b0437cc5f8f58da41 | vrcunha/db_sql_and_nosql | redis/funcs/crud_redis.py | [
"MIT"
] | Python | delete | null | def delete():
"""Delete an item selected by id."""
conn = connect()
key = input('Enter product key: ')
result = conn.delete(key)
if result:
print('Item delect successfully.') | Delete an item selected by id. | Delete an item selected by id. | [
"Delete",
"an",
"item",
"selected",
"by",
"id",
"."
] | def delete():
conn = connect()
key = input('Enter product key: ')
result = conn.delete(key)
if result:
print('Item delect successfully.') | [
"def",
"delete",
"(",
")",
":",
"conn",
"=",
"connect",
"(",
")",
"key",
"=",
"input",
"(",
"'Enter product key: '",
")",
"result",
"=",
"conn",
".",
"delete",
"(",
"key",
")",
"if",
"result",
":",
"print",
"(",
"'Item delect successfully.'",
")"
] | Delete an item selected by id. | [
"Delete",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Delete an item selected by id.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
bf1a575eaf1fa5bfc382566ed1619221fa328f69 | vrcunha/db_sql_and_nosql | sqlite/funcs/crud_sqlite.py | [
"MIT"
] | Python | insert | null | def insert():
"""Insert new item in table."""
connection = connect()
cursor = connection.cursor()
nome = input('Enter product name: ')
preco = input('Enter product price: ')
estoque = input('Enter product stock: ')
cursor.execute(f"INSERT INTO products" \
f"(name, price, s... | Insert new item in table. | Insert new item in table. | [
"Insert",
"new",
"item",
"in",
"table",
"."
] | def insert():
connection = connect()
cursor = connection.cursor()
nome = input('Enter product name: ')
preco = input('Enter product price: ')
estoque = input('Enter product stock: ')
cursor.execute(f"INSERT INTO products" \
f"(name, price, stock) VALUES " \
... | [
"def",
"insert",
"(",
")",
":",
"connection",
"=",
"connect",
"(",
")",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"nome",
"=",
"input",
"(",
"'Enter product name: '",
")",
"preco",
"=",
"input",
"(",
"'Enter product price: '",
")",
"estoque",
"... | Insert new item in table. | [
"Insert",
"new",
"item",
"in",
"table",
"."
] | [
"\"\"\"Insert new item in table.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
bf1a575eaf1fa5bfc382566ed1619221fa328f69 | vrcunha/db_sql_and_nosql | sqlite/funcs/crud_sqlite.py | [
"MIT"
] | Python | update | null | def update(id, name=False, price=False, stock=False):
"""Update an item selected by id."""
connection = connect()
cursor = connection.cursor()
if name:
new_name = input('Enter new product name: ')
cursor.execute(f"UPDATE products SET name='{new_name}' WHERE id = {int(id)}")
check... | Update an item selected by id. | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | def update(id, name=False, price=False, stock=False):
connection = connect()
cursor = connection.cursor()
if name:
new_name = input('Enter new product name: ')
cursor.execute(f"UPDATE products SET name='{new_name}' WHERE id = {int(id)}")
check_operation(connection, cursor)
pr... | [
"def",
"update",
"(",
"id",
",",
"name",
"=",
"False",
",",
"price",
"=",
"False",
",",
"stock",
"=",
"False",
")",
":",
"connection",
"=",
"connect",
"(",
")",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"if",
"name",
":",
"new_name",
"=... | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Update an item selected by id.\"\"\""
] | [
{
"param": "id",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "price",
"type": null
},
{
"param": "stock",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
bf1a575eaf1fa5bfc382566ed1619221fa328f69 | vrcunha/db_sql_and_nosql | sqlite/funcs/crud_sqlite.py | [
"MIT"
] | Python | delete | null | def delete(id):
"""Delete an item selected by id."""
connection = connect()
cursor = connection.cursor()
cursor.execute(f"DELETE FROM products WHERE id = {int(id)}")
check_operation(connection, cursor)
disconnect(connection) | Delete an item selected by id. | Delete an item selected by id. | [
"Delete",
"an",
"item",
"selected",
"by",
"id",
"."
] | def delete(id):
connection = connect()
cursor = connection.cursor()
cursor.execute(f"DELETE FROM products WHERE id = {int(id)}")
check_operation(connection, cursor)
disconnect(connection) | [
"def",
"delete",
"(",
"id",
")",
":",
"connection",
"=",
"connect",
"(",
")",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"f\"DELETE FROM products WHERE id = {int(id)}\"",
")",
"check_operation",
"(",
"connection",
",",
... | Delete an item selected by id. | [
"Delete",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Delete an item selected by id.\"\"\""
] | [
{
"param": "id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
83a1ca9538e27bc701d0fccb0ada896e972103c9 | vrcunha/db_sql_and_nosql | postgresql/funcs/crud_postgresql.py | [
"MIT"
] | Python | insert | null | def insert():
"""Insert new item in table."""
connection = connect()
cursor = connection.cursor()
nome = input('Enter product name: ')
preco = input('Enter product price: ')
estoque = input('Enter product stock: ')
cursor.execute(f"INSERT INTO produtos" \
f"(nome, preco, e... | Insert new item in table. | Insert new item in table. | [
"Insert",
"new",
"item",
"in",
"table",
"."
] | def insert():
connection = connect()
cursor = connection.cursor()
nome = input('Enter product name: ')
preco = input('Enter product price: ')
estoque = input('Enter product stock: ')
cursor.execute(f"INSERT INTO produtos" \
f"(nome, preco, estoque) VALUES " \
... | [
"def",
"insert",
"(",
")",
":",
"connection",
"=",
"connect",
"(",
")",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"nome",
"=",
"input",
"(",
"'Enter product name: '",
")",
"preco",
"=",
"input",
"(",
"'Enter product price: '",
")",
"estoque",
"... | Insert new item in table. | [
"Insert",
"new",
"item",
"in",
"table",
"."
] | [
"\"\"\"Insert new item in table.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
83a1ca9538e27bc701d0fccb0ada896e972103c9 | vrcunha/db_sql_and_nosql | postgresql/funcs/crud_postgresql.py | [
"MIT"
] | Python | update | null | def update(id, name=False, price=False, stock=False):
"""Update an item selected by id."""
connection = connect()
cursor = connection.cursor()
if name:
new_name = input('Enter new product name: ')
cursor.execute(f"UPDATE produtos SET nome='{new_name}' WHERE id = {int(id)}")
check... | Update an item selected by id. | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | def update(id, name=False, price=False, stock=False):
connection = connect()
cursor = connection.cursor()
if name:
new_name = input('Enter new product name: ')
cursor.execute(f"UPDATE produtos SET nome='{new_name}' WHERE id = {int(id)}")
check_operation(connection, cursor)
pr... | [
"def",
"update",
"(",
"id",
",",
"name",
"=",
"False",
",",
"price",
"=",
"False",
",",
"stock",
"=",
"False",
")",
":",
"connection",
"=",
"connect",
"(",
")",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"if",
"name",
":",
"new_name",
"=... | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Update an item selected by id.\"\"\""
] | [
{
"param": "id",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "price",
"type": null
},
{
"param": "stock",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
83a1ca9538e27bc701d0fccb0ada896e972103c9 | vrcunha/db_sql_and_nosql | postgresql/funcs/crud_postgresql.py | [
"MIT"
] | Python | delete | null | def delete(id):
"""Delete an item selected by id."""
connection = connect()
cursor = connection.cursor()
cursor.execute(f"DELETE FROM produtos WHERE id = {int(id)}")
check_operation(connection, cursor)
disconnect(connection) | Delete an item selected by id. | Delete an item selected by id. | [
"Delete",
"an",
"item",
"selected",
"by",
"id",
"."
] | def delete(id):
connection = connect()
cursor = connection.cursor()
cursor.execute(f"DELETE FROM produtos WHERE id = {int(id)}")
check_operation(connection, cursor)
disconnect(connection) | [
"def",
"delete",
"(",
"id",
")",
":",
"connection",
"=",
"connect",
"(",
")",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"f\"DELETE FROM produtos WHERE id = {int(id)}\"",
")",
"check_operation",
"(",
"connection",
",",
... | Delete an item selected by id. | [
"Delete",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Delete an item selected by id.\"\"\""
] | [
{
"param": "id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
509dad8dae6a5bc56648fc5ff8668ce39ebe0a5a | vrcunha/db_sql_and_nosql | mysql/funcs/crud_mysql.py | [
"MIT"
] | Python | insert | null | def insert():
"""Insert new item in table."""
connection = connect()
cursor = connection.cursor()
name = input('Enter product name: ')
price = input('Enter product price: ')
stock = input('Enter product stock: ')
cursor.execute(f"INSERT INTO produtos" \
f"(nome, preco, est... | Insert new item in table. | Insert new item in table. | [
"Insert",
"new",
"item",
"in",
"table",
"."
] | def insert():
connection = connect()
cursor = connection.cursor()
name = input('Enter product name: ')
price = input('Enter product price: ')
stock = input('Enter product stock: ')
cursor.execute(f"INSERT INTO produtos" \
f"(nome, preco, estoque) VALUES " \
... | [
"def",
"insert",
"(",
")",
":",
"connection",
"=",
"connect",
"(",
")",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"name",
"=",
"input",
"(",
"'Enter product name: '",
")",
"price",
"=",
"input",
"(",
"'Enter product price: '",
")",
"stock",
"="... | Insert new item in table. | [
"Insert",
"new",
"item",
"in",
"table",
"."
] | [
"\"\"\"Insert new item in table.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
509dad8dae6a5bc56648fc5ff8668ce39ebe0a5a | vrcunha/db_sql_and_nosql | mysql/funcs/crud_mysql.py | [
"MIT"
] | Python | update | null | def update(id, name=False, price=False, stock=False):
"""Update an item selected by id."""
connection = connect()
cursor = connection.cursor()
if name:
new_name = input('Enter new product name: ')
cursor.execute(f"UPDATE produtos SET nome='{new_name}' WHERE id = {int(id)}")
check... | Update an item selected by id. | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | def update(id, name=False, price=False, stock=False):
connection = connect()
cursor = connection.cursor()
if name:
new_name = input('Enter new product name: ')
cursor.execute(f"UPDATE produtos SET nome='{new_name}' WHERE id = {int(id)}")
check_operation(connection, cursor)
pr... | [
"def",
"update",
"(",
"id",
",",
"name",
"=",
"False",
",",
"price",
"=",
"False",
",",
"stock",
"=",
"False",
")",
":",
"connection",
"=",
"connect",
"(",
")",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"if",
"name",
":",
"new_name",
"=... | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Update an item selected by id.\"\"\""
] | [
{
"param": "id",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "price",
"type": null
},
{
"param": "stock",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
8e5886b7fb1e2d3ff1d2c7c3cec36deb27c401b2 | vrcunha/db_sql_and_nosql | couch/funcs/crud_couch.py | [
"MIT"
] | Python | update | <not_specific> | def update(name=False, price=False, stock=False):
"""Update an item selected by id."""
db = connect()
if db:
key = input('Enter your product id: ')
try:
doc = db[key]
if name:
doc['name'] = input('Enter new product name: ')
db[doc.id] =... | Update an item selected by id. | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | def update(name=False, price=False, stock=False):
db = connect()
if db:
key = input('Enter your product id: ')
try:
doc = db[key]
if name:
doc['name'] = input('Enter new product name: ')
db[doc.id] = doc
print('Product name ... | [
"def",
"update",
"(",
"name",
"=",
"False",
",",
"price",
"=",
"False",
",",
"stock",
"=",
"False",
")",
":",
"db",
"=",
"connect",
"(",
")",
"if",
"db",
":",
"key",
"=",
"input",
"(",
"'Enter your product id: '",
")",
"try",
":",
"doc",
"=",
"db",... | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Update an item selected by id.\"\"\""
] | [
{
"param": "name",
"type": null
},
{
"param": "price",
"type": null
},
{
"param": "stock",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "price",
"type": null,
"docstring": null,
"docstring_tokens": ... |
8e5886b7fb1e2d3ff1d2c7c3cec36deb27c401b2 | vrcunha/db_sql_and_nosql | couch/funcs/crud_couch.py | [
"MIT"
] | Python | delete | null | def delete():
"""Delete an item selected by id."""
db = connect()
if db:
key = input('Enter product id: ')
try:
db.delete(db[key])
print('Product successfully deleted.')
except couchdb.http.ResourceNotFound as e:
print('Operation failed.')
else... | Delete an item selected by id. | Delete an item selected by id. | [
"Delete",
"an",
"item",
"selected",
"by",
"id",
"."
] | def delete():
db = connect()
if db:
key = input('Enter product id: ')
try:
db.delete(db[key])
print('Product successfully deleted.')
except couchdb.http.ResourceNotFound as e:
print('Operation failed.')
else:
print('Connection Error.') | [
"def",
"delete",
"(",
")",
":",
"db",
"=",
"connect",
"(",
")",
"if",
"db",
":",
"key",
"=",
"input",
"(",
"'Enter product id: '",
")",
"try",
":",
"db",
".",
"delete",
"(",
"db",
"[",
"key",
"]",
")",
"print",
"(",
"'Product successfully deleted.'",
... | Delete an item selected by id. | [
"Delete",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Delete an item selected by id.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
e986facbc139f6c8919949bae62a4974c3803bce | vrcunha/db_sql_and_nosql | firebase/funcs/crud_firebase.py | [
"MIT"
] | Python | update | <not_specific> | def update(name=False, price=False, stock=False):
"""Update an item selected by id."""
db = connect()
key = input('Enter your product id: ')
product = db.child('products').child(key).get()
if product.val():
if name:
db.child('products').child(key).update({"name":input('Enter new... | Update an item selected by id. | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | def update(name=False, price=False, stock=False):
db = connect()
key = input('Enter your product id: ')
product = db.child('products').child(key).get()
if product.val():
if name:
db.child('products').child(key).update({"name":input('Enter new product name: ')})
print('Pro... | [
"def",
"update",
"(",
"name",
"=",
"False",
",",
"price",
"=",
"False",
",",
"stock",
"=",
"False",
")",
":",
"db",
"=",
"connect",
"(",
")",
"key",
"=",
"input",
"(",
"'Enter your product id: '",
")",
"product",
"=",
"db",
".",
"child",
"(",
"'produ... | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Update an item selected by id.\"\"\""
] | [
{
"param": "name",
"type": null
},
{
"param": "price",
"type": null
},
{
"param": "stock",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "price",
"type": null,
"docstring": null,
"docstring_tokens": ... |
e986facbc139f6c8919949bae62a4974c3803bce | vrcunha/db_sql_and_nosql | firebase/funcs/crud_firebase.py | [
"MIT"
] | Python | delete | null | def delete():
"""Delete an item selected by id."""
db = connect()
key = input('Enter product id: ')
product = db.child('products').child(key).get()
if product.val():
db.child('products').child(key).remove()
print('Product deleted.')
else:
print('Product not found.') | Delete an item selected by id. | Delete an item selected by id. | [
"Delete",
"an",
"item",
"selected",
"by",
"id",
"."
] | def delete():
db = connect()
key = input('Enter product id: ')
product = db.child('products').child(key).get()
if product.val():
db.child('products').child(key).remove()
print('Product deleted.')
else:
print('Product not found.') | [
"def",
"delete",
"(",
")",
":",
"db",
"=",
"connect",
"(",
")",
"key",
"=",
"input",
"(",
"'Enter product id: '",
")",
"product",
"=",
"db",
".",
"child",
"(",
"'products'",
")",
".",
"child",
"(",
"key",
")",
".",
"get",
"(",
")",
"if",
"product",... | Delete an item selected by id. | [
"Delete",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Delete an item selected by id.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
a3f444868f25c6137eecbb84a05a3e7d27d32b01 | vrcunha/db_sql_and_nosql | mongo/funcs/crud_mongo.py | [
"MIT"
] | Python | insert | null | def insert(collection):
"""Insert item inside collection in database.
insert_one: insert one item in the collection.
insert_many: insert many itens in the collection.
Keyword arguments:
collection -- Name of the collection on database.
"""
quant = int(input('How many itens you want to inse... | Insert item inside collection in database.
insert_one: insert one item in the collection.
insert_many: insert many itens in the collection.
Keyword arguments:
collection -- Name of the collection on database.
| Insert item inside collection in database.
insert_one: insert one item in the collection.
insert_many: insert many itens in the collection.
Keyword arguments:
collection -- Name of the collection on database. | [
"Insert",
"item",
"inside",
"collection",
"in",
"database",
".",
"insert_one",
":",
"insert",
"one",
"item",
"in",
"the",
"collection",
".",
"insert_many",
":",
"insert",
"many",
"itens",
"in",
"the",
"collection",
".",
"Keyword",
"arguments",
":",
"collection... | def insert(collection):
quant = int(input('How many itens you want to insert: '))
properties = int(input('How much properties this item have? '))
itens_input = [{
input('Enter key name: '): input('Enter value: ') for x in range(properties)
} for i in range(quant)]
if quant == 1:
collecti... | [
"def",
"insert",
"(",
"collection",
")",
":",
"quant",
"=",
"int",
"(",
"input",
"(",
"'How many itens you want to insert: '",
")",
")",
"properties",
"=",
"int",
"(",
"input",
"(",
"'How much properties this item have? '",
")",
")",
"itens_input",
"=",
"[",
"{"... | Insert item inside collection in database. | [
"Insert",
"item",
"inside",
"collection",
"in",
"database",
"."
] | [
"\"\"\"Insert item inside collection in database.\n\n insert_one: insert one item in the collection.\n insert_many: insert many itens in the collection.\n\n Keyword arguments:\n collection -- Name of the collection on database.\n \"\"\""
] | [
{
"param": "collection",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "collection",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a3f444868f25c6137eecbb84a05a3e7d27d32b01 | vrcunha/db_sql_and_nosql | mongo/funcs/crud_mongo.py | [
"MIT"
] | Python | list_itens | null | def list_itens(collection):
"""List itens from database.
Keyword arguments:
collection -- Name of the collection on database.
"""
db_list = collection.find()
if collection.count_documents({}) > 0:
for item in db_list:
print(len(item)*'-')
print(item)
else:
... | List itens from database.
Keyword arguments:
collection -- Name of the collection on database.
| List itens from database.
Keyword arguments:
collection -- Name of the collection on database. | [
"List",
"itens",
"from",
"database",
".",
"Keyword",
"arguments",
":",
"collection",
"--",
"Name",
"of",
"the",
"collection",
"on",
"database",
"."
] | def list_itens(collection):
db_list = collection.find()
if collection.count_documents({}) > 0:
for item in db_list:
print(len(item)*'-')
print(item)
else:
print('This collection is empty.') | [
"def",
"list_itens",
"(",
"collection",
")",
":",
"db_list",
"=",
"collection",
".",
"find",
"(",
")",
"if",
"collection",
".",
"count_documents",
"(",
"{",
"}",
")",
">",
"0",
":",
"for",
"item",
"in",
"db_list",
":",
"print",
"(",
"len",
"(",
"item... | List itens from database. | [
"List",
"itens",
"from",
"database",
"."
] | [
"\"\"\"List itens from database.\n\n Keyword arguments:\n collection -- Name of the collection on database.\n \"\"\""
] | [
{
"param": "collection",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "collection",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a3f444868f25c6137eecbb84a05a3e7d27d32b01 | vrcunha/db_sql_and_nosql | mongo/funcs/crud_mongo.py | [
"MIT"
] | Python | update | null | def update(collection):
"""Update an item selected by id."""
db_list = collection.find({})
for idx, item in enumerate(db_list, start=1):
print(len(item)*'-')
print(idx, item)
db_list = collection.find({})
idx = int(input('Select the object to update by index: '))
prod_id ... | Update an item selected by id. | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | def update(collection):
db_list = collection.find({})
for idx, item in enumerate(db_list, start=1):
print(len(item)*'-')
print(idx, item)
db_list = collection.find({})
idx = int(input('Select the object to update by index: '))
prod_id = {'_id': db_list[idx-1]['_id']}
upda... | [
"def",
"update",
"(",
"collection",
")",
":",
"db_list",
"=",
"collection",
".",
"find",
"(",
"{",
"}",
")",
"for",
"idx",
",",
"item",
"in",
"enumerate",
"(",
"db_list",
",",
"start",
"=",
"1",
")",
":",
"print",
"(",
"len",
"(",
"item",
")",
"*... | Update an item selected by id. | [
"Update",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Update an item selected by id.\"\"\""
] | [
{
"param": "collection",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "collection",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a3f444868f25c6137eecbb84a05a3e7d27d32b01 | vrcunha/db_sql_and_nosql | mongo/funcs/crud_mongo.py | [
"MIT"
] | Python | delete | null | def delete(collection):
"""Delete an item selected by id."""
db_list = collection.find({})
for idx, item in enumerate(db_list, start=1):
print(len(item)*'-')
print(idx, item)
db_list = collection.find({})
idx = int(input('Select the object to update by index: '))
prod_id ... | Delete an item selected by id. | Delete an item selected by id. | [
"Delete",
"an",
"item",
"selected",
"by",
"id",
"."
] | def delete(collection):
db_list = collection.find({})
for idx, item in enumerate(db_list, start=1):
print(len(item)*'-')
print(idx, item)
db_list = collection.find({})
idx = int(input('Select the object to update by index: '))
prod_id = {'_id': db_list[idx-1]['_id']}
del_... | [
"def",
"delete",
"(",
"collection",
")",
":",
"db_list",
"=",
"collection",
".",
"find",
"(",
"{",
"}",
")",
"for",
"idx",
",",
"item",
"in",
"enumerate",
"(",
"db_list",
",",
"start",
"=",
"1",
")",
":",
"print",
"(",
"len",
"(",
"item",
")",
"*... | Delete an item selected by id. | [
"Delete",
"an",
"item",
"selected",
"by",
"id",
"."
] | [
"\"\"\"Delete an item selected by id.\"\"\""
] | [
{
"param": "collection",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "collection",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0808aa42379ba8646a13ee968ff277ea0daafaca | resuly/embedding | model/model/data_loader.py | [
"Apache-2.0"
] | Python | fetch_dataloader | <not_specific> | def fetch_dataloader(types, data_dir, params):
"""
Fetches the DataLoader object for each type in types from data_dir.
Args:
types: (list) has one or more of 'train', 'val', 'test' depending on which data is required
data_dir: (string) directory containing the dataset
params: (Param... |
Fetches the DataLoader object for each type in types from data_dir.
Args:
types: (list) has one or more of 'train', 'val', 'test' depending on which data is required
data_dir: (string) directory containing the dataset
params: (Params) hyperparameters
Returns:
data: (dict) ... | Fetches the DataLoader object for each type in types from data_dir. | [
"Fetches",
"the",
"DataLoader",
"object",
"for",
"each",
"type",
"in",
"types",
"from",
"data_dir",
"."
] | def fetch_dataloader(types, data_dir, params):
dataloaders = {}
train_dataset = PEMSTrianDataset(params=params)
indices = list(range(len(train_dataset)))
split = int(0.1*len(train_dataset))
validation_idx = np.random.choice(indices, size=split, replace=False)
train_idx = list(set(indices) - se... | [
"def",
"fetch_dataloader",
"(",
"types",
",",
"data_dir",
",",
"params",
")",
":",
"dataloaders",
"=",
"{",
"}",
"train_dataset",
"=",
"PEMSTrianDataset",
"(",
"params",
"=",
"params",
")",
"indices",
"=",
"list",
"(",
"range",
"(",
"len",
"(",
"train_data... | Fetches the DataLoader object for each type in types from data_dir. | [
"Fetches",
"the",
"DataLoader",
"object",
"for",
"each",
"type",
"in",
"types",
"from",
"data_dir",
"."
] | [
"\"\"\"\n Fetches the DataLoader object for each type in types from data_dir.\n\n Args:\n types: (list) has one or more of 'train', 'val', 'test' depending on which data is required\n data_dir: (string) directory containing the dataset\n params: (Params) hyperparameters\n\n Returns:\n ... | [
{
"param": "types",
"type": null
},
{
"param": "data_dir",
"type": null
},
{
"param": "params",
"type": null
}
] | {
"returns": [
{
"docstring": "(dict) contains the DataLoader object for each type in types",
"docstring_tokens": [
"(",
"dict",
")",
"contains",
"the",
"DataLoader",
"object",
"for",
"each",
"type",
"in",
... |
2806057742efcb94eca5ba27ef4dd2d6ec387989 | resuly/embedding | model/train.py | [
"Apache-2.0"
] | Python | train | null | def train(model, optimizer, loss_fn, dataloader, metrics, params):
"""Train the model on `num_steps` batches
Args:
model: (torch.nn.Module) the neural network
optimizer: (torch.optim) optimizer for parameters of model
loss_fn: a function that takes batch_output and batch_labels and comp... | Train the model on `num_steps` batches
Args:
model: (torch.nn.Module) the neural network
optimizer: (torch.optim) optimizer for parameters of model
loss_fn: a function that takes batch_output and batch_labels and computes the loss for the batch
dataloader: (DataLoader) a torch.utils... | Train the model on `num_steps` batches | [
"Train",
"the",
"model",
"on",
"`",
"num_steps",
"`",
"batches"
] | def train(model, optimizer, loss_fn, dataloader, metrics, params):
model.train()
summ = []
loss_avg = utils.RunningAverage()
with tqdm(total=len(dataloader), ascii=True) as t:
for i, (train_batch, labels_batch) in enumerate(dataloader):
if params.cuda:
train_batch, la... | [
"def",
"train",
"(",
"model",
",",
"optimizer",
",",
"loss_fn",
",",
"dataloader",
",",
"metrics",
",",
"params",
")",
":",
"model",
".",
"train",
"(",
")",
"summ",
"=",
"[",
"]",
"loss_avg",
"=",
"utils",
".",
"RunningAverage",
"(",
")",
"with",
"tq... | Train the model on `num_steps` batches | [
"Train",
"the",
"model",
"on",
"`",
"num_steps",
"`",
"batches"
] | [
"\"\"\"Train the model on `num_steps` batches\n\n Args:\n model: (torch.nn.Module) the neural network\n optimizer: (torch.optim) optimizer for parameters of model\n loss_fn: a function that takes batch_output and batch_labels and computes the loss for the batch\n dataloader: (DataLoad... | [
{
"param": "model",
"type": null
},
{
"param": "optimizer",
"type": null
},
{
"param": "loss_fn",
"type": null
},
{
"param": "dataloader",
"type": null
},
{
"param": "metrics",
"type": null
},
{
"param": "params",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model",
"type": null,
"docstring": "(torch.nn.Module) the neural network",
"docstring_tokens": [
"(",
"torch",
".",
"nn",
".",
"Module",
")",
"the",
"neur... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.