Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
unblock
(msg, room_id)
Unblocks posting to a room :param msg: :param room_id: :return: None
Unblocks posting to a room :param msg: :param room_id: :return: None
def unblock(msg, room_id): """ Unblocks posting to a room :param msg: :param room_id: :return: None """ block_room(room_id, msg._client.host, -1) which_room = "globally" if room_id is None else "in room {} on {}".format(room_id, msg._client.host) unblock_message = "Reports unblocked...
[ "def", "unblock", "(", "msg", ",", "room_id", ")", ":", "block_room", "(", "room_id", ",", "msg", ".", "_client", ".", "host", ",", "-", "1", ")", "which_room", "=", "\"globally\"", "if", "room_id", "is", "None", "else", "\"in room {} on {}\"", ".", "for...
[ 781, 0 ]
[ 793, 93 ]
python
en
['en', 'error', 'th']
False
alive
()
Returns a string indicating the process is still active :return: A string
Returns a string indicating the process is still active :return: A string
def alive(): """ Returns a string indicating the process is still active :return: A string """ return random.choice(ALIVE_MSG)
[ "def", "alive", "(", ")", ":", "return", "random", ".", "choice", "(", "ALIVE_MSG", ")" ]
[ 806, 0 ]
[ 811, 35 ]
python
en
['en', 'error', 'th']
False
errorlogs
(count)
Shows the most recent lines in the error logs :param count: :return: A string
Shows the most recent lines in the error logs :param count: :return: A string
def errorlogs(count): """ Shows the most recent lines in the error logs :param count: :return: A string """ return fetch_lines_from_error_log(count or 2)
[ "def", "errorlogs", "(", "count", ")", ":", "return", "fetch_lines_from_error_log", "(", "count", "or", "2", ")" ]
[ 816, 0 ]
[ 822, 49 ]
python
en
['en', 'error', 'th']
False
stat
()
Return post scan statistics.
Return post scan statistics.
def stat(): """ Return post scan statistics. """ posts_scanned, scan_time, posts_per_second = GlobalVars.PostScanStat.get_stat() stat_msg = "Posts scanned: {}; Scan time: {}".format(posts_scanned, scan_time) rate_msg = "" if posts_per_second: rate_msg = "; Posts scanned per second: {}".form...
[ "def", "stat", "(", ")", ":", "posts_scanned", ",", "scan_time", ",", "posts_per_second", "=", "GlobalVars", ".", "PostScanStat", ".", "get_stat", "(", ")", "stat_msg", "=", "\"Posts scanned: {}; Scan time: {}\"", ".", "format", "(", "posts_scanned", ",", "scan_ti...
[ 858, 0 ]
[ 867, 30 ]
python
en
['en', 'mt', 'en']
True
ping_failure_counter
()
Return ping failure counter value of Metasmoke: AutoSwitch.
Return ping failure counter value of Metasmoke: AutoSwitch.
def ping_failure_counter(): """ Return ping failure counter value of Metasmoke: AutoSwitch. """ counter = Metasmoke.AutoSwitch.get_ping_failure() return "Current ping failure counter value: {}".format(counter)
[ "def", "ping_failure_counter", "(", ")", ":", "counter", "=", "Metasmoke", ".", "AutoSwitch", ".", "get_ping_failure", "(", ")", "return", "\"Current ping failure counter value: {}\"", ".", "format", "(", "counter", ")" ]
[ 871, 0 ]
[ 874, 67 ]
python
en
['en', 'en', 'en']
True
info
()
Returns the help text :return: A string
Returns the help text :return: A string
def info(): """ Returns the help text :return: A string """ return "I'm " + GlobalVars.chatmessage_prefix +\ ", a bot that detects spam and offensive posts on the network and"\ " posts alerts to chat."\ " [A command list is available here](https://git.io/SD-Commands)...
[ "def", "info", "(", ")", ":", "return", "\"I'm \"", "+", "GlobalVars", ".", "chatmessage_prefix", "+", "\", a bot that detects spam and offensive posts on the network and\"", "\" posts alerts to chat.\"", "\" [A command list is available here](https://git.io/SD-Commands).\"" ]
[ 879, 0 ]
[ 887, 77 ]
python
en
['en', 'error', 'th']
False
welcome
(msg, other_user)
Returns the welcome text :param msg: :param other_user: :return: A string
Returns the welcome text :param msg: :param other_user: :return: A string
def welcome(msg, other_user): """ Returns the welcome text :param msg: :param other_user: :return: A string """ w_msg = ("Welcome to {room}{user}! I'm {me}, a bot that detects spam and offensive posts on the network, " "and posts alerts to chat. You can find more about me on the...
[ "def", "welcome", "(", "msg", ",", "other_user", ")", ":", "w_msg", "=", "(", "\"Welcome to {room}{user}! I'm {me}, a bot that detects spam and offensive posts on the network, \"", "\"and posts alerts to chat. You can find more about me on the \"", "\"[Charcoal website](https://charcoal-se...
[ 892, 0 ]
[ 906, 118 ]
python
en
['en', 'error', 'th']
False
master
()
Forces a system exit with exit code = 8 :return: None
Forces a system exit with exit code = 8 :return: None
def master(): """ Forces a system exit with exit code = 8 :return: None """ exit_mode("checkout_deploy")
[ "def", "master", "(", ")", ":", "exit_mode", "(", "\"checkout_deploy\"", ")" ]
[ 911, 0 ]
[ 916, 32 ]
python
en
['en', 'error', 'th']
False
pull
(alias_used='pull')
Pull an update from GitHub :return: String on failure, None on success
Pull an update from GitHub :return: String on failure, None on success
def pull(alias_used='pull'): """ Pull an update from GitHub :return: String on failure, None on success """ remote_diff = GitManager.get_remote_diff() if (not alias_used == "pull-force") and only_blacklists_changed(remote_diff): GitManager.pull_remote() findspam.FindSpam.reload_b...
[ "def", "pull", "(", "alias_used", "=", "'pull'", ")", ":", "remote_diff", "=", "GitManager", ".", "get_remote_diff", "(", ")", "if", "(", "not", "alias_used", "==", "\"pull-force\"", ")", "and", "only_blacklists_changed", "(", "remote_diff", ")", ":", "GitMana...
[ 921, 0 ]
[ 956, 111 ]
python
en
['en', 'error', 'th']
False
sync_remote
(msg, alias_used='pull-sync')
Force a branch sync from origin/master with [git branch -M] :param msg: :return: A string containing a response message
Force a branch sync from origin/master with [git branch -M] :param msg: :return: A string containing a response message
def sync_remote(msg, alias_used='pull-sync'): """ Force a branch sync from origin/master with [git branch -M] :param msg: :return: A string containing a response message """ if not is_code_privileged(msg._client.host, msg.owner.id): raise CmdException("You don't have blacklist manager pr...
[ "def", "sync_remote", "(", "msg", ",", "alias_used", "=", "'pull-sync'", ")", ":", "if", "not", "is_code_privileged", "(", "msg", ".", "_client", ".", "host", ",", "msg", ".", "owner", ".", "id", ")", ":", "raise", "CmdException", "(", "\"You don't have bl...
[ 960, 0 ]
[ 971, 38 ]
python
en
['en', 'error', 'th']
False
sync_remote_hard
(msg, alias_used='pull-sync-hard')
Force a branch sync from origin/master and origin/deploy :param msg: :return: A string containing a response message or None
Force a branch sync from origin/master and origin/deploy :param msg: :return: A string containing a response message or None
def sync_remote_hard(msg, alias_used='pull-sync-hard'): """ Force a branch sync from origin/master and origin/deploy :param msg: :return: A string containing a response message or None """ if not is_code_privileged(msg._client.host, msg.owner.id): raise CmdException("You don't have black...
[ "def", "sync_remote_hard", "(", "msg", ",", "alias_used", "=", "'pull-sync-hard'", ")", ":", "if", "not", "is_code_privileged", "(", "msg", ".", "_client", ".", "host", ",", "msg", ".", "owner", ".", "id", ")", ":", "raise", "CmdException", "(", "\"You don...
[ 978, 0 ]
[ 995, 67 ]
python
en
['en', 'error', 'th']
False
reboot
(msg, alias_used="reboot")
Forces a system exit with exit code = 5 :param msg: :return: None
Forces a system exit with exit code = 5 :param msg: :return: None
def reboot(msg, alias_used="reboot"): """ Forces a system exit with exit code = 5 :param msg: :return: None """ if alias_used in {"reboot", "restart"}: tell_rooms("{}: Goodbye, cruel world".format(GlobalVars.location), ("debug", (msg._client.host, msg.room.id)), ()) ...
[ "def", "reboot", "(", "msg", ",", "alias_used", "=", "\"reboot\"", ")", ":", "if", "alias_used", "in", "{", "\"reboot\"", ",", "\"restart\"", "}", ":", "tell_rooms", "(", "\"{}: Goodbye, cruel world\"", ".", "format", "(", "GlobalVars", ".", "location", ")", ...
[ 1018, 0 ]
[ 1034, 44 ]
python
en
['en', 'error', 'th']
False
amiprivileged
(msg)
Tells user whether or not they have privileges :param msg: :return: A string
Tells user whether or not they have privileges :param msg: :return: A string
def amiprivileged(msg): """ Tells user whether or not they have privileges :param msg: :return: A string """ if is_privileged(msg.owner, msg.room): return "\u2713 You are a privileged user." return "\u2573 " + GlobalVars.not_privileged_warning
[ "def", "amiprivileged", "(", "msg", ")", ":", "if", "is_privileged", "(", "msg", ".", "owner", ",", "msg", ".", "room", ")", ":", "return", "\"\\u2713 You are a privileged user.\"", "return", "\"\\u2573 \"", "+", "GlobalVars", ".", "not_privileged_warning" ]
[ 1039, 0 ]
[ 1048, 56 ]
python
en
['en', 'error', 'th']
False
amiblacklistprivileged
(msg)
Tells user whether or not they have blacklister privileges :param msg: :return: A string
Tells user whether or not they have blacklister privileges :param msg: :return: A string
def amiblacklistprivileged(msg): """ Tells user whether or not they have blacklister privileges :param msg: :return: A string """ update_code_privileged_users_list() if is_code_privileged(msg._client.host, msg.owner.id): return "\u2713 You are a blacklist manager privileged user." ...
[ "def", "amiblacklistprivileged", "(", "msg", ")", ":", "update_code_privileged_users_list", "(", ")", "if", "is_code_privileged", "(", "msg", ".", "_client", ".", "host", ",", "msg", ".", "owner", ".", "id", ")", ":", "return", "\"\\u2713 You are a blacklist manag...
[ 1053, 0 ]
[ 1063, 72 ]
python
en
['en', 'error', 'th']
False
apiquota
()
Report how many API hits remain for the day :return: A string
Report how many API hits remain for the day :return: A string
def apiquota(): """ Report how many API hits remain for the day :return: A string """ GlobalVars.apiquota_rw_lock.acquire() current_apiquota = GlobalVars.apiquota GlobalVars.apiquota_rw_lock.release() return "The current API quota remaining is {}.".format(current_apiquota)
[ "def", "apiquota", "(", ")", ":", "GlobalVars", ".", "apiquota_rw_lock", ".", "acquire", "(", ")", "current_apiquota", "=", "GlobalVars", ".", "apiquota", "GlobalVars", ".", "apiquota_rw_lock", ".", "release", "(", ")", "return", "\"The current API quota remaining i...
[ 1068, 0 ]
[ 1077, 76 ]
python
en
['en', 'error', 'th']
False
queuestatus
()
Report current API queue :return: A string
Report current API queue :return: A string
def queuestatus(): """ Report current API queue :return: A string """ return GlobalVars.bodyfetcher.print_queue()
[ "def", "queuestatus", "(", ")", ":", "return", "GlobalVars", ".", "bodyfetcher", ".", "print_queue", "(", ")" ]
[ 1082, 0 ]
[ 1087, 47 ]
python
en
['en', 'error', 'th']
False
stappit
(msg, location_search)
Forces a system exit with exit code = 6 :param msg: :param location_search: :return: None
Forces a system exit with exit code = 6 :param msg: :param location_search: :return: None
def stappit(msg, location_search): """ Forces a system exit with exit code = 6 :param msg: :param location_search: :return: None """ if location_search is None or location_search.lower() in GlobalVars.location.lower(): tell_rooms("{}: Goodbye, cruel world".format(GlobalVars.location)...
[ "def", "stappit", "(", "msg", ",", "location_search", ")", ":", "if", "location_search", "is", "None", "or", "location_search", ".", "lower", "(", ")", "in", "GlobalVars", ".", "location", ".", "lower", "(", ")", ":", "tell_rooms", "(", "\"{}: Goodbye, cruel...
[ 1118, 0 ]
[ 1130, 37 ]
python
en
['en', 'error', 'th']
False
status
()
Returns the amount of time the application has been running :return: A string
Returns the amount of time the application has been running :return: A string
def status(): """ Returns the amount of time the application has been running :return: A string """ now = datetime.utcnow() diff = now - GlobalVars.startup_utc_date return 'Running since {time} UTC ({relative})'.format(time=GlobalVars.startup_utc, relative=td_format(diff))
[ "def", "status", "(", ")", ":", "now", "=", "datetime", ".", "utcnow", "(", ")", "diff", "=", "now", "-", "GlobalVars", ".", "startup_utc_date", "return", "'Running since {time} UTC ({relative})'", ".", "format", "(", "time", "=", "GlobalVars", ".", "startup_u...
[ 1159, 0 ]
[ 1167, 112 ]
python
en
['en', 'error', 'th']
False
standby
(msg, location_search, alias_used="standby")
Forces a system exit with exit code = 7 :param msg: :param location_search: :return: None
Forces a system exit with exit code = 7 :param msg: :param location_search: :return: None
def standby(msg, location_search, alias_used="standby"): """ Forces a system exit with exit code = 7 :param msg: :param location_search: :return: None """ match = location_search.lower() in GlobalVars.location.lower() reverse_search = "except" in alias_used # Use `!=` as Logical XO...
[ "def", "standby", "(", "msg", ",", "location_search", ",", "alias_used", "=", "\"standby\"", ")", ":", "match", "=", "location_search", ".", "lower", "(", ")", "in", "GlobalVars", ".", "location", ".", "lower", "(", ")", "reverse_search", "=", "\"except\"", ...
[ 1180, 0 ]
[ 1197, 36 ]
python
en
['en', 'error', 'th']
False
test
(content, alias_used="test")
Test content provided in chat to determine if it'd be automatically reported :param content: :return: A string
Test content provided in chat to determine if it'd be automatically reported :param content: :return: A string
def test(content, alias_used="test"): """ Test content provided in chat to determine if it'd be automatically reported :param content: :return: A string """ result = "> " site = "" option_count = 0 for segment in content.split(): if segment.startswith("site="): s...
[ "def", "test", "(", "content", ",", "alias_used", "=", "\"test\"", ")", ":", "result", "=", "\"> \"", "site", "=", "\"\"", "option_count", "=", "0", "for", "segment", "in", "content", ".", "split", "(", ")", ":", "if", "segment", ".", "startswith", "("...
[ 1204, 0 ]
[ 1305, 17 ]
python
en
['en', 'error', 'th']
False
threads
()
Returns a description of current threads, for debugging :return: A string
Returns a description of current threads, for debugging :return: A string
def threads(): """ Returns a description of current threads, for debugging :return: A string """ # Note: One may see multiple threads named "message_sender", and they are started by ChatExchange, # one for each chat server. # The one started by SmokeDetector is named "message sender", witho...
[ "def", "threads", "(", ")", ":", "# Note: One may see multiple threads named \"message_sender\", and they are started by ChatExchange,", "# one for each chat server.", "# The one started by SmokeDetector is named \"message sender\", without the underscore.", "threads_list", "=", "[", "\"{ident...
[ 1446, 0 ]
[ 1457, 34 ]
python
en
['en', 'error', 'th']
False
version
()
Returns the current version of the application :return: A string
Returns the current version of the application :return: A string
def version(): """ Returns the current version of the application :return: A string """ return '{id} [{commit_name}]({repository}/commit/{commit_code})'.format( id=GlobalVars.location, commit_name=GlobalVars.commit_with_author_escaped, commit_code=GlobalVars.commit.id, ...
[ "def", "version", "(", ")", ":", "return", "'{id} [{commit_name}]({repository}/commit/{commit_code})'", ".", "format", "(", "id", "=", "GlobalVars", ".", "location", ",", "commit_name", "=", "GlobalVars", ".", "commit_with_author_escaped", ",", "commit_code", "=", "Gl...
[ 1462, 0 ]
[ 1473, 5 ]
python
en
['en', 'error', 'th']
False
whoami
(msg)
Returns user id of smoke detector :param msg: :return:
Returns user id of smoke detector :param msg: :return:
def whoami(msg): """ Returns user id of smoke detector :param msg: :return: """ return "My id for this room is {}, and it's not apnorton's fault.".format(msg._client._br.user_id)
[ "def", "whoami", "(", "msg", ")", ":", "return", "\"My id for this room is {}, and it's not apnorton's fault.\"", ".", "format", "(", "msg", ".", "_client", ".", "_br", ".", "user_id", ")" ]
[ 1478, 0 ]
[ 1484, 102 ]
python
en
['en', 'error', 'th']
False
allnotificationsites
(msg, room_id)
Returns a string stating what sites a user will be notified about :param msg: :param room_id: :return: A string
Returns a string stating what sites a user will be notified about :param msg: :param room_id: :return: A string
def allnotificationsites(msg, room_id): """ Returns a string stating what sites a user will be notified about :param msg: :param room_id: :return: A string """ sites = get_all_notification_sites(msg.owner.id, msg._client.host, room_id) if len(sites) == 0: return "You won't get n...
[ "def", "allnotificationsites", "(", "msg", ",", "room_id", ")", ":", "sites", "=", "get_all_notification_sites", "(", "msg", ".", "owner", ".", "id", ",", "msg", ".", "_client", ".", "host", ",", "room_id", ")", "if", "len", "(", "sites", ")", "==", "0...
[ 1490, 0 ]
[ 1502, 74 ]
python
en
['en', 'error', 'th']
False
notify
(msg, room_id, se_site, always_ping)
Subscribe a user to events on a site in a single room :param msg: :param room_id: :param se_site: :return: A string
Subscribe a user to events on a site in a single room :param msg: :param room_id: :param se_site: :return: A string
def notify(msg, room_id, se_site, always_ping): """ Subscribe a user to events on a site in a single room :param msg: :param room_id: :param se_site: :return: A string """ # TODO: Add check whether smokey reports in that room response, full_site = add_to_notification_list(msg.owner.i...
[ "def", "notify", "(", "msg", ",", "room_id", ",", "se_site", ",", "always_ping", ")", ":", "# TODO: Add check whether smokey reports in that room", "response", ",", "full_site", "=", "add_to_notification_list", "(", "msg", ".", "owner", ".", "id", ",", "msg", ".",...
[ 1507, 0 ]
[ 1527, 82 ]
python
en
['en', 'error', 'th']
False
unnotify_all
(msg)
Unsubscribes a user to all events :param msg: :return: A string
Unsubscribes a user to all events :param msg: :return: A string
def unnotify_all(msg): """ Unsubscribes a user to all events :param msg: :return: A string """ remove_all_from_notification_list(msg.owner.id) return "I will no longer ping you if I report a post anywhere."
[ "def", "unnotify_all", "(", "msg", ")", ":", "remove_all_from_notification_list", "(", "msg", ".", "owner", ".", "id", ")", "return", "\"I will no longer ping you if I report a post anywhere.\"" ]
[ 1545, 0 ]
[ 1552, 67 ]
python
en
['en', 'error', 'th']
False
unnotify
(msg, room_id, se_site)
Unsubscribes a user to specific events :param msg: :param room_id: :param se_site: :return: A string
Unsubscribes a user to specific events :param msg: :param room_id: :param se_site: :return: A string
def unnotify(msg, room_id, se_site): """ Unsubscribes a user to specific events :param msg: :param room_id: :param se_site: :return: A string """ response = remove_from_notification_list(msg.owner.id, msg._client.host, room_id, se_site) if response: return "I will no longer ...
[ "def", "unnotify", "(", "msg", ",", "room_id", ",", "se_site", ")", ":", "response", "=", "remove_from_notification_list", "(", "msg", ".", "owner", ".", "id", ",", "msg", ".", "_client", ".", "host", ",", "room_id", ",", "se_site", ")", "if", "response"...
[ 1557, 0 ]
[ 1571, 59 ]
python
en
['en', 'error', 'th']
False
willbenotified
(msg, room_id, se_site)
Returns a string stating whether a user will be notified or not :param msg: :param room_id: :param se_site: :return: A string
Returns a string stating whether a user will be notified or not :param msg: :param room_id: :param se_site: :return: A string
def willbenotified(msg, room_id, se_site): """ Returns a string stating whether a user will be notified or not :param msg: :param room_id: :param se_site: :return: A string """ if will_i_be_notified(msg.owner.id, msg._client.host, room_id, se_site): return "Yes, you will be notif...
[ "def", "willbenotified", "(", "msg", ",", "room_id", ",", "se_site", ")", ":", "if", "will_i_be_notified", "(", "msg", ".", "owner", ".", "id", ",", "msg", ".", "_client", ".", "host", ",", "room_id", ",", "se_site", ")", ":", "return", "\"Yes, you will ...
[ 1576, 0 ]
[ 1587, 66 ]
python
en
['en', 'error', 'th']
False
whois
(msg, role)
Return a list of important users :param msg: :param role: :return: A string
Return a list of important users :param msg: :param role: :return: A string
def whois(msg, role): """ Return a list of important users :param msg: :param role: :return: A string """ if role not in VALID_ROLES: raise CmdException("That is not a user level I can check. " "I know about {0}".format(", ".join(set(VALID_ROLES.values())))...
[ "def", "whois", "(", "msg", ",", "role", ")", ":", "if", "role", "not", "in", "VALID_ROLES", ":", "raise", "CmdException", "(", "\"That is not a user level I can check. \"", "\"I know about {0}\"", ".", "format", "(", "\", \"", ".", "join", "(", "set", "(", "V...
[ 1602, 0 ]
[ 1680, 19 ]
python
en
['en', 'error', 'th']
False
report
(msg, args, alias_used="report")
Report a post (or posts) :param msg: :return: A string (or None)
Report a post (or posts) :param msg: :return: A string (or None)
def report(msg, args, alias_used="report"): """ Report a post (or posts) :param msg: :return: A string (or None) """ if not is_privileged(msg.owner, msg.room) and alias_used != "scan": raise CmdException(GlobalVars.not_privileged_warning) crn, wait = can_report_now(msg.owner.id, msg...
[ "def", "report", "(", "msg", ",", "args", ",", "alias_used", "=", "\"report\"", ")", ":", "if", "not", "is_privileged", "(", "msg", ".", "owner", ",", "msg", ".", "room", ")", "and", "alias_used", "!=", "\"scan\"", ":", "raise", "CmdException", "(", "G...
[ 1695, 0 ]
[ 1741, 21 ]
python
en
['en', 'error', 'th']
False
allspam
(msg, url)
Reports all of a user's posts as spam :param msg: :param url: A user profile URL :return:
Reports all of a user's posts as spam :param msg: :param url: A user profile URL :return:
def allspam(msg, url): """ Reports all of a user's posts as spam :param msg: :param url: A user profile URL :return: """ api_key = 'IAkbitmze4B8KpacUfLqkw((' crn, wait = can_report_now(msg.owner.id, msg._client.host) if not crn: raise CmdException("You can execute the !!/all...
[ "def", "allspam", "(", "msg", ",", "url", ")", ":", "api_key", "=", "'IAkbitmze4B8KpacUfLqkw(('", "crn", ",", "wait", "=", "can_report_now", "(", "msg", ".", "owner", ".", "id", ",", "msg", ".", "_client", ".", "host", ")", "if", "not", "crn", ":", "...
[ 1746, 0 ]
[ 1876, 84 ]
python
en
['en', 'error', 'th']
False
report_posts
(urls, reported_by_owner, reported_in=None, blacklist_by=None, operation="report", custom_reason=None)
Reports a list of URLs :param urls: A list of URLs :param reported_by_owner: The chatexchange User record for the user that reported the URLs, or a str. :param reported_in: The name of the room in which the URLs were reported, or True if reported by the MS API. :param blacklist_by: String of the UR...
Reports a list of URLs :param urls: A list of URLs :param reported_by_owner: The chatexchange User record for the user that reported the URLs, or a str. :param reported_in: The name of the room in which the URLs were reported, or True if reported by the MS API. :param blacklist_by: String of the UR...
def report_posts(urls, reported_by_owner, reported_in=None, blacklist_by=None, operation="report", custom_reason=None): """ Reports a list of URLs :param urls: A list of URLs :param reported_by_owner: The chatexchange User record for the user that reported the URLs, or a str. :param reported_in: The...
[ "def", "report_posts", "(", "urls", ",", "reported_by_owner", ",", "reported_in", "=", "None", ",", "blacklist_by", "=", "None", ",", "operation", "=", "\"report\"", ",", "custom_reason", "=", "None", ")", ":", "# Use reported_by_owner.name (ChatExchange user record) ...
[ 1879, 0 ]
[ 2029, 15 ]
python
en
['en', 'error', 'th']
False
delete_force
(msg)
Delete a post from the room, ignoring protection for Charcoal HQ :param msg: :return: None
Delete a post from the room, ignoring protection for Charcoal HQ :param msg: :return: None
def delete_force(msg): """ Delete a post from the room, ignoring protection for Charcoal HQ :param msg: :return: None """ # noinspection PyBroadException try: msg.delete() except Exception: # I don't want to dig into ChatExchange pass
[ "def", "delete_force", "(", "msg", ")", ":", "# noinspection PyBroadException", "try", ":", "msg", ".", "delete", "(", ")", "except", "Exception", ":", "# I don't want to dig into ChatExchange", "pass" ]
[ 2082, 0 ]
[ 2092, 12 ]
python
en
['en', 'error', 'th']
False
delete
(msg)
Delete a post from a chatroom, with an override for Charcoal HQ. :param msg: :return: None
Delete a post from a chatroom, with an override for Charcoal HQ. :param msg: :return: None
def delete(msg): """ Delete a post from a chatroom, with an override for Charcoal HQ. :param msg: :return: None """ if msg.room.id == 11540: return "Messages/reports from SmokeDetector in Charcoal HQ are generally kept "\ "as records. If you really need to delete a messag...
[ "def", "delete", "(", "msg", ")", ":", "if", "msg", ".", "room", ".", "id", "==", "11540", ":", "return", "\"Messages/reports from SmokeDetector in Charcoal HQ are generally kept \"", "\"as records. If you really need to delete a message, please use \"", "\"`sd delete-force`. See...
[ 2097, 0 ]
[ 2114, 16 ]
python
en
['en', 'error', 'th']
False
postgone
(msg)
Removes link from a marked report message :param msg: :return: None
Removes link from a marked report message :param msg: :return: None
def postgone(msg): """ Removes link from a marked report message :param msg: :return: None """ edited = edited_message_after_postgone_command(msg.content) if edited is None: raise CmdException("That's not a report.") msg.edit(edited)
[ "def", "postgone", "(", "msg", ")", ":", "edited", "=", "edited_message_after_postgone_command", "(", "msg", ".", "content", ")", "if", "edited", "is", "None", ":", "raise", "CmdException", "(", "\"That's not a report.\"", ")", "msg", ".", "edit", "(", "edited...
[ 2119, 0 ]
[ 2130, 20 ]
python
en
['en', 'error', 'th']
False
false
(feedback, msg, comment, alias_used="false")
Marks a post as a false positive :param feedback: :param msg: :return: String
Marks a post as a false positive :param feedback: :param msg: :return: String
def false(feedback, msg, comment, alias_used="false"): """ Marks a post as a false positive :param feedback: :param msg: :return: String """ post_data = get_report_data(msg) if not post_data: raise CmdException("That message is not a report.") post_url, owner_url = post_data...
[ "def", "false", "(", "feedback", ",", "msg", ",", "comment", ",", "alias_used", "=", "\"false\"", ")", ":", "post_data", "=", "get_report_data", "(", "msg", ")", "if", "not", "post_data", ":", "raise", "CmdException", "(", "\"That message is not a report.\"", ...
[ 2136, 0 ]
[ 2180, 60 ]
python
en
['en', 'error', 'th']
False
ignore
(feedback, msg, comment, alias_used="ignore")
Marks a post to be ignored :param feedback: :param msg: :return: String
Marks a post to be ignored :param feedback: :param msg: :return: String
def ignore(feedback, msg, comment, alias_used="ignore"): """ Marks a post to be ignored :param feedback: :param msg: :return: String """ post_data = get_report_data(msg) if not post_data: raise CmdException("That message is not a report.") post_url, _ = post_data Feedba...
[ "def", "ignore", "(", "feedback", ",", "msg", ",", "comment", ",", "alias_used", "=", "\"ignore\"", ")", ":", "post_data", "=", "get_report_data", "(", "msg", ")", "if", "not", "post_data", ":", "raise", "CmdException", "(", "\"That message is not a report.\"", ...
[ 2185, 0 ]
[ 2208, 68 ]
python
en
['en', 'error', 'th']
False
naa
(feedback, msg, comment, alias_used="naa")
Marks a post as NAA :param feedback: :param msg: :return: String
Marks a post as NAA :param feedback: :param msg: :return: String
def naa(feedback, msg, comment, alias_used="naa"): """ Marks a post as NAA :param feedback: :param msg: :return: String """ post_data = get_report_data(msg) if not post_data: raise CmdException("That message is not a report.") post_url, _ = post_data post_id, site, post_...
[ "def", "naa", "(", "feedback", ",", "msg", ",", "comment", ",", "alias_used", "=", "\"naa\"", ")", ":", "post_data", "=", "get_report_data", "(", "msg", ")", "if", "not", "post_data", ":", "raise", "CmdException", "(", "\"That message is not a report.\"", ")",...
[ 2214, 0 ]
[ 2240, 95 ]
python
en
['en', 'error', 'th']
False
true
(feedback, msg, comment, alias_used="true")
Marks a post as a true positive :param feedback: :param msg: :return: string
Marks a post as a true positive :param feedback: :param msg: :return: string
def true(feedback, msg, comment, alias_used="true"): """ Marks a post as a true positive :param feedback: :param msg: :return: string """ post_data = get_report_data(msg) if not post_data: raise CmdException("That message is not a report.") post_url, owner_url = post_data ...
[ "def", "true", "(", "feedback", ",", "msg", ",", "comment", ",", "alias_used", "=", "\"true\"", ")", ":", "post_data", "=", "get_report_data", "(", "msg", ")", "if", "not", "post_data", ":", "raise", "CmdException", "(", "\"That message is not a report.\"", ")...
[ 2246, 0 ]
[ 2288, 60 ]
python
en
['en', 'error', 'th']
False
why
(msg)
Returns reasons a post was reported :param msg: :return: A string
Returns reasons a post was reported :param msg: :return: A string
def why(msg): """ Returns reasons a post was reported :param msg: :return: A string """ post_data = get_report_data(msg) if not post_data: raise CmdException("That's not a report.") else: *post, _ = fetch_post_id_and_site_from_url(post_data[0]) why_info = get_why(...
[ "def", "why", "(", "msg", ")", ":", "post_data", "=", "get_report_data", "(", "msg", ")", "if", "not", "post_data", ":", "raise", "CmdException", "(", "\"That's not a report.\"", ")", "else", ":", "*", "post", ",", "_", "=", "fetch_post_id_and_site_from_url", ...
[ 2293, 0 ]
[ 2309, 77 ]
python
en
['en', 'error', 'th']
False
autoflagged
(msg)
Determines whether a post was automatically flagged by Metasmoke :param msg: :return: A string
Determines whether a post was automatically flagged by Metasmoke :param msg: :return: A string
def autoflagged(msg): """ Determines whether a post was automatically flagged by Metasmoke :param msg: :return: A string """ # sneaky! update_reason_weights() post_data = get_report_data(msg) if not post_data: raise CmdException("That's not a report.") is_autoflagged, ...
[ "def", "autoflagged", "(", "msg", ")", ":", "# sneaky!", "update_reason_weights", "(", ")", "post_data", "=", "get_report_data", "(", "msg", ")", "if", "not", "post_data", ":", "raise", "CmdException", "(", "\"That's not a report.\"", ")", "is_autoflagged", ",", ...
[ 2314, 0 ]
[ 2333, 74 ]
python
en
['en', 'error', 'th']
False
dig
(domain)
Runs a DNS query using pydns and returns the list of A and AAAA records as output. :param domain: the domain to get DNS records for :return: A comma-separated string of IPs
Runs a DNS query using pydns and returns the list of A and AAAA records as output. :param domain: the domain to get DNS records for :return: A comma-separated string of IPs
def dig(domain): """ Runs a DNS query using pydns and returns the list of A and AAAA records as output. :param domain: the domain to get DNS records for :return: A comma-separated string of IPs """ results = dns_resolve(domain) if results: return ", ".join(result for result in re...
[ "def", "dig", "(", "domain", ")", ":", "results", "=", "dns_resolve", "(", "domain", ")", "if", "results", ":", "return", "\", \"", ".", "join", "(", "result", "for", "result", "in", "results", ")", "else", ":", "return", "\"No data found.\"" ]
[ 2338, 0 ]
[ 2349, 31 ]
python
en
['en', 'error', 'th']
False
build_dist_dict
(noise_prior, outputscale_prior, lengthscale_prior)
Build a dictionary of distributions to sample for random restarts.
Build a dictionary of distributions to sample for random restarts.
def build_dist_dict(noise_prior, outputscale_prior, lengthscale_prior): """ Build a dictionary of distributions to sample for random restarts. """ if noise_prior == None: noise_dist = GammaPrior(1.5,0.5) else: noise_dist = noise_prior[0] if outputscale_prior == None: ou...
[ "def", "build_dist_dict", "(", "noise_prior", ",", "outputscale_prior", ",", "lengthscale_prior", ")", ":", "if", "noise_prior", "==", "None", ":", "noise_dist", "=", "GammaPrior", "(", "1.5", ",", "0.5", ")", "else", ":", "noise_dist", "=", "noise_prior", "["...
[ 13, 0 ]
[ 37, 24 ]
python
en
['en', 'error', 'th']
False
set_init_params
(dictionary, distributions, seed=0)
Generate a new random state dictionary with entries drawn from the list of distributions.
Generate a new random state dictionary with entries drawn from the list of distributions.
def set_init_params(dictionary, distributions, seed=0): """ Generate a new random state dictionary with entries drawn from the list of distributions. """ dict_copy = deepcopy(dictionary) for key in distributions: # Get parameter values for dict entry params = ...
[ "def", "set_init_params", "(", "dictionary", ",", "distributions", ",", "seed", "=", "0", ")", ":", "dict_copy", "=", "deepcopy", "(", "dictionary", ")", "for", "key", "in", "distributions", ":", "# Get parameter values for dict entry", "params", "=", "dictionary"...
[ 41, 0 ]
[ 64, 20 ]
python
en
['en', 'error', 'th']
False
remove_initial_data
(apps, schema_editor)
This function does nothing. The below code is commented out together with an explanation of why we don't need to bother reversing any of the initial data
This function does nothing. The below code is commented out together with an explanation of why we don't need to bother reversing any of the initial data
def remove_initial_data(apps, schema_editor): """This function does nothing. The below code is commented out together with an explanation of why we don't need to bother reversing any of the initial data""" pass
[ "def", "remove_initial_data", "(", "apps", ",", "schema_editor", ")", ":", "pass" ]
[ 79, 0 ]
[ 83, 8 ]
python
en
['en', 'en', 'en']
True
check_cs_op
(result, func, cargs)
Checks the status code of a coordinate sequence operation.
Checks the status code of a coordinate sequence operation.
def check_cs_op(result, func, cargs): "Checks the status code of a coordinate sequence operation." if result == 0: raise GEOSException('Could not set value on coordinate sequence') else: return result
[ "def", "check_cs_op", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "result", "==", "0", ":", "raise", "GEOSException", "(", "'Could not set value on coordinate sequence'", ")", "else", ":", "return", "result" ]
[ 9, 0 ]
[ 14, 21 ]
python
en
['en', 'en', 'en']
True
check_cs_get
(result, func, cargs)
Checking the coordinate sequence retrieval.
Checking the coordinate sequence retrieval.
def check_cs_get(result, func, cargs): "Checking the coordinate sequence retrieval." check_cs_op(result, func, cargs) # Object in by reference, return its value. return last_arg_byref(cargs)
[ "def", "check_cs_get", "(", "result", ",", "func", ",", "cargs", ")", ":", "check_cs_op", "(", "result", ",", "func", ",", "cargs", ")", "# Object in by reference, return its value.", "return", "last_arg_byref", "(", "cargs", ")" ]
[ 17, 0 ]
[ 21, 32 ]
python
en
['en', 'en', 'en']
True
AsyncApp.app_func
(self)
trio needs to run a function, so this is it.
trio needs to run a function, so this is it.
async def app_func(self): '''trio needs to run a function, so this is it. ''' async with trio.open_nursery() as nursery: '''In trio you create a nursery, in which you schedule async functions to be run by the nursery simultaneously as tasks. This will run all two me...
[ "async", "def", "app_func", "(", "self", ")", ":", "async", "with", "trio", ".", "open_nursery", "(", ")", "as", "nursery", ":", "'''In trio you create a nursery, in which you schedule async\n functions to be run by the nursery simultaneously as tasks.\n\n Thi...
[ 45, 4 ]
[ 64, 54 ]
python
en
['en', 'en', 'en']
True
AsyncApp.waste_time_freely
(self)
This method is also run by trio and periodically prints something.
This method is also run by trio and periodically prints something.
async def waste_time_freely(self): '''This method is also run by trio and periodically prints something. ''' try: i = 0 while True: if self.root is not None: status = self.root.ids.label.status print('{} on the beach...
[ "async", "def", "waste_time_freely", "(", "self", ")", ":", "try", ":", "i", "=", "0", "while", "True", ":", "if", "self", ".", "root", "is", "not", "None", ":", "status", "=", "self", ".", "root", ".", "ids", ".", "label", ".", "status", "print", ...
[ 66, 4 ]
[ 88, 38 ]
python
en
['en', 'en', 'en']
True
AdHocCommand.passwords_needed_to_start
(self)
Return list of password field names needed to start the job.
Return list of password field names needed to start the job.
def passwords_needed_to_start(self): '''Return list of password field names needed to start the job.''' if self.credential: return self.credential.passwords_needed else: return []
[ "def", "passwords_needed_to_start", "(", "self", ")", ":", "if", "self", ".", "credential", ":", "return", "self", ".", "credential", ".", "passwords_needed", "else", ":", "return", "[", "]" ]
[ 134, 4 ]
[ 139, 21 ]
python
en
['en', 'en', 'en']
True
getmode
(mode)
Gets a mode descriptor for the given mode.
Gets a mode descriptor for the given mode.
def getmode(mode): """Gets a mode descriptor for the given mode.""" global _modes if not _modes: # initialize mode cache from . import Image modes = {} # core modes for m, (basemode, basetype, bands) in Image._MODEINFO.items(): modes[m] = ModeDescriptor(...
[ "def", "getmode", "(", "mode", ")", ":", "global", "_modes", "if", "not", "_modes", ":", "# initialize mode cache", "from", ".", "import", "Image", "modes", "=", "{", "}", "# core modes", "for", "m", ",", "(", "basemode", ",", "basetype", ",", "bands", "...
[ 32, 0 ]
[ 63, 23 ]
python
en
['en', 'gl', 'en']
True
precision_wkt
(geom, prec)
Returns WKT text of the geometry according to the given precision (an integer or a string). If the precision is an integer, then the decimal places of coordinates WKT will be truncated to that number: >>> from django.contrib.gis.geos import Point >>> pnt = Point(5, 23) >>> pnt.wkt 'PO...
Returns WKT text of the geometry according to the given precision (an integer or a string). If the precision is an integer, then the decimal places of coordinates WKT will be truncated to that number:
def precision_wkt(geom, prec): """ Returns WKT text of the geometry according to the given precision (an integer or a string). If the precision is an integer, then the decimal places of coordinates WKT will be truncated to that number: >>> from django.contrib.gis.geos import Point >>> pnt = ...
[ "def", "precision_wkt", "(", "geom", ",", "prec", ")", ":", "warnings", ".", "warn", "(", "\"precision_wkt() is deprecated in favor of the WKTWriter class.\"", ",", "RemovedInDjango20Warning", ",", "stacklevel", "=", "2", ")", "if", "isinstance", "(", "prec", ",", "...
[ 9, 0 ]
[ 65, 55 ]
python
en
['en', 'error', 'th']
False
lookup
(code)
Lookup an error code and return its exception class. Raise `!KeyError` if the code is not found.
Lookup an error code and return its exception class.
def lookup(code): """Lookup an error code and return its exception class. Raise `!KeyError` if the code is not found. """ from psycopg2._psycopg import sqlstate_errors # avoid circular import return sqlstate_errors[code]
[ "def", "lookup", "(", "code", ")", ":", "from", "psycopg2", ".", "_psycopg", "import", "sqlstate_errors", "# avoid circular import", "return", "sqlstate_errors", "[", "code", "]" ]
[ 31, 0 ]
[ 37, 32 ]
python
en
['en', 'en', 'en']
True
SelectableGrid.goto_node
(self, key, last_node, last_node_idx)
This function is used to go to the node by typing the number of the text of the button.
This function is used to go to the node by typing the number of the text of the button.
def goto_node(self, key, last_node, last_node_idx): ''' This function is used to go to the node by typing the number of the text of the button. ''' node, idx = super(SelectableGrid, self).goto_node(key, last_node, last_node_idx) ...
[ "def", "goto_node", "(", "self", ",", "key", ",", "last_node", ",", "last_node_idx", ")", ":", "node", ",", "idx", "=", "super", "(", "SelectableGrid", ",", "self", ")", ".", "goto_node", "(", "key", ",", "last_node", ",", "last_node_idx", ")", "if", "...
[ 31, 4 ]
[ 55, 24 ]
python
en
['en', 'en', 'en']
True
rl_puzzle_for_pk
( pubkey: bytes, rate_amount: uint64, interval_time: uint64, origin_id: bytes32, clawback_pk: bytes, )
Solution to this puzzle must be in format: (1 my_parent_id, my_puzzlehash, my_amount, outgoing_puzzle_hash, outgoing_amount, min_block_time, parent_parent_id, parent_amount, fee) RATE LIMIT LOGIC: M - kale_per_interval N - interval_blocks V - amount being spent MIN_BLOCK_AGE = V / (M /...
Solution to this puzzle must be in format: (1 my_parent_id, my_puzzlehash, my_amount, outgoing_puzzle_hash, outgoing_amount, min_block_time, parent_parent_id, parent_amount, fee) RATE LIMIT LOGIC: M - kale_per_interval N - interval_blocks V - amount being spent MIN_BLOCK_AGE = V / (M /...
def rl_puzzle_for_pk( pubkey: bytes, rate_amount: uint64, interval_time: uint64, origin_id: bytes32, clawback_pk: bytes, ): """ Solution to this puzzle must be in format: (1 my_parent_id, my_puzzlehash, my_amount, outgoing_puzzle_hash, outgoing_amount, min_block_time, parent_parent_...
[ "def", "rl_puzzle_for_pk", "(", "pubkey", ":", "bytes", ",", "rate_amount", ":", "uint64", ",", "interval_time", ":", "uint64", ",", "origin_id", ":", "bytes32", ",", "clawback_pk", ":", "bytes", ",", ")", ":", "MOD", "=", "load_clvm", "(", "\"rl.clvm\"", ...
[ 17, 0 ]
[ 38, 80 ]
python
en
['en', 'error', 'th']
False
solution_for_rl
( my_parent_id: bytes32, my_puzzlehash: bytes32, my_amount: uint64, out_puzzlehash: bytes32, out_amount: uint64, my_parent_parent_id: bytes32, parent_amount: uint64, interval, limit, fee, )
Solution is (1 my_parent_id, my_puzzlehash, my_amount, outgoing_puzzle_hash, outgoing_amount, min_block_time, parent_parent_id, parent_amount, fee) min block time = Math.ceil((new_amount * self.interval) / self.limit)
Solution is (1 my_parent_id, my_puzzlehash, my_amount, outgoing_puzzle_hash, outgoing_amount, min_block_time, parent_parent_id, parent_amount, fee) min block time = Math.ceil((new_amount * self.interval) / self.limit)
def solution_for_rl( my_parent_id: bytes32, my_puzzlehash: bytes32, my_amount: uint64, out_puzzlehash: bytes32, out_amount: uint64, my_parent_parent_id: bytes32, parent_amount: uint64, interval, limit, fee, ): """ Solution is (1 my_parent_id, my_puzzlehash, my_amount, out...
[ "def", "solution_for_rl", "(", "my_parent_id", ":", "bytes32", ",", "my_puzzlehash", ":", "bytes32", ",", "my_amount", ":", "uint64", ",", "out_puzzlehash", ":", "bytes32", ",", "out_amount", ":", "uint64", ",", "my_parent_parent_id", ":", "bytes32", ",", "paren...
[ 82, 0 ]
[ 113, 50 ]
python
en
['en', 'error', 'th']
False
rl_make_aggregation_puzzle
(wallet_puzzle)
If Wallet A wants to send further funds to Wallet B then they can lock them up using this code Solution will be (my_id wallet_coin_primary_input wallet_coin_amount)
If Wallet A wants to send further funds to Wallet B then they can lock them up using this code Solution will be (my_id wallet_coin_primary_input wallet_coin_amount)
def rl_make_aggregation_puzzle(wallet_puzzle): """ If Wallet A wants to send further funds to Wallet B then they can lock them up using this code Solution will be (my_id wallet_coin_primary_input wallet_coin_amount) """ MOD = load_clvm("rl_aggregation.clvm") return MOD.curry(wallet_puzzle)
[ "def", "rl_make_aggregation_puzzle", "(", "wallet_puzzle", ")", ":", "MOD", "=", "load_clvm", "(", "\"rl_aggregation.clvm\"", ")", "return", "MOD", ".", "curry", "(", "wallet_puzzle", ")" ]
[ 116, 0 ]
[ 123, 35 ]
python
en
['en', 'error', 'th']
False
_possibly_make_aware
(dt)
Convert a datetime object in the local timezone to aware in UTC, if USE_TZ is True.
Convert a datetime object in the local timezone to aware in UTC, if USE_TZ is True.
def _possibly_make_aware(dt): """ Convert a datetime object in the local timezone to aware in UTC, if USE_TZ is True. """ # This function is only needed to help with the deprecations above and can # be removed in Django 2.0, RemovedInDjango20Warning. if settings.USE_TZ: tz = timezone...
[ "def", "_possibly_make_aware", "(", "dt", ")", ":", "# This function is only needed to help with the deprecations above and can", "# be removed in Django 2.0, RemovedInDjango20Warning.", "if", "settings", ".", "USE_TZ", ":", "tz", "=", "timezone", ".", "get_default_timezone", "("...
[ 233, 0 ]
[ 244, 17 ]
python
en
['en', 'error', 'th']
False
Storage.open
(self, name, mode='rb')
Retrieves the specified file from storage.
Retrieves the specified file from storage.
def open(self, name, mode='rb'): """ Retrieves the specified file from storage. """ return self._open(name, mode)
[ "def", "open", "(", "self", ",", "name", ",", "mode", "=", "'rb'", ")", ":", "return", "self", ".", "_open", "(", "name", ",", "mode", ")" ]
[ 33, 4 ]
[ 37, 37 ]
python
en
['en', 'error', 'th']
False
Storage.save
(self, name, content, max_length=None)
Saves new content to the file specified by name. The content should be a proper File object or any python file-like object, ready to be read from the beginning.
Saves new content to the file specified by name. The content should be a proper File object or any python file-like object, ready to be read from the beginning.
def save(self, name, content, max_length=None): """ Saves new content to the file specified by name. The content should be a proper File object or any python file-like object, ready to be read from the beginning. """ # Get the proper name for the file, as it will actually...
[ "def", "save", "(", "self", ",", "name", ",", "content", ",", "max_length", "=", "None", ")", ":", "# Get the proper name for the file, as it will actually be saved.", "if", "name", "is", "None", ":", "name", "=", "content", ".", "name", "if", "not", "hasattr", ...
[ 39, 4 ]
[ 53, 40 ]
python
en
['en', 'error', 'th']
False
Storage.get_valid_name
(self, name)
Returns a filename, based on the provided filename, that's suitable for use in the target storage system.
Returns a filename, based on the provided filename, that's suitable for use in the target storage system.
def get_valid_name(self, name): """ Returns a filename, based on the provided filename, that's suitable for use in the target storage system. """ return get_valid_filename(name)
[ "def", "get_valid_name", "(", "self", ",", "name", ")", ":", "return", "get_valid_filename", "(", "name", ")" ]
[ 57, 4 ]
[ 62, 39 ]
python
en
['en', 'error', 'th']
False
Storage.get_available_name
(self, name, max_length=None)
Returns a filename that's free on the target storage system, and available for new content to be written to.
Returns a filename that's free on the target storage system, and available for new content to be written to.
def get_available_name(self, name, max_length=None): """ Returns a filename that's free on the target storage system, and available for new content to be written to. """ dir_name, file_name = os.path.split(name) file_root, file_ext = os.path.splitext(file_name) # ...
[ "def", "get_available_name", "(", "self", ",", "name", ",", "max_length", "=", "None", ")", ":", "dir_name", ",", "file_name", "=", "os", ".", "path", ".", "split", "(", "name", ")", "file_root", ",", "file_ext", "=", "os", ".", "path", ".", "splitext"...
[ 64, 4 ]
[ 93, 19 ]
python
en
['en', 'error', 'th']
False
Storage.generate_filename
(self, filename)
Validate the filename by calling get_valid_name() and return a filename to be passed to the save() method.
Validate the filename by calling get_valid_name() and return a filename to be passed to the save() method.
def generate_filename(self, filename): """ Validate the filename by calling get_valid_name() and return a filename to be passed to the save() method. """ # `filename` may include a path as returned by FileField.upload_to. dirname, filename = os.path.split(filename) ...
[ "def", "generate_filename", "(", "self", ",", "filename", ")", ":", "# `filename` may include a path as returned by FileField.upload_to.", "dirname", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "filename", ")", "return", "os", ".", "path", ".", "no...
[ 95, 4 ]
[ 102, 85 ]
python
en
['en', 'error', 'th']
False
Storage.path
(self, name)
Returns a local filesystem path where the file can be retrieved using Python's built-in open() function. Storage systems that can't be accessed using open() should *not* implement this method.
Returns a local filesystem path where the file can be retrieved using Python's built-in open() function. Storage systems that can't be accessed using open() should *not* implement this method.
def path(self, name): """ Returns a local filesystem path where the file can be retrieved using Python's built-in open() function. Storage systems that can't be accessed using open() should *not* implement this method. """ raise NotImplementedError("This backend doesn't s...
[ "def", "path", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "\"This backend doesn't support absolute paths.\"", ")" ]
[ 104, 4 ]
[ 110, 81 ]
python
en
['en', 'error', 'th']
False
Storage.delete
(self, name)
Deletes the specified file from the storage system.
Deletes the specified file from the storage system.
def delete(self, name): """ Deletes the specified file from the storage system. """ raise NotImplementedError('subclasses of Storage must provide a delete() method')
[ "def", "delete", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a delete() method'", ")" ]
[ 115, 4 ]
[ 119, 89 ]
python
en
['en', 'error', 'th']
False
Storage.exists
(self, name)
Returns True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file.
Returns True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file.
def exists(self, name): """ Returns True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file. """ raise NotImplementedError('subclasses of Storage must provide an exists() method')
[ "def", "exists", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide an exists() method'", ")" ]
[ 121, 4 ]
[ 126, 90 ]
python
en
['en', 'error', 'th']
False
Storage.listdir
(self, path)
Lists the contents of the specified path, returning a 2-tuple of lists; the first item being directories, the second item being files.
Lists the contents of the specified path, returning a 2-tuple of lists; the first item being directories, the second item being files.
def listdir(self, path): """ Lists the contents of the specified path, returning a 2-tuple of lists; the first item being directories, the second item being files. """ raise NotImplementedError('subclasses of Storage must provide a listdir() method')
[ "def", "listdir", "(", "self", ",", "path", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a listdir() method'", ")" ]
[ 128, 4 ]
[ 133, 90 ]
python
en
['en', 'error', 'th']
False
Storage.size
(self, name)
Returns the total size, in bytes, of the file specified by name.
Returns the total size, in bytes, of the file specified by name.
def size(self, name): """ Returns the total size, in bytes, of the file specified by name. """ raise NotImplementedError('subclasses of Storage must provide a size() method')
[ "def", "size", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a size() method'", ")" ]
[ 135, 4 ]
[ 139, 87 ]
python
en
['en', 'error', 'th']
False
Storage.url
(self, name)
Returns an absolute URL where the file's contents can be accessed directly by a Web browser.
Returns an absolute URL where the file's contents can be accessed directly by a Web browser.
def url(self, name): """ Returns an absolute URL where the file's contents can be accessed directly by a Web browser. """ raise NotImplementedError('subclasses of Storage must provide a url() method')
[ "def", "url", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a url() method'", ")" ]
[ 141, 4 ]
[ 146, 86 ]
python
en
['en', 'error', 'th']
False
Storage.accessed_time
(self, name)
Returns the last accessed time (as datetime object) of the file specified by name. Deprecated: use get_accessed_time() instead.
Returns the last accessed time (as datetime object) of the file specified by name. Deprecated: use get_accessed_time() instead.
def accessed_time(self, name): """ Returns the last accessed time (as datetime object) of the file specified by name. Deprecated: use get_accessed_time() instead. """ warnings.warn( 'Storage.accessed_time() is deprecated in favor of get_accessed_time().', ...
[ "def", "accessed_time", "(", "self", ",", "name", ")", ":", "warnings", ".", "warn", "(", "'Storage.accessed_time() is deprecated in favor of get_accessed_time().'", ",", "RemovedInDjango20Warning", ",", "stacklevel", "=", "2", ",", ")", "raise", "NotImplementedError", ...
[ 148, 4 ]
[ 158, 97 ]
python
en
['en', 'error', 'th']
False
Storage.created_time
(self, name)
Returns the creation time (as datetime object) of the file specified by name. Deprecated: use get_created_time() instead.
Returns the creation time (as datetime object) of the file specified by name. Deprecated: use get_created_time() instead.
def created_time(self, name): """ Returns the creation time (as datetime object) of the file specified by name. Deprecated: use get_created_time() instead. """ warnings.warn( 'Storage.created_time() is deprecated in favor of get_created_time().', RemovedIn...
[ "def", "created_time", "(", "self", ",", "name", ")", ":", "warnings", ".", "warn", "(", "'Storage.created_time() is deprecated in favor of get_created_time().'", ",", "RemovedInDjango20Warning", ",", "stacklevel", "=", "2", ",", ")", "raise", "NotImplementedError", "("...
[ 160, 4 ]
[ 170, 95 ]
python
en
['en', 'error', 'th']
False
Storage.modified_time
(self, name)
Returns the last modified time (as datetime object) of the file specified by name. Deprecated: use get_modified_time() instead.
Returns the last modified time (as datetime object) of the file specified by name. Deprecated: use get_modified_time() instead.
def modified_time(self, name): """ Returns the last modified time (as datetime object) of the file specified by name. Deprecated: use get_modified_time() instead. """ warnings.warn( 'Storage.modified_time() is deprecated in favor of get_modified_time().', ...
[ "def", "modified_time", "(", "self", ",", "name", ")", ":", "warnings", ".", "warn", "(", "'Storage.modified_time() is deprecated in favor of get_modified_time().'", ",", "RemovedInDjango20Warning", ",", "stacklevel", "=", "2", ",", ")", "raise", "NotImplementedError", ...
[ 172, 4 ]
[ 182, 96 ]
python
en
['en', 'error', 'th']
False
Storage.get_accessed_time
(self, name)
Return the last accessed time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
Return the last accessed time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
def get_accessed_time(self, name): """ Return the last accessed time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True. """ # At the end of the deprecation: # raise NotImplementedError('subclasses of Storage must provide a g...
[ "def", "get_accessed_time", "(", "self", ",", "name", ")", ":", "# At the end of the deprecation:", "# raise NotImplementedError('subclasses of Storage must provide a get_accessed_time() method')", "warnings", ".", "warn", "(", "'Storage.accessed_time() is deprecated. '", "'Storage bac...
[ 184, 4 ]
[ 198, 39 ]
python
en
['en', 'error', 'th']
False
Storage.get_created_time
(self, name)
Return the creation time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
Return the creation time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
def get_created_time(self, name): """ Return the creation time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True. """ # At the end of the deprecation: # raise NotImplementedError('subclasses of Storage must provide a get_cre...
[ "def", "get_created_time", "(", "self", ",", "name", ")", ":", "# At the end of the deprecation:", "# raise NotImplementedError('subclasses of Storage must provide a get_created_time() method')", "warnings", ".", "warn", "(", "'Storage.created_time() is deprecated. '", "'Storage backen...
[ 200, 4 ]
[ 214, 39 ]
python
en
['en', 'error', 'th']
False
Storage.get_modified_time
(self, name)
Return the last modified time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
Return the last modified time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
def get_modified_time(self, name): """ Return the last modified time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True. """ # At the end of the deprecation: # raise NotImplementedError('subclasses of Storage must provide a g...
[ "def", "get_modified_time", "(", "self", ",", "name", ")", ":", "# At the end of the deprecation:", "# raise NotImplementedError('subclasses of Storage must provide a get_modified_time() method')", "warnings", ".", "warn", "(", "'Storage.modified_time() is deprecated. '", "'Storage bac...
[ 216, 4 ]
[ 230, 39 ]
python
en
['en', 'error', 'th']
False
task_flake8
()
Run flake8 check.
Run flake8 check.
def task_flake8(): """Run flake8 check.""" return { 'actions': ['flake8 setup.py pyppeteer tests'], }
[ "def", "task_flake8", "(", ")", ":", "return", "{", "'actions'", ":", "[", "'flake8 setup.py pyppeteer tests'", "]", ",", "}" ]
[ 20, 0 ]
[ 24, 5 ]
python
en
['it', 'fil', 'en']
False
task_mypy
()
Run mypy check.
Run mypy check.
def task_mypy(): """Run mypy check.""" return { 'actions': ['mypy pyppeteer'], }
[ "def", "task_mypy", "(", ")", ":", "return", "{", "'actions'", ":", "[", "'mypy pyppeteer'", "]", ",", "}" ]
[ 27, 0 ]
[ 31, 5 ]
python
en
['it', 'kk', 'en']
False
task_pydocstyle
()
Run docstyle check.
Run docstyle check.
def task_pydocstyle(): """Run docstyle check.""" return { 'actions': ['pydocstyle pyppeteer'], }
[ "def", "task_pydocstyle", "(", ")", ":", "return", "{", "'actions'", ":", "[", "'pydocstyle pyppeteer'", "]", ",", "}" ]
[ 34, 0 ]
[ 38, 5 ]
python
en
['fr', 'en', 'en']
True
task_docs
()
Build sphinx document.
Build sphinx document.
def task_docs(): """Build sphinx document.""" return { 'actions': [ 'sphinx-build -q -W -E -j auto -b html docs docs/_build/html', ], }
[ "def", "task_docs", "(", ")", ":", "return", "{", "'actions'", ":", "[", "'sphinx-build -q -W -E -j auto -b html docs docs/_build/html'", ",", "]", ",", "}" ]
[ 41, 0 ]
[ 47, 5 ]
python
en
['en', 'sr', 'en']
True
task_readme
()
Check long description for package.
Check long description for package.
def task_readme(): """Check long description for package.""" return { 'actions': ['python setup.py check -r -s'], }
[ "def", "task_readme", "(", ")", ":", "return", "{", "'actions'", ":", "[", "'python setup.py check -r -s'", "]", ",", "}" ]
[ 50, 0 ]
[ 54, 5 ]
python
en
['de', 'en', 'en']
True
task_spell
()
Check spelling of comments and docstrings.
Check spelling of comments and docstrings.
def task_spell(): """Check spelling of comments and docstrings.""" return { 'actions': [ 'pylint --disable all --enable spelling --spelling-dict en_US ' '--spelling-private-dict-file spell.txt pyppeteer' ], }
[ "def", "task_spell", "(", ")", ":", "return", "{", "'actions'", ":", "[", "'pylint --disable all --enable spelling --spelling-dict en_US '", "'--spelling-private-dict-file spell.txt pyppeteer'", "]", ",", "}" ]
[ 57, 0 ]
[ 64, 5 ]
python
en
['en', 'en', 'en']
True
task_check
()
Run flake8/mypy/pydocstyle/docs/readme tasks.
Run flake8/mypy/pydocstyle/docs/readme tasks.
def task_check(): """Run flake8/mypy/pydocstyle/docs/readme tasks.""" return { 'actions': None, 'task_dep': ['flake8', 'mypy', 'pydocstyle', 'docs', 'readme'] }
[ "def", "task_check", "(", ")", ":", "return", "{", "'actions'", ":", "None", ",", "'task_dep'", ":", "[", "'flake8'", ",", "'mypy'", ",", "'pydocstyle'", ",", "'docs'", ",", "'readme'", "]", "}" ]
[ 67, 0 ]
[ 72, 5 ]
python
en
['mt', 'hu', 'en']
False
task_test
()
Run pytest.
Run pytest.
def task_test(): """Run pytest.""" return { 'actions': [CmdAction( 'pytest -n {}'.format(cores // 2), buffering=1, )], 'verbosity': 2, }
[ "def", "task_test", "(", ")", ":", "return", "{", "'actions'", ":", "[", "CmdAction", "(", "'pytest -n {}'", ".", "format", "(", "cores", "//", "2", ")", ",", "buffering", "=", "1", ",", ")", "]", ",", "'verbosity'", ":", "2", ",", "}" ]
[ 75, 0 ]
[ 83, 5 ]
python
en
['fr', 'is', 'en']
False
task_all
()
Run all tests and checks.
Run all tests and checks.
def task_all(): """Run all tests and checks.""" return { 'actions': None, 'task_dep': ['test', 'check'], }
[ "def", "task_all", "(", ")", ":", "return", "{", "'actions'", ":", "None", ",", "'task_dep'", ":", "[", "'test'", ",", "'check'", "]", ",", "}" ]
[ 86, 0 ]
[ 91, 5 ]
python
en
['en', 'en', 'en']
True
spew
(trace_names=None, show_values=False)
Install a trace hook which writes incredibly detailed logs about what code is being executed to stdout.
Install a trace hook which writes incredibly detailed logs about what code is being executed to stdout.
def spew(trace_names=None, show_values=False): """Install a trace hook which writes incredibly detailed logs about what code is being executed to stdout. """ sys.settrace(Spew(trace_names, show_values))
[ "def", "spew", "(", "trace_names", "=", "None", ",", "show_values", "=", "False", ")", ":", "sys", ".", "settrace", "(", "Spew", "(", "trace_names", ",", "show_values", ")", ")" ]
[ 58, 0 ]
[ 62, 48 ]
python
en
['en', 'en', 'en']
True
unspew
()
Remove the trace hook installed by spew.
Remove the trace hook installed by spew.
def unspew(): """Remove the trace hook installed by spew. """ sys.settrace(None)
[ "def", "unspew", "(", ")", ":", "sys", ".", "settrace", "(", "None", ")" ]
[ 65, 0 ]
[ 68, 22 ]
python
en
['en', 'en', 'en']
True
TestSequenceFunctions._ExpectedWarnings
(self, expected)
Compares recorded lines to expected warnings.
Compares recorded lines to expected warnings.
def _ExpectedWarnings(self, expected): """Compares recorded lines to expected warnings.""" self.stderr.seek(0) actual = self.stderr.read().split("\n") actual = [line for line in actual if line] self.assertEqual(sorted(expected), sorted(actual))
[ "def", "_ExpectedWarnings", "(", "self", ",", "expected", ")", ":", "self", ".", "stderr", ".", "seek", "(", "0", ")", "actual", "=", "self", ".", "stderr", ".", "read", "(", ")", ".", "split", "(", "\"\\n\"", ")", "actual", "=", "[", "line", "for"...
[ 21, 4 ]
[ 26, 58 ]
python
en
['en', 'en', 'en']
True
TestSequenceFunctions.testValidateMSVSSettings_tool_names
(self)
Tests that only MSVS tool names are allowed.
Tests that only MSVS tool names are allowed.
def testValidateMSVSSettings_tool_names(self): """Tests that only MSVS tool names are allowed.""" MSVSSettings.ValidateMSVSSettings( { "VCCLCompilerTool": {}, "VCLinkerTool": {}, "VCMIDLTool": {}, "foo": {}, "VCR...
[ "def", "testValidateMSVSSettings_tool_names", "(", "self", ")", ":", "MSVSSettings", ".", "ValidateMSVSSettings", "(", "{", "\"VCCLCompilerTool\"", ":", "{", "}", ",", "\"VCLinkerTool\"", ":", "{", "}", ",", "\"VCMIDLTool\"", ":", "{", "}", ",", "\"foo\"", ":", ...
[ 28, 4 ]
[ 45, 9 ]
python
en
['en', 'en', 'en']
True
TestSequenceFunctions.testValidateMSVSSettings_settings
(self)
Tests that for invalid MSVS settings.
Tests that for invalid MSVS settings.
def testValidateMSVSSettings_settings(self): """Tests that for invalid MSVS settings.""" MSVSSettings.ValidateMSVSSettings( { "VCCLCompilerTool": { "AdditionalIncludeDirectories": "folder1;folder2", "AdditionalOptions": ["string1", "str...
[ "def", "testValidateMSVSSettings_settings", "(", "self", ")", ":", "MSVSSettings", ".", "ValidateMSVSSettings", "(", "{", "\"VCCLCompilerTool\"", ":", "{", "\"AdditionalIncludeDirectories\"", ":", "\"folder1;folder2\"", ",", "\"AdditionalOptions\"", ":", "[", "\"string1\"",...
[ 47, 4 ]
[ 298, 9 ]
python
en
['en', 'en', 'en']
True
TestSequenceFunctions.testValidateMSBuildSettings_settings
(self)
Tests that for invalid MSBuild settings.
Tests that for invalid MSBuild settings.
def testValidateMSBuildSettings_settings(self): """Tests that for invalid MSBuild settings.""" MSVSSettings.ValidateMSBuildSettings( { "ClCompile": { "AdditionalIncludeDirectories": "folder1;folder2", "AdditionalOptions": ["string1", "s...
[ "def", "testValidateMSBuildSettings_settings", "(", "self", ")", ":", "MSVSSettings", ".", "ValidateMSBuildSettings", "(", "{", "\"ClCompile\"", ":", "{", "\"AdditionalIncludeDirectories\"", ":", "\"folder1;folder2\"", ",", "\"AdditionalOptions\"", ":", "[", "\"string1\"", ...
[ 300, 4 ]
[ 589, 9 ]
python
en
['en', 'en', 'en']
True
TestSequenceFunctions.testConvertToMSBuildSettings_empty
(self)
Tests an empty conversion.
Tests an empty conversion.
def testConvertToMSBuildSettings_empty(self): """Tests an empty conversion.""" msvs_settings = {} expected_msbuild_settings = {} actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings( msvs_settings, self.stderr ) self.assertEqual(expected_msbuild_set...
[ "def", "testConvertToMSBuildSettings_empty", "(", "self", ")", ":", "msvs_settings", "=", "{", "}", "expected_msbuild_settings", "=", "{", "}", "actual_msbuild_settings", "=", "MSVSSettings", ".", "ConvertToMSBuildSettings", "(", "msvs_settings", ",", "self", ".", "st...
[ 591, 4 ]
[ 599, 34 ]
python
en
['en', 'en', 'en']
True
TestSequenceFunctions.testConvertToMSBuildSettings_minimal
(self)
Tests a minimal conversion.
Tests a minimal conversion.
def testConvertToMSBuildSettings_minimal(self): """Tests a minimal conversion.""" msvs_settings = { "VCCLCompilerTool": { "AdditionalIncludeDirectories": "dir1", "AdditionalOptions": "/foo", "BasicRuntimeChecks": "0", }, ...
[ "def", "testConvertToMSBuildSettings_minimal", "(", "self", ")", ":", "msvs_settings", "=", "{", "\"VCCLCompilerTool\"", ":", "{", "\"AdditionalIncludeDirectories\"", ":", "\"dir1\"", ",", "\"AdditionalOptions\"", ":", "\"/foo\"", ",", "\"BasicRuntimeChecks\"", ":", "\"0\...
[ 601, 4 ]
[ 631, 34 ]
python
en
['en', 'en', 'en']
True
TestSequenceFunctions.testConvertToMSBuildSettings_warnings
(self)
Tests conversion that generates warnings.
Tests conversion that generates warnings.
def testConvertToMSBuildSettings_warnings(self): """Tests conversion that generates warnings.""" msvs_settings = { "VCCLCompilerTool": { "AdditionalIncludeDirectories": "1", "AdditionalOptions": "2", # These are incorrect values: ...
[ "def", "testConvertToMSBuildSettings_warnings", "(", "self", ")", ":", "msvs_settings", "=", "{", "\"VCCLCompilerTool\"", ":", "{", "\"AdditionalIncludeDirectories\"", ":", "\"1\"", ",", "\"AdditionalOptions\"", ":", "\"2\"", ",", "# These are incorrect values:", "\"BasicRu...
[ 633, 4 ]
[ 692, 9 ]
python
en
['en', 'jv', 'en']
True
TestSequenceFunctions.testConvertToMSBuildSettings_full_synthetic
(self)
Tests conversion of all the MSBuild settings.
Tests conversion of all the MSBuild settings.
def testConvertToMSBuildSettings_full_synthetic(self): """Tests conversion of all the MSBuild settings.""" msvs_settings = { "VCCLCompilerTool": { "AdditionalIncludeDirectories": "folder1;folder2;folder3", "AdditionalOptions": "a_string", "Addi...
[ "def", "testConvertToMSBuildSettings_full_synthetic", "(", "self", ")", ":", "msvs_settings", "=", "{", "\"VCCLCompilerTool\"", ":", "{", "\"AdditionalIncludeDirectories\"", ":", "\"folder1;folder2;folder3\"", ",", "\"AdditionalOptions\"", ":", "\"a_string\"", ",", "\"Additio...
[ 694, 4 ]
[ 1143, 34 ]
python
en
['en', 'en', 'en']
True
TestSequenceFunctions.testConvertToMSBuildSettings_actual
(self)
Tests the conversion of an actual project. A VS2008 project with most of the options defined was created through the VS2008 IDE. It was then converted to VS2010. The tool settings found in the .vcproj and .vcxproj files were converted to the two dictionaries msvs_settings and expected_msbuild_setting...
Tests the conversion of an actual project.
def testConvertToMSBuildSettings_actual(self): """Tests the conversion of an actual project. A VS2008 project with most of the options defined was created through the VS2008 IDE. It was then converted to VS2010. The tool settings found in the .vcproj and .vcxproj files were converted to the two d...
[ "def", "testConvertToMSBuildSettings_actual", "(", "self", ")", ":", "msvs_settings", "=", "{", "\"VCCLCompilerTool\"", ":", "{", "\"AdditionalIncludeDirectories\"", ":", "\"dir1\"", ",", "\"AdditionalOptions\"", ":", "\"/more\"", ",", "\"AdditionalUsingDirectories\"", ":",...
[ 1145, 4 ]
[ 1545, 34 ]
python
en
['en', 'en', 'en']
True
smart_text
(s, encoding='utf-8', strings_only=False, errors='strict')
Returns a text object representing 's' -- unicode on Python 2 and str on Python 3. Treats bytestrings using the 'encoding' codec. If strings_only is True, don't convert (some) non-string-like objects.
Returns a text object representing 's' -- unicode on Python 2 and str on Python 3. Treats bytestrings using the 'encoding' codec.
def smart_text(s, encoding='utf-8', strings_only=False, errors='strict'): """ Returns a text object representing 's' -- unicode on Python 2 and str on Python 3. Treats bytestrings using the 'encoding' codec. If strings_only is True, don't convert (some) non-string-like objects. """ if isinstanc...
[ "def", "smart_text", "(", "s", ",", "encoding", "=", "'utf-8'", ",", "strings_only", "=", "False", ",", "errors", "=", "'strict'", ")", ":", "if", "isinstance", "(", "s", ",", "Promise", ")", ":", "# The input is the result of a gettext_lazy() call.", "return", ...
[ 30, 0 ]
[ 40, 56 ]
python
en
['en', 'error', 'th']
False
is_protected_type
(obj)
Determine if the object instance is of a protected type. Objects of protected types are preserved as-is when passed to force_text(strings_only=True).
Determine if the object instance is of a protected type.
def is_protected_type(obj): """Determine if the object instance is of a protected type. Objects of protected types are preserved as-is when passed to force_text(strings_only=True). """ return isinstance(obj, _PROTECTED_TYPES)
[ "def", "is_protected_type", "(", "obj", ")", ":", "return", "isinstance", "(", "obj", ",", "_PROTECTED_TYPES", ")" ]
[ 48, 0 ]
[ 54, 44 ]
python
en
['en', 'en', 'en']
True
force_text
(s, encoding='utf-8', strings_only=False, errors='strict')
Similar to smart_text, except that lazy instances are resolved to strings, rather than kept as lazy objects. If strings_only is True, don't convert (some) non-string-like objects.
Similar to smart_text, except that lazy instances are resolved to strings, rather than kept as lazy objects.
def force_text(s, encoding='utf-8', strings_only=False, errors='strict'): """ Similar to smart_text, except that lazy instances are resolved to strings, rather than kept as lazy objects. If strings_only is True, don't convert (some) non-string-like objects. """ # Handle the common case first fo...
[ "def", "force_text", "(", "s", ",", "encoding", "=", "'utf-8'", ",", "strings_only", "=", "False", ",", "errors", "=", "'strict'", ")", ":", "# Handle the common case first for performance reasons.", "if", "issubclass", "(", "type", "(", "s", ")", ",", "six", ...
[ 57, 0 ]
[ 96, 12 ]
python
en
['en', 'error', 'th']
False
smart_bytes
(s, encoding='utf-8', strings_only=False, errors='strict')
Returns a bytestring version of 's', encoded as specified in 'encoding'. If strings_only is True, don't convert (some) non-string-like objects.
Returns a bytestring version of 's', encoded as specified in 'encoding'.
def smart_bytes(s, encoding='utf-8', strings_only=False, errors='strict'): """ Returns a bytestring version of 's', encoded as specified in 'encoding'. If strings_only is True, don't convert (some) non-string-like objects. """ if isinstance(s, Promise): # The input is the result of a gettex...
[ "def", "smart_bytes", "(", "s", ",", "encoding", "=", "'utf-8'", ",", "strings_only", "=", "False", ",", "errors", "=", "'strict'", ")", ":", "if", "isinstance", "(", "s", ",", "Promise", ")", ":", "# The input is the result of a gettext_lazy() call.", "return",...
[ 99, 0 ]
[ 108, 57 ]
python
en
['en', 'error', 'th']
False
force_bytes
(s, encoding='utf-8', strings_only=False, errors='strict')
Similar to smart_bytes, except that lazy instances are resolved to strings, rather than kept as lazy objects. If strings_only is True, don't convert (some) non-string-like objects.
Similar to smart_bytes, except that lazy instances are resolved to strings, rather than kept as lazy objects.
def force_bytes(s, encoding='utf-8', strings_only=False, errors='strict'): """ Similar to smart_bytes, except that lazy instances are resolved to strings, rather than kept as lazy objects. If strings_only is True, don't convert (some) non-string-like objects. """ # Handle the common case first ...
[ "def", "force_bytes", "(", "s", ",", "encoding", "=", "'utf-8'", ",", "strings_only", "=", "False", ",", "errors", "=", "'strict'", ")", ":", "# Handle the common case first for performance reasons.", "if", "isinstance", "(", "s", ",", "bytes", ")", ":", "if", ...
[ 111, 0 ]
[ 145, 41 ]
python
en
['en', 'error', 'th']
False