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
GetOldMessagesTest.setup_web_public_test
(self, num_web_public_message: int = 1)
Send N+2 messages, N in a web-public stream, then one in a non web-public stream and then a private message.
Send N+2 messages, N in a web-public stream, then one in a non web-public stream and then a private message.
def setup_web_public_test(self, num_web_public_message: int = 1) -> None: """ Send N+2 messages, N in a web-public stream, then one in a non web-public stream and then a private message. """ user_profile = self.example_user("iago") self.login("iago") web_public_st...
[ "def", "setup_web_public_test", "(", "self", ",", "num_web_public_message", ":", "int", "=", "1", ")", "->", "None", ":", "user_profile", "=", "self", ".", "example_user", "(", "\"iago\"", ")", "self", ".", "login", "(", "\"iago\"", ")", "web_public_stream", ...
[ 1558, 4 ]
[ 1580, 21 ]
python
en
['en', 'error', 'th']
False
GetOldMessagesTest.test_get_messages_with_web_public
(self)
An unauthenticated call to GET /json/messages with valid parameters including `streams:web-public` narrow returns list of messages in the `web-public` streams.
An unauthenticated call to GET /json/messages with valid parameters including `streams:web-public` narrow returns list of messages in the `web-public` streams.
def test_get_messages_with_web_public(self) -> None: """ An unauthenticated call to GET /json/messages with valid parameters including `streams:web-public` narrow returns list of messages in the `web-public` streams. """ self.setup_web_public_test(num_web_public_message=8...
[ "def", "test_get_messages_with_web_public", "(", "self", ")", "->", "None", ":", "self", ".", "setup_web_public_test", "(", "num_web_public_message", "=", "8", ")", "post_params", "=", "{", "\"anchor\"", ":", "\"first_unread\"", ",", "\"num_before\"", ":", "5", ",...
[ 1612, 4 ]
[ 1631, 62 ]
python
en
['en', 'error', 'th']
False
GetOldMessagesTest.test_client_avatar
(self)
The client_gravatar flag determines whether we send avatar_url.
The client_gravatar flag determines whether we send avatar_url.
def test_client_avatar(self) -> None: """ The client_gravatar flag determines whether we send avatar_url. """ hamlet = self.example_user("hamlet") self.login_user(hamlet) do_set_realm_property( hamlet.realm, "email_address_visibility", ...
[ "def", "test_client_avatar", "(", "self", ")", "->", "None", ":", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "self", ".", "login_user", "(", "hamlet", ")", "do_set_realm_property", "(", "hamlet", ".", "realm", ",", "\"email_address_vis...
[ 1633, 4 ]
[ 1666, 60 ]
python
en
['en', 'error', 'th']
False
GetOldMessagesTest.test_get_messages_with_narrow_pm_with
(self)
A request for old messages with a narrow by pm-with only returns conversations with that user.
A request for old messages with a narrow by pm-with only returns conversations with that user.
def test_get_messages_with_narrow_pm_with(self) -> None: """ A request for old messages with a narrow by pm-with only returns conversations with that user. """ me = self.example_user("hamlet") def dr_emails(dr: DisplayRecipientT) -> str: assert isinstance(dr,...
[ "def", "test_get_messages_with_narrow_pm_with", "(", "self", ")", "->", "None", ":", "me", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "def", "dr_emails", "(", "dr", ":", "DisplayRecipientT", ")", "->", "str", ":", "assert", "isinstance", "(", ...
[ 1668, 4 ]
[ 1720, 81 ]
python
en
['en', 'error', 'th']
False
GetOldMessagesTest.test_get_messages_with_narrow_group_pm_with
(self)
A request for old messages with a narrow by group-pm-with only returns group-private conversations with that user.
A request for old messages with a narrow by group-pm-with only returns group-private conversations with that user.
def test_get_messages_with_narrow_group_pm_with(self) -> None: """ A request for old messages with a narrow by group-pm-with only returns group-private conversations with that user. """ me = self.example_user("hamlet") iago = self.example_user("iago") cordelia = ...
[ "def", "test_get_messages_with_narrow_group_pm_with", "(", "self", ")", "->", "None", ":", "me", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "iago", "=", "self", ".", "example_user", "(", "\"iago\"", ")", "cordelia", "=", "self", ".", "example_us...
[ 1734, 4 ]
[ 1788, 73 ]
python
en
['en', 'error', 'th']
False
GetOldMessagesTest.test_get_messages_with_narrow_stream
(self)
A request for old messages with a narrow by stream only returns messages for that stream.
A request for old messages with a narrow by stream only returns messages for that stream.
def test_get_messages_with_narrow_stream(self) -> None: """ A request for old messages with a narrow by stream only returns messages for that stream. """ self.login("hamlet") # We need to subscribe to a stream and then send a message to # it to ensure that we actu...
[ "def", "test_get_messages_with_narrow_stream", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "# We need to subscribe to a stream and then send a message to", "# it to ensure that we actually have a stream message in this", "# narrow view.", "sel...
[ 1862, 4 ]
[ 1886, 78 ]
python
en
['en', 'error', 'th']
False
GetOldMessagesTest.test_get_messages_with_narrow_stream_mit_unicode_regex
(self)
A request for old messages for a user in the mit.edu relam with Unicode stream name should be correctly escaped in the database query.
A request for old messages for a user in the mit.edu relam with Unicode stream name should be correctly escaped in the database query.
def test_get_messages_with_narrow_stream_mit_unicode_regex(self) -> None: """ A request for old messages for a user in the mit.edu relam with Unicode stream name should be correctly escaped in the database query. """ user = self.mit_user("starnine") self.login_user(user) ...
[ "def", "test_get_messages_with_narrow_stream_mit_unicode_regex", "(", "self", ")", "->", "None", ":", "user", "=", "self", ".", "mit_user", "(", "\"starnine\"", ")", "self", ".", "login_user", "(", "user", ")", "# We need to susbcribe to a stream and then send a message t...
[ 1899, 4 ]
[ 1931, 64 ]
python
en
['en', 'error', 'th']
False
GetOldMessagesTest.test_get_messages_with_narrow_topic_mit_unicode_regex
(self)
A request for old messages for a user in the mit.edu realm with Unicode topic name should be correctly escaped in the database query.
A request for old messages for a user in the mit.edu realm with Unicode topic name should be correctly escaped in the database query.
def test_get_messages_with_narrow_topic_mit_unicode_regex(self) -> None: """ A request for old messages for a user in the mit.edu realm with Unicode topic name should be correctly escaped in the database query. """ mit_user_profile = self.mit_user("starnine") self.login_u...
[ "def", "test_get_messages_with_narrow_topic_mit_unicode_regex", "(", "self", ")", "->", "None", ":", "mit_user_profile", "=", "self", ".", "mit_user", "(", "\"starnine\"", ")", "self", ".", "login_user", "(", "mit_user_profile", ")", "# We need to susbcribe to a stream an...
[ 1933, 4 ]
[ 1961, 64 ]
python
en
['en', 'error', 'th']
False
GetOldMessagesTest.test_get_messages_with_narrow_topic_mit_personal
(self)
We handle .d grouping for MIT realm personal messages correctly.
We handle .d grouping for MIT realm personal messages correctly.
def test_get_messages_with_narrow_topic_mit_personal(self) -> None: """ We handle .d grouping for MIT realm personal messages correctly. """ mit_user_profile = self.mit_user("starnine") # We need to susbcribe to a stream and then send a message to # it to ensure that we ...
[ "def", "test_get_messages_with_narrow_topic_mit_personal", "(", "self", ")", "->", "None", ":", "mit_user_profile", "=", "self", ".", "mit_user", "(", "\"starnine\"", ")", "# We need to susbcribe to a stream and then send a message to", "# it to ensure that we actually have a strea...
[ 1963, 4 ]
[ 1995, 64 ]
python
en
['en', 'error', 'th']
False
GetOldMessagesTest.test_get_messages_with_narrow_sender
(self)
A request for old messages with a narrow by sender only returns messages sent by that person.
A request for old messages with a narrow by sender only returns messages sent by that person.
def test_get_messages_with_narrow_sender(self) -> None: """ A request for old messages with a narrow by sender only returns messages sent by that person. """ self.login("hamlet") hamlet = self.example_user("hamlet") othello = self.example_user("othello") ...
[ "def", "test_get_messages_with_narrow_sender", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "othello", "=", "self", ".", "example_user", "(", "\"othello\"...
[ 1997, 4 ]
[ 2021, 66 ]
python
en
['en', 'error', 'th']
False
GetOldMessagesTest.test_get_messages_with_search_not_subscribed
(self)
Verify support for searching a stream you're not subscribed to
Verify support for searching a stream you're not subscribed to
def test_get_messages_with_search_not_subscribed(self) -> None: """Verify support for searching a stream you're not subscribed to""" self.subscribe(self.example_user("hamlet"), "newstream") self.send_stream_message( sender=self.example_user("hamlet"), stream_name="newstre...
[ "def", "test_get_messages_with_search_not_subscribed", "(", "self", ")", "->", "None", ":", "self", ".", "subscribe", "(", "self", ".", "example_user", "(", "\"hamlet\"", ")", ",", "\"newstream\"", ")", "self", ".", "send_stream_message", "(", "sender", "=", "se...
[ 2246, 4 ]
[ 2275, 9 ]
python
en
['en', 'en', 'en']
True
GetOldMessagesTest.test_get_messages_with_only_searching_anchor
(self)
Test that specifying an anchor but 0 for num_before and num_after returns at most 1 message.
Test that specifying an anchor but 0 for num_before and num_after returns at most 1 message.
def test_get_messages_with_only_searching_anchor(self) -> None: """ Test that specifying an anchor but 0 for num_before and num_after returns at most 1 message. """ self.login("cordelia") cordelia = self.example_user("cordelia") anchor = self.send_stream_message...
[ "def", "test_get_messages_with_only_searching_anchor", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"cordelia\"", ")", "cordelia", "=", "self", ".", "example_user", "(", "\"cordelia\"", ")", "anchor", "=", "self", ".", "send_stream_message", ...
[ 2467, 4 ]
[ 2493, 52 ]
python
en
['en', 'error', 'th']
False
PostGISAdapter.__init__
(self, obj, geography=False)
Initialize on the spatial object.
Initialize on the spatial object.
def __init__(self, obj, geography=False): """ Initialize on the spatial object. """ self.is_geometry = isinstance(obj, (GEOSGeometry, PostGISAdapter)) # Getting the WKB (in string form, to allow easy pickling of # the adaptor) and the SRID from the geometry or raster. ...
[ "def", "__init__", "(", "self", ",", "obj", ",", "geography", "=", "False", ")", ":", "self", ".", "is_geometry", "=", "isinstance", "(", "obj", ",", "(", "GEOSGeometry", ",", "PostGISAdapter", ")", ")", "# Getting the WKB (in string form, to allow easy pickling o...
[ 11, 4 ]
[ 26, 34 ]
python
en
['en', 'error', 'th']
False
PostGISAdapter.__conform__
(self, proto)
Does the given protocol conform to what Psycopg2 expects?
Does the given protocol conform to what Psycopg2 expects?
def __conform__(self, proto): """Does the given protocol conform to what Psycopg2 expects?""" if proto == ISQLQuote: return self else: raise Exception('Error implementing psycopg2 protocol. Is psycopg2 installed?')
[ "def", "__conform__", "(", "self", ",", "proto", ")", ":", "if", "proto", "==", "ISQLQuote", ":", "return", "self", "else", ":", "raise", "Exception", "(", "'Error implementing psycopg2 protocol. Is psycopg2 installed?'", ")" ]
[ 28, 4 ]
[ 33, 91 ]
python
en
['en', 'en', 'en']
True
PostGISAdapter.prepare
(self, conn)
This method allows escaping the binary in the style required by the server's `standard_conforming_string` setting.
This method allows escaping the binary in the style required by the server's `standard_conforming_string` setting.
def prepare(self, conn): """ This method allows escaping the binary in the style required by the server's `standard_conforming_string` setting. """ if self.is_geometry: self._adapter.prepare(conn)
[ "def", "prepare", "(", "self", ",", "conn", ")", ":", "if", "self", ".", "is_geometry", ":", "self", ".", "_adapter", ".", "prepare", "(", "conn", ")" ]
[ 44, 4 ]
[ 50, 39 ]
python
en
['en', 'error', 'th']
False
PostGISAdapter.getquoted
(self)
Return a properly quoted string for use in PostgreSQL/PostGIS.
Return a properly quoted string for use in PostgreSQL/PostGIS.
def getquoted(self): """ Return a properly quoted string for use in PostgreSQL/PostGIS. """ if self.is_geometry: # Psycopg will figure out whether to use E'\\000' or '\000'. return '%s(%s)' % ( 'ST_GeogFromWKB' if self.geography else 'ST_GeomFromEW...
[ "def", "getquoted", "(", "self", ")", ":", "if", "self", ".", "is_geometry", ":", "# Psycopg will figure out whether to use E'\\\\000' or '\\000'.", "return", "'%s(%s)'", "%", "(", "'ST_GeogFromWKB'", "if", "self", ".", "geography", "else", "'ST_GeomFromEWKB'", ",", "...
[ 52, 4 ]
[ 64, 45 ]
python
en
['en', 'error', 'th']
False
TargetPython.__init__
( self, platform=None, # type: Optional[str] py_version_info=None, # type: Optional[Tuple[int, ...]] abi=None, # type: Optional[str] implementation=None, # type: Optional[str] )
:param platform: A string or None. If None, searches for packages that are supported by the current system. Otherwise, will find packages that can be built on the platform passed in. These packages will only be downloaded for distribution: they will not be built ...
:param platform: A string or None. If None, searches for packages that are supported by the current system. Otherwise, will find packages that can be built on the platform passed in. These packages will only be downloaded for distribution: they will not be built ...
def __init__( self, platform=None, # type: Optional[str] py_version_info=None, # type: Optional[Tuple[int, ...]] abi=None, # type: Optional[str] implementation=None, # type: Optional[str] ): # type: (...) -> None """ :param platform: A string or No...
[ "def", "__init__", "(", "self", ",", "platform", "=", "None", ",", "# type: Optional[str]", "py_version_info", "=", "None", ",", "# type: Optional[Tuple[int, ...]]", "abi", "=", "None", ",", "# type: Optional[str]", "implementation", "=", "None", ",", "# type: Optiona...
[ 22, 4 ]
[ 61, 31 ]
python
en
['en', 'error', 'th']
False
TargetPython.format_given
(self)
Format the given, non-None attributes for display.
Format the given, non-None attributes for display.
def format_given(self): # type: () -> str """ Format the given, non-None attributes for display. """ display_version = None if self._given_py_version_info is not None: display_version = '.'.join( str(part) for part in self._given_py_version_inf...
[ "def", "format_given", "(", "self", ")", ":", "# type: () -> str", "display_version", "=", "None", "if", "self", ".", "_given_py_version_info", "is", "not", "None", ":", "display_version", "=", "'.'", ".", "join", "(", "str", "(", "part", ")", "for", "part",...
[ 63, 4 ]
[ 83, 9 ]
python
en
['en', 'error', 'th']
False
TargetPython.get_tags
(self)
Return the supported PEP 425 tags to check wheel candidates against. The tags are returned in order of preference (most preferred first).
Return the supported PEP 425 tags to check wheel candidates against.
def get_tags(self): # type: () -> List[Tag] """ Return the supported PEP 425 tags to check wheel candidates against. The tags are returned in order of preference (most preferred first). """ if self._valid_tags is None: # Pass versions=None if no py_version_in...
[ "def", "get_tags", "(", "self", ")", ":", "# type: () -> List[Tag]", "if", "self", ".", "_valid_tags", "is", "None", ":", "# Pass versions=None if no py_version_info was given since", "# versions=None uses special default logic.", "py_version_info", "=", "self", ".", "_given_...
[ 85, 4 ]
[ 109, 31 ]
python
en
['en', 'error', 'th']
False
SpatialReference.__init__
(self, srs_input='', srs_type='user')
Create a GDAL OSR Spatial Reference object from the given input. The input may be string of OGC Well Known Text (WKT), an integer EPSG code, a PROJ.4 string, and/or a projection "well known" shorthand string (one of 'WGS84', 'WGS72', 'NAD27', 'NAD83').
Create a GDAL OSR Spatial Reference object from the given input. The input may be string of OGC Well Known Text (WKT), an integer EPSG code, a PROJ.4 string, and/or a projection "well known" shorthand string (one of 'WGS84', 'WGS72', 'NAD27', 'NAD83').
def __init__(self, srs_input='', srs_type='user'): """ Create a GDAL OSR Spatial Reference object from the given input. The input may be string of OGC Well Known Text (WKT), an integer EPSG code, a PROJ.4 string, and/or a projection "well known" shorthand string (one of 'WGS84', ...
[ "def", "__init__", "(", "self", ",", "srs_input", "=", "''", ",", "srs_type", "=", "'user'", ")", ":", "if", "srs_type", "==", "'wkt'", ":", "self", ".", "ptr", "=", "capi", ".", "new_srs", "(", "c_char_p", "(", "b''", ")", ")", "self", ".", "impor...
[ 44, 4 ]
[ 91, 39 ]
python
en
['en', 'error', 'th']
False
SpatialReference.__getitem__
(self, target)
Return the value of the given string attribute node, None if the node doesn't exist. Can also take a tuple as a parameter, (target, child), where child is the index of the attribute in the WKT. For example: >>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]' ...
Return the value of the given string attribute node, None if the node doesn't exist. Can also take a tuple as a parameter, (target, child), where child is the index of the attribute in the WKT. For example:
def __getitem__(self, target): """ Return the value of the given string attribute node, None if the node doesn't exist. Can also take a tuple as a parameter, (target, child), where child is the index of the attribute in the WKT. For example: >>> wkt = 'GEOGCS["WGS 84", DATUM["...
[ "def", "__getitem__", "(", "self", ",", "target", ")", ":", "if", "isinstance", "(", "target", ",", "tuple", ")", ":", "return", "self", ".", "attr_value", "(", "*", "target", ")", "else", ":", "return", "self", ".", "attr_value", "(", "target", ")" ]
[ 93, 4 ]
[ 119, 42 ]
python
en
['en', 'error', 'th']
False
SpatialReference.__str__
(self)
Use 'pretty' WKT.
Use 'pretty' WKT.
def __str__(self): "Use 'pretty' WKT." return self.pretty_wkt
[ "def", "__str__", "(", "self", ")", ":", "return", "self", ".", "pretty_wkt" ]
[ 121, 4 ]
[ 123, 30 ]
python
en
['en', 'cy', 'en']
True
SpatialReference.attr_value
(self, target, index=0)
The attribute value for the given target node (e.g. 'PROJCS'). The index keyword specifies an index of the child node to return.
The attribute value for the given target node (e.g. 'PROJCS'). The index keyword specifies an index of the child node to return.
def attr_value(self, target, index=0): """ The attribute value for the given target node (e.g. 'PROJCS'). The index keyword specifies an index of the child node to return. """ if not isinstance(target, str) or not isinstance(index, int): raise TypeError return...
[ "def", "attr_value", "(", "self", ",", "target", ",", "index", "=", "0", ")", ":", "if", "not", "isinstance", "(", "target", ",", "str", ")", "or", "not", "isinstance", "(", "index", ",", "int", ")", ":", "raise", "TypeError", "return", "capi", ".", ...
[ 126, 4 ]
[ 133, 72 ]
python
en
['en', 'error', 'th']
False
SpatialReference.auth_name
(self, target)
Return the authority name for the given string target node.
Return the authority name for the given string target node.
def auth_name(self, target): "Return the authority name for the given string target node." return capi.get_auth_name(self.ptr, force_bytes(target))
[ "def", "auth_name", "(", "self", ",", "target", ")", ":", "return", "capi", ".", "get_auth_name", "(", "self", ".", "ptr", ",", "force_bytes", "(", "target", ")", ")" ]
[ 135, 4 ]
[ 137, 64 ]
python
en
['en', 'en', 'en']
True
SpatialReference.auth_code
(self, target)
Return the authority code for the given string target node.
Return the authority code for the given string target node.
def auth_code(self, target): "Return the authority code for the given string target node." return capi.get_auth_code(self.ptr, force_bytes(target))
[ "def", "auth_code", "(", "self", ",", "target", ")", ":", "return", "capi", ".", "get_auth_code", "(", "self", ".", "ptr", ",", "force_bytes", "(", "target", ")", ")" ]
[ 139, 4 ]
[ 141, 64 ]
python
en
['en', 'en', 'en']
True
SpatialReference.clone
(self)
Return a clone of this SpatialReference object.
Return a clone of this SpatialReference object.
def clone(self): "Return a clone of this SpatialReference object." return SpatialReference(capi.clone_srs(self.ptr))
[ "def", "clone", "(", "self", ")", ":", "return", "SpatialReference", "(", "capi", ".", "clone_srs", "(", "self", ".", "ptr", ")", ")" ]
[ 143, 4 ]
[ 145, 57 ]
python
en
['en', 'en', 'en']
True
SpatialReference.from_esri
(self)
Morph this SpatialReference from ESRI's format to EPSG.
Morph this SpatialReference from ESRI's format to EPSG.
def from_esri(self): "Morph this SpatialReference from ESRI's format to EPSG." capi.morph_from_esri(self.ptr)
[ "def", "from_esri", "(", "self", ")", ":", "capi", ".", "morph_from_esri", "(", "self", ".", "ptr", ")" ]
[ 147, 4 ]
[ 149, 38 ]
python
en
['en', 'en', 'en']
True
SpatialReference.identify_epsg
(self)
This method inspects the WKT of this SpatialReference, and will add EPSG authority nodes where an EPSG identifier is applicable.
This method inspects the WKT of this SpatialReference, and will add EPSG authority nodes where an EPSG identifier is applicable.
def identify_epsg(self): """ This method inspects the WKT of this SpatialReference, and will add EPSG authority nodes where an EPSG identifier is applicable. """ capi.identify_epsg(self.ptr)
[ "def", "identify_epsg", "(", "self", ")", ":", "capi", ".", "identify_epsg", "(", "self", ".", "ptr", ")" ]
[ 151, 4 ]
[ 156, 36 ]
python
en
['en', 'error', 'th']
False
SpatialReference.to_esri
(self)
Morph this SpatialReference to ESRI's format.
Morph this SpatialReference to ESRI's format.
def to_esri(self): "Morph this SpatialReference to ESRI's format." capi.morph_to_esri(self.ptr)
[ "def", "to_esri", "(", "self", ")", ":", "capi", ".", "morph_to_esri", "(", "self", ".", "ptr", ")" ]
[ 158, 4 ]
[ 160, 36 ]
python
en
['en', 'en', 'en']
True
SpatialReference.validate
(self)
Check to see if the given spatial reference is valid.
Check to see if the given spatial reference is valid.
def validate(self): "Check to see if the given spatial reference is valid." capi.srs_validate(self.ptr)
[ "def", "validate", "(", "self", ")", ":", "capi", ".", "srs_validate", "(", "self", ".", "ptr", ")" ]
[ 162, 4 ]
[ 164, 35 ]
python
en
['en', 'en', 'en']
True
SpatialReference.name
(self)
Return the name of this Spatial Reference.
Return the name of this Spatial Reference.
def name(self): "Return the name of this Spatial Reference." if self.projected: return self.attr_value('PROJCS') elif self.geographic: return self.attr_value('GEOGCS') elif self.local: return self.attr_value('LOCAL_CS') else: return...
[ "def", "name", "(", "self", ")", ":", "if", "self", ".", "projected", ":", "return", "self", ".", "attr_value", "(", "'PROJCS'", ")", "elif", "self", ".", "geographic", ":", "return", "self", ".", "attr_value", "(", "'GEOGCS'", ")", "elif", "self", "."...
[ 168, 4 ]
[ 177, 23 ]
python
en
['en', 'en', 'en']
True
SpatialReference.srid
(self)
Return the SRID of top-level authority, or None if undefined.
Return the SRID of top-level authority, or None if undefined.
def srid(self): "Return the SRID of top-level authority, or None if undefined." try: return int(self.attr_value('AUTHORITY', 1)) except (TypeError, ValueError): return None
[ "def", "srid", "(", "self", ")", ":", "try", ":", "return", "int", "(", "self", ".", "attr_value", "(", "'AUTHORITY'", ",", "1", ")", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "return", "None" ]
[ 180, 4 ]
[ 185, 23 ]
python
en
['en', 'en', 'en']
True
SpatialReference.linear_name
(self)
Return the name of the linear units.
Return the name of the linear units.
def linear_name(self): "Return the name of the linear units." units, name = capi.linear_units(self.ptr, byref(c_char_p())) return name
[ "def", "linear_name", "(", "self", ")", ":", "units", ",", "name", "=", "capi", ".", "linear_units", "(", "self", ".", "ptr", ",", "byref", "(", "c_char_p", "(", ")", ")", ")", "return", "name" ]
[ 189, 4 ]
[ 192, 19 ]
python
en
['en', 'en', 'en']
True
SpatialReference.linear_units
(self)
Return the value of the linear units.
Return the value of the linear units.
def linear_units(self): "Return the value of the linear units." units, name = capi.linear_units(self.ptr, byref(c_char_p())) return units
[ "def", "linear_units", "(", "self", ")", ":", "units", ",", "name", "=", "capi", ".", "linear_units", "(", "self", ".", "ptr", ",", "byref", "(", "c_char_p", "(", ")", ")", ")", "return", "units" ]
[ 195, 4 ]
[ 198, 20 ]
python
en
['en', 'en', 'en']
True
SpatialReference.angular_name
(self)
Return the name of the angular units.
Return the name of the angular units.
def angular_name(self): "Return the name of the angular units." units, name = capi.angular_units(self.ptr, byref(c_char_p())) return name
[ "def", "angular_name", "(", "self", ")", ":", "units", ",", "name", "=", "capi", ".", "angular_units", "(", "self", ".", "ptr", ",", "byref", "(", "c_char_p", "(", ")", ")", ")", "return", "name" ]
[ 201, 4 ]
[ 204, 19 ]
python
en
['en', 'mi', 'en']
True
SpatialReference.angular_units
(self)
Return the value of the angular units.
Return the value of the angular units.
def angular_units(self): "Return the value of the angular units." units, name = capi.angular_units(self.ptr, byref(c_char_p())) return units
[ "def", "angular_units", "(", "self", ")", ":", "units", ",", "name", "=", "capi", ".", "angular_units", "(", "self", ".", "ptr", ",", "byref", "(", "c_char_p", "(", ")", ")", ")", "return", "units" ]
[ 207, 4 ]
[ 210, 20 ]
python
en
['en', 'en', 'en']
True
SpatialReference.units
(self)
Return a 2-tuple of the units value and the units name. Automatically determine whether to return the linear or angular units.
Return a 2-tuple of the units value and the units name. Automatically determine whether to return the linear or angular units.
def units(self): """ Return a 2-tuple of the units value and the units name. Automatically determine whether to return the linear or angular units. """ units, name = None, None if self.projected or self.local: units, name = capi.linear_units(self.ptr, byref(c_...
[ "def", "units", "(", "self", ")", ":", "units", ",", "name", "=", "None", ",", "None", "if", "self", ".", "projected", "or", "self", ".", "local", ":", "units", ",", "name", "=", "capi", ".", "linear_units", "(", "self", ".", "ptr", ",", "byref", ...
[ 213, 4 ]
[ 225, 28 ]
python
en
['en', 'error', 'th']
False
SpatialReference.ellipsoid
(self)
Return a tuple of the ellipsoid parameters: (semimajor axis, semiminor axis, and inverse flattening)
Return a tuple of the ellipsoid parameters: (semimajor axis, semiminor axis, and inverse flattening)
def ellipsoid(self): """ Return a tuple of the ellipsoid parameters: (semimajor axis, semiminor axis, and inverse flattening) """ return (self.semi_major, self.semi_minor, self.inverse_flattening)
[ "def", "ellipsoid", "(", "self", ")", ":", "return", "(", "self", ".", "semi_major", ",", "self", ".", "semi_minor", ",", "self", ".", "inverse_flattening", ")" ]
[ 229, 4 ]
[ 234, 74 ]
python
en
['en', 'error', 'th']
False
SpatialReference.semi_major
(self)
Return the Semi Major Axis for this Spatial Reference.
Return the Semi Major Axis for this Spatial Reference.
def semi_major(self): "Return the Semi Major Axis for this Spatial Reference." return capi.semi_major(self.ptr, byref(c_int()))
[ "def", "semi_major", "(", "self", ")", ":", "return", "capi", ".", "semi_major", "(", "self", ".", "ptr", ",", "byref", "(", "c_int", "(", ")", ")", ")" ]
[ 237, 4 ]
[ 239, 56 ]
python
en
['en', 'en', 'en']
True
SpatialReference.semi_minor
(self)
Return the Semi Minor Axis for this Spatial Reference.
Return the Semi Minor Axis for this Spatial Reference.
def semi_minor(self): "Return the Semi Minor Axis for this Spatial Reference." return capi.semi_minor(self.ptr, byref(c_int()))
[ "def", "semi_minor", "(", "self", ")", ":", "return", "capi", ".", "semi_minor", "(", "self", ".", "ptr", ",", "byref", "(", "c_int", "(", ")", ")", ")" ]
[ 242, 4 ]
[ 244, 56 ]
python
en
['en', 'en', 'en']
True
SpatialReference.inverse_flattening
(self)
Return the Inverse Flattening for this Spatial Reference.
Return the Inverse Flattening for this Spatial Reference.
def inverse_flattening(self): "Return the Inverse Flattening for this Spatial Reference." return capi.invflattening(self.ptr, byref(c_int()))
[ "def", "inverse_flattening", "(", "self", ")", ":", "return", "capi", ".", "invflattening", "(", "self", ".", "ptr", ",", "byref", "(", "c_int", "(", ")", ")", ")" ]
[ 247, 4 ]
[ 249, 59 ]
python
en
['en', 'en', 'en']
True
SpatialReference.geographic
(self)
Return True if this SpatialReference is geographic (root node is GEOGCS).
Return True if this SpatialReference is geographic (root node is GEOGCS).
def geographic(self): """ Return True if this SpatialReference is geographic (root node is GEOGCS). """ return bool(capi.isgeographic(self.ptr))
[ "def", "geographic", "(", "self", ")", ":", "return", "bool", "(", "capi", ".", "isgeographic", "(", "self", ".", "ptr", ")", ")" ]
[ 253, 4 ]
[ 258, 48 ]
python
en
['en', 'error', 'th']
False
SpatialReference.local
(self)
Return True if this SpatialReference is local (root node is LOCAL_CS).
Return True if this SpatialReference is local (root node is LOCAL_CS).
def local(self): "Return True if this SpatialReference is local (root node is LOCAL_CS)." return bool(capi.islocal(self.ptr))
[ "def", "local", "(", "self", ")", ":", "return", "bool", "(", "capi", ".", "islocal", "(", "self", ".", "ptr", ")", ")" ]
[ 261, 4 ]
[ 263, 43 ]
python
en
['en', 'en', 'en']
True
SpatialReference.projected
(self)
Return True if this SpatialReference is a projected coordinate system (root node is PROJCS).
Return True if this SpatialReference is a projected coordinate system (root node is PROJCS).
def projected(self): """ Return True if this SpatialReference is a projected coordinate system (root node is PROJCS). """ return bool(capi.isprojected(self.ptr))
[ "def", "projected", "(", "self", ")", ":", "return", "bool", "(", "capi", ".", "isprojected", "(", "self", ".", "ptr", ")", ")" ]
[ 266, 4 ]
[ 271, 47 ]
python
en
['en', 'error', 'th']
False
SpatialReference.import_epsg
(self, epsg)
Import the Spatial Reference from the EPSG code (an integer).
Import the Spatial Reference from the EPSG code (an integer).
def import_epsg(self, epsg): "Import the Spatial Reference from the EPSG code (an integer)." capi.from_epsg(self.ptr, epsg)
[ "def", "import_epsg", "(", "self", ",", "epsg", ")", ":", "capi", ".", "from_epsg", "(", "self", ".", "ptr", ",", "epsg", ")" ]
[ 274, 4 ]
[ 276, 38 ]
python
en
['en', 'en', 'en']
True
SpatialReference.import_proj
(self, proj)
Import the Spatial Reference from a PROJ.4 string.
Import the Spatial Reference from a PROJ.4 string.
def import_proj(self, proj): "Import the Spatial Reference from a PROJ.4 string." capi.from_proj(self.ptr, proj)
[ "def", "import_proj", "(", "self", ",", "proj", ")", ":", "capi", ".", "from_proj", "(", "self", ".", "ptr", ",", "proj", ")" ]
[ 278, 4 ]
[ 280, 38 ]
python
en
['en', 'en', 'en']
True
SpatialReference.import_user_input
(self, user_input)
Import the Spatial Reference from the given user input string.
Import the Spatial Reference from the given user input string.
def import_user_input(self, user_input): "Import the Spatial Reference from the given user input string." capi.from_user_input(self.ptr, force_bytes(user_input))
[ "def", "import_user_input", "(", "self", ",", "user_input", ")", ":", "capi", ".", "from_user_input", "(", "self", ".", "ptr", ",", "force_bytes", "(", "user_input", ")", ")" ]
[ 282, 4 ]
[ 284, 63 ]
python
en
['en', 'en', 'en']
True
SpatialReference.import_wkt
(self, wkt)
Import the Spatial Reference from OGC WKT (string)
Import the Spatial Reference from OGC WKT (string)
def import_wkt(self, wkt): "Import the Spatial Reference from OGC WKT (string)" capi.from_wkt(self.ptr, byref(c_char_p(force_bytes(wkt))))
[ "def", "import_wkt", "(", "self", ",", "wkt", ")", ":", "capi", ".", "from_wkt", "(", "self", ".", "ptr", ",", "byref", "(", "c_char_p", "(", "force_bytes", "(", "wkt", ")", ")", ")", ")" ]
[ 286, 4 ]
[ 288, 66 ]
python
en
['en', 'en', 'en']
True
SpatialReference.import_xml
(self, xml)
Import the Spatial Reference from an XML string.
Import the Spatial Reference from an XML string.
def import_xml(self, xml): "Import the Spatial Reference from an XML string." capi.from_xml(self.ptr, xml)
[ "def", "import_xml", "(", "self", ",", "xml", ")", ":", "capi", ".", "from_xml", "(", "self", ".", "ptr", ",", "xml", ")" ]
[ 290, 4 ]
[ 292, 36 ]
python
en
['en', 'en', 'en']
True
SpatialReference.wkt
(self)
Return the WKT representation of this Spatial Reference.
Return the WKT representation of this Spatial Reference.
def wkt(self): "Return the WKT representation of this Spatial Reference." return capi.to_wkt(self.ptr, byref(c_char_p()))
[ "def", "wkt", "(", "self", ")", ":", "return", "capi", ".", "to_wkt", "(", "self", ".", "ptr", ",", "byref", "(", "c_char_p", "(", ")", ")", ")" ]
[ 296, 4 ]
[ 298, 55 ]
python
en
['en', 'en', 'en']
True
SpatialReference.pretty_wkt
(self, simplify=0)
Return the 'pretty' representation of the WKT.
Return the 'pretty' representation of the WKT.
def pretty_wkt(self, simplify=0): "Return the 'pretty' representation of the WKT." return capi.to_pretty_wkt(self.ptr, byref(c_char_p()), simplify)
[ "def", "pretty_wkt", "(", "self", ",", "simplify", "=", "0", ")", ":", "return", "capi", ".", "to_pretty_wkt", "(", "self", ".", "ptr", ",", "byref", "(", "c_char_p", "(", ")", ")", ",", "simplify", ")" ]
[ 301, 4 ]
[ 303, 72 ]
python
en
['en', 'it', 'en']
True
SpatialReference.proj
(self)
Return the PROJ.4 representation for this Spatial Reference.
Return the PROJ.4 representation for this Spatial Reference.
def proj(self): "Return the PROJ.4 representation for this Spatial Reference." return capi.to_proj(self.ptr, byref(c_char_p()))
[ "def", "proj", "(", "self", ")", ":", "return", "capi", ".", "to_proj", "(", "self", ".", "ptr", ",", "byref", "(", "c_char_p", "(", ")", ")", ")" ]
[ 306, 4 ]
[ 308, 56 ]
python
en
['en', 'en', 'en']
True
SpatialReference.proj4
(self)
Alias for proj().
Alias for proj().
def proj4(self): "Alias for proj()." return self.proj
[ "def", "proj4", "(", "self", ")", ":", "return", "self", ".", "proj" ]
[ 311, 4 ]
[ 313, 24 ]
python
eo
['es', 'eo', 'ur']
False
SpatialReference.xml
(self, dialect='')
Return the XML representation of this Spatial Reference.
Return the XML representation of this Spatial Reference.
def xml(self, dialect=''): "Return the XML representation of this Spatial Reference." return capi.to_xml(self.ptr, byref(c_char_p()), force_bytes(dialect))
[ "def", "xml", "(", "self", ",", "dialect", "=", "''", ")", ":", "return", "capi", ".", "to_xml", "(", "self", ".", "ptr", ",", "byref", "(", "c_char_p", "(", ")", ")", ",", "force_bytes", "(", "dialect", ")", ")" ]
[ 316, 4 ]
[ 318, 77 ]
python
en
['en', 'en', 'en']
True
CoordTransform.__init__
(self, source, target)
Initialize on a source and target SpatialReference objects.
Initialize on a source and target SpatialReference objects.
def __init__(self, source, target): "Initialize on a source and target SpatialReference objects." if not isinstance(source, SpatialReference) or not isinstance(target, SpatialReference): raise TypeError('source and target must be of type SpatialReference') self.ptr = capi.new_ct(sour...
[ "def", "__init__", "(", "self", ",", "source", ",", "target", ")", ":", "if", "not", "isinstance", "(", "source", ",", "SpatialReference", ")", "or", "not", "isinstance", "(", "target", ",", "SpatialReference", ")", ":", "raise", "TypeError", "(", "'source...
[ 325, 4 ]
[ 331, 37 ]
python
en
['en', 'en', 'en']
True
RunnerMultiGPU.set_input
(self, X_batch=None)
Preprocessing the inputs before calling session.run() :param X_batch: A dictionary of inputs to the first sub-graph :return: A tuple, `(fetches, fd)`, with `fetches` being a list of Tensors to be fetches and `fd` the feed dictionary.
Preprocessing the inputs before calling session.run()
def set_input(self, X_batch=None): """ Preprocessing the inputs before calling session.run() :param X_batch: A dictionary of inputs to the first sub-graph :return: A tuple, `(fetches, fd)`, with `fetches` being a list of Tensors to be fetches and `fd` the feed dictionar...
[ "def", "set_input", "(", "self", ",", "X_batch", "=", "None", ")", ":", "inputs", "=", "self", ".", "inputs", "outputs", "=", "self", ".", "outputs", "# data for first gpu", "fd", "=", "{", "}", "if", "X_batch", "is", "not", "None", ":", "self", ".", ...
[ 63, 4 ]
[ 103, 26 ]
python
en
['en', 'error', 'th']
False
RunnerMultiGPU.proc_fvals
(self, fvals)
Postprocess the outputs of the Session.run(). Move the outputs of sub-graphs to next ones and return the output of the last sub-graph. :param fvals: A list of fetched values returned by Session.run() :return: A dictionary of fetched values returned by the last sub-graph.
Postprocess the outputs of the Session.run(). Move the outputs of sub-graphs to next ones and return the output of the last sub-graph.
def proc_fvals(self, fvals): """ Postprocess the outputs of the Session.run(). Move the outputs of sub-graphs to next ones and return the output of the last sub-graph. :param fvals: A list of fetched values returned by Session.run() :return: A dictionary of fetched values return...
[ "def", "proc_fvals", "(", "self", ",", "fvals", ")", ":", "inputs", "=", "self", ".", "inputs", "outputs", "=", "self", ".", "outputs", "# Move data to the next sub-graph for the next step", "cur", "=", "0", "for", "i", "in", "range", "(", "len", "(", "input...
[ 105, 4 ]
[ 136, 25 ]
python
en
['en', 'error', 'th']
False
RunnerSingleGPU.proc_fvals
(self, fvals)
Nothing to post-process on single GPU.
Nothing to post-process on single GPU.
def proc_fvals(self, fvals): """ Nothing to post-process on single GPU. """ return True
[ "def", "proc_fvals", "(", "self", ",", "fvals", ")", ":", "return", "True" ]
[ 154, 4 ]
[ 158, 19 ]
python
en
['en', 'error', 'th']
False
RunnerSingleGPU.is_finished
(self)
Single GPU trainer has no cache.
Single GPU trainer has no cache.
def is_finished(self): """ Single GPU trainer has no cache. """ return True
[ "def", "is_finished", "(", "self", ")", ":", "return", "True" ]
[ 160, 4 ]
[ 164, 19 ]
python
en
['en', 'error', 'th']
False
MiddlewareTest.test_response_without_messages
(self)
Makes sure that the response middleware is tolerant of messages not existing on request.
Makes sure that the response middleware is tolerant of messages not existing on request.
def test_response_without_messages(self): """ Makes sure that the response middleware is tolerant of messages not existing on request. """ request = http.HttpRequest() response = http.HttpResponse() self.middleware.process_response(request, response)
[ "def", "test_response_without_messages", "(", "self", ")", ":", "request", "=", "http", ".", "HttpRequest", "(", ")", "response", "=", "http", ".", "HttpResponse", "(", ")", "self", ".", "middleware", ".", "process_response", "(", "request", ",", "response", ...
[ 11, 4 ]
[ 18, 59 ]
python
en
['en', 'error', 'th']
False
test_vscode_ext_min_version
(mock_checks, mocker)
Test VSCode Extension Template Checks
Test VSCode Extension Template Checks
def test_vscode_ext_min_version(mock_checks, mocker): """Test VSCode Extension Template Checks""" assert checks.vscode_ext_min_version("ms-python.python") assert not checks.vscode_ext_min_version("ms-python.python", min_version="2019.9.34911") mock_subproc = mocker.patch.object(subprocess, "run") mo...
[ "def", "test_vscode_ext_min_version", "(", "mock_checks", ",", "mocker", ")", ":", "assert", "checks", ".", "vscode_ext_min_version", "(", "\"ms-python.python\"", ")", "assert", "not", "checks", ".", "vscode_ext_min_version", "(", "\"ms-python.python\"", ",", "min_versi...
[ 7, 0 ]
[ 13, 60 ]
python
en
['en', 'en', 'en']
True
ManagedTargetGroup.manage_targetgroup
(self)
Add and remove EC2 instances in optionally user supplied TargetGroup
Add and remove EC2 instances in optionally user supplied TargetGroup
def manage_targetgroup(self): """ Add and remove EC2 instances in optionally user supplied TargetGroup """ cache = {} running_instances = self.ec2.get_instances(State="running", ScalingState="-excluded") # Add excluded instances explicitly marked for forced inclusion to...
[ "def", "manage_targetgroup", "(", "self", ")", ":", "cache", "=", "{", "}", "running_instances", "=", "self", ".", "ec2", ".", "get_instances", "(", "State", "=", "\"running\"", ",", "ScalingState", "=", "\"-excluded\"", ")", "# Add excluded instances explicitly m...
[ 211, 4 ]
[ 231, 74 ]
python
en
['en', 'error', 'th']
False
get_view
(request)
A simple view that expects a GET request, and returns a rendered template
A simple view that expects a GET request, and returns a rendered template
def get_view(request): "A simple view that expects a GET request, and returns a rendered template" t = Template('This is a test. {{ var }} is the value.', name='GET Template') c = Context({'var': request.GET.get('var', 42)}) return HttpResponse(t.render(c))
[ "def", "get_view", "(", "request", ")", ":", "t", "=", "Template", "(", "'This is a test. {{ var }} is the value.'", ",", "name", "=", "'GET Template'", ")", "c", "=", "Context", "(", "{", "'var'", ":", "request", ".", "GET", ".", "get", "(", "'var'", ",",...
[ 14, 0 ]
[ 19, 36 ]
python
en
['en', 'en', 'en']
True
post_view
(request)
A view that expects a POST, and returns a different template depending on whether any POST data is available
A view that expects a POST, and returns a different template depending on whether any POST data is available
def post_view(request): """A view that expects a POST, and returns a different template depending on whether any POST data is available """ if request.method == 'POST': if request.POST: t = Template('Data received: {{ data }} is the value.', name='POST Template') c = Cont...
[ "def", "post_view", "(", "request", ")", ":", "if", "request", ".", "method", "==", "'POST'", ":", "if", "request", ".", "POST", ":", "t", "=", "Template", "(", "'Data received: {{ data }} is the value.'", ",", "name", "=", "'POST Template'", ")", "c", "=", ...
[ 22, 0 ]
[ 37, 36 ]
python
en
['en', 'en', 'en']
True
view_with_header
(request)
A view that has a custom header
A view that has a custom header
def view_with_header(request): "A view that has a custom header" response = HttpResponse() response['X-DJANGO-TEST'] = 'Slartibartfast' return response
[ "def", "view_with_header", "(", "request", ")", ":", "response", "=", "HttpResponse", "(", ")", "response", "[", "'X-DJANGO-TEST'", "]", "=", "'Slartibartfast'", "return", "response" ]
[ 40, 0 ]
[ 44, 19 ]
python
en
['en', 'gd', 'en']
True
raw_post_view
(request)
A view which expects raw XML to be posted and returns content extracted from the XML
A view which expects raw XML to be posted and returns content extracted from the XML
def raw_post_view(request): """A view which expects raw XML to be posted and returns content extracted from the XML""" if request.method == 'POST': root = parseString(request.body) first_book = root.firstChild.firstChild title, author = [n.firstChild.nodeValue for n in first_book.chi...
[ "def", "raw_post_view", "(", "request", ")", ":", "if", "request", ".", "method", "==", "'POST'", ":", "root", "=", "parseString", "(", "request", ".", "body", ")", "first_book", "=", "root", ".", "firstChild", ".", "firstChild", "title", ",", "author", ...
[ 47, 0 ]
[ 60, 36 ]
python
en
['en', 'en', 'en']
True
redirect_view
(request)
A view that redirects all requests to the GET view
A view that redirects all requests to the GET view
def redirect_view(request): "A view that redirects all requests to the GET view" if request.GET: query = '?' + urlencode(request.GET, True) else: query = '' return HttpResponseRedirect('/get_view/' + query)
[ "def", "redirect_view", "(", "request", ")", ":", "if", "request", ".", "GET", ":", "query", "=", "'?'", "+", "urlencode", "(", "request", ".", "GET", ",", "True", ")", "else", ":", "query", "=", "''", "return", "HttpResponseRedirect", "(", "'/get_view/'...
[ 63, 0 ]
[ 69, 53 ]
python
en
['en', 'en', 'en']
True
view_with_secure
(request)
A view that indicates if the request was secure
A view that indicates if the request was secure
def view_with_secure(request): "A view that indicates if the request was secure" response = HttpResponse() response.test_was_secure_request = request.is_secure() response.test_server_port = request.META.get('SERVER_PORT', 80) return response
[ "def", "view_with_secure", "(", "request", ")", ":", "response", "=", "HttpResponse", "(", ")", "response", ".", "test_was_secure_request", "=", "request", ".", "is_secure", "(", ")", "response", ".", "test_server_port", "=", "request", ".", "META", ".", "get"...
[ 72, 0 ]
[ 77, 19 ]
python
en
['en', 'en', 'en']
True
double_redirect_view
(request)
A view that redirects all requests to a redirection view
A view that redirects all requests to a redirection view
def double_redirect_view(request): "A view that redirects all requests to a redirection view" return HttpResponseRedirect('/permanent_redirect_view/')
[ "def", "double_redirect_view", "(", "request", ")", ":", "return", "HttpResponseRedirect", "(", "'/permanent_redirect_view/'", ")" ]
[ 80, 0 ]
[ 82, 60 ]
python
en
['en', 'en', 'en']
True
bad_view
(request)
A view that returns a 404 with some error content
A view that returns a 404 with some error content
def bad_view(request): "A view that returns a 404 with some error content" return HttpResponseNotFound('Not found!. This page contains some MAGIC content')
[ "def", "bad_view", "(", "request", ")", ":", "return", "HttpResponseNotFound", "(", "'Not found!. This page contains some MAGIC content'", ")" ]
[ 85, 0 ]
[ 87, 84 ]
python
en
['en', 'en', 'en']
True
form_view
(request)
A view that tests a simple form
A view that tests a simple form
def form_view(request): "A view that tests a simple form" if request.method == 'POST': form = TestForm(request.POST) if form.is_valid(): t = Template('Valid POST data.', name='Valid POST Template') c = Context() else: t = Template('Invalid POST data. {...
[ "def", "form_view", "(", "request", ")", ":", "if", "request", ".", "method", "==", "'POST'", ":", "form", "=", "TestForm", "(", "request", ".", "POST", ")", "if", "form", ".", "is_valid", "(", ")", ":", "t", "=", "Template", "(", "'Valid POST data.'",...
[ 112, 0 ]
[ 127, 36 ]
python
en
['en', 'en', 'en']
True
form_view_with_template
(request)
A view that tests a simple form
A view that tests a simple form
def form_view_with_template(request): "A view that tests a simple form" if request.method == 'POST': form = TestForm(request.POST) if form.is_valid(): message = 'POST data OK' else: message = 'POST data has errors' else: form = TestForm() messa...
[ "def", "form_view_with_template", "(", "request", ")", ":", "if", "request", ".", "method", "==", "'POST'", ":", "form", "=", "TestForm", "(", "request", ".", "POST", ")", "if", "form", ".", "is_valid", "(", ")", ":", "message", "=", "'POST data OK'", "e...
[ 130, 0 ]
[ 146, 5 ]
python
en
['en', 'en', 'en']
True
formset_view
(request)
A view that tests a simple formset
A view that tests a simple formset
def formset_view(request): "A view that tests a simple formset" if request.method == 'POST': formset = TestFormSet(request.POST) if formset.is_valid(): t = Template('Valid POST data.', name='Valid POST Template') c = Context() else: t = Template('Inval...
[ "def", "formset_view", "(", "request", ")", ":", "if", "request", ".", "method", "==", "'POST'", ":", "formset", "=", "TestFormSet", "(", "request", ".", "POST", ")", "if", "formset", ".", "is_valid", "(", ")", ":", "t", "=", "Template", "(", "'Valid P...
[ 169, 0 ]
[ 185, 36 ]
python
en
['en', 'en', 'en']
True
login_protected_view
(request)
A simple view that is login protected.
A simple view that is login protected.
def login_protected_view(request): "A simple view that is login protected." t = Template('This is a login protected test. Username is {{ user.username }}.', name='Login Template') c = Context({'user': request.user}) return HttpResponse(t.render(c))
[ "def", "login_protected_view", "(", "request", ")", ":", "t", "=", "Template", "(", "'This is a login protected test. Username is {{ user.username }}.'", ",", "name", "=", "'Login Template'", ")", "c", "=", "Context", "(", "{", "'user'", ":", "request", ".", "user",...
[ 188, 0 ]
[ 193, 36 ]
python
en
['en', 'en', 'en']
True
login_protected_view_changed_redirect
(request)
A simple view that is login protected with a custom redirect field set
A simple view that is login protected with a custom redirect field set
def login_protected_view_changed_redirect(request): "A simple view that is login protected with a custom redirect field set" t = Template('This is a login protected test. Username is {{ user.username }}.', name='Login Template') c = Context({'user': request.user}) return HttpResponse(t.render(c))
[ "def", "login_protected_view_changed_redirect", "(", "request", ")", ":", "t", "=", "Template", "(", "'This is a login protected test. Username is {{ user.username }}.'", ",", "name", "=", "'Login Template'", ")", "c", "=", "Context", "(", "{", "'user'", ":", "request",...
[ 197, 0 ]
[ 202, 36 ]
python
en
['en', 'en', 'en']
True
_permission_protected_view
(request)
A simple view that is permission protected.
A simple view that is permission protected.
def _permission_protected_view(request): "A simple view that is permission protected." t = Template('This is a permission protected test. ' 'Username is {{ user.username }}. ' 'Permissions are {{ user.get_all_permissions }}.', name='Permissions Template') c...
[ "def", "_permission_protected_view", "(", "request", ")", ":", "t", "=", "Template", "(", "'This is a permission protected test. '", "'Username is {{ user.username }}. '", "'Permissions are {{ user.get_all_permissions }}.'", ",", "name", "=", "'Permissions Template'", ")", "c", ...
[ 206, 0 ]
[ 213, 36 ]
python
en
['en', 'en', 'en']
True
session_view
(request)
A view that modifies the session
A view that modifies the session
def session_view(request): "A view that modifies the session" request.session['tobacconist'] = 'hovercraft' t = Template('This is a view that modifies the session.', name='Session Modifying View Template') c = Context() return HttpResponse(t.render(c))
[ "def", "session_view", "(", "request", ")", ":", "request", ".", "session", "[", "'tobacconist'", "]", "=", "'hovercraft'", "t", "=", "Template", "(", "'This is a view that modifies the session.'", ",", "name", "=", "'Session Modifying View Template'", ")", "c", "="...
[ 241, 0 ]
[ 248, 36 ]
python
en
['en', 'en', 'en']
True
broken_view
(request)
A view which just raises an exception, simulating a broken view.
A view which just raises an exception, simulating a broken view.
def broken_view(request): """A view which just raises an exception, simulating a broken view.""" raise KeyError("Oops! Looks like you wrote some bad code.")
[ "def", "broken_view", "(", "request", ")", ":", "raise", "KeyError", "(", "\"Oops! Looks like you wrote some bad code.\"", ")" ]
[ 251, 0 ]
[ 253, 63 ]
python
en
['en', 'en', 'en']
True
BaseTestFormSet.clean
(self)
Checks that no two email addresses are the same.
Checks that no two email addresses are the same.
def clean(self): """Checks that no two email addresses are the same.""" if any(self.errors): # Don't bother validating the formset unless each form is valid return emails = [] for i in range(0, self.total_form_count()): form = self.forms[i] ...
[ "def", "clean", "(", "self", ")", ":", "if", "any", "(", "self", ".", "errors", ")", ":", "# Don't bother validating the formset unless each form is valid", "return", "emails", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "self", ".", "total_form...
[ 150, 4 ]
[ 164, 32 ]
python
en
['en', 'en', 'en']
True
TestMadryEtAlMultiGPU.test_single_vs_multi_gpu
(self)
Compare the strength of the single GPU and multi-GPU implementations.
Compare the strength of the single GPU and multi-GPU implementations.
def test_single_vs_multi_gpu(self): """ Compare the strength of the single GPU and multi-GPU implementations. """ x_val = np.random.rand(100, 2) x_val = np.array(x_val, dtype=np.float32) def multi_attack(attack): flags = { "ngpu": 1, ...
[ "def", "test_single_vs_multi_gpu", "(", "self", ")", ":", "x_val", "=", "np", ".", "random", ".", "rand", "(", "100", ",", "2", ")", "x_val", "=", "np", ".", "array", "(", "x_val", ",", "dtype", "=", "np", ".", "float32", ")", "def", "multi_attack", ...
[ 49, 4 ]
[ 83, 49 ]
python
en
['en', 'error', 'th']
False
cleanse_setting
(key, value)
Cleanse an individual setting key/value of sensitive content. If the value is a dictionary, recursively cleanse the keys in that dictionary.
Cleanse an individual setting key/value of sensitive content. If the value is a dictionary, recursively cleanse the keys in that dictionary.
def cleanse_setting(key, value): """ Cleanse an individual setting key/value of sensitive content. If the value is a dictionary, recursively cleanse the keys in that dictionary. """ try: if HIDDEN_SETTINGS.search(key): cleansed = CLEANSED_SUBSTITUTE else: if i...
[ "def", "cleanse_setting", "(", "key", ",", "value", ")", ":", "try", ":", "if", "HIDDEN_SETTINGS", ".", "search", "(", "key", ")", ":", "cleansed", "=", "CLEANSED_SUBSTITUTE", "else", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "cleanse...
[ 47, 0 ]
[ 68, 19 ]
python
en
['en', 'error', 'th']
False
get_safe_settings
()
Return a dictionary of the settings module with values of sensitive settings replaced with stars (*********).
Return a dictionary of the settings module with values of sensitive settings replaced with stars (*********).
def get_safe_settings(): """ Return a dictionary of the settings module with values of sensitive settings replaced with stars (*********). """ settings_dict = {} for k in dir(settings): if k.isupper(): settings_dict[k] = cleanse_setting(k, getattr(settings, k)) return set...
[ "def", "get_safe_settings", "(", ")", ":", "settings_dict", "=", "{", "}", "for", "k", "in", "dir", "(", "settings", ")", ":", "if", "k", ".", "isupper", "(", ")", ":", "settings_dict", "[", "k", "]", "=", "cleanse_setting", "(", "k", ",", "getattr",...
[ 71, 0 ]
[ 80, 24 ]
python
en
['en', 'error', 'th']
False
technical_500_response
(request, exc_type, exc_value, tb, status_code=500)
Create a technical server error response. The last three arguments are the values returned from sys.exc_info() and friends.
Create a technical server error response. The last three arguments are the values returned from sys.exc_info() and friends.
def technical_500_response(request, exc_type, exc_value, tb, status_code=500): """ Create a technical server error response. The last three arguments are the values returned from sys.exc_info() and friends. """ reporter = ExceptionReporter(request, exc_type, exc_value, tb) if request.is_ajax(): ...
[ "def", "technical_500_response", "(", "request", ",", "exc_type", ",", "exc_value", ",", "tb", ",", "status_code", "=", "500", ")", ":", "reporter", "=", "ExceptionReporter", "(", "request", ",", "exc_type", ",", "exc_value", ",", "tb", ")", "if", "request",...
[ 83, 0 ]
[ 94, 79 ]
python
en
['en', 'error', 'th']
False
technical_404_response
(request, exception)
Create a technical 404 error response. `exception` is the Http404.
Create a technical 404 error response. `exception` is the Http404.
def technical_404_response(request, exception): """Create a technical 404 error response. `exception` is the Http404.""" try: error_url = exception.args[0]['path'] except (IndexError, TypeError, KeyError): error_url = request.path_info[1:] # Trim leading slash try: tried = exce...
[ "def", "technical_404_response", "(", "request", ",", "exception", ")", ":", "try", ":", "error_url", "=", "exception", ".", "args", "[", "0", "]", "[", "'path'", "]", "except", "(", "IndexError", ",", "TypeError", ",", "KeyError", ")", ":", "error_url", ...
[ 458, 0 ]
[ 511, 70 ]
python
en
['en', 'en', 'en']
True
default_urlconf
(request)
Create an empty URLconf 404 error response.
Create an empty URLconf 404 error response.
def default_urlconf(request): """Create an empty URLconf 404 error response.""" with Path(CURRENT_DIR, 'templates', 'default_urlconf.html').open(encoding='utf-8') as fh: t = DEBUG_ENGINE.from_string(fh.read()) c = Context({ 'version': get_docs_version(), }) return HttpResponse(t.ren...
[ "def", "default_urlconf", "(", "request", ")", ":", "with", "Path", "(", "CURRENT_DIR", ",", "'templates'", ",", "'default_urlconf.html'", ")", ".", "open", "(", "encoding", "=", "'utf-8'", ")", "as", "fh", ":", "t", "=", "DEBUG_ENGINE", ".", "from_string", ...
[ 514, 0 ]
[ 522, 62 ]
python
en
['en', 'de', 'en']
True
SafeExceptionReporterFilter.is_active
(self, request)
This filter is to add safety in production environments (i.e. DEBUG is False). If DEBUG is True then your site is not safe anyway. This hook is provided as a convenience to easily activate or deactivate the filter on a per request basis.
This filter is to add safety in production environments (i.e. DEBUG is False). If DEBUG is True then your site is not safe anyway. This hook is provided as a convenience to easily activate or deactivate the filter on a per request basis.
def is_active(self, request): """ This filter is to add safety in production environments (i.e. DEBUG is False). If DEBUG is True then your site is not safe anyway. This hook is provided as a convenience to easily activate or deactivate the filter on a per request basis. ...
[ "def", "is_active", "(", "self", ",", "request", ")", ":", "return", "settings", ".", "DEBUG", "is", "False" ]
[ 130, 4 ]
[ 137, 38 ]
python
en
['en', 'error', 'th']
False
SafeExceptionReporterFilter.get_cleansed_multivaluedict
(self, request, multivaluedict)
Replace the keys in a MultiValueDict marked as sensitive with stars. This mitigates leaking sensitive POST parameters if something like request.POST['nonexistent_key'] throws an exception (#21098).
Replace the keys in a MultiValueDict marked as sensitive with stars. This mitigates leaking sensitive POST parameters if something like request.POST['nonexistent_key'] throws an exception (#21098).
def get_cleansed_multivaluedict(self, request, multivaluedict): """ Replace the keys in a MultiValueDict marked as sensitive with stars. This mitigates leaking sensitive POST parameters if something like request.POST['nonexistent_key'] throws an exception (#21098). """ se...
[ "def", "get_cleansed_multivaluedict", "(", "self", ",", "request", ",", "multivaluedict", ")", ":", "sensitive_post_parameters", "=", "getattr", "(", "request", ",", "'sensitive_post_parameters'", ",", "[", "]", ")", "if", "self", ".", "is_active", "(", "request",...
[ 139, 4 ]
[ 151, 29 ]
python
en
['en', 'error', 'th']
False
SafeExceptionReporterFilter.get_post_parameters
(self, request)
Replace the values of POST parameters marked as sensitive with stars (*********).
Replace the values of POST parameters marked as sensitive with stars (*********).
def get_post_parameters(self, request): """ Replace the values of POST parameters marked as sensitive with stars (*********). """ if request is None: return {} else: sensitive_post_parameters = getattr(request, 'sensitive_post_parameters', []) ...
[ "def", "get_post_parameters", "(", "self", ",", "request", ")", ":", "if", "request", "is", "None", ":", "return", "{", "}", "else", ":", "sensitive_post_parameters", "=", "getattr", "(", "request", ",", "'sensitive_post_parameters'", ",", "[", "]", ")", "if...
[ 153, 4 ]
[ 176, 35 ]
python
en
['en', 'error', 'th']
False
SafeExceptionReporterFilter.get_traceback_frame_variables
(self, request, tb_frame)
Replace the values of variables marked as sensitive with stars (*********).
Replace the values of variables marked as sensitive with stars (*********).
def get_traceback_frame_variables(self, request, tb_frame): """ Replace the values of variables marked as sensitive with stars (*********). """ # Loop through the frame's callers to see if the sensitive_variables # decorator was used. current_frame = tb_frame.f_ba...
[ "def", "get_traceback_frame_variables", "(", "self", ",", "request", ",", "tb_frame", ")", ":", "# Loop through the frame's callers to see if the sensitive_variables", "# decorator was used.", "current_frame", "=", "tb_frame", ".", "f_back", "sensitive_variables", "=", "None", ...
[ 192, 4 ]
[ 240, 31 ]
python
en
['en', 'error', 'th']
False
ExceptionReporter.get_traceback_data
(self)
Return a dictionary containing traceback information.
Return a dictionary containing traceback information.
def get_traceback_data(self): """Return a dictionary containing traceback information.""" if self.exc_type and issubclass(self.exc_type, TemplateDoesNotExist): self.template_does_not_exist = True self.postmortem = self.exc_value.chain or [self.exc_value] frames = self.ge...
[ "def", "get_traceback_data", "(", "self", ")", ":", "if", "self", ".", "exc_type", "and", "issubclass", "(", "self", ".", "exc_type", ",", "TemplateDoesNotExist", ")", ":", "self", ".", "template_does_not_exist", "=", "True", "self", ".", "postmortem", "=", ...
[ 257, 4 ]
[ 326, 16 ]
python
en
['en', 'en', 'en']
True
ExceptionReporter.get_traceback_html
(self)
Return HTML version of debug 500 HTTP error page.
Return HTML version of debug 500 HTTP error page.
def get_traceback_html(self): """Return HTML version of debug 500 HTTP error page.""" with Path(CURRENT_DIR, 'templates', 'technical_500.html').open(encoding='utf-8') as fh: t = DEBUG_ENGINE.from_string(fh.read()) c = Context(self.get_traceback_data(), use_l10n=False) return ...
[ "def", "get_traceback_html", "(", "self", ")", ":", "with", "Path", "(", "CURRENT_DIR", ",", "'templates'", ",", "'technical_500.html'", ")", ".", "open", "(", "encoding", "=", "'utf-8'", ")", "as", "fh", ":", "t", "=", "DEBUG_ENGINE", ".", "from_string", ...
[ 328, 4 ]
[ 333, 26 ]
python
en
['en', 'da', 'en']
True
ExceptionReporter.get_traceback_text
(self)
Return plain text version of debug 500 HTTP error page.
Return plain text version of debug 500 HTTP error page.
def get_traceback_text(self): """Return plain text version of debug 500 HTTP error page.""" with Path(CURRENT_DIR, 'templates', 'technical_500.txt').open(encoding='utf-8') as fh: t = DEBUG_ENGINE.from_string(fh.read()) c = Context(self.get_traceback_data(), autoescape=False, use_l10n...
[ "def", "get_traceback_text", "(", "self", ")", ":", "with", "Path", "(", "CURRENT_DIR", ",", "'templates'", ",", "'technical_500.txt'", ")", ".", "open", "(", "encoding", "=", "'utf-8'", ")", "as", "fh", ":", "t", "=", "DEBUG_ENGINE", ".", "from_string", "...
[ 335, 4 ]
[ 340, 26 ]
python
en
['en', 'en', 'en']
True
ExceptionReporter._get_lines_from_file
(self, filename, lineno, context_lines, loader=None, module_name=None)
Return context_lines before and after lineno from file. Return (pre_context_lineno, pre_context, context_line, post_context).
Return context_lines before and after lineno from file. Return (pre_context_lineno, pre_context, context_line, post_context).
def _get_lines_from_file(self, filename, lineno, context_lines, loader=None, module_name=None): """ Return context_lines before and after lineno from file. Return (pre_context_lineno, pre_context, context_line, post_context). """ source = None if hasattr(loader, 'get_sour...
[ "def", "_get_lines_from_file", "(", "self", ",", "filename", ",", "lineno", ",", "context_lines", ",", "loader", "=", "None", ",", "module_name", "=", "None", ")", ":", "source", "=", "None", "if", "hasattr", "(", "loader", ",", "'get_source'", ")", ":", ...
[ 342, 4 ]
[ 385, 67 ]
python
en
['en', 'error', 'th']
False
spsa
( model_fn, x, eps, nb_iter, norm=np.inf, clip_min=-np.inf, clip_max=np.inf, y=None, targeted=False, early_stop_loss_threshold=None, learning_rate=0.01, delta=0.01, spsa_samples=128, spsa_iters=1, is_debug=False, sanity_checks=True, )
This implements the SPSA adversary, as in https://arxiv.org/abs/1802.05666 (Uesato et al. 2018). SPSA is a gradient-free optimization method, which is useful when the model is non-differentiable, or more generally, the gradients do not point in useful directions. :param model_fn: A callable that t...
This implements the SPSA adversary, as in https://arxiv.org/abs/1802.05666 (Uesato et al. 2018). SPSA is a gradient-free optimization method, which is useful when the model is non-differentiable, or more generally, the gradients do not point in useful directions.
def spsa( model_fn, x, eps, nb_iter, norm=np.inf, clip_min=-np.inf, clip_max=np.inf, y=None, targeted=False, early_stop_loss_threshold=None, learning_rate=0.01, delta=0.01, spsa_samples=128, spsa_iters=1, is_debug=False, sanity_checks=True, ): """ ...
[ "def", "spsa", "(", "model_fn", ",", "x", ",", "eps", ",", "nb_iter", ",", "norm", "=", "np", ".", "inf", ",", "clip_min", "=", "-", "np", ".", "inf", ",", "clip_max", "=", "np", ".", "inf", ",", "y", "=", "None", ",", "targeted", "=", "False",...
[ 7, 0 ]
[ 167, 16 ]
python
en
['en', 'error', 'th']
False
_project_perturbation
( perturbation, norm, epsilon, input_image, clip_min=-np.inf, clip_max=np.inf )
Project `perturbation` onto L-infinity ball of radius `epsilon`. Also project into hypercube such that the resulting adversarial example is between clip_min and clip_max, if applicable. This is an in-place operation.
Project `perturbation` onto L-infinity ball of radius `epsilon`. Also project into hypercube such that the resulting adversarial example is between clip_min and clip_max, if applicable. This is an in-place operation.
def _project_perturbation( perturbation, norm, epsilon, input_image, clip_min=-np.inf, clip_max=np.inf ): """ Project `perturbation` onto L-infinity ball of radius `epsilon`. Also project into hypercube such that the resulting adversarial example is between clip_min and clip_max, if applicable. This...
[ "def", "_project_perturbation", "(", "perturbation", ",", "norm", ",", "epsilon", ",", "input_image", ",", "clip_min", "=", "-", "np", ".", "inf", ",", "clip_max", "=", "np", ".", "inf", ")", ":", "clipped_perturbation", "=", "clip_eta", "(", "perturbation",...
[ 170, 0 ]
[ 182, 63 ]
python
en
['en', 'error', 'th']
False
_compute_spsa_gradient
(loss_fn, x, delta, samples, iters)
Approximately compute the gradient of `loss_fn` at `x` using SPSA with the given parameters. The gradient is approximated by evaluating `iters` batches of `samples` size each.
Approximately compute the gradient of `loss_fn` at `x` using SPSA with the given parameters. The gradient is approximated by evaluating `iters` batches of `samples` size each.
def _compute_spsa_gradient(loss_fn, x, delta, samples, iters): """ Approximately compute the gradient of `loss_fn` at `x` using SPSA with the given parameters. The gradient is approximated by evaluating `iters` batches of `samples` size each. """ assert len(x) == 1 num_dims = len(x.size()) ...
[ "def", "_compute_spsa_gradient", "(", "loss_fn", ",", "x", ",", "delta", ",", "samples", ",", "iters", ")", ":", "assert", "len", "(", "x", ")", "==", "1", "num_dims", "=", "len", "(", "x", ".", "size", "(", ")", ")", "x_batch", "=", "x", ".", "e...
[ 185, 0 ]
[ 210, 64 ]
python
en
['en', 'error', 'th']
False
_margin_logit_loss
(logits, labels)
Computes difference between logits for `labels` and next highest logits. The loss is high when `label` is unlikely (targeted by default).
Computes difference between logits for `labels` and next highest logits.
def _margin_logit_loss(logits, labels): """ Computes difference between logits for `labels` and next highest logits. The loss is high when `label` is unlikely (targeted by default). """ correct_logits = logits.gather(1, labels[:, None]).squeeze(1) logit_indices = torch.arange( logits....
[ "def", "_margin_logit_loss", "(", "logits", ",", "labels", ")", ":", "correct_logits", "=", "logits", ".", "gather", "(", "1", ",", "labels", "[", ":", ",", "None", "]", ")", ".", "squeeze", "(", "1", ")", "logit_indices", "=", "torch", ".", "arange", ...
[ 213, 0 ]
[ 234, 48 ]
python
en
['en', 'error', 'th']
False
is_connection_dropped
(conn)
Returns True if the connection is dropped and should be closed. :param conn: :class:`httplib.HTTPConnection` object. Note: For platforms like AppEngine, this will always return ``False`` to let the platform handle connection recycling transparently for us.
Returns True if the connection is dropped and should be closed.
def is_connection_dropped(conn): # Platform-specific """ Returns True if the connection is dropped and should be closed. :param conn: :class:`httplib.HTTPConnection` object. Note: For platforms like AppEngine, this will always return ``False`` to let the platform handle connection recycli...
[ "def", "is_connection_dropped", "(", "conn", ")", ":", "# Platform-specific", "sock", "=", "getattr", "(", "conn", ",", "\"sock\"", ",", "False", ")", "if", "sock", "is", "False", ":", "# Platform-specific: AppEngine", "return", "False", "if", "sock", "is", "N...
[ 6, 0 ]
[ 25, 20 ]
python
en
['en', 'error', 'th']
False
create_connection
( address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None, socket_options=None, )
Connect to *address* and return the socket object. Convenience function. Connect to *address* (a 2-tuple ``(host, port)``) and return the socket object. Passing the optional *timeout* parameter will set the timeout on the socket instance before attempting to connect. If no *timeout* is supplied, the...
Connect to *address* and return the socket object.
def create_connection( address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None, socket_options=None, ): """Connect to *address* and return the socket object. Convenience function. Connect to *address* (a 2-tuple ``(host, port)``) and return the socket object. Passing the opti...
[ "def", "create_connection", "(", "address", ",", "timeout", "=", "socket", ".", "_GLOBAL_DEFAULT_TIMEOUT", ",", "source_address", "=", "None", ",", "socket_options", "=", "None", ",", ")", ":", "host", ",", "port", "=", "address", "if", "host", ".", "startsw...
[ 32, 0 ]
[ 85, 59 ]
python
en
['en', 'en', 'en']
True
allowed_gai_family
()
This function is designed to work in the context of getaddrinfo, where family=socket.AF_UNSPEC is the default and will perform a DNS search for both IPv6 and IPv4 records.
This function is designed to work in the context of getaddrinfo, where family=socket.AF_UNSPEC is the default and will perform a DNS search for both IPv6 and IPv4 records.
def allowed_gai_family(): """This function is designed to work in the context of getaddrinfo, where family=socket.AF_UNSPEC is the default and will perform a DNS search for both IPv6 and IPv4 records.""" family = socket.AF_INET if HAS_IPV6: family = socket.AF_UNSPEC return family
[ "def", "allowed_gai_family", "(", ")", ":", "family", "=", "socket", ".", "AF_INET", "if", "HAS_IPV6", ":", "family", "=", "socket", ".", "AF_UNSPEC", "return", "family" ]
[ 96, 0 ]
[ 104, 17 ]
python
en
['en', 'en', 'en']
True