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
Command.link_file
(self, path, prefixed_path, source_storage)
Attempt to link ``path``
Attempt to link ``path``
def link_file(self, path, prefixed_path, source_storage): """ Attempt to link ``path`` """ # Skip this file if it was already copied earlier if prefixed_path in self.symlinked_files: return self.log("Skipping '%s' (already linked earlier)" % path) # Delete the...
[ "def", "link_file", "(", "self", ",", "path", ",", "prefixed_path", ",", "source_storage", ")", ":", "# Skip this file if it was already copied earlier", "if", "prefixed_path", "in", "self", ".", "symlinked_files", ":", "return", "self", ".", "log", "(", "\"Skipping...
[ 293, 4 ]
[ 327, 54 ]
python
en
['en', 'error', 'th']
False
Command.copy_file
(self, path, prefixed_path, source_storage)
Attempt to copy ``path`` with storage
Attempt to copy ``path`` with storage
def copy_file(self, path, prefixed_path, source_storage): """ Attempt to copy ``path`` with storage """ # Skip this file if it was already copied earlier if prefixed_path in self.copied_files: return self.log("Skipping '%s' (already copied earlier)" % path) # ...
[ "def", "copy_file", "(", "self", ",", "path", ",", "prefixed_path", ",", "source_storage", ")", ":", "# Skip this file if it was already copied earlier", "if", "prefixed_path", "in", "self", ".", "copied_files", ":", "return", "self", ".", "log", "(", "\"Skipping '%...
[ 329, 4 ]
[ 348, 47 ]
python
en
['en', 'error', 'th']
False
FindCalendarItemsRequest.__init__
(self, principal, start_date, end_date)
Initialize the request. start_date and end_date should be kept sanely close to each other to avoid EWS erroring out. :param principal: The principal email whose calendar to query. :param start_date: Start date for the query :param end_date: End date for the query
Initialize the request.
def __init__(self, principal, start_date, end_date): """ Initialize the request. start_date and end_date should be kept sanely close to each other to avoid EWS erroring out. :param principal: The principal email whose calendar to query. :param start_date: Start date for the que...
[ "def", "__init__", "(", "self", ",", "principal", ",", "start_date", ",", "end_date", ")", ":", "body", "=", "M", ".", "FindItem", "(", "{", "'Traversal'", ":", "'Shallow'", "}", ",", "M", ".", "ItemShape", "(", "T", ".", "BaseShape", "(", "'AllPropert...
[ 12, 4 ]
[ 34, 55 ]
python
en
['en', 'error', 'th']
False
FindCalendarItemsRequest.send
(self, sess)
Send the calendar item request, and return a list of CalendarItem XML elements. :type sess: respa_exchange.session.ExchangeSession :rtype: list[lxml.etree.Element]
Send the calendar item request, and return a list of CalendarItem XML elements.
def send(self, sess): """ Send the calendar item request, and return a list of CalendarItem XML elements. :type sess: respa_exchange.session.ExchangeSession :rtype: list[lxml.etree.Element] """ resp = sess.soap(self) return resp.xpath("//t:CalendarItem", namespac...
[ "def", "send", "(", "self", ",", "sess", ")", ":", "resp", "=", "sess", ".", "soap", "(", "self", ")", "return", "resp", ".", "xpath", "(", "\"//t:CalendarItem\"", ",", "namespaces", "=", "NAMESPACES", ")" ]
[ 36, 4 ]
[ 44, 68 ]
python
en
['en', 'error', 'th']
False
GetCalendarItemsRequest.__init__
(self, principal, item_ids)
Initialize the request. :param principal: The principal email whose calendar to query. :param item_ids: Item IDs for the requested calendar items.
Initialize the request.
def __init__(self, principal, item_ids): """ Initialize the request. :param principal: The principal email whose calendar to query. :param item_ids: Item IDs for the requested calendar items. """ body = M.GetItem( M.ItemShape( T.BaseShape("Al...
[ "def", "__init__", "(", "self", ",", "principal", ",", "item_ids", ")", ":", "body", "=", "M", ".", "GetItem", "(", "M", ".", "ItemShape", "(", "T", ".", "BaseShape", "(", "\"AllProperties\"", ")", ",", "T", ".", "BodyType", "(", "\"HTML\"", ")", ","...
[ 52, 4 ]
[ 67, 55 ]
python
en
['en', 'error', 'th']
False
GetCalendarItemsRequest.send
(self, sess)
Send the calendar item request, and return a list of CalendarItem XML elements. :type sess: respa_exchange.session.ExchangeSession :rtype: list[lxml.etree.Element]
Send the calendar item request, and return a list of CalendarItem XML elements.
def send(self, sess): """ Send the calendar item request, and return a list of CalendarItem XML elements. :type sess: respa_exchange.session.ExchangeSession :rtype: list[lxml.etree.Element] """ resp = sess.soap(self) return resp.xpath("//t:CalendarItem", namespac...
[ "def", "send", "(", "self", ",", "sess", ")", ":", "resp", "=", "sess", ".", "soap", "(", "self", ")", "return", "resp", ".", "xpath", "(", "\"//t:CalendarItem\"", ",", "namespaces", "=", "NAMESPACES", ")" ]
[ 69, 4 ]
[ 77, 68 ]
python
en
['en', 'error', 'th']
False
BaseCalendarItemRequest._convert_props
( self, props, add_defaults=False, )
Convert a calendar property bag to an iterable of (field_uri, Node) tuples. None values in props are ignored. :type props: dict[str, object] :rtype: Iterable[tuple[str, object]]
Convert a calendar property bag to an iterable of (field_uri, Node) tuples.
def _convert_props( self, props, add_defaults=False, ): """ Convert a calendar property bag to an iterable of (field_uri, Node) tuples. None values in props are ignored. :type props: dict[str, object] :rtype: Iterable[tuple[str, object]] """ ...
[ "def", "_convert_props", "(", "self", ",", "props", ",", "add_defaults", "=", "False", ",", ")", ":", "if", "add_defaults", ":", "props", "=", "dict", "(", "self", ".", "PROP_DEFAULTS", ",", "*", "*", "props", ")", "for", "key", ",", "(", "field_uri", ...
[ 103, 4 ]
[ 122, 47 ]
python
en
['en', 'error', 'th']
False
BaseCalendarItemRequest.send
(self, sess)
Send the item manipulation request and return the Item ID object (for further manipulation) :type sess: respa_exchange.session.ExchangeSession :rtype: ItemID
Send the item manipulation request and return the Item ID object (for further manipulation)
def send(self, sess): """ Send the item manipulation request and return the Item ID object (for further manipulation) :type sess: respa_exchange.session.ExchangeSession :rtype: ItemID """ return ItemID.from_tree(sess.soap(self))
[ "def", "send", "(", "self", ",", "sess", ")", ":", "return", "ItemID", ".", "from_tree", "(", "sess", ".", "soap", "(", "self", ")", ")" ]
[ 124, 4 ]
[ 131, 48 ]
python
en
['en', 'error', 'th']
False
CreateCalendarItemRequest.__init__
( self, principal, item_props, send_notifications=True, )
Initialize the request. :param principal: Principal email to impersonate :type principal: str :param item_props: Dict of calendar item properties :type item_props: dict[str, object]
Initialize the request.
def __init__( self, principal, item_props, send_notifications=True, ): """ Initialize the request. :param principal: Principal email to impersonate :type principal: str :param item_props: Dict of calendar item properties :type item_pro...
[ "def", "__init__", "(", "self", ",", "principal", ",", "item_props", ",", "send_notifications", "=", "True", ",", ")", ":", "# See http://msdn.microsoft.com/en-us/library/aa564690(v=exchg.140).aspx", "fields", "=", "[", "node", "for", "(", "field_id", ",", "node", "...
[ 139, 4 ]
[ 170, 91 ]
python
en
['en', 'error', 'th']
False
UpdateCalendarItemRequest.__init__
( self, principal, item_id, update_props, send_notifications=True, )
Initialize the request. :param principal: Principal email to impersonate :type principal: str :param item_id: Item ID object :type item_id: respa_exchange.objs.ItemID :param update_props: Dict of properties to update :type update_props: dict[str, object] ...
Initialize the request.
def __init__( self, principal, item_id, update_props, send_notifications=True, ): """ Initialize the request. :param principal: Principal email to impersonate :type principal: str :param item_id: Item ID object :type item_id: r...
[ "def", "__init__", "(", "self", ",", "principal", ",", "item_id", ",", "update_props", ",", "send_notifications", "=", "True", ",", ")", ":", "updates", "=", "[", "]", "for", "field_uri", ",", "node", "in", "self", ".", "_convert_props", "(", "update_props...
[ 178, 4 ]
[ 220, 86 ]
python
en
['en', 'error', 'th']
False
DeleteCalendarItemRequest.__init__
( self, principal, item_id, send_notifications=True, )
Initialize the request. :param principal: Principal email to impersonate :param item_id: Item ID object :type item_id: respa_exchange.objs.ItemID
Initialize the request.
def __init__( self, principal, item_id, send_notifications=True, ): """ Initialize the request. :param principal: Principal email to impersonate :param item_id: Item ID object :type item_id: respa_exchange.objs.ItemID """ if se...
[ "def", "__init__", "(", "self", ",", "principal", ",", "item_id", ",", "send_notifications", "=", "True", ",", ")", ":", "if", "send_notifications", ":", "send_notifications_string", "=", "\"SendToAllAndSaveCopy\"", "else", ":", "send_notifications_string", "=", "\"...
[ 228, 4 ]
[ 251, 86 ]
python
en
['en', 'error', 'th']
False
DeleteCalendarItemRequest.send
(self, sess)
Send the deletion request. :type sess: respa_exchange.session.ExchangeSession :return: True if the deletion was successful
Send the deletion request.
def send(self, sess): """ Send the deletion request. :type sess: respa_exchange.session.ExchangeSession :return: True if the deletion was successful """ resp = sess.soap(self) dirm = resp.find("*//m:DeleteItemResponseMessage", namespaces=NAMESPACES) retur...
[ "def", "send", "(", "self", ",", "sess", ")", ":", "resp", "=", "sess", ".", "soap", "(", "self", ")", "dirm", "=", "resp", ".", "find", "(", "\"*//m:DeleteItemResponseMessage\"", ",", "namespaces", "=", "NAMESPACES", ")", "return", "dirm", ".", "attrib"...
[ 253, 4 ]
[ 262, 56 ]
python
en
['en', 'error', 'th']
False
timesince
(d, now=None, reversed=False, time_strings=None)
Take two datetime objects and return the time between d and now as a nicely formatted string, e.g. "10 minutes". If d occurs after now, return "0 minutes". Units used are years, months, weeks, days, hours, and minutes. Seconds and microseconds are ignored. Up to two adjacent units will be dis...
Take two datetime objects and return the time between d and now as a nicely formatted string, e.g. "10 minutes". If d occurs after now, return "0 minutes".
def timesince(d, now=None, reversed=False, time_strings=None): """ Take two datetime objects and return the time between d and now as a nicely formatted string, e.g. "10 minutes". If d occurs after now, return "0 minutes". Units used are years, months, weeks, days, hours, and minutes. Seconds a...
[ "def", "timesince", "(", "d", ",", "now", "=", "None", ",", "reversed", "=", "False", ",", "time_strings", "=", "None", ")", ":", "if", "time_strings", "is", "None", ":", "time_strings", "=", "TIME_STRINGS", "# Convert datetime.date to datetime.datetime for compar...
[ 26, 0 ]
[ 83, 17 ]
python
en
['en', 'error', 'th']
False
timeuntil
(d, now=None, time_strings=None)
Like timesince, but return a string measuring the time until the given time.
Like timesince, but return a string measuring the time until the given time.
def timeuntil(d, now=None, time_strings=None): """ Like timesince, but return a string measuring the time until the given time. """ return timesince(d, now, reversed=True, time_strings=time_strings)
[ "def", "timeuntil", "(", "d", ",", "now", "=", "None", ",", "time_strings", "=", "None", ")", ":", "return", "timesince", "(", "d", ",", "now", ",", "reversed", "=", "True", ",", "time_strings", "=", "time_strings", ")" ]
[ 86, 0 ]
[ 90, 70 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.extract_api_suffix_url
(self, url: str)
Function that extracts the URL after `/api/v1` or `/json` and also returns the query data in the URL, if there is any.
Function that extracts the URL after `/api/v1` or `/json` and also returns the query data in the URL, if there is any.
def extract_api_suffix_url(self, url: str) -> Tuple[str, Dict[str, Any]]: """ Function that extracts the URL after `/api/v1` or `/json` and also returns the query data in the URL, if there is any. """ url_split = url.split("?") data: Dict[str, Any] = {} if len(url...
[ "def", "extract_api_suffix_url", "(", "self", ",", "url", ":", "str", ")", "->", "Tuple", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ":", "url_split", "=", "url", ".", "split", "(", "\"?\"", ")", "data", ":", "Dict", "[", "str", "...
[ 215, 4 ]
[ 226, 26 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.validate_api_response_openapi
( self, url: str, method: str, result: HttpResponse, data: Union[str, bytes, Dict[str, Any]], http_headers: Dict[str, Any], intentionally_undocumented: bool = False, )
Validates all API responses received by this test against Zulip's API documentation, declared in zerver/openapi/zulip.yaml. This powerful test lets us use Zulip's extensive test coverage of corner cases in the API to ensure that we've properly documented those corner cases.
Validates all API responses received by this test against Zulip's API documentation, declared in zerver/openapi/zulip.yaml. This powerful test lets us use Zulip's extensive test coverage of corner cases in the API to ensure that we've properly documented those corner cases.
def validate_api_response_openapi( self, url: str, method: str, result: HttpResponse, data: Union[str, bytes, Dict[str, Any]], http_headers: Dict[str, Any], intentionally_undocumented: bool = False, ) -> None: """ Validates all API responses re...
[ "def", "validate_api_response_openapi", "(", "self", ",", "url", ":", "str", ",", "method", ":", "str", ",", "result", ":", "HttpResponse", ",", "data", ":", "Union", "[", "str", ",", "bytes", ",", "Dict", "[", "str", ",", "Any", "]", "]", ",", "http...
[ 228, 4 ]
[ 270, 13 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.client_patch
( self, url: str, info: Dict[str, Any] = {}, intentionally_undocumented: bool = False, **kwargs: Any, )
We need to urlencode, since Django's function won't do it for us.
We need to urlencode, since Django's function won't do it for us.
def client_patch( self, url: str, info: Dict[str, Any] = {}, intentionally_undocumented: bool = False, **kwargs: Any, ) -> HttpResponse: """ We need to urlencode, since Django's function won't do it for us. """ encoded = urllib.parse.urlencode(...
[ "def", "client_patch", "(", "self", ",", "url", ":", "str", ",", "info", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", ",", "intentionally_undocumented", ":", "bool", "=", "False", ",", "*", "*", "kwargs", ":", "Any", ",", ")", "->", "...
[ 273, 4 ]
[ 295, 21 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.client_patch_multipart
( self, url: str, info: Dict[str, Any] = {}, **kwargs: Any )
Use this for patch requests that have file uploads or that need some sort of multi-part content. In the future Django's test client may become a bit more flexible, so we can hopefully eliminate this. (When you post with the Django test client, it deals with MULTIPART_CONTENT ...
Use this for patch requests that have file uploads or that need some sort of multi-part content. In the future Django's test client may become a bit more flexible, so we can hopefully eliminate this. (When you post with the Django test client, it deals with MULTIPART_CONTENT ...
def client_patch_multipart( self, url: str, info: Dict[str, Any] = {}, **kwargs: Any ) -> HttpResponse: """ Use this for patch requests that have file uploads or that need some sort of multi-part content. In the future Django's test client may become a bit more flexible, ...
[ "def", "client_patch_multipart", "(", "self", ",", "url", ":", "str", ",", "info", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "HttpResponse", ":", "encoded", "=", "encode_multipart", "(", ...
[ 298, 4 ]
[ 314, 21 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.client_post_request
(self, url: str, req: Any)
We simulate hitting an endpoint here, although we actually resolve the URL manually and hit the view directly. We have this helper method to allow our instrumentation to work for /notify_tornado and future similar methods that require doing funny things to a request obj...
We simulate hitting an endpoint here, although we actually resolve the URL manually and hit the view directly. We have this helper method to allow our instrumentation to work for /notify_tornado and future similar methods that require doing funny things to a request obj...
def client_post_request(self, url: str, req: Any) -> HttpResponse: """ We simulate hitting an endpoint here, although we actually resolve the URL manually and hit the view directly. We have this helper method to allow our instrumentation to work for /notify_tornado and f...
[ "def", "client_post_request", "(", "self", ",", "url", ":", "str", ",", "req", ":", "Any", ")", "->", "HttpResponse", ":", "match", "=", "resolve", "(", "url", ")", "return", "match", ".", "func", "(", "req", ")" ]
[ 363, 4 ]
[ 374, 30 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase._get_page_params
(self, result: HttpResponse)
Helper for parsing page_params after fetching the webapp's home view.
Helper for parsing page_params after fetching the webapp's home view.
def _get_page_params(self, result: HttpResponse) -> Dict[str, Any]: """Helper for parsing page_params after fetching the webapp's home view.""" doc = lxml.html.document_fromstring(result.content) [div] = doc.xpath("//div[@id='page-params']") page_params_json = div.get("data-params") ...
[ "def", "_get_page_params", "(", "self", ",", "result", ":", "HttpResponse", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "doc", "=", "lxml", ".", "html", ".", "document_fromstring", "(", "result", ".", "content", ")", "[", "div", "]", "=", "d...
[ 496, 4 ]
[ 502, 26 ]
python
en
['en', 'en', 'en']
True
ZulipTestCase.check_rendered_logged_in_app
(self, result: HttpResponse)
Verifies that a visit of / was a 200 that rendered page_params and not for a logged-out web-public visitor.
Verifies that a visit of / was a 200 that rendered page_params and not for a logged-out web-public visitor.
def check_rendered_logged_in_app(self, result: HttpResponse) -> None: """Verifies that a visit of / was a 200 that rendered page_params and not for a logged-out web-public visitor.""" self.assertEqual(result.status_code, 200) page_params = self._get_page_params(result) # It is im...
[ "def", "check_rendered_logged_in_app", "(", "self", ",", "result", ":", "HttpResponse", ")", "->", "None", ":", "self", ".", "assertEqual", "(", "result", ".", "status_code", ",", "200", ")", "page_params", "=", "self", ".", "_get_page_params", "(", "result", ...
[ 504, 4 ]
[ 512, 69 ]
python
en
['en', 'en', 'en']
True
ZulipTestCase.check_rendered_web_public_visitor
(self, result: HttpResponse)
Verifies that a visit of / was a 200 that rendered page_params for a logged-out web-public visitor.
Verifies that a visit of / was a 200 that rendered page_params for a logged-out web-public visitor.
def check_rendered_web_public_visitor(self, result: HttpResponse) -> None: """Verifies that a visit of / was a 200 that rendered page_params for a logged-out web-public visitor.""" self.assertEqual(result.status_code, 200) page_params = self._get_page_params(result) # It is impor...
[ "def", "check_rendered_web_public_visitor", "(", "self", ",", "result", ":", "HttpResponse", ")", "->", "None", ":", "self", ".", "assertEqual", "(", "result", ".", "status_code", ",", "200", ")", "page_params", "=", "self", ".", "_get_page_params", "(", "resu...
[ 514, 4 ]
[ 521, 68 ]
python
en
['en', 'en', 'en']
True
ZulipTestCase.login
(self, name: str)
Use this for really simple tests where you just need to be logged in as some user, but don't need the actual user object for anything else. Try to use 'hamlet' for non-admins and 'iago' for admins: self.login('hamlet') Try to use 'cordelia' or 'othello' as "other"...
Use this for really simple tests where you just need to be logged in as some user, but don't need the actual user object for anything else. Try to use 'hamlet' for non-admins and 'iago' for admins:
def login(self, name: str) -> None: """ Use this for really simple tests where you just need to be logged in as some user, but don't need the actual user object for anything else. Try to use 'hamlet' for non-admins and 'iago' for admins: self.login('hamlet') ...
[ "def", "login", "(", "self", ",", "name", ":", "str", ")", "->", "None", ":", "assert", "\"@\"", "not", "in", "name", ",", "\"use login_by_email for email logins\"", "user", "=", "self", ".", "example_user", "(", "name", ")", "self", ".", "login_user", "("...
[ 534, 4 ]
[ 547, 29 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.login_2fa
(self, user_profile: UserProfile)
We need this function to call request.session.save(). do_two_factor_login doesn't save session; in normal request-response cycle this doesn't matter because middleware will save the session when it finds it dirty; however,in tests we will have to do that explicitly.
We need this function to call request.session.save(). do_two_factor_login doesn't save session; in normal request-response cycle this doesn't matter because middleware will save the session when it finds it dirty; however,in tests we will have to do that explicitly.
def login_2fa(self, user_profile: UserProfile) -> None: """ We need this function to call request.session.save(). do_two_factor_login doesn't save session; in normal request-response cycle this doesn't matter because middleware will save the session when it finds it dirty; howeve...
[ "def", "login_2fa", "(", "self", ",", "user_profile", ":", "UserProfile", ")", "->", "None", ":", "request", "=", "HttpRequest", "(", ")", "request", ".", "session", "=", "self", ".", "client", ".", "session", "request", ".", "user", "=", "user_profile", ...
[ 582, 4 ]
[ 594, 30 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.submit_reg_form_for_user
( self, email: str, password: str, realm_name: str = "Zulip Test", realm_subdomain: str = "zuliptest", from_confirmation: str = "", full_name: Optional[str] = None, timezone: str = "", realm_in_root_domain: Optional[str] = None, default_str...
Stage two of the two-step registration process. If things are working correctly the account should be fully registered after this call. You can pass the HTTP_HOST variable for subdomains via kwargs.
Stage two of the two-step registration process.
def submit_reg_form_for_user( self, email: str, password: str, realm_name: str = "Zulip Test", realm_subdomain: str = "zuliptest", from_confirmation: str = "", full_name: Optional[str] = None, timezone: str = "", realm_in_root_domain: Optional[str]...
[ "def", "submit_reg_form_for_user", "(", "self", ",", "email", ":", "str", ",", "password", ":", "str", ",", "realm_name", ":", "str", "=", "\"Zulip Test\"", ",", "realm_subdomain", ":", "str", "=", "\"zuliptest\"", ",", "from_confirmation", ":", "str", "=", ...
[ 603, 4 ]
[ 642, 73 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.encode_uuid
(self, uuid: str)
identifier: Can be an email or a remote server uuid.
identifier: Can be an email or a remote server uuid.
def encode_uuid(self, uuid: str) -> str: """ identifier: Can be an email or a remote server uuid. """ if uuid in self.API_KEYS: api_key = self.API_KEYS[uuid] else: api_key = get_remote_server_by_uuid(uuid).api_key self.API_KEYS[uuid] = api_key ...
[ "def", "encode_uuid", "(", "self", ",", "uuid", ":", "str", ")", "->", "str", ":", "if", "uuid", "in", "self", ".", "API_KEYS", ":", "api_key", "=", "self", ".", "API_KEYS", "[", "uuid", "]", "else", ":", "api_key", "=", "get_remote_server_by_uuid", "(...
[ 666, 4 ]
[ 676, 53 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.encode_credentials
(self, identifier: str, api_key: str)
identifier: Can be an email or a remote server uuid.
identifier: Can be an email or a remote server uuid.
def encode_credentials(self, identifier: str, api_key: str) -> str: """ identifier: Can be an email or a remote server uuid. """ credentials = f"{identifier}:{api_key}" return "Basic " + base64.b64encode(credentials.encode("utf-8")).decode("utf-8")
[ "def", "encode_credentials", "(", "self", ",", "identifier", ":", "str", ",", "api_key", ":", "str", ")", "->", "str", ":", "credentials", "=", "f\"{identifier}:{api_key}\"", "return", "\"Basic \"", "+", "base64", ".", "b64encode", "(", "credentials", ".", "en...
[ 691, 4 ]
[ 696, 87 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.get_streams
(self, user_profile: UserProfile)
Helper function to get the stream names for a user
Helper function to get the stream names for a user
def get_streams(self, user_profile: UserProfile) -> List[str]: """ Helper function to get the stream names for a user """ subs = get_stream_subscriptions_for_user(user_profile).filter( active=True, ) return [check_string("recipient", get_display_recipient(sub....
[ "def", "get_streams", "(", "self", ",", "user_profile", ":", "UserProfile", ")", "->", "List", "[", "str", "]", ":", "subs", "=", "get_stream_subscriptions_for_user", "(", "user_profile", ")", ".", "filter", "(", "active", "=", "True", ",", ")", "return", ...
[ 726, 4 ]
[ 733, 96 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.assert_json_success
(self, result: HttpResponse)
Successful POSTs return a 200 and JSON of the form {"result": "success", "msg": ""}.
Successful POSTs return a 200 and JSON of the form {"result": "success", "msg": ""}.
def assert_json_success(self, result: HttpResponse) -> Dict[str, Any]: """ Successful POSTs return a 200 and JSON of the form {"result": "success", "msg": ""}. """ try: json = orjson.loads(result.content) except orjson.JSONDecodeError: # nocoverage ...
[ "def", "assert_json_success", "(", "self", ",", "result", ":", "HttpResponse", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "try", ":", "json", "=", "orjson", ".", "loads", "(", "result", ".", "content", ")", "except", "orjson", ".", "JSONDecod...
[ 834, 4 ]
[ 849, 19 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.assert_json_error
(self, result: HttpResponse, msg: str, status_code: int = 400)
Invalid POSTs return an error status code and JSON of the form {"result": "error", "msg": "reason"}.
Invalid POSTs return an error status code and JSON of the form {"result": "error", "msg": "reason"}.
def assert_json_error(self, result: HttpResponse, msg: str, status_code: int = 400) -> None: """ Invalid POSTs return an error status code and JSON of the form {"result": "error", "msg": "reason"}. """ self.assertEqual(self.get_json_error(result, status_code=status_code), msg)
[ "def", "assert_json_error", "(", "self", ",", "result", ":", "HttpResponse", ",", "msg", ":", "str", ",", "status_code", ":", "int", "=", "400", ")", "->", "None", ":", "self", ".", "assertEqual", "(", "self", ".", "get_json_error", "(", "result", ",", ...
[ 860, 4 ]
[ 865, 83 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.assert_logged_in_user_id
(self, user_id: Optional[int])
Verifies the user currently logged in for the test client has the provided user_id. Pass None to verify no user is logged in.
Verifies the user currently logged in for the test client has the provided user_id. Pass None to verify no user is logged in.
def assert_logged_in_user_id(self, user_id: Optional[int]) -> None: """ Verifies the user currently logged in for the test client has the provided user_id. Pass None to verify no user is logged in. """ self.assertEqual(get_session_dict_user(self.client.session), user_id)
[ "def", "assert_logged_in_user_id", "(", "self", ",", "user_id", ":", "Optional", "[", "int", "]", ")", "->", "None", ":", "self", ".", "assertEqual", "(", "get_session_dict_user", "(", "self", ".", "client", ".", "session", ")", ",", "user_id", ")" ]
[ 896, 4 ]
[ 901, 77 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.send_webhook_payload
( self, user_profile: UserProfile, url: str, payload: Union[str, Dict[str, Any]], **post_params: Any, )
Send a webhook payload to the server, and verify that the post is successful. This is a pretty low-level function. For most use cases see the helpers that call this function, which do additional checks. Occasionally tests will call this directly, for unique si...
Send a webhook payload to the server, and verify that the post is successful.
def send_webhook_payload( self, user_profile: UserProfile, url: str, payload: Union[str, Dict[str, Any]], **post_params: Any, ) -> Message: """ Send a webhook payload to the server, and verify that the post is successful. This is a pretty low-...
[ "def", "send_webhook_payload", "(", "self", ",", "user_profile", ":", "UserProfile", ",", "url", ":", "str", ",", "payload", ":", "Union", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ",", "*", "*", "post_params", ":", "Any", ",", ")", ...
[ 1016, 4 ]
[ 1066, 18 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.simulated_markdown_failure
(self)
This raises a failure inside of the try/except block of markdown.__init__.do_convert.
This raises a failure inside of the try/except block of markdown.__init__.do_convert.
def simulated_markdown_failure(self) -> Iterator[None]: """ This raises a failure inside of the try/except block of markdown.__init__.do_convert. """ with self.settings(ERROR_BOT=None), mock.patch( "zerver.lib.markdown.timeout", side_effect=subprocess.CalledProcessErr...
[ "def", "simulated_markdown_failure", "(", "self", ")", "->", "Iterator", "[", "None", "]", ":", "with", "self", ".", "settings", "(", "ERROR_BOT", "=", "None", ")", ",", "mock", ".", "patch", "(", "\"zerver.lib.markdown.timeout\"", ",", "side_effect", "=", "...
[ 1075, 4 ]
[ 1083, 17 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.init_default_ldap_database
(self)
Takes care of the mock_ldap setup, loads a directory from zerver/tests/fixtures/ldap/directory.json with various entries to be used by tests. If a test wants to specify its own directory, it can just replace self.mock_ldap.directory with its own content, but in most cases it sho...
Takes care of the mock_ldap setup, loads a directory from zerver/tests/fixtures/ldap/directory.json with various entries to be used by tests. If a test wants to specify its own directory, it can just replace self.mock_ldap.directory with its own content, but in most cases it sho...
def init_default_ldap_database(self) -> None: """ Takes care of the mock_ldap setup, loads a directory from zerver/tests/fixtures/ldap/directory.json with various entries to be used by tests. If a test wants to specify its own directory, it can just replace self.mock_ldap...
[ "def", "init_default_ldap_database", "(", "self", ")", "->", "None", ":", "directory", "=", "orjson", ".", "loads", "(", "self", ".", "fixture_data", "(", "\"directory.json\"", ",", "type", "=", "\"ldap\"", ")", ")", "for", "dn", ",", "attrs", "in", "direc...
[ 1116, 4 ]
[ 1146, 58 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.change_ldap_user_attr
( self, username: str, attr_name: str, attr_value: Union[str, bytes], binary: bool = False )
Method for changing the value of an attribute of a user entry in the mock directory. Use option binary=True if you want binary data to be loaded into the attribute from a file specified at attr_value. This changes the attribute only for the specific test function that calls this method,...
Method for changing the value of an attribute of a user entry in the mock directory. Use option binary=True if you want binary data to be loaded into the attribute from a file specified at attr_value. This changes the attribute only for the specific test function that calls this method,...
def change_ldap_user_attr( self, username: str, attr_name: str, attr_value: Union[str, bytes], binary: bool = False ) -> None: """ Method for changing the value of an attribute of a user entry in the mock directory. Use option binary=True if you want binary data to be loaded ...
[ "def", "change_ldap_user_attr", "(", "self", ",", "username", ":", "str", ",", "attr_name", ":", "str", ",", "attr_value", ":", "Union", "[", "str", ",", "bytes", "]", ",", "binary", ":", "bool", "=", "False", ")", "->", "None", ":", "dn", "=", "f\"u...
[ 1148, 4 ]
[ 1166, 56 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.ldap_username
(self, username: str)
Maps Zulip username to the name of the corresponding LDAP user in our test directory at zerver/tests/fixtures/ldap/directory.json, if the LDAP user exists.
Maps Zulip username to the name of the corresponding LDAP user in our test directory at zerver/tests/fixtures/ldap/directory.json, if the LDAP user exists.
def ldap_username(self, username: str) -> str: """ Maps Zulip username to the name of the corresponding LDAP user in our test directory at zerver/tests/fixtures/ldap/directory.json, if the LDAP user exists. """ return self.example_user_ldap_username_map[username]
[ "def", "ldap_username", "(", "self", ",", "username", ":", "str", ")", "->", "str", ":", "return", "self", ".", "example_user_ldap_username_map", "[", "username", "]" ]
[ 1168, 4 ]
[ 1174, 60 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.email_display_from
(self, email_message: EmailMessage)
Returns the email address that will show in email clients as the "From" field.
Returns the email address that will show in email clients as the "From" field.
def email_display_from(self, email_message: EmailMessage) -> str: """ Returns the email address that will show in email clients as the "From" field. """ # The extra_headers field may contain a "From" which is used # for display in email clients, and appears in the RFC822 ...
[ "def", "email_display_from", "(", "self", ",", "email_message", ":", "EmailMessage", ")", "->", "str", ":", "# The extra_headers field may contain a \"From\" which is used", "# for display in email clients, and appears in the RFC822", "# header as `From`. The `.from_email` accessor is t...
[ 1179, 4 ]
[ 1189, 80 ]
python
en
['en', 'error', 'th']
False
ZulipTestCase.email_envelope_from
(self, email_message: EmailMessage)
Returns the email address that will be used if the email bounces.
Returns the email address that will be used if the email bounces.
def email_envelope_from(self, email_message: EmailMessage) -> str: """ Returns the email address that will be used if the email bounces. """ # See email_display_from, above. return email_message.from_email
[ "def", "email_envelope_from", "(", "self", ",", "email_message", ":", "EmailMessage", ")", "->", "str", ":", "# See email_display_from, above.", "return", "email_message", ".", "from_email" ]
[ 1191, 4 ]
[ 1196, 39 ]
python
en
['en', 'error', 'th']
False
WebhookTestCase.check_webhook
( self, fixture_name: str, expected_topic: str, expected_message: str, content_type: Optional[str] = "application/json", **kwargs: Any, )
check_webhook is the main way to test "normal" webhooks that work by receiving a payload from a third party and then writing some message to a Zulip stream. We use `fixture_name` to find the payload data in of our test fixtures. Then we verify that a message gets sent to a str...
check_webhook is the main way to test "normal" webhooks that work by receiving a payload from a third party and then writing some message to a Zulip stream.
def check_webhook( self, fixture_name: str, expected_topic: str, expected_message: str, content_type: Optional[str] = "application/json", **kwargs: Any, ) -> None: """ check_webhook is the main way to test "normal" webhooks that work by receivi...
[ "def", "check_webhook", "(", "self", ",", "fixture_name", ":", "str", ",", "expected_topic", ":", "str", ",", "expected_message", ":", "str", ",", "content_type", ":", "Optional", "[", "str", "]", "=", "\"application/json\"", ",", "*", "*", "kwargs", ":", ...
[ 1279, 4 ]
[ 1328, 9 ]
python
en
['en', 'error', 'th']
False
WebhookTestCase.send_and_test_private_message
( self, fixture_name: str, expected_message: str, content_type: str = "application/json", **kwargs: Any, )
For the rare cases that you are testing a webhook that sends private messages, use this function. Most webhooks send to streams, and you will want to look at check_webhook.
For the rare cases that you are testing a webhook that sends private messages, use this function.
def send_and_test_private_message( self, fixture_name: str, expected_message: str, content_type: str = "application/json", **kwargs: Any, ) -> Message: """ For the rare cases that you are testing a webhook that sends private messages, use this function...
[ "def", "send_and_test_private_message", "(", "self", ",", "fixture_name", ":", "str", ",", "expected_message", ":", "str", ",", "content_type", ":", "str", "=", "\"application/json\"", ",", "*", "*", "kwargs", ":", "Any", ",", ")", "->", "Message", ":", "pay...
[ 1341, 4 ]
[ 1373, 18 ]
python
en
['en', 'error', 'th']
False
WebhookTestCase.get_payload
(self, fixture_name: str)
Generally webhooks that override this should return dicts.
Generally webhooks that override this should return dicts.
def get_payload(self, fixture_name: str) -> Union[str, Dict[str, str]]: """ Generally webhooks that override this should return dicts.""" return self.get_body(fixture_name)
[ "def", "get_payload", "(", "self", ",", "fixture_name", ":", "str", ")", "->", "Union", "[", "str", ",", "Dict", "[", "str", ",", "str", "]", "]", ":", "return", "self", ".", "get_body", "(", "fixture_name", ")" ]
[ 1397, 4 ]
[ 1400, 42 ]
python
en
['en', 'error', 'th']
False
async_unsafe
(message)
Decorator to mark functions as async-unsafe. Someone trying to access the function while in an async context will get an error message.
Decorator to mark functions as async-unsafe. Someone trying to access the function while in an async context will get an error message.
def async_unsafe(message): """ Decorator to mark functions as async-unsafe. Someone trying to access the function while in an async context will get an error message. """ def decorator(func): @functools.wraps(func) def inner(*args, **kwargs): if not os.environ.get('DJANGO...
[ "def", "async_unsafe", "(", "message", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "os", ".", "environ", ...
[ 7, 0 ]
[ 33, 24 ]
python
en
['en', 'error', 'th']
False
_default_key_normalizer
(key_class, request_context)
Create a pool key out of a request context dictionary. According to RFC 3986, both the scheme and host are case-insensitive. Therefore, this function normalizes both before constructing the pool key for an HTTPS request. If you wish to change this behaviour, provide alternate callables to ``key_fn...
Create a pool key out of a request context dictionary.
def _default_key_normalizer(key_class, request_context): """ Create a pool key out of a request context dictionary. According to RFC 3986, both the scheme and host are case-insensitive. Therefore, this function normalizes both before constructing the pool key for an HTTPS request. If you wish to ch...
[ "def", "_default_key_normalizer", "(", "key_class", ",", "request_context", ")", ":", "# Since we mutate the dictionary, make a copy first", "context", "=", "request_context", ".", "copy", "(", ")", "context", "[", "\"scheme\"", "]", "=", "context", "[", "\"scheme\"", ...
[ 67, 0 ]
[ 113, 31 ]
python
en
['en', 'error', 'th']
False
PoolManager._new_pool
(self, scheme, host, port, request_context=None)
Create a new :class:`ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments. If ``request_context`` is provided, it is provided as keyword arguments to the pool class used. This method is used to actually create the connection pools handed out by...
Create a new :class:`ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments.
def _new_pool(self, scheme, host, port, request_context=None): """ Create a new :class:`ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments. If ``request_context`` is provided, it is provided as keyword arguments to the pool class used. This me...
[ "def", "_new_pool", "(", "self", ",", "scheme", ",", "host", ",", "port", ",", "request_context", "=", "None", ")", ":", "pool_cls", "=", "self", ".", "pool_classes_by_scheme", "[", "scheme", "]", "if", "request_context", "is", "None", ":", "request_context"...
[ 176, 4 ]
[ 201, 54 ]
python
en
['en', 'error', 'th']
False
PoolManager.clear
(self)
Empty our store of pools and direct them all to close. This will not affect in-flight connections, but they will not be re-used after completion.
Empty our store of pools and direct them all to close.
def clear(self): """ Empty our store of pools and direct them all to close. This will not affect in-flight connections, but they will not be re-used after completion. """ self.pools.clear()
[ "def", "clear", "(", "self", ")", ":", "self", ".", "pools", ".", "clear", "(", ")" ]
[ 203, 4 ]
[ 210, 26 ]
python
en
['en', 'error', 'th']
False
PoolManager.connection_from_host
(self, host, port=None, scheme="http", pool_kwargs=None)
Get a :class:`ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is provided, it is merged with the instance's ``connection_pool_kw`` variable a...
Get a :class:`ConnectionPool` based on the host, port, and scheme.
def connection_from_host(self, host, port=None, scheme="http", pool_kwargs=None): """ Get a :class:`ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is...
[ "def", "connection_from_host", "(", "self", ",", "host", ",", "port", "=", "None", ",", "scheme", "=", "\"http\"", ",", "pool_kwargs", "=", "None", ")", ":", "if", "not", "host", ":", "raise", "LocationValueError", "(", "\"No host specified.\"", ")", "reques...
[ 212, 4 ]
[ 233, 60 ]
python
en
['en', 'error', 'th']
False
PoolManager.connection_from_context
(self, request_context)
Get a :class:`ConnectionPool` based on the request context. ``request_context`` must at least contain the ``scheme`` key and its value must be a key in ``key_fn_by_scheme`` instance variable.
Get a :class:`ConnectionPool` based on the request context.
def connection_from_context(self, request_context): """ Get a :class:`ConnectionPool` based on the request context. ``request_context`` must at least contain the ``scheme`` key and its value must be a key in ``key_fn_by_scheme`` instance variable. """ scheme = request_co...
[ "def", "connection_from_context", "(", "self", ",", "request_context", ")", ":", "scheme", "=", "request_context", "[", "\"scheme\"", "]", ".", "lower", "(", ")", "pool_key_constructor", "=", "self", ".", "key_fn_by_scheme", "[", "scheme", "]", "pool_key", "=", ...
[ 235, 4 ]
[ 246, 87 ]
python
en
['en', 'error', 'th']
False
PoolManager.connection_from_pool_key
(self, pool_key, request_context=None)
Get a :class:`ConnectionPool` based on the provided pool key. ``pool_key`` should be a namedtuple that only contains immutable objects. At a minimum it must have the ``scheme``, ``host``, and ``port`` fields.
Get a :class:`ConnectionPool` based on the provided pool key.
def connection_from_pool_key(self, pool_key, request_context=None): """ Get a :class:`ConnectionPool` based on the provided pool key. ``pool_key`` should be a namedtuple that only contains immutable objects. At a minimum it must have the ``scheme``, ``host``, and ``port`` fields...
[ "def", "connection_from_pool_key", "(", "self", ",", "pool_key", ",", "request_context", "=", "None", ")", ":", "with", "self", ".", "pools", ".", "lock", ":", "# If the scheme, host, or port doesn't match existing open", "# connections, open a new ConnectionPool.", "pool",...
[ 248, 4 ]
[ 270, 19 ]
python
en
['en', 'error', 'th']
False
PoolManager.connection_from_url
(self, url, pool_kwargs=None)
Similar to :func:`urllib3.connectionpool.connection_from_url`. If ``pool_kwargs`` is not provided and a new pool needs to be constructed, ``self.connection_pool_kw`` is used to initialize the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs`` is provided, it is ...
Similar to :func:`urllib3.connectionpool.connection_from_url`.
def connection_from_url(self, url, pool_kwargs=None): """ Similar to :func:`urllib3.connectionpool.connection_from_url`. If ``pool_kwargs`` is not provided and a new pool needs to be constructed, ``self.connection_pool_kw`` is used to initialize the :class:`urllib3.connectionpoo...
[ "def", "connection_from_url", "(", "self", ",", "url", ",", "pool_kwargs", "=", "None", ")", ":", "u", "=", "parse_url", "(", "url", ")", "return", "self", ".", "connection_from_host", "(", "u", ".", "host", ",", "port", "=", "u", ".", "port", ",", "...
[ 272, 4 ]
[ 286, 9 ]
python
en
['en', 'error', 'th']
False
PoolManager._merge_pool_kwargs
(self, override)
Merge a dictionary of override values for self.connection_pool_kw. This does not modify self.connection_pool_kw and returns a new dict. Any keys in the override dictionary with a value of ``None`` are removed from the merged dictionary.
Merge a dictionary of override values for self.connection_pool_kw.
def _merge_pool_kwargs(self, override): """ Merge a dictionary of override values for self.connection_pool_kw. This does not modify self.connection_pool_kw and returns a new dict. Any keys in the override dictionary with a value of ``None`` are removed from the merged dictionary...
[ "def", "_merge_pool_kwargs", "(", "self", ",", "override", ")", ":", "base_pool_kwargs", "=", "self", ".", "connection_pool_kw", ".", "copy", "(", ")", "if", "override", ":", "for", "key", ",", "value", "in", "override", ".", "items", "(", ")", ":", "if"...
[ 288, 4 ]
[ 306, 31 ]
python
en
['en', 'error', 'th']
False
PoolManager.urlopen
(self, method, url, redirect=True, **kw)
Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen` with custom cross-host redirect logic and only sends the request-uri portion of the ``url``. The given ``url`` parameter must be absolute, such that an appropriate :class:`urllib3.connectionpool.ConnectionPool` c...
Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen` with custom cross-host redirect logic and only sends the request-uri portion of the ``url``.
def urlopen(self, method, url, redirect=True, **kw): """ Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen` with custom cross-host redirect logic and only sends the request-uri portion of the ``url``. The given ``url`` parameter must be absolute, such that an appr...
[ "def", "urlopen", "(", "self", ",", "method", ",", "url", ",", "redirect", "=", "True", ",", "*", "*", "kw", ")", ":", "u", "=", "parse_url", "(", "url", ")", "conn", "=", "self", ".", "connection_from_host", "(", "u", ".", "host", ",", "port", "...
[ 308, 4 ]
[ 368, 60 ]
python
en
['en', 'error', 'th']
False
ProxyManager._set_proxy_headers
(self, url, headers=None)
Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user.
Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user.
def _set_proxy_headers(self, url, headers=None): """ Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user. """ headers_ = {"Accept": "*/*"} netloc = parse_url(url).netloc if netloc: head...
[ "def", "_set_proxy_headers", "(", "self", ",", "url", ",", "headers", "=", "None", ")", ":", "headers_", "=", "{", "\"Accept\"", ":", "\"*/*\"", "}", "netloc", "=", "parse_url", "(", "url", ")", ".", "netloc", "if", "netloc", ":", "headers_", "[", "\"H...
[ 439, 4 ]
[ 452, 23 ]
python
en
['en', 'error', 'th']
False
ProxyManager.urlopen
(self, method, url, redirect=True, **kw)
Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.
Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.
def urlopen(self, method, url, redirect=True, **kw): "Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute." u = parse_url(url) if u.scheme == "http": # For proxied HTTPS requests, httplib sets the necessary headers # on the CONNECT to the proxy. For HTTP, we'...
[ "def", "urlopen", "(", "self", ",", "method", ",", "url", ",", "redirect", "=", "True", ",", "*", "*", "kw", ")", ":", "u", "=", "parse_url", "(", "url", ")", "if", "u", ".", "scheme", "==", "\"http\"", ":", "# For proxied HTTPS requests, httplib sets th...
[ 454, 4 ]
[ 465, 86 ]
python
en
['en', 'en', 'nl']
True
build_topic_mute_checker
( cursor: CursorObj, user_profile: UserProfile )
This function is similar to the function of the same name in zerver/lib/topic_mutes.py, but it works without the ORM, so that we can use it in migrations.
This function is similar to the function of the same name in zerver/lib/topic_mutes.py, but it works without the ORM, so that we can use it in migrations.
def build_topic_mute_checker( cursor: CursorObj, user_profile: UserProfile ) -> Callable[[int, str], bool]: """ This function is similar to the function of the same name in zerver/lib/topic_mutes.py, but it works without the ORM, so that we can use it in migrations. """ query = SQL( ...
[ "def", "build_topic_mute_checker", "(", "cursor", ":", "CursorObj", ",", "user_profile", ":", "UserProfile", ")", "->", "Callable", "[", "[", "int", ",", "str", "]", ",", "bool", "]", ":", "query", "=", "SQL", "(", "\"\"\"\n SELECT\n recipient_...
[ 24, 0 ]
[ 51, 19 ]
python
en
['en', 'error', 'th']
False
add_message
(request, level, message, extra_tags='', fail_silently=False)
Attempts to add a message to the request using the 'messages' app.
Attempts to add a message to the request using the 'messages' app.
def add_message(request, level, message, extra_tags='', fail_silently=False): """ Attempts to add a message to the request using the 'messages' app. """ if not isinstance(request, HttpRequest): raise TypeError("add_message() argument must be an HttpRequest object, " "not ...
[ "def", "add_message", "(", "request", ",", "level", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "if", "not", "isinstance", "(", "request", ",", "HttpRequest", ")", ":", "raise", "TypeError", "(", "\"add_messa...
[ 16, 0 ]
[ 27, 75 ]
python
en
['en', 'error', 'th']
False
get_messages
(request)
Returns the message storage on the request if it exists, otherwise returns an empty list.
Returns the message storage on the request if it exists, otherwise returns an empty list.
def get_messages(request): """ Returns the message storage on the request if it exists, otherwise returns an empty list. """ if hasattr(request, '_messages'): return request._messages else: return []
[ "def", "get_messages", "(", "request", ")", ":", "if", "hasattr", "(", "request", ",", "'_messages'", ")", ":", "return", "request", ".", "_messages", "else", ":", "return", "[", "]" ]
[ 30, 0 ]
[ 38, 17 ]
python
en
['en', 'error', 'th']
False
get_level
(request)
Returns the minimum level of messages to be recorded. The default level is the ``MESSAGE_LEVEL`` setting. If this is not found, the ``INFO`` level is used.
Returns the minimum level of messages to be recorded.
def get_level(request): """ Returns the minimum level of messages to be recorded. The default level is the ``MESSAGE_LEVEL`` setting. If this is not found, the ``INFO`` level is used. """ if hasattr(request, '_messages'): storage = request._messages else: storage = default_s...
[ "def", "get_level", "(", "request", ")", ":", "if", "hasattr", "(", "request", ",", "'_messages'", ")", ":", "storage", "=", "request", ".", "_messages", "else", ":", "storage", "=", "default_storage", "(", "request", ")", "return", "storage", ".", "level"...
[ 41, 0 ]
[ 52, 24 ]
python
en
['en', 'error', 'th']
False
set_level
(request, level)
Sets the minimum level of messages to be recorded, returning ``True`` if the level was recorded successfully. If set to ``None``, the default level will be used (see the ``get_level`` method).
Sets the minimum level of messages to be recorded, returning ``True`` if the level was recorded successfully.
def set_level(request, level): """ Sets the minimum level of messages to be recorded, returning ``True`` if the level was recorded successfully. If set to ``None``, the default level will be used (see the ``get_level`` method). """ if not hasattr(request, '_messages'): return False ...
[ "def", "set_level", "(", "request", ",", "level", ")", ":", "if", "not", "hasattr", "(", "request", ",", "'_messages'", ")", ":", "return", "False", "request", ".", "_messages", ".", "level", "=", "level", "return", "True" ]
[ 55, 0 ]
[ 66, 15 ]
python
en
['en', 'error', 'th']
False
debug
(request, message, extra_tags='', fail_silently=False)
Adds a message with the ``DEBUG`` level.
Adds a message with the ``DEBUG`` level.
def debug(request, message, extra_tags='', fail_silently=False): """ Adds a message with the ``DEBUG`` level. """ add_message(request, constants.DEBUG, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "debug", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "DEBUG", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_sile...
[ 69, 0 ]
[ 74, 44 ]
python
en
['en', 'error', 'th']
False
info
(request, message, extra_tags='', fail_silently=False)
Adds a message with the ``INFO`` level.
Adds a message with the ``INFO`` level.
def info(request, message, extra_tags='', fail_silently=False): """ Adds a message with the ``INFO`` level. """ add_message(request, constants.INFO, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "info", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "INFO", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_silent...
[ 77, 0 ]
[ 82, 44 ]
python
en
['en', 'error', 'th']
False
success
(request, message, extra_tags='', fail_silently=False)
Adds a message with the ``SUCCESS`` level.
Adds a message with the ``SUCCESS`` level.
def success(request, message, extra_tags='', fail_silently=False): """ Adds a message with the ``SUCCESS`` level. """ add_message(request, constants.SUCCESS, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "success", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "SUCCESS", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_...
[ 85, 0 ]
[ 90, 44 ]
python
en
['en', 'error', 'th']
False
warning
(request, message, extra_tags='', fail_silently=False)
Adds a message with the ``WARNING`` level.
Adds a message with the ``WARNING`` level.
def warning(request, message, extra_tags='', fail_silently=False): """ Adds a message with the ``WARNING`` level. """ add_message(request, constants.WARNING, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "warning", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "WARNING", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_...
[ 93, 0 ]
[ 98, 44 ]
python
en
['en', 'error', 'th']
False
error
(request, message, extra_tags='', fail_silently=False)
Adds a message with the ``ERROR`` level.
Adds a message with the ``ERROR`` level.
def error(request, message, extra_tags='', fail_silently=False): """ Adds a message with the ``ERROR`` level. """ add_message(request, constants.ERROR, message, extra_tags=extra_tags, fail_silently=fail_silently)
[ "def", "error", "(", "request", ",", "message", ",", "extra_tags", "=", "''", ",", "fail_silently", "=", "False", ")", ":", "add_message", "(", "request", ",", "constants", ".", "ERROR", ",", "message", ",", "extra_tags", "=", "extra_tags", ",", "fail_sile...
[ 101, 0 ]
[ 106, 44 ]
python
en
['en', 'error', 'th']
False
get_template
(template_name, using=None)
Load and return a template for the given name. Raise TemplateDoesNotExist if no such template exists.
Load and return a template for the given name.
def get_template(template_name, using=None): """ Load and return a template for the given name. Raise TemplateDoesNotExist if no such template exists. """ chain = [] engines = _engine_list(using) for engine in engines: try: return engine.get_template(template_name) ...
[ "def", "get_template", "(", "template_name", ",", "using", "=", "None", ")", ":", "chain", "=", "[", "]", "engines", "=", "_engine_list", "(", "using", ")", "for", "engine", "in", "engines", ":", "try", ":", "return", "engine", ".", "get_template", "(", ...
[ 4, 0 ]
[ 18, 58 ]
python
en
['en', 'error', 'th']
False
select_template
(template_name_list, using=None)
Load and return a template for one of the given names. Try names in order and return the first template found. Raise TemplateDoesNotExist if no such template exists.
Load and return a template for one of the given names.
def select_template(template_name_list, using=None): """ Load and return a template for one of the given names. Try names in order and return the first template found. Raise TemplateDoesNotExist if no such template exists. """ if isinstance(template_name_list, str): raise TypeError( ...
[ "def", "select_template", "(", "template_name_list", ",", "using", "=", "None", ")", ":", "if", "isinstance", "(", "template_name_list", ",", "str", ")", ":", "raise", "TypeError", "(", "'select_template() takes an iterable of template names but got a '", "'string: %r. Us...
[ 21, 0 ]
[ 48, 64 ]
python
en
['en', 'error', 'th']
False
render_to_string
(template_name, context=None, request=None, using=None)
Load a template and render it with a context. Return a string. template_name may be a string or a list of strings.
Load a template and render it with a context. Return a string.
def render_to_string(template_name, context=None, request=None, using=None): """ Load a template and render it with a context. Return a string. template_name may be a string or a list of strings. """ if isinstance(template_name, (list, tuple)): template = select_template(template_name, usin...
[ "def", "render_to_string", "(", "template_name", ",", "context", "=", "None", ",", "request", "=", "None", ",", "using", "=", "None", ")", ":", "if", "isinstance", "(", "template_name", ",", "(", "list", ",", "tuple", ")", ")", ":", "template", "=", "s...
[ 51, 0 ]
[ 61, 44 ]
python
en
['en', 'error', 'th']
False
TestPerImageStandardize.setUp
(self)
Set up session and build model graph
Set up session and build model graph
def setUp(self): """ Set up session and build model graph """ super(TestPerImageStandardize, self).setUp() self.input_shape = (128, 32, 32, 3) self.sess = tf.Session() self.model = MLP( input_shape=self.input_shape, layers=[PerImageStandardize(name="o...
[ "def", "setUp", "(", "self", ")", ":", "super", "(", "TestPerImageStandardize", ",", "self", ")", ".", "setUp", "(", ")", "self", ".", "input_shape", "=", "(", "128", ",", "32", ",", "32", ",", "3", ")", "self", ".", "sess", "=", "tf", ".", "Sess...
[ 15, 4 ]
[ 30, 75 ]
python
en
['en', 'error', 'th']
False
TestPerImageStandardize.run_and_check_output
(self, x)
Make sure y and y_true evaluate to the same value
Make sure y and y_true evaluate to the same value
def run_and_check_output(self, x): """ Make sure y and y_true evaluate to the same value """ y, y_true = self.sess.run([self.y, self.y_true], feed_dict={self.x: x}) self.assertClose(y, y_true)
[ "def", "run_and_check_output", "(", "self", ",", "x", ")", ":", "y", ",", "y_true", "=", "self", ".", "sess", ".", "run", "(", "[", "self", ".", "y", ",", "self", ".", "y_true", "]", ",", "feed_dict", "=", "{", "self", ".", "x", ":", "x", "}", ...
[ 32, 4 ]
[ 37, 35 ]
python
en
['en', 'error', 'th']
False
TestPerImageStandardize.test_random_inputs
(self)
Test on random inputs
Test on random inputs
def test_random_inputs(self): """ Test on random inputs """ x = np.random.rand(*self.input_shape) self.run_and_check_output(x)
[ "def", "test_random_inputs", "(", "self", ")", ":", "x", "=", "np", ".", "random", ".", "rand", "(", "*", "self", ".", "input_shape", ")", "self", ".", "run_and_check_output", "(", "x", ")" ]
[ 39, 4 ]
[ 44, 36 ]
python
en
['en', 'error', 'th']
False
TestPerImageStandardize.test_ones_inputs
(self)
Test with input set to all ones.
Test with input set to all ones.
def test_ones_inputs(self): """ Test with input set to all ones. """ x = np.ones(self.input_shape) self.run_and_check_output(x)
[ "def", "test_ones_inputs", "(", "self", ")", ":", "x", "=", "np", ".", "ones", "(", "self", ".", "input_shape", ")", "self", ".", "run_and_check_output", "(", "x", ")" ]
[ 46, 4 ]
[ 51, 36 ]
python
en
['en', 'error', 'th']
False
TestDropout.test_no_drop
(self)
test_no_drop: Make sure dropout does nothing by default (so it does not cause stochasticity at test time)
test_no_drop: Make sure dropout does nothing by default (so it does not cause stochasticity at test time)
def test_no_drop(self): """test_no_drop: Make sure dropout does nothing by default (so it does not cause stochasticity at test time)""" model = MLP(input_shape=[1, 1], layers=[Dropout(name="output")]) x = tf.constant([[1]], dtype=tf.float32) y = model.get_layer(x, "output") ...
[ "def", "test_no_drop", "(", "self", ")", ":", "model", "=", "MLP", "(", "input_shape", "=", "[", "1", ",", "1", "]", ",", "layers", "=", "[", "Dropout", "(", "name", "=", "\"output\"", ")", "]", ")", "x", "=", "tf", ".", "constant", "(", "[", "...
[ 59, 4 ]
[ 70, 42 ]
python
en
['en', 'en', 'en']
True
TestDropout.test_drop
(self)
test_drop: Make sure dropout is activated successfully
test_drop: Make sure dropout is activated successfully
def test_drop(self): """test_drop: Make sure dropout is activated successfully""" # We would like to configure the test to deterministically drop, # so that the test does not need to use multiple runs. # However, tf.nn.dropout divides by include_prob, so zero or # infinitesimal ...
[ "def", "test_drop", "(", "self", ")", ":", "# We would like to configure the test to deterministically drop,", "# so that the test does not need to use multiple runs.", "# However, tf.nn.dropout divides by include_prob, so zero or", "# infinitesimal include_prob causes NaNs.", "# 1e-8 does not c...
[ 72, 4 ]
[ 89, 38 ]
python
en
['en', 'en', 'en']
True
TestDropout.test_override
(self)
test_override: Make sure dropout_dict changes dropout probabilities successfully.
test_override: Make sure dropout_dict changes dropout probabilities successfully.
def test_override(self): """test_override: Make sure dropout_dict changes dropout probabilities successfully.""" # We would like to configure the test to deterministically drop, # so that the test does not need to use multiple runs. # However, tf.nn.dropout divides by include_pr...
[ "def", "test_override", "(", "self", ")", ":", "# We would like to configure the test to deterministically drop,", "# so that the test does not need to use multiple runs.", "# However, tf.nn.dropout divides by include_prob, so zero or", "# infinitesimal include_prob causes NaNs.", "# For this te...
[ 91, 4 ]
[ 110, 38 ]
python
fr
['fr', 'fr', 'en']
True
Greatest.as_sqlite
(self, compiler, connection, **extra_context)
Use the MAX function on SQLite.
Use the MAX function on SQLite.
def as_sqlite(self, compiler, connection, **extra_context): """Use the MAX function on SQLite.""" return super().as_sqlite(compiler, connection, function='MAX', **extra_context)
[ "def", "as_sqlite", "(", "self", ",", "compiler", ",", "connection", ",", "*", "*", "extra_context", ")", ":", "return", "super", "(", ")", ".", "as_sqlite", "(", "compiler", ",", "connection", ",", "function", "=", "'MAX'", ",", "*", "*", "extra_context...
[ 78, 4 ]
[ 80, 87 ]
python
en
['en', 'en', 'en']
True
Least.as_sqlite
(self, compiler, connection, **extra_context)
Use the MIN function on SQLite.
Use the MIN function on SQLite.
def as_sqlite(self, compiler, connection, **extra_context): """Use the MIN function on SQLite.""" return super().as_sqlite(compiler, connection, function='MIN', **extra_context)
[ "def", "as_sqlite", "(", "self", ",", "compiler", ",", "connection", ",", "*", "*", "extra_context", ")", ":", "return", "super", "(", ")", ".", "as_sqlite", "(", "compiler", ",", "connection", ",", "function", "=", "'MIN'", ",", "*", "*", "extra_context...
[ 98, 4 ]
[ 100, 87 ]
python
en
['en', 'en', 'en']
True
FallbackStorage._get
(self, *args, **kwargs)
Gets a single list of messages from all storage backends.
Gets a single list of messages from all storage backends.
def _get(self, *args, **kwargs): """ Gets a single list of messages from all storage backends. """ all_messages = [] for storage in self.storages: messages, all_retrieved = storage._get() # If the backend hasn't been used, no more retrieval is necessary. ...
[ "def", "_get", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "all_messages", "=", "[", "]", "for", "storage", "in", "self", ".", "storages", ":", "messages", ",", "all_retrieved", "=", "storage", ".", "_get", "(", ")", "# If the b...
[ 18, 4 ]
[ 35, 42 ]
python
en
['en', 'error', 'th']
False
FallbackStorage._store
(self, messages, response, *args, **kwargs)
Stores the messages, returning any unstored messages after trying all backends. For each storage backend, any messages not stored are passed on to the next backend.
Stores the messages, returning any unstored messages after trying all backends.
def _store(self, messages, response, *args, **kwargs): """ Stores the messages, returning any unstored messages after trying all backends. For each storage backend, any messages not stored are passed on to the next backend. """ for storage in self.storages: ...
[ "def", "_store", "(", "self", ",", "messages", ",", "response", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "storage", "in", "self", ".", "storages", ":", "if", "messages", ":", "messages", "=", "storage", ".", "_store", "(", "message...
[ 37, 4 ]
[ 54, 23 ]
python
en
['en', 'error', 'th']
False
_byte_string
(s)
Cast a string or byte string to an ASCII byte string.
Cast a string or byte string to an ASCII byte string.
def _byte_string(s): """Cast a string or byte string to an ASCII byte string.""" return s.encode('ASCII')
[ "def", "_byte_string", "(", "s", ")", ":", "return", "s", ".", "encode", "(", "'ASCII'", ")" ]
[ 12, 0 ]
[ 14, 28 ]
python
en
['en', 'en', 'en']
True
_std_string
(s)
Cast a string or byte string to an ASCII string.
Cast a string or byte string to an ASCII string.
def _std_string(s): """Cast a string or byte string to an ASCII string.""" return str(s.decode('ASCII'))
[ "def", "_std_string", "(", "s", ")", ":", "return", "str", "(", "s", ".", "decode", "(", "'ASCII'", ")", ")" ]
[ 19, 0 ]
[ 21, 33 ]
python
en
['en', 'en', 'en']
True
make_excel
(data)
Based on models.utils.generate_reservation_xlsx Data is a dict where key is the model's name and value is a list with first item the translated field names and second item list of instances (or a queryset returning such) Each model gets added to its own sheet (tab) in XLS file :param data:{m...
Based on models.utils.generate_reservation_xlsx
def make_excel(data): """ Based on models.utils.generate_reservation_xlsx Data is a dict where key is the model's name and value is a list with first item the translated field names and second item list of instances (or a queryset returning such) Each model gets added to its own sheet (tab) in...
[ "def", "make_excel", "(", "data", ")", ":", "output", "=", "io", ".", "BytesIO", "(", ")", "workbook", "=", "xlsxwriter", ".", "Workbook", "(", "output", ")", "for", "name", ",", "(", "translated_fields", ",", "items", ")", "in", "data", ".", "items", ...
[ 17, 0 ]
[ 51, 28 ]
python
en
['en', 'error', 'th']
False
TemplatesModule.config
(self)
Template config. Returns: dict: Current configuration
Template config.
def config(self): """Template config. Returns: dict: Current configuration """ return self.parent.config
[ "def", "config", "(", "self", ")", ":", "return", "self", ".", "parent", ".", "config" ]
[ 32, 4 ]
[ 39, 33 ]
python
en
['en', 'en', 'en']
False
TemplatesModule.load
(self, **kwargs)
Loads project templates.
Loads project templates.
def load(self, **kwargs): """Loads project templates.""" self.provider = self.get_provider(self.config.get("config")) templates = [k for k, v in self.config.get("config").items() if v] self.log.debug(f"Loading Templates: {templates}") self.provider = TemplateProvider(templates, *...
[ "def", "load", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "provider", "=", "self", ".", "get_provider", "(", "self", ".", "config", ".", "get", "(", "\"config\"", ")", ")", "templates", "=", "[", "k", "for", "k", ",", "v", "in",...
[ 44, 4 ]
[ 50, 21 ]
python
en
['en', 'en', 'en']
True
TemplatesModule.create
(self)
Generates project files. Returns: dict: Project context
Generates project files.
def create(self): """Generates project files. Returns: dict: Project context """ self.log.title("Rendering Templates") self.log.info("Populating Stub Info...") for key in self._templates: if key in self._dynamic: self.config.add("...
[ "def", "create", "(", "self", ")", ":", "self", ".", "log", ".", "title", "(", "\"Rendering Templates\"", ")", "self", ".", "log", ".", "info", "(", "\"Populating Stub Info...\"", ")", "for", "key", "in", "self", ".", "_templates", ":", "if", "key", "in"...
[ 52, 4 ]
[ 68, 30 ]
python
en
['fr', 'en', 'en']
True
TemplatesModule.update
(self)
Updates project files. Returns: dict: Project context
Updates project files.
def update(self): """Updates project files. Returns: dict: Project context """ self.provider = self.get_provider(self.config.get("config")) self.log.debug(f"updating templates with context: {self.parent.context.raw()}") for tmp in self.provider.templates: ...
[ "def", "update", "(", "self", ")", ":", "self", ".", "provider", "=", "self", ".", "get_provider", "(", "self", ".", "config", ".", "get", "(", "\"config\"", ")", ")", "self", ".", "log", ".", "debug", "(", "f\"updating templates with context: {self.parent.c...
[ 70, 4 ]
[ 81, 34 ]
python
en
['fr', 'en', 'en']
True
_error
(msg)
Print msg and optionally exit with return code exit_.
Print msg and optionally exit with return code exit_.
def _error(msg): """Print msg and optionally exit with return code exit_.""" sys.stderr.write(u'[ERROR] {0}\n'.format(msg)) return 1
[ "def", "_error", "(", "msg", ")", ":", "sys", ".", "stderr", ".", "write", "(", "u'[ERROR] {0}\\n'", ".", "format", "(", "msg", ")", ")", "return", "1" ]
[ 153, 0 ]
[ 156, 12 ]
python
en
['en', 'en', 'en']
True
i18n_patterns
(*urls, prefix_default_language=True)
Add the language code prefix to every URL pattern within this function. This may only be used in the root URLconf, not in an included URLconf.
Add the language code prefix to every URL pattern within this function. This may only be used in the root URLconf, not in an included URLconf.
def i18n_patterns(*urls, prefix_default_language=True): """ Add the language code prefix to every URL pattern within this function. This may only be used in the root URLconf, not in an included URLconf. """ if not settings.USE_I18N: return list(urls) return [ URLResolver( ...
[ "def", "i18n_patterns", "(", "*", "urls", ",", "prefix_default_language", "=", "True", ")", ":", "if", "not", "settings", ".", "USE_I18N", ":", "return", "list", "(", "urls", ")", "return", "[", "URLResolver", "(", "LocalePrefixPattern", "(", "prefix_default_l...
[ 7, 0 ]
[ 19, 5 ]
python
en
['en', 'error', 'th']
False
is_language_prefix_patterns_used
(urlconf)
Return a tuple of two booleans: ( `True` if i18n_patterns() (LocalePrefixPattern) is used in the URLconf, `True` if the default language should be prefixed )
Return a tuple of two booleans: ( `True` if i18n_patterns() (LocalePrefixPattern) is used in the URLconf, `True` if the default language should be prefixed )
def is_language_prefix_patterns_used(urlconf): """ Return a tuple of two booleans: ( `True` if i18n_patterns() (LocalePrefixPattern) is used in the URLconf, `True` if the default language should be prefixed ) """ for url_pattern in get_resolver(urlconf).url_patterns: if isins...
[ "def", "is_language_prefix_patterns_used", "(", "urlconf", ")", ":", "for", "url_pattern", "in", "get_resolver", "(", "urlconf", ")", ".", "url_patterns", ":", "if", "isinstance", "(", "url_pattern", ".", "pattern", ",", "LocalePrefixPattern", ")", ":", "return", ...
[ 23, 0 ]
[ 33, 23 ]
python
en
['en', 'error', 'th']
False
ping_google
(sitemap_url=None, ping_url=PING_URL)
Alerts Google that the sitemap for the current site has been updated. If sitemap_url is provided, it should be an absolute path to the sitemap for this site -- e.g., '/sitemap.xml'. If sitemap_url is not provided, this function will attempt to deduce it by using urlresolvers.reverse().
Alerts Google that the sitemap for the current site has been updated. If sitemap_url is provided, it should be an absolute path to the sitemap for this site -- e.g., '/sitemap.xml'. If sitemap_url is not provided, this function will attempt to deduce it by using urlresolvers.reverse().
def ping_google(sitemap_url=None, ping_url=PING_URL): """ Alerts Google that the sitemap for the current site has been updated. If sitemap_url is provided, it should be an absolute path to the sitemap for this site -- e.g., '/sitemap.xml'. If sitemap_url is not provided, this function will attempt t...
[ "def", "ping_google", "(", "sitemap_url", "=", "None", ",", "ping_url", "=", "PING_URL", ")", ":", "if", "sitemap_url", "is", "None", ":", "try", ":", "# First, try to get the \"index\" sitemap URL.", "sitemap_url", "=", "urlresolvers", ".", "reverse", "(", "'djan...
[ 16, 0 ]
[ 43, 41 ]
python
en
['en', 'error', 'th']
False
AppveyorHookTests.test_appveyor_build_success_message
(self)
Tests if appveyor build success notification is handled correctly
Tests if appveyor build success notification is handled correctly
def test_appveyor_build_success_message(self) -> None: """ Tests if appveyor build success notification is handled correctly """ expected_topic = "Hubot-DSC-Resource" expected_message = """ [Build Hubot-DSC-Resource 2.0.59 completed](https://ci.appveyor.com/project/joebloggs/hubo...
[ "def", "test_appveyor_build_success_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"Hubot-DSC-Resource\"", "expected_message", "=", "\"\"\"\n[Build Hubot-DSC-Resource 2.0.59 completed](https://ci.appveyor.com/project/joebloggs/hubot-dsc-resource/build/2.0.59):\n* *...
[ 8, 4 ]
[ 20, 86 ]
python
en
['en', 'error', 'th']
False
AppveyorHookTests.test_appveyor_build_failure_message
(self)
Tests if appveyor build failure notification is handled correctly
Tests if appveyor build failure notification is handled correctly
def test_appveyor_build_failure_message(self) -> None: """ Tests if appveyor build failure notification is handled correctly """ expected_topic = "Hubot-DSC-Resource" expected_message = """ [Build Hubot-DSC-Resource 2.0.59 failed](https://ci.appveyor.com/project/joebloggs/hubot-d...
[ "def", "test_appveyor_build_failure_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"Hubot-DSC-Resource\"", "expected_message", "=", "\"\"\"\n[Build Hubot-DSC-Resource 2.0.59 failed](https://ci.appveyor.com/project/joebloggs/hubot-dsc-resource/build/2.0.59):\n* **Co...
[ 22, 4 ]
[ 34, 86 ]
python
en
['en', 'error', 'th']
False
BashCompletionTests._user_input
(self, input_str)
Set the environment and the list of command line arguments. This sets the bash variables $COMP_WORDS and $COMP_CWORD. The former is an array consisting of the individual words in the current command line, the latter is the index of the current cursor position, so in case a word...
Set the environment and the list of command line arguments.
def _user_input(self, input_str): """ Set the environment and the list of command line arguments. This sets the bash variables $COMP_WORDS and $COMP_CWORD. The former is an array consisting of the individual words in the current command line, the latter is the index of the curre...
[ "def", "_user_input", "(", "self", ",", "input_str", ")", ":", "os", ".", "environ", "[", "'COMP_WORDS'", "]", "=", "input_str", "idx", "=", "len", "(", "input_str", ".", "split", "(", "' '", ")", ")", "-", "1", "# Index of the last word", "comp_cword", ...
[ 33, 4 ]
[ 51, 36 ]
python
en
['en', 'error', 'th']
False
BashCompletionTests.test_django_admin_py
(self)
django_admin.py will autocomplete option flags
django_admin.py will autocomplete option flags
def test_django_admin_py(self): "django_admin.py will autocomplete option flags" self._user_input('django-admin sqlall --verb') output = self._run_autocomplete() self.assertEqual(output, ['--verbosity='])
[ "def", "test_django_admin_py", "(", "self", ")", ":", "self", ".", "_user_input", "(", "'django-admin sqlall --verb'", ")", "output", "=", "self", ".", "_run_autocomplete", "(", ")", "self", ".", "assertEqual", "(", "output", ",", "[", "'--verbosity='", "]", "...
[ 61, 4 ]
[ 65, 50 ]
python
en
['en', 'en', 'en']
True
BashCompletionTests.test_manage_py
(self)
manage.py will autocomplete option flags
manage.py will autocomplete option flags
def test_manage_py(self): "manage.py will autocomplete option flags" self._user_input('manage.py sqlall --verb') output = self._run_autocomplete() self.assertEqual(output, ['--verbosity='])
[ "def", "test_manage_py", "(", "self", ")", ":", "self", ".", "_user_input", "(", "'manage.py sqlall --verb'", ")", "output", "=", "self", ".", "_run_autocomplete", "(", ")", "self", ".", "assertEqual", "(", "output", ",", "[", "'--verbosity='", "]", ")" ]
[ 67, 4 ]
[ 71, 50 ]
python
en
['en', 'en', 'en']
True
BashCompletionTests.test_custom_command
(self)
A custom command can autocomplete option flags
A custom command can autocomplete option flags
def test_custom_command(self): "A custom command can autocomplete option flags" self._user_input('django-admin test_command --l') output = self._run_autocomplete() self.assertEqual(output, ['--list'])
[ "def", "test_custom_command", "(", "self", ")", ":", "self", ".", "_user_input", "(", "'django-admin test_command --l'", ")", "output", "=", "self", ".", "_run_autocomplete", "(", ")", "self", ".", "assertEqual", "(", "output", ",", "[", "'--list'", "]", ")" ]
[ 73, 4 ]
[ 77, 44 ]
python
en
['en', 'en', 'en']
True
BashCompletionTests.test_subcommands
(self)
Subcommands can be autocompleted
Subcommands can be autocompleted
def test_subcommands(self): "Subcommands can be autocompleted" self._user_input('django-admin sql') output = self._run_autocomplete() self.assertEqual(output, ['sql sqlall sqlclear sqlcustom sqldropindexes sqlflush sqlindexes sqlmigrate sqlsequencereset'])
[ "def", "test_subcommands", "(", "self", ")", ":", "self", ".", "_user_input", "(", "'django-admin sql'", ")", "output", "=", "self", ".", "_run_autocomplete", "(", ")", "self", ".", "assertEqual", "(", "output", ",", "[", "'sql sqlall sqlclear sqlcustom sqldropind...
[ 79, 4 ]
[ 83, 130 ]
python
en
['en', 'en', 'en']
True
BashCompletionTests.test_completed_subcommand
(self)
Show option flags in case a subcommand is completed
Show option flags in case a subcommand is completed
def test_completed_subcommand(self): "Show option flags in case a subcommand is completed" self._user_input('django-admin startproject ') # Trailing whitespace output = self._run_autocomplete() for item in output: self.assertTrue(item.startswith('--'))
[ "def", "test_completed_subcommand", "(", "self", ")", ":", "self", ".", "_user_input", "(", "'django-admin startproject '", ")", "# Trailing whitespace", "output", "=", "self", ".", "_run_autocomplete", "(", ")", "for", "item", "in", "output", ":", "self", ".", ...
[ 85, 4 ]
[ 90, 50 ]
python
en
['en', 'en', 'en']
True
BashCompletionTests.test_help
(self)
No errors, just an empty list if there are no autocomplete options
No errors, just an empty list if there are no autocomplete options
def test_help(self): "No errors, just an empty list if there are no autocomplete options" self._user_input('django-admin help --') output = self._run_autocomplete() self.assertEqual(output, [''])
[ "def", "test_help", "(", "self", ")", ":", "self", ".", "_user_input", "(", "'django-admin help --'", ")", "output", "=", "self", ".", "_run_autocomplete", "(", ")", "self", ".", "assertEqual", "(", "output", ",", "[", "''", "]", ")" ]
[ 92, 4 ]
[ 96, 38 ]
python
en
['en', 'en', 'en']
True
BashCompletionTests.test_runfcgi
(self)
Command arguments will be autocompleted
Command arguments will be autocompleted
def test_runfcgi(self): "Command arguments will be autocompleted" self._user_input('django-admin runfcgi h') output = self._run_autocomplete() self.assertEqual(output, ['host='])
[ "def", "test_runfcgi", "(", "self", ")", ":", "self", ".", "_user_input", "(", "'django-admin runfcgi h'", ")", "output", "=", "self", ".", "_run_autocomplete", "(", ")", "self", ".", "assertEqual", "(", "output", ",", "[", "'host='", "]", ")" ]
[ 98, 4 ]
[ 102, 43 ]
python
en
['en', 'en', 'en']
True
BashCompletionTests.test_app_completion
(self)
Application names will be autocompleted for an AppCommand
Application names will be autocompleted for an AppCommand
def test_app_completion(self): "Application names will be autocompleted for an AppCommand" self._user_input('django-admin sqlall a') output = self._run_autocomplete() a_labels = sorted(app_config.label for app_config in apps.get_app_configs() if app_config.label.s...
[ "def", "test_app_completion", "(", "self", ")", ":", "self", ".", "_user_input", "(", "'django-admin sqlall a'", ")", "output", "=", "self", ".", "_run_autocomplete", "(", ")", "a_labels", "=", "sorted", "(", "app_config", ".", "label", "for", "app_config", "i...
[ 104, 4 ]
[ 111, 42 ]
python
en
['en', 'en', 'en']
True
AutodetectorTests.make_project_state
(self, model_states)
Shortcut to make ProjectStates from lists of predefined models
Shortcut to make ProjectStates from lists of predefined models
def make_project_state(self, model_states): "Shortcut to make ProjectStates from lists of predefined models" project_state = ProjectState() for model_state in model_states: project_state.add_model_state(model_state.clone()) return project_state
[ "def", "make_project_state", "(", "self", ",", "model_states", ")", ":", "project_state", "=", "ProjectState", "(", ")", "for", "model_state", "in", "model_states", ":", "project_state", ".", "add_model_state", "(", "model_state", ".", "clone", "(", ")", ")", ...
[ 150, 4 ]
[ 155, 28 ]
python
en
['en', 'en', 'en']
True