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
Draw.pieslice
(self, xy, start, end, *options)
Same as arc, but also draws straight lines between the end points and the center of the bounding box. .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.pieslice`
Same as arc, but also draws straight lines between the end points and the center of the bounding box.
def pieslice(self, xy, start, end, *options): """ Same as arc, but also draws straight lines between the end points and the center of the bounding box. .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.pieslice` """ self.render("pieslice", xy, start, end, *options)
[ "def", "pieslice", "(", "self", ",", "xy", ",", "start", ",", "end", ",", "*", "options", ")", ":", "self", ".", "render", "(", "\"pieslice\"", ",", "xy", ",", "start", ",", "end", ",", "*", "options", ")" ]
[ 131, 4 ]
[ 138, 57 ]
python
en
['en', 'error', 'th']
False
Draw.polygon
(self, xy, *options)
Draws a polygon. The polygon outline consists of straight lines between the given coordinates, plus a straight line between the last and the first coordinate. .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.polygon`
Draws a polygon.
def polygon(self, xy, *options): """ Draws a polygon. The polygon outline consists of straight lines between the given coordinates, plus a straight line between the last and the first coordinate. .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.polygon` """ ...
[ "def", "polygon", "(", "self", ",", "xy", ",", "*", "options", ")", ":", "self", ".", "render", "(", "\"polygon\"", ",", "xy", ",", "*", "options", ")" ]
[ 140, 4 ]
[ 151, 44 ]
python
en
['en', 'error', 'th']
False
Draw.rectangle
(self, xy, *options)
Draws a rectangle. .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.rectangle`
Draws a rectangle.
def rectangle(self, xy, *options): """ Draws a rectangle. .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.rectangle` """ self.render("rectangle", xy, *options)
[ "def", "rectangle", "(", "self", ",", "xy", ",", "*", "options", ")", ":", "self", ".", "render", "(", "\"rectangle\"", ",", "xy", ",", "*", "options", ")" ]
[ 153, 4 ]
[ 159, 46 ]
python
en
['en', 'error', 'th']
False
Draw.text
(self, xy, text, font)
Draws the string at the given position. .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.text`
Draws the string at the given position.
def text(self, xy, text, font): """ Draws the string at the given position. .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.text` """ if self.transform: xy = ImagePath.Path(xy) xy.transform(self.transform) self.draw.text(xy, text, font=font.font, f...
[ "def", "text", "(", "self", ",", "xy", ",", "text", ",", "font", ")", ":", "if", "self", ".", "transform", ":", "xy", "=", "ImagePath", ".", "Path", "(", "xy", ")", "xy", ".", "transform", "(", "self", ".", "transform", ")", "self", ".", "draw", ...
[ 161, 4 ]
[ 170, 65 ]
python
en
['en', 'error', 'th']
False
Draw.textsize
(self, text, font)
Return the size of the given string, in pixels. .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.textsize`
Return the size of the given string, in pixels.
def textsize(self, text, font): """ Return the size of the given string, in pixels. .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.textsize` """ return self.draw.textsize(text, font=font.font)
[ "def", "textsize", "(", "self", ",", "text", ",", "font", ")", ":", "return", "self", ".", "draw", ".", "textsize", "(", "text", ",", "font", "=", "font", ".", "font", ")" ]
[ 172, 4 ]
[ 178, 55 ]
python
en
['en', 'error', 'th']
False
Command.handle_pip_version_check
(self, options)
This is a no-op so that commands by default do not do the pip version check.
This is a no-op so that commands by default do not do the pip version check.
def handle_pip_version_check(self, options): # type: (Values) -> None """ This is a no-op so that commands by default do not do the pip version check. """ # Make sure we do the pip version check if the index_group options # are present. assert not hasattr(...
[ "def", "handle_pip_version_check", "(", "self", ",", "options", ")", ":", "# type: (Values) -> None", "# Make sure we do the pip version check if the index_group options", "# are present.", "assert", "not", "hasattr", "(", "options", ",", "'no_index'", ")" ]
[ 90, 4 ]
[ 98, 47 ]
python
en
['en', 'error', 'th']
False
_get_prepared_distribution
( req, # type: InstallRequirement req_tracker, # type: RequirementTracker finder, # type: PackageFinder build_isolation # type: bool )
Prepare a distribution for installation.
Prepare a distribution for installation.
def _get_prepared_distribution( req, # type: InstallRequirement req_tracker, # type: RequirementTracker finder, # type: PackageFinder build_isolation # type: bool ): # type: (...) -> AbstractDistribution """Prepare a distribution for installation. """ abstract_dist = ...
[ "def", "_get_prepared_distribution", "(", "req", ",", "# type: InstallRequirement", "req_tracker", ",", "# type: RequirementTracker", "finder", ",", "# type: PackageFinder", "build_isolation", "# type: bool", ")", ":", "# type: (...) -> AbstractDistribution", "abstract_dist", "="...
[ 79, 0 ]
[ 91, 24 ]
python
it
['it', 'it', 'en']
True
_copy2_ignoring_special_files
(src, dest)
Copying special files is not supported, but as a convenience to users we skip errors copying them. This supports tools that may create e.g. socket files in the project source directory.
Copying special files is not supported, but as a convenience to users we skip errors copying them. This supports tools that may create e.g. socket files in the project source directory.
def _copy2_ignoring_special_files(src, dest): # type: (str, str) -> None """Copying special files is not supported, but as a convenience to users we skip errors copying them. This supports tools that may create e.g. socket files in the project source directory. """ try: copy2_fixed(src, ...
[ "def", "_copy2_ignoring_special_files", "(", "src", ",", "dest", ")", ":", "# type: (str, str) -> None", "try", ":", "copy2_fixed", "(", "src", ",", "dest", ")", "except", "shutil", ".", "SpecialFileError", "as", "e", ":", "# SpecialFileError may be raised due to eith...
[ 135, 0 ]
[ 153, 9 ]
python
en
['en', 'en', 'en']
True
get_file_url
( link, # type: Link download_dir=None, # type: Optional[str] hashes=None # type: Optional[Hashes] )
Get file and optionally check its hash.
Get file and optionally check its hash.
def get_file_url( link, # type: Link download_dir=None, # type: Optional[str] hashes=None # type: Optional[Hashes] ): # type: (...) -> File """Get file and optionally check its hash. """ # If a download dir is specified, is the file already there and valid? already_downloaded_path = N...
[ "def", "get_file_url", "(", "link", ",", "# type: Link", "download_dir", "=", "None", ",", "# type: Optional[str]", "hashes", "=", "None", "# type: Optional[Hashes]", ")", ":", "# type: (...) -> File", "# If a download dir is specified, is the file already there and valid?", "a...
[ 188, 0 ]
[ 218, 40 ]
python
en
['en', 'en', 'en']
True
unpack_url
( link, # type: Link location, # type: str downloader, # type: Downloader download_dir=None, # type: Optional[str] hashes=None, # type: Optional[Hashes] )
Unpack link into location, downloading if required. :param hashes: A Hashes object, one of whose embedded hashes must match, or HashMismatch will be raised. If the Hashes is empty, no matches are required, and unhashable types of requirements (like VCS ones, which would ordinarily raise Has...
Unpack link into location, downloading if required.
def unpack_url( link, # type: Link location, # type: str downloader, # type: Downloader download_dir=None, # type: Optional[str] hashes=None, # type: Optional[Hashes] ): # type: (...) -> Optional[File] """Unpack link into location, downloading if required. :param hashes: A Hashes o...
[ "def", "unpack_url", "(", "link", ",", "# type: Link", "location", ",", "# type: str", "downloader", ",", "# type: Downloader", "download_dir", "=", "None", ",", "# type: Optional[str]", "hashes", "=", "None", ",", "# type: Optional[Hashes]", ")", ":", "# type: (...) ...
[ 221, 0 ]
[ 265, 15 ]
python
en
['it', 'en', 'en']
True
_download_http_url
( link, # type: Link downloader, # type: Downloader temp_dir, # type: str hashes, # type: Optional[Hashes] )
Download link url into temp_dir using provided session
Download link url into temp_dir using provided session
def _download_http_url( link, # type: Link downloader, # type: Downloader temp_dir, # type: str hashes, # type: Optional[Hashes] ): # type: (...) -> Tuple[str, str] """Download link url into temp_dir using provided session""" download = downloader(link) file_path = os.path.join(temp...
[ "def", "_download_http_url", "(", "link", ",", "# type: Link", "downloader", ",", "# type: Downloader", "temp_dir", ",", "# type: str", "hashes", ",", "# type: Optional[Hashes]", ")", ":", "# type: (...) -> Tuple[str, str]", "download", "=", "downloader", "(", "link", "...
[ 268, 0 ]
[ 286, 71 ]
python
en
['en', 'en', 'en']
True
_check_download_dir
(link, download_dir, hashes)
Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None
Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None
def _check_download_dir(link, download_dir, hashes): # type: (Link, str, Optional[Hashes]) -> Optional[str] """ Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None """ download_path = os.path.join(download_dir, link.filename) ...
[ "def", "_check_download_dir", "(", "link", ",", "download_dir", ",", "hashes", ")", ":", "# type: (Link, str, Optional[Hashes]) -> Optional[str]", "download_path", "=", "os", ".", "path", ".", "join", "(", "download_dir", ",", "link", ".", "filename", ")", "if", "...
[ 289, 0 ]
[ 312, 24 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer.prepare_linked_requirement
( self, req, # type: InstallRequirement )
Prepare a requirement that would be obtained from req.link
Prepare a requirement that would be obtained from req.link
def prepare_linked_requirement( self, req, # type: InstallRequirement ): # type: (...) -> AbstractDistribution """Prepare a requirement that would be obtained from req.link """ assert req.link link = req.link # TODO: Breakup into smaller functions ...
[ "def", "prepare_linked_requirement", "(", "self", ",", "req", ",", "# type: InstallRequirement", ")", ":", "# type: (...) -> AbstractDistribution", "assert", "req", ".", "link", "link", "=", "req", ".", "link", "# TODO: Breakup into smaller functions", "if", "link", "."...
[ 378, 4 ]
[ 507, 28 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer.prepare_editable_requirement
( self, req, # type: InstallRequirement )
Prepare an editable requirement
Prepare an editable requirement
def prepare_editable_requirement( self, req, # type: InstallRequirement ): # type: (...) -> AbstractDistribution """Prepare an editable requirement """ assert req.editable, "cannot prepare a non-editable req as editable" logger.info('Obtaining %s', req) ...
[ "def", "prepare_editable_requirement", "(", "self", ",", "req", ",", "# type: InstallRequirement", ")", ":", "# type: (...) -> AbstractDistribution", "assert", "req", ".", "editable", ",", "\"cannot prepare a non-editable req as editable\"", "logger", ".", "info", "(", "'Ob...
[ 509, 4 ]
[ 538, 28 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer.prepare_installed_requirement
( self, req, # type: InstallRequirement skip_reason # type: str )
Prepare an already-installed requirement
Prepare an already-installed requirement
def prepare_installed_requirement( self, req, # type: InstallRequirement skip_reason # type: str ): # type: (...) -> AbstractDistribution """Prepare an already-installed requirement """ assert req.satisfied_by, "req should have been satisfied but isn't" ...
[ "def", "prepare_installed_requirement", "(", "self", ",", "req", ",", "# type: InstallRequirement", "skip_reason", "# type: str", ")", ":", "# type: (...) -> AbstractDistribution", "assert", "req", ".", "satisfied_by", ",", "\"req should have been satisfied but isn't\"", "asser...
[ 540, 4 ]
[ 567, 28 ]
python
en
['en', 'en', 'en']
True
NTLMConnectionPool.__init__
(self, user, pw, authurl, *args, **kwargs)
authurl is a random URL on the server that is protected by NTLM. user is the Windows user, probably in the DOMAIN\\username format. pw is the password for the user.
authurl is a random URL on the server that is protected by NTLM. user is the Windows user, probably in the DOMAIN\\username format. pw is the password for the user.
def __init__(self, user, pw, authurl, *args, **kwargs): """ authurl is a random URL on the server that is protected by NTLM. user is the Windows user, probably in the DOMAIN\\username format. pw is the password for the user. """ super(NTLMConnectionPool, self).__init__(*a...
[ "def", "__init__", "(", "self", ",", "user", ",", "pw", ",", "authurl", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", "NTLMConnectionPool", ",", "self", ")", ".", "__init__", "(", "*", "args", ",", "*", "*", "kwargs", ")", "s...
[ 24, 4 ]
[ 36, 20 ]
python
en
['en', 'error', 'th']
False
Widget.subwidgets
(self, name, value, attrs=None, choices=())
Yields all "subwidgets" of this widget. Used only by RadioSelect to allow template access to individual <input type="radio"> buttons. Arguments are the same as for render().
Yields all "subwidgets" of this widget. Used only by RadioSelect to allow template access to individual <input type="radio"> buttons.
def subwidgets(self, name, value, attrs=None, choices=()): """ Yields all "subwidgets" of this widget. Used only by RadioSelect to allow template access to individual <input type="radio"> buttons. Arguments are the same as for render(). """ yield SubWidget(self, name, va...
[ "def", "subwidgets", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ",", "choices", "=", "(", ")", ")", ":", "yield", "SubWidget", "(", "self", ",", "name", ",", "value", ",", "attrs", ",", "choices", ")" ]
[ 194, 4 ]
[ 201, 58 ]
python
en
['en', 'error', 'th']
False
Widget.render
(self, name, value, attrs=None)
Returns this Widget rendered as HTML, as a Unicode string. The 'value' given is not guaranteed to be valid input, so subclass implementations should program defensively.
Returns this Widget rendered as HTML, as a Unicode string.
def render(self, name, value, attrs=None): """ Returns this Widget rendered as HTML, as a Unicode string. The 'value' given is not guaranteed to be valid input, so subclass implementations should program defensively. """ raise NotImplementedError('subclasses of Widget mu...
[ "def", "render", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Widget must provide a render() method'", ")" ]
[ 203, 4 ]
[ 210, 88 ]
python
en
['en', 'error', 'th']
False
Widget.build_attrs
(self, extra_attrs=None, **kwargs)
Helper function for building an attribute dictionary.
Helper function for building an attribute dictionary.
def build_attrs(self, extra_attrs=None, **kwargs): "Helper function for building an attribute dictionary." attrs = dict(self.attrs, **kwargs) if extra_attrs: attrs.update(extra_attrs) return attrs
[ "def", "build_attrs", "(", "self", ",", "extra_attrs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "attrs", "=", "dict", "(", "self", ".", "attrs", ",", "*", "*", "kwargs", ")", "if", "extra_attrs", ":", "attrs", ".", "update", "(", "extra_attrs"...
[ 212, 4 ]
[ 217, 20 ]
python
en
['en', 'en', 'en']
True
Widget.value_from_datadict
(self, data, files, name)
Given a dictionary of data and this widget's name, returns the value of this widget. Returns None if it's not provided.
Given a dictionary of data and this widget's name, returns the value of this widget. Returns None if it's not provided.
def value_from_datadict(self, data, files, name): """ Given a dictionary of data and this widget's name, returns the value of this widget. Returns None if it's not provided. """ return data.get(name, None)
[ "def", "value_from_datadict", "(", "self", ",", "data", ",", "files", ",", "name", ")", ":", "return", "data", ".", "get", "(", "name", ",", "None", ")" ]
[ 219, 4 ]
[ 224, 35 ]
python
en
['en', 'error', 'th']
False
Widget.id_for_label
(self, id_)
Returns the HTML ID attribute of this Widget for use by a <label>, given the ID of the field. Returns None if no ID is available. This hook is necessary because some widgets have multiple HTML elements and, thus, multiple IDs. In that case, this method should return an ID value...
Returns the HTML ID attribute of this Widget for use by a <label>, given the ID of the field. Returns None if no ID is available.
def id_for_label(self, id_): """ Returns the HTML ID attribute of this Widget for use by a <label>, given the ID of the field. Returns None if no ID is available. This hook is necessary because some widgets have multiple HTML elements and, thus, multiple IDs. In that case, this ...
[ "def", "id_for_label", "(", "self", ",", "id_", ")", ":", "return", "id_" ]
[ 226, 4 ]
[ 236, 18 ]
python
en
['en', 'error', 'th']
False
FileInput.value_from_datadict
(self, data, files, name)
File widgets take data from FILES, not POST
File widgets take data from FILES, not POST
def value_from_datadict(self, data, files, name): "File widgets take data from FILES, not POST" return files.get(name, None)
[ "def", "value_from_datadict", "(", "self", ",", "data", ",", "files", ",", "name", ")", ":", "return", "files", ".", "get", "(", "name", ",", "None", ")" ]
[ 337, 4 ]
[ 339, 36 ]
python
en
['en', 'en', 'en']
True
ClearableFileInput.clear_checkbox_name
(self, name)
Given the name of the file input, return the name of the clear checkbox input.
Given the name of the file input, return the name of the clear checkbox input.
def clear_checkbox_name(self, name): """ Given the name of the file input, return the name of the clear checkbox input. """ return name + '-clear'
[ "def", "clear_checkbox_name", "(", "self", ",", "name", ")", ":", "return", "name", "+", "'-clear'" ]
[ 357, 4 ]
[ 362, 30 ]
python
en
['en', 'error', 'th']
False
ClearableFileInput.clear_checkbox_id
(self, name)
Given the name of the clear checkbox input, return the HTML id for it.
Given the name of the clear checkbox input, return the HTML id for it.
def clear_checkbox_id(self, name): """ Given the name of the clear checkbox input, return the HTML id for it. """ return name + '_id'
[ "def", "clear_checkbox_id", "(", "self", ",", "name", ")", ":", "return", "name", "+", "'_id'" ]
[ 364, 4 ]
[ 368, 27 ]
python
en
['en', 'error', 'th']
False
ClearableFileInput.is_initial
(self, value)
Return whether value is considered to be initial value.
Return whether value is considered to be initial value.
def is_initial(self, value): """ Return whether value is considered to be initial value. """ return bool(value and hasattr(value, 'url'))
[ "def", "is_initial", "(", "self", ",", "value", ")", ":", "return", "bool", "(", "value", "and", "hasattr", "(", "value", ",", "'url'", ")", ")" ]
[ 370, 4 ]
[ 374, 52 ]
python
en
['en', 'error', 'th']
False
ClearableFileInput.get_template_substitution_values
(self, value)
Return value-related substitutions.
Return value-related substitutions.
def get_template_substitution_values(self, value): """ Return value-related substitutions. """ return { 'initial': conditional_escape(value), 'initial_url': conditional_escape(value.url), }
[ "def", "get_template_substitution_values", "(", "self", ",", "value", ")", ":", "return", "{", "'initial'", ":", "conditional_escape", "(", "value", ")", ",", "'initial_url'", ":", "conditional_escape", "(", "value", ".", "url", ")", ",", "}" ]
[ 376, 4 ]
[ 383, 9 ]
python
en
['en', 'error', 'th']
False
RendererMixin.get_renderer
(self, name, value, attrs=None, choices=())
Returns an instance of the renderer.
Returns an instance of the renderer.
def get_renderer(self, name, value, attrs=None, choices=()): """Returns an instance of the renderer.""" if value is None: value = self._empty_value final_attrs = self.build_attrs(attrs) choices = list(chain(self.choices, choices)) return self.renderer(name, value, fin...
[ "def", "get_renderer", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ",", "choices", "=", "(", ")", ")", ":", "if", "value", "is", "None", ":", "value", "=", "self", ".", "_empty_value", "final_attrs", "=", "self", ".", "build_at...
[ 740, 4 ]
[ 746, 63 ]
python
en
['en', 'en', 'en']
True
MultiWidget.format_output
(self, rendered_widgets)
Given a list of rendered widgets (as strings), returns a Unicode string representing the HTML for the whole lot. This hook allows you to format the HTML design of the widgets, if needed.
Given a list of rendered widgets (as strings), returns a Unicode string representing the HTML for the whole lot.
def format_output(self, rendered_widgets): """ Given a list of rendered widgets (as strings), returns a Unicode string representing the HTML for the whole lot. This hook allows you to format the HTML design of the widgets, if needed. """ return ''.join(rendered_w...
[ "def", "format_output", "(", "self", ",", "rendered_widgets", ")", ":", "return", "''", ".", "join", "(", "rendered_widgets", ")" ]
[ 837, 4 ]
[ 845, 40 ]
python
en
['en', 'error', 'th']
False
MultiWidget.decompress
(self, value)
Returns a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty.
Returns a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty.
def decompress(self, value): """ Returns a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty. """ raise NotImplementedError('Subclasses must implement this method.')
[ "def", "decompress", "(", "self", ",", "value", ")", ":", "raise", "NotImplementedError", "(", "'Subclasses must implement this method.'", ")" ]
[ 847, 4 ]
[ 853, 75 ]
python
en
['en', 'error', 'th']
False
MultiWidget._get_media
(self)
Media for a multiwidget is the combination of all media of the subwidgets
Media for a multiwidget is the combination of all media of the subwidgets
def _get_media(self): "Media for a multiwidget is the combination of all media of the subwidgets" media = Media() for w in self.widgets: media = media + w.media return media
[ "def", "_get_media", "(", "self", ")", ":", "media", "=", "Media", "(", ")", "for", "w", "in", "self", ".", "widgets", ":", "media", "=", "media", "+", "w", ".", "media", "return", "media" ]
[ 855, 4 ]
[ 860, 20 ]
python
en
['en', 'en', 'en']
True
receiver
(signal, **kwargs)
A decorator for connecting receivers to signals. Used by passing in the signal (or list of signals) and keyword arguments to connect:: @receiver(post_save, sender=MyModel) def signal_receiver(sender, **kwargs): ... @receiver([post_save, post_delete], sender=MyModel) ...
A decorator for connecting receivers to signals. Used by passing in the signal (or list of signals) and keyword arguments to connect::
def receiver(signal, **kwargs): """ A decorator for connecting receivers to signals. Used by passing in the signal (or list of signals) and keyword arguments to connect:: @receiver(post_save, sender=MyModel) def signal_receiver(sender, **kwargs): ... @receiver([post_sav...
[ "def", "receiver", "(", "signal", ",", "*", "*", "kwargs", ")", ":", "def", "_decorator", "(", "func", ")", ":", "if", "isinstance", "(", "signal", ",", "(", "list", ",", "tuple", ")", ")", ":", "for", "s", "in", "signal", ":", "s", ".", "connect...
[ 302, 0 ]
[ 323, 21 ]
python
en
['en', 'error', 'th']
False
Signal.__init__
(self, providing_args=None, use_caching=False)
Create a new signal. providing_args A list of the arguments this signal can pass along in a send() call.
Create a new signal.
def __init__(self, providing_args=None, use_caching=False): """ Create a new signal. providing_args A list of the arguments this signal can pass along in a send() call. """ self.receivers = [] if providing_args is None: providing_args = [] ...
[ "def", "__init__", "(", "self", ",", "providing_args", "=", "None", ",", "use_caching", "=", "False", ")", ":", "self", ".", "receivers", "=", "[", "]", "if", "providing_args", "is", "None", ":", "providing_args", "=", "[", "]", "self", ".", "providing_a...
[ 31, 4 ]
[ 50, 36 ]
python
en
['en', 'error', 'th']
False
Signal.connect
(self, receiver, sender=None, weak=True, dispatch_uid=None)
Connect receiver to sender for signal. Arguments: receiver A function or an instance method which is to receive signals. Receivers must be hashable objects. If weak is True, then receiver must be weak-referencable. Receiver...
Connect receiver to sender for signal.
def connect(self, receiver, sender=None, weak=True, dispatch_uid=None): """ Connect receiver to sender for signal. Arguments: receiver A function or an instance method which is to receive signals. Receivers must be hashable objects. ...
[ "def", "connect", "(", "self", ",", "receiver", ",", "sender", "=", "None", ",", "weak", "=", "True", ",", "dispatch_uid", "=", "None", ")", ":", "from", "django", ".", "conf", "import", "settings", "# If DEBUG is on, check that we got a good receiver", "if", ...
[ 52, 4 ]
[ 133, 47 ]
python
en
['en', 'error', 'th']
False
Signal.disconnect
(self, receiver=None, sender=None, weak=True, dispatch_uid=None)
Disconnect receiver from sender for signal. If weak references are used, disconnect need not be called. The receiver will be remove from dispatch automatically. Arguments: receiver The registered receiver to disconnect. May be none if dispa...
Disconnect receiver from sender for signal.
def disconnect(self, receiver=None, sender=None, weak=True, dispatch_uid=None): """ Disconnect receiver from sender for signal. If weak references are used, disconnect need not be called. The receiver will be remove from dispatch automatically. Arguments: receiver ...
[ "def", "disconnect", "(", "self", ",", "receiver", "=", "None", ",", "sender", "=", "None", ",", "weak", "=", "True", ",", "dispatch_uid", "=", "None", ")", ":", "if", "dispatch_uid", ":", "lookup_key", "=", "(", "dispatch_uid", ",", "_make_id", "(", "...
[ 135, 4 ]
[ 169, 47 ]
python
en
['en', 'error', 'th']
False
Signal.send
(self, sender, **named)
Send signal from sender to all connected receivers. If any receiver raises an error, the error propagates back through send, terminating the dispatch loop, so it is quite possible to not have all receivers called if a raises an error. Arguments: sender ...
Send signal from sender to all connected receivers.
def send(self, sender, **named): """ Send signal from sender to all connected receivers. If any receiver raises an error, the error propagates back through send, terminating the dispatch loop, so it is quite possible to not have all receivers called if a raises an error. ...
[ "def", "send", "(", "self", ",", "sender", ",", "*", "*", "named", ")", ":", "responses", "=", "[", "]", "if", "not", "self", ".", "receivers", "or", "self", ".", "sender_receivers_cache", ".", "get", "(", "sender", ")", "is", "NO_RECEIVERS", ":", "r...
[ 174, 4 ]
[ 199, 24 ]
python
en
['en', 'error', 'th']
False
Signal.send_robust
(self, sender, **named)
Send signal from sender to all connected receivers catching errors. Arguments: sender The sender of the signal. Can be any python object (normally one registered with a connect if you actually want something to occur). named ...
Send signal from sender to all connected receivers catching errors.
def send_robust(self, sender, **named): """ Send signal from sender to all connected receivers catching errors. Arguments: sender The sender of the signal. Can be any python object (normally one registered with a connect if you actually want somethin...
[ "def", "send_robust", "(", "self", ",", "sender", ",", "*", "*", "named", ")", ":", "responses", "=", "[", "]", "if", "not", "self", ".", "receivers", "or", "self", ".", "sender_receivers_cache", ".", "get", "(", "sender", ")", "is", "NO_RECEIVERS", ":...
[ 201, 4 ]
[ 240, 24 ]
python
en
['en', 'error', 'th']
False
Signal._live_receivers
(self, sender)
Filter sequence of receivers to get resolved, live receivers. This checks for weak references and resolves them, then returning only live receivers.
Filter sequence of receivers to get resolved, live receivers.
def _live_receivers(self, sender): """ Filter sequence of receivers to get resolved, live receivers. This checks for weak references and resolves them, then returning only live receivers. """ receivers = None if self.use_caching and not self._dead_receivers: ...
[ "def", "_live_receivers", "(", "self", ",", "sender", ")", ":", "receivers", "=", "None", "if", "self", ".", "use_caching", "and", "not", "self", ".", "_dead_receivers", ":", "receivers", "=", "self", ".", "sender_receivers_cache", ".", "get", "(", "sender",...
[ 253, 4 ]
[ 290, 33 ]
python
en
['en', 'error', 'th']
False
cifar10_tutorial
( train_start=0, train_end=60000, test_start=0, test_end=10000, nb_epochs=NB_EPOCHS, batch_size=BATCH_SIZE, learning_rate=LEARNING_RATE, clean_train=CLEAN_TRAIN, testing=False, backprop_through_attack=BACKPROP_THROUGH_ATTACK, nb_filters=NB_FILTERS, num_threads=None, l...
CIFAR10 cleverhans tutorial :param train_start: index of first training set example :param train_end: index of last training set example :param test_start: index of first test set example :param test_end: index of last test set example :param nb_epochs: number of epochs to train model :para...
CIFAR10 cleverhans tutorial :param train_start: index of first training set example :param train_end: index of last training set example :param test_start: index of first test set example :param test_end: index of last test set example :param nb_epochs: number of epochs to train model :para...
def cifar10_tutorial( train_start=0, train_end=60000, test_start=0, test_end=10000, nb_epochs=NB_EPOCHS, batch_size=BATCH_SIZE, learning_rate=LEARNING_RATE, clean_train=CLEAN_TRAIN, testing=False, backprop_through_attack=BACKPROP_THROUGH_ATTACK, nb_filters=NB_FILTERS, num...
[ "def", "cifar10_tutorial", "(", "train_start", "=", "0", ",", "train_end", "=", "60000", ",", "test_start", "=", "0", ",", "test_end", "=", "10000", ",", "nb_epochs", "=", "NB_EPOCHS", ",", "batch_size", "=", "BATCH_SIZE", ",", "learning_rate", "=", "LEARNIN...
[ 36, 0 ]
[ 224, 17 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.assertSuccessfulRawQuery
(self, model, query, expected_results, expected_annotations=(), params=[], translations=None)
Execute the passed query against the passed model and check the output
Execute the passed query against the passed model and check the output
def assertSuccessfulRawQuery(self, model, query, expected_results, expected_annotations=(), params=[], translations=None): """ Execute the passed query against the passed model and check the output """ results = list(model.objects.raw(query, params=params, translations=transl...
[ "def", "assertSuccessfulRawQuery", "(", "self", ",", "model", ",", "query", ",", "expected_results", ",", "expected_annotations", "=", "(", ")", ",", "params", "=", "[", "]", ",", "translations", "=", "None", ")", ":", "results", "=", "list", "(", "model",...
[ 13, 4 ]
[ 20, 61 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.assertProcessed
(self, model, results, orig, expected_annotations=())
Compare the results of a raw query against expected results
Compare the results of a raw query against expected results
def assertProcessed(self, model, results, orig, expected_annotations=()): """ Compare the results of a raw query against expected results """ self.assertEqual(len(results), len(orig)) for index, item in enumerate(results): orig_item = orig[index] for annot...
[ "def", "assertProcessed", "(", "self", ",", "model", ",", "results", ",", "orig", ",", "expected_annotations", "=", "(", ")", ")", ":", "self", ".", "assertEqual", "(", "len", "(", "results", ")", ",", "len", "(", "orig", ")", ")", "for", "index", ",...
[ 22, 4 ]
[ 42, 17 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.assertNoAnnotations
(self, results)
Check that the results of a raw query contain no annotations
Check that the results of a raw query contain no annotations
def assertNoAnnotations(self, results): """ Check that the results of a raw query contain no annotations """ self.assertAnnotations(results, ())
[ "def", "assertNoAnnotations", "(", "self", ",", "results", ")", ":", "self", ".", "assertAnnotations", "(", "results", ",", "(", ")", ")" ]
[ 44, 4 ]
[ 48, 43 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.assertAnnotations
(self, results, expected_annotations)
Check that the passed raw query results contain the expected annotations
Check that the passed raw query results contain the expected annotations
def assertAnnotations(self, results, expected_annotations): """ Check that the passed raw query results contain the expected annotations """ if expected_annotations: for index, result in enumerate(results): annotation, value = expected_annotations[inde...
[ "def", "assertAnnotations", "(", "self", ",", "results", ",", "expected_annotations", ")", ":", "if", "expected_annotations", ":", "for", "index", ",", "result", "in", "enumerate", "(", "results", ")", ":", "annotation", ",", "value", "=", "expected_annotations"...
[ 50, 4 ]
[ 59, 68 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.test_simple_raw_query
(self)
Basic test of raw query with a simple database query
Basic test of raw query with a simple database query
def test_simple_raw_query(self): """ Basic test of raw query with a simple database query """ query = "SELECT * FROM raw_query_author" authors = Author.objects.all() self.assertSuccessfulRawQuery(Author, query, authors)
[ "def", "test_simple_raw_query", "(", "self", ")", ":", "query", "=", "\"SELECT * FROM raw_query_author\"", "authors", "=", "Author", ".", "objects", ".", "all", "(", ")", "self", ".", "assertSuccessfulRawQuery", "(", "Author", ",", "query", ",", "authors", ")" ]
[ 61, 4 ]
[ 67, 61 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.test_raw_query_lazy
(self)
Raw queries are lazy: they aren't actually executed until they're iterated over.
Raw queries are lazy: they aren't actually executed until they're iterated over.
def test_raw_query_lazy(self): """ Raw queries are lazy: they aren't actually executed until they're iterated over. """ q = Author.objects.raw('SELECT * FROM raw_query_author') self.assertTrue(q.query.cursor is None) list(q) self.assertTrue(q.query.cursor ...
[ "def", "test_raw_query_lazy", "(", "self", ")", ":", "q", "=", "Author", ".", "objects", ".", "raw", "(", "'SELECT * FROM raw_query_author'", ")", "self", ".", "assertTrue", "(", "q", ".", "query", ".", "cursor", "is", "None", ")", "list", "(", "q", ")",...
[ 69, 4 ]
[ 77, 51 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.test_FK_raw_query
(self)
Test of a simple raw query against a model containing a foreign key
Test of a simple raw query against a model containing a foreign key
def test_FK_raw_query(self): """ Test of a simple raw query against a model containing a foreign key """ query = "SELECT * FROM raw_query_book" books = Book.objects.all() self.assertSuccessfulRawQuery(Book, query, books)
[ "def", "test_FK_raw_query", "(", "self", ")", ":", "query", "=", "\"SELECT * FROM raw_query_book\"", "books", "=", "Book", ".", "objects", ".", "all", "(", ")", "self", ".", "assertSuccessfulRawQuery", "(", "Book", ",", "query", ",", "books", ")" ]
[ 79, 4 ]
[ 85, 57 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.test_db_column_handler
(self)
Test of a simple raw query against a model containing a field with db_column defined.
Test of a simple raw query against a model containing a field with db_column defined.
def test_db_column_handler(self): """ Test of a simple raw query against a model containing a field with db_column defined. """ query = "SELECT * FROM raw_query_coffee" coffees = Coffee.objects.all() self.assertSuccessfulRawQuery(Coffee, query, coffees)
[ "def", "test_db_column_handler", "(", "self", ")", ":", "query", "=", "\"SELECT * FROM raw_query_coffee\"", "coffees", "=", "Coffee", ".", "objects", ".", "all", "(", ")", "self", ".", "assertSuccessfulRawQuery", "(", "Coffee", ",", "query", ",", "coffees", ")" ...
[ 87, 4 ]
[ 94, 61 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.test_order_handler
(self)
Test of raw raw query's tolerance for columns being returned in any order
Test of raw raw query's tolerance for columns being returned in any order
def test_order_handler(self): """ Test of raw raw query's tolerance for columns being returned in any order """ selects = ( ('dob, last_name, first_name, id'), ('last_name, dob, first_name, id'), ('first_name, last_name, dob, id'), ) ...
[ "def", "test_order_handler", "(", "self", ")", ":", "selects", "=", "(", "(", "'dob, last_name, first_name, id'", ")", ",", "(", "'last_name, dob, first_name, id'", ")", ",", "(", "'first_name, last_name, dob, id'", ")", ",", ")", "for", "select", "in", "selects", ...
[ 96, 4 ]
[ 110, 65 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.test_translations
(self)
Test of raw query's optional ability to translate unexpected result column names to specific model fields
Test of raw query's optional ability to translate unexpected result column names to specific model fields
def test_translations(self): """ Test of raw query's optional ability to translate unexpected result column names to specific model fields """ query = "SELECT first_name AS first, last_name AS last, dob, id FROM raw_query_author" translations = {'first': 'first_name', 'la...
[ "def", "test_translations", "(", "self", ")", ":", "query", "=", "\"SELECT first_name AS first, last_name AS last, dob, id FROM raw_query_author\"", "translations", "=", "{", "'first'", ":", "'first_name'", ",", "'last'", ":", "'last_name'", "}", "authors", "=", "Author",...
[ 112, 4 ]
[ 120, 88 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.test_params
(self)
Test passing optional query parameters
Test passing optional query parameters
def test_params(self): """ Test passing optional query parameters """ query = "SELECT * FROM raw_query_author WHERE first_name = %s" author = Author.objects.all()[2] params = [author.first_name] qset = Author.objects.raw(query, params=params) results = lis...
[ "def", "test_params", "(", "self", ")", ":", "query", "=", "\"SELECT * FROM raw_query_author WHERE first_name = %s\"", "author", "=", "Author", ".", "objects", ".", "all", "(", ")", "[", "2", "]", "params", "=", "[", "author", ".", "first_name", "]", "qset", ...
[ 122, 4 ]
[ 134, 46 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.test_pyformat_params
(self)
Test passing optional query parameters
Test passing optional query parameters
def test_pyformat_params(self): """ Test passing optional query parameters """ query = "SELECT * FROM raw_query_author WHERE first_name = %(first)s" author = Author.objects.all()[2] params = {'first': author.first_name} qset = Author.objects.raw(query, params=para...
[ "def", "test_pyformat_params", "(", "self", ")", ":", "query", "=", "\"SELECT * FROM raw_query_author WHERE first_name = %(first)s\"", "author", "=", "Author", ".", "objects", ".", "all", "(", ")", "[", "2", "]", "params", "=", "{", "'first'", ":", "author", "."...
[ 137, 4 ]
[ 149, 46 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.test_query_representation
(self)
Test representation of raw query with parameters
Test representation of raw query with parameters
def test_query_representation(self): """ Test representation of raw query with parameters """ query = "SELECT * FROM raw_query_author WHERE last_name = %(last)s" qset = Author.objects.raw(query, {'last': 'foo'}) self.assertEqual(repr(qset), "<RawQuerySet: SELECT * FROM ra...
[ "def", "test_query_representation", "(", "self", ")", ":", "query", "=", "\"SELECT * FROM raw_query_author WHERE last_name = %(last)s\"", "qset", "=", "Author", ".", "objects", ".", "raw", "(", "query", ",", "{", "'last'", ":", "'foo'", "}", ")", "self", ".", "a...
[ 151, 4 ]
[ 163, 110 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.test_many_to_many
(self)
Test of a simple raw query against a model containing a m2m field
Test of a simple raw query against a model containing a m2m field
def test_many_to_many(self): """ Test of a simple raw query against a model containing a m2m field """ query = "SELECT * FROM raw_query_reviewer" reviewers = Reviewer.objects.all() self.assertSuccessfulRawQuery(Reviewer, query, reviewers)
[ "def", "test_many_to_many", "(", "self", ")", ":", "query", "=", "\"SELECT * FROM raw_query_reviewer\"", "reviewers", "=", "Reviewer", ".", "objects", ".", "all", "(", ")", "self", ".", "assertSuccessfulRawQuery", "(", "Reviewer", ",", "query", ",", "reviewers", ...
[ 165, 4 ]
[ 171, 65 ]
python
en
['en', 'error', 'th']
False
RawQueryTests.test_extra_conversions
(self)
Test to insure that extra translations are ignored.
Test to insure that extra translations are ignored.
def test_extra_conversions(self): """ Test to insure that extra translations are ignored. """ query = "SELECT * FROM raw_query_author" translations = {'something': 'else'} authors = Author.objects.all() self.assertSuccessfulRawQuery(Author, query, authors, transla...
[ "def", "test_extra_conversions", "(", "self", ")", ":", "query", "=", "\"SELECT * FROM raw_query_author\"", "translations", "=", "{", "'something'", ":", "'else'", "}", "authors", "=", "Author", ".", "objects", ".", "all", "(", ")", "self", ".", "assertSuccessfu...
[ 173, 4 ]
[ 180, 88 ]
python
en
['en', 'error', 'th']
False
create_generic_related_manager
(superclass)
Factory function for a manager that subclasses 'superclass' (which is a Manager) and adds behavior for generic related objects.
Factory function for a manager that subclasses 'superclass' (which is a Manager) and adds behavior for generic related objects.
def create_generic_related_manager(superclass): """ Factory function for a manager that subclasses 'superclass' (which is a Manager) and adds behavior for generic related objects. """ class GenericRelatedObjectManager(superclass): def __init__(self, model=None, instance=None, symmetrical=No...
[ "def", "create_generic_related_manager", "(", "superclass", ")", ":", "class", "GenericRelatedObjectManager", "(", "superclass", ")", ":", "def", "__init__", "(", "self", ",", "model", "=", "None", ",", "instance", "=", "None", ",", "symmetrical", "=", "None", ...
[ 419, 0 ]
[ 553, 38 ]
python
en
['en', 'error', 'th']
False
GenericRelation.get_content_type
(self)
Returns the content type associated with this field's model.
Returns the content type associated with this field's model.
def get_content_type(self): """ Returns the content type associated with this field's model. """ return ContentType.objects.get_for_model(self.model, for_concrete_model=self.for_concrete_model)
[ "def", "get_content_type", "(", "self", ")", ":", "return", "ContentType", ".", "objects", ".", "get_for_model", "(", "self", ".", "model", ",", "for_concrete_model", "=", "self", ".", "for_concrete_model", ")" ]
[ 338, 4 ]
[ 343, 92 ]
python
en
['en', 'error', 'th']
False
GenericRelation.bulk_related_objects
(self, objs, using=DEFAULT_DB_ALIAS)
Return all objects related to ``objs`` via this ``GenericRelation``.
Return all objects related to ``objs`` via this ``GenericRelation``.
def bulk_related_objects(self, objs, using=DEFAULT_DB_ALIAS): """ Return all objects related to ``objs`` via this ``GenericRelation``. """ return self.rel.to._base_manager.db_manager(using).filter(**{ "%s__pk" % self.content_type_field_name: ContentType.objects.db_manager(us...
[ "def", "bulk_related_objects", "(", "self", ",", "objs", ",", "using", "=", "DEFAULT_DB_ALIAS", ")", ":", "return", "self", ".", "rel", ".", "to", ".", "_base_manager", ".", "db_manager", "(", "using", ")", ".", "filter", "(", "*", "*", "{", "\"%s__pk\""...
[ 353, 4 ]
[ 362, 10 ]
python
en
['en', 'error', 'th']
False
tempdir_registry
()
Provides a scoped global tempdir registry that can be used to dictate whether directories should be deleted.
Provides a scoped global tempdir registry that can be used to dictate whether directories should be deleted.
def tempdir_registry(): # type: () -> Iterator[TempDirectoryTypeRegistry] """Provides a scoped global tempdir registry that can be used to dictate whether directories should be deleted. """ global _tempdir_registry old_tempdir_registry = _tempdir_registry _tempdir_registry = TempDirectoryTyp...
[ "def", "tempdir_registry", "(", ")", ":", "# type: () -> Iterator[TempDirectoryTypeRegistry]", "global", "_tempdir_registry", "old_tempdir_registry", "=", "_tempdir_registry", "_tempdir_registry", "=", "TempDirectoryTypeRegistry", "(", ")", "try", ":", "yield", "_tempdir_regist...
[ 74, 0 ]
[ 85, 48 ]
python
en
['en', 'en', 'en']
True
TempDirectoryTypeRegistry.set_delete
(self, kind, value)
Indicate whether a TempDirectory of the given kind should be auto-deleted.
Indicate whether a TempDirectory of the given kind should be auto-deleted.
def set_delete(self, kind, value): # type: (str, bool) -> None """Indicate whether a TempDirectory of the given kind should be auto-deleted. """ self._should_delete[kind] = value
[ "def", "set_delete", "(", "self", ",", "kind", ",", "value", ")", ":", "# type: (str, bool) -> None", "self", ".", "_should_delete", "[", "kind", "]", "=", "value" ]
[ 55, 4 ]
[ 60, 41 ]
python
en
['en', 'en', 'en']
True
TempDirectoryTypeRegistry.get_delete
(self, kind)
Get configured auto-delete flag for a given TempDirectory type, default True.
Get configured auto-delete flag for a given TempDirectory type, default True.
def get_delete(self, kind): # type: (str) -> bool """Get configured auto-delete flag for a given TempDirectory type, default True. """ return self._should_delete.get(kind, True)
[ "def", "get_delete", "(", "self", ",", "kind", ")", ":", "# type: (str) -> bool", "return", "self", ".", "_should_delete", ".", "get", "(", "kind", ",", "True", ")" ]
[ 62, 4 ]
[ 67, 50 ]
python
en
['en', 'en', 'en']
True
TempDirectory._create
(self, kind)
Create a temporary directory and store its path in self.path
Create a temporary directory and store its path in self.path
def _create(self, kind): # type: (str) -> str """Create a temporary directory and store its path in self.path """ # We realpath here because some systems have their default tmpdir # symlinked to another directory. This tends to confuse build # scripts, so we canonicalize...
[ "def", "_create", "(", "self", ",", "kind", ")", ":", "# type: (str) -> str", "# We realpath here because some systems have their default tmpdir", "# symlinked to another directory. This tends to confuse build", "# scripts, so we canonicalize the path by traversing potential", "# symlinks h...
[ 175, 4 ]
[ 187, 19 ]
python
en
['en', 'en', 'en']
True
TempDirectory.cleanup
(self)
Remove the temporary directory created and reset state
Remove the temporary directory created and reset state
def cleanup(self): # type: () -> None """Remove the temporary directory created and reset state """ self._deleted = True if os.path.exists(self._path): rmtree(self._path)
[ "def", "cleanup", "(", "self", ")", ":", "# type: () -> None", "self", ".", "_deleted", "=", "True", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "_path", ")", ":", "rmtree", "(", "self", ".", "_path", ")" ]
[ 189, 4 ]
[ 195, 30 ]
python
en
['en', 'en', 'en']
True
AdjacentTempDirectory._generate_names
(cls, name)
Generates a series of temporary names. The algorithm replaces the leading characters in the name with ones that are valid filesystem characters, but are not valid package names (for both Python and pip definitions of package).
Generates a series of temporary names.
def _generate_names(cls, name): # type: (str) -> Iterator[str] """Generates a series of temporary names. The algorithm replaces the leading characters in the name with ones that are valid filesystem characters, but are not valid package names (for both Python and pip definitions...
[ "def", "_generate_names", "(", "cls", ",", "name", ")", ":", "# type: (str) -> Iterator[str]", "for", "i", "in", "range", "(", "1", ",", "len", "(", "name", ")", ")", ":", "for", "candidate", "in", "itertools", ".", "combinations_with_replacement", "(", "cls...
[ 225, 4 ]
[ 247, 34 ]
python
en
['en', 'en', 'en']
True
datatype
(dbtype, description)
Helper to convert a data type into a string.
Helper to convert a data type into a string.
def datatype(dbtype, description): """Helper to convert a data type into a string.""" dt = connection.introspection.get_field_type(dbtype, description) if type(dt) is tuple: return dt[0] else: return dt
[ "def", "datatype", "(", "dbtype", ",", "description", ")", ":", "dt", "=", "connection", ".", "introspection", ".", "get_field_type", "(", "dbtype", ",", "description", ")", "if", "type", "(", "dt", ")", "is", "tuple", ":", "return", "dt", "[", "0", "]...
[ 155, 0 ]
[ 161, 17 ]
python
en
['it', 'en', 'en']
True
IntrospectionTests.test_get_indexes_multicol
(self)
Test that multicolumn indexes are not included in the introspection results.
Test that multicolumn indexes are not included in the introspection results.
def test_get_indexes_multicol(self): """ Test that multicolumn indexes are not included in the introspection results. """ with connection.cursor() as cursor: indexes = connection.introspection.get_indexes(cursor, Reporter._meta.db_table) self.assertNotIn('firs...
[ "def", "test_get_indexes_multicol", "(", "self", ")", ":", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "indexes", "=", "connection", ".", "introspection", ".", "get_indexes", "(", "cursor", ",", "Reporter", ".", "_meta", ".", "db_tabl...
[ 144, 4 ]
[ 152, 36 ]
python
en
['en', 'error', 'th']
False
SchemaTests.delete_tables
(self)
Deletes all model tables for our models for a clean test environment
Deletes all model tables for our models for a clean test environment
def delete_tables(self): "Deletes all model tables for our models for a clean test environment" with connection.cursor() as cursor: connection.disable_constraint_checking() table_names = connection.introspection.table_names(cursor) for model in self.models: ...
[ "def", "delete_tables", "(", "self", ")", ":", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "connection", ".", "disable_constraint_checking", "(", ")", "table_names", "=", "connection", ".", "introspection", ".", "table_names", "(", "cur...
[ 39, 4 ]
[ 62, 47 ]
python
en
['ca', 'en', 'en']
True
SchemaTests.get_indexes
(self, table)
Get the indexes on the table using a new cursor.
Get the indexes on the table using a new cursor.
def get_indexes(self, table): """ Get the indexes on the table using a new cursor. """ with connection.cursor() as cursor: return connection.introspection.get_indexes(cursor, table)
[ "def", "get_indexes", "(", "self", ",", "table", ")", ":", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "return", "connection", ".", "introspection", ".", "get_indexes", "(", "cursor", ",", "table", ")" ]
[ 82, 4 ]
[ 87, 70 ]
python
en
['en', 'error', 'th']
False
SchemaTests.get_constraints
(self, table)
Get the constraints on a table using a new cursor.
Get the constraints on a table using a new cursor.
def get_constraints(self, table): """ Get the constraints on a table using a new cursor. """ with connection.cursor() as cursor: return connection.introspection.get_constraints(cursor, table)
[ "def", "get_constraints", "(", "self", ",", "table", ")", ":", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "return", "connection", ".", "introspection", ".", "get_constraints", "(", "cursor", ",", "table", ")" ]
[ 89, 4 ]
[ 94, 74 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_creation_deletion
(self)
Tries creating a model's table, and then deleting it.
Tries creating a model's table, and then deleting it.
def test_creation_deletion(self): """ Tries creating a model's table, and then deleting it. """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Check that it's there list(Author.objects.all()) # Clean...
[ "def", "test_creation_deletion", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "# Check that it's there", "list", "(", "Author", ".", "ob...
[ 98, 4 ]
[ 114, 9 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_fk
(self)
Tests that creating tables out of FK order, then repointing, works
Tests that creating tables out of FK order, then repointing, works
def test_fk(self): "Tests that creating tables out of FK order, then repointing, works" # Create the table with connection.schema_editor() as editor: editor.create_model(Book) editor.create_model(Author) editor.create_model(Tag) # Check that initial ta...
[ "def", "test_fk", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Book", ")", "editor", ".", "create_model", "(", "Author", ")", "editor", ".", "cr...
[ 117, 4 ]
[ 151, 61 ]
python
en
['en', 'en', 'en']
True
SchemaTests.test_fk_db_constraint
(self)
Tests that the db_constraint parameter is respected
Tests that the db_constraint parameter is respected
def test_fk_db_constraint(self): "Tests that the db_constraint parameter is respected" # Create the table with connection.schema_editor() as editor: editor.create_model(Tag) editor.create_model(Author) editor.create_model(BookWeak) # Check that initial...
[ "def", "test_fk_db_constraint", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Tag", ")", "editor", ".", "create_model", "(", "Author", ")", "editor",...
[ 154, 4 ]
[ 215, 59 ]
python
en
['en', 'en', 'en']
True
SchemaTests.test_add_field
(self)
Tests adding fields to models
Tests adding fields to models
def test_add_field(self): """ Tests adding fields to models """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure there's no age field columns = self.column_classes(Author) self.assertNotIn("age"...
[ "def", "test_add_field", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "# Ensure there's no age field", "columns", "=", "self", ".", "col...
[ 241, 4 ]
[ 262, 52 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_add_field_temp_default
(self)
Tests adding fields to models with a temporary default
Tests adding fields to models with a temporary default
def test_add_field_temp_default(self): """ Tests adding fields to models with a temporary default """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure there's no age field columns = self.column_classes(...
[ "def", "test_add_field_temp_default", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "# Ensure there's no age field", "columns", "=", "self", ...
[ 264, 4 ]
[ 289, 79 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_add_field_temp_default_boolean
(self)
Tests adding fields to models with a temporary default where the default is False. (#21783)
Tests adding fields to models with a temporary default where the default is False. (#21783)
def test_add_field_temp_default_boolean(self): """ Tests adding fields to models with a temporary default where the default is False. (#21783) """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure there'...
[ "def", "test_add_field_temp_default_boolean", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "# Ensure there's no age field", "columns", "=", ...
[ 291, 4 ]
[ 317, 125 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_add_field_default_transform
(self)
Tests adding fields to models with a default that is not directly valid in the database (#22581)
Tests adding fields to models with a default that is not directly valid in the database (#22581)
def test_add_field_default_transform(self): """ Tests adding fields to models with a default that is not directly valid in the database (#22581) """ class TestTransformField(IntegerField): # Weird field that saves the count of items in its value def get_...
[ "def", "test_add_field_default_transform", "(", "self", ")", ":", "class", "TestTransformField", "(", "IntegerField", ")", ":", "# Weird field that saves the count of items in its value", "def", "get_default", "(", "self", ")", ":", "return", "self", ".", "default", "de...
[ 319, 4 ]
[ 355, 78 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_add_field_binary
(self)
Tests binary fields get a sane default (#22851)
Tests binary fields get a sane default (#22851)
def test_add_field_binary(self): """ Tests binary fields get a sane default (#22851) """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Add the new field new_field = BinaryField(blank=True) new_field...
[ "def", "test_add_field_binary", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "# Add the new field", "new_field", "=", "BinaryField", "(", ...
[ 357, 4 ]
[ 376, 71 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_alter
(self)
Tests simple altering of fields
Tests simple altering of fields
def test_alter(self): """ Tests simple altering of fields """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure the field is right to begin with columns = self.column_classes(Author) self.assertE...
[ "def", "test_alter", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "# Ensure the field is right to begin with", "columns", "=", "self", "."...
[ 378, 4 ]
[ 416, 60 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_alter_null_to_not_null
(self)
#23609 - Tests handling of default values when altering from NULL to NOT NULL.
#23609 - Tests handling of default values when altering from NULL to NOT NULL.
def test_alter_null_to_not_null(self): """ #23609 - Tests handling of default values when altering from NULL to NOT NULL. """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure the field is right to begin with ...
[ "def", "test_alter_null_to_not_null", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "# Ensure the field is right to begin with", "columns", "="...
[ 418, 4 ]
[ 448, 75 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_alter_fk
(self)
Tests altering of FKs
Tests altering of FKs
def test_alter_fk(self): """ Tests altering of FKs """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) # Ensure the field is right to begin with columns = self.column_class...
[ "def", "test_alter_fk", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "editor", ".", "create_model", "(", "Book", ")", "# Ensure the fi...
[ 451, 4 ]
[ 490, 61 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_rename
(self)
Tests simple altering of fields
Tests simple altering of fields
def test_rename(self): """ Tests simple altering of fields """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure the field is right to begin with columns = self.column_classes(Author) self.assert...
[ "def", "test_rename", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "# Ensure the field is right to begin with", "columns", "=", "self", "....
[ 492, 4 ]
[ 516, 41 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_m2m_create
(self)
Tests M2M fields on models during creation
Tests M2M fields on models during creation
def test_m2m_create(self): """ Tests M2M fields on models during creation """ # Create the tables with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(TagM2MTest) editor.create_model(BookWithM2M) # ...
[ "def", "test_m2m_create", "(", "self", ")", ":", "# Create the tables", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "editor", ".", "create_model", "(", "TagM2MTest", ")", "editor...
[ 518, 4 ]
[ 529, 69 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_m2m_create_through
(self)
Tests M2M fields on models during creation with through models
Tests M2M fields on models during creation with through models
def test_m2m_create_through(self): """ Tests M2M fields on models during creation with through models """ # Create the tables with connection.schema_editor() as editor: editor.create_model(TagThrough) editor.create_model(TagM2MTest) editor.crea...
[ "def", "test_m2m_create_through", "(", "self", ")", ":", "# Create the tables", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "TagThrough", ")", "editor", ".", "create_model", "(", "TagM2MTest", ")...
[ 531, 4 ]
[ 543, 62 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_m2m
(self)
Tests adding/removing M2M fields on models
Tests adding/removing M2M fields on models
def test_m2m(self): """ Tests adding/removing M2M fields on models """ # Create the tables with connection.schema_editor() as editor: editor.create_model(AuthorWithM2M) editor.create_model(TagM2MTest) # Create an M2M field new_field = ManyT...
[ "def", "test_m2m", "(", "self", ")", ":", "# Create the tables", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "AuthorWithM2M", ")", "editor", ".", "create_model", "(", "TagM2MTest", ")", "# Crea...
[ 545, 4 ]
[ 587, 68 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_m2m_through_alter
(self)
Tests altering M2Ms with explicit through models (should no-op)
Tests altering M2Ms with explicit through models (should no-op)
def test_m2m_through_alter(self): """ Tests altering M2Ms with explicit through models (should no-op) """ # Create the tables with connection.schema_editor() as editor: editor.create_model(AuthorTag) editor.create_model(AuthorWithM2MThrough) ed...
[ "def", "test_m2m_through_alter", "(", "self", ")", ":", "# Create the tables", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "AuthorTag", ")", "editor", ".", "create_model", "(", "AuthorWithM2MThroug...
[ 589, 4 ]
[ 611, 64 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_m2m_repoint
(self)
Tests repointing M2M fields
Tests repointing M2M fields
def test_m2m_repoint(self): """ Tests repointing M2M fields """ # Create the tables with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(BookWithM2M) editor.create_model(TagM2MTest) editor.creat...
[ "def", "test_m2m_repoint", "(", "self", ")", ":", "# Create the tables", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "editor", ".", "create_model", "(", "BookWithM2M", ")", "edit...
[ 613, 4 ]
[ 659, 44 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_check_constraints
(self)
Tests creating/deleting CHECK constraints
Tests creating/deleting CHECK constraints
def test_check_constraints(self): """ Tests creating/deleting CHECK constraints """ # Create the tables with connection.schema_editor() as editor: editor.create_model(Author) # Ensure the constraint exists constraints = self.get_constraints(Author._met...
[ "def", "test_check_constraints", "(", "self", ")", ":", "# Create the tables", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "# Ensure the constraint exists", "constraints", "=", "self",...
[ 662, 4 ]
[ 703, 61 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_unique
(self)
Tests removing and adding unique constraints to a single column.
Tests removing and adding unique constraints to a single column.
def test_unique(self): """ Tests removing and adding unique constraints to a single column. """ # Create the table with connection.schema_editor() as editor: editor.create_model(Tag) # Ensure the field is unique to begin with Tag.objects.create(title="...
[ "def", "test_unique", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Tag", ")", "# Ensure the field is unique to begin with", "Tag", ".", "objects", ".", ...
[ 705, 4 ]
[ 757, 34 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_unique_together
(self)
Tests removing and adding unique_together constraints on a model.
Tests removing and adding unique_together constraints on a model.
def test_unique_together(self): """ Tests removing and adding unique_together constraints on a model. """ # Create the table with connection.schema_editor() as editor: editor.create_model(UniqueTest) # Ensure the fields are unique to begin with UniqueT...
[ "def", "test_unique_together", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "UniqueTest", ")", "# Ensure the fields are unique to begin with", "UniqueTest", ...
[ 759, 4 ]
[ 795, 41 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_index_together
(self)
Tests removing and adding index_together constraints on a model.
Tests removing and adding index_together constraints on a model.
def test_index_together(self): """ Tests removing and adding index_together constraints on a model. """ # Create the table with connection.schema_editor() as editor: editor.create_model(Tag) # Ensure there's no index on the year/slug columns first self...
[ "def", "test_index_together", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Tag", ")", "# Ensure there's no index on the year/slug columns first", "self", "....
[ 797, 4 ]
[ 846, 9 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_create_index_together
(self)
Tests creating models with index_together already defined
Tests creating models with index_together already defined
def test_create_index_together(self): """ Tests creating models with index_together already defined """ # Create the table with connection.schema_editor() as editor: editor.create_model(TagIndexed) # Ensure there is an index self.assertEqual( ...
[ "def", "test_create_index_together", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "TagIndexed", ")", "# Ensure there is an index", "self", ".", "assertEqua...
[ 848, 4 ]
[ 863, 9 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_db_table
(self)
Tests renaming of the table
Tests renaming of the table
def test_db_table(self): """ Tests renaming of the table """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure the table is there to begin with columns = self.column_classes(Author) self.assertEq...
[ "def", "test_db_table", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "# Ensure the table is there to begin with", "columns", "=", "self", ...
[ 865, 4 ]
[ 896, 57 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_indexes
(self)
Tests creation/altering of indexes
Tests creation/altering of indexes
def test_indexes(self): """ Tests creation/altering of indexes """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) # Ensure the table is there and has the right index self....
[ "def", "test_indexes", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Author", ")", "editor", ".", "create_model", "(", "Book", ")", "# Ensure the tab...
[ 898, 4 ]
[ 962, 9 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_primary_key
(self)
Tests altering of the primary key
Tests altering of the primary key
def test_primary_key(self): """ Tests altering of the primary key """ # Create the table with connection.schema_editor() as editor: editor.create_model(Tag) # Ensure the table is there and has the right PK self.assertTrue( self.get_indexes(...
[ "def", "test_primary_key", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "Tag", ")", "# Ensure the table is there and has the right PK", "self", ".", "asser...
[ 964, 4 ]
[ 993, 9 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_context_manager_exit
(self)
Ensures transaction is correctly closed when an error occurs inside a SchemaEditor context.
Ensures transaction is correctly closed when an error occurs inside a SchemaEditor context.
def test_context_manager_exit(self): """ Ensures transaction is correctly closed when an error occurs inside a SchemaEditor context. """ class SomeError(Exception): pass try: with connection.schema_editor(): raise SomeError ...
[ "def", "test_context_manager_exit", "(", "self", ")", ":", "class", "SomeError", "(", "Exception", ")", ":", "pass", "try", ":", "with", "connection", ".", "schema_editor", "(", ")", ":", "raise", "SomeError", "except", "SomeError", ":", "self", ".", "assert...
[ 995, 4 ]
[ 1006, 56 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_foreign_key_index_long_names_regression
(self)
Regression test for #21497. Only affects databases that supports foreign keys.
Regression test for #21497. Only affects databases that supports foreign keys.
def test_foreign_key_index_long_names_regression(self): """ Regression test for #21497. Only affects databases that supports foreign keys. """ # Create the table with connection.schema_editor() as editor: editor.create_model(AuthorWithEvenLongerName) ...
[ "def", "test_foreign_key_index_long_names_regression", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "AuthorWithEvenLongerName", ")", "editor", ".", "create_m...
[ 1009, 4 ]
[ 1025, 9 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_add_foreign_key_long_names
(self)
Regression test for #23009. Only affects databases that supports foreign keys.
Regression test for #23009. Only affects databases that supports foreign keys.
def test_add_foreign_key_long_names(self): """ Regression test for #23009. Only affects databases that supports foreign keys. """ # Create the initial tables with connection.schema_editor() as editor: editor.create_model(AuthorWithEvenLongerName) e...
[ "def", "test_add_foreign_key_long_names", "(", "self", ")", ":", "# Create the initial tables", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "editor", ".", "create_model", "(", "AuthorWithEvenLongerName", ")", "editor", ".", "create_model...
[ 1028, 4 ]
[ 1044, 13 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_creation_deletion_reserved_names
(self)
Tries creating a model's table, and then deleting it when it has a SQL reserved name.
Tries creating a model's table, and then deleting it when it has a SQL reserved name.
def test_creation_deletion_reserved_names(self): """ Tries creating a model's table, and then deleting it when it has a SQL reserved name. """ # Create the table with connection.schema_editor() as editor: try: editor.create_model(Thing) ...
[ "def", "test_creation_deletion_reserved_names", "(", "self", ")", ":", "# Create the table", "with", "connection", ".", "schema_editor", "(", ")", "as", "editor", ":", "try", ":", "editor", ".", "create_model", "(", "Thing", ")", "except", "OperationalError", "as"...
[ 1046, 4 ]
[ 1067, 9 ]
python
en
['en', 'error', 'th']
False
SchemaTests.test_remove_constraints_capital_letters
(self)
#23065 - Constraint names must be quoted if they contain capital letters.
#23065 - Constraint names must be quoted if they contain capital letters.
def test_remove_constraints_capital_letters(self): """ #23065 - Constraint names must be quoted if they contain capital letters. """ def get_field(*args, **kwargs): kwargs['db_column'] = "CamelCase" field = kwargs.pop('field_class', IntegerField)(*args, **kwargs) ...
[ "def", "test_remove_constraints_capital_letters", "(", "self", ")", ":", "def", "get_field", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'db_column'", "]", "=", "\"CamelCase\"", "field", "=", "kwargs", ".", "pop", "(", "'field_class'...
[ 1070, 4 ]
[ 1117, 87 ]
python
en
['en', 'error', 'th']
False
render_field
( # noqa: C901 field, form, form_style, context, template=None, labelclass=None, layout_object=None, attrs=None, template_pack=TEMPLATE_PACK, extra_context=None, **kwargs )
Renders a django-crispy-forms field :param field: Can be a string or a Layout object like `Row`. If it's a layout object, we call its render method, otherwise we instantiate a BoundField and render it using default template 'CRISPY_TEMPLATE_PACK/field.html' The field is added to ...
Renders a django-crispy-forms field :param field: Can be a string or a Layout object like `Row`. If it's a layout object, we call its render method, otherwise we instantiate a BoundField and render it using default template 'CRISPY_TEMPLATE_PACK/field.html' The field is added to ...
def render_field( # noqa: C901 field, form, form_style, context, template=None, labelclass=None, layout_object=None, attrs=None, template_pack=TEMPLATE_PACK, extra_context=None, **kwargs ): """ Renders a django-crispy-forms field :param field: Ca...
[ "def", "render_field", "(", "# noqa: C901\r", "field", ",", "form", ",", "form_style", ",", "context", ",", "template", "=", "None", ",", "labelclass", "=", "None", ",", "layout_object", "=", "None", ",", "attrs", "=", "None", ",", "template_pack", "=", "T...
[ 27, 0 ]
[ 140, 19 ]
python
en
['en', 'ja', 'th']
False
flatatt
(attrs)
Convert a dictionary of attributes to a single string. Passed attributes are redirected to `django.forms.utils.flatatt()` with replaced "_" (underscores) by "-" (dashes) in their names.
Convert a dictionary of attributes to a single string. Passed attributes are redirected to `django.forms.utils.flatatt()` with replaced "_" (underscores) by "-" (dashes) in their names.
def flatatt(attrs): """ Convert a dictionary of attributes to a single string. Passed attributes are redirected to `django.forms.utils.flatatt()` with replaced "_" (underscores) by "-" (dashes) in their names. """ return _flatatt({k.replace("_", "-"): v for k, v in attrs.items()})
[ "def", "flatatt", "(", "attrs", ")", ":", "return", "_flatatt", "(", "{", "k", ".", "replace", "(", "\"_\"", ",", "\"-\"", ")", ":", "v", "for", "k", ",", "v", "in", "attrs", ".", "items", "(", ")", "}", ")" ]
[ 143, 0 ]
[ 150, 71 ]
python
en
['en', 'ja', 'th']
False
render_crispy_form
(form, helper=None, context=None)
Renders a form and returns its HTML output. This function wraps the template logic in a function easy to use in a Django view.
Renders a form and returns its HTML output. This function wraps the template logic in a function easy to use in a Django view.
def render_crispy_form(form, helper=None, context=None): """ Renders a form and returns its HTML output. This function wraps the template logic in a function easy to use in a Django view. """ from crispy_forms.templatetags.crispy_forms_tags import CrispyFormNode if helper is not None: ...
[ "def", "render_crispy_form", "(", "form", ",", "helper", "=", "None", ",", "context", "=", "None", ")", ":", "from", "crispy_forms", ".", "templatetags", ".", "crispy_forms_tags", "import", "CrispyFormNode", "if", "helper", "is", "not", "None", ":", "node", ...
[ 153, 0 ]
[ 169, 36 ]
python
en
['en', 'ja', 'th']
False