code stringlengths 1 1.49M | file_id stringlengths 42 46 | node_count int64 0 7.38k | total_lines int64 1 20.9k | vector_dim int64 15 15 | vector_labels stringclasses 1
value | nodes stringlengths 2 3.75M | connections stringlengths 2 964k |
|---|---|---|---|---|---|---|---|
"""
A generic comment-moderation system which allows configuration of
moderation options on a per-model basis.
To use, do two things:
1. Create or import a subclass of ``CommentModerator`` defining the
options you want.
2. Import ``moderator`` from this module and register one or more
models, passing the models and the ``CommentModerator`` options
class you want to use.
Example
-------
First, we define a simple model class which might represent entries in
a Weblog::
from django.db import models
class Entry(models.Model):
title = models.CharField(maxlength=250)
body = models.TextField()
pub_date = models.DateField()
enable_comments = models.BooleanField()
Then we create a ``CommentModerator`` subclass specifying some
moderation options::
from django.contrib.comments.moderation import CommentModerator, moderator
class EntryModerator(CommentModerator):
email_notification = True
enable_field = 'enable_comments'
And finally register it for moderation::
moderator.register(Entry, EntryModerator)
This sample class would apply two moderation steps to each new
comment submitted on an Entry:
* If the entry's ``enable_comments`` field is set to ``False``, the
comment will be rejected (immediately deleted).
* If the comment is successfully posted, an email notification of the
comment will be sent to site staff.
For a full list of built-in moderation options and other
configurability, see the documentation for the ``CommentModerator``
class.
"""
import datetime
from django.conf import settings
from django.core.mail import send_mail
from django.contrib.comments import signals
from django.db.models.base import ModelBase
from django.template import Context, loader
from django.contrib import comments
from django.contrib.sites.models import Site
class AlreadyModerated(Exception):
"""
Raised when a model which is already registered for moderation is
attempting to be registered again.
"""
pass
class NotModerated(Exception):
"""
Raised when a model which is not registered for moderation is
attempting to be unregistered.
"""
pass
class CommentModerator(object):
"""
Encapsulates comment-moderation options for a given model.
This class is not designed to be used directly, since it doesn't
enable any of the available moderation options. Instead, subclass
it and override attributes to enable different options::
``auto_close_field``
If this is set to the name of a ``DateField`` or
``DateTimeField`` on the model for which comments are
being moderated, new comments for objects of that model
will be disallowed (immediately deleted) when a certain
number of days have passed after the date specified in
that field. Must be used in conjunction with
``close_after``, which specifies the number of days past
which comments should be disallowed. Default value is
``None``.
``auto_moderate_field``
Like ``auto_close_field``, but instead of outright
deleting new comments when the requisite number of days
have elapsed, it will simply set the ``is_public`` field
of new comments to ``False`` before saving them. Must be
used in conjunction with ``moderate_after``, which
specifies the number of days past which comments should be
moderated. Default value is ``None``.
``close_after``
If ``auto_close_field`` is used, this must specify the
number of days past the value of the field specified by
``auto_close_field`` after which new comments for an
object should be disallowed. Default value is ``None``.
``email_notification``
If ``True``, any new comment on an object of this model
which survives moderation will generate an email to site
staff. Default value is ``False``.
``enable_field``
If this is set to the name of a ``BooleanField`` on the
model for which comments are being moderated, new comments
on objects of that model will be disallowed (immediately
deleted) whenever the value of that field is ``False`` on
the object the comment would be attached to. Default value
is ``None``.
``moderate_after``
If ``auto_moderate_field`` is used, this must specify the number
of days past the value of the field specified by
``auto_moderate_field`` after which new comments for an
object should be marked non-public. Default value is
``None``.
Most common moderation needs can be covered by changing these
attributes, but further customization can be obtained by
subclassing and overriding the following methods. Each method will
be called with three arguments: ``comment``, which is the comment
being submitted, ``content_object``, which is the object the
comment will be attached to, and ``request``, which is the
``HttpRequest`` in which the comment is being submitted::
``allow``
Should return ``True`` if the comment should be allowed to
post on the content object, and ``False`` otherwise (in
which case the comment will be immediately deleted).
``email``
If email notification of the new comment should be sent to
site staff or moderators, this method is responsible for
sending the email.
``moderate``
Should return ``True`` if the comment should be moderated
(in which case its ``is_public`` field will be set to
``False`` before saving), and ``False`` otherwise (in
which case the ``is_public`` field will not be changed).
Subclasses which want to introspect the model for which comments
are being moderated can do so through the attribute ``_model``,
which will be the model class.
"""
auto_close_field = None
auto_moderate_field = None
close_after = None
email_notification = False
enable_field = None
moderate_after = None
def __init__(self, model):
self._model = model
def _get_delta(self, now, then):
"""
Internal helper which will return a ``datetime.timedelta``
representing the time between ``now`` and ``then``. Assumes
``now`` is a ``datetime.date`` or ``datetime.datetime`` later
than ``then``.
If ``now`` and ``then`` are not of the same type due to one of
them being a ``datetime.date`` and the other being a
``datetime.datetime``, both will be coerced to
``datetime.date`` before calculating the delta.
"""
if now.__class__ is not then.__class__:
now = datetime.date(now.year, now.month, now.day)
then = datetime.date(then.year, then.month, then.day)
if now < then:
raise ValueError("Cannot determine moderation rules because date field is set to a value in the future")
return now - then
def allow(self, comment, content_object, request):
"""
Determine whether a given comment is allowed to be posted on
a given object.
Return ``True`` if the comment should be allowed, ``False
otherwise.
"""
if self.enable_field:
if not getattr(content_object, self.enable_field):
return False
if self.auto_close_field and self.close_after is not None:
close_after_date = getattr(content_object, self.auto_close_field)
if close_after_date is not None and self._get_delta(datetime.datetime.now(), close_after_date).days >= self.close_after:
return False
return True
def moderate(self, comment, content_object, request):
"""
Determine whether a given comment on a given object should be
allowed to show up immediately, or should be marked non-public
and await approval.
Return ``True`` if the comment should be moderated (marked
non-public), ``False`` otherwise.
"""
if self.auto_moderate_field and self.moderate_after is not None:
moderate_after_date = getattr(content_object, self.auto_moderate_field)
if moderate_after_date is not None and self._get_delta(datetime.datetime.now(), moderate_after_date).days >= self.moderate_after:
return True
return False
def email(self, comment, content_object, request):
"""
Send email notification of a new comment to site staff when email
notifications have been requested.
"""
if not self.email_notification:
return
recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS]
t = loader.get_template('comments/comment_notification_email.txt')
c = Context({ 'comment': comment,
'content_object': content_object })
subject = '[%s] New comment posted on "%s"' % (Site.objects.get_current().name,
content_object)
message = t.render(c)
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True)
class Moderator(object):
"""
Handles moderation of a set of models.
An instance of this class will maintain a list of one or more
models registered for comment moderation, and their associated
moderation classes, and apply moderation to all incoming comments.
To register a model, obtain an instance of ``Moderator`` (this
module exports one as ``moderator``), and call its ``register``
method, passing the model class and a moderation class (which
should be a subclass of ``CommentModerator``). Note that both of
these should be the actual classes, not instances of the classes.
To cease moderation for a model, call the ``unregister`` method,
passing the model class.
For convenience, both ``register`` and ``unregister`` can also
accept a list of model classes in place of a single model; this
allows easier registration of multiple models with the same
``CommentModerator`` class.
The actual moderation is applied in two phases: one prior to
saving a new comment, and the other immediately after saving. The
pre-save moderation may mark a comment as non-public or mark it to
be removed; the post-save moderation may delete a comment which
was disallowed (there is currently no way to prevent the comment
being saved once before removal) and, if the comment is still
around, will send any notification emails the comment generated.
"""
def __init__(self):
self._registry = {}
self.connect()
def connect(self):
"""
Hook up the moderation methods to pre- and post-save signals
from the comment models.
"""
signals.comment_will_be_posted.connect(self.pre_save_moderation, sender=comments.get_model())
signals.comment_was_posted.connect(self.post_save_moderation, sender=comments.get_model())
def register(self, model_or_iterable, moderation_class):
"""
Register a model or a list of models for comment moderation,
using a particular moderation class.
Raise ``AlreadyModerated`` if any of the models are already
registered.
"""
if isinstance(model_or_iterable, ModelBase):
model_or_iterable = [model_or_iterable]
for model in model_or_iterable:
if model in self._registry:
raise AlreadyModerated("The model '%s' is already being moderated" % model._meta.module_name)
self._registry[model] = moderation_class(model)
def unregister(self, model_or_iterable):
"""
Remove a model or a list of models from the list of models
whose comments will be moderated.
Raise ``NotModerated`` if any of the models are not currently
registered for moderation.
"""
if isinstance(model_or_iterable, ModelBase):
model_or_iterable = [model_or_iterable]
for model in model_or_iterable:
if model not in self._registry:
raise NotModerated("The model '%s' is not currently being moderated" % model._meta.module_name)
del self._registry[model]
def pre_save_moderation(self, sender, comment, request, **kwargs):
"""
Apply any necessary pre-save moderation steps to new
comments.
"""
model = comment.content_type.model_class()
if model not in self._registry:
return
content_object = comment.content_object
moderation_class = self._registry[model]
# Comment will be disallowed outright (HTTP 403 response)
if not moderation_class.allow(comment, content_object, request):
return False
if moderation_class.moderate(comment, content_object, request):
comment.is_public = False
def post_save_moderation(self, sender, comment, request, **kwargs):
"""
Apply any necessary post-save moderation steps to new
comments.
"""
model = comment.content_type.model_class()
if model not in self._registry:
return
self._registry[model].email(comment, comment.content_object, request)
# Import this instance in your own code to use in registering
# your models for moderation.
moderator = Moderator()
| ajibawa-2023/Python-Code-Large/train/row_98589 | 97 | 355 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 55], "level": 0, "parent": null, "vector": [8, 0, 0.0789, 0.1549, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nA generic comment-moderation system which allows configuration of\nmoderation options on a per-model basis.\n\nTo use, do two things:\n\n1. Create or import a subclass of ``CommentModerator`` defining the\n options you want."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Import_L57_C0", "label": "datetime import datetime", "type": "import", "loc": [57, 57], "level": 0, "parent": null, "vector": [1, 0, 0.1606, 0.0028, 0, 0.66, 0.0769, 426, 0, 1, 0, 0, 426, 0, 0], "semantic": {"name": "datetime", "arg_names": [], "import_names": ["datetime"], "rhs_call_name": "", "annotation": ""}, "snippet": "import datetime"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:ImportFrom_L59_C0", "label": "from django.conf import settings", "type": "import", "loc": [59, 59], "level": 0, "parent": null, "vector": [1, 0, 0.1662, 0.0028, 0, 0.66, 0.1538, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:ImportFrom_L60_C0", "label": "from django.core.mail import send_mail", "type": "import", "loc": [60, 60], "level": 0, "parent": null, "vector": [1, 0, 0.169, 0.0028, 0, 0.66, 0.2308, 537, 0, 1, 0, 0, 537, 0, 0], "semantic": {"name": "django.core.mail", "arg_names": [], "import_names": ["send_mail"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.mail import send_mail"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:ImportFrom_L61_C0", "label": "from django.contrib.comments import signals", "type": "import", "loc": [61, 61], "level": 0, "parent": null, "vector": [1, 0, 0.1718, 0.0028, 0, 0.66, 0.3077, 45, 0, 1, 0, 0, 45, 0, 0], "semantic": {"name": "django.contrib.comments", "arg_names": [], "import_names": ["signals"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.comments import signals"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:ImportFrom_L62_C0", "label": "from django.db.models.base import ModelBase", "type": "import", "loc": [62, 62], "level": 0, "parent": null, "vector": [1, 0, 0.1746, 0.0028, 0, 0.66, 0.3846, 465, 0, 1, 0, 0, 465, 0, 0], "semantic": {"name": "django.db.models.base", "arg_names": [], "import_names": ["ModelBase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models.base import ModelBase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:ImportFrom_L63_C0", "label": "from django.template import Context, loader", "type": "import", "loc": [63, 63], "level": 0, "parent": null, "vector": [1, 0, 0.1775, 0.0028, 0, 0.66, 0.4615, 213, 0, 2, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["Context", "loader"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import Context, loader"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:ImportFrom_L64_C0", "label": "from django.contrib import comments", "type": "import", "loc": [64, 64], "level": 0, "parent": null, "vector": [1, 0, 0.1803, 0.0028, 0, 0.66, 0.5385, 302, 0, 1, 0, 0, 302, 0, 0], "semantic": {"name": "django.contrib", "arg_names": [], "import_names": ["comments"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib import comments"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:ImportFrom_L65_C0", "label": "from django.contrib.sites.models import Site", "type": "import", "loc": [65, 65], "level": 0, "parent": null, "vector": [1, 0, 0.1831, 0.0028, 0, 0.66, 0.6154, 890, 0, 1, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sites.models", "arg_names": [], "import_names": ["Site"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sites.models import Site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L67_C0", "label": "AlreadyModerated", "type": "class", "loc": [67, 73], "level": 0, "parent": null, "vector": [3, 0, 0.1972, 0.0197, 0, 0.66, 0.6923, 706, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "AlreadyModerated", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AlreadyModerated(Exception):\n \"\"\"\n Raised when a model which is already registered for moderation is\n attempting to be registered again.\n\n \"\"\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L68_C4", "label": "expression", "type": "expression", "loc": [68, 72], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L67_C0", "vector": [8, 1, 0.1972, 0.0141, 1, 0.52, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Raised when a model which is already registered for moderation is\n attempting to be registered again.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L75_C0", "label": "NotModerated", "type": "class", "loc": [75, 81], "level": 0, "parent": null, "vector": [3, 0, 0.2197, 0.0197, 0, 0.66, 0.7692, 341, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "NotModerated", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class NotModerated(Exception):\n \"\"\"\n Raised when a model which is not registered for moderation is\n attempting to be unregistered.\n\n \"\"\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L76_C4", "label": "expression", "type": "expression", "loc": [76, 80], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L75_C0", "vector": [8, 1, 0.2197, 0.0141, 1, 0.32, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Raised when a model which is not registered for moderation is\n attempting to be unregistered.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "label": "CommentModerator", "type": "class", "loc": [83, 245], "level": 0, "parent": null, "vector": [3, 0, 0.462, 0.4592, 0, 0.66, 0.8462, 883, 0, 5, 0, 0, 186, 0, 15], "semantic": {"name": "CommentModerator", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CommentModerator(object):\n \"\"\"\n Encapsulates comment-moderation options for a given model.\n\n This class is not designed to be used directly, since it doesn't\n enable any of the available moderation options. Instead, subclass\n it and override attributes to enable different options::\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L84_C4", "label": "expression", "type": "expression", "loc": [84, 165], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "vector": [8, 1, 0.3507, 0.231, 1, 0.73, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Encapsulates comment-moderation options for a given model.\n\n This class is not designed to be used directly, since it doesn't\n enable any of the available moderation options. Instead, subclass\n it and override attributes to enable different options::\n\n ``auto_close_field``"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L166_C4", "label": "auto_close_field =", "type": "assigned_variable", "loc": [166, 166], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "vector": [14, 1, 0.4676, 0.0028, 1, 0.73, 0.0909, 501, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "auto_close_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " auto_close_field = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L167_C4", "label": "auto_moderate_field =", "type": "assigned_variable", "loc": [167, 167], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "vector": [14, 1, 0.4704, 0.0028, 1, 0.73, 0.1818, 200, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "auto_moderate_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " auto_moderate_field = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L168_C4", "label": "close_after =", "type": "assigned_variable", "loc": [168, 168], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "vector": [14, 1, 0.4732, 0.0028, 1, 0.73, 0.2727, 905, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "close_after", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " close_after = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L169_C4", "label": "email_notification =", "type": "assigned_variable", "loc": [169, 169], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "vector": [14, 1, 0.4761, 0.0028, 1, 0.73, 0.3636, 416, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "email_notification", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " email_notification = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L170_C4", "label": "enable_field =", "type": "assigned_variable", "loc": [170, 170], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "vector": [14, 1, 0.4789, 0.0028, 1, 0.73, 0.4545, 388, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "enable_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " enable_field = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L171_C4", "label": "moderate_after =", "type": "assigned_variable", "loc": [171, 171], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "vector": [14, 1, 0.4817, 0.0028, 1, 0.73, 0.5455, 412, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "moderate_after", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " moderate_after = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L173_C4", "label": "__init__", "type": "function", "loc": [173, 174], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "vector": [2, 1, 0.4887, 0.0056, 1, 0.73, 0.6364, 555, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "model"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, model):\n self._model = model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L174_C8", "label": "self._model =", "type": "assigned_variable", "loc": [174, 174], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L173_C4", "vector": [14, 2, 0.4901, 0.0028, 2, 0.3, 0.0, 580, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._model = model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L176_C4", "label": "_get_delta", "type": "function", "loc": [176, 194], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "vector": [2, 1, 0.5211, 0.0535, 1, 0.73, 0.7273, 563, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "_get_delta", "arg_names": ["self", "now", "then"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_delta(self, now, then):\n \"\"\"\n Internal helper which will return a ``datetime.timedelta``\n representing the time between ``now`` and ``then``. Assumes\n ``now`` is a ``datetime.date`` or ``datetime.datetime`` later\n than ``then``.\n\n If ``now`` and ``then`` are not of the same type due to one of"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L177_C8", "label": "expression", "type": "expression", "loc": [177, 188], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L176_C4", "vector": [8, 2, 0.5141, 0.0338, 2, 0.94, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Internal helper which will return a ``datetime.timedelta``\n representing the time between ``now`` and ``then``. Assumes\n ``now`` is a ``datetime.date`` or ``datetime.datetime`` later\n than ``then``.\n\n If ``now`` and ``then`` are not of the same type due to one of\n them being a ``datetime.date`` and the other being a"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L189_C8", "label": "if", "type": "if", "loc": [189, 191], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L176_C4", "vector": [4, 2, 0.5352, 0.0085, 2, 0.94, 0.3333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if now.__class__ is not then.__class__:\n now = datetime.date(now.year, now.month, now.day)\n then = datetime.date(then.year, then.month, then.day)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L190_C12", "label": "now = date()", "type": "assigned_variable", "loc": [190, 190], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L189_C8", "vector": [14, 3, 0.5352, 0.0028, 3, 0.51, 0.0, 894, 3, 3, 0, 0, 56, 10, 1], "semantic": {"name": "now", "arg_names": [], "import_names": [], "rhs_call_name": "date", "annotation": ""}, "snippet": " now = datetime.date(now.year, now.month, now.day)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L191_C12", "label": "then = date()", "type": "assigned_variable", "loc": [191, 191], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L189_C8", "vector": [14, 3, 0.538, 0.0028, 3, 0.51, 1.0, 896, 3, 3, 0, 0, 56, 10, 1], "semantic": {"name": "then", "arg_names": [], "import_names": [], "rhs_call_name": "date", "annotation": ""}, "snippet": " then = datetime.date(then.year, then.month, then.day)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L192_C8", "label": "if", "type": "if", "loc": [192, 193], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L176_C4", "vector": [4, 2, 0.5423, 0.0056, 2, 0.94, 0.6667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if now < then:\n raise ValueError(\"Cannot determine moderation rules because date field is set to a value in the future\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L194_C8", "label": "return", "type": "return", "loc": [194, 194], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L176_C4", "vector": [13, 2, 0.5465, 0.0028, 2, 0.94, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return now - then"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L196_C4", "label": "allow", "type": "function", "loc": [196, 212], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "vector": [2, 1, 0.5746, 0.0479, 1, 0.73, 0.8182, 319, 0, 4, 1, 0, 0, 0, 4], "semantic": {"name": "allow", "arg_names": ["self", "comment", "content_object", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def allow(self, comment, content_object, request):\n \"\"\"\n Determine whether a given comment is allowed to be posted on\n a given object.\n\n Return ``True`` if the comment should be allowed, ``False\n otherwise.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L197_C8", "label": "expression", "type": "expression", "loc": [197, 204], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L196_C4", "vector": [8, 2, 0.5648, 0.0225, 2, 0.59, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Determine whether a given comment is allowed to be posted on\n a given object.\n\n Return ``True`` if the comment should be allowed, ``False\n otherwise.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L205_C8", "label": "if", "type": "if", "loc": [205, 207], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L196_C4", "vector": [4, 2, 0.5803, 0.0085, 2, 0.59, 0.3333, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.enable_field:\n if not getattr(content_object, self.enable_field):\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L206_C12", "label": "if", "type": "if", "loc": [206, 207], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L205_C8", "vector": [4, 3, 0.5817, 0.0056, 3, 0.34, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not getattr(content_object, self.enable_field):\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L207_C16", "label": "return", "type": "return", "loc": [207, 207], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L206_C12", "vector": [13, 4, 0.5831, 0.0028, 4, 0.07, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L208_C8", "label": "if", "type": "if", "loc": [208, 211], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L196_C4", "vector": [4, 2, 0.5901, 0.0113, 2, 0.59, 0.6667, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.auto_close_field and self.close_after is not None:\n close_after_date = getattr(content_object, self.auto_close_field)\n if close_after_date is not None and self._get_delta(datetime.datetime.now(), close_after_date).days >= self.close_after:\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L209_C12", "label": "close_after_date = getattr()", "type": "assigned_variable", "loc": [209, 209], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L208_C8", "vector": [14, 3, 0.5887, 0.0028, 3, 0.24, 0.0, 836, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "close_after_date", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " close_after_date = getattr(content_object, self.auto_close_field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L210_C12", "label": "if", "type": "if", "loc": [210, 211], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L208_C8", "vector": [4, 3, 0.593, 0.0056, 3, 0.24, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if close_after_date is not None and self._get_delta(datetime.datetime.now(), close_after_date).days >= self.close_after:\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L211_C16", "label": "return", "type": "return", "loc": [211, 211], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L210_C12", "vector": [13, 4, 0.5944, 0.0028, 4, 0.96, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L212_C8", "label": "return", "type": "return", "loc": [212, 212], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L196_C4", "vector": [13, 2, 0.5972, 0.0028, 2, 0.59, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L214_C4", "label": "moderate", "type": "function", "loc": [214, 228], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "vector": [2, 1, 0.6225, 0.0423, 1, 0.73, 0.9091, 289, 0, 4, 1, 0, 0, 0, 3], "semantic": {"name": "moderate", "arg_names": ["self", "comment", "content_object", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def moderate(self, comment, content_object, request):\n \"\"\"\n Determine whether a given comment on a given object should be\n allowed to show up immediately, or should be marked non-public\n and await approval.\n\n Return ``True`` if the comment should be moderated (marked\n non-public), ``False`` otherwise."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L215_C8", "label": "expression", "type": "expression", "loc": [215, 223], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L214_C4", "vector": [8, 2, 0.6169, 0.0254, 2, 0.39, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Determine whether a given comment on a given object should be\n allowed to show up immediately, or should be marked non-public\n and await approval.\n\n Return ``True`` if the comment should be moderated (marked\n non-public), ``False`` otherwise.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L224_C8", "label": "if", "type": "if", "loc": [224, 227], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L214_C4", "vector": [4, 2, 0.6352, 0.0113, 2, 0.39, 0.5, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.auto_moderate_field and self.moderate_after is not None:\n moderate_after_date = getattr(content_object, self.auto_moderate_field)\n if moderate_after_date is not None and self._get_delta(datetime.datetime.now(), moderate_after_date).days >= self.moderate_after:\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L225_C12", "label": "moderate_after_date = getattr()", "type": "assigned_variable", "loc": [225, 225], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L224_C8", "vector": [14, 3, 0.6338, 0.0028, 3, 0.21, 0.0, 113, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "moderate_after_date", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " moderate_after_date = getattr(content_object, self.auto_moderate_field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L226_C12", "label": "if", "type": "if", "loc": [226, 227], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L224_C8", "vector": [4, 3, 0.638, 0.0056, 3, 0.21, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if moderate_after_date is not None and self._get_delta(datetime.datetime.now(), moderate_after_date).days >= self.moderate_after:\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L227_C16", "label": "return", "type": "return", "loc": [227, 227], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L226_C12", "vector": [13, 4, 0.6394, 0.0028, 4, 0.22, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L228_C8", "label": "return", "type": "return", "loc": [228, 228], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L214_C4", "vector": [13, 2, 0.6423, 0.0028, 2, 0.39, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "label": "email", "type": "function", "loc": [230, 245], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "vector": [2, 1, 0.669, 0.0451, 1, 0.73, 1.0, 413, 0, 4, 0, 0, 0, 0, 5], "semantic": {"name": "email", "arg_names": ["self", "comment", "content_object", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def email(self, comment, content_object, request):\n \"\"\"\n Send email notification of a new comment to site staff when email\n notifications have been requested.\n\n \"\"\"\n if not self.email_notification:\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L231_C8", "label": "expression", "type": "expression", "loc": [231, 235], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "vector": [8, 2, 0.6563, 0.0141, 2, 0.93, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Send email notification of a new comment to site staff when email\n notifications have been requested.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L236_C8", "label": "if", "type": "if", "loc": [236, 237], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "vector": [4, 2, 0.6662, 0.0056, 2, 0.93, 0.1429, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.email_notification:\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L237_C12", "label": "return", "type": "return", "loc": [237, 237], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L236_C8", "vector": [13, 3, 0.6676, 0.0028, 3, 0.72, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L238_C8", "label": "recipient_list =", "type": "assigned_variable", "loc": [238, 238], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "vector": [14, 2, 0.6704, 0.0028, 2, 0.93, 0.2857, 778, 5, 0, 0, 0, 0, 0, 0], "semantic": {"name": "recipient_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L239_C8", "label": "t = get_template()", "type": "assigned_variable", "loc": [239, 239], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "vector": [14, 2, 0.6732, 0.0028, 2, 0.93, 0.4286, 15, 3, 1, 0, 0, 27, 10, 1], "semantic": {"name": "t", "arg_names": [], "import_names": [], "rhs_call_name": "get_template", "annotation": ""}, "snippet": " t = loader.get_template('comments/comment_notification_email.txt')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L240_C8", "label": "c = Context()", "type": "assigned_variable", "loc": [240, 241], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "vector": [14, 2, 0.6775, 0.0056, 2, 0.93, 0.5714, 411, 3, 1, 0, 0, 560, 10, 1], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "Context", "annotation": ""}, "snippet": " c = Context({ 'comment': comment,\n 'content_object': content_object })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L242_C8", "label": "subject =", "type": "assigned_variable", "loc": [242, 243], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "vector": [14, 2, 0.6831, 0.0056, 2, 0.93, 0.7143, 241, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "subject", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " subject = '[%s] New comment posted on \"%s\"' % (Site.objects.get_current().name,\n content_object)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L244_C8", "label": "message = render()", "type": "assigned_variable", "loc": [244, 244], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "vector": [14, 2, 0.6873, 0.0028, 2, 0.93, 0.8571, 635, 3, 1, 0, 0, 24, 10, 1], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "render", "annotation": ""}, "snippet": " message = t.render(c)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L245_C8", "label": "send_mail()", "type": "expression", "loc": [245, 245], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "vector": [8, 2, 0.6901, 0.0028, 2, 0.93, 1.0, 975, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "send_mail", "arg_names": [], "import_names": [], "rhs_call_name": "send_mail", "annotation": ""}, "snippet": " send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "label": "Moderator", "type": "class", "loc": [247, 351], "level": 0, "parent": null, "vector": [3, 0, 0.8423, 0.2958, 0, 0.66, 0.9231, 691, 0, 6, 0, 0, 186, 0, 15], "semantic": {"name": "Moderator", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Moderator(object):\n \"\"\"\n Handles moderation of a set of models.\n\n An instance of this class will maintain a list of one or more\n models registered for comment moderation, and their associated\n moderation classes, and apply moderation to all incoming comments.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L248_C4", "label": "expression", "type": "expression", "loc": [248, 277], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "vector": [8, 1, 0.7394, 0.0845, 1, 0.93, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Handles moderation of a set of models.\n\n An instance of this class will maintain a list of one or more\n models registered for comment moderation, and their associated\n moderation classes, and apply moderation to all incoming comments.\n\n To register a model, obtain an instance of ``Moderator`` (this"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L278_C4", "label": "__init__", "type": "function", "loc": [278, 280], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "vector": [2, 1, 0.7859, 0.0085, 1, 0.93, 0.1667, 555, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self):\n self._registry = {}\n self.connect()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L279_C8", "label": "self._registry =", "type": "assigned_variable", "loc": [279, 279], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L278_C4", "vector": [14, 2, 0.7859, 0.0028, 2, 0.48, 0.0, 394, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "self._registry", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._registry = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L280_C8", "label": "connect()", "type": "expression", "loc": [280, 280], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L278_C4", "vector": [8, 2, 0.7887, 0.0028, 2, 0.48, 1.0, 242, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "connect", "arg_names": [], "import_names": [], "rhs_call_name": "connect", "annotation": ""}, "snippet": " self.connect()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L282_C4", "label": "connect", "type": "function", "loc": [282, 289], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "vector": [2, 1, 0.8042, 0.0225, 1, 0.93, 0.3333, 242, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "connect", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def connect(self):\n \"\"\"\n Hook up the moderation methods to pre- and post-save signals\n from the comment models.\n\n \"\"\"\n signals.comment_will_be_posted.connect(self.pre_save_moderation, sender=comments.get_model())\n signals.comment_was_posted.connect(self.post_save_moderation, sender=comments.get_model())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L283_C8", "label": "expression", "type": "expression", "loc": [283, 287], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L282_C4", "vector": [8, 2, 0.8028, 0.0141, 2, 0.54, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Hook up the moderation methods to pre- and post-save signals\n from the comment models.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L288_C8", "label": "connect()", "type": "expression", "loc": [288, 288], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L282_C4", "vector": [8, 2, 0.8113, 0.0028, 2, 0.54, 0.5, 242, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "connect", "arg_names": [], "import_names": [], "rhs_call_name": "connect", "annotation": ""}, "snippet": " signals.comment_will_be_posted.connect(self.pre_save_moderation, sender=comments.get_model())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L289_C8", "label": "connect()", "type": "expression", "loc": [289, 289], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L282_C4", "vector": [8, 2, 0.8141, 0.0028, 2, 0.54, 1.0, 242, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "connect", "arg_names": [], "import_names": [], "rhs_call_name": "connect", "annotation": ""}, "snippet": " signals.comment_was_posted.connect(self.post_save_moderation, sender=comments.get_model())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L291_C4", "label": "register", "type": "function", "loc": [291, 305], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "vector": [2, 1, 0.8394, 0.0423, 1, 0.93, 0.5, 276, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "register", "arg_names": ["self", "model_or_iterable", "moderation_class"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def register(self, model_or_iterable, moderation_class):\n \"\"\"\n Register a model or a list of models for comment moderation,\n using a particular moderation class.\n\n Raise ``AlreadyModerated`` if any of the models are already\n registered.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L292_C8", "label": "expression", "type": "expression", "loc": [292, 299], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L291_C4", "vector": [8, 2, 0.8324, 0.0225, 2, 0.89, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Register a model or a list of models for comment moderation,\n using a particular moderation class.\n\n Raise ``AlreadyModerated`` if any of the models are already\n registered.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L300_C8", "label": "if", "type": "if", "loc": [300, 301], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L291_C4", "vector": [4, 2, 0.8465, 0.0056, 2, 0.89, 0.5, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(model_or_iterable, ModelBase):\n model_or_iterable = [model_or_iterable]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L301_C12", "label": "model_or_iterable =", "type": "assigned_variable", "loc": [301, 301], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L300_C8", "vector": [14, 3, 0.8479, 0.0028, 3, 0.58, 0.0, 624, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "model_or_iterable", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model_or_iterable = [model_or_iterable]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:For_L302_C8", "label": "for model", "type": "for", "loc": [302, 305], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L291_C4", "vector": [6, 2, 0.8549, 0.0113, 2, 0.89, 1.0, 722, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model in model_or_iterable:\n if model in self._registry:\n raise AlreadyModerated(\"The model '%s' is already being moderated\" % model._meta.module_name)\n self._registry[model] = moderation_class(model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L303_C12", "label": "if", "type": "if", "loc": [303, 304], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:For_L302_C8", "vector": [4, 3, 0.8549, 0.0056, 3, 0.94, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if model in self._registry:\n raise AlreadyModerated(\"The model '%s' is already being moderated\" % model._meta.module_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L305_C12", "label": " = moderation_class()", "type": "assigned_variable", "loc": [305, 305], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:For_L302_C8", "vector": [14, 3, 0.8592, 0.0028, 3, 0.94, 1.0, 0, 3, 1, 0, 0, 540, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "moderation_class", "annotation": ""}, "snippet": " self._registry[model] = moderation_class(model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L307_C4", "label": "unregister", "type": "function", "loc": [307, 321], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "vector": [2, 1, 0.8845, 0.0423, 1, 0.93, 0.6667, 614, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "unregister", "arg_names": ["self", "model_or_iterable"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def unregister(self, model_or_iterable):\n \"\"\"\n Remove a model or a list of models from the list of models\n whose comments will be moderated.\n\n Raise ``NotModerated`` if any of the models are not currently\n registered for moderation.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L308_C8", "label": "expression", "type": "expression", "loc": [308, 315], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L307_C4", "vector": [8, 2, 0.8775, 0.0225, 2, 0.84, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Remove a model or a list of models from the list of models\n whose comments will be moderated.\n\n Raise ``NotModerated`` if any of the models are not currently\n registered for moderation.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L316_C8", "label": "if", "type": "if", "loc": [316, 317], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L307_C4", "vector": [4, 2, 0.8915, 0.0056, 2, 0.84, 0.5, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(model_or_iterable, ModelBase):\n model_or_iterable = [model_or_iterable]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L317_C12", "label": "model_or_iterable =", "type": "assigned_variable", "loc": [317, 317], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L316_C8", "vector": [14, 3, 0.893, 0.0028, 3, 0.58, 0.0, 624, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "model_or_iterable", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model_or_iterable = [model_or_iterable]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:For_L318_C8", "label": "for model", "type": "for", "loc": [318, 321], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L307_C4", "vector": [6, 2, 0.9, 0.0113, 2, 0.84, 1.0, 722, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model in model_or_iterable:\n if model not in self._registry:\n raise NotModerated(\"The model '%s' is not currently being moderated\" % model._meta.module_name)\n del self._registry[model]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L319_C12", "label": "if", "type": "if", "loc": [319, 320], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:For_L318_C8", "vector": [4, 3, 0.9, 0.0056, 3, 0.38, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if model not in self._registry:\n raise NotModerated(\"The model '%s' is not currently being moderated\" % model._meta.module_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "label": "pre_save_moderation", "type": "function", "loc": [323, 340], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "vector": [2, 1, 0.9338, 0.0507, 1, 0.93, 0.8333, 685, 0, 5, 1, 0, 0, 0, 3], "semantic": {"name": "pre_save_moderation", "arg_names": ["self", "sender", "comment", "request", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def pre_save_moderation(self, sender, comment, request, **kwargs):\n \"\"\"\n Apply any necessary pre-save moderation steps to new\n comments.\n\n \"\"\"\n model = comment.content_type.model_class()\n if model not in self._registry:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L324_C8", "label": "expression", "type": "expression", "loc": [324, 328], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "vector": [8, 2, 0.9183, 0.0141, 2, 0.82, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Apply any necessary pre-save moderation steps to new\n comments.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L329_C8", "label": "model = model_class()", "type": "assigned_variable", "loc": [329, 329], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "vector": [14, 2, 0.9268, 0.0028, 2, 0.82, 0.1667, 722, 3, 0, 0, 0, 826, 10, 1], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "model_class", "annotation": ""}, "snippet": " model = comment.content_type.model_class()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L330_C8", "label": "if", "type": "if", "loc": [330, 331], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "vector": [4, 2, 0.931, 0.0056, 2, 0.82, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if model not in self._registry:\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L331_C12", "label": "return", "type": "return", "loc": [331, 331], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L330_C8", "vector": [13, 3, 0.9324, 0.0028, 3, 0.23, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L332_C8", "label": "content_object =", "type": "assigned_variable", "loc": [332, 332], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "vector": [14, 2, 0.9352, 0.0028, 2, 0.82, 0.5, 646, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "content_object", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " content_object = comment.content_object"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L333_C8", "label": "moderation_class =", "type": "assigned_variable", "loc": [333, 333], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "vector": [14, 2, 0.938, 0.0028, 2, 0.82, 0.6667, 540, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "moderation_class", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " moderation_class = self._registry[model]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L336_C8", "label": "if", "type": "if", "loc": [336, 337], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "vector": [4, 2, 0.9479, 0.0056, 2, 0.82, 0.8333, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not moderation_class.allow(comment, content_object, request): \n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L337_C12", "label": "return", "type": "return", "loc": [337, 337], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L336_C8", "vector": [13, 3, 0.9493, 0.0028, 3, 0.88, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L339_C8", "label": "if", "type": "if", "loc": [339, 340], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "vector": [4, 2, 0.9563, 0.0056, 2, 0.82, 1.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if moderation_class.moderate(comment, content_object, request):\n comment.is_public = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L340_C12", "label": "comment.is_public =", "type": "assigned_variable", "loc": [340, 340], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L339_C8", "vector": [14, 3, 0.9577, 0.0028, 3, 0.28, 0.0, 498, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "comment.is_public", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " comment.is_public = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L342_C4", "label": "post_save_moderation", "type": "function", "loc": [342, 351], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "vector": [2, 1, 0.9761, 0.0282, 1, 0.93, 1.0, 425, 0, 5, 0, 0, 0, 0, 2], "semantic": {"name": "post_save_moderation", "arg_names": ["self", "sender", "comment", "request", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def post_save_moderation(self, sender, comment, request, **kwargs):\n \"\"\"\n Apply any necessary post-save moderation steps to new\n comments.\n\n \"\"\"\n model = comment.content_type.model_class()\n if model not in self._registry:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L343_C8", "label": "expression", "type": "expression", "loc": [343, 347], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L342_C4", "vector": [8, 2, 0.9718, 0.0141, 2, 0.38, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Apply any necessary post-save moderation steps to new\n comments.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L348_C8", "label": "model = model_class()", "type": "assigned_variable", "loc": [348, 348], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L342_C4", "vector": [14, 2, 0.9803, 0.0028, 2, 0.38, 0.3333, 722, 3, 0, 0, 0, 826, 10, 1], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "model_class", "annotation": ""}, "snippet": " model = comment.content_type.model_class()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L349_C8", "label": "if", "type": "if", "loc": [349, 350], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L342_C4", "vector": [4, 2, 0.9845, 0.0056, 2, 0.38, 0.6667, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if model not in self._registry:\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L350_C12", "label": "return", "type": "return", "loc": [350, 350], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L349_C8", "vector": [13, 3, 0.9859, 0.0028, 3, 0.45, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L351_C8", "label": "email()", "type": "expression", "loc": [351, 351], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L342_C4", "vector": [8, 2, 0.9887, 0.0028, 2, 0.38, 1.0, 413, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "email", "arg_names": [], "import_names": [], "rhs_call_name": "email", "annotation": ""}, "snippet": " self._registry[model].email(comment, comment.content_object, request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L355_C0", "label": "moderator = Moderator()", "type": "assigned_variable", "loc": [355, 355], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0028, 0, 0.66, 1.0, 98, 3, 0, 0, 0, 691, 10, 1], "semantic": {"name": "moderator", "arg_names": [], "import_names": [], "rhs_call_name": "Moderator", "annotation": ""}, "snippet": "moderator = Moderator()"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L67_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L68_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L75_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L76_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L84_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L166_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L167_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L168_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L169_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L170_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L171_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L173_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L174_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L176_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L176_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L177_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L176_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L189_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L189_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L190_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L189_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L191_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L176_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L192_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L176_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L194_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L196_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L197_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L205_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L205_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L206_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L206_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L207_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L208_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L208_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L209_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L208_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L210_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L210_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L211_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L212_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L214_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L214_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L215_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L214_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L224_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L224_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L225_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L224_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L226_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L226_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L227_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L214_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L228_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L231_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L236_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L236_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L237_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L238_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L239_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L240_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L242_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L244_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L230_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L245_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L248_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L278_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L278_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L279_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L278_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L280_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L282_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L282_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L283_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L282_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L288_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L282_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L289_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L291_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L291_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L292_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L291_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L300_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L300_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L301_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L291_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:For_L302_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:For_L302_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L303_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:For_L302_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L305_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L307_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L307_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L308_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L307_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L316_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L316_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L317_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L307_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:For_L318_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:For_L318_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L319_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L324_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L329_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L330_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L330_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L331_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L332_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L333_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L336_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L336_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L337_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L323_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L339_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L339_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L340_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:ClassDef_L247_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L342_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L342_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L343_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L342_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Assign_L348_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L342_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L349_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:If_L349_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Return_L350_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98589:FunctionDef_L342_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98589:Expr_L351_C8"}] |
"""
Signals relating to comments.
"""
from django.dispatch import Signal
# Sent just before a comment will be posted (after it's been approved and
# moderated; this can be used to modify the comment (in place) with posting
# details or other such actions. If any receiver returns False the comment will be
# discarded and a 403 (not allowed) response. This signal is sent at more or less
# the same time (just before, actually) as the Comment object's pre-save signal,
# except that the HTTP request is sent along with this signal.
comment_will_be_posted = Signal(providing_args=["comment", "request"])
# Sent just after a comment was posted. See above for how this differs
# from the Comment object's post-save signal.
comment_was_posted = Signal(providing_args=["comment", "request"])
# Sent after a comment was "flagged" in some way. Check the flag to see if this
# was a user requesting removal of a comment, a moderator approving/removing a
# comment, or some other custom user flag.
comment_was_flagged = Signal(providing_args=["comment", "flag", "created", "request"])
| ajibawa-2023/Python-Code-Large/train/row_98590 | 5 | 21 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98590:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.0952, 0.1429, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nSignals relating to comments.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98590:ImportFrom_L4_C0", "label": "from django.dispatch import Signal", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.1905, 0.0476, 0, 0.66, 0.25, 548, 0, 1, 0, 0, 548, 0, 0], "semantic": {"name": "django.dispatch", "arg_names": [], "import_names": ["Signal"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.dispatch import Signal"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98590:Assign_L12_C0", "label": "comment_will_be_posted = Signal()", "type": "assigned_variable", "loc": [12, 12], "level": 0, "parent": null, "vector": [14, 0, 0.5714, 0.0476, 0, 0.66, 0.5, 911, 3, 1, 0, 0, 592, 10, 1], "semantic": {"name": "comment_will_be_posted", "arg_names": [], "import_names": [], "rhs_call_name": "Signal", "annotation": ""}, "snippet": "comment_will_be_posted = Signal(providing_args=[\"comment\", \"request\"])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98590:Assign_L16_C0", "label": "comment_was_posted = Signal()", "type": "assigned_variable", "loc": [16, 16], "level": 0, "parent": null, "vector": [14, 0, 0.7619, 0.0476, 0, 0.66, 0.75, 957, 3, 1, 0, 0, 592, 10, 1], "semantic": {"name": "comment_was_posted", "arg_names": [], "import_names": [], "rhs_call_name": "Signal", "annotation": ""}, "snippet": "comment_was_posted = Signal(providing_args=[\"comment\", \"request\"])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98590:Assign_L21_C0", "label": "comment_was_flagged = Signal()", "type": "assigned_variable", "loc": [21, 21], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0476, 0, 0.66, 1.0, 634, 3, 1, 0, 0, 592, 10, 1], "semantic": {"name": "comment_was_flagged", "arg_names": [], "import_names": [], "rhs_call_name": "Signal", "annotation": ""}, "snippet": "comment_was_flagged = Signal(providing_args=[\"comment\", \"flag\", \"created\", \"request\"])"}] | [] |
from django.conf import settings
from django.contrib.syndication.views import Feed
from django.contrib.sites.models import Site
from django.contrib import comments
from django.utils.translation import ugettext as _
class LatestCommentFeed(Feed):
"""Feed of latest comments on the current site."""
def title(self):
if not hasattr(self, '_site'):
self._site = Site.objects.get_current()
return _("%(site_name)s comments") % dict(site_name=self._site.name)
def link(self):
if not hasattr(self, '_site'):
self._site = Site.objects.get_current()
return "http://%s/" % (self._site.domain)
def description(self):
if not hasattr(self, '_site'):
self._site = Site.objects.get_current()
return _("Latest comments on %(site_name)s") % dict(site_name=self._site.name)
def items(self):
qs = comments.get_model().objects.filter(
site__pk = settings.SITE_ID,
is_public = True,
is_removed = False,
)
if getattr(settings, 'COMMENTS_BANNED_USERS_GROUP', None):
where = ['user_id NOT IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)']
params = [settings.COMMENTS_BANNED_USERS_GROUP]
qs = qs.extra(where=where, params=params)
return qs.order_by('-submit_date')[:40]
def item_pubdate(self, item):
return item.submit_date
| ajibawa-2023/Python-Code-Large/train/row_98591 | 28 | 38 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98591:ImportFrom_L1_C0", "label": "from django.conf import settings", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0263, 0.0263, 0, 0.66, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:ImportFrom_L2_C0", "label": "from django.contrib.syndication.views import Feed", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0526, 0.0263, 0, 0.66, 0.2, 264, 0, 1, 0, 0, 264, 0, 0], "semantic": {"name": "django.contrib.syndication.views", "arg_names": [], "import_names": ["Feed"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.syndication.views import Feed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:ImportFrom_L3_C0", "label": "from django.contrib.sites.models import Site", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0789, 0.0263, 0, 0.66, 0.4, 890, 0, 1, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sites.models", "arg_names": [], "import_names": ["Site"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sites.models import Site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:ImportFrom_L4_C0", "label": "from django.contrib import comments", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.1053, 0.0263, 0, 0.66, 0.6, 302, 0, 1, 0, 0, 302, 0, 0], "semantic": {"name": "django.contrib", "arg_names": [], "import_names": ["comments"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib import comments"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:ImportFrom_L5_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.1316, 0.0263, 0, 0.66, 0.8, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "label": "LatestCommentFeed", "type": "class", "loc": [7, 38], "level": 0, "parent": null, "vector": [3, 0, 0.5921, 0.8421, 0, 0.66, 1.0, 152, 0, 5, 0, 0, 571, 0, 15], "semantic": {"name": "LatestCommentFeed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class LatestCommentFeed(Feed):\n \"\"\"Feed of latest comments on the current site.\"\"\"\n\n def title(self):\n if not hasattr(self, '_site'):\n self._site = Site.objects.get_current()\n return _(\"%(site_name)s comments\") % dict(site_name=self._site.name)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Expr_L8_C4", "label": "expression", "type": "expression", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "vector": [8, 1, 0.2105, 0.0263, 1, 0.73, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Feed of latest comments on the current site.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L10_C4", "label": "title", "type": "function", "loc": [10, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "vector": [2, 1, 0.3026, 0.1053, 1, 0.73, 0.2, 48, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "title", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def title(self):\n if not hasattr(self, '_site'):\n self._site = Site.objects.get_current()\n return _(\"%(site_name)s comments\") % dict(site_name=self._site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L11_C8", "label": "if", "type": "if", "loc": [11, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L10_C4", "vector": [4, 2, 0.3026, 0.0526, 2, 0.51, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(self, '_site'):\n self._site = Site.objects.get_current()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L12_C12", "label": "self._site = get_current()", "type": "assigned_variable", "loc": [12, 12], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L11_C8", "vector": [14, 3, 0.3158, 0.0263, 3, 0.24, 0.0, 115, 3, 0, 0, 0, 632, 10, 1], "semantic": {"name": "self._site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current", "annotation": ""}, "snippet": " self._site = Site.objects.get_current()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Return_L13_C8", "label": "return", "type": "return", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L10_C4", "vector": [13, 2, 0.3421, 0.0263, 2, 0.51, 1.0, 0, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _(\"%(site_name)s comments\") % dict(site_name=self._site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L15_C4", "label": "link", "type": "function", "loc": [15, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "vector": [2, 1, 0.4342, 0.1053, 1, 0.73, 0.4, 880, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "link", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def link(self):\n if not hasattr(self, '_site'):\n self._site = Site.objects.get_current()\n return \"http://%s/\" % (self._site.domain)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L16_C8", "label": "if", "type": "if", "loc": [16, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L15_C4", "vector": [4, 2, 0.4342, 0.0526, 2, 0.22, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(self, '_site'):\n self._site = Site.objects.get_current()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L17_C12", "label": "self._site = get_current()", "type": "assigned_variable", "loc": [17, 17], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L16_C8", "vector": [14, 3, 0.4474, 0.0263, 3, 0.93, 0.0, 115, 3, 0, 0, 0, 632, 10, 1], "semantic": {"name": "self._site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current", "annotation": ""}, "snippet": " self._site = Site.objects.get_current()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Return_L18_C8", "label": "return", "type": "return", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L15_C4", "vector": [13, 2, 0.4737, 0.0263, 2, 0.22, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"http://%s/\" % (self._site.domain)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L20_C4", "label": "description", "type": "function", "loc": [20, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "vector": [2, 1, 0.5658, 0.1053, 1, 0.73, 0.6, 306, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "description", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def description(self):\n if not hasattr(self, '_site'):\n self._site = Site.objects.get_current()\n return _(\"Latest comments on %(site_name)s\") % dict(site_name=self._site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L21_C8", "label": "if", "type": "if", "loc": [21, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L20_C4", "vector": [4, 2, 0.5658, 0.0526, 2, 0.15, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(self, '_site'):\n self._site = Site.objects.get_current()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L22_C12", "label": "self._site = get_current()", "type": "assigned_variable", "loc": [22, 22], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L21_C8", "vector": [14, 3, 0.5789, 0.0263, 3, 0.27, 0.0, 115, 3, 0, 0, 0, 632, 10, 1], "semantic": {"name": "self._site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current", "annotation": ""}, "snippet": " self._site = Site.objects.get_current()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Return_L23_C8", "label": "return", "type": "return", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L20_C4", "vector": [13, 2, 0.6053, 0.0263, 2, 0.15, 1.0, 0, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _(\"Latest comments on %(site_name)s\") % dict(site_name=self._site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L25_C4", "label": "items", "type": "function", "loc": [25, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "vector": [2, 1, 0.7895, 0.2895, 1, 0.73, 0.8, 339, 0, 1, 1, 0, 0, 0, 5], "semantic": {"name": "items", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def items(self):\n qs = comments.get_model().objects.filter(\n site__pk = settings.SITE_ID,\n is_public = True,\n is_removed = False,\n )\n if getattr(settings, 'COMMENTS_BANNED_USERS_GROUP', None):\n where = ['user_id NOT IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L26_C8", "label": "qs = filter()", "type": "assigned_variable", "loc": [26, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L25_C4", "vector": [14, 2, 0.7368, 0.1316, 2, 0.96, 0.0, 251, 3, 3, 0, 0, 526, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = comments.get_model().objects.filter(\n site__pk = settings.SITE_ID,\n is_public = True,\n is_removed = False,\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L31_C8", "label": "if", "type": "if", "loc": [31, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L25_C4", "vector": [4, 2, 0.8553, 0.1053, 2, 0.96, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if getattr(settings, 'COMMENTS_BANNED_USERS_GROUP', None):\n where = ['user_id NOT IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)']\n params = [settings.COMMENTS_BANNED_USERS_GROUP]\n qs = qs.extra(where=where, params=params)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L32_C12", "label": "where =", "type": "assigned_variable", "loc": [32, 32], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L31_C8", "vector": [14, 3, 0.8421, 0.0263, 3, 0.95, 0.0, 169, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "where", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " where = ['user_id NOT IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L33_C12", "label": "params =", "type": "assigned_variable", "loc": [33, 33], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L31_C8", "vector": [14, 3, 0.8684, 0.0263, 3, 0.95, 0.5, 206, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "params", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " params = [settings.COMMENTS_BANNED_USERS_GROUP]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L34_C12", "label": "qs = extra()", "type": "assigned_variable", "loc": [34, 34], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L31_C8", "vector": [14, 3, 0.8947, 0.0263, 3, 0.95, 1.0, 251, 3, 2, 0, 0, 980, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "extra", "annotation": ""}, "snippet": " qs = qs.extra(where=where, params=params)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Return_L35_C8", "label": "return", "type": "return", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L25_C4", "vector": [13, 2, 0.9211, 0.0263, 2, 0.96, 1.0, 0, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return qs.order_by('-submit_date')[:40]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L37_C4", "label": "item_pubdate", "type": "function", "loc": [37, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "vector": [2, 1, 0.9868, 0.0526, 1, 0.73, 1.0, 229, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "item_pubdate", "arg_names": ["self", "item"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def item_pubdate(self, item):\n return item.submit_date"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98591:Return_L38_C8", "label": "return", "type": "return", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L37_C4", "vector": [13, 2, 1.0, 0.0263, 2, 0.55, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return item.submit_date"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Expr_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L11_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L12_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Return_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L16_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L17_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Return_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L21_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L22_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Return_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L31_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L32_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L31_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L33_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:If_L31_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Assign_L34_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Return_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98591:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98591:Return_L38_C8"}] |
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.utils.encoding import force_unicode
class CommentManager(models.Manager):
def in_moderation(self):
"""
QuerySet for all comments currently in the moderation queue.
"""
return self.get_query_set().filter(is_public=False, is_removed=False)
def for_model(self, model):
"""
QuerySet for all comments for a particular model (either an instance or
a class).
"""
ct = ContentType.objects.get_for_model(model)
qs = self.get_query_set().filter(content_type=ct)
if isinstance(model, models.Model):
qs = qs.filter(object_pk=force_unicode(model._get_pk_val()))
return qs
| ajibawa-2023/Python-Code-Large/train/row_98592 | 14 | 22 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98592:ImportFrom_L1_C0", "label": "from django.db import models", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0455, 0.0455, 0, 0.66, 0.0, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:ImportFrom_L2_C0", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0909, 0.0455, 0, 0.66, 0.3333, 469, 0, 1, 0, 0, 469, 0, 0], "semantic": {"name": "django.contrib.contenttypes.models", "arg_names": [], "import_names": ["ContentType"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.contenttypes.models import ContentType"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:ImportFrom_L3_C0", "label": "from django.utils.encoding import force_unicode", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.1364, 0.0455, 0, 0.66, 0.6667, 96, 0, 1, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["force_unicode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import force_unicode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:ClassDef_L5_C0", "label": "CommentManager", "type": "class", "loc": [5, 22], "level": 0, "parent": null, "vector": [3, 0, 0.6136, 0.8182, 0, 0.66, 1.0, 523, 0, 2, 0, 0, 948, 0, 9], "semantic": {"name": "CommentManager", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CommentManager(models.Manager):\n\n def in_moderation(self):\n \"\"\"\n QuerySet for all comments currently in the moderation queue.\n \"\"\"\n return self.get_query_set().filter(is_public=False, is_removed=False)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L7_C4", "label": "in_moderation", "type": "function", "loc": [7, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98592:ClassDef_L5_C0", "vector": [2, 1, 0.4091, 0.2273, 1, 0.93, 0.0, 336, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "in_moderation", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def in_moderation(self):\n \"\"\"\n QuerySet for all comments currently in the moderation queue.\n \"\"\"\n return self.get_query_set().filter(is_public=False, is_removed=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:Expr_L8_C8", "label": "expression", "type": "expression", "loc": [8, 10], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L7_C4", "vector": [8, 2, 0.4091, 0.1364, 2, 0.92, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n QuerySet for all comments currently in the moderation queue.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:Return_L11_C8", "label": "return", "type": "return", "loc": [11, 11], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L7_C4", "vector": [13, 2, 0.5, 0.0455, 2, 0.92, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.get_query_set().filter(is_public=False, is_removed=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L13_C4", "label": "for_model", "type": "function", "loc": [13, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98592:ClassDef_L5_C0", "vector": [2, 1, 0.7955, 0.4545, 1, 0.93, 1.0, 495, 0, 2, 1, 0, 0, 0, 7], "semantic": {"name": "for_model", "arg_names": ["self", "model"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def for_model(self, model):\n \"\"\"\n QuerySet for all comments for a particular model (either an instance or\n a class).\n \"\"\"\n ct = ContentType.objects.get_for_model(model)\n qs = self.get_query_set().filter(content_type=ct)\n if isinstance(model, models.Model):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:Expr_L14_C8", "label": "expression", "type": "expression", "loc": [14, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L13_C4", "vector": [8, 2, 0.7045, 0.1818, 2, 0.87, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n QuerySet for all comments for a particular model (either an instance or\n a class).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:Assign_L18_C8", "label": "ct = get_for_model()", "type": "assigned_variable", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L13_C4", "vector": [14, 2, 0.8182, 0.0455, 2, 0.87, 0.25, 147, 3, 1, 0, 0, 752, 10, 1], "semantic": {"name": "ct", "arg_names": [], "import_names": [], "rhs_call_name": "get_for_model", "annotation": ""}, "snippet": " ct = ContentType.objects.get_for_model(model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:Assign_L19_C8", "label": "qs = filter()", "type": "assigned_variable", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L13_C4", "vector": [14, 2, 0.8636, 0.0455, 2, 0.87, 0.5, 251, 3, 1, 0, 0, 526, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = self.get_query_set().filter(content_type=ct)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:If_L20_C8", "label": "if", "type": "if", "loc": [20, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L13_C4", "vector": [4, 2, 0.9318, 0.0909, 2, 0.87, 0.75, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(model, models.Model):\n qs = qs.filter(object_pk=force_unicode(model._get_pk_val()))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:Assign_L21_C12", "label": "qs = filter()", "type": "assigned_variable", "loc": [21, 21], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98592:If_L20_C8", "vector": [14, 3, 0.9545, 0.0455, 3, 0.48, 0.0, 251, 3, 1, 0, 0, 526, 10, 3], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = qs.filter(object_pk=force_unicode(model._get_pk_val()))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98592:Return_L22_C8", "label": "return", "type": "return", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L13_C4", "vector": [13, 2, 1.0, 0.0455, 2, 0.87, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return qs"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98592:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98592:Expr_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98592:Return_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98592:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98592:Expr_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98592:Assign_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98592:Assign_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98592:If_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98592:If_L20_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98592:Assign_L21_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98592:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98592:Return_L22_C8"}] |
from django.conf.urls.defaults import *
urlpatterns = patterns('django.contrib.comments.views',
url(r'^post/$', 'comments.post_comment', name='comments-post-comment'),
url(r'^posted/$', 'comments.comment_done', name='comments-comment-done'),
url(r'^flag/(\d+)/$', 'moderation.flag', name='comments-flag'),
url(r'^flagged/$', 'moderation.flag_done', name='comments-flag-done'),
url(r'^delete/(\d+)/$', 'moderation.delete', name='comments-delete'),
url(r'^deleted/$', 'moderation.delete_done', name='comments-delete-done'),
url(r'^approve/(\d+)/$', 'moderation.approve', name='comments-approve'),
url(r'^approved/$', 'moderation.approve_done', name='comments-approve-done'),
)
urlpatterns += patterns('',
url(r'^cr/(\d+)/(.+)/$', 'django.contrib.contenttypes.views.shortcut', name='comments-url-redirect'),
)
| ajibawa-2023/Python-Code-Large/train/row_98593 | 2 | 16 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98593:ImportFrom_L1_C0", "label": "from django.conf.urls.defaults import *", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0625, 0.0625, 0, 0.66, 0.0, 341, 0, 1, 0, 0, 341, 0, 0], "semantic": {"name": "django.conf.urls.defaults", "arg_names": [], "import_names": ["*"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf.urls.defaults import *"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98593:Assign_L3_C0", "label": "urlpatterns = patterns()", "type": "assigned_variable", "loc": [3, 12], "level": 0, "parent": null, "vector": [14, 0, 0.4688, 0.625, 0, 0.66, 1.0, 990, 3, 9, 0, 0, 75, 10, 9], "semantic": {"name": "urlpatterns", "arg_names": [], "import_names": [], "rhs_call_name": "patterns", "annotation": ""}, "snippet": "urlpatterns = patterns('django.contrib.comments.views',\n url(r'^post/$', 'comments.post_comment', name='comments-post-comment'),\n url(r'^posted/$', 'comments.comment_done', name='comments-comment-done'),\n url(r'^flag/(\\d+)/$', 'moderation.flag', name='comments-flag'),\n url(r'^flagged/$', 'moderation.flag_done', name='comments-flag-done'),\n url(r'^delete/(\\d+)/$', 'moderation.delete', name='comments-delete'),\n url(r'^deleted/$', 'moderation.delete_done', name='comments-delete-done'),\n url(r'^approve/(\\d+)/$', 'moderation.approve', name='comments-approve'),"}] | [] |
from django import template
from django.template.loader import render_to_string
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.contrib import comments
from django.utils.encoding import smart_unicode
register = template.Library()
class BaseCommentNode(template.Node):
"""
Base helper class (abstract) for handling the get_comment_* template tags.
Looks a bit strange, but the subclasses below should make this a bit more
obvious.
"""
#@classmethod
def handle_token(cls, parser, token):
"""Class method to parse get_comment_list/count/form and return a Node."""
tokens = token.contents.split()
if tokens[1] != 'for':
raise template.TemplateSyntaxError("Second argument in %r tag must be 'for'" % tokens[0])
# {% get_whatever for obj as varname %}
if len(tokens) == 5:
if tokens[3] != 'as':
raise template.TemplateSyntaxError("Third argument in %r must be 'as'" % tokens[0])
return cls(
object_expr = parser.compile_filter(tokens[2]),
as_varname = tokens[4],
)
# {% get_whatever for app.model pk as varname %}
elif len(tokens) == 6:
if tokens[4] != 'as':
raise template.TemplateSyntaxError("Fourth argument in %r must be 'as'" % tokens[0])
return cls(
ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
object_pk_expr = parser.compile_filter(tokens[3]),
as_varname = tokens[5]
)
else:
raise template.TemplateSyntaxError("%r tag requires 4 or 5 arguments" % tokens[0])
handle_token = classmethod(handle_token)
#@staticmethod
def lookup_content_type(token, tagname):
try:
app, model = token.split('.')
return ContentType.objects.get(app_label=app, model=model)
except ValueError:
raise template.TemplateSyntaxError("Third argument in %r must be in the format 'app.model'" % tagname)
except ContentType.DoesNotExist:
raise template.TemplateSyntaxError("%r tag has non-existant content-type: '%s.%s'" % (tagname, app, model))
lookup_content_type = staticmethod(lookup_content_type)
def __init__(self, ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, comment=None):
if ctype is None and object_expr is None:
raise template.TemplateSyntaxError("Comment nodes must be given either a literal object or a ctype and object pk.")
self.comment_model = comments.get_model()
self.as_varname = as_varname
self.ctype = ctype
self.object_pk_expr = object_pk_expr
self.object_expr = object_expr
self.comment = comment
def render(self, context):
qs = self.get_query_set(context)
context[self.as_varname] = self.get_context_value_from_queryset(context, qs)
return ''
def get_query_set(self, context):
ctype, object_pk = self.get_target_ctype_pk(context)
if not object_pk:
return self.comment_model.objects.none()
qs = self.comment_model.objects.filter(
content_type = ctype,
object_pk = smart_unicode(object_pk),
site__pk = settings.SITE_ID,
)
# The is_public and is_removed fields are implementation details of the
# built-in comment model's spam filtering system, so they might not
# be present on a custom comment model subclass. If they exist, we
# should filter on them.
field_names = [f.name for f in self.comment_model._meta.fields]
if 'is_public' in field_names:
qs = qs.filter(is_public=True)
if getattr(settings, 'COMMENTS_HIDE_REMOVED', True) and 'is_removed' in field_names:
qs = qs.filter(is_removed=False)
return qs
def get_target_ctype_pk(self, context):
if self.object_expr:
try:
obj = self.object_expr.resolve(context)
except template.VariableDoesNotExist:
return None, None
return ContentType.objects.get_for_model(obj), obj.pk
else:
return self.ctype, self.object_pk_expr.resolve(context, ignore_failures=True)
def get_context_value_from_queryset(self, context, qs):
"""Subclasses should override this."""
raise NotImplementedError
class CommentListNode(BaseCommentNode):
"""Insert a list of comments into the context."""
def get_context_value_from_queryset(self, context, qs):
return list(qs)
class CommentCountNode(BaseCommentNode):
"""Insert a count of comments into the context."""
def get_context_value_from_queryset(self, context, qs):
return qs.count()
class CommentFormNode(BaseCommentNode):
"""Insert a form for the comment model into the context."""
def get_form(self, context):
ctype, object_pk = self.get_target_ctype_pk(context)
if object_pk:
return comments.get_form()(ctype.get_object_for_this_type(pk=object_pk))
else:
return None
def render(self, context):
context[self.as_varname] = self.get_form(context)
return ''
class RenderCommentFormNode(CommentFormNode):
"""Render the comment form directly"""
#@classmethod
def handle_token(cls, parser, token):
"""Class method to parse render_comment_form and return a Node."""
tokens = token.contents.split()
if tokens[1] != 'for':
raise template.TemplateSyntaxError("Second argument in %r tag must be 'for'" % tokens[0])
# {% render_comment_form for obj %}
if len(tokens) == 3:
return cls(object_expr=parser.compile_filter(tokens[2]))
# {% render_comment_form for app.models pk %}
elif len(tokens) == 4:
return cls(
ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
object_pk_expr = parser.compile_filter(tokens[3])
)
handle_token = classmethod(handle_token)
def render(self, context):
ctype, object_pk = self.get_target_ctype_pk(context)
if object_pk:
template_search_list = [
"comments/%s/%s/form.html" % (ctype.app_label, ctype.model),
"comments/%s/form.html" % ctype.app_label,
"comments/form.html"
]
context.push()
formstr = render_to_string(template_search_list, {"form" : self.get_form(context)}, context)
context.pop()
return formstr
else:
return ''
class RenderCommentListNode(CommentListNode):
"""Render the comment list directly"""
#@classmethod
def handle_token(cls, parser, token):
"""Class method to parse render_comment_list and return a Node."""
tokens = token.contents.split()
if tokens[1] != 'for':
raise template.TemplateSyntaxError("Second argument in %r tag must be 'for'" % tokens[0])
# {% render_comment_list for obj %}
if len(tokens) == 3:
return cls(object_expr=parser.compile_filter(tokens[2]))
# {% render_comment_list for app.models pk %}
elif len(tokens) == 4:
return cls(
ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
object_pk_expr = parser.compile_filter(tokens[3])
)
handle_token = classmethod(handle_token)
def render(self, context):
ctype, object_pk = self.get_target_ctype_pk(context)
if object_pk:
template_search_list = [
"comments/%s/%s/list.html" % (ctype.app_label, ctype.model),
"comments/%s/list.html" % ctype.app_label,
"comments/list.html"
]
qs = self.get_query_set(context)
context.push()
liststr = render_to_string(template_search_list, {
"comment_list" : self.get_context_value_from_queryset(context, qs)
}, context)
context.pop()
return liststr
else:
return ''
# We could just register each classmethod directly, but then we'd lose out on
# the automagic docstrings-into-admin-docs tricks. So each node gets a cute
# wrapper function that just exists to hold the docstring.
#@register.tag
def get_comment_count(parser, token):
"""
Gets the comment count for the given params and populates the template
context with a variable containing that value, whose name is defined by the
'as' clause.
Syntax::
{% get_comment_count for [object] as [varname] %}
{% get_comment_count for [app].[model] [object_id] as [varname] %}
Example usage::
{% get_comment_count for event as comment_count %}
{% get_comment_count for calendar.event event.id as comment_count %}
{% get_comment_count for calendar.event 17 as comment_count %}
"""
return CommentCountNode.handle_token(parser, token)
#@register.tag
def get_comment_list(parser, token):
"""
Gets the list of comments for the given params and populates the template
context with a variable containing that value, whose name is defined by the
'as' clause.
Syntax::
{% get_comment_list for [object] as [varname] %}
{% get_comment_list for [app].[model] [object_id] as [varname] %}
Example usage::
{% get_comment_list for event as comment_list %}
{% for comment in comment_list %}
...
{% endfor %}
"""
return CommentListNode.handle_token(parser, token)
#@register.tag
def render_comment_list(parser, token):
"""
Render the comment list (as returned by ``{% get_comment_list %}``)
through the ``comments/list.html`` template
Syntax::
{% render_comment_list for [object] %}
{% render_comment_list for [app].[model] [object_id] %}
Example usage::
{% render_comment_list for event %}
"""
return RenderCommentListNode.handle_token(parser, token)
#@register.tag
def get_comment_form(parser, token):
"""
Get a (new) form object to post a new comment.
Syntax::
{% get_comment_form for [object] as [varname] %}
{% get_comment_form for [app].[model] [object_id] as [varname] %}
"""
return CommentFormNode.handle_token(parser, token)
#@register.tag
def render_comment_form(parser, token):
"""
Render the comment form (as returned by ``{% render_comment_form %}``) through
the ``comments/form.html`` template.
Syntax::
{% render_comment_form for [object] %}
{% render_comment_form for [app].[model] [object_id] %}
"""
return RenderCommentFormNode.handle_token(parser, token)
#@register.simple_tag
def comment_form_target():
"""
Get the target URL for the comment form.
Example::
<form action="{% comment_form_target %}" method="post">
"""
return comments.get_form_target()
#@register.simple_tag
def get_comment_permalink(comment, anchor_pattern=None):
"""
Get the permalink for a comment, optionally specifying the format of the
named anchor to be appended to the end of the URL.
Example::
{{ get_comment_permalink comment "#c%(id)s-by-%(user_name)s" }}
"""
if anchor_pattern:
return comment.get_absolute_url(anchor_pattern)
return comment.get_absolute_url()
register.tag(get_comment_count)
register.tag(get_comment_list)
register.tag(get_comment_form)
register.tag(render_comment_form)
register.simple_tag(comment_form_target)
register.simple_tag(get_comment_permalink)
register.tag(render_comment_list)
| ajibawa-2023/Python-Code-Large/train/row_98594 | 146 | 333 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98594:ImportFrom_L1_C0", "label": "from django import template", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.003, 0.003, 0, 0.66, 0.0, 294, 0, 1, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["template"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django import template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:ImportFrom_L2_C0", "label": "from django.template.loader import render_to_string", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.006, 0.003, 0, 0.66, 0.0385, 970, 0, 1, 0, 0, 970, 0, 0], "semantic": {"name": "django.template.loader", "arg_names": [], "import_names": ["render_to_string"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template.loader import render_to_string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:ImportFrom_L3_C0", "label": "from django.conf import settings", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.009, 0.003, 0, 0.66, 0.0769, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:ImportFrom_L4_C0", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.012, 0.003, 0, 0.66, 0.1154, 469, 0, 1, 0, 0, 469, 0, 0], "semantic": {"name": "django.contrib.contenttypes.models", "arg_names": [], "import_names": ["ContentType"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.contenttypes.models import ContentType"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:ImportFrom_L5_C0", "label": "from django.contrib import comments", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.015, 0.003, 0, 0.66, 0.1538, 302, 0, 1, 0, 0, 302, 0, 0], "semantic": {"name": "django.contrib", "arg_names": [], "import_names": ["comments"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib import comments"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:ImportFrom_L6_C0", "label": "from django.utils.encoding import smart_unicode", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.018, 0.003, 0, 0.66, 0.1923, 96, 0, 1, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_unicode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_unicode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L8_C0", "label": "register = Library()", "type": "assigned_variable", "loc": [8, 8], "level": 0, "parent": null, "vector": [14, 0, 0.024, 0.003, 0, 0.66, 0.2308, 276, 3, 0, 0, 0, 77, 10, 1], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "Library", "annotation": ""}, "snippet": "register = template.Library()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "label": "BaseCommentNode", "type": "class", "loc": [10, 109], "level": 0, "parent": null, "vector": [3, 0, 0.1787, 0.3003, 0, 0.66, 0.2692, 159, 0, 7, 0, 0, 586, 0, 32], "semantic": {"name": "BaseCommentNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class BaseCommentNode(template.Node):\n \"\"\"\n Base helper class (abstract) for handling the get_comment_* template tags.\n Looks a bit strange, but the subclasses below should make this a bit more\n obvious.\n \"\"\"\n\n #@classmethod"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L11_C4", "label": "expression", "type": "expression", "loc": [11, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "vector": [8, 1, 0.039, 0.015, 1, 0.28, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Base helper class (abstract) for handling the get_comment_* template tags.\n Looks a bit strange, but the subclasses below should make this a bit more\n obvious.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L18_C4", "label": "handle_token", "type": "function", "loc": [18, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "vector": [2, 1, 0.0931, 0.0811, 1, 0.28, 0.1111, 279, 0, 3, 1, 0, 0, 0, 12], "semantic": {"name": "handle_token", "arg_names": ["cls", "parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_token(cls, parser, token):\n \"\"\"Class method to parse get_comment_list/count/form and return a Node.\"\"\"\n tokens = token.contents.split()\n if tokens[1] != 'for':\n raise template.TemplateSyntaxError(\"Second argument in %r tag must be 'for'\" % tokens[0])\n\n # {% get_whatever for obj as varname %}\n if len(tokens) == 5:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L19_C8", "label": "expression", "type": "expression", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L18_C4", "vector": [8, 2, 0.0571, 0.003, 2, 0.28, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Class method to parse get_comment_list/count/form and return a Node.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L20_C8", "label": "tokens = split()", "type": "assigned_variable", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L18_C4", "vector": [14, 2, 0.0601, 0.003, 2, 0.28, 0.3333, 700, 3, 0, 0, 0, 908, 10, 1], "semantic": {"name": "tokens", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " tokens = token.contents.split()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L21_C8", "label": "if", "type": "if", "loc": [21, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L18_C4", "vector": [4, 2, 0.0646, 0.006, 2, 0.28, 0.6667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if tokens[1] != 'for':\n raise template.TemplateSyntaxError(\"Second argument in %r tag must be 'for'\" % tokens[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L25_C8", "label": "if", "type": "if", "loc": [25, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L18_C4", "vector": [4, 2, 0.1036, 0.0601, 2, 0.28, 1.0, 0, 0, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(tokens) == 5:\n if tokens[3] != 'as':\n raise template.TemplateSyntaxError(\"Third argument in %r must be 'as'\" % tokens[0])\n return cls(\n object_expr = parser.compile_filter(tokens[2]),\n as_varname = tokens[4],\n )\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L26_C12", "label": "if", "type": "if", "loc": [26, 27], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L25_C8", "vector": [4, 3, 0.0796, 0.006, 3, 0.8, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if tokens[3] != 'as':\n raise template.TemplateSyntaxError(\"Third argument in %r must be 'as'\" % tokens[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L28_C12", "label": "return", "type": "return", "loc": [28, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L25_C8", "vector": [13, 3, 0.0886, 0.012, 3, 0.8, 0.5, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return cls(\n object_expr = parser.compile_filter(tokens[2]),\n as_varname = tokens[4],\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L34_C8", "label": "if", "type": "if", "loc": [34, 44], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L25_C8", "vector": [4, 3, 0.1171, 0.033, 3, 0.8, 1.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif len(tokens) == 6:\n if tokens[4] != 'as':\n raise template.TemplateSyntaxError(\"Fourth argument in %r must be 'as'\" % tokens[0])\n return cls(\n ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),\n object_pk_expr = parser.compile_filter(tokens[3]),\n as_varname = tokens[5]\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L35_C12", "label": "if", "type": "if", "loc": [35, 36], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L34_C8", "vector": [4, 4, 0.1066, 0.006, 4, 0.26, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if tokens[4] != 'as':\n raise template.TemplateSyntaxError(\"Fourth argument in %r must be 'as'\" % tokens[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L37_C12", "label": "return", "type": "return", "loc": [37, 41], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L34_C8", "vector": [13, 4, 0.1171, 0.015, 4, 0.26, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return cls(\n ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),\n object_pk_expr = parser.compile_filter(tokens[3]),\n as_varname = tokens[5]\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L46_C4", "label": "handle_token = classmethod()", "type": "assigned_variable", "loc": [46, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "vector": [14, 1, 0.1381, 0.003, 1, 0.28, 0.2222, 279, 3, 1, 0, 0, 76, 10, 1], "semantic": {"name": "handle_token", "arg_names": [], "import_names": [], "rhs_call_name": "classmethod", "annotation": ""}, "snippet": " handle_token = classmethod(handle_token)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L49_C4", "label": "lookup_content_type", "type": "function", "loc": [49, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "vector": [2, 1, 0.1577, 0.024, 1, 0.28, 0.3333, 8, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "lookup_content_type", "arg_names": ["token", "tagname"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def lookup_content_type(token, tagname):\n try:\n app, model = token.split('.')\n return ContentType.objects.get(app_label=app, model=model)\n except ValueError:\n raise template.TemplateSyntaxError(\"Third argument in %r must be in the format 'app.model'\" % tagname)\n except ContentType.DoesNotExist:\n raise template.TemplateSyntaxError(\"%r tag has non-existant content-type: '%s.%s'\" % (tagname, app, model))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Try_L50_C8", "label": "try", "type": "try", "loc": [50, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L49_C4", "vector": [7, 2, 0.1592, 0.021, 2, 0.2, 0.0, 0, 0, 2, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n app, model = token.split('.')\n return ContentType.objects.get(app_label=app, model=model)\n except ValueError:\n raise template.TemplateSyntaxError(\"Third argument in %r must be in the format 'app.model'\" % tagname)\n except ContentType.DoesNotExist:\n raise template.TemplateSyntaxError(\"%r tag has non-existant content-type: '%s.%s'\" % (tagname, app, model))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L51_C12", "label": "app, model = split()", "type": "assigned_variable", "loc": [51, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:Try_L50_C8", "vector": [14, 3, 0.1532, 0.003, 3, 0.68, 0.0, 352, 3, 1, 0, 0, 908, 10, 1], "semantic": {"name": "app, model", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " app, model = token.split('.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L52_C12", "label": "return", "type": "return", "loc": [52, 52], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:Try_L50_C8", "vector": [13, 3, 0.1562, 0.003, 3, 0.68, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ContentType.objects.get(app_label=app, model=model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L57_C4", "label": "lookup_content_type = staticmethod()", "type": "assigned_variable", "loc": [57, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "vector": [14, 1, 0.1712, 0.003, 1, 0.28, 0.4444, 8, 3, 1, 0, 0, 884, 10, 1], "semantic": {"name": "lookup_content_type", "arg_names": [], "import_names": [], "rhs_call_name": "staticmethod", "annotation": ""}, "snippet": " lookup_content_type = staticmethod(lookup_content_type)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "label": "__init__", "type": "function", "loc": [59, 67], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "vector": [2, 1, 0.1892, 0.027, 1, 0.28, 0.5556, 555, 0, 6, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "ctype", "object_pk_expr", "object_expr", "as_varname", "comment"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, comment=None):\n if ctype is None and object_expr is None:\n raise template.TemplateSyntaxError(\"Comment nodes must be given either a literal object or a ctype and object pk.\")\n self.comment_model = comments.get_model()\n self.as_varname = as_varname\n self.ctype = ctype\n self.object_pk_expr = object_pk_expr\n self.object_expr = object_expr"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L60_C8", "label": "if", "type": "if", "loc": [60, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "vector": [4, 2, 0.1817, 0.006, 2, 0.9, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ctype is None and object_expr is None:\n raise template.TemplateSyntaxError(\"Comment nodes must be given either a literal object or a ctype and object pk.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L62_C8", "label": "self.comment_model = get_model()", "type": "assigned_variable", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "vector": [14, 2, 0.1862, 0.003, 2, 0.9, 0.1667, 98, 3, 0, 0, 0, 115, 10, 1], "semantic": {"name": "self.comment_model", "arg_names": [], "import_names": [], "rhs_call_name": "get_model", "annotation": ""}, "snippet": " self.comment_model = comments.get_model()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L63_C8", "label": "self.as_varname =", "type": "assigned_variable", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "vector": [14, 2, 0.1892, 0.003, 2, 0.9, 0.3333, 792, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.as_varname", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.as_varname = as_varname"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L64_C8", "label": "self.ctype =", "type": "assigned_variable", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "vector": [14, 2, 0.1922, 0.003, 2, 0.9, 0.5, 766, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.ctype", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.ctype = ctype"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L65_C8", "label": "self.object_pk_expr =", "type": "assigned_variable", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "vector": [14, 2, 0.1952, 0.003, 2, 0.9, 0.6667, 82, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.object_pk_expr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.object_pk_expr = object_pk_expr"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L66_C8", "label": "self.object_expr =", "type": "assigned_variable", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "vector": [14, 2, 0.1982, 0.003, 2, 0.9, 0.8333, 719, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.object_expr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.object_expr = object_expr"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L67_C8", "label": "self.comment =", "type": "assigned_variable", "loc": [67, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "vector": [14, 2, 0.2012, 0.003, 2, 0.9, 1.0, 450, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.comment", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.comment = comment"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L69_C4", "label": "render", "type": "function", "loc": [69, 72], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "vector": [2, 1, 0.2117, 0.012, 1, 0.28, 0.6667, 24, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "render", "arg_names": ["self", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self, context):\n qs = self.get_query_set(context)\n context[self.as_varname] = self.get_context_value_from_queryset(context, qs)\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L70_C8", "label": "qs = get_query_set()", "type": "assigned_variable", "loc": [70, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L69_C4", "vector": [14, 2, 0.2102, 0.003, 2, 0.88, 0.0, 251, 3, 1, 0, 0, 696, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "get_query_set", "annotation": ""}, "snippet": " qs = self.get_query_set(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L71_C8", "label": " = get_context_value_from_queryset()", "type": "assigned_variable", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L69_C4", "vector": [14, 2, 0.2132, 0.003, 2, 0.88, 0.5, 0, 3, 2, 0, 0, 812, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get_context_value_from_queryset", "annotation": ""}, "snippet": " context[self.as_varname] = self.get_context_value_from_queryset(context, qs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L72_C8", "label": "return", "type": "return", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L69_C4", "vector": [13, 2, 0.2162, 0.003, 2, 0.88, 1.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "label": "get_query_set", "type": "function", "loc": [74, 95], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "vector": [2, 1, 0.2538, 0.0661, 1, 0.28, 0.7778, 696, 0, 2, 1, 0, 0, 0, 7], "semantic": {"name": "get_query_set", "arg_names": ["self", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_query_set(self, context):\n ctype, object_pk = self.get_target_ctype_pk(context)\n if not object_pk:\n return self.comment_model.objects.none()\n\n qs = self.comment_model.objects.filter(\n content_type = ctype,\n object_pk = smart_unicode(object_pk),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L75_C8", "label": "ctype, object_pk = get_target_ctype_pk()", "type": "assigned_variable", "loc": [75, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "vector": [14, 2, 0.2252, 0.003, 2, 0.99, 0.0, 403, 3, 1, 0, 0, 890, 10, 1], "semantic": {"name": "ctype, object_pk", "arg_names": [], "import_names": [], "rhs_call_name": "get_target_ctype_pk", "annotation": ""}, "snippet": " ctype, object_pk = self.get_target_ctype_pk(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L76_C8", "label": "if", "type": "if", "loc": [76, 77], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "vector": [4, 2, 0.2297, 0.006, 2, 0.99, 0.1667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not object_pk:\n return self.comment_model.objects.none()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L77_C12", "label": "return", "type": "return", "loc": [77, 77], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L76_C8", "vector": [13, 3, 0.2312, 0.003, 3, 0.62, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.comment_model.objects.none()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L79_C8", "label": "qs = filter()", "type": "assigned_variable", "loc": [79, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "vector": [14, 2, 0.2432, 0.015, 2, 0.99, 0.3333, 251, 3, 3, 0, 0, 526, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = self.comment_model.objects.filter(\n content_type = ctype,\n object_pk = smart_unicode(object_pk),\n site__pk = settings.SITE_ID,\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L89_C8", "label": "field_names =", "type": "assigned_variable", "loc": [89, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "vector": [14, 2, 0.2673, 0.003, 2, 0.99, 0.5, 723, 5, 0, 0, 0, 0, 0, 0], "semantic": {"name": "field_names", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_names = [f.name for f in self.comment_model._meta.fields]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L90_C8", "label": "if", "type": "if", "loc": [90, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "vector": [4, 2, 0.2718, 0.006, 2, 0.99, 0.6667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'is_public' in field_names:\n qs = qs.filter(is_public=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L91_C12", "label": "qs = filter()", "type": "assigned_variable", "loc": [91, 91], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L90_C8", "vector": [14, 3, 0.2733, 0.003, 3, 0.01, 0.0, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = qs.filter(is_public=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L92_C8", "label": "if", "type": "if", "loc": [92, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "vector": [4, 2, 0.2778, 0.006, 2, 0.99, 0.8333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if getattr(settings, 'COMMENTS_HIDE_REMOVED', True) and 'is_removed' in field_names:\n qs = qs.filter(is_removed=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L93_C12", "label": "qs = filter()", "type": "assigned_variable", "loc": [93, 93], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L92_C8", "vector": [14, 3, 0.2793, 0.003, 3, 0.92, 0.0, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = qs.filter(is_removed=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L95_C8", "label": "return", "type": "return", "loc": [95, 95], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "vector": [13, 2, 0.2853, 0.003, 2, 0.99, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return qs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L97_C4", "label": "get_target_ctype_pk", "type": "function", "loc": [97, 105], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "vector": [2, 1, 0.3033, 0.027, 1, 0.28, 0.8889, 890, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "get_target_ctype_pk", "arg_names": ["self", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_target_ctype_pk(self, context):\n if self.object_expr:\n try:\n obj = self.object_expr.resolve(context)\n except template.VariableDoesNotExist:\n return None, None\n return ContentType.objects.get_for_model(obj), obj.pk\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L98_C8", "label": "if", "type": "if", "loc": [98, 105], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L97_C4", "vector": [4, 2, 0.3048, 0.024, 2, 0.5, 0.0, 0, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.object_expr:\n try:\n obj = self.object_expr.resolve(context)\n except template.VariableDoesNotExist:\n return None, None\n return ContentType.objects.get_for_model(obj), obj.pk\n else:\n return self.ctype, self.object_pk_expr.resolve(context, ignore_failures=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Try_L99_C12", "label": "try", "type": "try", "loc": [99, 102], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L98_C8", "vector": [7, 3, 0.3018, 0.012, 3, 0.67, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n obj = self.object_expr.resolve(context)\n except template.VariableDoesNotExist:\n return None, None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L100_C16", "label": "obj = resolve()", "type": "assigned_variable", "loc": [100, 100], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:Try_L99_C12", "vector": [14, 4, 0.3003, 0.003, 4, 0.67, 0.0, 505, 3, 1, 0, 0, 675, 10, 1], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "resolve", "annotation": ""}, "snippet": " obj = self.object_expr.resolve(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L102_C16", "label": "return", "type": "return", "loc": [102, 102], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:Try_L99_C12", "vector": [13, 4, 0.3063, 0.003, 4, 0.67, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None, None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L103_C12", "label": "return", "type": "return", "loc": [103, 103], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L98_C8", "vector": [13, 3, 0.3093, 0.003, 3, 0.67, 0.5, 0, 0, 0, 0, 0, 0, 8, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ContentType.objects.get_for_model(obj), obj.pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L105_C12", "label": "return", "type": "return", "loc": [105, 105], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L98_C8", "vector": [13, 3, 0.3153, 0.003, 3, 0.67, 1.0, 0, 0, 0, 0, 0, 0, 8, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.ctype, self.object_pk_expr.resolve(context, ignore_failures=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L107_C4", "label": "get_context_value_from_queryset", "type": "function", "loc": [107, 109], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "vector": [2, 1, 0.3243, 0.009, 1, 0.28, 1.0, 812, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "get_context_value_from_queryset", "arg_names": ["self", "context", "qs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_context_value_from_queryset(self, context, qs):\n \"\"\"Subclasses should override this.\"\"\"\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L108_C8", "label": "expression", "type": "expression", "loc": [108, 108], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L107_C4", "vector": [8, 2, 0.3243, 0.003, 2, 0.26, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Subclasses should override this.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L111_C0", "label": "CommentListNode", "type": "class", "loc": [111, 114], "level": 0, "parent": null, "vector": [3, 0, 0.3378, 0.012, 0, 0.66, 0.3077, 448, 0, 1, 0, 0, 159, 0, 1], "semantic": {"name": "CommentListNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CommentListNode(BaseCommentNode):\n \"\"\"Insert a list of comments into the context.\"\"\"\n def get_context_value_from_queryset(self, context, qs):\n return list(qs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L112_C4", "label": "expression", "type": "expression", "loc": [112, 112], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L111_C0", "vector": [8, 1, 0.3363, 0.003, 1, 0.69, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Insert a list of comments into the context.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L113_C4", "label": "get_context_value_from_queryset", "type": "function", "loc": [113, 114], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L111_C0", "vector": [2, 1, 0.3408, 0.006, 1, 0.69, 1.0, 812, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "get_context_value_from_queryset", "arg_names": ["self", "context", "qs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_context_value_from_queryset(self, context, qs):\n return list(qs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L114_C8", "label": "return", "type": "return", "loc": [114, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L113_C4", "vector": [13, 2, 0.3423, 0.003, 2, 0.04, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return list(qs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L116_C0", "label": "CommentCountNode", "type": "class", "loc": [116, 119], "level": 0, "parent": null, "vector": [3, 0, 0.3529, 0.012, 0, 0.66, 0.3462, 223, 0, 1, 0, 0, 159, 0, 1], "semantic": {"name": "CommentCountNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CommentCountNode(BaseCommentNode):\n \"\"\"Insert a count of comments into the context.\"\"\"\n def get_context_value_from_queryset(self, context, qs):\n return qs.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L117_C4", "label": "expression", "type": "expression", "loc": [117, 117], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L116_C0", "vector": [8, 1, 0.3514, 0.003, 1, 0.19, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Insert a count of comments into the context.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L118_C4", "label": "get_context_value_from_queryset", "type": "function", "loc": [118, 119], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L116_C0", "vector": [2, 1, 0.3559, 0.006, 1, 0.19, 1.0, 812, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "get_context_value_from_queryset", "arg_names": ["self", "context", "qs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_context_value_from_queryset(self, context, qs):\n return qs.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L119_C8", "label": "return", "type": "return", "loc": [119, 119], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L118_C4", "vector": [13, 2, 0.3574, 0.003, 2, 0.53, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return qs.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L121_C0", "label": "CommentFormNode", "type": "class", "loc": [121, 133], "level": 0, "parent": null, "vector": [3, 0, 0.3814, 0.039, 0, 0.66, 0.3846, 463, 0, 2, 0, 0, 159, 0, 5], "semantic": {"name": "CommentFormNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CommentFormNode(BaseCommentNode):\n \"\"\"Insert a form for the comment model into the context.\"\"\"\n\n def get_form(self, context):\n ctype, object_pk = self.get_target_ctype_pk(context)\n if object_pk:\n return comments.get_form()(ctype.get_object_for_this_type(pk=object_pk))\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L122_C4", "label": "expression", "type": "expression", "loc": [122, 122], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L121_C0", "vector": [8, 1, 0.3664, 0.003, 1, 0.17, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Insert a form for the comment model into the context.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L124_C4", "label": "get_form", "type": "function", "loc": [124, 129], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L121_C0", "vector": [2, 1, 0.3799, 0.018, 1, 0.17, 0.5, 265, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "get_form", "arg_names": ["self", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_form(self, context):\n ctype, object_pk = self.get_target_ctype_pk(context)\n if object_pk:\n return comments.get_form()(ctype.get_object_for_this_type(pk=object_pk))\n else:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L125_C8", "label": "ctype, object_pk = get_target_ctype_pk()", "type": "assigned_variable", "loc": [125, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L124_C4", "vector": [14, 2, 0.3754, 0.003, 2, 0.2, 0.0, 403, 3, 1, 0, 0, 890, 10, 1], "semantic": {"name": "ctype, object_pk", "arg_names": [], "import_names": [], "rhs_call_name": "get_target_ctype_pk", "annotation": ""}, "snippet": " ctype, object_pk = self.get_target_ctype_pk(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L126_C8", "label": "if", "type": "if", "loc": [126, 129], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L124_C4", "vector": [4, 2, 0.3829, 0.012, 2, 0.2, 1.0, 0, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if object_pk:\n return comments.get_form()(ctype.get_object_for_this_type(pk=object_pk))\n else:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L127_C12", "label": "return", "type": "return", "loc": [127, 127], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L126_C8", "vector": [13, 3, 0.3814, 0.003, 3, 0.31, 0.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return comments.get_form()(ctype.get_object_for_this_type(pk=object_pk))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L129_C12", "label": "return", "type": "return", "loc": [129, 129], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L126_C8", "vector": [13, 3, 0.3874, 0.003, 3, 0.31, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L131_C4", "label": "render", "type": "function", "loc": [131, 133], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L121_C0", "vector": [2, 1, 0.3964, 0.009, 1, 0.17, 1.0, 24, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "render", "arg_names": ["self", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self, context):\n context[self.as_varname] = self.get_form(context)\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L132_C8", "label": " = get_form()", "type": "assigned_variable", "loc": [132, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L131_C4", "vector": [14, 2, 0.3964, 0.003, 2, 0.34, 0.0, 0, 3, 1, 0, 0, 265, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get_form", "annotation": ""}, "snippet": " context[self.as_varname] = self.get_form(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L133_C8", "label": "return", "type": "return", "loc": [133, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L131_C4", "vector": [13, 2, 0.3994, 0.003, 2, 0.34, 1.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L135_C0", "label": "RenderCommentFormNode", "type": "class", "loc": [135, 170], "level": 0, "parent": null, "vector": [3, 0, 0.458, 0.1081, 0, 0.66, 0.4231, 259, 0, 2, 0, 0, 463, 0, 15], "semantic": {"name": "RenderCommentFormNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RenderCommentFormNode(CommentFormNode):\n \"\"\"Render the comment form directly\"\"\"\n\n #@classmethod\n def handle_token(cls, parser, token):\n \"\"\"Class method to parse render_comment_form and return a Node.\"\"\"\n tokens = token.contents.split()\n if tokens[1] != 'for':"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L136_C4", "label": "expression", "type": "expression", "loc": [136, 136], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L135_C0", "vector": [8, 1, 0.4084, 0.003, 1, 0.74, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Render the comment form directly\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L139_C4", "label": "handle_token", "type": "function", "loc": [139, 154], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L135_C0", "vector": [2, 1, 0.4399, 0.048, 1, 0.74, 0.3333, 279, 0, 3, 1, 0, 0, 0, 9], "semantic": {"name": "handle_token", "arg_names": ["cls", "parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_token(cls, parser, token):\n \"\"\"Class method to parse render_comment_form and return a Node.\"\"\"\n tokens = token.contents.split()\n if tokens[1] != 'for':\n raise template.TemplateSyntaxError(\"Second argument in %r tag must be 'for'\" % tokens[0])\n\n # {% render_comment_form for obj %}\n if len(tokens) == 3:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L140_C8", "label": "expression", "type": "expression", "loc": [140, 140], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L139_C4", "vector": [8, 2, 0.4204, 0.003, 2, 0.2, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Class method to parse render_comment_form and return a Node.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L141_C8", "label": "tokens = split()", "type": "assigned_variable", "loc": [141, 141], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L139_C4", "vector": [14, 2, 0.4234, 0.003, 2, 0.2, 0.3333, 700, 3, 0, 0, 0, 908, 10, 1], "semantic": {"name": "tokens", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " tokens = token.contents.split()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L142_C8", "label": "if", "type": "if", "loc": [142, 143], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L139_C4", "vector": [4, 2, 0.4279, 0.006, 2, 0.2, 0.6667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if tokens[1] != 'for':\n raise template.TemplateSyntaxError(\"Second argument in %r tag must be 'for'\" % tokens[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L146_C8", "label": "if", "type": "if", "loc": [146, 154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L139_C4", "vector": [4, 2, 0.4505, 0.027, 2, 0.2, 1.0, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(tokens) == 3:\n return cls(object_expr=parser.compile_filter(tokens[2]))\n\n # {% render_comment_form for app.models pk %}\n elif len(tokens) == 4:\n return cls(\n ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),\n object_pk_expr = parser.compile_filter(tokens[3])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L147_C12", "label": "return", "type": "return", "loc": [147, 147], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L146_C8", "vector": [13, 3, 0.4414, 0.003, 3, 0.23, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return cls(object_expr=parser.compile_filter(tokens[2]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L150_C8", "label": "if", "type": "if", "loc": [150, 154], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L146_C8", "vector": [4, 3, 0.4565, 0.015, 3, 0.23, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif len(tokens) == 4:\n return cls(\n ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),\n object_pk_expr = parser.compile_filter(tokens[3])\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L151_C12", "label": "return", "type": "return", "loc": [151, 154], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L150_C8", "vector": [13, 4, 0.458, 0.012, 4, 0.86, 0.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return cls(\n ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),\n object_pk_expr = parser.compile_filter(tokens[3])\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L155_C4", "label": "handle_token = classmethod()", "type": "assigned_variable", "loc": [155, 155], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L135_C0", "vector": [14, 1, 0.4655, 0.003, 1, 0.74, 0.6667, 279, 3, 1, 0, 0, 76, 10, 1], "semantic": {"name": "handle_token", "arg_names": [], "import_names": [], "rhs_call_name": "classmethod", "annotation": ""}, "snippet": " handle_token = classmethod(handle_token)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L157_C4", "label": "render", "type": "function", "loc": [157, 170], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L135_C0", "vector": [2, 1, 0.491, 0.042, 1, 0.74, 1.0, 24, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "render", "arg_names": ["self", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self, context):\n ctype, object_pk = self.get_target_ctype_pk(context)\n if object_pk:\n template_search_list = [\n \"comments/%s/%s/form.html\" % (ctype.app_label, ctype.model),\n \"comments/%s/form.html\" % ctype.app_label,\n \"comments/form.html\"\n ]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L158_C8", "label": "ctype, object_pk = get_target_ctype_pk()", "type": "assigned_variable", "loc": [158, 158], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L157_C4", "vector": [14, 2, 0.4745, 0.003, 2, 0.37, 0.0, 403, 3, 1, 0, 0, 890, 10, 1], "semantic": {"name": "ctype, object_pk", "arg_names": [], "import_names": [], "rhs_call_name": "get_target_ctype_pk", "annotation": ""}, "snippet": " ctype, object_pk = self.get_target_ctype_pk(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "label": "if", "type": "if", "loc": [159, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L157_C4", "vector": [4, 2, 0.494, 0.036, 2, 0.37, 1.0, 0, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if object_pk:\n template_search_list = [\n \"comments/%s/%s/form.html\" % (ctype.app_label, ctype.model),\n \"comments/%s/form.html\" % ctype.app_label,\n \"comments/form.html\"\n ]\n context.push()\n formstr = render_to_string(template_search_list, {\"form\" : self.get_form(context)}, context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L160_C12", "label": "template_search_list =", "type": "assigned_variable", "loc": [160, 164], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "vector": [14, 3, 0.4865, 0.015, 3, 0.74, 0.0, 961, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "template_search_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " template_search_list = [\n \"comments/%s/%s/form.html\" % (ctype.app_label, ctype.model),\n \"comments/%s/form.html\" % ctype.app_label,\n \"comments/form.html\"\n ]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L165_C12", "label": "push()", "type": "expression", "loc": [165, 165], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "vector": [8, 3, 0.4955, 0.003, 3, 0.74, 0.2, 176, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "push", "arg_names": [], "import_names": [], "rhs_call_name": "push", "annotation": ""}, "snippet": " context.push()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L166_C12", "label": "formstr = render_to_string()", "type": "assigned_variable", "loc": [166, 166], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "vector": [14, 3, 0.4985, 0.003, 3, 0.74, 0.4, 852, 3, 3, 0, 0, 851, 10, 2], "semantic": {"name": "formstr", "arg_names": [], "import_names": [], "rhs_call_name": "render_to_string", "annotation": ""}, "snippet": " formstr = render_to_string(template_search_list, {\"form\" : self.get_form(context)}, context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L167_C12", "label": "pop()", "type": "expression", "loc": [167, 167], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "vector": [8, 3, 0.5015, 0.003, 3, 0.74, 0.6, 969, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " context.pop()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L168_C12", "label": "return", "type": "return", "loc": [168, 168], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "vector": [13, 3, 0.5045, 0.003, 3, 0.74, 0.8, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return formstr"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L170_C12", "label": "return", "type": "return", "loc": [170, 170], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "vector": [13, 3, 0.5105, 0.003, 3, 0.74, 1.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L172_C0", "label": "RenderCommentListNode", "type": "class", "loc": [172, 210], "level": 0, "parent": null, "vector": [3, 0, 0.5736, 0.1171, 0, 0.66, 0.4615, 558, 0, 2, 0, 0, 448, 0, 16], "semantic": {"name": "RenderCommentListNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RenderCommentListNode(CommentListNode):\n \"\"\"Render the comment list directly\"\"\"\n\n #@classmethod\n def handle_token(cls, parser, token):\n \"\"\"Class method to parse render_comment_list and return a Node.\"\"\"\n tokens = token.contents.split()\n if tokens[1] != 'for':"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L173_C4", "label": "expression", "type": "expression", "loc": [173, 173], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L172_C0", "vector": [8, 1, 0.5195, 0.003, 1, 0.67, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Render the comment list directly\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L176_C4", "label": "handle_token", "type": "function", "loc": [176, 191], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L172_C0", "vector": [2, 1, 0.5511, 0.048, 1, 0.67, 0.3333, 279, 0, 3, 1, 0, 0, 0, 9], "semantic": {"name": "handle_token", "arg_names": ["cls", "parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_token(cls, parser, token):\n \"\"\"Class method to parse render_comment_list and return a Node.\"\"\"\n tokens = token.contents.split()\n if tokens[1] != 'for':\n raise template.TemplateSyntaxError(\"Second argument in %r tag must be 'for'\" % tokens[0])\n\n # {% render_comment_list for obj %}\n if len(tokens) == 3:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L177_C8", "label": "expression", "type": "expression", "loc": [177, 177], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L176_C4", "vector": [8, 2, 0.5315, 0.003, 2, 0.98, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Class method to parse render_comment_list and return a Node.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L178_C8", "label": "tokens = split()", "type": "assigned_variable", "loc": [178, 178], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L176_C4", "vector": [14, 2, 0.5345, 0.003, 2, 0.98, 0.3333, 700, 3, 0, 0, 0, 908, 10, 1], "semantic": {"name": "tokens", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " tokens = token.contents.split()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L179_C8", "label": "if", "type": "if", "loc": [179, 180], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L176_C4", "vector": [4, 2, 0.539, 0.006, 2, 0.98, 0.6667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if tokens[1] != 'for':\n raise template.TemplateSyntaxError(\"Second argument in %r tag must be 'for'\" % tokens[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L183_C8", "label": "if", "type": "if", "loc": [183, 191], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L176_C4", "vector": [4, 2, 0.5616, 0.027, 2, 0.98, 1.0, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(tokens) == 3:\n return cls(object_expr=parser.compile_filter(tokens[2]))\n\n # {% render_comment_list for app.models pk %}\n elif len(tokens) == 4:\n return cls(\n ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),\n object_pk_expr = parser.compile_filter(tokens[3])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L184_C12", "label": "return", "type": "return", "loc": [184, 184], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L183_C8", "vector": [13, 3, 0.5526, 0.003, 3, 0.77, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return cls(object_expr=parser.compile_filter(tokens[2]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L187_C8", "label": "if", "type": "if", "loc": [187, 191], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L183_C8", "vector": [4, 3, 0.5676, 0.015, 3, 0.77, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif len(tokens) == 4:\n return cls(\n ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),\n object_pk_expr = parser.compile_filter(tokens[3])\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L188_C12", "label": "return", "type": "return", "loc": [188, 191], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L187_C8", "vector": [13, 4, 0.5691, 0.012, 4, 0.45, 0.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return cls(\n ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),\n object_pk_expr = parser.compile_filter(tokens[3])\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L192_C4", "label": "handle_token = classmethod()", "type": "assigned_variable", "loc": [192, 192], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L172_C0", "vector": [14, 1, 0.5766, 0.003, 1, 0.67, 0.6667, 279, 3, 1, 0, 0, 76, 10, 1], "semantic": {"name": "handle_token", "arg_names": [], "import_names": [], "rhs_call_name": "classmethod", "annotation": ""}, "snippet": " handle_token = classmethod(handle_token)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L194_C4", "label": "render", "type": "function", "loc": [194, 210], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L172_C0", "vector": [2, 1, 0.6066, 0.0511, 1, 0.67, 1.0, 24, 0, 2, 1, 0, 0, 0, 6], "semantic": {"name": "render", "arg_names": ["self", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self, context):\n ctype, object_pk = self.get_target_ctype_pk(context)\n if object_pk:\n template_search_list = [\n \"comments/%s/%s/list.html\" % (ctype.app_label, ctype.model),\n \"comments/%s/list.html\" % ctype.app_label,\n \"comments/list.html\"\n ]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L195_C8", "label": "ctype, object_pk = get_target_ctype_pk()", "type": "assigned_variable", "loc": [195, 195], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L194_C4", "vector": [14, 2, 0.5856, 0.003, 2, 0.51, 0.0, 403, 3, 1, 0, 0, 890, 10, 1], "semantic": {"name": "ctype, object_pk", "arg_names": [], "import_names": [], "rhs_call_name": "get_target_ctype_pk", "annotation": ""}, "snippet": " ctype, object_pk = self.get_target_ctype_pk(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "label": "if", "type": "if", "loc": [196, 210], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L194_C4", "vector": [4, 2, 0.6096, 0.045, 2, 0.51, 1.0, 0, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if object_pk:\n template_search_list = [\n \"comments/%s/%s/list.html\" % (ctype.app_label, ctype.model),\n \"comments/%s/list.html\" % ctype.app_label,\n \"comments/list.html\"\n ]\n qs = self.get_query_set(context)\n context.push()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L197_C12", "label": "template_search_list =", "type": "assigned_variable", "loc": [197, 201], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "vector": [14, 3, 0.5976, 0.015, 3, 0.03, 0.0, 961, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "template_search_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " template_search_list = [\n \"comments/%s/%s/list.html\" % (ctype.app_label, ctype.model),\n \"comments/%s/list.html\" % ctype.app_label,\n \"comments/list.html\"\n ]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L202_C12", "label": "qs = get_query_set()", "type": "assigned_variable", "loc": [202, 202], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "vector": [14, 3, 0.6066, 0.003, 3, 0.03, 0.1667, 251, 3, 1, 0, 0, 696, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "get_query_set", "annotation": ""}, "snippet": " qs = self.get_query_set(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L203_C12", "label": "push()", "type": "expression", "loc": [203, 203], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "vector": [8, 3, 0.6096, 0.003, 3, 0.03, 0.3333, 176, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "push", "arg_names": [], "import_names": [], "rhs_call_name": "push", "annotation": ""}, "snippet": " context.push()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L204_C12", "label": "liststr = render_to_string()", "type": "assigned_variable", "loc": [204, 206], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "vector": [14, 3, 0.6156, 0.009, 3, 0.03, 0.5, 484, 3, 3, 0, 0, 851, 10, 2], "semantic": {"name": "liststr", "arg_names": [], "import_names": [], "rhs_call_name": "render_to_string", "annotation": ""}, "snippet": " liststr = render_to_string(template_search_list, {\n \"comment_list\" : self.get_context_value_from_queryset(context, qs)\n }, context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L207_C12", "label": "pop()", "type": "expression", "loc": [207, 207], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "vector": [8, 3, 0.6216, 0.003, 3, 0.03, 0.6667, 969, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " context.pop()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L208_C12", "label": "return", "type": "return", "loc": [208, 208], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "vector": [13, 3, 0.6246, 0.003, 3, 0.03, 0.8333, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return liststr"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L210_C12", "label": "return", "type": "return", "loc": [210, 210], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "vector": [13, 3, 0.6306, 0.003, 3, 0.03, 1.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L217_C0", "label": "get_comment_count", "type": "function", "loc": [217, 235], "level": 0, "parent": null, "vector": [2, 0, 0.6787, 0.0571, 0, 0.66, 0.5, 968, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "get_comment_count", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_comment_count(parser, token):\n \"\"\"\n Gets the comment count for the given params and populates the template\n context with a variable containing that value, whose name is defined by the\n 'as' clause.\n\n Syntax::\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L218_C4", "label": "expression", "type": "expression", "loc": [218, 234], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L217_C0", "vector": [8, 1, 0.6787, 0.0511, 1, 0.33, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Gets the comment count for the given params and populates the template\n context with a variable containing that value, whose name is defined by the\n 'as' clause.\n\n Syntax::\n\n {% get_comment_count for [object] as [varname] %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L235_C4", "label": "return", "type": "return", "loc": [235, 235], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L217_C0", "vector": [13, 1, 0.7057, 0.003, 1, 0.33, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return CommentCountNode.handle_token(parser, token)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L238_C0", "label": "get_comment_list", "type": "function", "loc": [238, 257], "level": 0, "parent": null, "vector": [2, 0, 0.7432, 0.0601, 0, 0.66, 0.5385, 190, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "get_comment_list", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_comment_list(parser, token):\n \"\"\"\n Gets the list of comments for the given params and populates the template\n context with a variable containing that value, whose name is defined by the\n 'as' clause.\n\n Syntax::\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L239_C4", "label": "expression", "type": "expression", "loc": [239, 256], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L238_C0", "vector": [8, 1, 0.7432, 0.0541, 1, 0.41, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Gets the list of comments for the given params and populates the template\n context with a variable containing that value, whose name is defined by the\n 'as' clause.\n\n Syntax::\n\n {% get_comment_list for [object] as [varname] %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L257_C4", "label": "return", "type": "return", "loc": [257, 257], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L238_C0", "vector": [13, 1, 0.7718, 0.003, 1, 0.41, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return CommentListNode.handle_token(parser, token)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L260_C0", "label": "render_comment_list", "type": "function", "loc": [260, 275], "level": 0, "parent": null, "vector": [2, 0, 0.8033, 0.048, 0, 0.66, 0.5769, 239, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "render_comment_list", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def render_comment_list(parser, token):\n \"\"\"\n Render the comment list (as returned by ``{% get_comment_list %}``)\n through the ``comments/list.html`` template\n\n Syntax::\n\n {% render_comment_list for [object] %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L261_C4", "label": "expression", "type": "expression", "loc": [261, 274], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L260_C0", "vector": [8, 1, 0.8033, 0.042, 1, 0.29, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Render the comment list (as returned by ``{% get_comment_list %}``)\n through the ``comments/list.html`` template\n\n Syntax::\n\n {% render_comment_list for [object] %}\n {% render_comment_list for [app].[model] [object_id] %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L275_C4", "label": "return", "type": "return", "loc": [275, 275], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L260_C0", "vector": [13, 1, 0.8258, 0.003, 1, 0.29, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return RenderCommentListNode.handle_token(parser, token)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L278_C0", "label": "get_comment_form", "type": "function", "loc": [278, 287], "level": 0, "parent": null, "vector": [2, 0, 0.8483, 0.03, 0, 0.66, 0.6154, 384, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "get_comment_form", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_comment_form(parser, token):\n \"\"\"\n Get a (new) form object to post a new comment.\n\n Syntax::\n\n {% get_comment_form for [object] as [varname] %}\n {% get_comment_form for [app].[model] [object_id] as [varname] %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L279_C4", "label": "expression", "type": "expression", "loc": [279, 286], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L278_C0", "vector": [8, 1, 0.8483, 0.024, 1, 0.41, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Get a (new) form object to post a new comment.\n\n Syntax::\n\n {% get_comment_form for [object] as [varname] %}\n {% get_comment_form for [app].[model] [object_id] as [varname] %}\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L287_C4", "label": "return", "type": "return", "loc": [287, 287], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L278_C0", "vector": [13, 1, 0.8619, 0.003, 1, 0.41, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return CommentFormNode.handle_token(parser, token)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L290_C0", "label": "render_comment_form", "type": "function", "loc": [290, 300], "level": 0, "parent": null, "vector": [2, 0, 0.8859, 0.033, 0, 0.66, 0.6538, 325, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "render_comment_form", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def render_comment_form(parser, token):\n \"\"\"\n Render the comment form (as returned by ``{% render_comment_form %}``) through\n the ``comments/form.html`` template.\n\n Syntax::\n\n {% render_comment_form for [object] %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L291_C4", "label": "expression", "type": "expression", "loc": [291, 299], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L290_C0", "vector": [8, 1, 0.8859, 0.027, 1, 0.17, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Render the comment form (as returned by ``{% render_comment_form %}``) through\n the ``comments/form.html`` template.\n\n Syntax::\n\n {% render_comment_form for [object] %}\n {% render_comment_form for [app].[model] [object_id] %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L300_C4", "label": "return", "type": "return", "loc": [300, 300], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L290_C0", "vector": [13, 1, 0.9009, 0.003, 1, 0.17, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return RenderCommentFormNode.handle_token(parser, token)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L303_C0", "label": "comment_form_target", "type": "function", "loc": [303, 311], "level": 0, "parent": null, "vector": [2, 0, 0.9219, 0.027, 0, 0.66, 0.6923, 496, 0, 0, 1, 0, 0, 0, 1], "semantic": {"name": "comment_form_target", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def comment_form_target():\n \"\"\"\n Get the target URL for the comment form.\n\n Example::\n\n <form action=\"{% comment_form_target %}\" method=\"post\">\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L304_C4", "label": "expression", "type": "expression", "loc": [304, 310], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L303_C0", "vector": [8, 1, 0.9219, 0.021, 1, 0.05, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Get the target URL for the comment form.\n\n Example::\n\n <form action=\"{% comment_form_target %}\" method=\"post\">\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L311_C4", "label": "return", "type": "return", "loc": [311, 311], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L303_C0", "vector": [13, 1, 0.9339, 0.003, 1, 0.05, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return comments.get_form_target()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L314_C0", "label": "get_comment_permalink", "type": "function", "loc": [314, 325], "level": 0, "parent": null, "vector": [2, 0, 0.9595, 0.036, 0, 0.66, 0.7308, 298, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "get_comment_permalink", "arg_names": ["comment", "anchor_pattern"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_comment_permalink(comment, anchor_pattern=None):\n \"\"\"\n Get the permalink for a comment, optionally specifying the format of the\n named anchor to be appended to the end of the URL.\n\n Example::\n {{ get_comment_permalink comment \"#c%(id)s-by-%(user_name)s\" }}\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L315_C4", "label": "expression", "type": "expression", "loc": [315, 321], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L314_C0", "vector": [8, 1, 0.955, 0.021, 1, 0.23, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Get the permalink for a comment, optionally specifying the format of the\n named anchor to be appended to the end of the URL.\n\n Example::\n {{ get_comment_permalink comment \"#c%(id)s-by-%(user_name)s\" }}\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L323_C4", "label": "if", "type": "if", "loc": [323, 324], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L314_C0", "vector": [4, 1, 0.9715, 0.006, 1, 0.23, 0.5, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if anchor_pattern:\n return comment.get_absolute_url(anchor_pattern)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L324_C8", "label": "return", "type": "return", "loc": [324, 324], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L323_C4", "vector": [13, 2, 0.973, 0.003, 2, 0.92, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return comment.get_absolute_url(anchor_pattern)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L325_C4", "label": "return", "type": "return", "loc": [325, 325], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L314_C0", "vector": [13, 1, 0.976, 0.003, 1, 0.23, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return comment.get_absolute_url()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L327_C0", "label": "tag()", "type": "expression", "loc": [327, 327], "level": 0, "parent": null, "vector": [8, 0, 0.982, 0.003, 0, 0.66, 0.7692, 732, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "register.tag(get_comment_count)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L328_C0", "label": "tag()", "type": "expression", "loc": [328, 328], "level": 0, "parent": null, "vector": [8, 0, 0.985, 0.003, 0, 0.66, 0.8077, 732, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "register.tag(get_comment_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L329_C0", "label": "tag()", "type": "expression", "loc": [329, 329], "level": 0, "parent": null, "vector": [8, 0, 0.988, 0.003, 0, 0.66, 0.8462, 732, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "register.tag(get_comment_form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L330_C0", "label": "tag()", "type": "expression", "loc": [330, 330], "level": 0, "parent": null, "vector": [8, 0, 0.991, 0.003, 0, 0.66, 0.8846, 732, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "register.tag(render_comment_form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L331_C0", "label": "simple_tag()", "type": "expression", "loc": [331, 331], "level": 0, "parent": null, "vector": [8, 0, 0.994, 0.003, 0, 0.66, 0.9231, 123, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "simple_tag", "arg_names": [], "import_names": [], "rhs_call_name": "simple_tag", "annotation": ""}, "snippet": "register.simple_tag(comment_form_target)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L332_C0", "label": "simple_tag()", "type": "expression", "loc": [332, 332], "level": 0, "parent": null, "vector": [8, 0, 0.997, 0.003, 0, 0.66, 0.9615, 123, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "simple_tag", "arg_names": [], "import_names": [], "rhs_call_name": "simple_tag", "annotation": ""}, "snippet": "register.simple_tag(get_comment_permalink)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L333_C0", "label": "tag()", "type": "expression", "loc": [333, 333], "level": 0, "parent": null, "vector": [8, 0, 1.0, 0.003, 0, 0.66, 1.0, 732, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "register.tag(render_comment_list)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L34_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L35_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L34_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Try_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:Try_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L51_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:Try_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L52_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L57_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L76_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L77_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L79_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L90_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L91_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L92_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L92_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L93_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L97_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L97_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L98_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L98_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Try_L99_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:Try_L99_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L100_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:Try_L99_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L102_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L98_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L103_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L98_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L105_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L107_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L107_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L108_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L111_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L112_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L111_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L113_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L113_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L117_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L118_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L121_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L122_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L121_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L124_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L124_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L124_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L126_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L127_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L126_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L129_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L121_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L131_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L132_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L135_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L136_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L135_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L139_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L141_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L142_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L146_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L146_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L147_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L146_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L150_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L150_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L151_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L135_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L155_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L135_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L157_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L157_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L158_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L157_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L160_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L165_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L166_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L167_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L168_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L159_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L170_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L172_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L173_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L172_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L176_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L176_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L177_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L176_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L178_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L176_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L179_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L176_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L183_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L183_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L184_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L183_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L187_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L187_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L188_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L172_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L192_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:ClassDef_L172_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L194_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L195_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L197_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L202_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L203_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Assign_L204_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L207_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L208_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L210_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L217_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L218_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L217_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L235_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L238_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L239_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L238_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L257_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L260_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L261_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L260_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L275_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L278_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L279_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L278_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L287_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L290_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L291_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L290_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L300_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L303_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L304_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L303_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L311_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L314_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Expr_L315_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L314_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L323_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:If_L323_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L324_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98594:FunctionDef_L314_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98594:Return_L325_C4"}] |
from django.contrib import admin
from django.contrib.comments.models import Comment
from django.utils.translation import ugettext_lazy as _, ungettext
from django.contrib.comments import get_model
from django.contrib.comments.views.moderation import perform_flag, perform_approve, perform_delete
class CommentsAdmin(admin.ModelAdmin):
fieldsets = (
(None,
{'fields': ('content_type', 'object_pk', 'site')}
),
(_('Content'),
{'fields': ('user', 'user_name', 'user_email', 'user_url', 'comment')}
),
(_('Metadata'),
{'fields': ('submit_date', 'ip_address', 'is_public', 'is_removed')}
),
)
list_display = ('name', 'content_type', 'object_pk', 'ip_address', 'submit_date', 'is_public', 'is_removed')
list_filter = ('submit_date', 'site', 'is_public', 'is_removed')
date_hierarchy = 'submit_date'
ordering = ('-submit_date',)
raw_id_fields = ('user',)
search_fields = ('comment', 'user__username', 'user_name', 'user_email', 'user_url', 'ip_address')
actions = ["flag_comments", "approve_comments", "remove_comments"]
def get_actions(self, request):
actions = super(CommentsAdmin, self).get_actions(request)
# Only superusers should be able to delete the comments from the DB.
if not request.user.is_superuser:
actions.pop('delete_selected')
if not request.user.has_perm('comments.can_moderate'):
actions.pop('approve_comments')
actions.pop('remove_comments')
return actions
def flag_comments(self, request, queryset):
self._bulk_flag(request, queryset, perform_flag,
lambda n: ungettext('flagged', 'flagged', n))
flag_comments.short_description = _("Flag selected comments")
def approve_comments(self, request, queryset):
self._bulk_flag(request, queryset, perform_approve,
lambda n: ungettext('approved', 'approved', n))
approve_comments.short_description = _("Approve selected comments")
def remove_comments(self, request, queryset):
self._bulk_flag(request, queryset, perform_delete,
lambda n: ungettext('removed', 'removed', n))
remove_comments.short_description = _("Remove selected comments")
def _bulk_flag(self, request, queryset, action, done_message):
"""
Flag, approve, or remove some comments from an admin action. Actually
calls the `action` argument to perform the heavy lifting.
"""
n_comments = 0
for comment in queryset:
action(request, comment)
n_comments += 1
msg = ungettext(u'1 comment was successfully %(action)s.',
u'%(count)s comments were successfully %(action)s.',
n_comments)
self.message_user(request, msg % {'count': n_comments, 'action': done_message(n_comments)})
# Only register the default admin if the model is the built-in comment model
# (this won't be true if there's a custom comment app).
if get_model() is Comment:
admin.site.register(Comment, CommentsAdmin)
| ajibawa-2023/Python-Code-Large/train/row_98595 | 40 | 71 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98595:ImportFrom_L1_C0", "label": "from django.contrib import admin", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0141, 0.0141, 0, 0.66, 0.0, 302, 0, 1, 0, 0, 302, 0, 0], "semantic": {"name": "django.contrib", "arg_names": [], "import_names": ["admin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib import admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:ImportFrom_L2_C0", "label": "from django.contrib.comments.models import Comment", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0282, 0.0141, 0, 0.66, 0.1667, 418, 0, 1, 0, 0, 418, 0, 0], "semantic": {"name": "django.contrib.comments.models", "arg_names": [], "import_names": ["Comment"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.comments.models import Comment"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:ImportFrom_L3_C0", "label": "from django.utils.translation import _, ungettext", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0423, 0.0141, 0, 0.66, 0.3333, 389, 0, 2, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_", "ungettext"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext_lazy as _, ungettext"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:ImportFrom_L4_C0", "label": "from django.contrib.comments import get_model", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0563, 0.0141, 0, 0.66, 0.5, 45, 0, 1, 0, 0, 45, 0, 0], "semantic": {"name": "django.contrib.comments", "arg_names": [], "import_names": ["get_model"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.comments import get_model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:ImportFrom_L5_C0", "label": "from django.contrib.comments.views.moderation import perform_flag, perform_approve, perform_delete", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0704, 0.0141, 0, 0.66, 0.6667, 316, 0, 3, 0, 0, 316, 0, 0], "semantic": {"name": "django.contrib.comments.views.moderation", "arg_names": [], "import_names": ["perform_flag", "perform_approve", "perform_delete"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.comments.views.moderation import perform_flag, perform_approve, perform_delete"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "label": "CommentsAdmin", "type": "class", "loc": [7, 66], "level": 0, "parent": null, "vector": [3, 0, 0.5141, 0.8451, 0, 0.66, 0.8333, 346, 0, 5, 0, 0, 823, 0, 21], "semantic": {"name": "CommentsAdmin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CommentsAdmin(admin.ModelAdmin):\n fieldsets = (\n (None,\n {'fields': ('content_type', 'object_pk', 'site')}\n ),\n (_('Content'),\n {'fields': ('user', 'user_name', 'user_email', 'user_url', 'comment')}\n ),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L8_C4", "label": "fieldsets =", "type": "assigned_variable", "loc": [8, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [14, 1, 0.1831, 0.1549, 1, 0.05, 0.0, 340, 0, 0, 0, 0, 0, 8, 2], "semantic": {"name": "fieldsets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fieldsets = (\n (None,\n {'fields': ('content_type', 'object_pk', 'site')}\n ),\n (_('Content'),\n {'fields': ('user', 'user_name', 'user_email', 'user_url', 'comment')}\n ),\n (_('Metadata'),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L20_C4", "label": "list_display =", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [14, 1, 0.2817, 0.0141, 1, 0.05, 0.0667, 489, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "list_display", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_display = ('name', 'content_type', 'object_pk', 'ip_address', 'submit_date', 'is_public', 'is_removed')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L21_C4", "label": "list_filter =", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [14, 1, 0.2958, 0.0141, 1, 0.05, 0.1333, 851, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "list_filter", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_filter = ('submit_date', 'site', 'is_public', 'is_removed')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L22_C4", "label": "date_hierarchy =", "type": "assigned_variable", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [14, 1, 0.3099, 0.0141, 1, 0.05, 0.2, 317, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "date_hierarchy", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " date_hierarchy = 'submit_date'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L23_C4", "label": "ordering =", "type": "assigned_variable", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [14, 1, 0.3239, 0.0141, 1, 0.05, 0.2667, 656, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "ordering", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ordering = ('-submit_date',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L24_C4", "label": "raw_id_fields =", "type": "assigned_variable", "loc": [24, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [14, 1, 0.338, 0.0141, 1, 0.05, 0.3333, 309, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "raw_id_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " raw_id_fields = ('user',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L25_C4", "label": "search_fields =", "type": "assigned_variable", "loc": [25, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [14, 1, 0.3521, 0.0141, 1, 0.05, 0.4, 834, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "search_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " search_fields = ('comment', 'user__username', 'user_name', 'user_email', 'user_url', 'ip_address')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L26_C4", "label": "actions =", "type": "assigned_variable", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [14, 1, 0.3662, 0.0141, 1, 0.05, 0.4667, 317, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "actions", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " actions = [\"flag_comments\", \"approve_comments\", \"remove_comments\"]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L28_C4", "label": "get_actions", "type": "function", "loc": [28, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [2, 1, 0.4507, 0.1268, 1, 0.05, 0.5333, 315, 0, 2, 1, 0, 0, 0, 6], "semantic": {"name": "get_actions", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_actions(self, request):\n actions = super(CommentsAdmin, self).get_actions(request)\n # Only superusers should be able to delete the comments from the DB.\n if not request.user.is_superuser:\n actions.pop('delete_selected')\n if not request.user.has_perm('comments.can_moderate'):\n actions.pop('approve_comments')\n actions.pop('remove_comments')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L29_C8", "label": "actions = get_actions()", "type": "assigned_variable", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L28_C4", "vector": [14, 2, 0.4085, 0.0141, 2, 0.88, 0.0, 317, 3, 1, 0, 0, 315, 10, 2], "semantic": {"name": "actions", "arg_names": [], "import_names": [], "rhs_call_name": "get_actions", "annotation": ""}, "snippet": " actions = super(CommentsAdmin, self).get_actions(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L31_C8", "label": "if", "type": "if", "loc": [31, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L28_C4", "vector": [4, 2, 0.4437, 0.0282, 2, 0.88, 0.3333, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not request.user.is_superuser:\n actions.pop('delete_selected')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L32_C12", "label": "pop()", "type": "expression", "loc": [32, 32], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L31_C8", "vector": [8, 3, 0.4507, 0.0141, 3, 0.66, 0.0, 969, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " actions.pop('delete_selected')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L33_C8", "label": "if", "type": "if", "loc": [33, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L28_C4", "vector": [4, 2, 0.4789, 0.0423, 2, 0.88, 0.6667, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not request.user.has_perm('comments.can_moderate'):\n actions.pop('approve_comments')\n actions.pop('remove_comments')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L34_C12", "label": "pop()", "type": "expression", "loc": [34, 34], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L33_C8", "vector": [8, 3, 0.4789, 0.0141, 3, 0.92, 0.0, 969, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " actions.pop('approve_comments')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L35_C12", "label": "pop()", "type": "expression", "loc": [35, 35], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L33_C8", "vector": [8, 3, 0.493, 0.0141, 3, 0.92, 1.0, 969, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " actions.pop('remove_comments')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Return_L36_C8", "label": "return", "type": "return", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L28_C4", "vector": [13, 2, 0.507, 0.0141, 2, 0.88, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return actions"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L38_C4", "label": "flag_comments", "type": "function", "loc": [38, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [2, 1, 0.5493, 0.0423, 1, 0.05, 0.6, 337, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "flag_comments", "arg_names": ["self", "request", "queryset"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def flag_comments(self, request, queryset):\n self._bulk_flag(request, queryset, perform_flag,\n lambda n: ungettext('flagged', 'flagged', n))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L39_C8", "label": "_bulk_flag()", "type": "expression", "loc": [39, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L38_C4", "vector": [8, 2, 0.5563, 0.0282, 2, 0.6, 0.0, 507, 3, 4, 0, 0, 0, 0, 2], "semantic": {"name": "_bulk_flag", "arg_names": [], "import_names": [], "rhs_call_name": "_bulk_flag", "annotation": ""}, "snippet": " self._bulk_flag(request, queryset, perform_flag,\n lambda n: ungettext('flagged', 'flagged', n))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L41_C4", "label": "flag_comments.short_description = _()", "type": "assigned_variable", "loc": [41, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [14, 1, 0.5775, 0.0141, 1, 0.05, 0.6667, 367, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "flag_comments.short_description", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " flag_comments.short_description = _(\"Flag selected comments\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L43_C4", "label": "approve_comments", "type": "function", "loc": [43, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [2, 1, 0.6197, 0.0423, 1, 0.05, 0.7333, 247, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "approve_comments", "arg_names": ["self", "request", "queryset"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def approve_comments(self, request, queryset):\n self._bulk_flag(request, queryset, perform_approve,\n lambda n: ungettext('approved', 'approved', n))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L44_C8", "label": "_bulk_flag()", "type": "expression", "loc": [44, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L43_C4", "vector": [8, 2, 0.6268, 0.0282, 2, 0.02, 0.0, 507, 3, 4, 0, 0, 0, 0, 2], "semantic": {"name": "_bulk_flag", "arg_names": [], "import_names": [], "rhs_call_name": "_bulk_flag", "annotation": ""}, "snippet": " self._bulk_flag(request, queryset, perform_approve,\n lambda n: ungettext('approved', 'approved', n))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L46_C4", "label": "approve_comments.short_description = _()", "type": "assigned_variable", "loc": [46, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [14, 1, 0.6479, 0.0141, 1, 0.05, 0.8, 716, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "approve_comments.short_description", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " approve_comments.short_description = _(\"Approve selected comments\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L48_C4", "label": "remove_comments", "type": "function", "loc": [48, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [2, 1, 0.6901, 0.0423, 1, 0.05, 0.8667, 71, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "remove_comments", "arg_names": ["self", "request", "queryset"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def remove_comments(self, request, queryset):\n self._bulk_flag(request, queryset, perform_delete,\n lambda n: ungettext('removed', 'removed', n))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L49_C8", "label": "_bulk_flag()", "type": "expression", "loc": [49, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L48_C4", "vector": [8, 2, 0.6972, 0.0282, 2, 0.94, 0.0, 507, 3, 4, 0, 0, 0, 0, 2], "semantic": {"name": "_bulk_flag", "arg_names": [], "import_names": [], "rhs_call_name": "_bulk_flag", "annotation": ""}, "snippet": " self._bulk_flag(request, queryset, perform_delete,\n lambda n: ungettext('removed', 'removed', n))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L51_C4", "label": "remove_comments.short_description = _()", "type": "assigned_variable", "loc": [51, 51], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [14, 1, 0.7183, 0.0141, 1, 0.05, 0.9333, 555, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "remove_comments.short_description", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " remove_comments.short_description = _(\"Remove selected comments\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L53_C4", "label": "_bulk_flag", "type": "function", "loc": [53, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "vector": [2, 1, 0.838, 0.1972, 1, 0.05, 1.0, 507, 0, 5, 0, 0, 0, 0, 4], "semantic": {"name": "_bulk_flag", "arg_names": ["self", "request", "queryset", "action", "done_message"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _bulk_flag(self, request, queryset, action, done_message):\n \"\"\"\n Flag, approve, or remove some comments from an admin action. Actually\n calls the `action` argument to perform the heavy lifting.\n \"\"\"\n n_comments = 0\n for comment in queryset:\n action(request, comment)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L54_C8", "label": "expression", "type": "expression", "loc": [54, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L53_C4", "vector": [8, 2, 0.7817, 0.0563, 2, 0.82, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Flag, approve, or remove some comments from an admin action. Actually\n calls the `action` argument to perform the heavy lifting.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L58_C8", "label": "n_comments =", "type": "assigned_variable", "loc": [58, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L53_C4", "vector": [14, 2, 0.8169, 0.0141, 2, 0.82, 0.25, 762, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "n_comments", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " n_comments = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:For_L59_C8", "label": "for comment", "type": "for", "loc": [59, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L53_C4", "vector": [6, 2, 0.8451, 0.0423, 2, 0.82, 0.5, 34, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "comment", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for comment in queryset:\n action(request, comment)\n n_comments += 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L60_C12", "label": "action()", "type": "expression", "loc": [60, 60], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:For_L59_C8", "vector": [8, 3, 0.8451, 0.0141, 3, 0.4, 0.0, 422, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "action", "arg_names": [], "import_names": [], "rhs_call_name": "action", "annotation": ""}, "snippet": " action(request, comment)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L63_C8", "label": "msg = ungettext()", "type": "assigned_variable", "loc": [63, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L53_C4", "vector": [14, 2, 0.9014, 0.0423, 2, 0.82, 0.75, 712, 3, 3, 0, 0, 950, 10, 1], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "ungettext", "annotation": ""}, "snippet": " msg = ungettext(u'1 comment was successfully %(action)s.',\n u'%(count)s comments were successfully %(action)s.',\n n_comments)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L66_C8", "label": "message_user()", "type": "expression", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L53_C4", "vector": [8, 2, 0.9296, 0.0141, 2, 0.82, 1.0, 207, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, msg % {'count': n_comments, 'action': done_message(n_comments)})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L70_C0", "label": "if", "type": "if", "loc": [70, 71], "level": 0, "parent": null, "vector": [4, 0, 0.993, 0.0282, 0, 0.66, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if get_model() is Comment:\n admin.site.register(Comment, CommentsAdmin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L71_C4", "label": "register()", "type": "expression", "loc": [71, 71], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L70_C0", "vector": [8, 1, 1.0, 0.0141, 1, 0.44, 0.0, 276, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "register", "annotation": ""}, "snippet": " admin.site.register(Comment, CommentsAdmin)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L31_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L32_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L33_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L34_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L33_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L35_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Return_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L38_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L51_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L53_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:For_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:For_L59_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L60_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Assign_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:FunctionDef_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98595:If_L70_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98595:Expr_L71_C4"}] |
from django.conf import settings
from django.core import urlresolvers
from django.core.exceptions import ImproperlyConfigured
from django.contrib.comments.models import Comment
from django.contrib.comments.forms import CommentForm
from django.utils.importlib import import_module
DEFAULT_COMMENTS_APP = 'django.contrib.comments'
def get_comment_app():
"""
Get the comment app (i.e. "django.contrib.comments") as defined in the settings
"""
# Make sure the app's in INSTALLED_APPS
comments_app = get_comment_app_name()
if comments_app not in settings.INSTALLED_APPS:
raise ImproperlyConfigured("The COMMENTS_APP (%r) "\
"must be in INSTALLED_APPS" % settings.COMMENTS_APP)
# Try to import the package
try:
package = import_module(comments_app)
except ImportError:
raise ImproperlyConfigured("The COMMENTS_APP setting refers to "\
"a non-existing package.")
return package
def get_comment_app_name():
"""
Returns the name of the comment app (either the setting value, if it
exists, or the default).
"""
return getattr(settings, 'COMMENTS_APP', DEFAULT_COMMENTS_APP)
def get_model():
"""
Returns the comment model class.
"""
if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_model"):
return get_comment_app().get_model()
else:
return Comment
def get_form():
"""
Returns the comment ModelForm class.
"""
if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_form"):
return get_comment_app().get_form()
else:
return CommentForm
def get_form_target():
"""
Returns the target URL for the comment form submission view.
"""
if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_form_target"):
return get_comment_app().get_form_target()
else:
return urlresolvers.reverse("django.contrib.comments.views.comments.post_comment")
def get_flag_url(comment):
"""
Get the URL for the "flag this comment" view.
"""
if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_flag_url"):
return get_comment_app().get_flag_url(comment)
else:
return urlresolvers.reverse("django.contrib.comments.views.moderation.flag",
args=(comment.id,))
def get_delete_url(comment):
"""
Get the URL for the "delete this comment" view.
"""
if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_delete_url"):
return get_comment_app().get_delete_url(comment)
else:
return urlresolvers.reverse("django.contrib.comments.views.moderation.delete",
args=(comment.id,))
def get_approve_url(comment):
"""
Get the URL for the "approve this comment from moderation" view.
"""
if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_approve_url"):
return get_comment_app().get_approve_url(comment)
else:
return urlresolvers.reverse("django.contrib.comments.views.moderation.approve",
args=(comment.id,))
| ajibawa-2023/Python-Code-Large/train/row_98596 | 47 | 91 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98596:ImportFrom_L1_C0", "label": "from django.conf import settings", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.011, 0.011, 0, 0.66, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:ImportFrom_L2_C0", "label": "from django.core import urlresolvers", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.022, 0.011, 0, 0.66, 0.0714, 913, 0, 1, 0, 0, 913, 0, 0], "semantic": {"name": "django.core", "arg_names": [], "import_names": ["urlresolvers"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core import urlresolvers"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:ImportFrom_L3_C0", "label": "from django.core.exceptions import ImproperlyConfigured", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.033, 0.011, 0, 0.66, 0.1429, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["ImproperlyConfigured"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import ImproperlyConfigured"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:ImportFrom_L4_C0", "label": "from django.contrib.comments.models import Comment", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.044, 0.011, 0, 0.66, 0.2143, 418, 0, 1, 0, 0, 418, 0, 0], "semantic": {"name": "django.contrib.comments.models", "arg_names": [], "import_names": ["Comment"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.comments.models import Comment"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:ImportFrom_L5_C0", "label": "from django.contrib.comments.forms import CommentForm", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0549, 0.011, 0, 0.66, 0.2857, 710, 0, 1, 0, 0, 710, 0, 0], "semantic": {"name": "django.contrib.comments.forms", "arg_names": [], "import_names": ["CommentForm"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.comments.forms import CommentForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:ImportFrom_L6_C0", "label": "from django.utils.importlib import import_module", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0659, 0.011, 0, 0.66, 0.3571, 118, 0, 1, 0, 0, 118, 0, 0], "semantic": {"name": "django.utils.importlib", "arg_names": [], "import_names": ["import_module"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.importlib import import_module"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Assign_L8_C0", "label": "DEFAULT_COMMENTS_APP =", "type": "assigned_variable", "loc": [8, 8], "level": 0, "parent": null, "vector": [14, 0, 0.0879, 0.011, 0, 0.66, 0.4286, 397, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DEFAULT_COMMENTS_APP", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DEFAULT_COMMENTS_APP = 'django.contrib.comments'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L10_C0", "label": "get_comment_app", "type": "function", "loc": [10, 27], "level": 0, "parent": null, "vector": [2, 0, 0.2033, 0.1978, 0, 0.66, 0.5, 837, 0, 0, 1, 0, 0, 0, 4], "semantic": {"name": "get_comment_app", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_comment_app():\n \"\"\"\n Get the comment app (i.e. \"django.contrib.comments\") as defined in the settings\n \"\"\"\n # Make sure the app's in INSTALLED_APPS\n comments_app = get_comment_app_name()\n if comments_app not in settings.INSTALLED_APPS:\n raise ImproperlyConfigured(\"The COMMENTS_APP (%r) \"\\"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L11_C4", "label": "expression", "type": "expression", "loc": [11, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L10_C0", "vector": [8, 1, 0.1319, 0.033, 1, 0.88, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Get the comment app (i.e. \"django.contrib.comments\") as defined in the settings\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Assign_L15_C4", "label": "comments_app = get_comment_app_name()", "type": "assigned_variable", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L10_C0", "vector": [14, 1, 0.1648, 0.011, 1, 0.88, 0.25, 145, 3, 0, 0, 0, 850, 10, 1], "semantic": {"name": "comments_app", "arg_names": [], "import_names": [], "rhs_call_name": "get_comment_app_name", "annotation": ""}, "snippet": " comments_app = get_comment_app_name()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L16_C4", "label": "if", "type": "if", "loc": [16, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L10_C0", "vector": [4, 1, 0.1868, 0.033, 1, 0.88, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if comments_app not in settings.INSTALLED_APPS:\n raise ImproperlyConfigured(\"The COMMENTS_APP (%r) \"\\\n \"must be in INSTALLED_APPS\" % settings.COMMENTS_APP)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Try_L21_C4", "label": "try", "type": "try", "loc": [21, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L10_C0", "vector": [7, 1, 0.2527, 0.0549, 1, 0.88, 0.75, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n package = import_module(comments_app)\n except ImportError:\n raise ImproperlyConfigured(\"The COMMENTS_APP setting refers to \"\\\n \"a non-existing package.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Assign_L22_C8", "label": "package = import_module()", "type": "assigned_variable", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:Try_L21_C4", "vector": [14, 2, 0.2418, 0.011, 2, 0.3, 0.0, 187, 3, 1, 0, 0, 637, 10, 1], "semantic": {"name": "package", "arg_names": [], "import_names": [], "rhs_call_name": "import_module", "annotation": ""}, "snippet": " package = import_module(comments_app)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L27_C4", "label": "return", "type": "return", "loc": [27, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L10_C0", "vector": [13, 1, 0.2967, 0.011, 1, 0.88, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return package"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L29_C0", "label": "get_comment_app_name", "type": "function", "loc": [29, 34], "level": 0, "parent": null, "vector": [2, 0, 0.3462, 0.0659, 0, 0.66, 0.5714, 850, 0, 0, 1, 0, 0, 0, 1], "semantic": {"name": "get_comment_app_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_comment_app_name():\n \"\"\"\n Returns the name of the comment app (either the setting value, if it\n exists, or the default).\n \"\"\"\n return getattr(settings, 'COMMENTS_APP', DEFAULT_COMMENTS_APP)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L30_C4", "label": "expression", "type": "expression", "loc": [30, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L29_C0", "vector": [8, 1, 0.3462, 0.044, 1, 0.4, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns the name of the comment app (either the setting value, if it\n exists, or the default).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L34_C4", "label": "return", "type": "return", "loc": [34, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L29_C0", "vector": [13, 1, 0.3736, 0.011, 1, 0.4, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return getattr(settings, 'COMMENTS_APP', DEFAULT_COMMENTS_APP)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L36_C0", "label": "get_model", "type": "function", "loc": [36, 43], "level": 0, "parent": null, "vector": [2, 0, 0.4341, 0.0879, 0, 0.66, 0.6429, 115, 0, 0, 1, 0, 0, 0, 5], "semantic": {"name": "get_model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_model():\n \"\"\"\n Returns the comment model class.\n \"\"\"\n if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), \"get_model\"):\n return get_comment_app().get_model()\n else:\n return Comment"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L37_C4", "label": "expression", "type": "expression", "loc": [37, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L36_C0", "vector": [8, 1, 0.4176, 0.033, 1, 0.05, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns the comment model class.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L40_C4", "label": "if", "type": "if", "loc": [40, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L36_C0", "vector": [4, 1, 0.456, 0.044, 1, 0.05, 1.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), \"get_model\"):\n return get_comment_app().get_model()\n else:\n return Comment"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L41_C8", "label": "return", "type": "return", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L40_C4", "vector": [13, 2, 0.4505, 0.011, 2, 0.78, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return get_comment_app().get_model()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L43_C8", "label": "return", "type": "return", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L40_C4", "vector": [13, 2, 0.4725, 0.011, 2, 0.78, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return Comment"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L45_C0", "label": "get_form", "type": "function", "loc": [45, 52], "level": 0, "parent": null, "vector": [2, 0, 0.533, 0.0879, 0, 0.66, 0.7143, 265, 0, 0, 1, 0, 0, 0, 5], "semantic": {"name": "get_form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_form():\n \"\"\"\n Returns the comment ModelForm class.\n \"\"\"\n if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), \"get_form\"):\n return get_comment_app().get_form()\n else:\n return CommentForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L46_C4", "label": "expression", "type": "expression", "loc": [46, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L45_C0", "vector": [8, 1, 0.5165, 0.033, 1, 0.05, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns the comment ModelForm class.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L49_C4", "label": "if", "type": "if", "loc": [49, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L45_C0", "vector": [4, 1, 0.5549, 0.044, 1, 0.05, 1.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), \"get_form\"):\n return get_comment_app().get_form()\n else:\n return CommentForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L50_C8", "label": "return", "type": "return", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L49_C4", "vector": [13, 2, 0.5495, 0.011, 2, 0.05, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return get_comment_app().get_form()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L52_C8", "label": "return", "type": "return", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L49_C4", "vector": [13, 2, 0.5714, 0.011, 2, 0.05, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return CommentForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L54_C0", "label": "get_form_target", "type": "function", "loc": [54, 61], "level": 0, "parent": null, "vector": [2, 0, 0.6319, 0.0879, 0, 0.66, 0.7857, 221, 0, 0, 1, 0, 0, 0, 6], "semantic": {"name": "get_form_target", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_form_target():\n \"\"\"\n Returns the target URL for the comment form submission view.\n \"\"\"\n if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), \"get_form_target\"):\n return get_comment_app().get_form_target()\n else:\n return urlresolvers.reverse(\"django.contrib.comments.views.comments.post_comment\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L55_C4", "label": "expression", "type": "expression", "loc": [55, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L54_C0", "vector": [8, 1, 0.6154, 0.033, 1, 0.85, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns the target URL for the comment form submission view.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L58_C4", "label": "if", "type": "if", "loc": [58, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L54_C0", "vector": [4, 1, 0.6538, 0.044, 1, 0.85, 1.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), \"get_form_target\"):\n return get_comment_app().get_form_target()\n else:\n return urlresolvers.reverse(\"django.contrib.comments.views.comments.post_comment\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L59_C8", "label": "return", "type": "return", "loc": [59, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L58_C4", "vector": [13, 2, 0.6484, 0.011, 2, 0.13, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return get_comment_app().get_form_target()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L61_C8", "label": "return", "type": "return", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L58_C4", "vector": [13, 2, 0.6703, 0.011, 2, 0.13, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return urlresolvers.reverse(\"django.contrib.comments.views.comments.post_comment\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L63_C0", "label": "get_flag_url", "type": "function", "loc": [63, 71], "level": 0, "parent": null, "vector": [2, 0, 0.7363, 0.0989, 0, 0.66, 0.8571, 870, 0, 1, 1, 0, 0, 0, 6], "semantic": {"name": "get_flag_url", "arg_names": ["comment"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_flag_url(comment):\n \"\"\"\n Get the URL for the \"flag this comment\" view.\n \"\"\"\n if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), \"get_flag_url\"):\n return get_comment_app().get_flag_url(comment)\n else:\n return urlresolvers.reverse(\"django.contrib.comments.views.moderation.flag\","}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L64_C4", "label": "expression", "type": "expression", "loc": [64, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L63_C0", "vector": [8, 1, 0.7143, 0.033, 1, 0.43, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Get the URL for the \"flag this comment\" view.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L67_C4", "label": "if", "type": "if", "loc": [67, 71], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L63_C0", "vector": [4, 1, 0.7582, 0.0549, 1, 0.43, 1.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), \"get_flag_url\"):\n return get_comment_app().get_flag_url(comment)\n else:\n return urlresolvers.reverse(\"django.contrib.comments.views.moderation.flag\",\n args=(comment.id,))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L68_C8", "label": "return", "type": "return", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L67_C4", "vector": [13, 2, 0.7473, 0.011, 2, 0.19, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return get_comment_app().get_flag_url(comment)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L70_C8", "label": "return", "type": "return", "loc": [70, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L67_C4", "vector": [13, 2, 0.7747, 0.022, 2, 0.19, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return urlresolvers.reverse(\"django.contrib.comments.views.moderation.flag\",\n args=(comment.id,))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L73_C0", "label": "get_delete_url", "type": "function", "loc": [73, 81], "level": 0, "parent": null, "vector": [2, 0, 0.8462, 0.0989, 0, 0.66, 0.9286, 361, 0, 1, 1, 0, 0, 0, 6], "semantic": {"name": "get_delete_url", "arg_names": ["comment"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_delete_url(comment):\n \"\"\"\n Get the URL for the \"delete this comment\" view.\n \"\"\"\n if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), \"get_delete_url\"):\n return get_comment_app().get_delete_url(comment)\n else:\n return urlresolvers.reverse(\"django.contrib.comments.views.moderation.delete\","}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L74_C4", "label": "expression", "type": "expression", "loc": [74, 76], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L73_C0", "vector": [8, 1, 0.8242, 0.033, 1, 0.74, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Get the URL for the \"delete this comment\" view.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L77_C4", "label": "if", "type": "if", "loc": [77, 81], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L73_C0", "vector": [4, 1, 0.8681, 0.0549, 1, 0.74, 1.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), \"get_delete_url\"):\n return get_comment_app().get_delete_url(comment)\n else:\n return urlresolvers.reverse(\"django.contrib.comments.views.moderation.delete\",\n args=(comment.id,))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L78_C8", "label": "return", "type": "return", "loc": [78, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L77_C4", "vector": [13, 2, 0.8571, 0.011, 2, 0.36, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return get_comment_app().get_delete_url(comment)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L80_C8", "label": "return", "type": "return", "loc": [80, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L77_C4", "vector": [13, 2, 0.8846, 0.022, 2, 0.36, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return urlresolvers.reverse(\"django.contrib.comments.views.moderation.delete\",\n args=(comment.id,))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L83_C0", "label": "get_approve_url", "type": "function", "loc": [83, 91], "level": 0, "parent": null, "vector": [2, 0, 0.956, 0.0989, 0, 0.66, 1.0, 353, 0, 1, 1, 0, 0, 0, 6], "semantic": {"name": "get_approve_url", "arg_names": ["comment"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_approve_url(comment):\n \"\"\"\n Get the URL for the \"approve this comment from moderation\" view.\n \"\"\"\n if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), \"get_approve_url\"):\n return get_comment_app().get_approve_url(comment)\n else:\n return urlresolvers.reverse(\"django.contrib.comments.views.moderation.approve\","}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L84_C4", "label": "expression", "type": "expression", "loc": [84, 86], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L83_C0", "vector": [8, 1, 0.9341, 0.033, 1, 0.72, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Get the URL for the \"approve this comment from moderation\" view.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L87_C4", "label": "if", "type": "if", "loc": [87, 91], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L83_C0", "vector": [4, 1, 0.978, 0.0549, 1, 0.72, 1.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), \"get_approve_url\"):\n return get_comment_app().get_approve_url(comment)\n else:\n return urlresolvers.reverse(\"django.contrib.comments.views.moderation.approve\",\n args=(comment.id,))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L88_C8", "label": "return", "type": "return", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L87_C4", "vector": [13, 2, 0.967, 0.011, 2, 0.86, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return get_comment_app().get_approve_url(comment)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L90_C8", "label": "return", "type": "return", "loc": [90, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L87_C4", "vector": [13, 2, 0.9945, 0.022, 2, 0.86, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return urlresolvers.reverse(\"django.contrib.comments.views.moderation.approve\",\n args=(comment.id,))"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Assign_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Try_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:Try_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Assign_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L29_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L29_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L36_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L36_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L54_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L54_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L58_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L64_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L73_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L74_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L73_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L77_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Expr_L84_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:FunctionDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L87_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L87_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98596:If_L87_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98596:Return_L90_C8"}] |
"""
Create a superuser from the command line. Deprecated; use manage.py
createsuperuser instead.
"""
if __name__ == "__main__":
from django.core.management import call_command
call_command("createsuperuser")
| ajibawa-2023/Python-Code-Large/train/row_98597 | 4 | 8 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98597:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 4], "level": 0, "parent": null, "vector": [8, 0, 0.3125, 0.5, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nCreate a superuser from the command line. Deprecated; use manage.py\ncreatesuperuser instead.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98597:If_L6_C0", "label": "if", "type": "if", "loc": [6, 8], "level": 0, "parent": null, "vector": [4, 0, 0.875, 0.375, 0, 0.66, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if __name__ == \"__main__\":\n from django.core.management import call_command\n call_command(\"createsuperuser\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98597:ImportFrom_L7_C4", "label": "from django.core.management import call_command", "type": "import", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98597:If_L6_C0", "vector": [1, 1, 0.875, 0.125, 1, 0.49, 0.0, 879, 0, 1, 0, 0, 879, 0, 0], "semantic": {"name": "django.core.management", "arg_names": [], "import_names": ["call_command"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.core.management import call_command"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98597:Expr_L8_C4", "label": "call_command()", "type": "expression", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98597:If_L6_C0", "vector": [8, 1, 1.0, 0.125, 1, 0.49, 1.0, 587, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "call_command", "arg_names": [], "import_names": [], "rhs_call_name": "call_command", "annotation": ""}, "snippet": " call_command(\"createsuperuser\")"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98597:If_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98597:ImportFrom_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98597:If_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98597:Expr_L8_C4"}] |
from django.contrib.auth.models import User
from django.contrib.auth import authenticate
from django.contrib.auth.tokens import default_token_generator
from django.contrib.sites.models import get_current_site
from django.template import Context, loader
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.http import int_to_base36
class UserCreationForm(forms.ModelForm):
"""
A form that creates a user, with no privileges, from the given username and password.
"""
username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^[\w.@+-]+$',
help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
error_messages = {'invalid': _("This value may contain only letters, numbers and @/./+/-/_ characters.")})
password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
password2 = forms.CharField(label=_("Password confirmation"), widget=forms.PasswordInput,
help_text = _("Enter the same password as above, for verification."))
class Meta:
model = User
fields = ("username",)
def clean_username(self):
username = self.cleaned_data["username"]
try:
User.objects.get(username=username)
except User.DoesNotExist:
return username
raise forms.ValidationError(_("A user with that username already exists."))
def clean_password2(self):
password1 = self.cleaned_data.get("password1", "")
password2 = self.cleaned_data["password2"]
if password1 != password2:
raise forms.ValidationError(_("The two password fields didn't match."))
return password2
def save(self, commit=True):
user = super(UserCreationForm, self).save(commit=False)
user.set_password(self.cleaned_data["password1"])
if commit:
user.save()
return user
class UserChangeForm(forms.ModelForm):
username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^[\w.@+-]+$',
help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
error_messages = {'invalid': _("This value may contain only letters, numbers and @/./+/-/_ characters.")})
class Meta:
model = User
def __init__(self, *args, **kwargs):
super(UserChangeForm, self).__init__(*args, **kwargs)
f = self.fields.get('user_permissions', None)
if f is not None:
f.queryset = f.queryset.select_related('content_type')
class AuthenticationForm(forms.Form):
"""
Base class for authenticating users. Extend this to get a form that accepts
username/password logins.
"""
username = forms.CharField(label=_("Username"), max_length=30)
password = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
def __init__(self, request=None, *args, **kwargs):
"""
If request is passed in, the form will validate that cookies are
enabled. Note that the request (a HttpRequest object) must have set a
cookie with the key TEST_COOKIE_NAME and value TEST_COOKIE_VALUE before
running this validation.
"""
self.request = request
self.user_cache = None
super(AuthenticationForm, self).__init__(*args, **kwargs)
def clean(self):
username = self.cleaned_data.get('username')
password = self.cleaned_data.get('password')
if username and password:
self.user_cache = authenticate(username=username, password=password)
if self.user_cache is None:
raise forms.ValidationError(_("Please enter a correct username and password. Note that both fields are case-sensitive."))
elif not self.user_cache.is_active:
raise forms.ValidationError(_("This account is inactive."))
# TODO: determine whether this should move to its own method.
if self.request:
if not self.request.session.test_cookie_worked():
raise forms.ValidationError(_("Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in."))
return self.cleaned_data
def get_user_id(self):
if self.user_cache:
return self.user_cache.id
return None
def get_user(self):
return self.user_cache
class PasswordResetForm(forms.Form):
email = forms.EmailField(label=_("E-mail"), max_length=75)
def clean_email(self):
"""
Validates that a user exists with the given e-mail address.
"""
email = self.cleaned_data["email"]
self.users_cache = User.objects.filter(email__iexact=email)
if len(self.users_cache) == 0:
raise forms.ValidationError(_("That e-mail address doesn't have an associated user account. Are you sure you've registered?"))
return email
def save(self, domain_override=None, email_template_name='registration/password_reset_email.html',
use_https=False, token_generator=default_token_generator, from_email=None, request=None):
"""
Generates a one-use only link for resetting password and sends to the user
"""
from django.core.mail import send_mail
for user in self.users_cache:
if not domain_override:
current_site = get_current_site(request)
site_name = current_site.name
domain = current_site.domain
else:
site_name = domain = domain_override
t = loader.get_template(email_template_name)
c = {
'email': user.email,
'domain': domain,
'site_name': site_name,
'uid': int_to_base36(user.id),
'user': user,
'token': token_generator.make_token(user),
'protocol': use_https and 'https' or 'http',
}
send_mail(_("Password reset on %s") % site_name,
t.render(Context(c)), from_email, [user.email])
class SetPasswordForm(forms.Form):
"""
A form that lets a user change set his/her password without
entering the old password
"""
new_password1 = forms.CharField(label=_("New password"), widget=forms.PasswordInput)
new_password2 = forms.CharField(label=_("New password confirmation"), widget=forms.PasswordInput)
def __init__(self, user, *args, **kwargs):
self.user = user
super(SetPasswordForm, self).__init__(*args, **kwargs)
def clean_new_password2(self):
password1 = self.cleaned_data.get('new_password1')
password2 = self.cleaned_data.get('new_password2')
if password1 and password2:
if password1 != password2:
raise forms.ValidationError(_("The two password fields didn't match."))
return password2
def save(self, commit=True):
self.user.set_password(self.cleaned_data['new_password1'])
if commit:
self.user.save()
return self.user
class PasswordChangeForm(SetPasswordForm):
"""
A form that lets a user change his/her password by entering
their old password.
"""
old_password = forms.CharField(label=_("Old password"), widget=forms.PasswordInput)
def clean_old_password(self):
"""
Validates that the old_password field is correct.
"""
old_password = self.cleaned_data["old_password"]
if not self.user.check_password(old_password):
raise forms.ValidationError(_("Your old password was entered incorrectly. Please enter it again."))
return old_password
PasswordChangeForm.base_fields.keyOrder = ['old_password', 'new_password1', 'new_password2']
class AdminPasswordChangeForm(forms.Form):
"""
A form used to change the password of a user in the admin interface.
"""
password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
password2 = forms.CharField(label=_("Password (again)"), widget=forms.PasswordInput)
def __init__(self, user, *args, **kwargs):
self.user = user
super(AdminPasswordChangeForm, self).__init__(*args, **kwargs)
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if password1 and password2:
if password1 != password2:
raise forms.ValidationError(_("The two password fields didn't match."))
return password2
def save(self, commit=True):
"""
Saves the new password.
"""
self.user.set_password(self.cleaned_data["password1"])
if commit:
self.user.save()
return self.user
| ajibawa-2023/Python-Code-Large/train/row_98598 | 132 | 214 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ImportFrom_L1_C0", "label": "from django.contrib.auth.models import User", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0047, 0.0047, 0, 0.66, 0.0, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ImportFrom_L2_C0", "label": "from django.contrib.auth import authenticate", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0093, 0.0047, 0, 0.66, 0.0667, 895, 0, 1, 0, 0, 895, 0, 0], "semantic": {"name": "django.contrib.auth", "arg_names": [], "import_names": ["authenticate"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth import authenticate"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ImportFrom_L3_C0", "label": "from django.contrib.auth.tokens import default_token_generator", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.014, 0.0047, 0, 0.66, 0.1333, 366, 0, 1, 0, 0, 366, 0, 0], "semantic": {"name": "django.contrib.auth.tokens", "arg_names": [], "import_names": ["default_token_generator"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.tokens import default_token_generator"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ImportFrom_L4_C0", "label": "from django.contrib.sites.models import get_current_site", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0187, 0.0047, 0, 0.66, 0.2, 890, 0, 1, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sites.models", "arg_names": [], "import_names": ["get_current_site"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sites.models import get_current_site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ImportFrom_L5_C0", "label": "from django.template import Context, loader", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0234, 0.0047, 0, 0.66, 0.2667, 213, 0, 2, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["Context", "loader"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import Context, loader"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ImportFrom_L6_C0", "label": "from django import forms", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.028, 0.0047, 0, 0.66, 0.3333, 294, 0, 1, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["forms"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django import forms"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ImportFrom_L7_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0327, 0.0047, 0, 0.66, 0.4, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext_lazy as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ImportFrom_L8_C0", "label": "from django.utils.http import int_to_base36", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0374, 0.0047, 0, 0.66, 0.4667, 516, 0, 1, 0, 0, 516, 0, 0], "semantic": {"name": "django.utils.http", "arg_names": [], "import_names": ["int_to_base36"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.http import int_to_base36"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "label": "UserCreationForm", "type": "class", "loc": [10, 45], "level": 0, "parent": null, "vector": [3, 0, 0.1285, 0.1682, 0, 0.66, 0.5333, 829, 0, 3, 0, 0, 445, 0, 19], "semantic": {"name": "UserCreationForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class UserCreationForm(forms.ModelForm):\n \"\"\"\n A form that creates a user, with no privileges, from the given username and password.\n \"\"\"\n username = forms.RegexField(label=_(\"Username\"), max_length=30, regex=r'^[\\w.@+-]+$',\n help_text = _(\"Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.\"),\n error_messages = {'invalid': _(\"This value may contain only letters, numbers and @/./+/-/_ characters.\")})\n password1 = forms.CharField(label=_(\"Password\"), widget=forms.PasswordInput)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L11_C4", "label": "expression", "type": "expression", "loc": [11, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "vector": [8, 1, 0.0561, 0.014, 1, 0.95, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A form that creates a user, with no privileges, from the given username and password.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L14_C4", "label": "username = RegexField()", "type": "assigned_variable", "loc": [14, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "vector": [14, 1, 0.0701, 0.014, 1, 0.95, 0.1429, 718, 3, 5, 0, 0, 671, 10, 4], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "RegexField", "annotation": ""}, "snippet": " username = forms.RegexField(label=_(\"Username\"), max_length=30, regex=r'^[\\w.@+-]+$',\n help_text = _(\"Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.\"),\n error_messages = {'invalid': _(\"This value may contain only letters, numbers and @/./+/-/_ characters.\")})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L17_C4", "label": "password1 = CharField()", "type": "assigned_variable", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "vector": [14, 1, 0.0794, 0.0047, 1, 0.95, 0.2857, 374, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "password1", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " password1 = forms.CharField(label=_(\"Password\"), widget=forms.PasswordInput)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L18_C4", "label": "password2 = CharField()", "type": "assigned_variable", "loc": [18, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "vector": [14, 1, 0.0864, 0.0093, 1, 0.95, 0.4286, 314, 3, 3, 0, 0, 952, 10, 3], "semantic": {"name": "password2", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " password2 = forms.CharField(label=_(\"Password confirmation\"), widget=forms.PasswordInput,\n help_text = _(\"Enter the same password as above, for verification.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L21_C4", "label": "Meta", "type": "class", "loc": [21, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "vector": [3, 1, 0.1028, 0.014, 1, 0.95, 0.5714, 130, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "Meta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Meta:\n model = User\n fields = (\"username\",)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L22_C8", "label": "model =", "type": "assigned_variable", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L21_C4", "vector": [14, 2, 0.1028, 0.0047, 2, 0.97, 0.0, 722, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model = User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L23_C8", "label": "fields =", "type": "assigned_variable", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L21_C4", "vector": [14, 2, 0.1075, 0.0047, 2, 0.97, 1.0, 358, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fields = (\"username\",)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L25_C4", "label": "clean_username", "type": "function", "loc": [25, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "vector": [2, 1, 0.1308, 0.0327, 1, 0.95, 0.7143, 629, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "clean_username", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clean_username(self):\n username = self.cleaned_data[\"username\"]\n try:\n User.objects.get(username=username)\n except User.DoesNotExist:\n return username\n raise forms.ValidationError(_(\"A user with that username already exists.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L26_C8", "label": "username =", "type": "assigned_variable", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L25_C4", "vector": [14, 2, 0.1215, 0.0047, 2, 0.16, 0.0, 718, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " username = self.cleaned_data[\"username\"]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Try_L27_C8", "label": "try", "type": "try", "loc": [27, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L25_C4", "vector": [7, 2, 0.1332, 0.0187, 2, 0.16, 1.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n User.objects.get(username=username)\n except User.DoesNotExist:\n return username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L28_C12", "label": "get()", "type": "expression", "loc": [28, 28], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:Try_L27_C8", "vector": [8, 3, 0.1308, 0.0047, 3, 0.39, 0.0, 607, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "get", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " User.objects.get(username=username)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L30_C12", "label": "return", "type": "return", "loc": [30, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:Try_L27_C8", "vector": [13, 3, 0.1402, 0.0047, 3, 0.39, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L33_C4", "label": "clean_password2", "type": "function", "loc": [33, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "vector": [2, 1, 0.1659, 0.028, 1, 0.95, 0.8571, 546, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "clean_password2", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clean_password2(self):\n password1 = self.cleaned_data.get(\"password1\", \"\")\n password2 = self.cleaned_data[\"password2\"]\n if password1 != password2:\n raise forms.ValidationError(_(\"The two password fields didn't match.\"))\n return password2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L34_C8", "label": "password1 = get()", "type": "assigned_variable", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L33_C4", "vector": [14, 2, 0.1589, 0.0047, 2, 0.56, 0.0, 374, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "password1", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " password1 = self.cleaned_data.get(\"password1\", \"\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L35_C8", "label": "password2 =", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L33_C4", "vector": [14, 2, 0.1636, 0.0047, 2, 0.56, 0.3333, 314, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "password2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " password2 = self.cleaned_data[\"password2\"]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L36_C8", "label": "if", "type": "if", "loc": [36, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L33_C4", "vector": [4, 2, 0.1706, 0.0093, 2, 0.56, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if password1 != password2:\n raise forms.ValidationError(_(\"The two password fields didn't match.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L38_C8", "label": "return", "type": "return", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L33_C4", "vector": [13, 2, 0.1776, 0.0047, 2, 0.56, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return password2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L40_C4", "label": "save", "type": "function", "loc": [40, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "vector": [2, 1, 0.1986, 0.028, 1, 0.95, 1.0, 928, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "save", "arg_names": ["self", "commit"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save(self, commit=True):\n user = super(UserCreationForm, self).save(commit=False)\n user.set_password(self.cleaned_data[\"password1\"])\n if commit:\n user.save()\n return user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L41_C8", "label": "user = save()", "type": "assigned_variable", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L40_C4", "vector": [14, 2, 0.1916, 0.0047, 2, 0.9, 0.0, 503, 3, 1, 0, 0, 928, 10, 2], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user = super(UserCreationForm, self).save(commit=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L42_C8", "label": "set_password()", "type": "expression", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L40_C4", "vector": [8, 2, 0.1963, 0.0047, 2, 0.9, 0.3333, 803, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "set_password", "arg_names": [], "import_names": [], "rhs_call_name": "set_password", "annotation": ""}, "snippet": " user.set_password(self.cleaned_data[\"password1\"])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L43_C8", "label": "if", "type": "if", "loc": [43, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L40_C4", "vector": [4, 2, 0.2033, 0.0093, 2, 0.9, 0.6667, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if commit:\n user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L44_C12", "label": "save()", "type": "expression", "loc": [44, 44], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L43_C8", "vector": [8, 3, 0.2056, 0.0047, 3, 0.97, 0.0, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L45_C8", "label": "return", "type": "return", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L40_C4", "vector": [13, 2, 0.2103, 0.0047, 2, 0.9, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L47_C0", "label": "UserChangeForm", "type": "class", "loc": [47, 59], "level": 0, "parent": null, "vector": [3, 0, 0.2477, 0.0607, 0, 0.66, 0.6, 456, 0, 1, 0, 0, 445, 0, 8], "semantic": {"name": "UserChangeForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class UserChangeForm(forms.ModelForm):\n username = forms.RegexField(label=_(\"Username\"), max_length=30, regex=r'^[\\w.@+-]+$',\n help_text = _(\"Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.\"),\n error_messages = {'invalid': _(\"This value may contain only letters, numbers and @/./+/-/_ characters.\")})\n\n class Meta:\n model = User\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L48_C4", "label": "username = RegexField()", "type": "assigned_variable", "loc": [48, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L47_C0", "vector": [14, 1, 0.229, 0.014, 1, 0.67, 0.0, 718, 3, 5, 0, 0, 671, 10, 4], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "RegexField", "annotation": ""}, "snippet": " username = forms.RegexField(label=_(\"Username\"), max_length=30, regex=r'^[\\w.@+-]+$',\n help_text = _(\"Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.\"),\n error_messages = {'invalid': _(\"This value may contain only letters, numbers and @/./+/-/_ characters.\")})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L52_C4", "label": "Meta", "type": "class", "loc": [52, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L47_C0", "vector": [3, 1, 0.2453, 0.0093, 1, 0.67, 0.5, 130, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "Meta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Meta:\n model = User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L53_C8", "label": "model =", "type": "assigned_variable", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L52_C4", "vector": [14, 2, 0.2477, 0.0047, 2, 0.13, 0.0, 722, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model = User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L55_C4", "label": "__init__", "type": "function", "loc": [55, 59], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L47_C0", "vector": [2, 1, 0.2664, 0.0234, 1, 0.67, 1.0, 555, 0, 3, 0, 0, 0, 0, 4], "semantic": {"name": "__init__", "arg_names": ["self", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, *args, **kwargs):\n super(UserChangeForm, self).__init__(*args, **kwargs)\n f = self.fields.get('user_permissions', None)\n if f is not None:\n f.queryset = f.queryset.select_related('content_type')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L56_C8", "label": "__init__()", "type": "expression", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L55_C4", "vector": [8, 2, 0.2617, 0.0047, 2, 0.05, 0.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(UserChangeForm, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L57_C8", "label": "f = get()", "type": "assigned_variable", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L55_C4", "vector": [14, 2, 0.2664, 0.0047, 2, 0.05, 0.5, 899, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " f = self.fields.get('user_permissions', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L58_C8", "label": "if", "type": "if", "loc": [58, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L55_C4", "vector": [4, 2, 0.2734, 0.0093, 2, 0.05, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f is not None:\n f.queryset = f.queryset.select_related('content_type')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L59_C12", "label": "f.queryset = select_related()", "type": "assigned_variable", "loc": [59, 59], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L58_C8", "vector": [14, 3, 0.2757, 0.0047, 3, 0.59, 0.0, 277, 3, 1, 0, 0, 595, 10, 1], "semantic": {"name": "f.queryset", "arg_names": [], "import_names": [], "rhs_call_name": "select_related", "annotation": ""}, "snippet": " f.queryset = f.queryset.select_related('content_type')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "label": "AuthenticationForm", "type": "class", "loc": [61, 104], "level": 0, "parent": null, "vector": [3, 0, 0.3855, 0.2056, 0, 0.66, 0.6667, 506, 0, 4, 0, 0, 953, 0, 16], "semantic": {"name": "AuthenticationForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AuthenticationForm(forms.Form):\n \"\"\"\n Base class for authenticating users. Extend this to get a form that accepts\n username/password logins.\n \"\"\"\n username = forms.CharField(label=_(\"Username\"), max_length=30)\n password = forms.CharField(label=_(\"Password\"), widget=forms.PasswordInput)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L62_C4", "label": "expression", "type": "expression", "loc": [62, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "vector": [8, 1, 0.2967, 0.0187, 1, 0.05, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Base class for authenticating users. Extend this to get a form that accepts\n username/password logins.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L66_C4", "label": "username = CharField()", "type": "assigned_variable", "loc": [66, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "vector": [14, 1, 0.3084, 0.0047, 1, 0.05, 0.1667, 718, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " username = forms.CharField(label=_(\"Username\"), max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L67_C4", "label": "password = CharField()", "type": "assigned_variable", "loc": [67, 67], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "vector": [14, 1, 0.3131, 0.0047, 1, 0.05, 0.3333, 489, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "password", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " password = forms.CharField(label=_(\"Password\"), widget=forms.PasswordInput)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L69_C4", "label": "__init__", "type": "function", "loc": [69, 78], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "vector": [2, 1, 0.3435, 0.0467, 1, 0.05, 0.5, 555, 0, 4, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "request", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, request=None, *args, **kwargs):\n \"\"\"\n If request is passed in, the form will validate that cookies are\n enabled. Note that the request (a HttpRequest object) must have set a\n cookie with the key TEST_COOKIE_NAME and value TEST_COOKIE_VALUE before\n running this validation.\n \"\"\"\n self.request = request"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L70_C8", "label": "expression", "type": "expression", "loc": [70, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L69_C4", "vector": [8, 2, 0.3388, 0.028, 2, 0.53, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n If request is passed in, the form will validate that cookies are\n enabled. Note that the request (a HttpRequest object) must have set a\n cookie with the key TEST_COOKIE_NAME and value TEST_COOKIE_VALUE before\n running this validation.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L76_C8", "label": "self.request =", "type": "assigned_variable", "loc": [76, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L69_C4", "vector": [14, 2, 0.3551, 0.0047, 2, 0.53, 0.3333, 952, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.request", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.request = request"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L77_C8", "label": "self.user_cache =", "type": "assigned_variable", "loc": [77, 77], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L69_C4", "vector": [14, 2, 0.3598, 0.0047, 2, 0.53, 0.6667, 742, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "self.user_cache", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.user_cache = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L78_C8", "label": "__init__()", "type": "expression", "loc": [78, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L69_C4", "vector": [8, 2, 0.3645, 0.0047, 2, 0.53, 1.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(AuthenticationForm, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L80_C4", "label": "clean", "type": "function", "loc": [80, 96], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "vector": [2, 1, 0.4112, 0.0794, 1, 0.05, 0.6667, 517, 0, 1, 1, 0, 0, 0, 10], "semantic": {"name": "clean", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clean(self):\n username = self.cleaned_data.get('username')\n password = self.cleaned_data.get('password')\n\n if username and password:\n self.user_cache = authenticate(username=username, password=password)\n if self.user_cache is None:\n raise forms.ValidationError(_(\"Please enter a correct username and password. Note that both fields are case-sensitive.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L81_C8", "label": "username = get()", "type": "assigned_variable", "loc": [81, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L80_C4", "vector": [14, 2, 0.3785, 0.0047, 2, 0.74, 0.0, 718, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " username = self.cleaned_data.get('username')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L82_C8", "label": "password = get()", "type": "assigned_variable", "loc": [82, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L80_C4", "vector": [14, 2, 0.3832, 0.0047, 2, 0.74, 0.25, 489, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "password", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " password = self.cleaned_data.get('password')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L84_C8", "label": "if", "type": "if", "loc": [84, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L80_C4", "vector": [4, 2, 0.4042, 0.028, 2, 0.74, 0.5, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if username and password:\n self.user_cache = authenticate(username=username, password=password)\n if self.user_cache is None:\n raise forms.ValidationError(_(\"Please enter a correct username and password. Note that both fields are case-sensitive.\"))\n elif not self.user_cache.is_active:\n raise forms.ValidationError(_(\"This account is inactive.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L85_C12", "label": "self.user_cache = authenticate()", "type": "assigned_variable", "loc": [85, 85], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L84_C8", "vector": [14, 3, 0.3972, 0.0047, 3, 0.17, 0.0, 742, 3, 2, 0, 0, 751, 10, 1], "semantic": {"name": "self.user_cache", "arg_names": [], "import_names": [], "rhs_call_name": "authenticate", "annotation": ""}, "snippet": " self.user_cache = authenticate(username=username, password=password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L86_C12", "label": "if", "type": "if", "loc": [86, 89], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L84_C8", "vector": [4, 3, 0.4089, 0.0187, 3, 0.17, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.user_cache is None:\n raise forms.ValidationError(_(\"Please enter a correct username and password. Note that both fields are case-sensitive.\"))\n elif not self.user_cache.is_active:\n raise forms.ValidationError(_(\"This account is inactive.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L88_C12", "label": "if", "type": "if", "loc": [88, 89], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L86_C12", "vector": [4, 4, 0.4136, 0.0093, 4, 0.03, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif not self.user_cache.is_active:\n raise forms.ValidationError(_(\"This account is inactive.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L92_C8", "label": "if", "type": "if", "loc": [92, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L80_C4", "vector": [4, 2, 0.4346, 0.014, 2, 0.74, 0.75, 0, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.request:\n if not self.request.session.test_cookie_worked():\n raise forms.ValidationError(_(\"Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L93_C12", "label": "if", "type": "if", "loc": [93, 94], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L92_C8", "vector": [4, 3, 0.4369, 0.0093, 3, 0.32, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.request.session.test_cookie_worked():\n raise forms.ValidationError(_(\"Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L96_C8", "label": "return", "type": "return", "loc": [96, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L80_C4", "vector": [13, 2, 0.4486, 0.0047, 2, 0.74, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.cleaned_data"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L98_C4", "label": "get_user_id", "type": "function", "loc": [98, 101], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "vector": [2, 1, 0.465, 0.0187, 1, 0.05, 0.8333, 102, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "get_user_id", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_user_id(self):\n if self.user_cache:\n return self.user_cache.id\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L99_C8", "label": "if", "type": "if", "loc": [99, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L98_C4", "vector": [4, 2, 0.465, 0.0093, 2, 0.77, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.user_cache:\n return self.user_cache.id"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L100_C12", "label": "return", "type": "return", "loc": [100, 100], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L99_C8", "vector": [13, 3, 0.4673, 0.0047, 3, 0.19, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.user_cache.id"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L101_C8", "label": "return", "type": "return", "loc": [101, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L98_C4", "vector": [13, 2, 0.472, 0.0047, 2, 0.77, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L103_C4", "label": "get_user", "type": "function", "loc": [103, 104], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "vector": [2, 1, 0.4836, 0.0093, 1, 0.05, 1.0, 174, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "get_user", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_user(self):\n return self.user_cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L104_C8", "label": "return", "type": "return", "loc": [104, 104], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L103_C4", "vector": [13, 2, 0.486, 0.0047, 2, 0.66, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.user_cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L106_C0", "label": "PasswordResetForm", "type": "class", "loc": [106, 143], "level": 0, "parent": null, "vector": [3, 0, 0.5818, 0.1776, 0, 0.66, 0.7333, 527, 0, 2, 0, 0, 953, 0, 14], "semantic": {"name": "PasswordResetForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PasswordResetForm(forms.Form):\n email = forms.EmailField(label=_(\"E-mail\"), max_length=75)\n\n def clean_email(self):\n \"\"\"\n Validates that a user exists with the given e-mail address.\n \"\"\"\n email = self.cleaned_data[\"email\"]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L107_C4", "label": "email = EmailField()", "type": "assigned_variable", "loc": [107, 107], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L106_C0", "vector": [14, 1, 0.5, 0.0047, 1, 0.19, 0.0, 413, 3, 2, 0, 0, 767, 10, 2], "semantic": {"name": "email", "arg_names": [], "import_names": [], "rhs_call_name": "EmailField", "annotation": ""}, "snippet": " email = forms.EmailField(label=_(\"E-mail\"), max_length=75)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L109_C4", "label": "clean_email", "type": "function", "loc": [109, 117], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L106_C0", "vector": [2, 1, 0.528, 0.0421, 1, 0.19, 0.5, 160, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "clean_email", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clean_email(self):\n \"\"\"\n Validates that a user exists with the given e-mail address.\n \"\"\"\n email = self.cleaned_data[\"email\"]\n self.users_cache = User.objects.filter(email__iexact=email)\n if len(self.users_cache) == 0:\n raise forms.ValidationError(_(\"That e-mail address doesn't have an associated user account. Are you sure you've registered?\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L110_C8", "label": "expression", "type": "expression", "loc": [110, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L109_C4", "vector": [8, 2, 0.5187, 0.014, 2, 0.02, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Validates that a user exists with the given e-mail address.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L113_C8", "label": "email =", "type": "assigned_variable", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L109_C4", "vector": [14, 2, 0.528, 0.0047, 2, 0.02, 0.25, 413, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "email", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " email = self.cleaned_data[\"email\"]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L114_C8", "label": "self.users_cache = filter()", "type": "assigned_variable", "loc": [114, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L109_C4", "vector": [14, 2, 0.5327, 0.0047, 2, 0.02, 0.5, 247, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "self.users_cache", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " self.users_cache = User.objects.filter(email__iexact=email)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L115_C8", "label": "if", "type": "if", "loc": [115, 116], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L109_C4", "vector": [4, 2, 0.5397, 0.0093, 2, 0.02, 0.75, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(self.users_cache) == 0:\n raise forms.ValidationError(_(\"That e-mail address doesn't have an associated user account. Are you sure you've registered?\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L117_C8", "label": "return", "type": "return", "loc": [117, 117], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L109_C4", "vector": [13, 2, 0.5467, 0.0047, 2, 0.02, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return email"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L119_C4", "label": "save", "type": "function", "loc": [119, 143], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L106_C0", "vector": [2, 1, 0.6121, 0.1168, 1, 0.19, 1.0, 928, 0, 7, 0, 0, 0, 0, 8], "semantic": {"name": "save", "arg_names": ["self", "domain_override", "email_template_name", "use_https", "token_generator", "from_email", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save(self, domain_override=None, email_template_name='registration/password_reset_email.html',\n use_https=False, token_generator=default_token_generator, from_email=None, request=None):\n \"\"\"\n Generates a one-use only link for resetting password and sends to the user\n \"\"\"\n from django.core.mail import send_mail\n for user in self.users_cache:\n if not domain_override:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L121_C8", "label": "expression", "type": "expression", "loc": [121, 123], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L119_C4", "vector": [8, 2, 0.5701, 0.014, 2, 0.01, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Generates a one-use only link for resetting password and sends to the user\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ImportFrom_L124_C8", "label": "from django.core.mail import send_mail", "type": "import", "loc": [124, 124], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L119_C4", "vector": [1, 2, 0.5794, 0.0047, 2, 0.01, 0.5, 537, 0, 1, 0, 0, 537, 0, 0], "semantic": {"name": "django.core.mail", "arg_names": [], "import_names": ["send_mail"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.core.mail import send_mail"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:For_L125_C8", "label": "for user", "type": "for", "loc": [125, 143], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L119_C4", "vector": [6, 2, 0.6262, 0.0888, 2, 0.01, 1.0, 503, 7, 0, 0, 0, 0, 0, 8], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for user in self.users_cache:\n if not domain_override:\n current_site = get_current_site(request)\n site_name = current_site.name\n domain = current_site.domain\n else:\n site_name = domain = domain_override\n t = loader.get_template(email_template_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L126_C12", "label": "if", "type": "if", "loc": [126, 131], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:For_L125_C8", "vector": [4, 3, 0.6005, 0.028, 3, 0.41, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not domain_override:\n current_site = get_current_site(request)\n site_name = current_site.name\n domain = current_site.domain\n else:\n site_name = domain = domain_override"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L127_C16", "label": "current_site = get_current_site()", "type": "assigned_variable", "loc": [127, 127], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L126_C12", "vector": [14, 4, 0.5935, 0.0047, 4, 0.1, 0.0, 725, 3, 1, 0, 0, 760, 10, 1], "semantic": {"name": "current_site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current_site", "annotation": ""}, "snippet": " current_site = get_current_site(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L128_C16", "label": "site_name =", "type": "assigned_variable", "loc": [128, 128], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L126_C12", "vector": [14, 4, 0.5981, 0.0047, 4, 0.1, 0.3333, 588, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "site_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " site_name = current_site.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L129_C16", "label": "domain =", "type": "assigned_variable", "loc": [129, 129], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L126_C12", "vector": [14, 4, 0.6028, 0.0047, 4, 0.1, 0.6667, 438, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "domain", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " domain = current_site.domain"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L131_C16", "label": "site_name =", "type": "assigned_variable", "loc": [131, 131], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L126_C12", "vector": [14, 4, 0.6121, 0.0047, 4, 0.1, 1.0, 588, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "site_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " site_name = domain = domain_override"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L132_C12", "label": "t = get_template()", "type": "assigned_variable", "loc": [132, 132], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:For_L125_C8", "vector": [14, 3, 0.6168, 0.0047, 3, 0.41, 0.3333, 15, 3, 1, 0, 0, 27, 10, 1], "semantic": {"name": "t", "arg_names": [], "import_names": [], "rhs_call_name": "get_template", "annotation": ""}, "snippet": " t = loader.get_template(email_template_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L133_C12", "label": "c =", "type": "assigned_variable", "loc": [133, 141], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:For_L125_C8", "vector": [14, 3, 0.6402, 0.0421, 3, 0.41, 0.6667, 411, 0, 0, 0, 0, 0, 6, 2], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " c = {\n 'email': user.email,\n 'domain': domain,\n 'site_name': site_name,\n 'uid': int_to_base36(user.id),\n 'user': user,\n 'token': token_generator.make_token(user),\n 'protocol': use_https and 'https' or 'http',"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L142_C12", "label": "send_mail()", "type": "expression", "loc": [142, 143], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:For_L125_C8", "vector": [8, 3, 0.6659, 0.0093, 3, 0.41, 1.0, 975, 3, 4, 0, 0, 0, 0, 4], "semantic": {"name": "send_mail", "arg_names": [], "import_names": [], "rhs_call_name": "send_mail", "annotation": ""}, "snippet": " send_mail(_(\"Password reset on %s\") % site_name,\n t.render(Context(c)), from_email, [user.email])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "label": "SetPasswordForm", "type": "class", "loc": [145, 169], "level": 0, "parent": null, "vector": [3, 0, 0.7336, 0.1168, 0, 0.66, 0.8, 828, 0, 3, 0, 0, 953, 0, 12], "semantic": {"name": "SetPasswordForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SetPasswordForm(forms.Form):\n \"\"\"\n A form that lets a user change set his/her password without\n entering the old password\n \"\"\"\n new_password1 = forms.CharField(label=_(\"New password\"), widget=forms.PasswordInput)\n new_password2 = forms.CharField(label=_(\"New password confirmation\"), widget=forms.PasswordInput)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L146_C4", "label": "expression", "type": "expression", "loc": [146, 149], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "vector": [8, 1, 0.6893, 0.0187, 1, 0.04, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A form that lets a user change set his/her password without\n entering the old password\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L150_C4", "label": "new_password1 = CharField()", "type": "assigned_variable", "loc": [150, 150], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "vector": [14, 1, 0.7009, 0.0047, 1, 0.04, 0.2, 226, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "new_password1", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " new_password1 = forms.CharField(label=_(\"New password\"), widget=forms.PasswordInput)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L151_C4", "label": "new_password2 = CharField()", "type": "assigned_variable", "loc": [151, 151], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "vector": [14, 1, 0.7056, 0.0047, 1, 0.04, 0.4, 294, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "new_password2", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " new_password2 = forms.CharField(label=_(\"New password confirmation\"), widget=forms.PasswordInput)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L153_C4", "label": "__init__", "type": "function", "loc": [153, 155], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "vector": [2, 1, 0.7196, 0.014, 1, 0.04, 0.6, 555, 0, 4, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "user", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, user, *args, **kwargs):\n self.user = user\n super(SetPasswordForm, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L154_C8", "label": "self.user =", "type": "assigned_variable", "loc": [154, 154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L153_C4", "vector": [14, 2, 0.7196, 0.0047, 2, 0.45, 0.0, 371, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.user = user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L155_C8", "label": "__init__()", "type": "expression", "loc": [155, 155], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L153_C4", "vector": [8, 2, 0.7243, 0.0047, 2, 0.45, 1.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(SetPasswordForm, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L157_C4", "label": "clean_new_password2", "type": "function", "loc": [157, 163], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "vector": [2, 1, 0.7477, 0.0327, 1, 0.04, 0.8, 528, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "clean_new_password2", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clean_new_password2(self):\n password1 = self.cleaned_data.get('new_password1')\n password2 = self.cleaned_data.get('new_password2')\n if password1 and password2:\n if password1 != password2:\n raise forms.ValidationError(_(\"The two password fields didn't match.\"))\n return password2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L158_C8", "label": "password1 = get()", "type": "assigned_variable", "loc": [158, 158], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L157_C4", "vector": [14, 2, 0.7383, 0.0047, 2, 0.82, 0.0, 374, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "password1", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " password1 = self.cleaned_data.get('new_password1')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L159_C8", "label": "password2 = get()", "type": "assigned_variable", "loc": [159, 159], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L157_C4", "vector": [14, 2, 0.743, 0.0047, 2, 0.82, 0.3333, 314, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "password2", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " password2 = self.cleaned_data.get('new_password2')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L160_C8", "label": "if", "type": "if", "loc": [160, 162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L157_C4", "vector": [4, 2, 0.7523, 0.014, 2, 0.82, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if password1 and password2:\n if password1 != password2:\n raise forms.ValidationError(_(\"The two password fields didn't match.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L161_C12", "label": "if", "type": "if", "loc": [161, 162], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L160_C8", "vector": [4, 3, 0.7547, 0.0093, 3, 0.92, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if password1 != password2:\n raise forms.ValidationError(_(\"The two password fields didn't match.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L163_C8", "label": "return", "type": "return", "loc": [163, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L157_C4", "vector": [13, 2, 0.7617, 0.0047, 2, 0.82, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return password2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L165_C4", "label": "save", "type": "function", "loc": [165, 169], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "vector": [2, 1, 0.7804, 0.0234, 1, 0.04, 1.0, 928, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "save", "arg_names": ["self", "commit"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save(self, commit=True):\n self.user.set_password(self.cleaned_data['new_password1'])\n if commit:\n self.user.save()\n return self.user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L166_C8", "label": "set_password()", "type": "expression", "loc": [166, 166], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L165_C4", "vector": [8, 2, 0.7757, 0.0047, 2, 0.83, 0.0, 803, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "set_password", "arg_names": [], "import_names": [], "rhs_call_name": "set_password", "annotation": ""}, "snippet": " self.user.set_password(self.cleaned_data['new_password1'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L167_C8", "label": "if", "type": "if", "loc": [167, 168], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L165_C4", "vector": [4, 2, 0.7827, 0.0093, 2, 0.83, 0.5, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if commit:\n self.user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L168_C12", "label": "save()", "type": "expression", "loc": [168, 168], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L167_C8", "vector": [8, 3, 0.785, 0.0047, 3, 0.62, 0.0, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " self.user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L169_C8", "label": "return", "type": "return", "loc": [169, 169], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L165_C4", "vector": [13, 2, 0.7897, 0.0047, 2, 0.83, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L171_C0", "label": "PasswordChangeForm", "type": "class", "loc": [171, 185], "level": 0, "parent": null, "vector": [3, 0, 0.8318, 0.0701, 0, 0.66, 0.8667, 810, 0, 1, 0, 0, 828, 0, 5], "semantic": {"name": "PasswordChangeForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PasswordChangeForm(SetPasswordForm):\n \"\"\"\n A form that lets a user change his/her password by entering\n their old password.\n \"\"\"\n old_password = forms.CharField(label=_(\"Old password\"), widget=forms.PasswordInput)\n\n def clean_old_password(self):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L172_C4", "label": "expression", "type": "expression", "loc": [172, 175], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L171_C0", "vector": [8, 1, 0.8107, 0.0187, 1, 0.23, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A form that lets a user change his/her password by entering\n their old password.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L176_C4", "label": "old_password = CharField()", "type": "assigned_variable", "loc": [176, 176], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L171_C0", "vector": [14, 1, 0.8224, 0.0047, 1, 0.23, 0.5, 773, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "old_password", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " old_password = forms.CharField(label=_(\"Old password\"), widget=forms.PasswordInput)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L178_C4", "label": "clean_old_password", "type": "function", "loc": [178, 185], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L171_C0", "vector": [2, 1, 0.8481, 0.0374, 1, 0.23, 1.0, 948, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "clean_old_password", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clean_old_password(self):\n \"\"\"\n Validates that the old_password field is correct.\n \"\"\"\n old_password = self.cleaned_data[\"old_password\"]\n if not self.user.check_password(old_password):\n raise forms.ValidationError(_(\"Your old password was entered incorrectly. Please enter it again.\"))\n return old_password"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L179_C8", "label": "expression", "type": "expression", "loc": [179, 181], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L178_C4", "vector": [8, 2, 0.8411, 0.014, 2, 0.32, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Validates that the old_password field is correct.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L182_C8", "label": "old_password =", "type": "assigned_variable", "loc": [182, 182], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L178_C4", "vector": [14, 2, 0.8505, 0.0047, 2, 0.32, 0.3333, 773, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "old_password", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " old_password = self.cleaned_data[\"old_password\"]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L183_C8", "label": "if", "type": "if", "loc": [183, 184], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L178_C4", "vector": [4, 2, 0.8575, 0.0093, 2, 0.32, 0.6667, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.user.check_password(old_password):\n raise forms.ValidationError(_(\"Your old password was entered incorrectly. Please enter it again.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L185_C8", "label": "return", "type": "return", "loc": [185, 185], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L178_C4", "vector": [13, 2, 0.8645, 0.0047, 2, 0.32, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return old_password"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L186_C0", "label": "PasswordChangeForm.base_fields.keyOrder =", "type": "assigned_variable", "loc": [186, 186], "level": 0, "parent": null, "vector": [14, 0, 0.8692, 0.0047, 0, 0.66, 0.9333, 218, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "PasswordChangeForm.base_fields.keyOrder", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "PasswordChangeForm.base_fields.keyOrder = ['old_password', 'new_password1', 'new_password2']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "label": "AdminPasswordChangeForm", "type": "class", "loc": [188, 214], "level": 0, "parent": null, "vector": [3, 0, 0.9393, 0.1262, 0, 0.66, 1.0, 628, 0, 3, 0, 0, 953, 0, 12], "semantic": {"name": "AdminPasswordChangeForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminPasswordChangeForm(forms.Form):\n \"\"\"\n A form used to change the password of a user in the admin interface.\n \"\"\"\n password1 = forms.CharField(label=_(\"Password\"), widget=forms.PasswordInput)\n password2 = forms.CharField(label=_(\"Password (again)\"), widget=forms.PasswordInput)\n\n def __init__(self, user, *args, **kwargs):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L189_C4", "label": "expression", "type": "expression", "loc": [189, 191], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "vector": [8, 1, 0.8879, 0.014, 1, 0.55, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A form used to change the password of a user in the admin interface.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L192_C4", "label": "password1 = CharField()", "type": "assigned_variable", "loc": [192, 192], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "vector": [14, 1, 0.8972, 0.0047, 1, 0.55, 0.2, 374, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "password1", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " password1 = forms.CharField(label=_(\"Password\"), widget=forms.PasswordInput)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L193_C4", "label": "password2 = CharField()", "type": "assigned_variable", "loc": [193, 193], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "vector": [14, 1, 0.9019, 0.0047, 1, 0.55, 0.4, 314, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "password2", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " password2 = forms.CharField(label=_(\"Password (again)\"), widget=forms.PasswordInput)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L195_C4", "label": "__init__", "type": "function", "loc": [195, 197], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "vector": [2, 1, 0.9159, 0.014, 1, 0.55, 0.6, 555, 0, 4, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "user", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, user, *args, **kwargs):\n self.user = user\n super(AdminPasswordChangeForm, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L196_C8", "label": "self.user =", "type": "assigned_variable", "loc": [196, 196], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L195_C4", "vector": [14, 2, 0.9159, 0.0047, 2, 0.51, 0.0, 371, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.user = user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L197_C8", "label": "__init__()", "type": "expression", "loc": [197, 197], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L195_C4", "vector": [8, 2, 0.9206, 0.0047, 2, 0.51, 1.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(AdminPasswordChangeForm, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L199_C4", "label": "clean_password2", "type": "function", "loc": [199, 205], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "vector": [2, 1, 0.9439, 0.0327, 1, 0.55, 0.8, 546, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "clean_password2", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clean_password2(self):\n password1 = self.cleaned_data.get('password1')\n password2 = self.cleaned_data.get('password2')\n if password1 and password2:\n if password1 != password2:\n raise forms.ValidationError(_(\"The two password fields didn't match.\"))\n return password2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L200_C8", "label": "password1 = get()", "type": "assigned_variable", "loc": [200, 200], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L199_C4", "vector": [14, 2, 0.9346, 0.0047, 2, 0.71, 0.0, 374, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "password1", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " password1 = self.cleaned_data.get('password1')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L201_C8", "label": "password2 = get()", "type": "assigned_variable", "loc": [201, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L199_C4", "vector": [14, 2, 0.9393, 0.0047, 2, 0.71, 0.3333, 314, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "password2", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " password2 = self.cleaned_data.get('password2')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L202_C8", "label": "if", "type": "if", "loc": [202, 204], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L199_C4", "vector": [4, 2, 0.9486, 0.014, 2, 0.71, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if password1 and password2:\n if password1 != password2:\n raise forms.ValidationError(_(\"The two password fields didn't match.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L203_C12", "label": "if", "type": "if", "loc": [203, 204], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L202_C8", "vector": [4, 3, 0.9509, 0.0093, 3, 0.66, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if password1 != password2:\n raise forms.ValidationError(_(\"The two password fields didn't match.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L205_C8", "label": "return", "type": "return", "loc": [205, 205], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L199_C4", "vector": [13, 2, 0.9579, 0.0047, 2, 0.71, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return password2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L207_C4", "label": "save", "type": "function", "loc": [207, 214], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "vector": [2, 1, 0.9836, 0.0374, 1, 0.55, 1.0, 928, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "save", "arg_names": ["self", "commit"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save(self, commit=True):\n \"\"\"\n Saves the new password.\n \"\"\"\n self.user.set_password(self.cleaned_data[\"password1\"])\n if commit:\n self.user.save()\n return self.user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L208_C8", "label": "expression", "type": "expression", "loc": [208, 210], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L207_C4", "vector": [8, 2, 0.9766, 0.014, 2, 0.24, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Saves the new password.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L211_C8", "label": "set_password()", "type": "expression", "loc": [211, 211], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L207_C4", "vector": [8, 2, 0.986, 0.0047, 2, 0.24, 0.3333, 803, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "set_password", "arg_names": [], "import_names": [], "rhs_call_name": "set_password", "annotation": ""}, "snippet": " self.user.set_password(self.cleaned_data[\"password1\"])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L212_C8", "label": "if", "type": "if", "loc": [212, 213], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L207_C4", "vector": [4, 2, 0.993, 0.0093, 2, 0.24, 0.6667, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if commit:\n self.user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L213_C12", "label": "save()", "type": "expression", "loc": [213, 213], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L212_C8", "vector": [8, 3, 0.9953, 0.0047, 3, 0.42, 0.0, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " self.user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L214_C8", "label": "return", "type": "return", "loc": [214, 214], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L207_C4", "vector": [13, 2, 1.0, 0.0047, 2, 0.24, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.user"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Try_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:Try_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:Try_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L43_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L44_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L55_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L55_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L55_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L58_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L59_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L62_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L66_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L80_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L81_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L84_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L85_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L84_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L86_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L86_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L88_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L92_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L92_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L93_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L98_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L98_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L99_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L99_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L100_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L98_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L103_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L103_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L104_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L106_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L107_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L106_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L109_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L115_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L117_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L106_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L119_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L121_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:ImportFrom_L124_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:For_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:For_L125_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L126_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L126_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L127_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L126_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L128_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L126_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L129_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L126_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L131_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:For_L125_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L132_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:For_L125_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L133_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:For_L125_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L142_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L146_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L150_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L151_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L153_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L153_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L153_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L155_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L157_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L157_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L158_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L157_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L159_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L157_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L160_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L160_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L161_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L157_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L165_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L167_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L167_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L168_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L169_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L171_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L172_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L171_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L176_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L171_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L178_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L178_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L179_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L178_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L182_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L178_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L183_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L178_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L185_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L189_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L192_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L193_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L195_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L195_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L195_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L197_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L199_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L200_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Assign_L201_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L202_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L202_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L203_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L205_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:ClassDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L207_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L208_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L211_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L212_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:If_L212_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Expr_L213_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98598:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98598:Return_L214_C8"}] |
from django.core.context_processors import PermWrapper
from django.utils.functional import lazy, memoize, SimpleLazyObject
from django.contrib import messages
def auth(request):
"""
Returns context variables required by apps that use Django's authentication
system.
If there is no 'user' attribute in the request, uses AnonymousUser (from
django.contrib.auth).
"""
# If we access request.user, request.session is accessed, which results in
# 'Vary: Cookie' being sent in every request that uses this context
# processor, which can easily be every request on a site if
# TEMPLATE_CONTEXT_PROCESSORS has this context processor added. This kills
# the ability to cache. So, we carefully ensure these attributes are lazy.
# We don't use django.utils.functional.lazy() for User, because that
# requires knowing the class of the object we want to proxy, which could
# break with custom auth backends. LazyObject is a less complete but more
# flexible solution that is a good enough wrapper for 'User'.
def get_user():
if hasattr(request, 'user'):
return request.user
else:
from django.contrib.auth.models import AnonymousUser
return AnonymousUser()
return {
'user': SimpleLazyObject(get_user),
'messages': messages.get_messages(request),
'perms': lazy(lambda: PermWrapper(get_user()), PermWrapper)(),
}
| ajibawa-2023/Python-Code-Large/train/row_98599 | 11 | 33 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98599:ImportFrom_L1_C0", "label": "from django.core.context_processors import PermWrapper", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0303, 0.0303, 0, 0.66, 0.0, 55, 0, 1, 0, 0, 55, 0, 0], "semantic": {"name": "django.core.context_processors", "arg_names": [], "import_names": ["PermWrapper"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.context_processors import PermWrapper"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98599:ImportFrom_L2_C0", "label": "from django.utils.functional import lazy, memoize, SimpleLazyObject", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0606, 0.0303, 0, 0.66, 0.3333, 375, 0, 3, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.functional", "arg_names": [], "import_names": ["lazy", "memoize", "SimpleLazyObject"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.functional import lazy, memoize, SimpleLazyObject"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98599:ImportFrom_L3_C0", "label": "from django.contrib import messages", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0909, 0.0303, 0, 0.66, 0.6667, 302, 0, 1, 0, 0, 302, 0, 0], "semantic": {"name": "django.contrib", "arg_names": [], "import_names": ["messages"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib import messages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98599:FunctionDef_L5_C0", "label": "auth", "type": "function", "loc": [5, 33], "level": 0, "parent": null, "vector": [2, 0, 0.5758, 0.8788, 0, 0.66, 1.0, 280, 0, 1, 1, 0, 0, 0, 8], "semantic": {"name": "auth", "arg_names": ["request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def auth(request):\n \"\"\"\n Returns context variables required by apps that use Django's authentication\n system.\n\n If there is no 'user' attribute in the request, uses AnonymousUser (from\n django.contrib.auth).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98599:Expr_L6_C4", "label": "expression", "type": "expression", "loc": [6, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98599:FunctionDef_L5_C0", "vector": [8, 1, 0.2727, 0.2121, 1, 0.4, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns context variables required by apps that use Django's authentication\n system.\n\n If there is no 'user' attribute in the request, uses AnonymousUser (from\n django.contrib.auth).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98599:FunctionDef_L22_C4", "label": "get_user", "type": "function", "loc": [22, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98599:FunctionDef_L5_C0", "vector": [2, 1, 0.7424, 0.1818, 1, 0.4, 0.5, 174, 0, 0, 1, 0, 0, 0, 2], "semantic": {"name": "get_user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_user():\n if hasattr(request, 'user'):\n return request.user\n else:\n from django.contrib.auth.models import AnonymousUser\n return AnonymousUser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98599:If_L23_C8", "label": "if", "type": "if", "loc": [23, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98599:FunctionDef_L22_C4", "vector": [4, 2, 0.7576, 0.1515, 2, 0.19, 0.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(request, 'user'):\n return request.user\n else:\n from django.contrib.auth.models import AnonymousUser\n return AnonymousUser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98599:Return_L24_C12", "label": "return", "type": "return", "loc": [24, 24], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98599:If_L23_C8", "vector": [13, 3, 0.7273, 0.0303, 3, 0.75, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return request.user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98599:ImportFrom_L26_C12", "label": "from django.contrib.auth.models import AnonymousUser", "type": "import", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98599:If_L23_C8", "vector": [1, 3, 0.7879, 0.0303, 3, 0.75, 0.5, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["AnonymousUser"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.auth.models import AnonymousUser"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98599:Return_L27_C12", "label": "return", "type": "return", "loc": [27, 27], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98599:If_L23_C8", "vector": [13, 3, 0.8182, 0.0303, 3, 0.75, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return AnonymousUser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98599:Return_L29_C4", "label": "return", "type": "return", "loc": [29, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98599:FunctionDef_L5_C0", "vector": [13, 1, 0.9394, 0.1515, 1, 0.4, 1.0, 0, 0, 0, 0, 0, 0, 6, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {\n 'user': SimpleLazyObject(get_user),\n 'messages': messages.get_messages(request),\n 'perms': lazy(lambda: PermWrapper(get_user()), PermWrapper)(),\n }"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98599:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98599:Expr_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98599:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98599:FunctionDef_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98599:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98599:If_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98599:If_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98599:Return_L24_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98599:If_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98599:ImportFrom_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98599:If_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98599:Return_L27_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98599:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98599:Return_L29_C4"}] |
from django.db import connection
from django.contrib.auth.models import User, Permission
class ModelBackend(object):
"""
Authenticates against django.contrib.auth.models.User.
"""
supports_object_permissions = False
supports_anonymous_user = True
# TODO: Model, login attribute name and password attribute name should be
# configurable.
def authenticate(self, username=None, password=None):
try:
user = User.objects.get(username=username)
if user.check_password(password):
return user
except User.DoesNotExist:
return None
def get_group_permissions(self, user_obj):
"""
Returns a set of permission strings that this user has through his/her
groups.
"""
if not hasattr(user_obj, '_group_perm_cache'):
perms = Permission.objects.filter(group__user=user_obj
).values_list('content_type__app_label', 'codename'
).order_by()
user_obj._group_perm_cache = set(["%s.%s" % (ct, name) for ct, name in perms])
return user_obj._group_perm_cache
def get_all_permissions(self, user_obj):
if user_obj.is_anonymous():
return set()
if not hasattr(user_obj, '_perm_cache'):
user_obj._perm_cache = set([u"%s.%s" % (p.content_type.app_label, p.codename) for p in user_obj.user_permissions.select_related()])
user_obj._perm_cache.update(self.get_group_permissions(user_obj))
return user_obj._perm_cache
def has_perm(self, user_obj, perm):
return perm in self.get_all_permissions(user_obj)
def has_module_perms(self, user_obj, app_label):
"""
Returns True if user_obj has any permissions in the given app_label.
"""
for perm in self.get_all_permissions(user_obj):
if perm[:perm.index('.')] == app_label:
return True
return False
def get_user(self, user_id):
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None
class RemoteUserBackend(ModelBackend):
"""
This backend is to be used in conjunction with the ``RemoteUserMiddleware``
found in the middleware module of this package, and is used when the server
is handling authentication outside of Django.
By default, the ``authenticate`` method creates ``User`` objects for
usernames that don't already exist in the database. Subclasses can disable
this behavior by setting the ``create_unknown_user`` attribute to
``False``.
"""
# Create a User object if not already in the database?
create_unknown_user = True
def authenticate(self, remote_user):
"""
The username passed as ``remote_user`` is considered trusted. This
method simply returns the ``User`` object with the given username,
creating a new ``User`` object if ``create_unknown_user`` is ``True``.
Returns None if ``create_unknown_user`` is ``False`` and a ``User``
object with the given username is not found in the database.
"""
if not remote_user:
return
user = None
username = self.clean_username(remote_user)
# Note that this could be accomplished in one try-except clause, but
# instead we use get_or_create when creating unknown users since it has
# built-in safeguards for multiple threads.
if self.create_unknown_user:
user, created = User.objects.get_or_create(username=username)
if created:
user = self.configure_user(user)
else:
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
pass
return user
def clean_username(self, username):
"""
Performs any cleaning on the "username" prior to using it to get or
create the user object. Returns the cleaned username.
By default, returns the username unchanged.
"""
return username
def configure_user(self, user):
"""
Configures a user after creation and returns the updated user.
By default, returns the user unmodified.
"""
return user
| ajibawa-2023/Python-Code-Large/train/row_98600 | 59 | 119 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98600:ImportFrom_L1_C0", "label": "from django.db import connection", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0084, 0.0084, 0, 0.66, 0.0, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["connection"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import connection"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:ImportFrom_L2_C0", "label": "from django.contrib.auth.models import User, Permission", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0168, 0.0084, 0, 0.66, 0.3333, 808, 0, 2, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User", "Permission"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User, Permission"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "label": "ModelBackend", "type": "class", "loc": [5, 58], "level": 0, "parent": null, "vector": [3, 0, 0.2647, 0.4538, 0, 0.66, 0.6667, 392, 0, 6, 0, 0, 186, 0, 18], "semantic": {"name": "ModelBackend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ModelBackend(object):\n \"\"\"\n Authenticates against django.contrib.auth.models.User.\n \"\"\"\n supports_object_permissions = False\n supports_anonymous_user = True\n\n # TODO: Model, login attribute name and password attribute name should be"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L6_C4", "label": "expression", "type": "expression", "loc": [6, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "vector": [8, 1, 0.0588, 0.0252, 1, 0.61, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Authenticates against django.contrib.auth.models.User.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L9_C4", "label": "supports_object_permissions =", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "vector": [14, 1, 0.0756, 0.0084, 1, 0.61, 0.125, 767, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "supports_object_permissions", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " supports_object_permissions = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L10_C4", "label": "supports_anonymous_user =", "type": "assigned_variable", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "vector": [14, 1, 0.084, 0.0084, 1, 0.61, 0.25, 50, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "supports_anonymous_user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " supports_anonymous_user = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L14_C4", "label": "authenticate", "type": "function", "loc": [14, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "vector": [2, 1, 0.1429, 0.0588, 1, 0.61, 0.375, 751, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "authenticate", "arg_names": ["self", "username", "password"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def authenticate(self, username=None, password=None):\n try:\n user = User.objects.get(username=username)\n if user.check_password(password):\n return user\n except User.DoesNotExist:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L15_C8", "label": "try", "type": "try", "loc": [15, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L14_C4", "vector": [7, 2, 0.1471, 0.0504, 2, 0.1, 0.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n user = User.objects.get(username=username)\n if user.check_password(password):\n return user\n except User.DoesNotExist:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L16_C12", "label": "user = get()", "type": "assigned_variable", "loc": [16, 16], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L15_C8", "vector": [14, 3, 0.1345, 0.0084, 3, 0.84, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username=username)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L17_C12", "label": "if", "type": "if", "loc": [17, 18], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L15_C8", "vector": [4, 3, 0.1471, 0.0168, 3, 0.84, 1.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user.check_password(password):\n return user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L18_C16", "label": "return", "type": "return", "loc": [18, 18], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L17_C12", "vector": [13, 4, 0.1513, 0.0084, 4, 0.74, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L20_C12", "label": "return", "type": "return", "loc": [20, 20], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L15_C8", "vector": [13, 3, 0.1681, 0.0084, 3, 0.84, 0.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L22_C4", "label": "get_group_permissions", "type": "function", "loc": [22, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "vector": [2, 1, 0.2269, 0.0924, 1, 0.61, 0.5, 228, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "get_group_permissions", "arg_names": ["self", "user_obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_group_permissions(self, user_obj):\n \"\"\"\n Returns a set of permission strings that this user has through his/her\n groups.\n \"\"\"\n if not hasattr(user_obj, '_group_perm_cache'):\n perms = Permission.objects.filter(group__user=user_obj\n ).values_list('content_type__app_label', 'codename'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L23_C8", "label": "expression", "type": "expression", "loc": [23, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L22_C4", "vector": [8, 2, 0.2059, 0.0336, 2, 0.88, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a set of permission strings that this user has through his/her\n groups.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L27_C8", "label": "if", "type": "if", "loc": [27, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L22_C4", "vector": [4, 2, 0.2437, 0.042, 2, 0.88, 0.5, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(user_obj, '_group_perm_cache'):\n perms = Permission.objects.filter(group__user=user_obj\n ).values_list('content_type__app_label', 'codename'\n ).order_by()\n user_obj._group_perm_cache = set([\"%s.%s\" % (ct, name) for ct, name in perms])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L28_C12", "label": "perms = order_by()", "type": "assigned_variable", "loc": [28, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L27_C8", "vector": [14, 3, 0.2437, 0.0252, 3, 0.42, 0.0, 840, 3, 0, 0, 0, 23, 10, 3], "semantic": {"name": "perms", "arg_names": [], "import_names": [], "rhs_call_name": "order_by", "annotation": ""}, "snippet": " perms = Permission.objects.filter(group__user=user_obj\n ).values_list('content_type__app_label', 'codename'\n ).order_by()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L31_C12", "label": "user_obj._group_perm_cache = set()", "type": "assigned_variable", "loc": [31, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L27_C8", "vector": [14, 3, 0.2605, 0.0084, 3, 0.42, 1.0, 504, 3, 1, 0, 0, 21, 10, 1], "semantic": {"name": "user_obj._group_perm_cache", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " user_obj._group_perm_cache = set([\"%s.%s\" % (ct, name) for ct, name in perms])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L32_C8", "label": "return", "type": "return", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L22_C4", "vector": [13, 2, 0.2689, 0.0084, 2, 0.88, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return user_obj._group_perm_cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L34_C4", "label": "get_all_permissions", "type": "function", "loc": [34, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "vector": [2, 1, 0.3109, 0.0588, 1, 0.61, 0.625, 669, 0, 2, 1, 0, 0, 0, 7], "semantic": {"name": "get_all_permissions", "arg_names": ["self", "user_obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_all_permissions(self, user_obj):\n if user_obj.is_anonymous():\n return set()\n if not hasattr(user_obj, '_perm_cache'):\n user_obj._perm_cache = set([u\"%s.%s\" % (p.content_type.app_label, p.codename) for p in user_obj.user_permissions.select_related()])\n user_obj._perm_cache.update(self.get_group_permissions(user_obj))\n return user_obj._perm_cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L35_C8", "label": "if", "type": "if", "loc": [35, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L34_C4", "vector": [4, 2, 0.2983, 0.0168, 2, 0.44, 0.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user_obj.is_anonymous():\n return set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L36_C12", "label": "return", "type": "return", "loc": [36, 36], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L35_C8", "vector": [13, 3, 0.3025, 0.0084, 3, 0.49, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L37_C8", "label": "if", "type": "if", "loc": [37, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L34_C4", "vector": [4, 2, 0.3193, 0.0252, 2, 0.44, 0.5, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(user_obj, '_perm_cache'):\n user_obj._perm_cache = set([u\"%s.%s\" % (p.content_type.app_label, p.codename) for p in user_obj.user_permissions.select_related()])\n user_obj._perm_cache.update(self.get_group_permissions(user_obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L38_C12", "label": "user_obj._perm_cache = set()", "type": "assigned_variable", "loc": [38, 38], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L37_C8", "vector": [14, 3, 0.3193, 0.0084, 3, 0.23, 0.0, 726, 3, 1, 0, 0, 21, 10, 2], "semantic": {"name": "user_obj._perm_cache", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " user_obj._perm_cache = set([u\"%s.%s\" % (p.content_type.app_label, p.codename) for p in user_obj.user_permissions.select_related()])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L39_C12", "label": "update()", "type": "expression", "loc": [39, 39], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L37_C8", "vector": [8, 3, 0.3277, 0.0084, 3, 0.23, 1.0, 637, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " user_obj._perm_cache.update(self.get_group_permissions(user_obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L40_C8", "label": "return", "type": "return", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L34_C4", "vector": [13, 2, 0.3361, 0.0084, 2, 0.44, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return user_obj._perm_cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L42_C4", "label": "has_perm", "type": "function", "loc": [42, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "vector": [2, 1, 0.3571, 0.0168, 1, 0.61, 0.75, 674, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "has_perm", "arg_names": ["self", "user_obj", "perm"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_perm(self, user_obj, perm):\n return perm in self.get_all_permissions(user_obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L43_C8", "label": "return", "type": "return", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L42_C4", "vector": [13, 2, 0.3613, 0.0084, 2, 0.91, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return perm in self.get_all_permissions(user_obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L45_C4", "label": "has_module_perms", "type": "function", "loc": [45, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "vector": [2, 1, 0.4076, 0.0672, 1, 0.61, 0.875, 249, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "has_module_perms", "arg_names": ["self", "user_obj", "app_label"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_module_perms(self, user_obj, app_label):\n \"\"\"\n Returns True if user_obj has any permissions in the given app_label.\n \"\"\"\n for perm in self.get_all_permissions(user_obj):\n if perm[:perm.index('.')] == app_label:\n return True\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L46_C8", "label": "expression", "type": "expression", "loc": [46, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L45_C4", "vector": [8, 2, 0.395, 0.0252, 2, 0.42, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns True if user_obj has any permissions in the given app_label.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:For_L49_C8", "label": "for perm", "type": "for", "loc": [49, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L45_C4", "vector": [6, 2, 0.4202, 0.0252, 2, 0.42, 0.5, 339, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "perm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for perm in self.get_all_permissions(user_obj):\n if perm[:perm.index('.')] == app_label:\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L50_C12", "label": "if", "type": "if", "loc": [50, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:For_L49_C8", "vector": [4, 3, 0.4244, 0.0168, 3, 0.26, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if perm[:perm.index('.')] == app_label:\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L51_C16", "label": "return", "type": "return", "loc": [51, 51], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L50_C12", "vector": [13, 4, 0.4286, 0.0084, 4, 0.87, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L52_C8", "label": "return", "type": "return", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L45_C4", "vector": [13, 2, 0.437, 0.0084, 2, 0.42, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L54_C4", "label": "get_user", "type": "function", "loc": [54, 58], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "vector": [2, 1, 0.4706, 0.042, 1, 0.61, 1.0, 174, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "get_user", "arg_names": ["self", "user_id"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_user(self, user_id):\n try:\n return User.objects.get(pk=user_id)\n except User.DoesNotExist:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L55_C8", "label": "try", "type": "try", "loc": [55, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L54_C4", "vector": [7, 2, 0.4748, 0.0336, 2, 0.22, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n return User.objects.get(pk=user_id)\n except User.DoesNotExist:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L56_C12", "label": "return", "type": "return", "loc": [56, 56], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L55_C8", "vector": [13, 3, 0.4706, 0.0084, 3, 0.94, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return User.objects.get(pk=user_id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L58_C12", "label": "return", "type": "return", "loc": [58, 58], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L55_C8", "vector": [13, 3, 0.4874, 0.0084, 3, 0.94, 0.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L61_C0", "label": "RemoteUserBackend", "type": "class", "loc": [61, 119], "level": 0, "parent": null, "vector": [3, 0, 0.7563, 0.4958, 0, 0.66, 1.0, 519, 0, 3, 0, 0, 392, 0, 4], "semantic": {"name": "RemoteUserBackend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RemoteUserBackend(ModelBackend):\n \"\"\"\n This backend is to be used in conjunction with the ``RemoteUserMiddleware``\n found in the middleware module of this package, and is used when the server\n is handling authentication outside of Django.\n\n By default, the ``authenticate`` method creates ``User`` objects for\n usernames that don't already exist in the database. Subclasses can disable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L62_C4", "label": "expression", "type": "expression", "loc": [62, 71], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L61_C0", "vector": [8, 1, 0.5588, 0.084, 1, 0.14, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This backend is to be used in conjunction with the ``RemoteUserMiddleware``\n found in the middleware module of this package, and is used when the server\n is handling authentication outside of Django.\n\n By default, the ``authenticate`` method creates ``User`` objects for\n usernames that don't already exist in the database. Subclasses can disable\n this behavior by setting the ``create_unknown_user`` attribute to"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L74_C4", "label": "create_unknown_user =", "type": "assigned_variable", "loc": [74, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L61_C0", "vector": [14, 1, 0.6218, 0.0084, 1, 0.14, 0.25, 497, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "create_unknown_user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " create_unknown_user = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "label": "authenticate", "type": "function", "loc": [76, 102], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L61_C0", "vector": [2, 1, 0.7479, 0.2269, 1, 0.14, 0.5, 751, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "authenticate", "arg_names": ["self", "remote_user"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def authenticate(self, remote_user):\n \"\"\"\n The username passed as ``remote_user`` is considered trusted. This\n method simply returns the ``User`` object with the given username,\n creating a new ``User`` object if ``create_unknown_user`` is ``True``.\n\n Returns None if ``create_unknown_user`` is ``False`` and a ``User``\n object with the given username is not found in the database."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L77_C8", "label": "expression", "type": "expression", "loc": [77, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "vector": [8, 2, 0.6765, 0.0672, 2, 0.97, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n The username passed as ``remote_user`` is considered trusted. This\n method simply returns the ``User`` object with the given username,\n creating a new ``User`` object if ``create_unknown_user`` is ``True``.\n\n Returns None if ``create_unknown_user`` is ``False`` and a ``User``\n object with the given username is not found in the database.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L85_C8", "label": "if", "type": "if", "loc": [85, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "vector": [4, 2, 0.7185, 0.0168, 2, 0.97, 0.2, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not remote_user:\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L86_C12", "label": "return", "type": "return", "loc": [86, 86], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L85_C8", "vector": [13, 3, 0.7227, 0.0084, 3, 0.86, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L87_C8", "label": "user =", "type": "assigned_variable", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "vector": [14, 2, 0.7311, 0.0084, 2, 0.97, 0.4, 503, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L88_C8", "label": "username = clean_username()", "type": "assigned_variable", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "vector": [14, 2, 0.7395, 0.0084, 2, 0.97, 0.6, 718, 3, 1, 0, 0, 629, 10, 1], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "clean_username", "annotation": ""}, "snippet": " username = self.clean_username(remote_user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L93_C8", "label": "if", "type": "if", "loc": [93, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "vector": [4, 2, 0.8151, 0.0756, 2, 0.97, 0.8, 0, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.create_unknown_user:\n user, created = User.objects.get_or_create(username=username)\n if created:\n user = self.configure_user(user)\n else:\n try:\n user = User.objects.get(username=username)\n except User.DoesNotExist:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L94_C12", "label": "user, created = get_or_create()", "type": "assigned_variable", "loc": [94, 94], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L93_C8", "vector": [14, 3, 0.7899, 0.0084, 3, 0.25, 0.0, 760, 3, 1, 0, 0, 204, 10, 1], "semantic": {"name": "user, created", "arg_names": [], "import_names": [], "rhs_call_name": "get_or_create", "annotation": ""}, "snippet": " user, created = User.objects.get_or_create(username=username)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L95_C12", "label": "if", "type": "if", "loc": [95, 96], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L93_C8", "vector": [4, 3, 0.8025, 0.0168, 3, 0.25, 0.5, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if created:\n user = self.configure_user(user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L96_C16", "label": "user = configure_user()", "type": "assigned_variable", "loc": [96, 96], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L95_C12", "vector": [14, 4, 0.8067, 0.0084, 4, 0.3, 0.0, 503, 3, 1, 0, 0, 548, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "configure_user", "annotation": ""}, "snippet": " user = self.configure_user(user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L98_C12", "label": "try", "type": "try", "loc": [98, 101], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L93_C8", "vector": [7, 3, 0.8361, 0.0336, 3, 0.25, 1.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n user = User.objects.get(username=username)\n except User.DoesNotExist:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L99_C16", "label": "user = get()", "type": "assigned_variable", "loc": [99, 99], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L98_C12", "vector": [14, 4, 0.8319, 0.0084, 4, 0.44, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username=username)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L102_C8", "label": "return", "type": "return", "loc": [102, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "vector": [13, 2, 0.8571, 0.0084, 2, 0.97, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L104_C4", "label": "clean_username", "type": "function", "loc": [104, 111], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L61_C0", "vector": [2, 1, 0.9034, 0.0672, 1, 0.14, 0.75, 629, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "clean_username", "arg_names": ["self", "username"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clean_username(self, username):\n \"\"\"\n Performs any cleaning on the \"username\" prior to using it to get or\n create the user object. Returns the cleaned username.\n\n By default, returns the username unchanged.\n \"\"\"\n return username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L105_C8", "label": "expression", "type": "expression", "loc": [105, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L104_C4", "vector": [8, 2, 0.9034, 0.0504, 2, 0.67, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Performs any cleaning on the \"username\" prior to using it to get or\n create the user object. Returns the cleaned username.\n\n By default, returns the username unchanged.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L111_C8", "label": "return", "type": "return", "loc": [111, 111], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L104_C4", "vector": [13, 2, 0.9328, 0.0084, 2, 0.67, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L113_C4", "label": "configure_user", "type": "function", "loc": [113, 119], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L61_C0", "vector": [2, 1, 0.9748, 0.0588, 1, 0.14, 1.0, 548, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "configure_user", "arg_names": ["self", "user"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def configure_user(self, user):\n \"\"\"\n Configures a user after creation and returns the updated user.\n\n By default, returns the user unmodified.\n \"\"\"\n return user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L114_C8", "label": "expression", "type": "expression", "loc": [114, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L113_C4", "vector": [8, 2, 0.9748, 0.042, 2, 0.39, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Configures a user after creation and returns the updated user.\n\n By default, returns the user unmodified.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L119_C8", "label": "return", "type": "return", "loc": [119, 119], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L113_C4", "vector": [13, 2, 1.0, 0.0084, 2, 0.39, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return user"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L15_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L16_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L15_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L17_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L17_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L18_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L15_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L20_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L31_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L35_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L36_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L38_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L39_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:For_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:For_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L50_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L51_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L56_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L58_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L62_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L74_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L85_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L86_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L93_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L93_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L94_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L93_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L95_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L95_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L96_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:If_L93_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L98_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:Try_L98_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Assign_L99_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L102_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L104_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L105_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L111_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:ClassDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L113_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L113_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Expr_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98600:FunctionDef_L113_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98600:Return_L119_C8"}] |
import datetime
import urllib
from django.contrib import auth
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.db.models.manager import EmptyManager
from django.contrib.contenttypes.models import ContentType
from django.utils.encoding import smart_str
from django.utils.hashcompat import md5_constructor, sha_constructor
from django.utils.translation import ugettext_lazy as _
UNUSABLE_PASSWORD = '!' # This will never be a valid hash
def get_hexdigest(algorithm, salt, raw_password):
"""
Returns a string of the hexdigest of the given plaintext password and salt
using the given algorithm ('md5', 'sha1' or 'crypt').
"""
raw_password, salt = smart_str(raw_password), smart_str(salt)
if algorithm == 'crypt':
try:
import crypt
except ImportError:
raise ValueError('"crypt" password algorithm not supported in this environment')
return crypt.crypt(raw_password, salt)
if algorithm == 'md5':
return md5_constructor(salt + raw_password).hexdigest()
elif algorithm == 'sha1':
return sha_constructor(salt + raw_password).hexdigest()
raise ValueError("Got unknown password algorithm type in password.")
def check_password(raw_password, enc_password):
"""
Returns a boolean of whether the raw_password was correct. Handles
encryption formats behind the scenes.
"""
algo, salt, hsh = enc_password.split('$')
return hsh == get_hexdigest(algo, salt, raw_password)
class SiteProfileNotAvailable(Exception):
pass
class PermissionManager(models.Manager):
def get_by_natural_key(self, codename, app_label, model):
return self.get(
codename=codename,
content_type=ContentType.objects.get_by_natural_key(app_label, model)
)
class Permission(models.Model):
"""The permissions system provides a way to assign permissions to specific users and groups of users.
The permission system is used by the Django admin site, but may also be useful in your own code. The Django admin site uses permissions as follows:
- The "add" permission limits the user's ability to view the "add" form and add an object.
- The "change" permission limits a user's ability to view the change list, view the "change" form and change an object.
- The "delete" permission limits the ability to delete an object.
Permissions are set globally per type of object, not per specific object instance. It is possible to say "Mary may change news stories," but it's not currently possible to say "Mary may change news stories, but only the ones she created herself" or "Mary may only change news stories that have a certain status or publication date."
Three basic permissions -- add, change and delete -- are automatically created for each Django model.
"""
name = models.CharField(_('name'), max_length=50)
content_type = models.ForeignKey(ContentType)
codename = models.CharField(_('codename'), max_length=100)
objects = PermissionManager()
class Meta:
verbose_name = _('permission')
verbose_name_plural = _('permissions')
unique_together = (('content_type', 'codename'),)
ordering = ('codename',)
def __unicode__(self):
return u"%s | %s | %s" % (
unicode(self.content_type.app_label),
unicode(self.content_type),
unicode(self.name))
def natural_key(self):
return (self.codename,) + self.content_type.natural_key()
natural_key.dependencies = ['contenttypes.contenttype']
class Group(models.Model):
"""Groups are a generic way of categorizing users to apply permissions, or some other label, to those users. A user can belong to any number of groups.
A user in a group automatically has all the permissions granted to that group. For example, if the group Site editors has the permission can_edit_home_page, any user in that group will have that permission.
Beyond permissions, groups are a convenient way to categorize users to apply some label, or extended functionality, to them. For example, you could create a group 'Special users', and you could write code that would do special things to those users -- such as giving them access to a members-only portion of your site, or sending them members-only e-mail messages.
"""
name = models.CharField(_('name'), max_length=80, unique=True)
permissions = models.ManyToManyField(Permission, verbose_name=_('permissions'), blank=True)
class Meta:
verbose_name = _('group')
verbose_name_plural = _('groups')
def __unicode__(self):
return self.name
class UserManager(models.Manager):
def create_user(self, username, email, password=None):
"""
Creates and saves a User with the given username, e-mail and password.
"""
now = datetime.datetime.now()
# Normalize the address by lowercasing the domain part of the email
# address.
try:
email_name, domain_part = email.strip().split('@', 1)
except ValueError:
pass
else:
email = '@'.join([email_name, domain_part.lower()])
user = self.model(username=username, email=email, is_staff=False,
is_active=True, is_superuser=False, last_login=now,
date_joined=now)
user.set_password(password)
user.save(using=self._db)
return user
def create_superuser(self, username, email, password):
u = self.create_user(username, email, password)
u.is_staff = True
u.is_active = True
u.is_superuser = True
u.save(using=self._db)
return u
def make_random_password(self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'):
"Generates a random password with the given length and given allowed_chars"
# Note that default value of allowed_chars does not have "I" or letters
# that look like it -- just to avoid confusion.
from random import choice
return ''.join([choice(allowed_chars) for i in range(length)])
# A few helper functions for common logic between User and AnonymousUser.
def _user_get_all_permissions(user, obj):
permissions = set()
anon = user.is_anonymous()
for backend in auth.get_backends():
if not anon or backend.supports_anonymous_user:
if hasattr(backend, "get_all_permissions"):
if obj is not None:
if backend.supports_object_permissions:
permissions.update(
backend.get_all_permissions(user, obj)
)
else:
permissions.update(backend.get_all_permissions(user))
return permissions
def _user_has_perm(user, perm, obj):
anon = user.is_anonymous()
for backend in auth.get_backends():
if not anon or backend.supports_anonymous_user:
if hasattr(backend, "has_perm"):
if obj is not None:
if (backend.supports_object_permissions and
backend.has_perm(user, perm, obj)):
return True
else:
if backend.has_perm(user, perm):
return True
return False
def _user_has_module_perms(user, app_label):
anon = user.is_anonymous()
for backend in auth.get_backends():
if not anon or backend.supports_anonymous_user:
if hasattr(backend, "has_module_perms"):
if backend.has_module_perms(user, app_label):
return True
return False
class User(models.Model):
"""
Users within the Django authentication system are represented by this model.
Username and password are required. Other fields are optional.
"""
username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters"))
first_name = models.CharField(_('first name'), max_length=30, blank=True)
last_name = models.CharField(_('last name'), max_length=30, blank=True)
email = models.EmailField(_('e-mail address'), blank=True)
password = models.CharField(_('password'), max_length=128, help_text=_("Use '[algo]$[salt]$[hexdigest]' or use the <a href=\"password/\">change password form</a>."))
is_staff = models.BooleanField(_('staff status'), default=False, help_text=_("Designates whether the user can log into this admin site."))
is_active = models.BooleanField(_('active'), default=True, help_text=_("Designates whether this user should be treated as active. Unselect this instead of deleting accounts."))
is_superuser = models.BooleanField(_('superuser status'), default=False, help_text=_("Designates that this user has all permissions without explicitly assigning them."))
last_login = models.DateTimeField(_('last login'), default=datetime.datetime.now)
date_joined = models.DateTimeField(_('date joined'), default=datetime.datetime.now)
groups = models.ManyToManyField(Group, verbose_name=_('groups'), blank=True,
help_text=_("In addition to the permissions manually assigned, this user will also get all permissions granted to each group he/she is in."))
user_permissions = models.ManyToManyField(Permission, verbose_name=_('user permissions'), blank=True)
objects = UserManager()
class Meta:
verbose_name = _('user')
verbose_name_plural = _('users')
def __unicode__(self):
return self.username
def get_absolute_url(self):
return "/users/%s/" % urllib.quote(smart_str(self.username))
def is_anonymous(self):
"""
Always returns False. This is a way of comparing User objects to
anonymous users.
"""
return False
def is_authenticated(self):
"""
Always return True. This is a way to tell if the user has been
authenticated in templates.
"""
return True
def get_full_name(self):
"Returns the first_name plus the last_name, with a space in between."
full_name = u'%s %s' % (self.first_name, self.last_name)
return full_name.strip()
def set_password(self, raw_password):
if raw_password is None:
self.set_unusable_password()
else:
import random
algo = 'sha1'
salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]
hsh = get_hexdigest(algo, salt, raw_password)
self.password = '%s$%s$%s' % (algo, salt, hsh)
def check_password(self, raw_password):
"""
Returns a boolean of whether the raw_password was correct. Handles
encryption formats behind the scenes.
"""
# Backwards-compatibility check. Older passwords won't include the
# algorithm or salt.
if '$' not in self.password:
is_correct = (self.password == get_hexdigest('md5', '', raw_password))
if is_correct:
# Convert the password to the new, more secure format.
self.set_password(raw_password)
self.save()
return is_correct
return check_password(raw_password, self.password)
def set_unusable_password(self):
# Sets a value that will never be a valid hash
self.password = UNUSABLE_PASSWORD
def has_usable_password(self):
if self.password is None \
or self.password == UNUSABLE_PASSWORD:
return False
else:
return True
def get_group_permissions(self, obj=None):
"""
Returns a list of permission strings that this user has through
his/her groups. This method queries all available auth backends.
If an object is passed in, only permissions matching this object
are returned.
"""
permissions = set()
for backend in auth.get_backends():
if hasattr(backend, "get_group_permissions"):
if obj is not None:
if backend.supports_object_permissions:
permissions.update(
backend.get_group_permissions(self, obj)
)
else:
permissions.update(backend.get_group_permissions(self))
return permissions
def get_all_permissions(self, obj=None):
return _user_get_all_permissions(self, obj)
def has_perm(self, perm, obj=None):
"""
Returns True if the user has the specified permission. This method
queries all available auth backends, but returns immediately if any
backend returns True. Thus, a user who has permission from a single
auth backend is assumed to have permission in general. If an object
is provided, permissions for this specific object are checked.
"""
# Inactive users have no permissions.
if not self.is_active:
return False
# Superusers have all permissions.
if self.is_superuser:
return True
# Otherwise we need to check the backends.
return _user_has_perm(self, perm, obj)
def has_perms(self, perm_list, obj=None):
"""
Returns True if the user has each of the specified permissions.
If object is passed, it checks if the user has all required perms
for this object.
"""
for perm in perm_list:
if not self.has_perm(perm, obj):
return False
return True
def has_module_perms(self, app_label):
"""
Returns True if the user has any permissions in the given app
label. Uses pretty much the same logic as has_perm, above.
"""
if not self.is_active:
return False
if self.is_superuser:
return True
return _user_has_module_perms(self, app_label)
def get_and_delete_messages(self):
messages = []
for m in self.message_set.all():
messages.append(m.message)
m.delete()
return messages
def email_user(self, subject, message, from_email=None):
"Sends an e-mail to this User."
from django.core.mail import send_mail
send_mail(subject, message, from_email, [self.email])
def get_profile(self):
"""
Returns site-specific profile for this user. Raises
SiteProfileNotAvailable if this site does not allow profiles.
"""
if not hasattr(self, '_profile_cache'):
from django.conf import settings
if not getattr(settings, 'AUTH_PROFILE_MODULE', False):
raise SiteProfileNotAvailable('You need to set AUTH_PROFILE_MO'
'DULE in your project settings')
try:
app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.')
except ValueError:
raise SiteProfileNotAvailable('app_label and model_name should'
' be separated by a dot in the AUTH_PROFILE_MODULE set'
'ting')
try:
model = models.get_model(app_label, model_name)
if model is None:
raise SiteProfileNotAvailable('Unable to load the profile '
'model, check AUTH_PROFILE_MODULE in your project sett'
'ings')
self._profile_cache = model._default_manager.using(self._state.db).get(user__id__exact=self.id)
self._profile_cache.user = self
except (ImportError, ImproperlyConfigured):
raise SiteProfileNotAvailable
return self._profile_cache
def _get_message_set(self):
import warnings
warnings.warn('The user messaging API is deprecated. Please update'
' your code to use the new messages framework.',
category=DeprecationWarning)
return self._message_set
message_set = property(_get_message_set)
class Message(models.Model):
"""
The message system is a lightweight way to queue messages for given
users. A message is associated with a User instance (so it is only
applicable for registered users). There's no concept of expiration or
timestamps. Messages are created by the Django admin after successful
actions. For example, "The poll Foo was created successfully." is a
message.
"""
user = models.ForeignKey(User, related_name='_message_set')
message = models.TextField(_('message'))
def __unicode__(self):
return self.message
class AnonymousUser(object):
id = None
username = ''
is_staff = False
is_active = False
is_superuser = False
_groups = EmptyManager()
_user_permissions = EmptyManager()
def __init__(self):
pass
def __unicode__(self):
return 'AnonymousUser'
def __str__(self):
return unicode(self).encode('utf-8')
def __eq__(self, other):
return isinstance(other, self.__class__)
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
return 1 # instances always return the same hash value
def save(self):
raise NotImplementedError
def delete(self):
raise NotImplementedError
def set_password(self, raw_password):
raise NotImplementedError
def check_password(self, raw_password):
raise NotImplementedError
def _get_groups(self):
return self._groups
groups = property(_get_groups)
def _get_user_permissions(self):
return self._user_permissions
user_permissions = property(_get_user_permissions)
def get_group_permissions(self, obj=None):
return set()
def get_all_permissions(self, obj=None):
return _user_get_all_permissions(self, obj=obj)
def has_perm(self, perm, obj=None):
return _user_has_perm(self, perm, obj=obj)
def has_perms(self, perm_list, obj=None):
for perm in perm_list:
if not self.has_perm(perm, obj):
return False
return True
def has_module_perms(self, module):
return _user_has_module_perms(self, module)
def get_and_delete_messages(self):
return []
def is_anonymous(self):
return True
def is_authenticated(self):
return False
| ajibawa-2023/Python-Code-Large/train/row_98601 | 276 | 474 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Import_L1_C0", "label": "datetime import datetime", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0021, 0.0021, 0, 0.66, 0.0, 426, 0, 1, 0, 0, 426, 0, 0], "semantic": {"name": "datetime", "arg_names": [], "import_names": ["datetime"], "rhs_call_name": "", "annotation": ""}, "snippet": "import datetime"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Import_L2_C0", "label": "urllib import urllib", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0042, 0.0021, 0, 0.66, 0.0435, 614, 0, 1, 0, 0, 614, 0, 0], "semantic": {"name": "urllib", "arg_names": [], "import_names": ["urllib"], "rhs_call_name": "", "annotation": ""}, "snippet": "import urllib"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L4_C0", "label": "from django.contrib import auth", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0084, 0.0021, 0, 0.66, 0.087, 302, 0, 1, 0, 0, 302, 0, 0], "semantic": {"name": "django.contrib", "arg_names": [], "import_names": ["auth"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib import auth"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L5_C0", "label": "from django.core.exceptions import ImproperlyConfigured", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0105, 0.0021, 0, 0.66, 0.1304, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["ImproperlyConfigured"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import ImproperlyConfigured"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L6_C0", "label": "from django.db import models", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0127, 0.0021, 0, 0.66, 0.1739, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L7_C0", "label": "from django.db.models.manager import EmptyManager", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0148, 0.0021, 0, 0.66, 0.2174, 59, 0, 1, 0, 0, 59, 0, 0], "semantic": {"name": "django.db.models.manager", "arg_names": [], "import_names": ["EmptyManager"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models.manager import EmptyManager"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L8_C0", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0169, 0.0021, 0, 0.66, 0.2609, 469, 0, 1, 0, 0, 469, 0, 0], "semantic": {"name": "django.contrib.contenttypes.models", "arg_names": [], "import_names": ["ContentType"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.contenttypes.models import ContentType"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L9_C0", "label": "from django.utils.encoding import smart_str", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.019, 0.0021, 0, 0.66, 0.3043, 96, 0, 1, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_str"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_str"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L10_C0", "label": "from django.utils.hashcompat import md5_constructor, sha_constructor", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0211, 0.0021, 0, 0.66, 0.3478, 474, 0, 2, 0, 0, 474, 0, 0], "semantic": {"name": "django.utils.hashcompat", "arg_names": [], "import_names": ["md5_constructor", "sha_constructor"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.hashcompat import md5_constructor, sha_constructor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L11_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0232, 0.0021, 0, 0.66, 0.3913, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext_lazy as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L14_C0", "label": "UNUSABLE_PASSWORD =", "type": "assigned_variable", "loc": [14, 14], "level": 0, "parent": null, "vector": [14, 0, 0.0295, 0.0021, 0, 0.66, 0.4348, 594, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "UNUSABLE_PASSWORD", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "UNUSABLE_PASSWORD = '!' # This will never be a valid hash"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L16_C0", "label": "get_hexdigest", "type": "function", "loc": [16, 33], "level": 0, "parent": null, "vector": [2, 0, 0.0517, 0.038, 0, 0.66, 0.4783, 706, 0, 3, 1, 0, 0, 0, 9], "semantic": {"name": "get_hexdigest", "arg_names": ["algorithm", "salt", "raw_password"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_hexdigest(algorithm, salt, raw_password):\n \"\"\"\n Returns a string of the hexdigest of the given plaintext password and salt\n using the given algorithm ('md5', 'sha1' or 'crypt').\n \"\"\"\n raw_password, salt = smart_str(raw_password), smart_str(salt)\n if algorithm == 'crypt':\n try:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L17_C4", "label": "expression", "type": "expression", "loc": [17, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L16_C0", "vector": [8, 1, 0.039, 0.0084, 1, 0.4, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a string of the hexdigest of the given plaintext password and salt\n using the given algorithm ('md5', 'sha1' or 'crypt').\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L21_C4", "label": "raw_password, salt =", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L16_C0", "vector": [14, 1, 0.0443, 0.0021, 1, 0.4, 0.3333, 201, 0, 0, 0, 0, 0, 8, 2], "semantic": {"name": "raw_password, salt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " raw_password, salt = smart_str(raw_password), smart_str(salt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L22_C4", "label": "if", "type": "if", "loc": [22, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L16_C0", "vector": [4, 1, 0.0517, 0.0127, 1, 0.4, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if algorithm == 'crypt':\n try:\n import crypt\n except ImportError:\n raise ValueError('\"crypt\" password algorithm not supported in this environment')\n return crypt.crypt(raw_password, salt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L23_C8", "label": "try", "type": "try", "loc": [23, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L22_C4", "vector": [7, 2, 0.0517, 0.0084, 2, 0.02, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n import crypt\n except ImportError:\n raise ValueError('\"crypt\" password algorithm not supported in this environment')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Import_L24_C12", "label": "crypt import crypt", "type": "import", "loc": [24, 24], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L23_C8", "vector": [1, 3, 0.0506, 0.0021, 3, 0.53, 0.0, 100, 0, 1, 0, 0, 100, 0, 0], "semantic": {"name": "crypt", "arg_names": [], "import_names": ["crypt"], "rhs_call_name": "", "annotation": ""}, "snippet": " import crypt"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L27_C8", "label": "return", "type": "return", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L22_C4", "vector": [13, 2, 0.057, 0.0021, 2, 0.02, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return crypt.crypt(raw_password, salt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L29_C4", "label": "if", "type": "if", "loc": [29, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L16_C0", "vector": [4, 1, 0.0643, 0.0084, 1, 0.4, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if algorithm == 'md5':\n return md5_constructor(salt + raw_password).hexdigest()\n elif algorithm == 'sha1':\n return sha_constructor(salt + raw_password).hexdigest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L30_C8", "label": "return", "type": "return", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L29_C4", "vector": [13, 2, 0.0633, 0.0021, 2, 0.72, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return md5_constructor(salt + raw_password).hexdigest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L31_C4", "label": "if", "type": "if", "loc": [31, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L29_C4", "vector": [4, 2, 0.0665, 0.0042, 2, 0.72, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif algorithm == 'sha1':\n return sha_constructor(salt + raw_password).hexdigest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L32_C8", "label": "return", "type": "return", "loc": [32, 32], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L31_C4", "vector": [13, 3, 0.0675, 0.0021, 3, 0.51, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return sha_constructor(salt + raw_password).hexdigest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L35_C0", "label": "check_password", "type": "function", "loc": [35, 41], "level": 0, "parent": null, "vector": [2, 0, 0.0802, 0.0148, 0, 0.66, 0.5217, 645, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "check_password", "arg_names": ["raw_password", "enc_password"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def check_password(raw_password, enc_password):\n \"\"\"\n Returns a boolean of whether the raw_password was correct. Handles\n encryption formats behind the scenes.\n \"\"\"\n algo, salt, hsh = enc_password.split('$')\n return hsh == get_hexdigest(algo, salt, raw_password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L36_C4", "label": "expression", "type": "expression", "loc": [36, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L35_C0", "vector": [8, 1, 0.0791, 0.0084, 1, 0.64, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a boolean of whether the raw_password was correct. Handles\n encryption formats behind the scenes.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L40_C4", "label": "algo, salt, hsh = split()", "type": "assigned_variable", "loc": [40, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L35_C0", "vector": [14, 1, 0.0844, 0.0021, 1, 0.64, 0.5, 466, 3, 1, 0, 0, 908, 10, 1], "semantic": {"name": "algo, salt, hsh", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " algo, salt, hsh = enc_password.split('$')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L41_C4", "label": "return", "type": "return", "loc": [41, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L35_C0", "vector": [13, 1, 0.0865, 0.0021, 1, 0.64, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return hsh == get_hexdigest(algo, salt, raw_password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L43_C0", "label": "SiteProfileNotAvailable", "type": "class", "loc": [43, 44], "level": 0, "parent": null, "vector": [3, 0, 0.0918, 0.0042, 0, 0.66, 0.5652, 754, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "SiteProfileNotAvailable", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SiteProfileNotAvailable(Exception):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L46_C0", "label": "PermissionManager", "type": "class", "loc": [46, 51], "level": 0, "parent": null, "vector": [3, 0, 0.1023, 0.0127, 0, 0.66, 0.6087, 210, 0, 1, 0, 0, 948, 0, 2], "semantic": {"name": "PermissionManager", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PermissionManager(models.Manager):\n def get_by_natural_key(self, codename, app_label, model):\n return self.get(\n codename=codename,\n content_type=ContentType.objects.get_by_natural_key(app_label, model)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L47_C4", "label": "get_by_natural_key", "type": "function", "loc": [47, 51], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L46_C0", "vector": [2, 1, 0.1034, 0.0105, 1, 0.49, 0.0, 668, 0, 4, 1, 0, 0, 0, 2], "semantic": {"name": "get_by_natural_key", "arg_names": ["self", "codename", "app_label", "model"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_by_natural_key(self, codename, app_label, model):\n return self.get(\n codename=codename,\n content_type=ContentType.objects.get_by_natural_key(app_label, model)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L48_C8", "label": "return", "type": "return", "loc": [48, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L47_C4", "vector": [13, 2, 0.1044, 0.0084, 2, 0.03, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.get(\n codename=codename,\n content_type=ContentType.objects.get_by_natural_key(app_label, model)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "label": "Permission", "type": "class", "loc": [53, 85], "level": 0, "parent": null, "vector": [3, 0, 0.1456, 0.0696, 0, 0.66, 0.6522, 950, 0, 2, 0, 0, 996, 0, 12], "semantic": {"name": "Permission", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Permission(models.Model):\n \"\"\"The permissions system provides a way to assign permissions to specific users and groups of users.\n\n The permission system is used by the Django admin site, but may also be useful in your own code. The Django admin site uses permissions as follows:\n\n - The \"add\" permission limits the user's ability to view the \"add\" form and add an object.\n - The \"change\" permission limits a user's ability to view the change list, view the \"change\" form and change an object.\n - The \"delete\" permission limits the ability to delete an object."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L54_C4", "label": "expression", "type": "expression", "loc": [54, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "vector": [8, 1, 0.1255, 0.0253, 1, 0.88, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"The permissions system provides a way to assign permissions to specific users and groups of users.\n\n The permission system is used by the Django admin site, but may also be useful in your own code. The Django admin site uses permissions as follows:\n\n - The \"add\" permission limits the user's ability to view the \"add\" form and add an object.\n - The \"change\" permission limits a user's ability to view the change list, view the \"change\" form and change an object.\n - The \"delete\" permission limits the ability to delete an object.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L66_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [66, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "vector": [14, 1, 0.1392, 0.0021, 1, 0.88, 0.125, 57, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(_('name'), max_length=50)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L67_C4", "label": "content_type = ForeignKey()", "type": "assigned_variable", "loc": [67, 67], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "vector": [14, 1, 0.1414, 0.0021, 1, 0.88, 0.25, 610, 3, 1, 0, 0, 140, 10, 1], "semantic": {"name": "content_type", "arg_names": [], "import_names": [], "rhs_call_name": "ForeignKey", "annotation": ""}, "snippet": " content_type = models.ForeignKey(ContentType)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L68_C4", "label": "codename = CharField()", "type": "assigned_variable", "loc": [68, 68], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "vector": [14, 1, 0.1435, 0.0021, 1, 0.88, 0.375, 503, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "codename", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " codename = models.CharField(_('codename'), max_length=100)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L69_C4", "label": "objects = PermissionManager()", "type": "assigned_variable", "loc": [69, 69], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "vector": [14, 1, 0.1456, 0.0021, 1, 0.88, 0.5, 550, 3, 0, 0, 0, 210, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "PermissionManager", "annotation": ""}, "snippet": " objects = PermissionManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L71_C4", "label": "Meta", "type": "class", "loc": [71, 75], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "vector": [3, 1, 0.154, 0.0105, 1, 0.88, 0.625, 130, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "Meta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Meta:\n verbose_name = _('permission')\n verbose_name_plural = _('permissions')\n unique_together = (('content_type', 'codename'),)\n ordering = ('codename',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L72_C8", "label": "verbose_name = _()", "type": "assigned_variable", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L71_C4", "vector": [14, 2, 0.1519, 0.0021, 2, 0.54, 0.0, 616, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "verbose_name", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " verbose_name = _('permission')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L73_C8", "label": "verbose_name_plural = _()", "type": "assigned_variable", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L71_C4", "vector": [14, 2, 0.154, 0.0021, 2, 0.54, 0.3333, 329, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "verbose_name_plural", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " verbose_name_plural = _('permissions')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L74_C8", "label": "unique_together =", "type": "assigned_variable", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L71_C4", "vector": [14, 2, 0.1561, 0.0021, 2, 0.54, 0.6667, 846, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "unique_together", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " unique_together = (('content_type', 'codename'),)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L75_C8", "label": "ordering =", "type": "assigned_variable", "loc": [75, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L71_C4", "vector": [14, 2, 0.1582, 0.0021, 2, 0.54, 1.0, 656, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "ordering", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ordering = ('codename',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L77_C4", "label": "__unicode__", "type": "function", "loc": [77, 81], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "vector": [2, 1, 0.1667, 0.0105, 1, 0.88, 0.75, 318, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return u\"%s | %s | %s\" % (\n unicode(self.content_type.app_label),\n unicode(self.content_type),\n unicode(self.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L78_C8", "label": "return", "type": "return", "loc": [78, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L77_C4", "vector": [13, 2, 0.1677, 0.0084, 2, 0.15, 0.0, 0, 4, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u\"%s | %s | %s\" % (\n unicode(self.content_type.app_label),\n unicode(self.content_type),\n unicode(self.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L83_C4", "label": "natural_key", "type": "function", "loc": [83, 84], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "vector": [2, 1, 0.1762, 0.0042, 1, 0.88, 0.875, 449, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "natural_key", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def natural_key(self):\n return (self.codename,) + self.content_type.natural_key()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L84_C8", "label": "return", "type": "return", "loc": [84, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L83_C4", "vector": [13, 2, 0.1772, 0.0021, 2, 0.89, 0.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return (self.codename,) + self.content_type.natural_key()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L85_C4", "label": "natural_key.dependencies =", "type": "assigned_variable", "loc": [85, 85], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "vector": [14, 1, 0.1793, 0.0021, 1, 0.88, 1.0, 105, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "natural_key.dependencies", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " natural_key.dependencies = ['contenttypes.contenttype']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L87_C0", "label": "Group", "type": "class", "loc": [87, 102], "level": 0, "parent": null, "vector": [3, 0, 0.1994, 0.0338, 0, 0.66, 0.6957, 536, 0, 1, 0, 0, 996, 0, 6], "semantic": {"name": "Group", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Group(models.Model):\n \"\"\"Groups are a generic way of categorizing users to apply permissions, or some other label, to those users. A user can belong to any number of groups.\n\n A user in a group automatically has all the permissions granted to that group. For example, if the group Site editors has the permission can_edit_home_page, any user in that group will have that permission.\n\n Beyond permissions, groups are a convenient way to categorize users to apply some label, or extended functionality, to them. For example, you could create a group 'Special users', and you could write code that would do special things to those users -- such as giving them access to a members-only portion of your site, or sending them members-only e-mail messages.\n \"\"\"\n name = models.CharField(_('name'), max_length=80, unique=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L88_C4", "label": "expression", "type": "expression", "loc": [88, 93], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L87_C0", "vector": [8, 1, 0.1909, 0.0127, 1, 0.0, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Groups are a generic way of categorizing users to apply permissions, or some other label, to those users. A user can belong to any number of groups.\n\n A user in a group automatically has all the permissions granted to that group. For example, if the group Site editors has the permission can_edit_home_page, any user in that group will have that permission.\n\n Beyond permissions, groups are a convenient way to categorize users to apply some label, or extended functionality, to them. For example, you could create a group 'Special users', and you could write code that would do special things to those users -- such as giving them access to a members-only portion of your site, or sending them members-only e-mail messages.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L94_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [94, 94], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L87_C0", "vector": [14, 1, 0.1983, 0.0021, 1, 0.0, 0.25, 57, 3, 3, 0, 0, 952, 10, 2], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(_('name'), max_length=80, unique=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L95_C4", "label": "permissions = ManyToManyField()", "type": "assigned_variable", "loc": [95, 95], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L87_C0", "vector": [14, 1, 0.2004, 0.0021, 1, 0.0, 0.5, 503, 3, 3, 0, 0, 941, 10, 2], "semantic": {"name": "permissions", "arg_names": [], "import_names": [], "rhs_call_name": "ManyToManyField", "annotation": ""}, "snippet": " permissions = models.ManyToManyField(Permission, verbose_name=_('permissions'), blank=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L97_C4", "label": "Meta", "type": "class", "loc": [97, 99], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L87_C0", "vector": [3, 1, 0.2068, 0.0063, 1, 0.0, 0.75, 130, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "Meta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Meta:\n verbose_name = _('group')\n verbose_name_plural = _('groups')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L98_C8", "label": "verbose_name = _()", "type": "assigned_variable", "loc": [98, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L97_C4", "vector": [14, 2, 0.2068, 0.0021, 2, 0.1, 0.0, 616, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "verbose_name", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " verbose_name = _('group')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L99_C8", "label": "verbose_name_plural = _()", "type": "assigned_variable", "loc": [99, 99], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L97_C4", "vector": [14, 2, 0.2089, 0.0021, 2, 0.1, 1.0, 329, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "verbose_name_plural", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " verbose_name_plural = _('groups')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L101_C4", "label": "__unicode__", "type": "function", "loc": [101, 102], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L87_C0", "vector": [2, 1, 0.2141, 0.0042, 1, 0.0, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L102_C8", "label": "return", "type": "return", "loc": [102, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L101_C4", "vector": [13, 2, 0.2152, 0.0021, 2, 0.6, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L104_C0", "label": "UserManager", "type": "class", "loc": [104, 141], "level": 0, "parent": null, "vector": [3, 0, 0.2584, 0.0802, 0, 0.66, 0.7391, 378, 0, 3, 0, 0, 948, 0, 13], "semantic": {"name": "UserManager", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class UserManager(models.Manager):\n def create_user(self, username, email, password=None):\n \"\"\"\n Creates and saves a User with the given username, e-mail and password.\n \"\"\"\n now = datetime.datetime.now()\n\n # Normalize the address by lowercasing the domain part of the email"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "label": "create_user", "type": "function", "loc": [105, 126], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L104_C0", "vector": [2, 1, 0.2437, 0.0464, 1, 0.41, 0.0, 946, 0, 4, 1, 0, 0, 0, 8], "semantic": {"name": "create_user", "arg_names": ["self", "username", "email", "password"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def create_user(self, username, email, password=None):\n \"\"\"\n Creates and saves a User with the given username, e-mail and password.\n \"\"\"\n now = datetime.datetime.now()\n\n # Normalize the address by lowercasing the domain part of the email\n # address."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L106_C8", "label": "expression", "type": "expression", "loc": [106, 108], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "vector": [8, 2, 0.2257, 0.0063, 2, 0.03, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Creates and saves a User with the given username, e-mail and password.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L109_C8", "label": "now = now()", "type": "assigned_variable", "loc": [109, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "vector": [14, 2, 0.23, 0.0021, 2, 0.03, 0.1667, 894, 3, 0, 0, 0, 894, 10, 1], "semantic": {"name": "now", "arg_names": [], "import_names": [], "rhs_call_name": "now", "annotation": ""}, "snippet": " now = datetime.datetime.now()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L113_C8", "label": "try", "type": "try", "loc": [113, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "vector": [7, 2, 0.2437, 0.0127, 2, 0.03, 0.3333, 0, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n email_name, domain_part = email.strip().split('@', 1)\n except ValueError:\n pass\n else:\n email = '@'.join([email_name, domain_part.lower()])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L114_C12", "label": "email_name, domain_part = split()", "type": "assigned_variable", "loc": [114, 114], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L113_C8", "vector": [14, 3, 0.2405, 0.0021, 3, 0.4, 0.0, 823, 3, 2, 0, 0, 908, 10, 2], "semantic": {"name": "email_name, domain_part", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " email_name, domain_part = email.strip().split('@', 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L118_C12", "label": "email = join()", "type": "assigned_variable", "loc": [118, 118], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L113_C8", "vector": [14, 3, 0.2489, 0.0021, 3, 0.4, 1.0, 413, 3, 1, 0, 0, 933, 10, 2], "semantic": {"name": "email", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " email = '@'.join([email_name, domain_part.lower()])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L120_C8", "label": "user = model()", "type": "assigned_variable", "loc": [120, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "vector": [14, 2, 0.2553, 0.0063, 2, 0.03, 0.5, 503, 3, 7, 0, 0, 722, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "model", "annotation": ""}, "snippet": " user = self.model(username=username, email=email, is_staff=False,\n is_active=True, is_superuser=False, last_login=now,\n date_joined=now)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L124_C8", "label": "set_password()", "type": "expression", "loc": [124, 124], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "vector": [8, 2, 0.2616, 0.0021, 2, 0.03, 0.6667, 803, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "set_password", "arg_names": [], "import_names": [], "rhs_call_name": "set_password", "annotation": ""}, "snippet": " user.set_password(password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L125_C8", "label": "save()", "type": "expression", "loc": [125, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "vector": [8, 2, 0.2637, 0.0021, 2, 0.03, 0.8333, 928, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save(using=self._db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L126_C8", "label": "return", "type": "return", "loc": [126, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "vector": [13, 2, 0.2658, 0.0021, 2, 0.03, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "label": "create_superuser", "type": "function", "loc": [128, 134], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L104_C0", "vector": [2, 1, 0.2764, 0.0148, 1, 0.41, 0.5, 149, 0, 4, 1, 0, 0, 0, 2], "semantic": {"name": "create_superuser", "arg_names": ["self", "username", "email", "password"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def create_superuser(self, username, email, password):\n u = self.create_user(username, email, password)\n u.is_staff = True\n u.is_active = True\n u.is_superuser = True\n u.save(using=self._db)\n return u"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L129_C8", "label": "u = create_user()", "type": "assigned_variable", "loc": [129, 129], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "vector": [14, 2, 0.2722, 0.0021, 2, 0.67, 0.0, 609, 3, 3, 0, 0, 946, 10, 1], "semantic": {"name": "u", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " u = self.create_user(username, email, password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L130_C8", "label": "u.is_staff =", "type": "assigned_variable", "loc": [130, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "vector": [14, 2, 0.2743, 0.0021, 2, 0.67, 0.2, 937, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "u.is_staff", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " u.is_staff = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L131_C8", "label": "u.is_active =", "type": "assigned_variable", "loc": [131, 131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "vector": [14, 2, 0.2764, 0.0021, 2, 0.67, 0.4, 260, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "u.is_active", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " u.is_active = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L132_C8", "label": "u.is_superuser =", "type": "assigned_variable", "loc": [132, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "vector": [14, 2, 0.2785, 0.0021, 2, 0.67, 0.6, 66, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "u.is_superuser", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " u.is_superuser = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L133_C8", "label": "save()", "type": "expression", "loc": [133, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "vector": [8, 2, 0.2806, 0.0021, 2, 0.67, 0.8, 928, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " u.save(using=self._db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L134_C8", "label": "return", "type": "return", "loc": [134, 134], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "vector": [13, 2, 0.2827, 0.0021, 2, 0.67, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L136_C4", "label": "make_random_password", "type": "function", "loc": [136, 141], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L104_C0", "vector": [2, 1, 0.2922, 0.0127, 1, 0.41, 1.0, 300, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "make_random_password", "arg_names": ["self", "length", "allowed_chars"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def make_random_password(self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'):\n \"Generates a random password with the given length and given allowed_chars\"\n # Note that default value of allowed_chars does not have \"I\" or letters\n # that look like it -- just to avoid confusion.\n from random import choice\n return ''.join([choice(allowed_chars) for i in range(length)])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L137_C8", "label": "expression", "type": "expression", "loc": [137, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L136_C4", "vector": [8, 2, 0.289, 0.0021, 2, 0.37, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Generates a random password with the given length and given allowed_chars\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L140_C8", "label": "from random import choice", "type": "import", "loc": [140, 140], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L136_C4", "vector": [1, 2, 0.2954, 0.0021, 2, 0.37, 0.5, 715, 0, 1, 0, 0, 715, 0, 0], "semantic": {"name": "random", "arg_names": [], "import_names": ["choice"], "rhs_call_name": "", "annotation": ""}, "snippet": " from random import choice"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L141_C8", "label": "return", "type": "return", "loc": [141, 141], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L136_C4", "vector": [13, 2, 0.2975, 0.0021, 2, 0.37, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''.join([choice(allowed_chars) for i in range(length)])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L145_C0", "label": "_user_get_all_permissions", "type": "function", "loc": [145, 158], "level": 0, "parent": null, "vector": [2, 0, 0.3196, 0.0295, 0, 0.66, 0.7826, 662, 0, 2, 1, 0, 0, 0, 8], "semantic": {"name": "_user_get_all_permissions", "arg_names": ["user", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _user_get_all_permissions(user, obj):\n permissions = set()\n anon = user.is_anonymous()\n for backend in auth.get_backends():\n if not anon or backend.supports_anonymous_user:\n if hasattr(backend, \"get_all_permissions\"):\n if obj is not None:\n if backend.supports_object_permissions:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L146_C4", "label": "permissions = set()", "type": "assigned_variable", "loc": [146, 146], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L145_C0", "vector": [14, 1, 0.308, 0.0021, 1, 0.95, 0.0, 503, 3, 0, 0, 0, 21, 10, 1], "semantic": {"name": "permissions", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " permissions = set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L147_C4", "label": "anon = is_anonymous()", "type": "assigned_variable", "loc": [147, 147], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L145_C0", "vector": [14, 1, 0.3101, 0.0021, 1, 0.95, 0.3333, 38, 3, 0, 0, 0, 814, 10, 1], "semantic": {"name": "anon", "arg_names": [], "import_names": [], "rhs_call_name": "is_anonymous", "annotation": ""}, "snippet": " anon = user.is_anonymous()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L148_C4", "label": "for backend", "type": "for", "loc": [148, 157], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L145_C0", "vector": [6, 1, 0.3217, 0.0211, 1, 0.95, 0.6667, 631, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "backend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for backend in auth.get_backends():\n if not anon or backend.supports_anonymous_user:\n if hasattr(backend, \"get_all_permissions\"):\n if obj is not None:\n if backend.supports_object_permissions:\n permissions.update(\n backend.get_all_permissions(user, obj)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L149_C8", "label": "if", "type": "if", "loc": [149, 157], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L148_C4", "vector": [4, 2, 0.3228, 0.019, 2, 0.52, 0.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not anon or backend.supports_anonymous_user:\n if hasattr(backend, \"get_all_permissions\"):\n if obj is not None:\n if backend.supports_object_permissions:\n permissions.update(\n backend.get_all_permissions(user, obj)\n )\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L150_C12", "label": "if", "type": "if", "loc": [150, 157], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L149_C8", "vector": [4, 3, 0.3238, 0.0169, 3, 0.98, 0.0, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(backend, \"get_all_permissions\"):\n if obj is not None:\n if backend.supports_object_permissions:\n permissions.update(\n backend.get_all_permissions(user, obj)\n )\n else:\n permissions.update(backend.get_all_permissions(user))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L151_C16", "label": "if", "type": "if", "loc": [151, 157], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L150_C12", "vector": [4, 4, 0.3249, 0.0148, 4, 0.89, 0.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if obj is not None:\n if backend.supports_object_permissions:\n permissions.update(\n backend.get_all_permissions(user, obj)\n )\n else:\n permissions.update(backend.get_all_permissions(user))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L152_C20", "label": "if", "type": "if", "loc": [152, 155], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L151_C16", "vector": [4, 5, 0.3238, 0.0084, 5, 0.12, 0.0, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if backend.supports_object_permissions:\n permissions.update(\n backend.get_all_permissions(user, obj)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L153_C24", "label": "update()", "type": "expression", "loc": [153, 155], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L152_C20", "vector": [8, 6, 0.3249, 0.0063, 6, 0.93, 0.0, 637, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " permissions.update(\n backend.get_all_permissions(user, obj)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L157_C20", "label": "update()", "type": "expression", "loc": [157, 157], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L151_C16", "vector": [8, 5, 0.3312, 0.0021, 5, 0.12, 1.0, 637, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " permissions.update(backend.get_all_permissions(user))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L158_C4", "label": "return", "type": "return", "loc": [158, 158], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L145_C0", "vector": [13, 1, 0.3333, 0.0021, 1, 0.95, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return permissions"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L161_C0", "label": "_user_has_perm", "type": "function", "loc": [161, 173], "level": 0, "parent": null, "vector": [2, 0, 0.3523, 0.0274, 0, 0.66, 0.8261, 960, 0, 3, 1, 0, 0, 0, 5], "semantic": {"name": "_user_has_perm", "arg_names": ["user", "perm", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _user_has_perm(user, perm, obj):\n anon = user.is_anonymous()\n for backend in auth.get_backends():\n if not anon or backend.supports_anonymous_user:\n if hasattr(backend, \"has_perm\"):\n if obj is not None:\n if (backend.supports_object_permissions and\n backend.has_perm(user, perm, obj)):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L162_C4", "label": "anon = is_anonymous()", "type": "assigned_variable", "loc": [162, 162], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L161_C0", "vector": [14, 1, 0.3418, 0.0021, 1, 0.83, 0.0, 38, 3, 0, 0, 0, 814, 10, 1], "semantic": {"name": "anon", "arg_names": [], "import_names": [], "rhs_call_name": "is_anonymous", "annotation": ""}, "snippet": " anon = user.is_anonymous()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L163_C4", "label": "for backend", "type": "for", "loc": [163, 172], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L161_C0", "vector": [6, 1, 0.3534, 0.0211, 1, 0.83, 0.5, 631, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "backend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for backend in auth.get_backends():\n if not anon or backend.supports_anonymous_user:\n if hasattr(backend, \"has_perm\"):\n if obj is not None:\n if (backend.supports_object_permissions and\n backend.has_perm(user, perm, obj)):\n return True\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L164_C8", "label": "if", "type": "if", "loc": [164, 172], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L163_C4", "vector": [4, 2, 0.3544, 0.019, 2, 0.91, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not anon or backend.supports_anonymous_user:\n if hasattr(backend, \"has_perm\"):\n if obj is not None:\n if (backend.supports_object_permissions and\n backend.has_perm(user, perm, obj)):\n return True\n else:\n if backend.has_perm(user, perm):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L165_C12", "label": "if", "type": "if", "loc": [165, 172], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L164_C8", "vector": [4, 3, 0.3555, 0.0169, 3, 0.11, 0.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(backend, \"has_perm\"):\n if obj is not None:\n if (backend.supports_object_permissions and\n backend.has_perm(user, perm, obj)):\n return True\n else:\n if backend.has_perm(user, perm):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L166_C16", "label": "if", "type": "if", "loc": [166, 172], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L165_C12", "vector": [4, 4, 0.3565, 0.0148, 4, 0.37, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if obj is not None:\n if (backend.supports_object_permissions and\n backend.has_perm(user, perm, obj)):\n return True\n else:\n if backend.has_perm(user, perm):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L167_C20", "label": "if", "type": "if", "loc": [167, 169], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L166_C16", "vector": [4, 5, 0.3544, 0.0063, 5, 0.44, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if (backend.supports_object_permissions and\n backend.has_perm(user, perm, obj)):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L169_C28", "label": "return", "type": "return", "loc": [169, 169], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L167_C20", "vector": [13, 6, 0.3565, 0.0021, 6, 0.18, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L171_C20", "label": "if", "type": "if", "loc": [171, 172], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L166_C16", "vector": [4, 5, 0.3618, 0.0042, 5, 0.44, 1.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if backend.has_perm(user, perm):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L172_C24", "label": "return", "type": "return", "loc": [172, 172], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L171_C20", "vector": [13, 6, 0.3629, 0.0021, 6, 0.4, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L173_C4", "label": "return", "type": "return", "loc": [173, 173], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L161_C0", "vector": [13, 1, 0.365, 0.0021, 1, 0.83, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L176_C0", "label": "_user_has_module_perms", "type": "function", "loc": [176, 183], "level": 0, "parent": null, "vector": [2, 0, 0.3787, 0.0169, 0, 0.66, 0.8696, 230, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "_user_has_module_perms", "arg_names": ["user", "app_label"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _user_has_module_perms(user, app_label):\n anon = user.is_anonymous()\n for backend in auth.get_backends():\n if not anon or backend.supports_anonymous_user:\n if hasattr(backend, \"has_module_perms\"):\n if backend.has_module_perms(user, app_label):\n return True\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L177_C4", "label": "anon = is_anonymous()", "type": "assigned_variable", "loc": [177, 177], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L176_C0", "vector": [14, 1, 0.3734, 0.0021, 1, 0.68, 0.0, 38, 3, 0, 0, 0, 814, 10, 1], "semantic": {"name": "anon", "arg_names": [], "import_names": [], "rhs_call_name": "is_anonymous", "annotation": ""}, "snippet": " anon = user.is_anonymous()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L178_C4", "label": "for backend", "type": "for", "loc": [178, 182], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L176_C0", "vector": [6, 1, 0.3797, 0.0105, 1, 0.68, 0.5, 631, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "backend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for backend in auth.get_backends():\n if not anon or backend.supports_anonymous_user:\n if hasattr(backend, \"has_module_perms\"):\n if backend.has_module_perms(user, app_label):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L179_C8", "label": "if", "type": "if", "loc": [179, 182], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L178_C4", "vector": [4, 2, 0.3808, 0.0084, 2, 0.97, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not anon or backend.supports_anonymous_user:\n if hasattr(backend, \"has_module_perms\"):\n if backend.has_module_perms(user, app_label):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L180_C12", "label": "if", "type": "if", "loc": [180, 182], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L179_C8", "vector": [4, 3, 0.3819, 0.0063, 3, 0.21, 0.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(backend, \"has_module_perms\"):\n if backend.has_module_perms(user, app_label):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L181_C16", "label": "if", "type": "if", "loc": [181, 182], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L180_C12", "vector": [4, 4, 0.3829, 0.0042, 4, 0.39, 0.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if backend.has_module_perms(user, app_label):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L182_C20", "label": "return", "type": "return", "loc": [182, 182], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L181_C16", "vector": [13, 5, 0.384, 0.0021, 5, 0.21, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L183_C4", "label": "return", "type": "return", "loc": [183, 183], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L176_C0", "vector": [13, 1, 0.3861, 0.0021, 1, 0.68, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "label": "User", "type": "class", "loc": [186, 385], "level": 0, "parent": null, "vector": [3, 0, 0.6023, 0.4219, 0, 0.66, 0.913, 61, 0, 18, 0, 0, 996, 0, 73], "semantic": {"name": "User", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class User(models.Model):\n \"\"\"\n Users within the Django authentication system are represented by this model.\n\n Username and password are required. Other fields are optional.\n \"\"\"\n username = models.CharField(_('username'), max_length=30, unique=True, help_text=_(\"Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters\"))\n first_name = models.CharField(_('first name'), max_length=30, blank=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L187_C4", "label": "expression", "type": "expression", "loc": [187, 191], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [8, 1, 0.3987, 0.0105, 1, 0.59, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Users within the Django authentication system are represented by this model.\n\n Username and password are required. Other fields are optional.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L192_C4", "label": "username = CharField()", "type": "assigned_variable", "loc": [192, 192], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4051, 0.0021, 1, 0.59, 0.0303, 718, 3, 4, 0, 0, 952, 10, 3], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " username = models.CharField(_('username'), max_length=30, unique=True, help_text=_(\"Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L193_C4", "label": "first_name = CharField()", "type": "assigned_variable", "loc": [193, 193], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4072, 0.0021, 1, 0.59, 0.0606, 185, 3, 3, 0, 0, 952, 10, 2], "semantic": {"name": "first_name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " first_name = models.CharField(_('first name'), max_length=30, blank=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L194_C4", "label": "last_name = CharField()", "type": "assigned_variable", "loc": [194, 194], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4093, 0.0021, 1, 0.59, 0.0909, 578, 3, 3, 0, 0, 952, 10, 2], "semantic": {"name": "last_name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " last_name = models.CharField(_('last name'), max_length=30, blank=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L195_C4", "label": "email = EmailField()", "type": "assigned_variable", "loc": [195, 195], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4114, 0.0021, 1, 0.59, 0.1212, 413, 3, 2, 0, 0, 767, 10, 2], "semantic": {"name": "email", "arg_names": [], "import_names": [], "rhs_call_name": "EmailField", "annotation": ""}, "snippet": " email = models.EmailField(_('e-mail address'), blank=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L196_C4", "label": "password = CharField()", "type": "assigned_variable", "loc": [196, 196], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4135, 0.0021, 1, 0.59, 0.1515, 489, 3, 3, 0, 0, 952, 10, 3], "semantic": {"name": "password", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " password = models.CharField(_('password'), max_length=128, help_text=_(\"Use '[algo]$[salt]$[hexdigest]' or use the <a href=\\\"password/\\\">change password form</a>.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L197_C4", "label": "is_staff = BooleanField()", "type": "assigned_variable", "loc": [197, 197], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4156, 0.0021, 1, 0.59, 0.1818, 212, 3, 3, 0, 0, 498, 10, 3], "semantic": {"name": "is_staff", "arg_names": [], "import_names": [], "rhs_call_name": "BooleanField", "annotation": ""}, "snippet": " is_staff = models.BooleanField(_('staff status'), default=False, help_text=_(\"Designates whether the user can log into this admin site.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L198_C4", "label": "is_active = BooleanField()", "type": "assigned_variable", "loc": [198, 198], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4177, 0.0021, 1, 0.59, 0.2121, 645, 3, 3, 0, 0, 498, 10, 3], "semantic": {"name": "is_active", "arg_names": [], "import_names": [], "rhs_call_name": "BooleanField", "annotation": ""}, "snippet": " is_active = models.BooleanField(_('active'), default=True, help_text=_(\"Designates whether this user should be treated as active. Unselect this instead of deleting accounts.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L199_C4", "label": "is_superuser = BooleanField()", "type": "assigned_variable", "loc": [199, 199], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4198, 0.0021, 1, 0.59, 0.2424, 358, 3, 3, 0, 0, 498, 10, 3], "semantic": {"name": "is_superuser", "arg_names": [], "import_names": [], "rhs_call_name": "BooleanField", "annotation": ""}, "snippet": " is_superuser = models.BooleanField(_('superuser status'), default=False, help_text=_(\"Designates that this user has all permissions without explicitly assigning them.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L200_C4", "label": "last_login = DateTimeField()", "type": "assigned_variable", "loc": [200, 200], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4219, 0.0021, 1, 0.59, 0.2727, 876, 3, 2, 0, 0, 789, 10, 2], "semantic": {"name": "last_login", "arg_names": [], "import_names": [], "rhs_call_name": "DateTimeField", "annotation": ""}, "snippet": " last_login = models.DateTimeField(_('last login'), default=datetime.datetime.now)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L201_C4", "label": "date_joined = DateTimeField()", "type": "assigned_variable", "loc": [201, 201], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4241, 0.0021, 1, 0.59, 0.303, 514, 3, 2, 0, 0, 789, 10, 2], "semantic": {"name": "date_joined", "arg_names": [], "import_names": [], "rhs_call_name": "DateTimeField", "annotation": ""}, "snippet": " date_joined = models.DateTimeField(_('date joined'), default=datetime.datetime.now)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L202_C4", "label": "groups = ManyToManyField()", "type": "assigned_variable", "loc": [202, 203], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4272, 0.0042, 1, 0.59, 0.3333, 161, 3, 4, 0, 0, 941, 10, 3], "semantic": {"name": "groups", "arg_names": [], "import_names": [], "rhs_call_name": "ManyToManyField", "annotation": ""}, "snippet": " groups = models.ManyToManyField(Group, verbose_name=_('groups'), blank=True,\n help_text=_(\"In addition to the permissions manually assigned, this user will also get all permissions granted to each group he/she is in.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L204_C4", "label": "user_permissions = ManyToManyField()", "type": "assigned_variable", "loc": [204, 204], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4304, 0.0021, 1, 0.59, 0.3636, 177, 3, 3, 0, 0, 941, 10, 2], "semantic": {"name": "user_permissions", "arg_names": [], "import_names": [], "rhs_call_name": "ManyToManyField", "annotation": ""}, "snippet": " user_permissions = models.ManyToManyField(Permission, verbose_name=_('user permissions'), blank=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L205_C4", "label": "objects = UserManager()", "type": "assigned_variable", "loc": [205, 205], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.4325, 0.0021, 1, 0.59, 0.3939, 550, 3, 0, 0, 0, 378, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "UserManager", "annotation": ""}, "snippet": " objects = UserManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L207_C4", "label": "Meta", "type": "class", "loc": [207, 209], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [3, 1, 0.4388, 0.0063, 1, 0.59, 0.4242, 130, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "Meta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Meta:\n verbose_name = _('user')\n verbose_name_plural = _('users')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L208_C8", "label": "verbose_name = _()", "type": "assigned_variable", "loc": [208, 208], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L207_C4", "vector": [14, 2, 0.4388, 0.0021, 2, 0.28, 0.0, 616, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "verbose_name", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " verbose_name = _('user')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L209_C8", "label": "verbose_name_plural = _()", "type": "assigned_variable", "loc": [209, 209], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L207_C4", "vector": [14, 2, 0.4409, 0.0021, 2, 0.28, 1.0, 329, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "verbose_name_plural", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " verbose_name_plural = _('users')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L211_C4", "label": "__unicode__", "type": "function", "loc": [211, 212], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.4462, 0.0042, 1, 0.59, 0.4545, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return self.username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L212_C8", "label": "return", "type": "return", "loc": [212, 212], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L211_C4", "vector": [13, 2, 0.4473, 0.0021, 2, 0.27, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L214_C4", "label": "get_absolute_url", "type": "function", "loc": [214, 215], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.4525, 0.0042, 1, 0.59, 0.4848, 276, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "get_absolute_url", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_absolute_url(self):\n return \"/users/%s/\" % urllib.quote(smart_str(self.username))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L215_C8", "label": "return", "type": "return", "loc": [215, 215], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L214_C4", "vector": [13, 2, 0.4536, 0.0021, 2, 0.81, 0.0, 0, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"/users/%s/\" % urllib.quote(smart_str(self.username))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L217_C4", "label": "is_anonymous", "type": "function", "loc": [217, 222], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.4631, 0.0127, 1, 0.59, 0.5152, 814, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "is_anonymous", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def is_anonymous(self):\n \"\"\"\n Always returns False. This is a way of comparing User objects to\n anonymous users.\n \"\"\"\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L218_C8", "label": "expression", "type": "expression", "loc": [218, 221], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L217_C4", "vector": [8, 2, 0.4631, 0.0084, 2, 0.84, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Always returns False. This is a way of comparing User objects to\n anonymous users.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L222_C8", "label": "return", "type": "return", "loc": [222, 222], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L217_C4", "vector": [13, 2, 0.4684, 0.0021, 2, 0.84, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L224_C4", "label": "is_authenticated", "type": "function", "loc": [224, 229], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.4778, 0.0127, 1, 0.59, 0.5455, 458, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "is_authenticated", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def is_authenticated(self):\n \"\"\"\n Always return True. This is a way to tell if the user has been\n authenticated in templates.\n \"\"\"\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L225_C8", "label": "expression", "type": "expression", "loc": [225, 228], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L224_C4", "vector": [8, 2, 0.4778, 0.0084, 2, 0.77, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Always return True. This is a way to tell if the user has been\n authenticated in templates.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L229_C8", "label": "return", "type": "return", "loc": [229, 229], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L224_C4", "vector": [13, 2, 0.4831, 0.0021, 2, 0.77, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L231_C4", "label": "get_full_name", "type": "function", "loc": [231, 234], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.4905, 0.0084, 1, 0.59, 0.5758, 822, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "get_full_name", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_full_name(self):\n \"Returns the first_name plus the last_name, with a space in between.\"\n full_name = u'%s %s' % (self.first_name, self.last_name)\n return full_name.strip()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L232_C8", "label": "expression", "type": "expression", "loc": [232, 232], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L231_C4", "vector": [8, 2, 0.4895, 0.0021, 2, 0.77, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the first_name plus the last_name, with a space in between.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L233_C8", "label": "full_name =", "type": "assigned_variable", "loc": [233, 233], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L231_C4", "vector": [14, 2, 0.4916, 0.0021, 2, 0.77, 0.5, 869, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "full_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " full_name = u'%s %s' % (self.first_name, self.last_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L234_C8", "label": "return", "type": "return", "loc": [234, 234], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L231_C4", "vector": [13, 2, 0.4937, 0.0021, 2, 0.77, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return full_name.strip()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L236_C4", "label": "set_password", "type": "function", "loc": [236, 244], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.5063, 0.019, 1, 0.59, 0.6061, 803, 0, 2, 0, 0, 0, 0, 7], "semantic": {"name": "set_password", "arg_names": ["self", "raw_password"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def set_password(self, raw_password):\n if raw_password is None:\n self.set_unusable_password()\n else:\n import random\n algo = 'sha1'\n salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]\n hsh = get_hexdigest(algo, salt, raw_password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "label": "if", "type": "if", "loc": [237, 244], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L236_C4", "vector": [4, 2, 0.5074, 0.0169, 2, 0.86, 0.0, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if raw_password is None:\n self.set_unusable_password()\n else:\n import random\n algo = 'sha1'\n salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]\n hsh = get_hexdigest(algo, salt, raw_password)\n self.password = '%s$%s$%s' % (algo, salt, hsh)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L238_C12", "label": "set_unusable_password()", "type": "expression", "loc": [238, 238], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "vector": [8, 3, 0.5021, 0.0021, 3, 0.37, 0.0, 733, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "set_unusable_password", "arg_names": [], "import_names": [], "rhs_call_name": "set_unusable_password", "annotation": ""}, "snippet": " self.set_unusable_password()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Import_L240_C12", "label": "random import random", "type": "import", "loc": [240, 240], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "vector": [1, 3, 0.5063, 0.0021, 3, 0.37, 0.2, 715, 0, 1, 0, 0, 715, 0, 0], "semantic": {"name": "random", "arg_names": [], "import_names": ["random"], "rhs_call_name": "", "annotation": ""}, "snippet": " import random"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L241_C12", "label": "algo =", "type": "assigned_variable", "loc": [241, 241], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "vector": [14, 3, 0.5084, 0.0021, 3, 0.37, 0.4, 641, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "algo", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " algo = 'sha1'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L242_C12", "label": "salt =", "type": "assigned_variable", "loc": [242, 242], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "vector": [14, 3, 0.5105, 0.0021, 3, 0.37, 0.6, 153, 6, 0, 0, 0, 0, 0, 5], "semantic": {"name": "salt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L243_C12", "label": "hsh = get_hexdigest()", "type": "assigned_variable", "loc": [243, 243], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "vector": [14, 3, 0.5127, 0.0021, 3, 0.37, 0.8, 230, 3, 3, 0, 0, 706, 10, 1], "semantic": {"name": "hsh", "arg_names": [], "import_names": [], "rhs_call_name": "get_hexdigest", "annotation": ""}, "snippet": " hsh = get_hexdigest(algo, salt, raw_password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L244_C12", "label": "self.password =", "type": "assigned_variable", "loc": [244, 244], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "vector": [14, 3, 0.5148, 0.0021, 3, 0.37, 1.0, 902, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.password", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.password = '%s$%s$%s' % (algo, salt, hsh)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L246_C4", "label": "check_password", "type": "function", "loc": [246, 260], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.5338, 0.0316, 1, 0.59, 0.6364, 645, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "check_password", "arg_names": ["self", "raw_password"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def check_password(self, raw_password):\n \"\"\"\n Returns a boolean of whether the raw_password was correct. Handles\n encryption formats behind the scenes.\n \"\"\"\n # Backwards-compatibility check. Older passwords won't include the\n # algorithm or salt.\n if '$' not in self.password:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L247_C8", "label": "expression", "type": "expression", "loc": [247, 250], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L246_C4", "vector": [8, 2, 0.5243, 0.0084, 2, 0.36, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a boolean of whether the raw_password was correct. Handles\n encryption formats behind the scenes.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L253_C8", "label": "if", "type": "if", "loc": [253, 259], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L246_C4", "vector": [4, 2, 0.5401, 0.0148, 2, 0.36, 0.5, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if '$' not in self.password:\n is_correct = (self.password == get_hexdigest('md5', '', raw_password))\n if is_correct:\n # Convert the password to the new, more secure format.\n self.set_password(raw_password)\n self.save()\n return is_correct"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L254_C12", "label": "is_correct =", "type": "assigned_variable", "loc": [254, 254], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L253_C8", "vector": [14, 3, 0.5359, 0.0021, 3, 0.34, 0.0, 101, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "is_correct", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " is_correct = (self.password == get_hexdigest('md5', '', raw_password))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L255_C12", "label": "if", "type": "if", "loc": [255, 258], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L253_C8", "vector": [4, 3, 0.5411, 0.0084, 3, 0.34, 0.5, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if is_correct:\n # Convert the password to the new, more secure format.\n self.set_password(raw_password)\n self.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L257_C16", "label": "set_password()", "type": "expression", "loc": [257, 257], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L255_C12", "vector": [8, 4, 0.5422, 0.0021, 4, 0.38, 0.0, 803, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "set_password", "arg_names": [], "import_names": [], "rhs_call_name": "set_password", "annotation": ""}, "snippet": " self.set_password(raw_password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L258_C16", "label": "save()", "type": "expression", "loc": [258, 258], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L255_C12", "vector": [8, 4, 0.5443, 0.0021, 4, 0.38, 1.0, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " self.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L259_C12", "label": "return", "type": "return", "loc": [259, 259], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L253_C8", "vector": [13, 3, 0.5464, 0.0021, 3, 0.34, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return is_correct"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L260_C8", "label": "return", "type": "return", "loc": [260, 260], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L246_C4", "vector": [13, 2, 0.5485, 0.0021, 2, 0.36, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return check_password(raw_password, self.password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L262_C4", "label": "set_unusable_password", "type": "function", "loc": [262, 264], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.5549, 0.0063, 1, 0.59, 0.6667, 733, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "set_unusable_password", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def set_unusable_password(self):\n # Sets a value that will never be a valid hash\n self.password = UNUSABLE_PASSWORD"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L264_C8", "label": "self.password =", "type": "assigned_variable", "loc": [264, 264], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L262_C4", "vector": [14, 2, 0.557, 0.0021, 2, 0.91, 0.0, 902, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.password", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.password = UNUSABLE_PASSWORD"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L266_C4", "label": "has_usable_password", "type": "function", "loc": [266, 271], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.5665, 0.0127, 1, 0.59, 0.697, 887, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "has_usable_password", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_usable_password(self):\n if self.password is None \\\n or self.password == UNUSABLE_PASSWORD:\n return False\n else:\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L267_C8", "label": "if", "type": "if", "loc": [267, 271], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L266_C4", "vector": [4, 2, 0.5675, 0.0105, 2, 0.26, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.password is None \\\n or self.password == UNUSABLE_PASSWORD:\n return False\n else:\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L269_C12", "label": "return", "type": "return", "loc": [269, 269], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L267_C8", "vector": [13, 3, 0.5675, 0.0021, 3, 0.63, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L271_C12", "label": "return", "type": "return", "loc": [271, 271], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L267_C8", "vector": [13, 3, 0.5717, 0.0021, 3, 0.63, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L273_C4", "label": "get_group_permissions", "type": "function", "loc": [273, 290], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.5939, 0.038, 1, 0.59, 0.7273, 228, 0, 2, 1, 0, 0, 0, 7], "semantic": {"name": "get_group_permissions", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_group_permissions(self, obj=None):\n \"\"\"\n Returns a list of permission strings that this user has through\n his/her groups. This method queries all available auth backends.\n If an object is passed in, only permissions matching this object\n are returned.\n \"\"\"\n permissions = set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L274_C8", "label": "expression", "type": "expression", "loc": [274, 279], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L273_C4", "vector": [8, 2, 0.5833, 0.0127, 2, 0.11, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a list of permission strings that this user has through\n his/her groups. This method queries all available auth backends.\n If an object is passed in, only permissions matching this object\n are returned.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L280_C8", "label": "permissions = set()", "type": "assigned_variable", "loc": [280, 280], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L273_C4", "vector": [14, 2, 0.5907, 0.0021, 2, 0.11, 0.3333, 503, 3, 0, 0, 0, 21, 10, 1], "semantic": {"name": "permissions", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " permissions = set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L281_C8", "label": "for backend", "type": "for", "loc": [281, 289], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L273_C4", "vector": [6, 2, 0.6013, 0.019, 2, 0.11, 0.6667, 631, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "backend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for backend in auth.get_backends():\n if hasattr(backend, \"get_group_permissions\"):\n if obj is not None:\n if backend.supports_object_permissions:\n permissions.update(\n backend.get_group_permissions(self, obj)\n )\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L282_C12", "label": "if", "type": "if", "loc": [282, 289], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L281_C8", "vector": [4, 3, 0.6023, 0.0169, 3, 0.37, 0.0, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(backend, \"get_group_permissions\"):\n if obj is not None:\n if backend.supports_object_permissions:\n permissions.update(\n backend.get_group_permissions(self, obj)\n )\n else:\n permissions.update(backend.get_group_permissions(self))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L283_C16", "label": "if", "type": "if", "loc": [283, 289], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L282_C12", "vector": [4, 4, 0.6034, 0.0148, 4, 0.16, 0.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if obj is not None:\n if backend.supports_object_permissions:\n permissions.update(\n backend.get_group_permissions(self, obj)\n )\n else:\n permissions.update(backend.get_group_permissions(self))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L284_C20", "label": "if", "type": "if", "loc": [284, 287], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L283_C16", "vector": [4, 5, 0.6023, 0.0084, 5, 0.42, 0.0, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if backend.supports_object_permissions:\n permissions.update(\n backend.get_group_permissions(self, obj)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L285_C24", "label": "update()", "type": "expression", "loc": [285, 287], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L284_C20", "vector": [8, 6, 0.6034, 0.0063, 6, 0.21, 0.0, 637, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " permissions.update(\n backend.get_group_permissions(self, obj)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L289_C20", "label": "update()", "type": "expression", "loc": [289, 289], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L283_C16", "vector": [8, 5, 0.6097, 0.0021, 5, 0.42, 1.0, 637, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " permissions.update(backend.get_group_permissions(self))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L290_C8", "label": "return", "type": "return", "loc": [290, 290], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L273_C4", "vector": [13, 2, 0.6118, 0.0021, 2, 0.11, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return permissions"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L292_C4", "label": "get_all_permissions", "type": "function", "loc": [292, 293], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.6171, 0.0042, 1, 0.59, 0.7576, 669, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "get_all_permissions", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_all_permissions(self, obj=None):\n return _user_get_all_permissions(self, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L293_C8", "label": "return", "type": "return", "loc": [293, 293], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L292_C4", "vector": [13, 2, 0.6181, 0.0021, 2, 0.64, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _user_get_all_permissions(self, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L295_C4", "label": "has_perm", "type": "function", "loc": [295, 312], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.6403, 0.038, 1, 0.59, 0.7879, 674, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "has_perm", "arg_names": ["self", "perm", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_perm(self, perm, obj=None):\n \"\"\"\n Returns True if the user has the specified permission. This method\n queries all available auth backends, but returns immediately if any\n backend returns True. Thus, a user who has permission from a single\n auth backend is assumed to have permission in general. If an object\n is provided, permissions for this specific object are checked.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L296_C8", "label": "expression", "type": "expression", "loc": [296, 302], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L295_C4", "vector": [8, 2, 0.6308, 0.0148, 2, 0.27, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns True if the user has the specified permission. This method\n queries all available auth backends, but returns immediately if any\n backend returns True. Thus, a user who has permission from a single\n auth backend is assumed to have permission in general. If an object\n is provided, permissions for this specific object are checked.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L304_C8", "label": "if", "type": "if", "loc": [304, 305], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L295_C4", "vector": [4, 2, 0.6424, 0.0042, 2, 0.27, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.is_active:\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L305_C12", "label": "return", "type": "return", "loc": [305, 305], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L304_C8", "vector": [13, 3, 0.6435, 0.0021, 3, 0.6, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L308_C8", "label": "if", "type": "if", "loc": [308, 309], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L295_C4", "vector": [4, 2, 0.6508, 0.0042, 2, 0.27, 0.6667, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.is_superuser:\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L309_C12", "label": "return", "type": "return", "loc": [309, 309], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L308_C8", "vector": [13, 3, 0.6519, 0.0021, 3, 0.02, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L312_C8", "label": "return", "type": "return", "loc": [312, 312], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L295_C4", "vector": [13, 2, 0.6582, 0.0021, 2, 0.27, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _user_has_perm(self, perm, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L314_C4", "label": "has_perms", "type": "function", "loc": [314, 323], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.6719, 0.0211, 1, 0.59, 0.8182, 55, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "has_perms", "arg_names": ["self", "perm_list", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_perms(self, perm_list, obj=None):\n \"\"\"\n Returns True if the user has each of the specified permissions.\n If object is passed, it checks if the user has all required perms\n for this object.\n \"\"\"\n for perm in perm_list:\n if not self.has_perm(perm, obj):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L315_C8", "label": "expression", "type": "expression", "loc": [315, 319], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L314_C4", "vector": [8, 2, 0.6688, 0.0105, 2, 0.29, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns True if the user has each of the specified permissions.\n If object is passed, it checks if the user has all required perms\n for this object.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L320_C8", "label": "for perm", "type": "for", "loc": [320, 322], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L314_C4", "vector": [6, 2, 0.6772, 0.0063, 2, 0.29, 0.5, 339, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "perm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for perm in perm_list:\n if not self.has_perm(perm, obj):\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L321_C12", "label": "if", "type": "if", "loc": [321, 322], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L320_C8", "vector": [4, 3, 0.6783, 0.0042, 3, 0.27, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.has_perm(perm, obj):\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L322_C16", "label": "return", "type": "return", "loc": [322, 322], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L321_C12", "vector": [13, 4, 0.6793, 0.0021, 4, 0.99, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L323_C8", "label": "return", "type": "return", "loc": [323, 323], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L314_C4", "vector": [13, 2, 0.6814, 0.0021, 2, 0.29, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L325_C4", "label": "has_module_perms", "type": "function", "loc": [325, 336], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.6973, 0.0253, 1, 0.59, 0.8485, 249, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "has_module_perms", "arg_names": ["self", "app_label"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_module_perms(self, app_label):\n \"\"\"\n Returns True if the user has any permissions in the given app\n label. Uses pretty much the same logic as has_perm, above.\n \"\"\"\n if not self.is_active:\n return False\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L326_C8", "label": "expression", "type": "expression", "loc": [326, 329], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L325_C4", "vector": [8, 2, 0.6909, 0.0084, 2, 0.79, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns True if the user has any permissions in the given app\n label. Uses pretty much the same logic as has_perm, above.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L330_C8", "label": "if", "type": "if", "loc": [330, 331], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L325_C4", "vector": [4, 2, 0.6973, 0.0042, 2, 0.79, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.is_active:\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L331_C12", "label": "return", "type": "return", "loc": [331, 331], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L330_C8", "vector": [13, 3, 0.6983, 0.0021, 3, 0.52, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L333_C8", "label": "if", "type": "if", "loc": [333, 334], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L325_C4", "vector": [4, 2, 0.7036, 0.0042, 2, 0.79, 0.6667, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.is_superuser:\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L334_C12", "label": "return", "type": "return", "loc": [334, 334], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L333_C8", "vector": [13, 3, 0.7046, 0.0021, 3, 0.13, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L336_C8", "label": "return", "type": "return", "loc": [336, 336], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L325_C4", "vector": [13, 2, 0.7089, 0.0021, 2, 0.79, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _user_has_module_perms(self, app_label)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L338_C4", "label": "get_and_delete_messages", "type": "function", "loc": [338, 343], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.7184, 0.0127, 1, 0.59, 0.8788, 980, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "get_and_delete_messages", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_and_delete_messages(self):\n messages = []\n for m in self.message_set.all():\n messages.append(m.message)\n m.delete()\n return messages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L339_C8", "label": "messages =", "type": "assigned_variable", "loc": [339, 339], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L338_C4", "vector": [14, 2, 0.7152, 0.0021, 2, 0.81, 0.0, 312, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "messages", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " messages = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L340_C8", "label": "for m", "type": "for", "loc": [340, 342], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L338_C4", "vector": [6, 2, 0.7194, 0.0063, 2, 0.81, 0.5, 711, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "m", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for m in self.message_set.all():\n messages.append(m.message)\n m.delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L341_C12", "label": "append()", "type": "expression", "loc": [341, 341], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L340_C8", "vector": [8, 3, 0.7194, 0.0021, 3, 0.79, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " messages.append(m.message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L342_C12", "label": "delete()", "type": "expression", "loc": [342, 342], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L340_C8", "vector": [8, 3, 0.7215, 0.0021, 3, 0.79, 1.0, 266, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " m.delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L343_C8", "label": "return", "type": "return", "loc": [343, 343], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L338_C4", "vector": [13, 2, 0.7236, 0.0021, 2, 0.81, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return messages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L345_C4", "label": "email_user", "type": "function", "loc": [345, 348], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.731, 0.0084, 1, 0.59, 0.9091, 47, 0, 4, 0, 0, 0, 0, 1], "semantic": {"name": "email_user", "arg_names": ["self", "subject", "message", "from_email"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def email_user(self, subject, message, from_email=None):\n \"Sends an e-mail to this User.\"\n from django.core.mail import send_mail\n send_mail(subject, message, from_email, [self.email])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L346_C8", "label": "expression", "type": "expression", "loc": [346, 346], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L345_C4", "vector": [8, 2, 0.73, 0.0021, 2, 0.46, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Sends an e-mail to this User.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L347_C8", "label": "from django.core.mail import send_mail", "type": "import", "loc": [347, 347], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L345_C4", "vector": [1, 2, 0.7321, 0.0021, 2, 0.46, 0.5, 537, 0, 1, 0, 0, 537, 0, 0], "semantic": {"name": "django.core.mail", "arg_names": [], "import_names": ["send_mail"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.core.mail import send_mail"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L348_C8", "label": "send_mail()", "type": "expression", "loc": [348, 348], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L345_C4", "vector": [8, 2, 0.7342, 0.0021, 2, 0.46, 1.0, 975, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "send_mail", "arg_names": [], "import_names": [], "rhs_call_name": "send_mail", "annotation": ""}, "snippet": " send_mail(subject, message, from_email, [self.email])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L350_C4", "label": "get_profile", "type": "function", "loc": [350, 377], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.7669, 0.0591, 1, 0.59, 0.9394, 956, 0, 1, 1, 0, 0, 0, 9], "semantic": {"name": "get_profile", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_profile(self):\n \"\"\"\n Returns site-specific profile for this user. Raises\n SiteProfileNotAvailable if this site does not allow profiles.\n \"\"\"\n if not hasattr(self, '_profile_cache'):\n from django.conf import settings\n if not getattr(settings, 'AUTH_PROFILE_MODULE', False):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L351_C8", "label": "expression", "type": "expression", "loc": [351, 354], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L350_C4", "vector": [8, 2, 0.7437, 0.0084, 2, 0.74, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns site-specific profile for this user. Raises\n SiteProfileNotAvailable if this site does not allow profiles.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L355_C8", "label": "if", "type": "if", "loc": [355, 376], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L350_C4", "vector": [4, 2, 0.7711, 0.0464, 2, 0.74, 0.5, 0, 0, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(self, '_profile_cache'):\n from django.conf import settings\n if not getattr(settings, 'AUTH_PROFILE_MODULE', False):\n raise SiteProfileNotAvailable('You need to set AUTH_PROFILE_MO'\n 'DULE in your project settings')\n try:\n app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.')\n except ValueError:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L356_C12", "label": "from django.conf import settings", "type": "import", "loc": [356, 356], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L355_C8", "vector": [1, 3, 0.7511, 0.0021, 3, 0.89, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L357_C12", "label": "if", "type": "if", "loc": [357, 359], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L355_C8", "vector": [4, 3, 0.7553, 0.0063, 3, 0.89, 0.3333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not getattr(settings, 'AUTH_PROFILE_MODULE', False):\n raise SiteProfileNotAvailable('You need to set AUTH_PROFILE_MO'\n 'DULE in your project settings')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L360_C12", "label": "try", "type": "try", "loc": [360, 365], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L355_C8", "vector": [7, 3, 0.7648, 0.0127, 3, 0.89, 0.6667, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.')\n except ValueError:\n raise SiteProfileNotAvailable('app_label and model_name should'\n ' be separated by a dot in the AUTH_PROFILE_MODULE set'\n 'ting')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L361_C16", "label": "app_label, model_name = split()", "type": "assigned_variable", "loc": [361, 361], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L360_C12", "vector": [14, 4, 0.7616, 0.0021, 4, 0.11, 0.0, 388, 3, 1, 0, 0, 908, 10, 1], "semantic": {"name": "app_label, model_name", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L367_C12", "label": "try", "type": "try", "loc": [367, 376], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L355_C8", "vector": [7, 3, 0.7838, 0.0211, 3, 0.89, 1.0, 0, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n model = models.get_model(app_label, model_name)\n if model is None:\n raise SiteProfileNotAvailable('Unable to load the profile '\n 'model, check AUTH_PROFILE_MODULE in your project sett'\n 'ings')\n self._profile_cache = model._default_manager.using(self._state.db).get(user__id__exact=self.id)\n self._profile_cache.user = self"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L368_C16", "label": "model = get_model()", "type": "assigned_variable", "loc": [368, 368], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L367_C12", "vector": [14, 4, 0.7764, 0.0021, 4, 0.33, 0.0, 722, 3, 2, 0, 0, 115, 10, 1], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "get_model", "annotation": ""}, "snippet": " model = models.get_model(app_label, model_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L369_C16", "label": "if", "type": "if", "loc": [369, 372], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L367_C12", "vector": [4, 4, 0.7816, 0.0084, 4, 0.33, 0.3333, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if model is None:\n raise SiteProfileNotAvailable('Unable to load the profile '\n 'model, check AUTH_PROFILE_MODULE in your project sett'\n 'ings')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L373_C16", "label": "self._profile_cache = get()", "type": "assigned_variable", "loc": [373, 373], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L367_C12", "vector": [14, 4, 0.7869, 0.0021, 4, 0.33, 0.6667, 104, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "self._profile_cache", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " self._profile_cache = model._default_manager.using(self._state.db).get(user__id__exact=self.id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L374_C16", "label": "self._profile_cache.user =", "type": "assigned_variable", "loc": [374, 374], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L367_C12", "vector": [14, 4, 0.789, 0.0021, 4, 0.33, 1.0, 118, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._profile_cache.user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._profile_cache.user = self"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L377_C8", "label": "return", "type": "return", "loc": [377, 377], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L350_C4", "vector": [13, 2, 0.7954, 0.0021, 2, 0.74, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._profile_cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L379_C4", "label": "_get_message_set", "type": "function", "loc": [379, 384], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [2, 1, 0.8049, 0.0127, 1, 0.59, 0.9697, 958, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "_get_message_set", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_message_set(self):\n import warnings\n warnings.warn('The user messaging API is deprecated. Please update'\n ' your code to use the new messages framework.',\n category=DeprecationWarning)\n return self._message_set"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Import_L380_C8", "label": "warnings import warnings", "type": "import", "loc": [380, 380], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L379_C4", "vector": [1, 2, 0.8017, 0.0021, 2, 0.51, 0.0, 358, 0, 1, 0, 0, 358, 0, 0], "semantic": {"name": "warnings", "arg_names": [], "import_names": ["warnings"], "rhs_call_name": "", "annotation": ""}, "snippet": " import warnings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L381_C8", "label": "warn()", "type": "expression", "loc": [381, 383], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L379_C4", "vector": [8, 2, 0.8059, 0.0063, 2, 0.51, 0.5, 960, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "warn", "arg_names": [], "import_names": [], "rhs_call_name": "warn", "annotation": ""}, "snippet": " warnings.warn('The user messaging API is deprecated. Please update'\n ' your code to use the new messages framework.',\n category=DeprecationWarning)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L384_C8", "label": "return", "type": "return", "loc": [384, 384], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L379_C4", "vector": [13, 2, 0.8101, 0.0021, 2, 0.51, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._message_set"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L385_C4", "label": "message_set = property()", "type": "assigned_variable", "loc": [385, 385], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "vector": [14, 1, 0.8122, 0.0021, 1, 0.59, 1.0, 527, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "message_set", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " message_set = property(_get_message_set)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L387_C0", "label": "Message", "type": "class", "loc": [387, 400], "level": 0, "parent": null, "vector": [3, 0, 0.8302, 0.0295, 0, 0.66, 0.9565, 6, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "Message", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Message(models.Model):\n \"\"\"\n The message system is a lightweight way to queue messages for given\n users. A message is associated with a User instance (so it is only\n applicable for registered users). There's no concept of expiration or\n timestamps. Messages are created by the Django admin after successful\n actions. For example, \"The poll Foo was created successfully.\" is a\n message."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L388_C4", "label": "expression", "type": "expression", "loc": [388, 395], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L387_C0", "vector": [8, 1, 0.8259, 0.0169, 1, 0.88, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n The message system is a lightweight way to queue messages for given\n users. A message is associated with a User instance (so it is only\n applicable for registered users). There's no concept of expiration or\n timestamps. Messages are created by the Django admin after successful\n actions. For example, \"The poll Foo was created successfully.\" is a\n message.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L396_C4", "label": "user = ForeignKey()", "type": "assigned_variable", "loc": [396, 396], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L387_C0", "vector": [14, 1, 0.8354, 0.0021, 1, 0.88, 0.3333, 503, 3, 2, 0, 0, 140, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "ForeignKey", "annotation": ""}, "snippet": " user = models.ForeignKey(User, related_name='_message_set')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L397_C4", "label": "message = TextField()", "type": "assigned_variable", "loc": [397, 397], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L387_C0", "vector": [14, 1, 0.8376, 0.0021, 1, 0.88, 0.6667, 635, 3, 1, 0, 0, 612, 10, 2], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "TextField", "annotation": ""}, "snippet": " message = models.TextField(_('message'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L399_C4", "label": "__unicode__", "type": "function", "loc": [399, 400], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L387_C0", "vector": [2, 1, 0.8428, 0.0042, 1, 0.88, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return self.message"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L400_C8", "label": "return", "type": "return", "loc": [400, 400], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L399_C4", "vector": [13, 2, 0.8439, 0.0021, 2, 0.27, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.message"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "label": "AnonymousUser", "type": "class", "loc": [402, 474], "level": 0, "parent": null, "vector": [3, 0, 0.9241, 0.154, 0, 0.66, 1.0, 185, 0, 20, 0, 0, 186, 0, 13], "semantic": {"name": "AnonymousUser", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AnonymousUser(object):\n id = None\n username = ''\n is_staff = False\n is_active = False\n is_superuser = False\n _groups = EmptyManager()\n _user_permissions = EmptyManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L403_C4", "label": "id =", "type": "assigned_variable", "loc": [403, 403], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [14, 1, 0.8502, 0.0021, 1, 0.5, 0.0, 941, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "id", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " id = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L404_C4", "label": "username =", "type": "assigned_variable", "loc": [404, 404], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [14, 1, 0.8523, 0.0021, 1, 0.5, 0.0357, 718, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " username = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L405_C4", "label": "is_staff =", "type": "assigned_variable", "loc": [405, 405], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [14, 1, 0.8544, 0.0021, 1, 0.5, 0.0714, 212, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "is_staff", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " is_staff = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L406_C4", "label": "is_active =", "type": "assigned_variable", "loc": [406, 406], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [14, 1, 0.8565, 0.0021, 1, 0.5, 0.1071, 645, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "is_active", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " is_active = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L407_C4", "label": "is_superuser =", "type": "assigned_variable", "loc": [407, 407], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [14, 1, 0.8586, 0.0021, 1, 0.5, 0.1429, 358, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "is_superuser", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " is_superuser = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L408_C4", "label": "_groups = EmptyManager()", "type": "assigned_variable", "loc": [408, 408], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [14, 1, 0.8608, 0.0021, 1, 0.5, 0.1786, 100, 3, 0, 0, 0, 207, 10, 1], "semantic": {"name": "_groups", "arg_names": [], "import_names": [], "rhs_call_name": "EmptyManager", "annotation": ""}, "snippet": " _groups = EmptyManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L409_C4", "label": "_user_permissions = EmptyManager()", "type": "assigned_variable", "loc": [409, 409], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [14, 1, 0.8629, 0.0021, 1, 0.5, 0.2143, 108, 3, 0, 0, 0, 207, 10, 1], "semantic": {"name": "_user_permissions", "arg_names": [], "import_names": [], "rhs_call_name": "EmptyManager", "annotation": ""}, "snippet": " _user_permissions = EmptyManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L411_C4", "label": "__init__", "type": "function", "loc": [411, 412], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.8681, 0.0042, 1, 0.5, 0.25, 555, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L414_C4", "label": "__unicode__", "type": "function", "loc": [414, 415], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.8745, 0.0042, 1, 0.5, 0.2857, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return 'AnonymousUser'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L415_C8", "label": "return", "type": "return", "loc": [415, 415], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L414_C4", "vector": [13, 2, 0.8755, 0.0021, 2, 0.43, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 'AnonymousUser'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L417_C4", "label": "__str__", "type": "function", "loc": [417, 418], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.8808, 0.0042, 1, 0.5, 0.3214, 527, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "__str__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __str__(self):\n return unicode(self).encode('utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L418_C8", "label": "return", "type": "return", "loc": [418, 418], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L417_C4", "vector": [13, 2, 0.8819, 0.0021, 2, 0.34, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return unicode(self).encode('utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L420_C4", "label": "__eq__", "type": "function", "loc": [420, 421], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.8871, 0.0042, 1, 0.5, 0.3571, 763, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "__eq__", "arg_names": ["self", "other"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __eq__(self, other):\n return isinstance(other, self.__class__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L421_C8", "label": "return", "type": "return", "loc": [421, 421], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L420_C4", "vector": [13, 2, 0.8882, 0.0021, 2, 0.88, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return isinstance(other, self.__class__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L423_C4", "label": "__ne__", "type": "function", "loc": [423, 424], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.8935, 0.0042, 1, 0.5, 0.3929, 254, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "__ne__", "arg_names": ["self", "other"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __ne__(self, other):\n return not self.__eq__(other)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L424_C8", "label": "return", "type": "return", "loc": [424, 424], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L423_C4", "vector": [13, 2, 0.8945, 0.0021, 2, 0.17, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return not self.__eq__(other)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L426_C4", "label": "__hash__", "type": "function", "loc": [426, 427], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.8998, 0.0042, 1, 0.5, 0.4286, 49, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__hash__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __hash__(self):\n return 1 # instances always return the same hash value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L427_C8", "label": "return", "type": "return", "loc": [427, 427], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L426_C4", "vector": [13, 2, 0.9008, 0.0021, 2, 0.89, 0.0, 0, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 1 # instances always return the same hash value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L429_C4", "label": "save", "type": "function", "loc": [429, 430], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.9061, 0.0042, 1, 0.5, 0.4643, 928, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "save", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save(self):\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L432_C4", "label": "delete", "type": "function", "loc": [432, 433], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.9124, 0.0042, 1, 0.5, 0.5, 266, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "delete", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def delete(self):\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L435_C4", "label": "set_password", "type": "function", "loc": [435, 436], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.9188, 0.0042, 1, 0.5, 0.5357, 803, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "set_password", "arg_names": ["self", "raw_password"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def set_password(self, raw_password):\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L438_C4", "label": "check_password", "type": "function", "loc": [438, 439], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.9251, 0.0042, 1, 0.5, 0.5714, 645, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "check_password", "arg_names": ["self", "raw_password"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def check_password(self, raw_password):\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L441_C4", "label": "_get_groups", "type": "function", "loc": [441, 442], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.9314, 0.0042, 1, 0.5, 0.6071, 247, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "_get_groups", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_groups(self):\n return self._groups"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L442_C8", "label": "return", "type": "return", "loc": [442, 442], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L441_C4", "vector": [13, 2, 0.9325, 0.0021, 2, 0.22, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._groups"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L443_C4", "label": "groups = property()", "type": "assigned_variable", "loc": [443, 443], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [14, 1, 0.9346, 0.0021, 1, 0.5, 0.6429, 161, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "groups", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " groups = property(_get_groups)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L445_C4", "label": "_get_user_permissions", "type": "function", "loc": [445, 446], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.9399, 0.0042, 1, 0.5, 0.6786, 528, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "_get_user_permissions", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_user_permissions(self):\n return self._user_permissions"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L446_C8", "label": "return", "type": "return", "loc": [446, 446], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L445_C4", "vector": [13, 2, 0.9409, 0.0021, 2, 0.95, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._user_permissions"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L447_C4", "label": "user_permissions = property()", "type": "assigned_variable", "loc": [447, 447], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [14, 1, 0.943, 0.0021, 1, 0.5, 0.7143, 177, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "user_permissions", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " user_permissions = property(_get_user_permissions)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L449_C4", "label": "get_group_permissions", "type": "function", "loc": [449, 450], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.9483, 0.0042, 1, 0.5, 0.75, 228, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "get_group_permissions", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_group_permissions(self, obj=None):\n return set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L450_C8", "label": "return", "type": "return", "loc": [450, 450], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L449_C4", "vector": [13, 2, 0.9494, 0.0021, 2, 0.47, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L452_C4", "label": "get_all_permissions", "type": "function", "loc": [452, 453], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.9546, 0.0042, 1, 0.5, 0.7857, 669, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "get_all_permissions", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_all_permissions(self, obj=None):\n return _user_get_all_permissions(self, obj=obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L453_C8", "label": "return", "type": "return", "loc": [453, 453], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L452_C4", "vector": [13, 2, 0.9557, 0.0021, 2, 0.99, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _user_get_all_permissions(self, obj=obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L455_C4", "label": "has_perm", "type": "function", "loc": [455, 456], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.961, 0.0042, 1, 0.5, 0.8214, 674, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "has_perm", "arg_names": ["self", "perm", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_perm(self, perm, obj=None):\n return _user_has_perm(self, perm, obj=obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L456_C8", "label": "return", "type": "return", "loc": [456, 456], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L455_C4", "vector": [13, 2, 0.962, 0.0021, 2, 0.25, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _user_has_perm(self, perm, obj=obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L458_C4", "label": "has_perms", "type": "function", "loc": [458, 462], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.9705, 0.0105, 1, 0.5, 0.8571, 55, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "has_perms", "arg_names": ["self", "perm_list", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_perms(self, perm_list, obj=None):\n for perm in perm_list:\n if not self.has_perm(perm, obj):\n return False\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L459_C8", "label": "for perm", "type": "for", "loc": [459, 461], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L458_C4", "vector": [6, 2, 0.9705, 0.0063, 2, 0.43, 0.0, 339, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "perm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for perm in perm_list:\n if not self.has_perm(perm, obj):\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L460_C12", "label": "if", "type": "if", "loc": [460, 461], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L459_C8", "vector": [4, 3, 0.9715, 0.0042, 3, 0.11, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.has_perm(perm, obj):\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L461_C16", "label": "return", "type": "return", "loc": [461, 461], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L460_C12", "vector": [13, 4, 0.9726, 0.0021, 4, 0.22, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L462_C8", "label": "return", "type": "return", "loc": [462, 462], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L458_C4", "vector": [13, 2, 0.9747, 0.0021, 2, 0.43, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L464_C4", "label": "has_module_perms", "type": "function", "loc": [464, 465], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.98, 0.0042, 1, 0.5, 0.8929, 249, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "has_module_perms", "arg_names": ["self", "module"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_module_perms(self, module):\n return _user_has_module_perms(self, module)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L465_C8", "label": "return", "type": "return", "loc": [465, 465], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L464_C4", "vector": [13, 2, 0.981, 0.0021, 2, 0.56, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _user_has_module_perms(self, module)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L467_C4", "label": "get_and_delete_messages", "type": "function", "loc": [467, 468], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.9863, 0.0042, 1, 0.5, 0.9286, 980, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "get_and_delete_messages", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_and_delete_messages(self):\n return []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L468_C8", "label": "return", "type": "return", "loc": [468, 468], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L467_C4", "vector": [13, 2, 0.9873, 0.0021, 2, 0.55, 0.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L470_C4", "label": "is_anonymous", "type": "function", "loc": [470, 471], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.9926, 0.0042, 1, 0.5, 0.9643, 814, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "is_anonymous", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def is_anonymous(self):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L471_C8", "label": "return", "type": "return", "loc": [471, 471], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L470_C4", "vector": [13, 2, 0.9937, 0.0021, 2, 0.14, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L473_C4", "label": "is_authenticated", "type": "function", "loc": [473, 474], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "vector": [2, 1, 0.9989, 0.0042, 1, 0.5, 1.0, 458, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "is_authenticated", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def is_authenticated(self):\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L474_C8", "label": "return", "type": "return", "loc": [474, 474], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L473_C4", "vector": [13, 2, 1.0, 0.0021, 2, 0.37, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Import_L24_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L31_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L31_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L46_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L47_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L66_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L68_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L71_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L77_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L83_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L83_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L85_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L88_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L94_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L95_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L97_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L97_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L98_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L97_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L99_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L101_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L101_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L102_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L104_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L106_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L114_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L118_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L120_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L124_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L104_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L129_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L130_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L132_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L128_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L134_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L104_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L136_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L137_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L141_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L146_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L147_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L148_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L148_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L149_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L149_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L150_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L150_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L151_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L151_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L152_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L152_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L153_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L151_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L157_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L158_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L161_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L162_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L161_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L163_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L163_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L164_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L164_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L165_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L165_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L166_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L166_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L167_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L167_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L169_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L166_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L171_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L171_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L172_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L161_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L173_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L176_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L177_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L176_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L178_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L178_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L179_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L179_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L180_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L180_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L181_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L181_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L182_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L176_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L183_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L187_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L192_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L193_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L194_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L195_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L196_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L197_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L198_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L199_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L200_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L201_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L202_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L204_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L205_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L207_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L208_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L209_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L211_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L211_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L212_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L214_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L214_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L215_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L217_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L217_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L218_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L217_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L222_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L224_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L224_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L225_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L224_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L229_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L231_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L231_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L232_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L231_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L233_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L231_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L234_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L236_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L236_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L238_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Import_L240_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L241_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L242_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L243_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L237_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L244_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L246_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L247_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L253_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L253_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L254_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L253_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L255_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L255_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L257_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L255_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L258_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L253_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L259_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L260_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L262_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L262_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L264_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L266_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L267_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L267_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L269_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L267_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L271_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L273_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L274_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L280_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L281_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L281_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L282_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L282_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L283_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L283_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L284_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L284_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L285_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L283_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L289_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L290_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L292_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L292_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L293_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L295_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L295_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L296_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L295_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L304_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L304_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L305_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L295_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L308_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L308_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L309_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L295_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L312_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L314_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L314_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L315_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L314_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L320_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L320_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L321_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L321_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L322_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L314_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L323_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L325_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L325_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L326_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L325_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L330_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L330_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L331_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L325_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L333_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L333_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L334_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L325_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L336_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L338_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L338_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L339_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L338_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L340_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L340_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L341_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L340_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L342_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L338_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L343_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L345_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L345_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L346_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L345_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L347_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L345_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L348_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L350_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L350_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L351_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L350_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L355_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L355_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:ImportFrom_L356_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L355_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L357_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L355_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L360_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L360_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L361_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L355_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L367_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L367_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L368_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L367_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L369_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L367_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L373_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:Try_L367_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L374_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L350_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L377_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L379_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L379_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Import_L380_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L379_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L381_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L379_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L384_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L385_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L387_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Expr_L388_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L387_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L396_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L387_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L397_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L387_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L399_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L399_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L400_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L403_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L404_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L405_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L406_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L407_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L408_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L409_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L411_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L414_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L414_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L415_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L417_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L417_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L418_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L420_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L420_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L421_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L423_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L423_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L424_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L426_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L426_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L427_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L429_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L432_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L435_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L438_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L441_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L441_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L442_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L443_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L445_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L445_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L446_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Assign_L447_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L449_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L449_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L450_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L452_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L452_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L453_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L455_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L455_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L456_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L458_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L458_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L459_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:For_L459_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L460_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:If_L460_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L461_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L458_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L462_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L464_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L464_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L465_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L467_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L467_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L468_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L470_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L470_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L471_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:ClassDef_L402_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L473_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98601:FunctionDef_L473_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98601:Return_L474_C8"}] |
from mod_python import apache
import os
def authenhandler(req, **kwargs):
"""
Authentication handler that checks against Django's auth database.
"""
# mod_python fakes the environ, and thus doesn't process SetEnv. This fixes
# that so that the following import works
os.environ.update(req.subprocess_env)
# apache 2.2 requires a call to req.get_basic_auth_pw() before
# req.user and friends are available.
req.get_basic_auth_pw()
# check for PythonOptions
_str_to_bool = lambda s: s.lower() in ('1', 'true', 'on', 'yes')
options = req.get_options()
permission_name = options.get('DjangoPermissionName', None)
staff_only = _str_to_bool(options.get('DjangoRequireStaffStatus', "on"))
superuser_only = _str_to_bool(options.get('DjangoRequireSuperuserStatus', "off"))
settings_module = options.get('DJANGO_SETTINGS_MODULE', None)
if settings_module:
os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
from django.contrib.auth.models import User
from django import db
db.reset_queries()
# check that the username is valid
kwargs = {'username': req.user, 'is_active': True}
if staff_only:
kwargs['is_staff'] = True
if superuser_only:
kwargs['is_superuser'] = True
try:
try:
user = User.objects.get(**kwargs)
except User.DoesNotExist:
return apache.HTTP_UNAUTHORIZED
# check the password and any permission given
if user.check_password(req.get_basic_auth_pw()):
if permission_name:
if user.has_perm(permission_name):
return apache.OK
else:
return apache.HTTP_UNAUTHORIZED
else:
return apache.OK
else:
return apache.HTTP_UNAUTHORIZED
finally:
db.connection.close()
| ajibawa-2023/Python-Code-Large/train/row_98602 | 34 | 56 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98602:ImportFrom_L1_C0", "label": "from mod_python import apache", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0179, 0.0179, 0, 0.66, 0.0, 889, 0, 1, 0, 0, 889, 0, 0], "semantic": {"name": "mod_python", "arg_names": [], "import_names": ["apache"], "rhs_call_name": "", "annotation": ""}, "snippet": "from mod_python import apache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Import_L2_C0", "label": "os import os", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0357, 0.0179, 0, 0.66, 0.5, 688, 0, 1, 0, 0, 688, 0, 0], "semantic": {"name": "os", "arg_names": [], "import_names": ["os"], "rhs_call_name": "", "annotation": ""}, "snippet": "import os"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "label": "authenhandler", "type": "function", "loc": [4, 56], "level": 0, "parent": null, "vector": [2, 0, 0.5357, 0.9464, 0, 0.66, 1.0, 61, 0, 2, 1, 0, 0, 0, 16], "semantic": {"name": "authenhandler", "arg_names": ["req", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def authenhandler(req, **kwargs):\n \"\"\"\n Authentication handler that checks against Django's auth database.\n \"\"\"\n\n # mod_python fakes the environ, and thus doesn't process SetEnv. This fixes\n # that so that the following import works\n os.environ.update(req.subprocess_env)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Expr_L5_C4", "label": "expression", "type": "expression", "loc": [5, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [8, 1, 0.1071, 0.0536, 1, 0.38, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Authentication handler that checks against Django's auth database.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Expr_L11_C4", "label": "update()", "type": "expression", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [8, 1, 0.1964, 0.0179, 1, 0.38, 0.0625, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " os.environ.update(req.subprocess_env)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Expr_L15_C4", "label": "get_basic_auth_pw()", "type": "expression", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [8, 1, 0.2679, 0.0179, 1, 0.38, 0.125, 39, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "get_basic_auth_pw", "arg_names": [], "import_names": [], "rhs_call_name": "get_basic_auth_pw", "annotation": ""}, "snippet": " req.get_basic_auth_pw()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L18_C4", "label": "_str_to_bool =", "type": "assigned_variable", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [14, 1, 0.3214, 0.0179, 1, 0.38, 0.1875, 559, 9, 0, 0, 0, 0, 0, 1], "semantic": {"name": "_str_to_bool", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " _str_to_bool = lambda s: s.lower() in ('1', 'true', 'on', 'yes')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L20_C4", "label": "options = get_options()", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [14, 1, 0.3571, 0.0179, 1, 0.38, 0.25, 707, 3, 0, 0, 0, 420, 10, 1], "semantic": {"name": "options", "arg_names": [], "import_names": [], "rhs_call_name": "get_options", "annotation": ""}, "snippet": " options = req.get_options()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L21_C4", "label": "permission_name = get()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [14, 1, 0.375, 0.0179, 1, 0.38, 0.3125, 648, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "permission_name", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " permission_name = options.get('DjangoPermissionName', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L22_C4", "label": "staff_only = _str_to_bool()", "type": "assigned_variable", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [14, 1, 0.3929, 0.0179, 1, 0.38, 0.375, 499, 3, 1, 0, 0, 559, 10, 2], "semantic": {"name": "staff_only", "arg_names": [], "import_names": [], "rhs_call_name": "_str_to_bool", "annotation": ""}, "snippet": " staff_only = _str_to_bool(options.get('DjangoRequireStaffStatus', \"on\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L23_C4", "label": "superuser_only = _str_to_bool()", "type": "assigned_variable", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [14, 1, 0.4107, 0.0179, 1, 0.38, 0.4375, 610, 3, 1, 0, 0, 559, 10, 2], "semantic": {"name": "superuser_only", "arg_names": [], "import_names": [], "rhs_call_name": "_str_to_bool", "annotation": ""}, "snippet": " superuser_only = _str_to_bool(options.get('DjangoRequireSuperuserStatus', \"off\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L24_C4", "label": "settings_module = get()", "type": "assigned_variable", "loc": [24, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [14, 1, 0.4286, 0.0179, 1, 0.38, 0.5, 951, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "settings_module", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " settings_module = options.get('DJANGO_SETTINGS_MODULE', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L25_C4", "label": "if", "type": "if", "loc": [25, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [4, 1, 0.4554, 0.0357, 1, 0.38, 0.5625, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if settings_module:\n os.environ['DJANGO_SETTINGS_MODULE'] = settings_module"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L26_C8", "label": "assign", "type": "assigned_variable", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L25_C4", "vector": [14, 2, 0.4643, 0.0179, 2, 0.6, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " os.environ['DJANGO_SETTINGS_MODULE'] = settings_module"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:ImportFrom_L28_C4", "label": "from django.contrib.auth.models import User", "type": "import", "loc": [28, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [1, 1, 0.5, 0.0179, 1, 0.38, 0.625, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.auth.models import User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:ImportFrom_L29_C4", "label": "from django import db", "type": "import", "loc": [29, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [1, 1, 0.5179, 0.0179, 1, 0.38, 0.6875, 294, 0, 1, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["db"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django import db"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Expr_L30_C4", "label": "reset_queries()", "type": "expression", "loc": [30, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [8, 1, 0.5357, 0.0179, 1, 0.38, 0.75, 537, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "reset_queries", "arg_names": [], "import_names": [], "rhs_call_name": "reset_queries", "annotation": ""}, "snippet": " db.reset_queries()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L33_C4", "label": "kwargs =", "type": "assigned_variable", "loc": [33, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [14, 1, 0.5893, 0.0179, 1, 0.38, 0.8125, 987, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "kwargs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs = {'username': req.user, 'is_active': True}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L34_C4", "label": "if", "type": "if", "loc": [34, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [4, 1, 0.6161, 0.0357, 1, 0.38, 0.875, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if staff_only:\n kwargs['is_staff'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L35_C8", "label": "assign", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L34_C4", "vector": [14, 2, 0.625, 0.0179, 2, 0.51, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs['is_staff'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L36_C4", "label": "if", "type": "if", "loc": [36, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [4, 1, 0.6518, 0.0357, 1, 0.38, 0.9375, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if superuser_only:\n kwargs['is_superuser'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L37_C8", "label": "assign", "type": "assigned_variable", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L36_C4", "vector": [14, 2, 0.6607, 0.0179, 2, 0.6, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs['is_superuser'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L38_C4", "label": "try", "type": "try", "loc": [38, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "vector": [7, 1, 0.8393, 0.3393, 1, 0.38, 1.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n try:\n user = User.objects.get(**kwargs)\n except User.DoesNotExist:\n return apache.HTTP_UNAUTHORIZED\n \n # check the password and any permission given\n if user.check_password(req.get_basic_auth_pw()):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L39_C8", "label": "try", "type": "try", "loc": [39, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L38_C4", "vector": [7, 2, 0.7232, 0.0714, 2, 0.33, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n user = User.objects.get(**kwargs)\n except User.DoesNotExist:\n return apache.HTTP_UNAUTHORIZED"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L40_C12", "label": "user = get()", "type": "assigned_variable", "loc": [40, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L39_C8", "vector": [14, 3, 0.7143, 0.0179, 3, 0.84, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Return_L42_C12", "label": "return", "type": "return", "loc": [42, 42], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L39_C8", "vector": [13, 3, 0.75, 0.0179, 3, 0.84, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return apache.HTTP_UNAUTHORIZED"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L45_C8", "label": "if", "type": "if", "loc": [45, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L38_C4", "vector": [4, 2, 0.8839, 0.1786, 2, 0.33, 0.5, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user.check_password(req.get_basic_auth_pw()):\n if permission_name:\n if user.has_perm(permission_name):\n return apache.OK\n else:\n return apache.HTTP_UNAUTHORIZED\n else:\n return apache.OK"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L46_C12", "label": "if", "type": "if", "loc": [46, 52], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L45_C8", "vector": [4, 3, 0.875, 0.125, 3, 0.11, 0.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if permission_name:\n if user.has_perm(permission_name):\n return apache.OK\n else:\n return apache.HTTP_UNAUTHORIZED\n else:\n return apache.OK"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L47_C16", "label": "if", "type": "if", "loc": [47, 50], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L46_C12", "vector": [4, 4, 0.8661, 0.0714, 4, 0.12, 0.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user.has_perm(permission_name):\n return apache.OK\n else:\n return apache.HTTP_UNAUTHORIZED"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Return_L48_C20", "label": "return", "type": "return", "loc": [48, 48], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L47_C16", "vector": [13, 5, 0.8571, 0.0179, 5, 0.55, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return apache.OK"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Return_L50_C20", "label": "return", "type": "return", "loc": [50, 50], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L47_C16", "vector": [13, 5, 0.8929, 0.0179, 5, 0.55, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return apache.HTTP_UNAUTHORIZED"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Return_L52_C16", "label": "return", "type": "return", "loc": [52, 52], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L46_C12", "vector": [13, 4, 0.9286, 0.0179, 4, 0.12, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return apache.OK"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Return_L54_C12", "label": "return", "type": "return", "loc": [54, 54], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L45_C8", "vector": [13, 3, 0.9643, 0.0179, 3, 0.11, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return apache.HTTP_UNAUTHORIZED"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98602:Expr_L56_C8", "label": "close()", "type": "expression", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L38_C4", "vector": [8, 2, 1.0, 0.0179, 2, 0.33, 1.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " db.connection.close()"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Expr_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Expr_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Expr_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:ImportFrom_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:ImportFrom_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Expr_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L38_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Assign_L40_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Return_L42_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L38_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L45_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L46_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L46_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L47_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L47_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Return_L48_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L47_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Return_L50_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L46_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Return_L52_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:If_L45_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Return_L54_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98602:Try_L38_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98602:Expr_L56_C8"}] |
import warnings
from django.conf import settings
from django.contrib.auth.models import User, Group, Permission, AnonymousUser
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
class BackendTest(TestCase):
backend = 'django.contrib.auth.backends.ModelBackend'
def setUp(self):
self.curr_auth = settings.AUTHENTICATION_BACKENDS
settings.AUTHENTICATION_BACKENDS = (self.backend,)
User.objects.create_user('test', 'test@example.com', 'test')
def tearDown(self):
settings.AUTHENTICATION_BACKENDS = self.curr_auth
def test_has_perm(self):
user = User.objects.get(username='test')
self.assertEqual(user.has_perm('auth.test'), False)
user.is_staff = True
user.save()
self.assertEqual(user.has_perm('auth.test'), False)
user.is_superuser = True
user.save()
self.assertEqual(user.has_perm('auth.test'), True)
user.is_staff = False
user.is_superuser = False
user.save()
self.assertEqual(user.has_perm('auth.test'), False)
user.is_staff = True
user.is_superuser = True
user.is_active = False
user.save()
self.assertEqual(user.has_perm('auth.test'), False)
def test_custom_perms(self):
user = User.objects.get(username='test')
content_type=ContentType.objects.get_for_model(Group)
perm = Permission.objects.create(name='test', content_type=content_type, codename='test')
user.user_permissions.add(perm)
user.save()
# reloading user to purge the _perm_cache
user = User.objects.get(username='test')
self.assertEqual(user.get_all_permissions() == set([u'auth.test']), True)
self.assertEqual(user.get_group_permissions(), set([]))
self.assertEqual(user.has_module_perms('Group'), False)
self.assertEqual(user.has_module_perms('auth'), True)
perm = Permission.objects.create(name='test2', content_type=content_type, codename='test2')
user.user_permissions.add(perm)
user.save()
perm = Permission.objects.create(name='test3', content_type=content_type, codename='test3')
user.user_permissions.add(perm)
user.save()
user = User.objects.get(username='test')
self.assertEqual(user.get_all_permissions(), set([u'auth.test2', u'auth.test', u'auth.test3']))
self.assertEqual(user.has_perm('test'), False)
self.assertEqual(user.has_perm('auth.test'), True)
self.assertEqual(user.has_perms(['auth.test2', 'auth.test3']), True)
perm = Permission.objects.create(name='test_group', content_type=content_type, codename='test_group')
group = Group.objects.create(name='test_group')
group.permissions.add(perm)
group.save()
user.groups.add(group)
user = User.objects.get(username='test')
exp = set([u'auth.test2', u'auth.test', u'auth.test3', u'auth.test_group'])
self.assertEqual(user.get_all_permissions(), exp)
self.assertEqual(user.get_group_permissions(), set([u'auth.test_group']))
self.assertEqual(user.has_perms(['auth.test3', 'auth.test_group']), True)
user = AnonymousUser()
self.assertEqual(user.has_perm('test'), False)
self.assertEqual(user.has_perms(['auth.test2', 'auth.test3']), False)
def test_has_no_object_perm(self):
"""Regressiontest for #12462"""
user = User.objects.get(username='test')
content_type=ContentType.objects.get_for_model(Group)
perm = Permission.objects.create(name='test', content_type=content_type, codename='test')
user.user_permissions.add(perm)
user.save()
self.assertEqual(user.has_perm('auth.test', 'object'), False)
self.assertEqual(user.get_all_permissions('object'), set([]))
self.assertEqual(user.has_perm('auth.test'), True)
self.assertEqual(user.get_all_permissions(), set(['auth.test']))
class TestObj(object):
pass
class SimpleRowlevelBackend(object):
supports_object_permissions = True
# This class also supports tests for anonymous user permissions,
# via subclasses which just set the 'supports_anonymous_user' attribute.
def has_perm(self, user, perm, obj=None):
if not obj:
return # We only support row level perms
if isinstance(obj, TestObj):
if user.username == 'test2':
return True
elif user.is_anonymous() and perm == 'anon':
# not reached due to supports_anonymous_user = False
return True
return False
def has_module_perms(self, user, app_label):
return app_label == "app1"
def get_all_permissions(self, user, obj=None):
if not obj:
return [] # We only support row level perms
if not isinstance(obj, TestObj):
return ['none']
if user.is_anonymous():
return ['anon']
if user.username == 'test2':
return ['simple', 'advanced']
else:
return ['simple']
def get_group_permissions(self, user, obj=None):
if not obj:
return # We only support row level perms
if not isinstance(obj, TestObj):
return ['none']
if 'test_group' in [group.name for group in user.groups.all()]:
return ['group_perm']
else:
return ['none']
class RowlevelBackendTest(TestCase):
"""
Tests for auth backend that supports object level permissions
"""
backend = 'django.contrib.auth.tests.auth_backends.SimpleRowlevelBackend'
def setUp(self):
self.curr_auth = settings.AUTHENTICATION_BACKENDS
settings.AUTHENTICATION_BACKENDS = tuple(self.curr_auth) + (self.backend,)
self.user1 = User.objects.create_user('test', 'test@example.com', 'test')
self.user2 = User.objects.create_user('test2', 'test2@example.com', 'test')
self.user3 = User.objects.create_user('test3', 'test3@example.com', 'test')
self.save_warnings_state()
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.contrib.auth')
def tearDown(self):
settings.AUTHENTICATION_BACKENDS = self.curr_auth
self.restore_warnings_state()
def test_has_perm(self):
self.assertEqual(self.user1.has_perm('perm', TestObj()), False)
self.assertEqual(self.user2.has_perm('perm', TestObj()), True)
self.assertEqual(self.user2.has_perm('perm'), False)
self.assertEqual(self.user2.has_perms(['simple', 'advanced'], TestObj()), True)
self.assertEqual(self.user3.has_perm('perm', TestObj()), False)
self.assertEqual(self.user3.has_perm('anon', TestObj()), False)
self.assertEqual(self.user3.has_perms(['simple', 'advanced'], TestObj()), False)
def test_get_all_permissions(self):
self.assertEqual(self.user1.get_all_permissions(TestObj()), set(['simple']))
self.assertEqual(self.user2.get_all_permissions(TestObj()), set(['simple', 'advanced']))
self.assertEqual(self.user2.get_all_permissions(), set([]))
def test_get_group_permissions(self):
content_type=ContentType.objects.get_for_model(Group)
group = Group.objects.create(name='test_group')
self.user3.groups.add(group)
self.assertEqual(self.user3.get_group_permissions(TestObj()), set(['group_perm']))
class AnonymousUserBackend(SimpleRowlevelBackend):
supports_anonymous_user = True
class NoAnonymousUserBackend(SimpleRowlevelBackend):
supports_anonymous_user = False
class AnonymousUserBackendTest(TestCase):
"""
Tests for AnonymousUser delegating to backend if it has 'supports_anonymous_user' = True
"""
backend = 'django.contrib.auth.tests.auth_backends.AnonymousUserBackend'
def setUp(self):
self.curr_auth = settings.AUTHENTICATION_BACKENDS
settings.AUTHENTICATION_BACKENDS = (self.backend,)
self.user1 = AnonymousUser()
def tearDown(self):
settings.AUTHENTICATION_BACKENDS = self.curr_auth
def test_has_perm(self):
self.assertEqual(self.user1.has_perm('perm', TestObj()), False)
self.assertEqual(self.user1.has_perm('anon', TestObj()), True)
def test_has_perms(self):
self.assertEqual(self.user1.has_perms(['anon'], TestObj()), True)
self.assertEqual(self.user1.has_perms(['anon', 'perm'], TestObj()), False)
def test_has_module_perms(self):
self.assertEqual(self.user1.has_module_perms("app1"), True)
self.assertEqual(self.user1.has_module_perms("app2"), False)
def test_get_all_permissions(self):
self.assertEqual(self.user1.get_all_permissions(TestObj()), set(['anon']))
class NoAnonymousUserBackendTest(TestCase):
"""
Tests that AnonymousUser does not delegate to backend if it has 'supports_anonymous_user' = False
"""
backend = 'django.contrib.auth.tests.auth_backends.NoAnonymousUserBackend'
def setUp(self):
self.curr_auth = settings.AUTHENTICATION_BACKENDS
settings.AUTHENTICATION_BACKENDS = tuple(self.curr_auth) + (self.backend,)
self.user1 = AnonymousUser()
def tearDown(self):
settings.AUTHENTICATION_BACKENDS = self.curr_auth
def test_has_perm(self):
self.assertEqual(self.user1.has_perm('perm', TestObj()), False)
self.assertEqual(self.user1.has_perm('anon', TestObj()), False)
def test_has_perms(self):
self.assertEqual(self.user1.has_perms(['anon'], TestObj()), False)
def test_has_module_perms(self):
self.assertEqual(self.user1.has_module_perms("app1"), False)
self.assertEqual(self.user1.has_module_perms("app2"), False)
def test_get_all_permissions(self):
self.assertEqual(self.user1.get_all_permissions(TestObj()), set())
| ajibawa-2023/Python-Code-Large/train/row_98603 | 183 | 253 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Import_L1_C0", "label": "warnings import warnings", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.004, 0.004, 0, 0.66, 0.0, 358, 0, 1, 0, 0, 358, 0, 0], "semantic": {"name": "warnings", "arg_names": [], "import_names": ["warnings"], "rhs_call_name": "", "annotation": ""}, "snippet": "import warnings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:ImportFrom_L3_C0", "label": "from django.conf import settings", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0119, 0.004, 0, 0.66, 0.0833, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:ImportFrom_L4_C0", "label": "from django.contrib.auth.models import User, Group, Permission\u2026", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0158, 0.004, 0, 0.66, 0.1667, 808, 0, 4, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User", "Group", "Permission", "AnonymousUser"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User, Group, Permission, AnonymousUser"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:ImportFrom_L5_C0", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0198, 0.004, 0, 0.66, 0.25, 469, 0, 1, 0, 0, 469, 0, 0], "semantic": {"name": "django.contrib.contenttypes.models", "arg_names": [], "import_names": ["ContentType"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.contenttypes.models import ContentType"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:ImportFrom_L6_C0", "label": "from django.test import TestCase", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0237, 0.004, 0, 0.66, 0.3333, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.test", "arg_names": [], "import_names": ["TestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.test import TestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "label": "BackendTest", "type": "class", "loc": [9, 90], "level": 0, "parent": null, "vector": [3, 0, 0.1957, 0.3241, 0, 0.66, 0.4167, 973, 0, 5, 0, 0, 3, 0, 82], "semantic": {"name": "BackendTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class BackendTest(TestCase):\n\n backend = 'django.contrib.auth.backends.ModelBackend'\n\n def setUp(self):\n self.curr_auth = settings.AUTHENTICATION_BACKENDS\n settings.AUTHENTICATION_BACKENDS = (self.backend,)\n User.objects.create_user('test', 'test@example.com', 'test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L11_C4", "label": "backend =", "type": "assigned_variable", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "vector": [14, 1, 0.0435, 0.004, 1, 0.51, 0.0, 631, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "backend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " backend = 'django.contrib.auth.backends.ModelBackend'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L13_C4", "label": "setUp", "type": "function", "loc": [13, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "vector": [2, 1, 0.0573, 0.0158, 1, 0.51, 0.2, 952, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "setUp", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def setUp(self):\n self.curr_auth = settings.AUTHENTICATION_BACKENDS\n settings.AUTHENTICATION_BACKENDS = (self.backend,)\n User.objects.create_user('test', 'test@example.com', 'test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L14_C8", "label": "self.curr_auth =", "type": "assigned_variable", "loc": [14, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L13_C4", "vector": [14, 2, 0.0553, 0.004, 2, 0.43, 0.0, 327, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.curr_auth", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.curr_auth = settings.AUTHENTICATION_BACKENDS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L15_C8", "label": "settings.AUTHENTICATION_BACKENDS =", "type": "assigned_variable", "loc": [15, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L13_C4", "vector": [14, 2, 0.0593, 0.004, 2, 0.43, 0.5, 257, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "settings.AUTHENTICATION_BACKENDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTHENTICATION_BACKENDS = (self.backend,)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L16_C8", "label": "create_user()", "type": "expression", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L13_C4", "vector": [8, 2, 0.0632, 0.004, 2, 0.43, 1.0, 946, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "create_user", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " User.objects.create_user('test', 'test@example.com', 'test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L18_C4", "label": "tearDown", "type": "function", "loc": [18, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "vector": [2, 1, 0.0731, 0.0079, 1, 0.51, 0.4, 530, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "tearDown", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def tearDown(self):\n settings.AUTHENTICATION_BACKENDS = self.curr_auth"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L19_C8", "label": "settings.AUTHENTICATION_BACKENDS =", "type": "assigned_variable", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L18_C4", "vector": [14, 2, 0.0751, 0.004, 2, 0.12, 0.0, 257, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "settings.AUTHENTICATION_BACKENDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTHENTICATION_BACKENDS = self.curr_auth"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "label": "test_has_perm", "type": "function", "loc": [21, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "vector": [2, 1, 0.1166, 0.0711, 1, 0.51, 0.6, 116, 0, 1, 0, 0, 0, 0, 15], "semantic": {"name": "test_has_perm", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_has_perm(self):\n user = User.objects.get(username='test')\n self.assertEqual(user.has_perm('auth.test'), False)\n user.is_staff = True\n user.save()\n self.assertEqual(user.has_perm('auth.test'), False)\n user.is_superuser = True\n user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L22_C8", "label": "user = get()", "type": "assigned_variable", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [14, 2, 0.087, 0.004, 2, 0.33, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L23_C8", "label": "assertEqual()", "type": "expression", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [8, 2, 0.0909, 0.004, 2, 0.33, 0.0625, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perm('auth.test'), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L24_C8", "label": "user.is_staff =", "type": "assigned_variable", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [14, 2, 0.0949, 0.004, 2, 0.33, 0.125, 369, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "user.is_staff", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user.is_staff = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L25_C8", "label": "save()", "type": "expression", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [8, 2, 0.0988, 0.004, 2, 0.33, 0.1875, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L26_C8", "label": "assertEqual()", "type": "expression", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [8, 2, 0.1028, 0.004, 2, 0.33, 0.25, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perm('auth.test'), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L27_C8", "label": "user.is_superuser =", "type": "assigned_variable", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [14, 2, 0.1067, 0.004, 2, 0.33, 0.3125, 870, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "user.is_superuser", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user.is_superuser = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L28_C8", "label": "save()", "type": "expression", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [8, 2, 0.1107, 0.004, 2, 0.33, 0.375, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L29_C8", "label": "assertEqual()", "type": "expression", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [8, 2, 0.1146, 0.004, 2, 0.33, 0.4375, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perm('auth.test'), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L30_C8", "label": "user.is_staff =", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [14, 2, 0.1186, 0.004, 2, 0.33, 0.5, 369, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "user.is_staff", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user.is_staff = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L31_C8", "label": "user.is_superuser =", "type": "assigned_variable", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [14, 2, 0.1225, 0.004, 2, 0.33, 0.5625, 870, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "user.is_superuser", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user.is_superuser = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L32_C8", "label": "save()", "type": "expression", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [8, 2, 0.1265, 0.004, 2, 0.33, 0.625, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L33_C8", "label": "assertEqual()", "type": "expression", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [8, 2, 0.1304, 0.004, 2, 0.33, 0.6875, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perm('auth.test'), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L34_C8", "label": "user.is_staff =", "type": "assigned_variable", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [14, 2, 0.1344, 0.004, 2, 0.33, 0.75, 369, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "user.is_staff", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user.is_staff = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L35_C8", "label": "user.is_superuser =", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [14, 2, 0.1383, 0.004, 2, 0.33, 0.8125, 870, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "user.is_superuser", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user.is_superuser = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L36_C8", "label": "user.is_active =", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [14, 2, 0.1423, 0.004, 2, 0.33, 0.875, 242, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "user.is_active", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user.is_active = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L37_C8", "label": "save()", "type": "expression", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [8, 2, 0.1462, 0.004, 2, 0.33, 0.9375, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L38_C8", "label": "assertEqual()", "type": "expression", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "vector": [8, 2, 0.1502, 0.004, 2, 0.33, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perm('auth.test'), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "label": "test_custom_perms", "type": "function", "loc": [40, 77], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "vector": [2, 1, 0.2312, 0.1502, 1, 0.51, 0.8, 249, 0, 1, 0, 0, 0, 0, 51], "semantic": {"name": "test_custom_perms", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_custom_perms(self):\n user = User.objects.get(username='test')\n content_type=ContentType.objects.get_for_model(Group)\n perm = Permission.objects.create(name='test', content_type=content_type, codename='test')\n user.user_permissions.add(perm)\n user.save()\n\n # reloading user to purge the _perm_cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L41_C8", "label": "user = get()", "type": "assigned_variable", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [14, 2, 0.1621, 0.004, 2, 0.64, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L42_C8", "label": "content_type = get_for_model()", "type": "assigned_variable", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [14, 2, 0.166, 0.004, 2, 0.64, 0.0303, 610, 3, 1, 0, 0, 752, 10, 1], "semantic": {"name": "content_type", "arg_names": [], "import_names": [], "rhs_call_name": "get_for_model", "annotation": ""}, "snippet": " content_type=ContentType.objects.get_for_model(Group)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L43_C8", "label": "perm = create()", "type": "assigned_variable", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [14, 2, 0.17, 0.004, 2, 0.64, 0.0606, 339, 3, 3, 0, 0, 316, 10, 1], "semantic": {"name": "perm", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " perm = Permission.objects.create(name='test', content_type=content_type, codename='test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L44_C8", "label": "add()", "type": "expression", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.1739, 0.004, 2, 0.64, 0.0909, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " user.user_permissions.add(perm)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L45_C8", "label": "save()", "type": "expression", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.1779, 0.004, 2, 0.64, 0.1212, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L48_C8", "label": "user = get()", "type": "assigned_variable", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [14, 2, 0.1897, 0.004, 2, 0.64, 0.1515, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L49_C8", "label": "assertEqual()", "type": "expression", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.1937, 0.004, 2, 0.64, 0.1818, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.get_all_permissions() == set([u'auth.test']), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L50_C8", "label": "assertEqual()", "type": "expression", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.1976, 0.004, 2, 0.64, 0.2121, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.get_group_permissions(), set([]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L51_C8", "label": "assertEqual()", "type": "expression", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2016, 0.004, 2, 0.64, 0.2424, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_module_perms('Group'), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L52_C8", "label": "assertEqual()", "type": "expression", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2055, 0.004, 2, 0.64, 0.2727, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_module_perms('auth'), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L53_C8", "label": "perm = create()", "type": "assigned_variable", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [14, 2, 0.2095, 0.004, 2, 0.64, 0.303, 339, 3, 3, 0, 0, 316, 10, 1], "semantic": {"name": "perm", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " perm = Permission.objects.create(name='test2', content_type=content_type, codename='test2')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L54_C8", "label": "add()", "type": "expression", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2134, 0.004, 2, 0.64, 0.3333, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " user.user_permissions.add(perm)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L55_C8", "label": "save()", "type": "expression", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2174, 0.004, 2, 0.64, 0.3636, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L56_C8", "label": "perm = create()", "type": "assigned_variable", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [14, 2, 0.2213, 0.004, 2, 0.64, 0.3939, 339, 3, 3, 0, 0, 316, 10, 1], "semantic": {"name": "perm", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " perm = Permission.objects.create(name='test3', content_type=content_type, codename='test3')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L57_C8", "label": "add()", "type": "expression", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2253, 0.004, 2, 0.64, 0.4242, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " user.user_permissions.add(perm)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L58_C8", "label": "save()", "type": "expression", "loc": [58, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2292, 0.004, 2, 0.64, 0.4545, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L59_C8", "label": "user = get()", "type": "assigned_variable", "loc": [59, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [14, 2, 0.2332, 0.004, 2, 0.64, 0.4848, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L60_C8", "label": "assertEqual()", "type": "expression", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2372, 0.004, 2, 0.64, 0.5152, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.get_all_permissions(), set([u'auth.test2', u'auth.test', u'auth.test3']))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L61_C8", "label": "assertEqual()", "type": "expression", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2411, 0.004, 2, 0.64, 0.5455, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perm('test'), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L62_C8", "label": "assertEqual()", "type": "expression", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2451, 0.004, 2, 0.64, 0.5758, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perm('auth.test'), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L63_C8", "label": "assertEqual()", "type": "expression", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.249, 0.004, 2, 0.64, 0.6061, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perms(['auth.test2', 'auth.test3']), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L64_C8", "label": "perm = create()", "type": "assigned_variable", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [14, 2, 0.253, 0.004, 2, 0.64, 0.6364, 339, 3, 3, 0, 0, 316, 10, 1], "semantic": {"name": "perm", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " perm = Permission.objects.create(name='test_group', content_type=content_type, codename='test_group')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L65_C8", "label": "group = create()", "type": "assigned_variable", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [14, 2, 0.2569, 0.004, 2, 0.64, 0.6667, 43, 3, 1, 0, 0, 316, 10, 1], "semantic": {"name": "group", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " group = Group.objects.create(name='test_group')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L66_C8", "label": "add()", "type": "expression", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2609, 0.004, 2, 0.64, 0.697, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " group.permissions.add(perm)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L67_C8", "label": "save()", "type": "expression", "loc": [67, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2648, 0.004, 2, 0.64, 0.7273, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " group.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L68_C8", "label": "add()", "type": "expression", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2688, 0.004, 2, 0.64, 0.7576, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " user.groups.add(group)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L69_C8", "label": "user = get()", "type": "assigned_variable", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [14, 2, 0.2727, 0.004, 2, 0.64, 0.7879, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L70_C8", "label": "exp = set()", "type": "assigned_variable", "loc": [70, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [14, 2, 0.2767, 0.004, 2, 0.64, 0.8182, 971, 3, 1, 0, 0, 21, 10, 1], "semantic": {"name": "exp", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " exp = set([u'auth.test2', u'auth.test', u'auth.test3', u'auth.test_group'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L71_C8", "label": "assertEqual()", "type": "expression", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2806, 0.004, 2, 0.64, 0.8485, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.get_all_permissions(), exp)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L72_C8", "label": "assertEqual()", "type": "expression", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2846, 0.004, 2, 0.64, 0.8788, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.get_group_permissions(), set([u'auth.test_group']))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L73_C8", "label": "assertEqual()", "type": "expression", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.2885, 0.004, 2, 0.64, 0.9091, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perms(['auth.test3', 'auth.test_group']), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L75_C8", "label": "user = AnonymousUser()", "type": "assigned_variable", "loc": [75, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [14, 2, 0.2964, 0.004, 2, 0.64, 0.9394, 503, 3, 0, 0, 0, 185, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "AnonymousUser", "annotation": ""}, "snippet": " user = AnonymousUser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L76_C8", "label": "assertEqual()", "type": "expression", "loc": [76, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.3004, 0.004, 2, 0.64, 0.9697, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perm('test'), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L77_C8", "label": "assertEqual()", "type": "expression", "loc": [77, 77], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "vector": [8, 2, 0.3043, 0.004, 2, 0.64, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perms(['auth.test2', 'auth.test3']), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "label": "test_has_no_object_perm", "type": "function", "loc": [79, 90], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "vector": [2, 1, 0.334, 0.0474, 1, 0.51, 1.0, 790, 0, 1, 0, 0, 0, 0, 15], "semantic": {"name": "test_has_no_object_perm", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_has_no_object_perm(self):\n \"\"\"Regressiontest for #12462\"\"\"\n user = User.objects.get(username='test')\n content_type=ContentType.objects.get_for_model(Group)\n perm = Permission.objects.create(name='test', content_type=content_type, codename='test')\n user.user_permissions.add(perm)\n user.save()\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L80_C8", "label": "expression", "type": "expression", "loc": [80, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "vector": [8, 2, 0.3162, 0.004, 2, 0.14, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Regressiontest for #12462\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L81_C8", "label": "user = get()", "type": "assigned_variable", "loc": [81, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "vector": [14, 2, 0.3202, 0.004, 2, 0.14, 0.1111, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L82_C8", "label": "content_type = get_for_model()", "type": "assigned_variable", "loc": [82, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "vector": [14, 2, 0.3241, 0.004, 2, 0.14, 0.2222, 610, 3, 1, 0, 0, 752, 10, 1], "semantic": {"name": "content_type", "arg_names": [], "import_names": [], "rhs_call_name": "get_for_model", "annotation": ""}, "snippet": " content_type=ContentType.objects.get_for_model(Group)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L83_C8", "label": "perm = create()", "type": "assigned_variable", "loc": [83, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "vector": [14, 2, 0.3281, 0.004, 2, 0.14, 0.3333, 339, 3, 3, 0, 0, 316, 10, 1], "semantic": {"name": "perm", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " perm = Permission.objects.create(name='test', content_type=content_type, codename='test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L84_C8", "label": "add()", "type": "expression", "loc": [84, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "vector": [8, 2, 0.332, 0.004, 2, 0.14, 0.4444, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " user.user_permissions.add(perm)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L85_C8", "label": "save()", "type": "expression", "loc": [85, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "vector": [8, 2, 0.336, 0.004, 2, 0.14, 0.5556, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L87_C8", "label": "assertEqual()", "type": "expression", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "vector": [8, 2, 0.3439, 0.004, 2, 0.14, 0.6667, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perm('auth.test', 'object'), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L88_C8", "label": "assertEqual()", "type": "expression", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "vector": [8, 2, 0.3478, 0.004, 2, 0.14, 0.7778, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.get_all_permissions('object'), set([]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L89_C8", "label": "assertEqual()", "type": "expression", "loc": [89, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "vector": [8, 2, 0.3518, 0.004, 2, 0.14, 0.8889, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.has_perm('auth.test'), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L90_C8", "label": "assertEqual()", "type": "expression", "loc": [90, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "vector": [8, 2, 0.3557, 0.004, 2, 0.14, 1.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.get_all_permissions(), set(['auth.test']))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L93_C0", "label": "TestObj", "type": "class", "loc": [93, 94], "level": 0, "parent": null, "vector": [3, 0, 0.3696, 0.0079, 0, 0.66, 0.5, 95, 0, 0, 0, 0, 186, 0, 0], "semantic": {"name": "TestObj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TestObj(object):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L97_C0", "label": "SimpleRowlevelBackend", "type": "class", "loc": [97, 142], "level": 0, "parent": null, "vector": [3, 0, 0.4723, 0.1818, 0, 0.66, 0.5833, 587, 0, 4, 0, 0, 186, 0, 6], "semantic": {"name": "SimpleRowlevelBackend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SimpleRowlevelBackend(object):\n supports_object_permissions = True\n\n # This class also supports tests for anonymous user permissions,\n # via subclasses which just set the 'supports_anonymous_user' attribute.\n\n def has_perm(self, user, perm, obj=None):\n if not obj:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L98_C4", "label": "supports_object_permissions =", "type": "assigned_variable", "loc": [98, 98], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L97_C0", "vector": [14, 1, 0.3874, 0.004, 1, 0.61, 0.0, 767, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "supports_object_permissions", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " supports_object_permissions = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L103_C4", "label": "has_perm", "type": "function", "loc": [103, 113], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L97_C0", "vector": [2, 1, 0.4269, 0.0435, 1, 0.61, 0.25, 674, 0, 4, 1, 0, 0, 0, 2], "semantic": {"name": "has_perm", "arg_names": ["self", "user", "perm", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_perm(self, user, perm, obj=None):\n if not obj:\n return # We only support row level perms\n\n if isinstance(obj, TestObj):\n if user.username == 'test2':\n return True\n elif user.is_anonymous() and perm == 'anon':"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L104_C8", "label": "if", "type": "if", "loc": [104, 105], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L103_C4", "vector": [4, 2, 0.413, 0.0079, 2, 0.12, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not obj:\n return # We only support row level perms"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L105_C12", "label": "return", "type": "return", "loc": [105, 105], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L104_C8", "vector": [13, 3, 0.415, 0.004, 3, 0.37, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return # We only support row level perms"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L107_C8", "label": "if", "type": "if", "loc": [107, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L103_C4", "vector": [4, 2, 0.4328, 0.0237, 2, 0.12, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(obj, TestObj):\n if user.username == 'test2':\n return True\n elif user.is_anonymous() and perm == 'anon':\n # not reached due to supports_anonymous_user = False\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L108_C12", "label": "if", "type": "if", "loc": [108, 112], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L107_C8", "vector": [4, 3, 0.4348, 0.0198, 3, 0.78, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user.username == 'test2':\n return True\n elif user.is_anonymous() and perm == 'anon':\n # not reached due to supports_anonymous_user = False\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L109_C16", "label": "return", "type": "return", "loc": [109, 109], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L108_C12", "vector": [13, 4, 0.4308, 0.004, 4, 0.4, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L110_C12", "label": "if", "type": "if", "loc": [110, 112], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L108_C12", "vector": [4, 4, 0.4387, 0.0119, 4, 0.4, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif user.is_anonymous() and perm == 'anon':\n # not reached due to supports_anonymous_user = False\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L112_C16", "label": "return", "type": "return", "loc": [112, 112], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L110_C12", "vector": [13, 5, 0.4427, 0.004, 5, 0.14, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L113_C8", "label": "return", "type": "return", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L103_C4", "vector": [13, 2, 0.4466, 0.004, 2, 0.12, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L115_C4", "label": "has_module_perms", "type": "function", "loc": [115, 116], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L97_C0", "vector": [2, 1, 0.4565, 0.0079, 1, 0.61, 0.5, 249, 0, 3, 1, 0, 0, 0, 0], "semantic": {"name": "has_module_perms", "arg_names": ["self", "user", "app_label"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_module_perms(self, user, app_label):\n return app_label == \"app1\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L116_C8", "label": "return", "type": "return", "loc": [116, 116], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L115_C4", "vector": [13, 2, 0.4585, 0.004, 2, 0.28, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return app_label == \"app1\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L118_C4", "label": "get_all_permissions", "type": "function", "loc": [118, 130], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L97_C0", "vector": [2, 1, 0.4901, 0.0514, 1, 0.61, 0.75, 669, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "get_all_permissions", "arg_names": ["self", "user", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_all_permissions(self, user, obj=None):\n if not obj:\n return [] # We only support row level perms\n\n if not isinstance(obj, TestObj):\n return ['none']\n\n if user.is_anonymous():"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L119_C8", "label": "if", "type": "if", "loc": [119, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L118_C4", "vector": [4, 2, 0.4723, 0.0079, 2, 0.48, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not obj:\n return [] # We only support row level perms"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L120_C12", "label": "return", "type": "return", "loc": [120, 120], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L119_C8", "vector": [13, 3, 0.4743, 0.004, 3, 0.47, 0.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [] # We only support row level perms"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L122_C8", "label": "if", "type": "if", "loc": [122, 123], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L118_C4", "vector": [4, 2, 0.4842, 0.0079, 2, 0.48, 0.3333, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(obj, TestObj):\n return ['none']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L123_C12", "label": "return", "type": "return", "loc": [123, 123], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L122_C8", "vector": [13, 3, 0.4862, 0.004, 3, 0.3, 0.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ['none']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L125_C8", "label": "if", "type": "if", "loc": [125, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L118_C4", "vector": [4, 2, 0.496, 0.0079, 2, 0.48, 0.6667, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user.is_anonymous():\n return ['anon']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L126_C12", "label": "return", "type": "return", "loc": [126, 126], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L125_C8", "vector": [13, 3, 0.498, 0.004, 3, 0.06, 0.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ['anon']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L127_C8", "label": "if", "type": "if", "loc": [127, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L118_C4", "vector": [4, 2, 0.5079, 0.0158, 2, 0.48, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user.username == 'test2':\n return ['simple', 'advanced']\n else:\n return ['simple']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L128_C12", "label": "return", "type": "return", "loc": [128, 128], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L127_C8", "vector": [13, 3, 0.5059, 0.004, 3, 0.91, 0.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ['simple', 'advanced']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L130_C12", "label": "return", "type": "return", "loc": [130, 130], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L127_C8", "vector": [13, 3, 0.5138, 0.004, 3, 0.91, 1.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ['simple']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L132_C4", "label": "get_group_permissions", "type": "function", "loc": [132, 142], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L97_C0", "vector": [2, 1, 0.5415, 0.0435, 1, 0.61, 1.0, 228, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "get_group_permissions", "arg_names": ["self", "user", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_group_permissions(self, user, obj=None):\n if not obj:\n return # We only support row level perms\n\n if not isinstance(obj, TestObj):\n return ['none']\n\n if 'test_group' in [group.name for group in user.groups.all()]:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L133_C8", "label": "if", "type": "if", "loc": [133, 134], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L132_C4", "vector": [4, 2, 0.5277, 0.0079, 2, 0.76, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not obj:\n return # We only support row level perms"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L134_C12", "label": "return", "type": "return", "loc": [134, 134], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L133_C8", "vector": [13, 3, 0.5296, 0.004, 3, 0.38, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return # We only support row level perms"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L136_C8", "label": "if", "type": "if", "loc": [136, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L132_C4", "vector": [4, 2, 0.5395, 0.0079, 2, 0.76, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(obj, TestObj):\n return ['none']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L137_C12", "label": "return", "type": "return", "loc": [137, 137], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L136_C8", "vector": [13, 3, 0.5415, 0.004, 3, 0.18, 0.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ['none']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L139_C8", "label": "if", "type": "if", "loc": [139, 142], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L132_C4", "vector": [4, 2, 0.5553, 0.0158, 2, 0.76, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'test_group' in [group.name for group in user.groups.all()]:\n return ['group_perm']\n else:\n return ['none']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L140_C12", "label": "return", "type": "return", "loc": [140, 140], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L139_C8", "vector": [13, 3, 0.5534, 0.004, 3, 0.61, 0.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ['group_perm']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L142_C12", "label": "return", "type": "return", "loc": [142, 142], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L139_C8", "vector": [13, 3, 0.5613, 0.004, 3, 0.61, 1.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ['none']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "label": "RowlevelBackendTest", "type": "class", "loc": [145, 183], "level": 0, "parent": null, "vector": [3, 0, 0.6482, 0.1542, 0, 0.66, 0.6667, 146, 0, 5, 0, 0, 3, 0, 45], "semantic": {"name": "RowlevelBackendTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RowlevelBackendTest(TestCase):\n \"\"\"\n Tests for auth backend that supports object level permissions\n \"\"\"\n backend = 'django.contrib.auth.tests.auth_backends.SimpleRowlevelBackend'\n\n def setUp(self):\n self.curr_auth = settings.AUTHENTICATION_BACKENDS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L146_C4", "label": "expression", "type": "expression", "loc": [146, 148], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "vector": [8, 1, 0.581, 0.0119, 1, 0.5, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Tests for auth backend that supports object level permissions\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L149_C4", "label": "backend =", "type": "assigned_variable", "loc": [149, 149], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "vector": [14, 1, 0.5889, 0.004, 1, 0.5, 0.1667, 631, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "backend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " backend = 'django.contrib.auth.tests.auth_backends.SimpleRowlevelBackend'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "label": "setUp", "type": "function", "loc": [151, 159], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "vector": [2, 1, 0.6126, 0.0356, 1, 0.5, 0.3333, 952, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "setUp", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def setUp(self):\n self.curr_auth = settings.AUTHENTICATION_BACKENDS\n settings.AUTHENTICATION_BACKENDS = tuple(self.curr_auth) + (self.backend,)\n self.user1 = User.objects.create_user('test', 'test@example.com', 'test')\n self.user2 = User.objects.create_user('test2', 'test2@example.com', 'test')\n self.user3 = User.objects.create_user('test3', 'test3@example.com', 'test')\n self.save_warnings_state()\n warnings.filterwarnings('ignore', category=DeprecationWarning,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L152_C8", "label": "self.curr_auth =", "type": "assigned_variable", "loc": [152, 152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "vector": [14, 2, 0.6008, 0.004, 2, 0.53, 0.0, 327, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.curr_auth", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.curr_auth = settings.AUTHENTICATION_BACKENDS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L153_C8", "label": "settings.AUTHENTICATION_BACKENDS =", "type": "assigned_variable", "loc": [153, 153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "vector": [14, 2, 0.6047, 0.004, 2, 0.53, 0.1667, 257, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "settings.AUTHENTICATION_BACKENDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTHENTICATION_BACKENDS = tuple(self.curr_auth) + (self.backend,)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L154_C8", "label": "self.user1 = create_user()", "type": "assigned_variable", "loc": [154, 154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "vector": [14, 2, 0.6087, 0.004, 2, 0.53, 0.3333, 519, 3, 3, 0, 0, 946, 10, 1], "semantic": {"name": "self.user1", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " self.user1 = User.objects.create_user('test', 'test@example.com', 'test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L155_C8", "label": "self.user2 = create_user()", "type": "assigned_variable", "loc": [155, 155], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "vector": [14, 2, 0.6126, 0.004, 2, 0.53, 0.5, 221, 3, 3, 0, 0, 946, 10, 1], "semantic": {"name": "self.user2", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " self.user2 = User.objects.create_user('test2', 'test2@example.com', 'test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L156_C8", "label": "self.user3 = create_user()", "type": "assigned_variable", "loc": [156, 156], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "vector": [14, 2, 0.6166, 0.004, 2, 0.53, 0.6667, 401, 3, 3, 0, 0, 946, 10, 1], "semantic": {"name": "self.user3", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " self.user3 = User.objects.create_user('test3', 'test3@example.com', 'test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L157_C8", "label": "save_warnings_state()", "type": "expression", "loc": [157, 157], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "vector": [8, 2, 0.6206, 0.004, 2, 0.53, 0.8333, 106, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save_warnings_state", "arg_names": [], "import_names": [], "rhs_call_name": "save_warnings_state", "annotation": ""}, "snippet": " self.save_warnings_state()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L158_C8", "label": "filterwarnings()", "type": "expression", "loc": [158, 159], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "vector": [8, 2, 0.6265, 0.0079, 2, 0.53, 1.0, 719, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "filterwarnings", "arg_names": [], "import_names": [], "rhs_call_name": "filterwarnings", "annotation": ""}, "snippet": " warnings.filterwarnings('ignore', category=DeprecationWarning,\n module='django.contrib.auth')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L161_C4", "label": "tearDown", "type": "function", "loc": [161, 163], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "vector": [2, 1, 0.6403, 0.0119, 1, 0.5, 0.5, 530, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "tearDown", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def tearDown(self):\n settings.AUTHENTICATION_BACKENDS = self.curr_auth\n self.restore_warnings_state()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L162_C8", "label": "settings.AUTHENTICATION_BACKENDS =", "type": "assigned_variable", "loc": [162, 162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L161_C4", "vector": [14, 2, 0.6403, 0.004, 2, 0.65, 0.0, 257, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "settings.AUTHENTICATION_BACKENDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTHENTICATION_BACKENDS = self.curr_auth"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L163_C8", "label": "restore_warnings_state()", "type": "expression", "loc": [163, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L161_C4", "vector": [8, 2, 0.6443, 0.004, 2, 0.65, 1.0, 473, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "restore_warnings_state", "arg_names": [], "import_names": [], "rhs_call_name": "restore_warnings_state", "annotation": ""}, "snippet": " self.restore_warnings_state()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "label": "test_has_perm", "type": "function", "loc": [165, 172], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "vector": [2, 1, 0.666, 0.0316, 1, 0.5, 0.6667, 116, 0, 1, 0, 0, 0, 0, 20], "semantic": {"name": "test_has_perm", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_has_perm(self):\n self.assertEqual(self.user1.has_perm('perm', TestObj()), False)\n self.assertEqual(self.user2.has_perm('perm', TestObj()), True)\n self.assertEqual(self.user2.has_perm('perm'), False)\n self.assertEqual(self.user2.has_perms(['simple', 'advanced'], TestObj()), True)\n self.assertEqual(self.user3.has_perm('perm', TestObj()), False)\n self.assertEqual(self.user3.has_perm('anon', TestObj()), False)\n self.assertEqual(self.user3.has_perms(['simple', 'advanced'], TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L166_C8", "label": "assertEqual()", "type": "expression", "loc": [166, 166], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "vector": [8, 2, 0.6561, 0.004, 2, 0.22, 0.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.has_perm('perm', TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L167_C8", "label": "assertEqual()", "type": "expression", "loc": [167, 167], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "vector": [8, 2, 0.6601, 0.004, 2, 0.22, 0.1667, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user2.has_perm('perm', TestObj()), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L168_C8", "label": "assertEqual()", "type": "expression", "loc": [168, 168], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "vector": [8, 2, 0.664, 0.004, 2, 0.22, 0.3333, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user2.has_perm('perm'), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L169_C8", "label": "assertEqual()", "type": "expression", "loc": [169, 169], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "vector": [8, 2, 0.668, 0.004, 2, 0.22, 0.5, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user2.has_perms(['simple', 'advanced'], TestObj()), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L170_C8", "label": "assertEqual()", "type": "expression", "loc": [170, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "vector": [8, 2, 0.6719, 0.004, 2, 0.22, 0.6667, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user3.has_perm('perm', TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L171_C8", "label": "assertEqual()", "type": "expression", "loc": [171, 171], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "vector": [8, 2, 0.6759, 0.004, 2, 0.22, 0.8333, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user3.has_perm('anon', TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L172_C8", "label": "assertEqual()", "type": "expression", "loc": [172, 172], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "vector": [8, 2, 0.6798, 0.004, 2, 0.22, 1.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user3.has_perms(['simple', 'advanced'], TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L174_C4", "label": "test_get_all_permissions", "type": "function", "loc": [174, 177], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "vector": [2, 1, 0.6937, 0.0158, 1, 0.5, 0.8333, 643, 0, 1, 0, 0, 0, 0, 11], "semantic": {"name": "test_get_all_permissions", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_get_all_permissions(self):\n self.assertEqual(self.user1.get_all_permissions(TestObj()), set(['simple']))\n self.assertEqual(self.user2.get_all_permissions(TestObj()), set(['simple', 'advanced']))\n self.assertEqual(self.user2.get_all_permissions(), set([]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L175_C8", "label": "assertEqual()", "type": "expression", "loc": [175, 175], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L174_C4", "vector": [8, 2, 0.6917, 0.004, 2, 0.22, 0.0, 299, 3, 2, 0, 0, 0, 0, 4], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.get_all_permissions(TestObj()), set(['simple']))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L176_C8", "label": "assertEqual()", "type": "expression", "loc": [176, 176], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L174_C4", "vector": [8, 2, 0.6957, 0.004, 2, 0.22, 0.5, 299, 3, 2, 0, 0, 0, 0, 4], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user2.get_all_permissions(TestObj()), set(['simple', 'advanced']))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L177_C8", "label": "assertEqual()", "type": "expression", "loc": [177, 177], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L174_C4", "vector": [8, 2, 0.6996, 0.004, 2, 0.22, 1.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user2.get_all_permissions(), set([]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L179_C4", "label": "test_get_group_permissions", "type": "function", "loc": [179, 183], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "vector": [2, 1, 0.7154, 0.0198, 1, 0.5, 1.0, 533, 0, 1, 0, 0, 0, 0, 7], "semantic": {"name": "test_get_group_permissions", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_get_group_permissions(self):\n content_type=ContentType.objects.get_for_model(Group)\n group = Group.objects.create(name='test_group')\n self.user3.groups.add(group)\n self.assertEqual(self.user3.get_group_permissions(TestObj()), set(['group_perm']))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L180_C8", "label": "content_type = get_for_model()", "type": "assigned_variable", "loc": [180, 180], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L179_C4", "vector": [14, 2, 0.7115, 0.004, 2, 0.73, 0.0, 610, 3, 1, 0, 0, 752, 10, 1], "semantic": {"name": "content_type", "arg_names": [], "import_names": [], "rhs_call_name": "get_for_model", "annotation": ""}, "snippet": " content_type=ContentType.objects.get_for_model(Group)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L181_C8", "label": "group = create()", "type": "assigned_variable", "loc": [181, 181], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L179_C4", "vector": [14, 2, 0.7154, 0.004, 2, 0.73, 0.3333, 43, 3, 1, 0, 0, 316, 10, 1], "semantic": {"name": "group", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " group = Group.objects.create(name='test_group')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L182_C8", "label": "add()", "type": "expression", "loc": [182, 182], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L179_C4", "vector": [8, 2, 0.7194, 0.004, 2, 0.73, 0.6667, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " self.user3.groups.add(group)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L183_C8", "label": "assertEqual()", "type": "expression", "loc": [183, 183], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L179_C4", "vector": [8, 2, 0.7233, 0.004, 2, 0.73, 1.0, 299, 3, 2, 0, 0, 0, 0, 4], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user3.get_group_permissions(TestObj()), set(['group_perm']))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L186_C0", "label": "AnonymousUserBackend", "type": "class", "loc": [186, 188], "level": 0, "parent": null, "vector": [3, 0, 0.7391, 0.0119, 0, 0.66, 0.75, 87, 0, 0, 0, 0, 587, 0, 0], "semantic": {"name": "AnonymousUserBackend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AnonymousUserBackend(SimpleRowlevelBackend):\n\n supports_anonymous_user = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L188_C4", "label": "supports_anonymous_user =", "type": "assigned_variable", "loc": [188, 188], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L186_C0", "vector": [14, 1, 0.7431, 0.004, 1, 0.65, 0.0, 50, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "supports_anonymous_user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " supports_anonymous_user = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L191_C0", "label": "NoAnonymousUserBackend", "type": "class", "loc": [191, 193], "level": 0, "parent": null, "vector": [3, 0, 0.7589, 0.0119, 0, 0.66, 0.8333, 658, 0, 0, 0, 0, 587, 0, 0], "semantic": {"name": "NoAnonymousUserBackend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class NoAnonymousUserBackend(SimpleRowlevelBackend):\n\n supports_anonymous_user = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L193_C4", "label": "supports_anonymous_user =", "type": "assigned_variable", "loc": [193, 193], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L191_C0", "vector": [14, 1, 0.7628, 0.004, 1, 0.28, 0.0, 50, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "supports_anonymous_user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " supports_anonymous_user = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "label": "AnonymousUserBackendTest", "type": "class", "loc": [196, 224], "level": 0, "parent": null, "vector": [3, 0, 0.83, 0.1146, 0, 0.66, 0.9167, 23, 0, 6, 0, 0, 3, 0, 21], "semantic": {"name": "AnonymousUserBackendTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AnonymousUserBackendTest(TestCase):\n \"\"\"\n Tests for AnonymousUser delegating to backend if it has 'supports_anonymous_user' = True\n \"\"\"\n\n backend = 'django.contrib.auth.tests.auth_backends.AnonymousUserBackend'\n\n def setUp(self):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L197_C4", "label": "expression", "type": "expression", "loc": [197, 199], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "vector": [8, 1, 0.7826, 0.0119, 1, 0.28, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Tests for AnonymousUser delegating to backend if it has 'supports_anonymous_user' = True\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L201_C4", "label": "backend =", "type": "assigned_variable", "loc": [201, 201], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "vector": [14, 1, 0.7945, 0.004, 1, 0.28, 0.1429, 631, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "backend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " backend = 'django.contrib.auth.tests.auth_backends.AnonymousUserBackend'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L203_C4", "label": "setUp", "type": "function", "loc": [203, 206], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "vector": [2, 1, 0.8083, 0.0158, 1, 0.28, 0.2857, 952, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "setUp", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def setUp(self):\n self.curr_auth = settings.AUTHENTICATION_BACKENDS\n settings.AUTHENTICATION_BACKENDS = (self.backend,)\n self.user1 = AnonymousUser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L204_C8", "label": "self.curr_auth =", "type": "assigned_variable", "loc": [204, 204], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L203_C4", "vector": [14, 2, 0.8063, 0.004, 2, 0.67, 0.0, 327, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.curr_auth", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.curr_auth = settings.AUTHENTICATION_BACKENDS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L205_C8", "label": "settings.AUTHENTICATION_BACKENDS =", "type": "assigned_variable", "loc": [205, 205], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L203_C4", "vector": [14, 2, 0.8103, 0.004, 2, 0.67, 0.5, 257, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "settings.AUTHENTICATION_BACKENDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTHENTICATION_BACKENDS = (self.backend,)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L206_C8", "label": "self.user1 = AnonymousUser()", "type": "assigned_variable", "loc": [206, 206], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L203_C4", "vector": [14, 2, 0.8142, 0.004, 2, 0.67, 1.0, 519, 3, 0, 0, 0, 185, 10, 1], "semantic": {"name": "self.user1", "arg_names": [], "import_names": [], "rhs_call_name": "AnonymousUser", "annotation": ""}, "snippet": " self.user1 = AnonymousUser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L208_C4", "label": "tearDown", "type": "function", "loc": [208, 209], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "vector": [2, 1, 0.8241, 0.0079, 1, 0.28, 0.4286, 530, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "tearDown", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def tearDown(self):\n settings.AUTHENTICATION_BACKENDS = self.curr_auth"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L209_C8", "label": "settings.AUTHENTICATION_BACKENDS =", "type": "assigned_variable", "loc": [209, 209], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L208_C4", "vector": [14, 2, 0.8261, 0.004, 2, 0.3, 0.0, 257, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "settings.AUTHENTICATION_BACKENDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTHENTICATION_BACKENDS = self.curr_auth"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L211_C4", "label": "test_has_perm", "type": "function", "loc": [211, 213], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "vector": [2, 1, 0.8379, 0.0119, 1, 0.28, 0.5714, 116, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_has_perm", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_has_perm(self):\n self.assertEqual(self.user1.has_perm('perm', TestObj()), False)\n self.assertEqual(self.user1.has_perm('anon', TestObj()), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L212_C8", "label": "assertEqual()", "type": "expression", "loc": [212, 212], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L211_C4", "vector": [8, 2, 0.8379, 0.004, 2, 0.44, 0.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.has_perm('perm', TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L213_C8", "label": "assertEqual()", "type": "expression", "loc": [213, 213], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L211_C4", "vector": [8, 2, 0.8419, 0.004, 2, 0.44, 1.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.has_perm('anon', TestObj()), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L215_C4", "label": "test_has_perms", "type": "function", "loc": [215, 217], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "vector": [2, 1, 0.8538, 0.0119, 1, 0.28, 0.7143, 84, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_has_perms", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_has_perms(self):\n self.assertEqual(self.user1.has_perms(['anon'], TestObj()), True)\n self.assertEqual(self.user1.has_perms(['anon', 'perm'], TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L216_C8", "label": "assertEqual()", "type": "expression", "loc": [216, 216], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L215_C4", "vector": [8, 2, 0.8538, 0.004, 2, 0.31, 0.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.has_perms(['anon'], TestObj()), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L217_C8", "label": "assertEqual()", "type": "expression", "loc": [217, 217], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L215_C4", "vector": [8, 2, 0.8577, 0.004, 2, 0.31, 1.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.has_perms(['anon', 'perm'], TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L219_C4", "label": "test_has_module_perms", "type": "function", "loc": [219, 221], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "vector": [2, 1, 0.8696, 0.0119, 1, 0.28, 0.8571, 898, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_has_module_perms", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_has_module_perms(self):\n self.assertEqual(self.user1.has_module_perms(\"app1\"), True)\n self.assertEqual(self.user1.has_module_perms(\"app2\"), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L220_C8", "label": "assertEqual()", "type": "expression", "loc": [220, 220], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L219_C4", "vector": [8, 2, 0.8696, 0.004, 2, 0.3, 0.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.has_module_perms(\"app1\"), True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L221_C8", "label": "assertEqual()", "type": "expression", "loc": [221, 221], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L219_C4", "vector": [8, 2, 0.8735, 0.004, 2, 0.3, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.has_module_perms(\"app2\"), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L223_C4", "label": "test_get_all_permissions", "type": "function", "loc": [223, 224], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "vector": [2, 1, 0.8834, 0.0079, 1, 0.28, 1.0, 643, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_get_all_permissions", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_get_all_permissions(self):\n self.assertEqual(self.user1.get_all_permissions(TestObj()), set(['anon']))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L224_C8", "label": "assertEqual()", "type": "expression", "loc": [224, 224], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L223_C4", "vector": [8, 2, 0.8854, 0.004, 2, 0.54, 0.0, 299, 3, 2, 0, 0, 0, 0, 4], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.get_all_permissions(TestObj()), set(['anon']))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "label": "NoAnonymousUserBackendTest", "type": "class", "loc": [227, 253], "level": 0, "parent": null, "vector": [3, 0, 0.9486, 0.1067, 0, 0.66, 1.0, 544, 0, 6, 0, 0, 3, 0, 19], "semantic": {"name": "NoAnonymousUserBackendTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class NoAnonymousUserBackendTest(TestCase):\n \"\"\"\n Tests that AnonymousUser does not delegate to backend if it has 'supports_anonymous_user' = False\n \"\"\"\n backend = 'django.contrib.auth.tests.auth_backends.NoAnonymousUserBackend'\n\n def setUp(self):\n self.curr_auth = settings.AUTHENTICATION_BACKENDS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L228_C4", "label": "expression", "type": "expression", "loc": [228, 230], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "vector": [8, 1, 0.9051, 0.0119, 1, 0.11, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Tests that AnonymousUser does not delegate to backend if it has 'supports_anonymous_user' = False\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L231_C4", "label": "backend =", "type": "assigned_variable", "loc": [231, 231], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "vector": [14, 1, 0.913, 0.004, 1, 0.11, 0.1429, 631, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "backend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " backend = 'django.contrib.auth.tests.auth_backends.NoAnonymousUserBackend'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L233_C4", "label": "setUp", "type": "function", "loc": [233, 236], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "vector": [2, 1, 0.9269, 0.0158, 1, 0.11, 0.2857, 952, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "setUp", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def setUp(self):\n self.curr_auth = settings.AUTHENTICATION_BACKENDS\n settings.AUTHENTICATION_BACKENDS = tuple(self.curr_auth) + (self.backend,)\n self.user1 = AnonymousUser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L234_C8", "label": "self.curr_auth =", "type": "assigned_variable", "loc": [234, 234], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L233_C4", "vector": [14, 2, 0.9249, 0.004, 2, 0.22, 0.0, 327, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.curr_auth", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.curr_auth = settings.AUTHENTICATION_BACKENDS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L235_C8", "label": "settings.AUTHENTICATION_BACKENDS =", "type": "assigned_variable", "loc": [235, 235], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L233_C4", "vector": [14, 2, 0.9289, 0.004, 2, 0.22, 0.5, 257, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "settings.AUTHENTICATION_BACKENDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTHENTICATION_BACKENDS = tuple(self.curr_auth) + (self.backend,)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L236_C8", "label": "self.user1 = AnonymousUser()", "type": "assigned_variable", "loc": [236, 236], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L233_C4", "vector": [14, 2, 0.9328, 0.004, 2, 0.22, 1.0, 519, 3, 0, 0, 0, 185, 10, 1], "semantic": {"name": "self.user1", "arg_names": [], "import_names": [], "rhs_call_name": "AnonymousUser", "annotation": ""}, "snippet": " self.user1 = AnonymousUser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L238_C4", "label": "tearDown", "type": "function", "loc": [238, 239], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "vector": [2, 1, 0.9427, 0.0079, 1, 0.11, 0.4286, 530, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "tearDown", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def tearDown(self):\n settings.AUTHENTICATION_BACKENDS = self.curr_auth"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L239_C8", "label": "settings.AUTHENTICATION_BACKENDS =", "type": "assigned_variable", "loc": [239, 239], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L238_C4", "vector": [14, 2, 0.9447, 0.004, 2, 0.74, 0.0, 257, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "settings.AUTHENTICATION_BACKENDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTHENTICATION_BACKENDS = self.curr_auth"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L241_C4", "label": "test_has_perm", "type": "function", "loc": [241, 243], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "vector": [2, 1, 0.9565, 0.0119, 1, 0.11, 0.5714, 116, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_has_perm", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_has_perm(self):\n self.assertEqual(self.user1.has_perm('perm', TestObj()), False)\n self.assertEqual(self.user1.has_perm('anon', TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L242_C8", "label": "assertEqual()", "type": "expression", "loc": [242, 242], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L241_C4", "vector": [8, 2, 0.9565, 0.004, 2, 0.6, 0.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.has_perm('perm', TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L243_C8", "label": "assertEqual()", "type": "expression", "loc": [243, 243], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L241_C4", "vector": [8, 2, 0.9605, 0.004, 2, 0.6, 1.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.has_perm('anon', TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L245_C4", "label": "test_has_perms", "type": "function", "loc": [245, 246], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "vector": [2, 1, 0.9704, 0.0079, 1, 0.11, 0.7143, 84, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "test_has_perms", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_has_perms(self):\n self.assertEqual(self.user1.has_perms(['anon'], TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L246_C8", "label": "assertEqual()", "type": "expression", "loc": [246, 246], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L245_C4", "vector": [8, 2, 0.9723, 0.004, 2, 0.39, 0.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.has_perms(['anon'], TestObj()), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L248_C4", "label": "test_has_module_perms", "type": "function", "loc": [248, 250], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "vector": [2, 1, 0.9842, 0.0119, 1, 0.11, 0.8571, 898, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_has_module_perms", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_has_module_perms(self):\n self.assertEqual(self.user1.has_module_perms(\"app1\"), False)\n self.assertEqual(self.user1.has_module_perms(\"app2\"), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L249_C8", "label": "assertEqual()", "type": "expression", "loc": [249, 249], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L248_C4", "vector": [8, 2, 0.9842, 0.004, 2, 0.57, 0.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.has_module_perms(\"app1\"), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L250_C8", "label": "assertEqual()", "type": "expression", "loc": [250, 250], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L248_C4", "vector": [8, 2, 0.9881, 0.004, 2, 0.57, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.has_module_perms(\"app2\"), False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L252_C4", "label": "test_get_all_permissions", "type": "function", "loc": [252, 253], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "vector": [2, 1, 0.998, 0.0079, 1, 0.11, 1.0, 643, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_get_all_permissions", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_get_all_permissions(self):\n self.assertEqual(self.user1.get_all_permissions(TestObj()), set())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L253_C8", "label": "assertEqual()", "type": "expression", "loc": [253, 253], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L252_C4", "vector": [8, 2, 1.0, 0.004, 2, 0.07, 0.0, 299, 3, 2, 0, 0, 0, 0, 4], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(self.user1.get_all_permissions(TestObj()), set())"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L81_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L83_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L97_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L98_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L97_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L103_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L103_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L104_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L104_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L105_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L103_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L107_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L108_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L108_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L109_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L108_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L110_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L110_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L112_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L103_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L97_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L115_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L115_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L116_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L97_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L118_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L119_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L120_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L122_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L122_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L123_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L125_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L126_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L127_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L127_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L128_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L127_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L130_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L97_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L132_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L132_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L133_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L134_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L132_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L136_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L137_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L132_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L139_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L139_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L140_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:If_L139_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Return_L142_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L146_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L149_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L152_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L153_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L155_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L157_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L158_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L161_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L167_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L168_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L169_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L170_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L171_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L172_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L174_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L174_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L175_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L174_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L176_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L174_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L177_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L179_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L180_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L181_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L182_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L183_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L186_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L188_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L191_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L193_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L197_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L201_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L203_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L203_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L204_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L203_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L205_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L203_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L206_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L208_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L208_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L209_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L211_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L211_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L212_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L211_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L213_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L215_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L215_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L216_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L215_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L217_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L219_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L219_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L220_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L219_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L221_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L196_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L223_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L224_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L228_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L231_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L233_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L233_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L234_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L233_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L235_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L233_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L236_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L238_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Assign_L239_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L241_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L242_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L243_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L245_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L245_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L246_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L248_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L248_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L249_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L248_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L250_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:ClassDef_L227_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L252_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98603:FunctionDef_L252_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98603:Expr_L253_C8"}] |
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm
from django.test import TestCase
class UserCreationFormTest(TestCase):
fixtures = ['authtestdata.json']
def test_user_already_exists(self):
data = {
'username': 'testclient',
'password1': 'test123',
'password2': 'test123',
}
form = UserCreationForm(data)
self.assertFalse(form.is_valid())
self.assertEqual(form["username"].errors,
[u'A user with that username already exists.'])
def test_invalid_data(self):
data = {
'username': 'jsmith!',
'password1': 'test123',
'password2': 'test123',
}
form = UserCreationForm(data)
self.assertFalse(form.is_valid())
self.assertEqual(form["username"].errors,
[u'This value may contain only letters, numbers and @/./+/-/_ characters.'])
def test_password_verification(self):
# The verification password is incorrect.
data = {
'username': 'jsmith',
'password1': 'test123',
'password2': 'test',
}
form = UserCreationForm(data)
self.assertFalse(form.is_valid())
self.assertEqual(form["password2"].errors,
[u"The two password fields didn't match."])
def test_both_passwords(self):
# One (or both) passwords weren't given
data = {'username': 'jsmith'}
form = UserCreationForm(data)
self.assertFalse(form.is_valid())
self.assertEqual(form['password1'].errors,
[u'This field is required.'])
self.assertEqual(form['password2'].errors,
[u'This field is required.'])
data['password2'] = 'test123'
form = UserCreationForm(data)
self.assertFalse(form.is_valid())
self.assertEqual(form['password1'].errors,
[u'This field is required.'])
def test_success(self):
# The success case.
data = {
'username': 'jsmith@example.com',
'password1': 'test123',
'password2': 'test123',
}
form = UserCreationForm(data)
self.assertTrue(form.is_valid())
u = form.save()
self.assertEqual(repr(u), '<User: jsmith@example.com>')
class AuthenticationFormTest(TestCase):
fixtures = ['authtestdata.json']
def test_invalid_username(self):
# The user submits an invalid username.
data = {
'username': 'jsmith_does_not_exist',
'password': 'test123',
}
form = AuthenticationForm(None, data)
self.assertFalse(form.is_valid())
self.assertEqual(form.non_field_errors(),
[u'Please enter a correct username and password. Note that both fields are case-sensitive.'])
def test_inactive_user(self):
# The user is inactive.
data = {
'username': 'inactive',
'password': 'password',
}
form = AuthenticationForm(None, data)
self.assertFalse(form.is_valid())
self.assertEqual(form.non_field_errors(),
[u'This account is inactive.'])
def test_success(self):
# The success case
data = {
'username': 'testclient',
'password': 'password',
}
form = AuthenticationForm(None, data)
self.assertTrue(form.is_valid())
self.assertEqual(form.non_field_errors(), [])
class SetPasswordFormTest(TestCase):
fixtures = ['authtestdata.json']
def test_password_verification(self):
# The two new passwords do not match.
user = User.objects.get(username='testclient')
data = {
'new_password1': 'abc123',
'new_password2': 'abc',
}
form = SetPasswordForm(user, data)
self.assertFalse(form.is_valid())
self.assertEqual(form["new_password2"].errors,
[u"The two password fields didn't match."])
def test_success(self):
user = User.objects.get(username='testclient')
data = {
'new_password1': 'abc123',
'new_password2': 'abc123',
}
form = SetPasswordForm(user, data)
self.assertTrue(form.is_valid())
class PasswordChangeFormTest(TestCase):
fixtures = ['authtestdata.json']
def test_incorrect_password(self):
user = User.objects.get(username='testclient')
data = {
'old_password': 'test',
'new_password1': 'abc123',
'new_password2': 'abc123',
}
form = PasswordChangeForm(user, data)
self.assertFalse(form.is_valid())
self.assertEqual(form["old_password"].errors,
[u'Your old password was entered incorrectly. Please enter it again.'])
def test_password_verification(self):
# The two new passwords do not match.
user = User.objects.get(username='testclient')
data = {
'old_password': 'password',
'new_password1': 'abc123',
'new_password2': 'abc',
}
form = PasswordChangeForm(user, data)
self.assertFalse(form.is_valid())
self.assertEqual(form["new_password2"].errors,
[u"The two password fields didn't match."])
def test_success(self):
# The success case.
user = User.objects.get(username='testclient')
data = {
'old_password': 'password',
'new_password1': 'abc123',
'new_password2': 'abc123',
}
form = PasswordChangeForm(user, data)
self.assertTrue(form.is_valid())
def test_field_order(self):
# Regression test - check the order of fields:
user = User.objects.get(username='testclient')
self.assertEqual(PasswordChangeForm(user, {}).fields.keys(),
['old_password', 'new_password1', 'new_password2'])
class UserChangeFormTest(TestCase):
fixtures = ['authtestdata.json']
def test_username_validity(self):
user = User.objects.get(username='testclient')
data = {'username': 'not valid'}
form = UserChangeForm(data, instance=user)
self.assertFalse(form.is_valid())
self.assertEqual(form['username'].errors,
[u'This value may contain only letters, numbers and @/./+/-/_ characters.'])
def test_bug_14242(self):
# A regression test, introduce by adding an optimization for the
# UserChangeForm.
class MyUserForm(UserChangeForm):
def __init__(self, *args, **kwargs):
super(MyUserForm, self).__init__(*args, **kwargs)
self.fields['groups'].help_text = 'These groups give users different permissions'
class Meta(UserChangeForm.Meta):
fields = ('groups',)
# Just check we can create it
form = MyUserForm({})
class PasswordResetFormTest(TestCase):
fixtures = ['authtestdata.json']
def test_invalid_email(self):
data = {'email':'not valid'}
form = PasswordResetForm(data)
self.assertFalse(form.is_valid())
self.assertEqual(form['email'].errors,
[u'Enter a valid e-mail address.'])
def test_nonexistant_email(self):
# Test nonexistant email address
data = {'email':'foo@bar.com'}
form = PasswordResetForm(data)
self.assertFalse(form.is_valid())
self.assertEqual(form.errors,
{'email': [u"That e-mail address doesn't have an associated user account. Are you sure you've registered?"]})
def test_cleaned_data(self):
# Regression test
user = User.objects.create_user("jsmith3", "jsmith3@example.com", "test123")
data = {'email':'jsmith3@example.com'}
form = PasswordResetForm(data)
self.assertTrue(form.is_valid())
self.assertEqual(form.cleaned_data['email'], u'jsmith3@example.com')
def test_bug_5605(self):
# bug #5605, preserve the case of the user name (before the @ in the
# email address) when creating a user.
user = User.objects.create_user('forms_test2', 'tesT@EXAMple.com', 'test')
self.assertEqual(user.email, 'tesT@example.com')
user = User.objects.create_user('forms_test3', 'tesT', 'test')
self.assertEqual(user.email, 'tesT')
| ajibawa-2023/Python-Code-Large/train/row_98604 | 127 | 252 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98604:ImportFrom_L1_C0", "label": "from django.contrib.auth.models import User", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.004, 0.004, 0, 0.66, 0.0, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:ImportFrom_L2_C0", "label": "from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, PasswordChangeForm\u2026", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0079, 0.004, 0, 0.66, 0.125, 579, 0, 6, 0, 0, 579, 0, 0], "semantic": {"name": "django.contrib.auth.forms", "arg_names": [], "import_names": ["UserCreationForm", "AuthenticationForm", "PasswordChangeForm", "SetPasswordForm", "UserChangeForm", "PasswordResetForm"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:ImportFrom_L3_C0", "label": "from django.test import TestCase", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0119, 0.004, 0, 0.66, 0.25, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.test", "arg_names": [], "import_names": ["TestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.test import TestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "label": "UserCreationFormTest", "type": "class", "loc": [6, 74], "level": 0, "parent": null, "vector": [3, 0, 0.1587, 0.2738, 0, 0.66, 0.375, 867, 0, 5, 0, 0, 3, 0, 27], "semantic": {"name": "UserCreationFormTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class UserCreationFormTest(TestCase):\n\n fixtures = ['authtestdata.json']\n\n def test_user_already_exists(self):\n data = {\n 'username': 'testclient',\n 'password1': 'test123',"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L8_C4", "label": "fixtures =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "vector": [14, 1, 0.0317, 0.004, 1, 0.17, 0.0, 752, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "fixtures", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fixtures = ['authtestdata.json']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L10_C4", "label": "test_user_already_exists", "type": "function", "loc": [10, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "vector": [2, 1, 0.0575, 0.0397, 1, 0.17, 0.2, 621, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_user_already_exists", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_user_already_exists(self):\n data = {\n 'username': 'testclient',\n 'password1': 'test123',\n 'password2': 'test123',\n }\n form = UserCreationForm(data)\n self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L11_C8", "label": "data =", "type": "assigned_variable", "loc": [11, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L10_C4", "vector": [14, 2, 0.0516, 0.0198, 2, 0.81, 0.0, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\n 'username': 'testclient',\n 'password1': 'test123',\n 'password2': 'test123',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L16_C8", "label": "form = UserCreationForm()", "type": "assigned_variable", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L10_C4", "vector": [14, 2, 0.0635, 0.004, 2, 0.81, 0.3333, 761, 3, 1, 0, 0, 829, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "UserCreationForm", "annotation": ""}, "snippet": " form = UserCreationForm(data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L17_C8", "label": "assertFalse()", "type": "expression", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L10_C4", "vector": [8, 2, 0.0675, 0.004, 2, 0.81, 0.6667, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L18_C8", "label": "assertEqual()", "type": "expression", "loc": [18, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L10_C4", "vector": [8, 2, 0.0734, 0.0079, 2, 0.81, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form[\"username\"].errors,\n [u'A user with that username already exists.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L21_C4", "label": "test_invalid_data", "type": "function", "loc": [21, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "vector": [2, 1, 0.1012, 0.0397, 1, 0.17, 0.4, 338, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_invalid_data", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_invalid_data(self):\n data = {\n 'username': 'jsmith!',\n 'password1': 'test123',\n 'password2': 'test123',\n }\n form = UserCreationForm(data)\n self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L22_C8", "label": "data =", "type": "assigned_variable", "loc": [22, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L21_C4", "vector": [14, 2, 0.0952, 0.0198, 2, 0.1, 0.0, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\n 'username': 'jsmith!',\n 'password1': 'test123',\n 'password2': 'test123',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L27_C8", "label": "form = UserCreationForm()", "type": "assigned_variable", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L21_C4", "vector": [14, 2, 0.1071, 0.004, 2, 0.1, 0.3333, 761, 3, 1, 0, 0, 829, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "UserCreationForm", "annotation": ""}, "snippet": " form = UserCreationForm(data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L28_C8", "label": "assertFalse()", "type": "expression", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L21_C4", "vector": [8, 2, 0.1111, 0.004, 2, 0.1, 0.6667, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L29_C8", "label": "assertEqual()", "type": "expression", "loc": [29, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L21_C4", "vector": [8, 2, 0.1171, 0.0079, 2, 0.1, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form[\"username\"].errors,\n [u'This value may contain only letters, numbers and @/./+/-/_ characters.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L33_C4", "label": "test_password_verification", "type": "function", "loc": [33, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "vector": [2, 1, 0.1508, 0.0437, 1, 0.17, 0.6, 500, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_password_verification", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_password_verification(self):\n # The verification password is incorrect.\n data = {\n 'username': 'jsmith',\n 'password1': 'test123',\n 'password2': 'test',\n }\n form = UserCreationForm(data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L35_C8", "label": "data =", "type": "assigned_variable", "loc": [35, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L33_C4", "vector": [14, 2, 0.1468, 0.0198, 2, 0.15, 0.0, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\n 'username': 'jsmith',\n 'password1': 'test123',\n 'password2': 'test',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L40_C8", "label": "form = UserCreationForm()", "type": "assigned_variable", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L33_C4", "vector": [14, 2, 0.1587, 0.004, 2, 0.15, 0.3333, 761, 3, 1, 0, 0, 829, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "UserCreationForm", "annotation": ""}, "snippet": " form = UserCreationForm(data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L41_C8", "label": "assertFalse()", "type": "expression", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L33_C4", "vector": [8, 2, 0.1627, 0.004, 2, 0.15, 0.6667, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L42_C8", "label": "assertEqual()", "type": "expression", "loc": [42, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L33_C4", "vector": [8, 2, 0.1687, 0.0079, 2, 0.15, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form[\"password2\"].errors,\n [u\"The two password fields didn't match.\"])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "label": "test_both_passwords", "type": "function", "loc": [46, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "vector": [2, 1, 0.2123, 0.0635, 1, 0.17, 0.8, 117, 0, 1, 0, 0, 0, 0, 9], "semantic": {"name": "test_both_passwords", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_both_passwords(self):\n # One (or both) passwords weren't given\n data = {'username': 'jsmith'}\n form = UserCreationForm(data)\n self.assertFalse(form.is_valid())\n self.assertEqual(form['password1'].errors,\n [u'This field is required.'])\n self.assertEqual(form['password2'].errors,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L48_C8", "label": "data =", "type": "assigned_variable", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "vector": [14, 2, 0.1905, 0.004, 2, 0.73, 0.0, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {'username': 'jsmith'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L49_C8", "label": "form = UserCreationForm()", "type": "assigned_variable", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "vector": [14, 2, 0.1944, 0.004, 2, 0.73, 0.125, 761, 3, 1, 0, 0, 829, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "UserCreationForm", "annotation": ""}, "snippet": " form = UserCreationForm(data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L50_C8", "label": "assertFalse()", "type": "expression", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "vector": [8, 2, 0.1984, 0.004, 2, 0.73, 0.25, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L51_C8", "label": "assertEqual()", "type": "expression", "loc": [51, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "vector": [8, 2, 0.2044, 0.0079, 2, 0.73, 0.375, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form['password1'].errors,\n [u'This field is required.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L53_C8", "label": "assertEqual()", "type": "expression", "loc": [53, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "vector": [8, 2, 0.2123, 0.0079, 2, 0.73, 0.5, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form['password2'].errors,\n [u'This field is required.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L57_C8", "label": "assign", "type": "assigned_variable", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "vector": [14, 2, 0.2262, 0.004, 2, 0.73, 0.625, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data['password2'] = 'test123'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L58_C8", "label": "form = UserCreationForm()", "type": "assigned_variable", "loc": [58, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "vector": [14, 2, 0.2302, 0.004, 2, 0.73, 0.75, 761, 3, 1, 0, 0, 829, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "UserCreationForm", "annotation": ""}, "snippet": " form = UserCreationForm(data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L59_C8", "label": "assertFalse()", "type": "expression", "loc": [59, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "vector": [8, 2, 0.2341, 0.004, 2, 0.73, 0.875, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L60_C8", "label": "assertEqual()", "type": "expression", "loc": [60, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "vector": [8, 2, 0.2401, 0.0079, 2, 0.73, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form['password1'].errors,\n [u'This field is required.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L63_C4", "label": "test_success", "type": "function", "loc": [63, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "vector": [2, 1, 0.2718, 0.0476, 1, 0.17, 1.0, 610, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_success", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_success(self):\n # The success case.\n\n data = {\n 'username': 'jsmith@example.com',\n 'password1': 'test123',\n 'password2': 'test123',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L66_C8", "label": "data =", "type": "assigned_variable", "loc": [66, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L63_C4", "vector": [14, 2, 0.2698, 0.0198, 2, 0.11, 0.0, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\n 'username': 'jsmith@example.com',\n 'password1': 'test123',\n 'password2': 'test123',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L71_C8", "label": "form = UserCreationForm()", "type": "assigned_variable", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L63_C4", "vector": [14, 2, 0.2817, 0.004, 2, 0.11, 0.25, 761, 3, 1, 0, 0, 829, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "UserCreationForm", "annotation": ""}, "snippet": " form = UserCreationForm(data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L72_C8", "label": "assertTrue()", "type": "expression", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L63_C4", "vector": [8, 2, 0.2857, 0.004, 2, 0.11, 0.5, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L73_C8", "label": "u = save()", "type": "assigned_variable", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L63_C4", "vector": [14, 2, 0.2897, 0.004, 2, 0.11, 0.75, 609, 3, 0, 0, 0, 928, 10, 1], "semantic": {"name": "u", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " u = form.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L74_C8", "label": "assertEqual()", "type": "expression", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L63_C4", "vector": [8, 2, 0.2937, 0.004, 2, 0.11, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(repr(u), '<User: jsmith@example.com>')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L77_C0", "label": "AuthenticationFormTest", "type": "class", "loc": [77, 113], "level": 0, "parent": null, "vector": [3, 0, 0.377, 0.1468, 0, 0.66, 0.5, 171, 0, 3, 0, 0, 3, 0, 15], "semantic": {"name": "AuthenticationFormTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AuthenticationFormTest(TestCase):\n\n fixtures = ['authtestdata.json']\n\n def test_invalid_username(self):\n # The user submits an invalid username.\n\n data = {"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L79_C4", "label": "fixtures =", "type": "assigned_variable", "loc": [79, 79], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L77_C0", "vector": [14, 1, 0.3135, 0.004, 1, 0.89, 0.0, 752, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "fixtures", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fixtures = ['authtestdata.json']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L81_C4", "label": "test_invalid_username", "type": "function", "loc": [81, 91], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L77_C0", "vector": [2, 1, 0.3413, 0.0437, 1, 0.89, 0.3333, 915, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_invalid_username", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_invalid_username(self):\n # The user submits an invalid username.\n\n data = {\n 'username': 'jsmith_does_not_exist',\n 'password': 'test123',\n }\n form = AuthenticationForm(None, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L84_C8", "label": "data =", "type": "assigned_variable", "loc": [84, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L81_C4", "vector": [14, 2, 0.3393, 0.0159, 2, 0.87, 0.0, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\n 'username': 'jsmith_does_not_exist',\n 'password': 'test123',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L88_C8", "label": "form = AuthenticationForm()", "type": "assigned_variable", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L81_C4", "vector": [14, 2, 0.3492, 0.004, 2, 0.87, 0.3333, 761, 3, 2, 0, 0, 506, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "AuthenticationForm", "annotation": ""}, "snippet": " form = AuthenticationForm(None, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L89_C8", "label": "assertFalse()", "type": "expression", "loc": [89, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L81_C4", "vector": [8, 2, 0.3532, 0.004, 2, 0.87, 0.6667, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L90_C8", "label": "assertEqual()", "type": "expression", "loc": [90, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L81_C4", "vector": [8, 2, 0.3591, 0.0079, 2, 0.87, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form.non_field_errors(),\n [u'Please enter a correct username and password. Note that both fields are case-sensitive.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L93_C4", "label": "test_inactive_user", "type": "function", "loc": [93, 102], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L77_C0", "vector": [2, 1, 0.3869, 0.0397, 1, 0.89, 0.6667, 190, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_inactive_user", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_inactive_user(self):\n # The user is inactive.\n data = {\n 'username': 'inactive',\n 'password': 'password',\n }\n form = AuthenticationForm(None, data)\n self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L95_C8", "label": "data =", "type": "assigned_variable", "loc": [95, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L93_C4", "vector": [14, 2, 0.3829, 0.0159, 2, 0.34, 0.0, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\n 'username': 'inactive',\n 'password': 'password',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L99_C8", "label": "form = AuthenticationForm()", "type": "assigned_variable", "loc": [99, 99], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L93_C4", "vector": [14, 2, 0.3929, 0.004, 2, 0.34, 0.3333, 761, 3, 2, 0, 0, 506, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "AuthenticationForm", "annotation": ""}, "snippet": " form = AuthenticationForm(None, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L100_C8", "label": "assertFalse()", "type": "expression", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L93_C4", "vector": [8, 2, 0.3968, 0.004, 2, 0.34, 0.6667, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L101_C8", "label": "assertEqual()", "type": "expression", "loc": [101, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L93_C4", "vector": [8, 2, 0.4028, 0.0079, 2, 0.34, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form.non_field_errors(),\n [u'This account is inactive.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L105_C4", "label": "test_success", "type": "function", "loc": [105, 113], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L77_C0", "vector": [2, 1, 0.4325, 0.0357, 1, 0.89, 1.0, 610, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_success", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_success(self):\n # The success case\n data = {\n 'username': 'testclient',\n 'password': 'password',\n }\n form = AuthenticationForm(None, data)\n self.assertTrue(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L107_C8", "label": "data =", "type": "assigned_variable", "loc": [107, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L105_C4", "vector": [14, 2, 0.4306, 0.0159, 2, 0.09, 0.0, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\n 'username': 'testclient',\n 'password': 'password',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L111_C8", "label": "form = AuthenticationForm()", "type": "assigned_variable", "loc": [111, 111], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L105_C4", "vector": [14, 2, 0.4405, 0.004, 2, 0.09, 0.3333, 761, 3, 2, 0, 0, 506, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "AuthenticationForm", "annotation": ""}, "snippet": " form = AuthenticationForm(None, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L112_C8", "label": "assertTrue()", "type": "expression", "loc": [112, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L105_C4", "vector": [8, 2, 0.4444, 0.004, 2, 0.09, 0.6667, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L113_C8", "label": "assertEqual()", "type": "expression", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L105_C4", "vector": [8, 2, 0.4484, 0.004, 2, 0.09, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form.non_field_errors(), [])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L116_C0", "label": "SetPasswordFormTest", "type": "class", "loc": [116, 139], "level": 0, "parent": null, "vector": [3, 0, 0.506, 0.0952, 0, 0.66, 0.625, 813, 0, 2, 0, 0, 3, 0, 9], "semantic": {"name": "SetPasswordFormTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SetPasswordFormTest(TestCase):\n\n fixtures = ['authtestdata.json']\n\n def test_password_verification(self):\n # The two new passwords do not match.\n user = User.objects.get(username='testclient')\n data = {"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L118_C4", "label": "fixtures =", "type": "assigned_variable", "loc": [118, 118], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L116_C0", "vector": [14, 1, 0.4683, 0.004, 1, 0.16, 0.0, 752, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "fixtures", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fixtures = ['authtestdata.json']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L120_C4", "label": "test_password_verification", "type": "function", "loc": [120, 130], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L116_C0", "vector": [2, 1, 0.496, 0.0437, 1, 0.16, 0.5, 500, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_password_verification", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_password_verification(self):\n # The two new passwords do not match.\n user = User.objects.get(username='testclient')\n data = {\n 'new_password1': 'abc123',\n 'new_password2': 'abc',\n }\n form = SetPasswordForm(user, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L122_C8", "label": "user = get()", "type": "assigned_variable", "loc": [122, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L120_C4", "vector": [14, 2, 0.4841, 0.004, 2, 0.29, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='testclient')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L123_C8", "label": "data =", "type": "assigned_variable", "loc": [123, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L120_C4", "vector": [14, 2, 0.494, 0.0159, 2, 0.29, 0.25, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\n 'new_password1': 'abc123',\n 'new_password2': 'abc',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L127_C8", "label": "form = SetPasswordForm()", "type": "assigned_variable", "loc": [127, 127], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L120_C4", "vector": [14, 2, 0.504, 0.004, 2, 0.29, 0.5, 761, 3, 2, 0, 0, 828, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "SetPasswordForm", "annotation": ""}, "snippet": " form = SetPasswordForm(user, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L128_C8", "label": "assertFalse()", "type": "expression", "loc": [128, 128], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L120_C4", "vector": [8, 2, 0.5079, 0.004, 2, 0.29, 0.75, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L129_C8", "label": "assertEqual()", "type": "expression", "loc": [129, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L120_C4", "vector": [8, 2, 0.5139, 0.0079, 2, 0.29, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form[\"new_password2\"].errors,\n [u\"The two password fields didn't match.\"])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L132_C4", "label": "test_success", "type": "function", "loc": [132, 139], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L116_C0", "vector": [2, 1, 0.5377, 0.0317, 1, 0.16, 1.0, 610, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_success", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_success(self):\n user = User.objects.get(username='testclient')\n data = {\n 'new_password1': 'abc123',\n 'new_password2': 'abc123',\n }\n form = SetPasswordForm(user, data)\n self.assertTrue(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L133_C8", "label": "user = get()", "type": "assigned_variable", "loc": [133, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L132_C4", "vector": [14, 2, 0.5278, 0.004, 2, 0.91, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='testclient')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L134_C8", "label": "data =", "type": "assigned_variable", "loc": [134, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L132_C4", "vector": [14, 2, 0.5377, 0.0159, 2, 0.91, 0.3333, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\n 'new_password1': 'abc123',\n 'new_password2': 'abc123',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L138_C8", "label": "form = SetPasswordForm()", "type": "assigned_variable", "loc": [138, 138], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L132_C4", "vector": [14, 2, 0.5476, 0.004, 2, 0.91, 0.6667, 761, 3, 2, 0, 0, 828, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "SetPasswordForm", "annotation": ""}, "snippet": " form = SetPasswordForm(user, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L139_C8", "label": "assertTrue()", "type": "expression", "loc": [139, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L132_C4", "vector": [8, 2, 0.5516, 0.004, 2, 0.91, 1.0, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L142_C0", "label": "PasswordChangeFormTest", "type": "class", "loc": [142, 188], "level": 0, "parent": null, "vector": [3, 0, 0.6548, 0.1865, 0, 0.66, 0.75, 133, 0, 4, 0, 0, 3, 0, 18], "semantic": {"name": "PasswordChangeFormTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PasswordChangeFormTest(TestCase):\n\n fixtures = ['authtestdata.json']\n\n def test_incorrect_password(self):\n user = User.objects.get(username='testclient')\n data = {\n 'old_password': 'test',"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L144_C4", "label": "fixtures =", "type": "assigned_variable", "loc": [144, 144], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L142_C0", "vector": [14, 1, 0.5714, 0.004, 1, 0.29, 0.0, 752, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "fixtures", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fixtures = ['authtestdata.json']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L146_C4", "label": "test_incorrect_password", "type": "function", "loc": [146, 156], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L142_C0", "vector": [2, 1, 0.5992, 0.0437, 1, 0.29, 0.25, 147, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_incorrect_password", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_incorrect_password(self):\n user = User.objects.get(username='testclient')\n data = {\n 'old_password': 'test',\n 'new_password1': 'abc123',\n 'new_password2': 'abc123',\n }\n form = PasswordChangeForm(user, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L147_C8", "label": "user = get()", "type": "assigned_variable", "loc": [147, 147], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L146_C4", "vector": [14, 2, 0.5833, 0.004, 2, 0.12, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='testclient')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L148_C8", "label": "data =", "type": "assigned_variable", "loc": [148, 152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L146_C4", "vector": [14, 2, 0.5952, 0.0198, 2, 0.12, 0.25, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\n 'old_password': 'test',\n 'new_password1': 'abc123',\n 'new_password2': 'abc123',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L153_C8", "label": "form = PasswordChangeForm()", "type": "assigned_variable", "loc": [153, 153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L146_C4", "vector": [14, 2, 0.6071, 0.004, 2, 0.12, 0.5, 761, 3, 2, 0, 0, 810, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "PasswordChangeForm", "annotation": ""}, "snippet": " form = PasswordChangeForm(user, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L154_C8", "label": "assertFalse()", "type": "expression", "loc": [154, 154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L146_C4", "vector": [8, 2, 0.6111, 0.004, 2, 0.12, 0.75, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L155_C8", "label": "assertEqual()", "type": "expression", "loc": [155, 156], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L146_C4", "vector": [8, 2, 0.6171, 0.0079, 2, 0.12, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form[\"old_password\"].errors,\n [u'Your old password was entered incorrectly. Please enter it again.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L159_C4", "label": "test_password_verification", "type": "function", "loc": [159, 170], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L142_C0", "vector": [2, 1, 0.6528, 0.0476, 1, 0.29, 0.5, 500, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_password_verification", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_password_verification(self):\n # The two new passwords do not match.\n user = User.objects.get(username='testclient')\n data = {\n 'old_password': 'password',\n 'new_password1': 'abc123',\n 'new_password2': 'abc',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L161_C8", "label": "user = get()", "type": "assigned_variable", "loc": [161, 161], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L159_C4", "vector": [14, 2, 0.6389, 0.004, 2, 0.59, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='testclient')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L162_C8", "label": "data =", "type": "assigned_variable", "loc": [162, 166], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L159_C4", "vector": [14, 2, 0.6508, 0.0198, 2, 0.59, 0.25, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\n 'old_password': 'password',\n 'new_password1': 'abc123',\n 'new_password2': 'abc',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L167_C8", "label": "form = PasswordChangeForm()", "type": "assigned_variable", "loc": [167, 167], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L159_C4", "vector": [14, 2, 0.6627, 0.004, 2, 0.59, 0.5, 761, 3, 2, 0, 0, 810, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "PasswordChangeForm", "annotation": ""}, "snippet": " form = PasswordChangeForm(user, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L168_C8", "label": "assertFalse()", "type": "expression", "loc": [168, 168], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L159_C4", "vector": [8, 2, 0.6667, 0.004, 2, 0.59, 0.75, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L169_C8", "label": "assertEqual()", "type": "expression", "loc": [169, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L159_C4", "vector": [8, 2, 0.6726, 0.0079, 2, 0.59, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form[\"new_password2\"].errors,\n [u\"The two password fields didn't match.\"])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L173_C4", "label": "test_success", "type": "function", "loc": [173, 182], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L142_C0", "vector": [2, 1, 0.7044, 0.0397, 1, 0.29, 0.75, 610, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_success", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_success(self):\n # The success case.\n user = User.objects.get(username='testclient')\n data = {\n 'old_password': 'password',\n 'new_password1': 'abc123',\n 'new_password2': 'abc123',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L175_C8", "label": "user = get()", "type": "assigned_variable", "loc": [175, 175], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L173_C4", "vector": [14, 2, 0.6944, 0.004, 2, 0.83, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='testclient')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L176_C8", "label": "data =", "type": "assigned_variable", "loc": [176, 180], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L173_C4", "vector": [14, 2, 0.7063, 0.0198, 2, 0.83, 0.3333, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\n 'old_password': 'password',\n 'new_password1': 'abc123',\n 'new_password2': 'abc123',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L181_C8", "label": "form = PasswordChangeForm()", "type": "assigned_variable", "loc": [181, 181], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L173_C4", "vector": [14, 2, 0.7183, 0.004, 2, 0.83, 0.6667, 761, 3, 2, 0, 0, 810, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "PasswordChangeForm", "annotation": ""}, "snippet": " form = PasswordChangeForm(user, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L182_C8", "label": "assertTrue()", "type": "expression", "loc": [182, 182], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L173_C4", "vector": [8, 2, 0.7222, 0.004, 2, 0.83, 1.0, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L184_C4", "label": "test_field_order", "type": "function", "loc": [184, 188], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L142_C0", "vector": [2, 1, 0.7381, 0.0198, 1, 0.29, 1.0, 474, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_field_order", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_field_order(self):\n # Regression test - check the order of fields:\n user = User.objects.get(username='testclient')\n self.assertEqual(PasswordChangeForm(user, {}).fields.keys(),\n ['old_password', 'new_password1', 'new_password2'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L186_C8", "label": "user = get()", "type": "assigned_variable", "loc": [186, 186], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L184_C4", "vector": [14, 2, 0.7381, 0.004, 2, 0.33, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='testclient')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L187_C8", "label": "assertEqual()", "type": "expression", "loc": [187, 188], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L184_C4", "vector": [8, 2, 0.744, 0.0079, 2, 0.33, 1.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(PasswordChangeForm(user, {}).fields.keys(),\n ['old_password', 'new_password1', 'new_password2'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L190_C0", "label": "UserChangeFormTest", "type": "class", "loc": [190, 215], "level": 0, "parent": null, "vector": [3, 0, 0.8036, 0.1032, 0, 0.66, 0.875, 357, 0, 3, 0, 0, 3, 0, 8], "semantic": {"name": "UserChangeFormTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class UserChangeFormTest(TestCase):\n\n fixtures = ['authtestdata.json']\n\n def test_username_validity(self):\n user = User.objects.get(username='testclient')\n data = {'username': 'not valid'}\n form = UserChangeForm(data, instance=user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L192_C4", "label": "fixtures =", "type": "assigned_variable", "loc": [192, 192], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L190_C0", "vector": [14, 1, 0.7619, 0.004, 1, 0.05, 0.0, 752, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "fixtures", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fixtures = ['authtestdata.json']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L194_C4", "label": "test_username_validity", "type": "function", "loc": [194, 200], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L190_C0", "vector": [2, 1, 0.7817, 0.0278, 1, 0.05, 0.5, 518, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_username_validity", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_username_validity(self):\n user = User.objects.get(username='testclient')\n data = {'username': 'not valid'}\n form = UserChangeForm(data, instance=user)\n self.assertFalse(form.is_valid())\n self.assertEqual(form['username'].errors,\n [u'This value may contain only letters, numbers and @/./+/-/_ characters.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L195_C8", "label": "user = get()", "type": "assigned_variable", "loc": [195, 195], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L194_C4", "vector": [14, 2, 0.7738, 0.004, 2, 0.75, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='testclient')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L196_C8", "label": "data =", "type": "assigned_variable", "loc": [196, 196], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L194_C4", "vector": [14, 2, 0.7778, 0.004, 2, 0.75, 0.25, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {'username': 'not valid'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L197_C8", "label": "form = UserChangeForm()", "type": "assigned_variable", "loc": [197, 197], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L194_C4", "vector": [14, 2, 0.7817, 0.004, 2, 0.75, 0.5, 761, 3, 2, 0, 0, 456, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "UserChangeForm", "annotation": ""}, "snippet": " form = UserChangeForm(data, instance=user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L198_C8", "label": "assertFalse()", "type": "expression", "loc": [198, 198], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L194_C4", "vector": [8, 2, 0.7857, 0.004, 2, 0.75, 0.75, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L199_C8", "label": "assertEqual()", "type": "expression", "loc": [199, 200], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L194_C4", "vector": [8, 2, 0.7917, 0.0079, 2, 0.75, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form['username'].errors,\n [u'This value may contain only letters, numbers and @/./+/-/_ characters.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L202_C4", "label": "test_bug_14242", "type": "function", "loc": [202, 215], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L190_C0", "vector": [2, 1, 0.8274, 0.0556, 1, 0.05, 1.0, 197, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "test_bug_14242", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_bug_14242(self):\n # A regression test, introduce by adding an optimization for the\n # UserChangeForm.\n\n class MyUserForm(UserChangeForm):\n def __init__(self, *args, **kwargs):\n super(MyUserForm, self).__init__(*args, **kwargs)\n self.fields['groups'].help_text = 'These groups give users different permissions'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L206_C8", "label": "MyUserForm", "type": "class", "loc": [206, 212], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L202_C4", "vector": [3, 2, 0.8294, 0.0278, 2, 0.22, 0.0, 813, 0, 1, 0, 0, 456, 0, 2], "semantic": {"name": "MyUserForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class MyUserForm(UserChangeForm):\n def __init__(self, *args, **kwargs):\n super(MyUserForm, self).__init__(*args, **kwargs)\n self.fields['groups'].help_text = 'These groups give users different permissions'\n\n class Meta(UserChangeForm.Meta):\n fields = ('groups',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L207_C12", "label": "__init__", "type": "function", "loc": [207, 209], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L206_C8", "vector": [2, 3, 0.8254, 0.0119, 3, 0.19, 0.0, 555, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, *args, **kwargs):\n super(MyUserForm, self).__init__(*args, **kwargs)\n self.fields['groups'].help_text = 'These groups give users different permissions'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L208_C16", "label": "__init__()", "type": "expression", "loc": [208, 208], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L207_C12", "vector": [8, 4, 0.8254, 0.004, 4, 0.0, 0.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(MyUserForm, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L209_C16", "label": "self.fields['groups'].help_text =", "type": "assigned_variable", "loc": [209, 209], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L207_C12", "vector": [14, 4, 0.8294, 0.004, 4, 0.0, 1.0, 593, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "self.fields['groups'].help_text", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.fields['groups'].help_text = 'These groups give users different permissions'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L211_C12", "label": "Meta", "type": "class", "loc": [211, 212], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L206_C8", "vector": [3, 3, 0.8393, 0.0079, 3, 0.19, 1.0, 130, 0, 0, 0, 0, 193, 0, 0], "semantic": {"name": "Meta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Meta(UserChangeForm.Meta):\n fields = ('groups',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L212_C16", "label": "fields =", "type": "assigned_variable", "loc": [212, 212], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L211_C12", "vector": [14, 4, 0.8413, 0.004, 4, 0.96, 0.0, 358, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fields = ('groups',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L215_C8", "label": "form = MyUserForm()", "type": "assigned_variable", "loc": [215, 215], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L202_C4", "vector": [14, 2, 0.8532, 0.004, 2, 0.22, 1.0, 761, 3, 1, 0, 0, 813, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "MyUserForm", "annotation": ""}, "snippet": " form = MyUserForm({})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L218_C0", "label": "PasswordResetFormTest", "type": "class", "loc": [218, 252], "level": 0, "parent": null, "vector": [3, 0, 0.9325, 0.1389, 0, 0.66, 1.0, 807, 0, 4, 0, 0, 3, 0, 17], "semantic": {"name": "PasswordResetFormTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PasswordResetFormTest(TestCase):\n\n fixtures = ['authtestdata.json']\n\n def test_invalid_email(self):\n data = {'email':'not valid'}\n form = PasswordResetForm(data)\n self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L220_C4", "label": "fixtures =", "type": "assigned_variable", "loc": [220, 220], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L218_C0", "vector": [14, 1, 0.873, 0.004, 1, 0.91, 0.0, 752, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "fixtures", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fixtures = ['authtestdata.json']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L222_C4", "label": "test_invalid_email", "type": "function", "loc": [222, 227], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L218_C0", "vector": [2, 1, 0.8909, 0.0238, 1, 0.91, 0.25, 821, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_invalid_email", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_invalid_email(self):\n data = {'email':'not valid'}\n form = PasswordResetForm(data)\n self.assertFalse(form.is_valid())\n self.assertEqual(form['email'].errors,\n [u'Enter a valid e-mail address.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L223_C8", "label": "data =", "type": "assigned_variable", "loc": [223, 223], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L222_C4", "vector": [14, 2, 0.8849, 0.004, 2, 0.31, 0.0, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {'email':'not valid'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L224_C8", "label": "form = PasswordResetForm()", "type": "assigned_variable", "loc": [224, 224], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L222_C4", "vector": [14, 2, 0.8889, 0.004, 2, 0.31, 0.3333, 761, 3, 1, 0, 0, 527, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "PasswordResetForm", "annotation": ""}, "snippet": " form = PasswordResetForm(data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L225_C8", "label": "assertFalse()", "type": "expression", "loc": [225, 225], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L222_C4", "vector": [8, 2, 0.8929, 0.004, 2, 0.31, 0.6667, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L226_C8", "label": "assertEqual()", "type": "expression", "loc": [226, 227], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L222_C4", "vector": [8, 2, 0.8988, 0.0079, 2, 0.31, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form['email'].errors,\n [u'Enter a valid e-mail address.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L229_C4", "label": "test_nonexistant_email", "type": "function", "loc": [229, 235], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L218_C0", "vector": [2, 1, 0.9206, 0.0278, 1, 0.91, 0.5, 900, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_nonexistant_email", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_nonexistant_email(self):\n # Test nonexistant email address\n data = {'email':'foo@bar.com'}\n form = PasswordResetForm(data)\n self.assertFalse(form.is_valid())\n self.assertEqual(form.errors,\n {'email': [u\"That e-mail address doesn't have an associated user account. Are you sure you've registered?\"]})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L231_C8", "label": "data =", "type": "assigned_variable", "loc": [231, 231], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L229_C4", "vector": [14, 2, 0.9167, 0.004, 2, 0.24, 0.0, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {'email':'foo@bar.com'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L232_C8", "label": "form = PasswordResetForm()", "type": "assigned_variable", "loc": [232, 232], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L229_C4", "vector": [14, 2, 0.9206, 0.004, 2, 0.24, 0.3333, 761, 3, 1, 0, 0, 527, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "PasswordResetForm", "annotation": ""}, "snippet": " form = PasswordResetForm(data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L233_C8", "label": "assertFalse()", "type": "expression", "loc": [233, 233], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L229_C4", "vector": [8, 2, 0.9246, 0.004, 2, 0.24, 0.6667, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L234_C8", "label": "assertEqual()", "type": "expression", "loc": [234, 235], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L229_C4", "vector": [8, 2, 0.9306, 0.0079, 2, 0.24, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form.errors,\n {'email': [u\"That e-mail address doesn't have an associated user account. Are you sure you've registered?\"]})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L237_C4", "label": "test_cleaned_data", "type": "function", "loc": [237, 243], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L218_C0", "vector": [2, 1, 0.9524, 0.0278, 1, 0.91, 0.75, 325, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_cleaned_data", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_cleaned_data(self):\n # Regression test\n user = User.objects.create_user(\"jsmith3\", \"jsmith3@example.com\", \"test123\")\n data = {'email':'jsmith3@example.com'}\n form = PasswordResetForm(data)\n self.assertTrue(form.is_valid())\n self.assertEqual(form.cleaned_data['email'], u'jsmith3@example.com')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L239_C8", "label": "user = create_user()", "type": "assigned_variable", "loc": [239, 239], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L237_C4", "vector": [14, 2, 0.9484, 0.004, 2, 0.51, 0.0, 503, 3, 3, 0, 0, 946, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " user = User.objects.create_user(\"jsmith3\", \"jsmith3@example.com\", \"test123\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L240_C8", "label": "data =", "type": "assigned_variable", "loc": [240, 240], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L237_C4", "vector": [14, 2, 0.9524, 0.004, 2, 0.51, 0.25, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {'email':'jsmith3@example.com'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L241_C8", "label": "form = PasswordResetForm()", "type": "assigned_variable", "loc": [241, 241], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L237_C4", "vector": [14, 2, 0.9563, 0.004, 2, 0.51, 0.5, 761, 3, 1, 0, 0, 527, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "PasswordResetForm", "annotation": ""}, "snippet": " form = PasswordResetForm(data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L242_C8", "label": "assertTrue()", "type": "expression", "loc": [242, 242], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L237_C4", "vector": [8, 2, 0.9603, 0.004, 2, 0.51, 0.75, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(form.is_valid())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L243_C8", "label": "assertEqual()", "type": "expression", "loc": [243, 243], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L237_C4", "vector": [8, 2, 0.9643, 0.004, 2, 0.51, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(form.cleaned_data['email'], u'jsmith3@example.com')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L246_C4", "label": "test_bug_5605", "type": "function", "loc": [246, 252], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L218_C0", "vector": [2, 1, 0.9881, 0.0278, 1, 0.91, 1.0, 273, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_bug_5605", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_bug_5605(self):\n # bug #5605, preserve the case of the user name (before the @ in the\n # email address) when creating a user.\n user = User.objects.create_user('forms_test2', 'tesT@EXAMple.com', 'test')\n self.assertEqual(user.email, 'tesT@example.com')\n user = User.objects.create_user('forms_test3', 'tesT', 'test')\n self.assertEqual(user.email, 'tesT')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L249_C8", "label": "user = create_user()", "type": "assigned_variable", "loc": [249, 249], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L246_C4", "vector": [14, 2, 0.9881, 0.004, 2, 0.74, 0.0, 503, 3, 3, 0, 0, 946, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " user = User.objects.create_user('forms_test2', 'tesT@EXAMple.com', 'test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L250_C8", "label": "assertEqual()", "type": "expression", "loc": [250, 250], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L246_C4", "vector": [8, 2, 0.9921, 0.004, 2, 0.74, 0.3333, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.email, 'tesT@example.com')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L251_C8", "label": "user = create_user()", "type": "assigned_variable", "loc": [251, 251], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L246_C4", "vector": [14, 2, 0.996, 0.004, 2, 0.74, 0.6667, 503, 3, 3, 0, 0, 946, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " user = User.objects.create_user('forms_test3', 'tesT', 'test')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L252_C8", "label": "assertEqual()", "type": "expression", "loc": [252, 252], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L246_C4", "vector": [8, 2, 1.0, 0.004, 2, 0.74, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(user.email, 'tesT')"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L77_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L79_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L77_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L81_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L81_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L81_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L81_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L81_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L77_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L93_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L99_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L77_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L105_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L111_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L112_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L118_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L120_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L120_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L122_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L120_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L123_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L120_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L127_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L120_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L120_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L129_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L132_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L132_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L132_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L134_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L132_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L138_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L132_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L139_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L144_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L146_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L147_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L148_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L153_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L155_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L159_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L161_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L167_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L168_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L169_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L173_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L175_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L176_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L181_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L182_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L184_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L184_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L186_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L184_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L187_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L190_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L192_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L190_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L194_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L195_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L197_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L198_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L199_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L190_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L202_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L202_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L206_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L206_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L207_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L207_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L208_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L207_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L209_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L206_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L211_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L211_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L212_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L202_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L215_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L218_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L220_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L218_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L222_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L223_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L224_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L225_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L226_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L218_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L229_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L229_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L231_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L229_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L232_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L229_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L233_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L229_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L234_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L218_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L237_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L237_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L239_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L237_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L240_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L237_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L241_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L237_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L242_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L237_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L243_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:ClassDef_L218_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L246_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L249_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L250_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Assign_L251_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98604:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98604:Expr_L252_C8"}] |
from django.conf import settings
from django.test import TestCase
from django.contrib.auth.models import User, SiteProfileNotAvailable
class ProfileTestCase(TestCase):
fixtures = ['authtestdata.json']
def setUp(self):
"""Backs up the AUTH_PROFILE_MODULE"""
self.old_AUTH_PROFILE_MODULE = getattr(settings,
'AUTH_PROFILE_MODULE', None)
def tearDown(self):
"""Restores the AUTH_PROFILE_MODULE -- if it was not set it is deleted,
otherwise the old value is restored"""
if self.old_AUTH_PROFILE_MODULE is None and \
hasattr(settings, 'AUTH_PROFILE_MODULE'):
del settings.AUTH_PROFILE_MODULE
if self.old_AUTH_PROFILE_MODULE is not None:
settings.AUTH_PROFILE_MODULE = self.old_AUTH_PROFILE_MODULE
def test_site_profile_not_available(self):
# calling get_profile without AUTH_PROFILE_MODULE set
if hasattr(settings, 'AUTH_PROFILE_MODULE'):
del settings.AUTH_PROFILE_MODULE
user = User.objects.get(username='testclient')
self.assertRaises(SiteProfileNotAvailable, user.get_profile)
# Bad syntax in AUTH_PROFILE_MODULE:
settings.AUTH_PROFILE_MODULE = 'foobar'
self.assertRaises(SiteProfileNotAvailable, user.get_profile)
# module that doesn't exist
settings.AUTH_PROFILE_MODULE = 'foo.bar'
self.assertRaises(SiteProfileNotAvailable, user.get_profile)
| ajibawa-2023/Python-Code-Large/train/row_98605 | 21 | 35 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98605:ImportFrom_L1_C0", "label": "from django.conf import settings", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0286, 0.0286, 0, 0.66, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:ImportFrom_L2_C0", "label": "from django.test import TestCase", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0571, 0.0286, 0, 0.66, 0.3333, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.test", "arg_names": [], "import_names": ["TestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.test import TestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:ImportFrom_L3_C0", "label": "from django.contrib.auth.models import User, SiteProfileNotAvailable", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0857, 0.0286, 0, 0.66, 0.6667, 808, 0, 2, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User", "SiteProfileNotAvailable"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User, SiteProfileNotAvailable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:ClassDef_L5_C0", "label": "ProfileTestCase", "type": "class", "loc": [5, 35], "level": 0, "parent": null, "vector": [3, 0, 0.5714, 0.8857, 0, 0.66, 1.0, 45, 0, 3, 0, 0, 3, 0, 7], "semantic": {"name": "ProfileTestCase", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ProfileTestCase(TestCase):\n fixtures = ['authtestdata.json']\n def setUp(self):\n \"\"\"Backs up the AUTH_PROFILE_MODULE\"\"\"\n self.old_AUTH_PROFILE_MODULE = getattr(settings,\n 'AUTH_PROFILE_MODULE', None)\n\n def tearDown(self):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:Assign_L6_C4", "label": "fixtures =", "type": "assigned_variable", "loc": [6, 6], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:ClassDef_L5_C0", "vector": [14, 1, 0.1714, 0.0286, 1, 0.24, 0.0, 752, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "fixtures", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fixtures = ['authtestdata.json']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L7_C4", "label": "setUp", "type": "function", "loc": [7, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:ClassDef_L5_C0", "vector": [2, 1, 0.2429, 0.1143, 1, 0.24, 0.3333, 952, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "setUp", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def setUp(self):\n \"\"\"Backs up the AUTH_PROFILE_MODULE\"\"\"\n self.old_AUTH_PROFILE_MODULE = getattr(settings,\n 'AUTH_PROFILE_MODULE', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:Expr_L8_C8", "label": "expression", "type": "expression", "loc": [8, 8], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L7_C4", "vector": [8, 2, 0.2286, 0.0286, 2, 0.43, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Backs up the AUTH_PROFILE_MODULE\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:Assign_L9_C8", "label": "self.old_AUTH_PROFILE_MODULE = getattr()", "type": "assigned_variable", "loc": [9, 10], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L7_C4", "vector": [14, 2, 0.2714, 0.0571, 2, 0.43, 1.0, 993, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "self.old_AUTH_PROFILE_MODULE", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " self.old_AUTH_PROFILE_MODULE = getattr(settings,\n 'AUTH_PROFILE_MODULE', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L12_C4", "label": "tearDown", "type": "function", "loc": [12, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:ClassDef_L5_C0", "vector": [2, 1, 0.4571, 0.2571, 1, 0.24, 0.6667, 530, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "tearDown", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def tearDown(self):\n \"\"\"Restores the AUTH_PROFILE_MODULE -- if it was not set it is deleted,\n otherwise the old value is restored\"\"\"\n if self.old_AUTH_PROFILE_MODULE is None and \\\n hasattr(settings, 'AUTH_PROFILE_MODULE'):\n del settings.AUTH_PROFILE_MODULE\n\n if self.old_AUTH_PROFILE_MODULE is not None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:Expr_L13_C8", "label": "expression", "type": "expression", "loc": [13, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L12_C4", "vector": [8, 2, 0.3857, 0.0571, 2, 0.72, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Restores the AUTH_PROFILE_MODULE -- if it was not set it is deleted,\n otherwise the old value is restored\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:If_L15_C8", "label": "if", "type": "if", "loc": [15, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L12_C4", "vector": [4, 2, 0.4571, 0.0857, 2, 0.72, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.old_AUTH_PROFILE_MODULE is None and \\\n hasattr(settings, 'AUTH_PROFILE_MODULE'):\n del settings.AUTH_PROFILE_MODULE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:If_L19_C8", "label": "if", "type": "if", "loc": [19, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L12_C4", "vector": [4, 2, 0.5571, 0.0571, 2, 0.72, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.old_AUTH_PROFILE_MODULE is not None:\n settings.AUTH_PROFILE_MODULE = self.old_AUTH_PROFILE_MODULE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:Assign_L20_C12", "label": "settings.AUTH_PROFILE_MODULE =", "type": "assigned_variable", "loc": [20, 20], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:If_L19_C8", "vector": [14, 3, 0.5714, 0.0286, 3, 0.23, 0.0, 479, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "settings.AUTH_PROFILE_MODULE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTH_PROFILE_MODULE = self.old_AUTH_PROFILE_MODULE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "label": "test_site_profile_not_available", "type": "function", "loc": [22, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:ClassDef_L5_C0", "vector": [2, 1, 0.8143, 0.4, 1, 0.24, 1.0, 433, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_site_profile_not_available", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_site_profile_not_available(self):\n # calling get_profile without AUTH_PROFILE_MODULE set\n if hasattr(settings, 'AUTH_PROFILE_MODULE'):\n del settings.AUTH_PROFILE_MODULE\n user = User.objects.get(username='testclient')\n self.assertRaises(SiteProfileNotAvailable, user.get_profile)\n\n # Bad syntax in AUTH_PROFILE_MODULE: "}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:If_L24_C8", "label": "if", "type": "if", "loc": [24, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "vector": [4, 2, 0.7, 0.0571, 2, 0.43, 0.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(settings, 'AUTH_PROFILE_MODULE'):\n del settings.AUTH_PROFILE_MODULE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:Assign_L26_C8", "label": "user = get()", "type": "assigned_variable", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "vector": [14, 2, 0.7429, 0.0286, 2, 0.43, 0.1667, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='testclient')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:Expr_L27_C8", "label": "assertRaises()", "type": "expression", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "vector": [8, 2, 0.7714, 0.0286, 2, 0.43, 0.3333, 11, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(SiteProfileNotAvailable, user.get_profile)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:Assign_L30_C8", "label": "settings.AUTH_PROFILE_MODULE =", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "vector": [14, 2, 0.8571, 0.0286, 2, 0.43, 0.5, 479, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "settings.AUTH_PROFILE_MODULE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTH_PROFILE_MODULE = 'foobar'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:Expr_L31_C8", "label": "assertRaises()", "type": "expression", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "vector": [8, 2, 0.8857, 0.0286, 2, 0.43, 0.6667, 11, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(SiteProfileNotAvailable, user.get_profile)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:Assign_L34_C8", "label": "settings.AUTH_PROFILE_MODULE =", "type": "assigned_variable", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "vector": [14, 2, 0.9714, 0.0286, 2, 0.43, 0.8333, 479, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "settings.AUTH_PROFILE_MODULE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTH_PROFILE_MODULE = 'foo.bar'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98605:Expr_L35_C8", "label": "assertRaises()", "type": "expression", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "vector": [8, 2, 1.0, 0.0286, 2, 0.43, 1.0, 11, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(SiteProfileNotAvailable, user.get_profile)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98605:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:Expr_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:Expr_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:If_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:If_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:If_L19_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:Assign_L20_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:If_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:Assign_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:Expr_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:Expr_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:Assign_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98605:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98605:Expr_L35_C8"}] |
from django.test import TestCase
from django.contrib.auth.models import User, AnonymousUser
from django.core.management import call_command
from StringIO import StringIO
class BasicTestCase(TestCase):
def test_user(self):
"Check that users can be created and can set their password"
u = User.objects.create_user('testuser', 'test@example.com', 'testpw')
self.assertTrue(u.has_usable_password())
self.assertFalse(u.check_password('bad'))
self.assertTrue(u.check_password('testpw'))
# Check we can manually set an unusable password
u.set_unusable_password()
u.save()
self.assertFalse(u.check_password('testpw'))
self.assertFalse(u.has_usable_password())
u.set_password('testpw')
self.assertTrue(u.check_password('testpw'))
u.set_password(None)
self.assertFalse(u.has_usable_password())
# Check authentication/permissions
self.assertTrue(u.is_authenticated())
self.assertFalse(u.is_staff)
self.assertTrue(u.is_active)
self.assertFalse(u.is_superuser)
# Check API-based user creation with no password
u2 = User.objects.create_user('testuser2', 'test2@example.com')
self.assertFalse(u.has_usable_password())
def test_anonymous_user(self):
"Check the properties of the anonymous user"
a = AnonymousUser()
self.assertFalse(a.is_authenticated())
self.assertFalse(a.is_staff)
self.assertFalse(a.is_active)
self.assertFalse(a.is_superuser)
self.assertEqual(a.groups.all().count(), 0)
self.assertEqual(a.user_permissions.all().count(), 0)
def test_superuser(self):
"Check the creation and properties of a superuser"
super = User.objects.create_superuser('super', 'super@example.com', 'super')
self.assertTrue(super.is_superuser)
self.assertTrue(super.is_active)
self.assertTrue(super.is_staff)
def test_createsuperuser_management_command(self):
"Check the operation of the createsuperuser management command"
# We can use the management command to create a superuser
new_io = StringIO()
call_command("createsuperuser",
interactive=False,
username="joe",
email="joe@somewhere.org",
stdout=new_io
)
command_output = new_io.getvalue().strip()
self.assertEqual(command_output, 'Superuser created successfully.')
u = User.objects.get(username="joe")
self.assertEquals(u.email, 'joe@somewhere.org')
self.assertTrue(u.check_password(''))
# We can supress output on the management command
new_io = StringIO()
call_command("createsuperuser",
interactive=False,
username="joe2",
email="joe2@somewhere.org",
verbosity=0,
stdout=new_io
)
command_output = new_io.getvalue().strip()
self.assertEqual(command_output, '')
u = User.objects.get(username="joe2")
self.assertEquals(u.email, 'joe2@somewhere.org')
self.assertTrue(u.check_password(''))
new_io = StringIO()
call_command("createsuperuser",
interactive=False,
username="joe+admin@somewhere.org",
email="joe@somewhere.org",
stdout=new_io
)
u = User.objects.get(username="joe+admin@somewhere.org")
self.assertEquals(u.email, 'joe@somewhere.org')
self.assertTrue(u.check_password(''))
| ajibawa-2023/Python-Code-Large/train/row_98606 | 61 | 92 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98606:ImportFrom_L1_C0", "label": "from django.test import TestCase", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0109, 0.0109, 0, 0.66, 0.0, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.test", "arg_names": [], "import_names": ["TestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.test import TestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:ImportFrom_L2_C0", "label": "from django.contrib.auth.models import User, AnonymousUser", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0217, 0.0109, 0, 0.66, 0.25, 808, 0, 2, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User", "AnonymousUser"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User, AnonymousUser"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:ImportFrom_L3_C0", "label": "from django.core.management import call_command", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0326, 0.0109, 0, 0.66, 0.5, 879, 0, 1, 0, 0, 879, 0, 0], "semantic": {"name": "django.core.management", "arg_names": [], "import_names": ["call_command"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management import call_command"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:ImportFrom_L4_C0", "label": "from StringIO import StringIO", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0435, 0.0109, 0, 0.66, 0.75, 609, 0, 1, 0, 0, 609, 0, 0], "semantic": {"name": "StringIO", "arg_names": [], "import_names": ["StringIO"], "rhs_call_name": "", "annotation": ""}, "snippet": "from StringIO import StringIO"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:ClassDef_L6_C0", "label": "BasicTestCase", "type": "class", "loc": [6, 91], "level": 0, "parent": null, "vector": [3, 0, 0.5272, 0.9348, 0, 0.66, 1.0, 145, 0, 4, 0, 0, 3, 0, 67], "semantic": {"name": "BasicTestCase", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class BasicTestCase(TestCase):\n def test_user(self):\n \"Check that users can be created and can set their password\"\n u = User.objects.create_user('testuser', 'test@example.com', 'testpw')\n self.assertTrue(u.has_usable_password())\n self.assertFalse(u.check_password('bad'))\n self.assertTrue(u.check_password('testpw'))\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "label": "test_user", "type": "function", "loc": [7, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:ClassDef_L6_C0", "vector": [2, 1, 0.212, 0.2826, 1, 0.26, 0.0, 2, 0, 1, 0, 0, 0, 0, 27], "semantic": {"name": "test_user", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_user(self):\n \"Check that users can be created and can set their password\"\n u = User.objects.create_user('testuser', 'test@example.com', 'testpw')\n self.assertTrue(u.has_usable_password())\n self.assertFalse(u.check_password('bad'))\n self.assertTrue(u.check_password('testpw'))\n\n # Check we can manually set an unusable password"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L8_C8", "label": "expression", "type": "expression", "loc": [8, 8], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.087, 0.0109, 2, 0.81, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Check that users can be created and can set their password\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L9_C8", "label": "u = create_user()", "type": "assigned_variable", "loc": [9, 9], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [14, 2, 0.0978, 0.0109, 2, 0.81, 0.0556, 609, 3, 3, 0, 0, 946, 10, 1], "semantic": {"name": "u", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " u = User.objects.create_user('testuser', 'test@example.com', 'testpw')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L10_C8", "label": "assertTrue()", "type": "expression", "loc": [10, 10], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.1087, 0.0109, 2, 0.81, 0.1111, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(u.has_usable_password())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L11_C8", "label": "assertFalse()", "type": "expression", "loc": [11, 11], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.1196, 0.0109, 2, 0.81, 0.1667, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(u.check_password('bad'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L12_C8", "label": "assertTrue()", "type": "expression", "loc": [12, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.1304, 0.0109, 2, 0.81, 0.2222, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(u.check_password('testpw'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L15_C8", "label": "set_unusable_password()", "type": "expression", "loc": [15, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.163, 0.0109, 2, 0.81, 0.2778, 733, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "set_unusable_password", "arg_names": [], "import_names": [], "rhs_call_name": "set_unusable_password", "annotation": ""}, "snippet": " u.set_unusable_password()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L16_C8", "label": "save()", "type": "expression", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.1739, 0.0109, 2, 0.81, 0.3333, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " u.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L17_C8", "label": "assertFalse()", "type": "expression", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.1848, 0.0109, 2, 0.81, 0.3889, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(u.check_password('testpw'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L18_C8", "label": "assertFalse()", "type": "expression", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.1957, 0.0109, 2, 0.81, 0.4444, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(u.has_usable_password())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L19_C8", "label": "set_password()", "type": "expression", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.2065, 0.0109, 2, 0.81, 0.5, 803, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "set_password", "arg_names": [], "import_names": [], "rhs_call_name": "set_password", "annotation": ""}, "snippet": " u.set_password('testpw')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L20_C8", "label": "assertTrue()", "type": "expression", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.2174, 0.0109, 2, 0.81, 0.5556, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(u.check_password('testpw'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L21_C8", "label": "set_password()", "type": "expression", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.2283, 0.0109, 2, 0.81, 0.6111, 803, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "set_password", "arg_names": [], "import_names": [], "rhs_call_name": "set_password", "annotation": ""}, "snippet": " u.set_password(None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L22_C8", "label": "assertFalse()", "type": "expression", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.2391, 0.0109, 2, 0.81, 0.6667, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(u.has_usable_password())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L25_C8", "label": "assertTrue()", "type": "expression", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.2717, 0.0109, 2, 0.81, 0.7222, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(u.is_authenticated())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L26_C8", "label": "assertFalse()", "type": "expression", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.2826, 0.0109, 2, 0.81, 0.7778, 861, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(u.is_staff)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L27_C8", "label": "assertTrue()", "type": "expression", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.2935, 0.0109, 2, 0.81, 0.8333, 170, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(u.is_active)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L28_C8", "label": "assertFalse()", "type": "expression", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.3043, 0.0109, 2, 0.81, 0.8889, 861, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(u.is_superuser)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L31_C8", "label": "u2 = create_user()", "type": "assigned_variable", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [14, 2, 0.337, 0.0109, 2, 0.81, 0.9444, 420, 3, 2, 0, 0, 946, 10, 1], "semantic": {"name": "u2", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " u2 = User.objects.create_user('testuser2', 'test2@example.com')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L32_C8", "label": "assertFalse()", "type": "expression", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "vector": [8, 2, 0.3478, 0.0109, 2, 0.81, 1.0, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(u.has_usable_password())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "label": "test_anonymous_user", "type": "function", "loc": [34, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:ClassDef_L6_C0", "vector": [2, 1, 0.413, 0.0978, 1, 0.26, 0.3333, 237, 0, 1, 0, 0, 0, 0, 12], "semantic": {"name": "test_anonymous_user", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_anonymous_user(self):\n \"Check the properties of the anonymous user\"\n a = AnonymousUser()\n self.assertFalse(a.is_authenticated())\n self.assertFalse(a.is_staff)\n self.assertFalse(a.is_active)\n self.assertFalse(a.is_superuser)\n self.assertEqual(a.groups.all().count(), 0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L35_C8", "label": "expression", "type": "expression", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "vector": [8, 2, 0.3804, 0.0109, 2, 0.51, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Check the properties of the anonymous user\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L36_C8", "label": "a = AnonymousUser()", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "vector": [14, 2, 0.3913, 0.0109, 2, 0.51, 0.1429, 475, 3, 0, 0, 0, 185, 10, 1], "semantic": {"name": "a", "arg_names": [], "import_names": [], "rhs_call_name": "AnonymousUser", "annotation": ""}, "snippet": " a = AnonymousUser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L37_C8", "label": "assertFalse()", "type": "expression", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "vector": [8, 2, 0.4022, 0.0109, 2, 0.51, 0.2857, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(a.is_authenticated())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L38_C8", "label": "assertFalse()", "type": "expression", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "vector": [8, 2, 0.413, 0.0109, 2, 0.51, 0.4286, 861, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(a.is_staff)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L39_C8", "label": "assertFalse()", "type": "expression", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "vector": [8, 2, 0.4239, 0.0109, 2, 0.51, 0.5714, 861, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(a.is_active)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L40_C8", "label": "assertFalse()", "type": "expression", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "vector": [8, 2, 0.4348, 0.0109, 2, 0.51, 0.7143, 861, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(a.is_superuser)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L41_C8", "label": "assertEqual()", "type": "expression", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "vector": [8, 2, 0.4457, 0.0109, 2, 0.51, 0.8571, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(a.groups.all().count(), 0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L42_C8", "label": "assertEqual()", "type": "expression", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "vector": [8, 2, 0.4565, 0.0109, 2, 0.51, 1.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(a.user_permissions.all().count(), 0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L44_C4", "label": "test_superuser", "type": "function", "loc": [44, 49], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:ClassDef_L6_C0", "vector": [2, 1, 0.5054, 0.0652, 1, 0.26, 0.6667, 978, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_superuser", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_superuser(self):\n \"Check the creation and properties of a superuser\"\n super = User.objects.create_superuser('super', 'super@example.com', 'super')\n self.assertTrue(super.is_superuser)\n self.assertTrue(super.is_active)\n self.assertTrue(super.is_staff)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L45_C8", "label": "expression", "type": "expression", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L44_C4", "vector": [8, 2, 0.4891, 0.0109, 2, 0.45, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Check the creation and properties of a superuser\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L46_C8", "label": "super = create_superuser()", "type": "assigned_variable", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L44_C4", "vector": [14, 2, 0.5, 0.0109, 2, 0.45, 0.25, 395, 3, 3, 0, 0, 149, 10, 1], "semantic": {"name": "super", "arg_names": [], "import_names": [], "rhs_call_name": "create_superuser", "annotation": ""}, "snippet": " super = User.objects.create_superuser('super', 'super@example.com', 'super')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L47_C8", "label": "assertTrue()", "type": "expression", "loc": [47, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L44_C4", "vector": [8, 2, 0.5109, 0.0109, 2, 0.45, 0.5, 170, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(super.is_superuser)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L48_C8", "label": "assertTrue()", "type": "expression", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L44_C4", "vector": [8, 2, 0.5217, 0.0109, 2, 0.45, 0.75, 170, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(super.is_active)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L49_C8", "label": "assertTrue()", "type": "expression", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L44_C4", "vector": [8, 2, 0.5326, 0.0109, 2, 0.45, 1.0, 170, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(super.is_staff)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "label": "test_createsuperuser_management_command", "type": "function", "loc": [51, 91], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:ClassDef_L6_C0", "vector": [2, 1, 0.7717, 0.4457, 1, 0.26, 1.0, 769, 0, 1, 0, 0, 0, 0, 24], "semantic": {"name": "test_createsuperuser_management_command", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_createsuperuser_management_command(self):\n \"Check the operation of the createsuperuser management command\"\n # We can use the management command to create a superuser\n new_io = StringIO()\n call_command(\"createsuperuser\",\n interactive=False,\n username=\"joe\",\n email=\"joe@somewhere.org\","}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L52_C8", "label": "expression", "type": "expression", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [8, 2, 0.5652, 0.0109, 2, 0.56, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Check the operation of the createsuperuser management command\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L54_C8", "label": "new_io = StringIO()", "type": "assigned_variable", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [14, 2, 0.587, 0.0109, 2, 0.56, 0.0526, 203, 3, 0, 0, 0, 609, 10, 1], "semantic": {"name": "new_io", "arg_names": [], "import_names": [], "rhs_call_name": "StringIO", "annotation": ""}, "snippet": " new_io = StringIO()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L55_C8", "label": "call_command()", "type": "expression", "loc": [55, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [8, 2, 0.625, 0.0652, 2, 0.56, 0.1053, 587, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "call_command", "arg_names": [], "import_names": [], "rhs_call_name": "call_command", "annotation": ""}, "snippet": " call_command(\"createsuperuser\",\n interactive=False,\n username=\"joe\",\n email=\"joe@somewhere.org\",\n stdout=new_io\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L61_C8", "label": "command_output = strip()", "type": "assigned_variable", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [14, 2, 0.663, 0.0109, 2, 0.56, 0.1579, 31, 3, 0, 0, 0, 973, 10, 2], "semantic": {"name": "command_output", "arg_names": [], "import_names": [], "rhs_call_name": "strip", "annotation": ""}, "snippet": " command_output = new_io.getvalue().strip()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L62_C8", "label": "assertEqual()", "type": "expression", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [8, 2, 0.6739, 0.0109, 2, 0.56, 0.2105, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(command_output, 'Superuser created successfully.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L63_C8", "label": "u = get()", "type": "assigned_variable", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [14, 2, 0.6848, 0.0109, 2, 0.56, 0.2632, 609, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "u", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " u = User.objects.get(username=\"joe\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L64_C8", "label": "assertEquals()", "type": "expression", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [8, 2, 0.6957, 0.0109, 2, 0.56, 0.3158, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(u.email, 'joe@somewhere.org')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L65_C8", "label": "assertTrue()", "type": "expression", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [8, 2, 0.7065, 0.0109, 2, 0.56, 0.3684, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(u.check_password(''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L68_C8", "label": "new_io = StringIO()", "type": "assigned_variable", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [14, 2, 0.7391, 0.0109, 2, 0.56, 0.4211, 203, 3, 0, 0, 0, 609, 10, 1], "semantic": {"name": "new_io", "arg_names": [], "import_names": [], "rhs_call_name": "StringIO", "annotation": ""}, "snippet": " new_io = StringIO()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L69_C8", "label": "call_command()", "type": "expression", "loc": [69, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [8, 2, 0.7826, 0.0761, 2, 0.56, 0.4737, 587, 3, 6, 0, 0, 0, 0, 1], "semantic": {"name": "call_command", "arg_names": [], "import_names": [], "rhs_call_name": "call_command", "annotation": ""}, "snippet": " call_command(\"createsuperuser\",\n interactive=False,\n username=\"joe2\",\n email=\"joe2@somewhere.org\",\n verbosity=0,\n stdout=new_io\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L76_C8", "label": "command_output = strip()", "type": "assigned_variable", "loc": [76, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [14, 2, 0.8261, 0.0109, 2, 0.56, 0.5263, 31, 3, 0, 0, 0, 973, 10, 2], "semantic": {"name": "command_output", "arg_names": [], "import_names": [], "rhs_call_name": "strip", "annotation": ""}, "snippet": " command_output = new_io.getvalue().strip()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L77_C8", "label": "assertEqual()", "type": "expression", "loc": [77, 77], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [8, 2, 0.837, 0.0109, 2, 0.56, 0.5789, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(command_output, '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L78_C8", "label": "u = get()", "type": "assigned_variable", "loc": [78, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [14, 2, 0.8478, 0.0109, 2, 0.56, 0.6316, 609, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "u", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " u = User.objects.get(username=\"joe2\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L79_C8", "label": "assertEquals()", "type": "expression", "loc": [79, 79], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [8, 2, 0.8587, 0.0109, 2, 0.56, 0.6842, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(u.email, 'joe2@somewhere.org')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L80_C8", "label": "assertTrue()", "type": "expression", "loc": [80, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [8, 2, 0.8696, 0.0109, 2, 0.56, 0.7368, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(u.check_password(''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L82_C8", "label": "new_io = StringIO()", "type": "assigned_variable", "loc": [82, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [14, 2, 0.8913, 0.0109, 2, 0.56, 0.7895, 203, 3, 0, 0, 0, 609, 10, 1], "semantic": {"name": "new_io", "arg_names": [], "import_names": [], "rhs_call_name": "StringIO", "annotation": ""}, "snippet": " new_io = StringIO()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L83_C8", "label": "call_command()", "type": "expression", "loc": [83, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [8, 2, 0.9293, 0.0652, 2, 0.56, 0.8421, 587, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "call_command", "arg_names": [], "import_names": [], "rhs_call_name": "call_command", "annotation": ""}, "snippet": " call_command(\"createsuperuser\",\n interactive=False,\n username=\"joe+admin@somewhere.org\",\n email=\"joe@somewhere.org\",\n stdout=new_io\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L89_C8", "label": "u = get()", "type": "assigned_variable", "loc": [89, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [14, 2, 0.9674, 0.0109, 2, 0.56, 0.8947, 609, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "u", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " u = User.objects.get(username=\"joe+admin@somewhere.org\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L90_C8", "label": "assertEquals()", "type": "expression", "loc": [90, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [8, 2, 0.9783, 0.0109, 2, 0.56, 0.9474, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(u.email, 'joe@somewhere.org')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L91_C8", "label": "assertTrue()", "type": "expression", "loc": [91, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "vector": [8, 2, 0.9891, 0.0109, 2, 0.56, 1.0, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(u.check_password(''))"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98606:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L79_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L83_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Assign_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98606:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98606:Expr_L91_C8"}] |
from django.conf.urls.defaults import patterns
from django.contrib.auth.urls import urlpatterns
from django.contrib.auth.views import password_reset
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.template import Template, RequestContext
def remote_user_auth_view(request):
"Dummy view for remote user tests"
t = Template("Username is {{ user }}.")
c = RequestContext(request, {})
return HttpResponse(t.render(c))
# special urls for auth test cases
urlpatterns = urlpatterns + patterns('',
(r'^logout/custom_query/$', 'django.contrib.auth.views.logout', dict(redirect_field_name='follow')),
(r'^logout/next_page/$', 'django.contrib.auth.views.logout', dict(next_page='/somewhere/')),
(r'^remote_user/$', remote_user_auth_view),
(r'^password_reset_from_email/$', 'django.contrib.auth.views.password_reset', dict(from_email='staffmember@example.com')),
(r'^login_required/$', login_required(password_reset)),
(r'^login_required_login_url/$', login_required(password_reset, login_url='/somewhere/')),
)
| ajibawa-2023/Python-Code-Large/train/row_98607 | 12 | 23 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98607:ImportFrom_L1_C0", "label": "from django.conf.urls.defaults import patterns", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0435, 0.0435, 0, 0.66, 0.0, 341, 0, 1, 0, 0, 341, 0, 0], "semantic": {"name": "django.conf.urls.defaults", "arg_names": [], "import_names": ["patterns"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf.urls.defaults import patterns"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98607:ImportFrom_L2_C0", "label": "from django.contrib.auth.urls import urlpatterns", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.087, 0.0435, 0, 0.66, 0.1429, 410, 0, 1, 0, 0, 410, 0, 0], "semantic": {"name": "django.contrib.auth.urls", "arg_names": [], "import_names": ["urlpatterns"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.urls import urlpatterns"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98607:ImportFrom_L3_C0", "label": "from django.contrib.auth.views import password_reset", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.1304, 0.0435, 0, 0.66, 0.2857, 745, 0, 1, 0, 0, 745, 0, 0], "semantic": {"name": "django.contrib.auth.views", "arg_names": [], "import_names": ["password_reset"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.views import password_reset"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98607:ImportFrom_L4_C0", "label": "from django.contrib.auth.decorators import login_required", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.1739, 0.0435, 0, 0.66, 0.4286, 885, 0, 1, 0, 0, 885, 0, 0], "semantic": {"name": "django.contrib.auth.decorators", "arg_names": [], "import_names": ["login_required"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.decorators import login_required"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98607:ImportFrom_L5_C0", "label": "from django.http import HttpResponse", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.2174, 0.0435, 0, 0.66, 0.5714, 779, 0, 1, 0, 0, 779, 0, 0], "semantic": {"name": "django.http", "arg_names": [], "import_names": ["HttpResponse"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.http import HttpResponse"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98607:ImportFrom_L6_C0", "label": "from django.template import Template, RequestContext", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.2609, 0.0435, 0, 0.66, 0.7143, 213, 0, 2, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["Template", "RequestContext"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import Template, RequestContext"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98607:FunctionDef_L8_C0", "label": "remote_user_auth_view", "type": "function", "loc": [8, 12], "level": 0, "parent": null, "vector": [2, 0, 0.4348, 0.2174, 0, 0.66, 0.8571, 969, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "remote_user_auth_view", "arg_names": ["request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def remote_user_auth_view(request):\n \"Dummy view for remote user tests\"\n t = Template(\"Username is {{ user }}.\")\n c = RequestContext(request, {})\n return HttpResponse(t.render(c))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98607:Expr_L9_C4", "label": "expression", "type": "expression", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98607:FunctionDef_L8_C0", "vector": [8, 1, 0.3913, 0.0435, 1, 0.47, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Dummy view for remote user tests\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98607:Assign_L10_C4", "label": "t = Template()", "type": "assigned_variable", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98607:FunctionDef_L8_C0", "vector": [14, 1, 0.4348, 0.0435, 1, 0.47, 0.3333, 15, 3, 1, 0, 0, 137, 10, 1], "semantic": {"name": "t", "arg_names": [], "import_names": [], "rhs_call_name": "Template", "annotation": ""}, "snippet": " t = Template(\"Username is {{ user }}.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98607:Assign_L11_C4", "label": "c = RequestContext()", "type": "assigned_variable", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98607:FunctionDef_L8_C0", "vector": [14, 1, 0.4783, 0.0435, 1, 0.47, 0.6667, 411, 3, 2, 0, 0, 47, 10, 1], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "RequestContext", "annotation": ""}, "snippet": " c = RequestContext(request, {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98607:Return_L12_C4", "label": "return", "type": "return", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98607:FunctionDef_L8_C0", "vector": [13, 1, 0.5217, 0.0435, 1, 0.47, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponse(t.render(c))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98607:Assign_L15_C0", "label": "urlpatterns =", "type": "assigned_variable", "loc": [15, 22], "level": 0, "parent": null, "vector": [14, 0, 0.8043, 0.3478, 0, 0.66, 1.0, 990, 4, 0, 0, 0, 0, 0, 6], "semantic": {"name": "urlpatterns", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "urlpatterns = urlpatterns + patterns('',\n (r'^logout/custom_query/$', 'django.contrib.auth.views.logout', dict(redirect_field_name='follow')),\n (r'^logout/next_page/$', 'django.contrib.auth.views.logout', dict(next_page='/somewhere/')),\n (r'^remote_user/$', remote_user_auth_view),\n (r'^password_reset_from_email/$', 'django.contrib.auth.views.password_reset', dict(from_email='staffmember@example.com')),\n (r'^login_required/$', login_required(password_reset)),\n (r'^login_required_login_url/$', login_required(password_reset, login_url='/somewhere/')),\n)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98607:FunctionDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98607:Expr_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98607:FunctionDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98607:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98607:FunctionDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98607:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98607:FunctionDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98607:Return_L12_C4"}] |
from datetime import datetime
from django.conf import settings
from django.contrib.auth.backends import RemoteUserBackend
from django.contrib.auth.models import User
from django.test import TestCase
class RemoteUserTest(TestCase):
urls = 'django.contrib.auth.tests.urls'
middleware = 'django.contrib.auth.middleware.RemoteUserMiddleware'
backend = 'django.contrib.auth.backends.RemoteUserBackend'
# Usernames to be passed in REMOTE_USER for the test_known_user test case.
known_user = 'knownuser'
known_user2 = 'knownuser2'
def setUp(self):
self.curr_middleware = settings.MIDDLEWARE_CLASSES
self.curr_auth = settings.AUTHENTICATION_BACKENDS
settings.MIDDLEWARE_CLASSES += (self.middleware,)
settings.AUTHENTICATION_BACKENDS = (self.backend,)
def test_no_remote_user(self):
"""
Tests requests where no remote user is specified and insures that no
users get created.
"""
num_users = User.objects.count()
response = self.client.get('/remote_user/')
self.assert_(response.context['user'].is_anonymous())
self.assertEqual(User.objects.count(), num_users)
response = self.client.get('/remote_user/', REMOTE_USER=None)
self.assert_(response.context['user'].is_anonymous())
self.assertEqual(User.objects.count(), num_users)
response = self.client.get('/remote_user/', REMOTE_USER='')
self.assert_(response.context['user'].is_anonymous())
self.assertEqual(User.objects.count(), num_users)
def test_unknown_user(self):
"""
Tests the case where the username passed in the header does not exist
as a User.
"""
num_users = User.objects.count()
response = self.client.get('/remote_user/', REMOTE_USER='newuser')
self.assertEqual(response.context['user'].username, 'newuser')
self.assertEqual(User.objects.count(), num_users + 1)
User.objects.get(username='newuser')
# Another request with same user should not create any new users.
response = self.client.get('/remote_user/', REMOTE_USER='newuser')
self.assertEqual(User.objects.count(), num_users + 1)
def test_known_user(self):
"""
Tests the case where the username passed in the header is a valid User.
"""
User.objects.create(username='knownuser')
User.objects.create(username='knownuser2')
num_users = User.objects.count()
response = self.client.get('/remote_user/', REMOTE_USER=self.known_user)
self.assertEqual(response.context['user'].username, 'knownuser')
self.assertEqual(User.objects.count(), num_users)
# Test that a different user passed in the headers causes the new user
# to be logged in.
response = self.client.get('/remote_user/', REMOTE_USER=self.known_user2)
self.assertEqual(response.context['user'].username, 'knownuser2')
self.assertEqual(User.objects.count(), num_users)
def test_last_login(self):
"""
Tests that a user's last_login is set the first time they make a
request but not updated in subsequent requests with the same session.
"""
user = User.objects.create(username='knownuser')
# Set last_login to something so we can determine if it changes.
default_login = datetime(2000, 1, 1)
user.last_login = default_login
user.save()
response = self.client.get('/remote_user/', REMOTE_USER=self.known_user)
self.assertNotEqual(default_login, response.context['user'].last_login)
user = User.objects.get(username='knownuser')
user.last_login = default_login
user.save()
response = self.client.get('/remote_user/', REMOTE_USER=self.known_user)
self.assertEqual(default_login, response.context['user'].last_login)
def tearDown(self):
"""Restores settings to avoid breaking other tests."""
settings.MIDDLEWARE_CLASSES = self.curr_middleware
settings.AUTHENTICATION_BACKENDS = self.curr_auth
class RemoteUserNoCreateBackend(RemoteUserBackend):
"""Backend that doesn't create unknown users."""
create_unknown_user = False
class RemoteUserNoCreateTest(RemoteUserTest):
"""
Contains the same tests as RemoteUserTest, but using a custom auth backend
class that doesn't create unknown users.
"""
backend =\
'django.contrib.auth.tests.remote_user.RemoteUserNoCreateBackend'
def test_unknown_user(self):
num_users = User.objects.count()
response = self.client.get('/remote_user/', REMOTE_USER='newuser')
self.assert_(response.context['user'].is_anonymous())
self.assertEqual(User.objects.count(), num_users)
class CustomRemoteUserBackend(RemoteUserBackend):
"""
Backend that overrides RemoteUserBackend methods.
"""
def clean_username(self, username):
"""
Grabs username before the @ character.
"""
return username.split('@')[0]
def configure_user(self, user):
"""
Sets user's email address.
"""
user.email = 'user@example.com'
user.save()
return user
class RemoteUserCustomTest(RemoteUserTest):
"""
Tests a custom RemoteUserBackend subclass that overrides the clean_username
and configure_user methods.
"""
backend =\
'django.contrib.auth.tests.remote_user.CustomRemoteUserBackend'
# REMOTE_USER strings with e-mail addresses for the custom backend to
# clean.
known_user = 'knownuser@example.com'
known_user2 = 'knownuser2@example.com'
def test_known_user(self):
"""
The strings passed in REMOTE_USER should be cleaned and the known users
should not have been configured with an email address.
"""
super(RemoteUserCustomTest, self).test_known_user()
self.assertEqual(User.objects.get(username='knownuser').email, '')
self.assertEqual(User.objects.get(username='knownuser2').email, '')
def test_unknown_user(self):
"""
The unknown user created should be configured with an email address.
"""
super(RemoteUserCustomTest, self).test_unknown_user()
newuser = User.objects.get(username='newuser')
self.assertEqual(newuser.email, 'user@example.com')
| ajibawa-2023/Python-Code-Large/train/row_98608 | 100 | 170 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98608:ImportFrom_L1_C0", "label": "from datetime import datetime", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0059, 0.0059, 0, 0.66, 0.0, 426, 0, 1, 0, 0, 426, 0, 0], "semantic": {"name": "datetime", "arg_names": [], "import_names": ["datetime"], "rhs_call_name": "", "annotation": ""}, "snippet": "from datetime import datetime"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:ImportFrom_L3_C0", "label": "from django.conf import settings", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0176, 0.0059, 0, 0.66, 0.1111, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:ImportFrom_L4_C0", "label": "from django.contrib.auth.backends import RemoteUserBackend", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0235, 0.0059, 0, 0.66, 0.2222, 182, 0, 1, 0, 0, 182, 0, 0], "semantic": {"name": "django.contrib.auth.backends", "arg_names": [], "import_names": ["RemoteUserBackend"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.backends import RemoteUserBackend"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:ImportFrom_L5_C0", "label": "from django.contrib.auth.models import User", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0294, 0.0059, 0, 0.66, 0.3333, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:ImportFrom_L6_C0", "label": "from django.test import TestCase", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0353, 0.0059, 0, 0.66, 0.4444, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.test", "arg_names": [], "import_names": ["TestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.test import TestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "label": "RemoteUserTest", "type": "class", "loc": [9, 98], "level": 0, "parent": null, "vector": [3, 0, 0.3147, 0.5294, 0, 0.66, 0.5556, 981, 0, 6, 0, 0, 3, 0, 45], "semantic": {"name": "RemoteUserTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RemoteUserTest(TestCase):\n\n urls = 'django.contrib.auth.tests.urls'\n middleware = 'django.contrib.auth.middleware.RemoteUserMiddleware'\n backend = 'django.contrib.auth.backends.RemoteUserBackend'\n\n # Usernames to be passed in REMOTE_USER for the test_known_user test case.\n known_user = 'knownuser'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L11_C4", "label": "urls =", "type": "assigned_variable", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "vector": [14, 1, 0.0647, 0.0059, 1, 0.81, 0.0, 260, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "urls", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " urls = 'django.contrib.auth.tests.urls'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L12_C4", "label": "middleware =", "type": "assigned_variable", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "vector": [14, 1, 0.0706, 0.0059, 1, 0.81, 0.1, 642, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "middleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " middleware = 'django.contrib.auth.middleware.RemoteUserMiddleware'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L13_C4", "label": "backend =", "type": "assigned_variable", "loc": [13, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "vector": [14, 1, 0.0765, 0.0059, 1, 0.81, 0.2, 631, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "backend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " backend = 'django.contrib.auth.backends.RemoteUserBackend'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L16_C4", "label": "known_user =", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "vector": [14, 1, 0.0941, 0.0059, 1, 0.81, 0.3, 133, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "known_user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " known_user = 'knownuser'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L17_C4", "label": "known_user2 =", "type": "assigned_variable", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "vector": [14, 1, 0.1, 0.0059, 1, 0.81, 0.4, 902, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "known_user2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " known_user2 = 'knownuser2'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L19_C4", "label": "setUp", "type": "function", "loc": [19, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "vector": [2, 1, 0.1235, 0.0294, 1, 0.81, 0.5, 952, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "setUp", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def setUp(self):\n self.curr_middleware = settings.MIDDLEWARE_CLASSES\n self.curr_auth = settings.AUTHENTICATION_BACKENDS\n settings.MIDDLEWARE_CLASSES += (self.middleware,)\n settings.AUTHENTICATION_BACKENDS = (self.backend,)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L20_C8", "label": "self.curr_middleware =", "type": "assigned_variable", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L19_C4", "vector": [14, 2, 0.1176, 0.0059, 2, 0.85, 0.0, 259, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.curr_middleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.curr_middleware = settings.MIDDLEWARE_CLASSES"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L21_C8", "label": "self.curr_auth =", "type": "assigned_variable", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L19_C4", "vector": [14, 2, 0.1235, 0.0059, 2, 0.85, 0.5, 327, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.curr_auth", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.curr_auth = settings.AUTHENTICATION_BACKENDS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L23_C8", "label": "settings.AUTHENTICATION_BACKENDS =", "type": "assigned_variable", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L19_C4", "vector": [14, 2, 0.1353, 0.0059, 2, 0.85, 1.0, 257, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "settings.AUTHENTICATION_BACKENDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTHENTICATION_BACKENDS = (self.backend,)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "label": "test_no_remote_user", "type": "function", "loc": [25, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "vector": [2, 1, 0.1971, 0.1059, 1, 0.81, 0.6, 924, 0, 1, 0, 0, 0, 0, 16], "semantic": {"name": "test_no_remote_user", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_no_remote_user(self):\n \"\"\"\n Tests requests where no remote user is specified and insures that no\n users get created.\n \"\"\"\n num_users = User.objects.count()\n\n response = self.client.get('/remote_user/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L26_C8", "label": "expression", "type": "expression", "loc": [26, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "vector": [8, 2, 0.1618, 0.0235, 2, 0.93, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Tests requests where no remote user is specified and insures that no\n users get created.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L30_C8", "label": "num_users = count()", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "vector": [14, 2, 0.1765, 0.0059, 2, 0.93, 0.1, 747, 3, 0, 0, 0, 778, 10, 1], "semantic": {"name": "num_users", "arg_names": [], "import_names": [], "rhs_call_name": "count", "annotation": ""}, "snippet": " num_users = User.objects.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L32_C8", "label": "response = get()", "type": "assigned_variable", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "vector": [14, 2, 0.1882, 0.0059, 2, 0.93, 0.2, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/remote_user/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L33_C8", "label": "assert_()", "type": "expression", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "vector": [8, 2, 0.1941, 0.0059, 2, 0.93, 0.3, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(response.context['user'].is_anonymous())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L34_C8", "label": "assertEqual()", "type": "expression", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "vector": [8, 2, 0.2, 0.0059, 2, 0.93, 0.4, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(User.objects.count(), num_users)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L36_C8", "label": "response = get()", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "vector": [14, 2, 0.2118, 0.0059, 2, 0.93, 0.5, 511, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/remote_user/', REMOTE_USER=None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L37_C8", "label": "assert_()", "type": "expression", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "vector": [8, 2, 0.2176, 0.0059, 2, 0.93, 0.6, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(response.context['user'].is_anonymous())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L38_C8", "label": "assertEqual()", "type": "expression", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "vector": [8, 2, 0.2235, 0.0059, 2, 0.93, 0.7, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(User.objects.count(), num_users)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L40_C8", "label": "response = get()", "type": "assigned_variable", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "vector": [14, 2, 0.2353, 0.0059, 2, 0.93, 0.8, 511, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/remote_user/', REMOTE_USER='')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L41_C8", "label": "assert_()", "type": "expression", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "vector": [8, 2, 0.2412, 0.0059, 2, 0.93, 0.9, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(response.context['user'].is_anonymous())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L42_C8", "label": "assertEqual()", "type": "expression", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "vector": [8, 2, 0.2471, 0.0059, 2, 0.93, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(User.objects.count(), num_users)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "label": "test_unknown_user", "type": "function", "loc": [44, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "vector": [2, 1, 0.2971, 0.0824, 1, 0.81, 0.7, 314, 0, 1, 0, 0, 0, 0, 9], "semantic": {"name": "test_unknown_user", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_unknown_user(self):\n \"\"\"\n Tests the case where the username passed in the header does not exist\n as a User.\n \"\"\"\n num_users = User.objects.count()\n response = self.client.get('/remote_user/', REMOTE_USER='newuser')\n self.assertEqual(response.context['user'].username, 'newuser')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L45_C8", "label": "expression", "type": "expression", "loc": [45, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "vector": [8, 2, 0.2735, 0.0235, 2, 0.4, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Tests the case where the username passed in the header does not exist\n as a User.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L49_C8", "label": "num_users = count()", "type": "assigned_variable", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "vector": [14, 2, 0.2882, 0.0059, 2, 0.4, 0.1429, 747, 3, 0, 0, 0, 778, 10, 1], "semantic": {"name": "num_users", "arg_names": [], "import_names": [], "rhs_call_name": "count", "annotation": ""}, "snippet": " num_users = User.objects.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L50_C8", "label": "response = get()", "type": "assigned_variable", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "vector": [14, 2, 0.2941, 0.0059, 2, 0.4, 0.2857, 511, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/remote_user/', REMOTE_USER='newuser')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L51_C8", "label": "assertEqual()", "type": "expression", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "vector": [8, 2, 0.3, 0.0059, 2, 0.4, 0.4286, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(response.context['user'].username, 'newuser')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L52_C8", "label": "assertEqual()", "type": "expression", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "vector": [8, 2, 0.3059, 0.0059, 2, 0.4, 0.5714, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(User.objects.count(), num_users + 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L53_C8", "label": "get()", "type": "expression", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "vector": [8, 2, 0.3118, 0.0059, 2, 0.4, 0.7143, 607, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "get", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " User.objects.get(username='newuser')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L56_C8", "label": "response = get()", "type": "assigned_variable", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "vector": [14, 2, 0.3294, 0.0059, 2, 0.4, 0.8571, 511, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/remote_user/', REMOTE_USER='newuser')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L57_C8", "label": "assertEqual()", "type": "expression", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "vector": [8, 2, 0.3353, 0.0059, 2, 0.4, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(User.objects.count(), num_users + 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "label": "test_known_user", "type": "function", "loc": [59, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "vector": [2, 1, 0.3882, 0.0882, 1, 0.81, 0.8, 627, 0, 1, 0, 0, 0, 0, 11], "semantic": {"name": "test_known_user", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_known_user(self):\n \"\"\"\n Tests the case where the username passed in the header is a valid User.\n \"\"\"\n User.objects.create(username='knownuser')\n User.objects.create(username='knownuser2')\n num_users = User.objects.count()\n response = self.client.get('/remote_user/', REMOTE_USER=self.known_user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L60_C8", "label": "expression", "type": "expression", "loc": [60, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "vector": [8, 2, 0.3588, 0.0176, 2, 0.87, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Tests the case where the username passed in the header is a valid User.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L63_C8", "label": "create()", "type": "expression", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "vector": [8, 2, 0.3706, 0.0059, 2, 0.87, 0.1111, 316, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " User.objects.create(username='knownuser')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L64_C8", "label": "create()", "type": "expression", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "vector": [8, 2, 0.3765, 0.0059, 2, 0.87, 0.2222, 316, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " User.objects.create(username='knownuser2')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L65_C8", "label": "num_users = count()", "type": "assigned_variable", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "vector": [14, 2, 0.3824, 0.0059, 2, 0.87, 0.3333, 747, 3, 0, 0, 0, 778, 10, 1], "semantic": {"name": "num_users", "arg_names": [], "import_names": [], "rhs_call_name": "count", "annotation": ""}, "snippet": " num_users = User.objects.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L66_C8", "label": "response = get()", "type": "assigned_variable", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "vector": [14, 2, 0.3882, 0.0059, 2, 0.87, 0.4444, 511, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/remote_user/', REMOTE_USER=self.known_user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L67_C8", "label": "assertEqual()", "type": "expression", "loc": [67, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "vector": [8, 2, 0.3941, 0.0059, 2, 0.87, 0.5556, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(response.context['user'].username, 'knownuser')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L68_C8", "label": "assertEqual()", "type": "expression", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "vector": [8, 2, 0.4, 0.0059, 2, 0.87, 0.6667, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(User.objects.count(), num_users)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L71_C8", "label": "response = get()", "type": "assigned_variable", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "vector": [14, 2, 0.4176, 0.0059, 2, 0.87, 0.7778, 511, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/remote_user/', REMOTE_USER=self.known_user2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L72_C8", "label": "assertEqual()", "type": "expression", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "vector": [8, 2, 0.4235, 0.0059, 2, 0.87, 0.8889, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(response.context['user'].username, 'knownuser2')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L73_C8", "label": "assertEqual()", "type": "expression", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "vector": [8, 2, 0.4294, 0.0059, 2, 0.87, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(User.objects.count(), num_users)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "label": "test_last_login", "type": "function", "loc": [75, 93], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "vector": [2, 1, 0.4941, 0.1118, 1, 0.81, 0.9, 169, 0, 1, 0, 0, 0, 0, 9], "semantic": {"name": "test_last_login", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_last_login(self):\n \"\"\"\n Tests that a user's last_login is set the first time they make a\n request but not updated in subsequent requests with the same session.\n \"\"\"\n user = User.objects.create(username='knownuser')\n # Set last_login to something so we can determine if it changes.\n default_login = datetime(2000, 1, 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L76_C8", "label": "expression", "type": "expression", "loc": [76, 79], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "vector": [8, 2, 0.4559, 0.0235, 2, 0.96, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Tests that a user's last_login is set the first time they make a\n request but not updated in subsequent requests with the same session.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L80_C8", "label": "user = create()", "type": "assigned_variable", "loc": [80, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "vector": [14, 2, 0.4706, 0.0059, 2, 0.96, 0.0909, 503, 3, 1, 0, 0, 316, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " user = User.objects.create(username='knownuser')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L82_C8", "label": "default_login = datetime()", "type": "assigned_variable", "loc": [82, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "vector": [14, 2, 0.4824, 0.0059, 2, 0.96, 0.1818, 214, 3, 3, 0, 0, 426, 10, 1], "semantic": {"name": "default_login", "arg_names": [], "import_names": [], "rhs_call_name": "datetime", "annotation": ""}, "snippet": " default_login = datetime(2000, 1, 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L83_C8", "label": "user.last_login =", "type": "assigned_variable", "loc": [83, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "vector": [14, 2, 0.4882, 0.0059, 2, 0.96, 0.2727, 633, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "user.last_login", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user.last_login = default_login"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L84_C8", "label": "save()", "type": "expression", "loc": [84, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "vector": [8, 2, 0.4941, 0.0059, 2, 0.96, 0.3636, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L86_C8", "label": "response = get()", "type": "assigned_variable", "loc": [86, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "vector": [14, 2, 0.5059, 0.0059, 2, 0.96, 0.4545, 511, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/remote_user/', REMOTE_USER=self.known_user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L87_C8", "label": "assertNotEqual()", "type": "expression", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "vector": [8, 2, 0.5118, 0.0059, 2, 0.96, 0.5455, 120, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertNotEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertNotEqual", "annotation": ""}, "snippet": " self.assertNotEqual(default_login, response.context['user'].last_login)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L89_C8", "label": "user = get()", "type": "assigned_variable", "loc": [89, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "vector": [14, 2, 0.5235, 0.0059, 2, 0.96, 0.6364, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(username='knownuser')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L90_C8", "label": "user.last_login =", "type": "assigned_variable", "loc": [90, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "vector": [14, 2, 0.5294, 0.0059, 2, 0.96, 0.7273, 633, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "user.last_login", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user.last_login = default_login"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L91_C8", "label": "save()", "type": "expression", "loc": [91, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "vector": [8, 2, 0.5353, 0.0059, 2, 0.96, 0.8182, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L92_C8", "label": "response = get()", "type": "assigned_variable", "loc": [92, 92], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "vector": [14, 2, 0.5412, 0.0059, 2, 0.96, 0.9091, 511, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/remote_user/', REMOTE_USER=self.known_user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L93_C8", "label": "assertEqual()", "type": "expression", "loc": [93, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "vector": [8, 2, 0.5471, 0.0059, 2, 0.96, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(default_login, response.context['user'].last_login)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L95_C4", "label": "tearDown", "type": "function", "loc": [95, 98], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "vector": [2, 1, 0.5676, 0.0235, 1, 0.81, 1.0, 530, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "tearDown", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def tearDown(self):\n \"\"\"Restores settings to avoid breaking other tests.\"\"\"\n settings.MIDDLEWARE_CLASSES = self.curr_middleware\n settings.AUTHENTICATION_BACKENDS = self.curr_auth"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L96_C8", "label": "expression", "type": "expression", "loc": [96, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L95_C4", "vector": [8, 2, 0.5647, 0.0059, 2, 0.43, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Restores settings to avoid breaking other tests.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L97_C8", "label": "settings.MIDDLEWARE_CLASSES =", "type": "assigned_variable", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L95_C4", "vector": [14, 2, 0.5706, 0.0059, 2, 0.43, 0.5, 955, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "settings.MIDDLEWARE_CLASSES", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.MIDDLEWARE_CLASSES = self.curr_middleware"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L98_C8", "label": "settings.AUTHENTICATION_BACKENDS =", "type": "assigned_variable", "loc": [98, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L95_C4", "vector": [14, 2, 0.5765, 0.0059, 2, 0.43, 1.0, 257, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "settings.AUTHENTICATION_BACKENDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.AUTHENTICATION_BACKENDS = self.curr_auth"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L101_C0", "label": "RemoteUserNoCreateBackend", "type": "class", "loc": [101, 103], "level": 0, "parent": null, "vector": [3, 0, 0.6, 0.0176, 0, 0.66, 0.6667, 591, 0, 0, 0, 0, 519, 0, 0], "semantic": {"name": "RemoteUserNoCreateBackend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RemoteUserNoCreateBackend(RemoteUserBackend):\n \"\"\"Backend that doesn't create unknown users.\"\"\"\n create_unknown_user = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L102_C4", "label": "expression", "type": "expression", "loc": [102, 102], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L101_C0", "vector": [8, 1, 0.6, 0.0059, 1, 0.03, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Backend that doesn't create unknown users.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L103_C4", "label": "create_unknown_user =", "type": "assigned_variable", "loc": [103, 103], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L101_C0", "vector": [14, 1, 0.6059, 0.0059, 1, 0.03, 1.0, 497, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "create_unknown_user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " create_unknown_user = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L106_C0", "label": "RemoteUserNoCreateTest", "type": "class", "loc": [106, 119], "level": 0, "parent": null, "vector": [3, 0, 0.6618, 0.0824, 0, 0.66, 0.7778, 416, 0, 1, 0, 0, 981, 0, 6], "semantic": {"name": "RemoteUserNoCreateTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RemoteUserNoCreateTest(RemoteUserTest):\n \"\"\"\n Contains the same tests as RemoteUserTest, but using a custom auth backend\n class that doesn't create unknown users.\n \"\"\"\n\n backend =\\\n 'django.contrib.auth.tests.remote_user.RemoteUserNoCreateBackend'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L107_C4", "label": "expression", "type": "expression", "loc": [107, 110], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L106_C0", "vector": [8, 1, 0.6382, 0.0235, 1, 0.99, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Contains the same tests as RemoteUserTest, but using a custom auth backend\n class that doesn't create unknown users.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L112_C4", "label": "backend =", "type": "assigned_variable", "loc": [112, 113], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L106_C0", "vector": [14, 1, 0.6618, 0.0118, 1, 0.99, 0.5, 631, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "backend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " backend =\\\n 'django.contrib.auth.tests.remote_user.RemoteUserNoCreateBackend'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L115_C4", "label": "test_unknown_user", "type": "function", "loc": [115, 119], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L106_C0", "vector": [2, 1, 0.6882, 0.0294, 1, 0.99, 1.0, 314, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_unknown_user", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_unknown_user(self):\n num_users = User.objects.count()\n response = self.client.get('/remote_user/', REMOTE_USER='newuser')\n self.assert_(response.context['user'].is_anonymous())\n self.assertEqual(User.objects.count(), num_users)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L116_C8", "label": "num_users = count()", "type": "assigned_variable", "loc": [116, 116], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L115_C4", "vector": [14, 2, 0.6824, 0.0059, 2, 0.85, 0.0, 747, 3, 0, 0, 0, 778, 10, 1], "semantic": {"name": "num_users", "arg_names": [], "import_names": [], "rhs_call_name": "count", "annotation": ""}, "snippet": " num_users = User.objects.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L117_C8", "label": "response = get()", "type": "assigned_variable", "loc": [117, 117], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L115_C4", "vector": [14, 2, 0.6882, 0.0059, 2, 0.85, 0.3333, 511, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/remote_user/', REMOTE_USER='newuser')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L118_C8", "label": "assert_()", "type": "expression", "loc": [118, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L115_C4", "vector": [8, 2, 0.6941, 0.0059, 2, 0.85, 0.6667, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(response.context['user'].is_anonymous())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L119_C8", "label": "assertEqual()", "type": "expression", "loc": [119, 119], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L115_C4", "vector": [8, 2, 0.7, 0.0059, 2, 0.85, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(User.objects.count(), num_users)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L122_C0", "label": "CustomRemoteUserBackend", "type": "class", "loc": [122, 139], "level": 0, "parent": null, "vector": [3, 0, 0.7676, 0.1059, 0, 0.66, 0.8889, 990, 0, 2, 0, 0, 519, 0, 2], "semantic": {"name": "CustomRemoteUserBackend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CustomRemoteUserBackend(RemoteUserBackend):\n \"\"\"\n Backend that overrides RemoteUserBackend methods.\n \"\"\"\n\n def clean_username(self, username):\n \"\"\"\n Grabs username before the @ character."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L123_C4", "label": "expression", "type": "expression", "loc": [123, 125], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L122_C0", "vector": [8, 1, 0.7294, 0.0176, 1, 0.18, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Backend that overrides RemoteUserBackend methods.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L127_C4", "label": "clean_username", "type": "function", "loc": [127, 131], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L122_C0", "vector": [2, 1, 0.7588, 0.0294, 1, 0.18, 0.5, 629, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "clean_username", "arg_names": ["self", "username"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clean_username(self, username):\n \"\"\"\n Grabs username before the @ character.\n \"\"\"\n return username.split('@')[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L128_C8", "label": "expression", "type": "expression", "loc": [128, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L127_C4", "vector": [8, 2, 0.7588, 0.0176, 2, 0.22, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Grabs username before the @ character.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Return_L131_C8", "label": "return", "type": "return", "loc": [131, 131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L127_C4", "vector": [13, 2, 0.7706, 0.0059, 2, 0.22, 1.0, 0, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return username.split('@')[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L133_C4", "label": "configure_user", "type": "function", "loc": [133, 139], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L122_C0", "vector": [2, 1, 0.8, 0.0412, 1, 0.18, 1.0, 548, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "configure_user", "arg_names": ["self", "user"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def configure_user(self, user):\n \"\"\"\n Sets user's email address.\n \"\"\"\n user.email = 'user@example.com'\n user.save()\n return user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L134_C8", "label": "expression", "type": "expression", "loc": [134, 136], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L133_C4", "vector": [8, 2, 0.7941, 0.0176, 2, 0.64, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Sets user's email address.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L137_C8", "label": "user.email =", "type": "assigned_variable", "loc": [137, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L133_C4", "vector": [14, 2, 0.8059, 0.0059, 2, 0.64, 0.3333, 846, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "user.email", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user.email = 'user@example.com'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L138_C8", "label": "save()", "type": "expression", "loc": [138, 138], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L133_C4", "vector": [8, 2, 0.8118, 0.0059, 2, 0.64, 0.6667, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " user.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Return_L139_C8", "label": "return", "type": "return", "loc": [139, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L133_C4", "vector": [13, 2, 0.8176, 0.0059, 2, 0.64, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "label": "RemoteUserCustomTest", "type": "class", "loc": [142, 170], "level": 0, "parent": null, "vector": [3, 0, 0.9176, 0.1706, 0, 0.66, 1.0, 260, 0, 2, 0, 0, 981, 0, 10], "semantic": {"name": "RemoteUserCustomTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RemoteUserCustomTest(RemoteUserTest):\n \"\"\"\n Tests a custom RemoteUserBackend subclass that overrides the clean_username\n and configure_user methods.\n \"\"\"\n\n backend =\\\n 'django.contrib.auth.tests.remote_user.CustomRemoteUserBackend'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L143_C4", "label": "expression", "type": "expression", "loc": [143, 146], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "vector": [8, 1, 0.85, 0.0235, 1, 0.03, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Tests a custom RemoteUserBackend subclass that overrides the clean_username\n and configure_user methods.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L148_C4", "label": "backend =", "type": "assigned_variable", "loc": [148, 149], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "vector": [14, 1, 0.8735, 0.0118, 1, 0.03, 0.2, 631, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "backend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " backend =\\\n 'django.contrib.auth.tests.remote_user.CustomRemoteUserBackend'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L152_C4", "label": "known_user =", "type": "assigned_variable", "loc": [152, 152], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "vector": [14, 1, 0.8941, 0.0059, 1, 0.03, 0.4, 133, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "known_user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " known_user = 'knownuser@example.com'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L153_C4", "label": "known_user2 =", "type": "assigned_variable", "loc": [153, 153], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "vector": [14, 1, 0.9, 0.0059, 1, 0.03, 0.6, 902, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "known_user2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " known_user2 = 'knownuser2@example.com'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L155_C4", "label": "test_known_user", "type": "function", "loc": [155, 162], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "vector": [2, 1, 0.9324, 0.0471, 1, 0.03, 0.8, 627, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_known_user", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_known_user(self):\n \"\"\"\n The strings passed in REMOTE_USER should be cleaned and the known users\n should not have been configured with an email address.\n \"\"\"\n super(RemoteUserCustomTest, self).test_known_user()\n self.assertEqual(User.objects.get(username='knownuser').email, '')\n self.assertEqual(User.objects.get(username='knownuser2').email, '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L156_C8", "label": "expression", "type": "expression", "loc": [156, 159], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L155_C4", "vector": [8, 2, 0.9265, 0.0235, 2, 0.38, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n The strings passed in REMOTE_USER should be cleaned and the known users\n should not have been configured with an email address.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L160_C8", "label": "test_known_user()", "type": "expression", "loc": [160, 160], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L155_C4", "vector": [8, 2, 0.9412, 0.0059, 2, 0.38, 0.3333, 627, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "test_known_user", "arg_names": [], "import_names": [], "rhs_call_name": "test_known_user", "annotation": ""}, "snippet": " super(RemoteUserCustomTest, self).test_known_user()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L161_C8", "label": "assertEqual()", "type": "expression", "loc": [161, 161], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L155_C4", "vector": [8, 2, 0.9471, 0.0059, 2, 0.38, 0.6667, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(User.objects.get(username='knownuser').email, '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L162_C8", "label": "assertEqual()", "type": "expression", "loc": [162, 162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L155_C4", "vector": [8, 2, 0.9529, 0.0059, 2, 0.38, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(User.objects.get(username='knownuser2').email, '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L164_C4", "label": "test_unknown_user", "type": "function", "loc": [164, 170], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "vector": [2, 1, 0.9824, 0.0412, 1, 0.03, 1.0, 314, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_unknown_user", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_unknown_user(self):\n \"\"\"\n The unknown user created should be configured with an email address.\n \"\"\"\n super(RemoteUserCustomTest, self).test_unknown_user()\n newuser = User.objects.get(username='newuser')\n self.assertEqual(newuser.email, 'user@example.com')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L165_C8", "label": "expression", "type": "expression", "loc": [165, 167], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L164_C4", "vector": [8, 2, 0.9765, 0.0176, 2, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n The unknown user created should be configured with an email address.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L168_C8", "label": "test_unknown_user()", "type": "expression", "loc": [168, 168], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L164_C4", "vector": [8, 2, 0.9882, 0.0059, 2, 0.66, 0.3333, 314, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "test_unknown_user", "arg_names": [], "import_names": [], "rhs_call_name": "test_unknown_user", "annotation": ""}, "snippet": " super(RemoteUserCustomTest, self).test_unknown_user()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L169_C8", "label": "newuser = get()", "type": "assigned_variable", "loc": [169, 169], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L164_C4", "vector": [14, 2, 0.9941, 0.0059, 2, 0.66, 0.6667, 468, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "newuser", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " newuser = User.objects.get(username='newuser')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L170_C8", "label": "assertEqual()", "type": "expression", "loc": [170, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L164_C4", "vector": [8, 2, 1.0, 0.0059, 2, 0.66, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(newuser.email, 'user@example.com')"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L83_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L92_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L93_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L95_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L95_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L95_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L95_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L98_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L101_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L102_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L101_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L103_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L106_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L107_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L106_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L112_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L106_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L115_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L115_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L116_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L115_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L117_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L115_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L115_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L122_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L123_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L122_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L127_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L127_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L127_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Return_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L122_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L133_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L133_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L134_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L133_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L137_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L133_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L138_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L133_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Return_L139_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L143_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L148_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L152_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L153_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L155_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L155_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L155_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L160_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L155_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L161_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L155_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L164_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L164_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L165_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L164_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L168_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L164_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Assign_L169_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98608:FunctionDef_L164_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98608:Expr_L170_C8"}] |
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.tests.views import AuthViewsTestCase
class LoginRequiredTestCase(AuthViewsTestCase):
"""
Tests the login_required decorators
"""
urls = 'django.contrib.auth.tests.urls'
def testCallable(self):
"""
Check that login_required is assignable to callable objects.
"""
class CallableView(object):
def __call__(self, *args, **kwargs):
pass
login_required(CallableView())
def testView(self):
"""
Check that login_required is assignable to normal views.
"""
def normal_view(request):
pass
login_required(normal_view)
def testLoginRequired(self, view_url='/login_required/', login_url=settings.LOGIN_URL):
"""
Check that login_required works on a simple view wrapped in a
login_required decorator.
"""
response = self.client.get(view_url)
self.assertEqual(response.status_code, 302)
self.assert_(login_url in response['Location'])
self.login()
response = self.client.get(view_url)
self.assertEqual(response.status_code, 200)
def testLoginRequiredNextUrl(self):
"""
Check that login_required works on a simple view wrapped in a
login_required decorator with a login_url set.
"""
self.testLoginRequired(view_url='/login_required_login_url/',
login_url='/somewhere/')
| ajibawa-2023/Python-Code-Large/train/row_98609 | 26 | 46 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98609:ImportFrom_L1_C0", "label": "from django.conf import settings", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0217, 0.0217, 0, 0.66, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:ImportFrom_L2_C0", "label": "from django.contrib.auth.decorators import login_required", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0435, 0.0217, 0, 0.66, 0.3333, 885, 0, 1, 0, 0, 885, 0, 0], "semantic": {"name": "django.contrib.auth.decorators", "arg_names": [], "import_names": ["login_required"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.decorators import login_required"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:ImportFrom_L3_C0", "label": "from django.contrib.auth.tests.views import AuthViewsTestCase", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0652, 0.0217, 0, 0.66, 0.6667, 405, 0, 1, 0, 0, 405, 0, 0], "semantic": {"name": "django.contrib.auth.tests.views", "arg_names": [], "import_names": ["AuthViewsTestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.tests.views import AuthViewsTestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "label": "LoginRequiredTestCase", "type": "class", "loc": [5, 46], "level": 0, "parent": null, "vector": [3, 0, 0.5543, 0.913, 0, 0.66, 1.0, 260, 0, 6, 0, 0, 308, 0, 10], "semantic": {"name": "LoginRequiredTestCase", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class LoginRequiredTestCase(AuthViewsTestCase):\n \"\"\"\n Tests the login_required decorators\n \"\"\"\n urls = 'django.contrib.auth.tests.urls'\n\n def testCallable(self):\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L6_C4", "label": "expression", "type": "expression", "loc": [6, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "vector": [8, 1, 0.1522, 0.0652, 1, 0.56, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Tests the login_required decorators\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Assign_L9_C4", "label": "urls =", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "vector": [14, 1, 0.1957, 0.0217, 1, 0.56, 0.2, 260, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "urls", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " urls = 'django.contrib.auth.tests.urls'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L11_C4", "label": "testCallable", "type": "function", "loc": [11, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "vector": [2, 1, 0.3152, 0.1739, 1, 0.56, 0.4, 329, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "testCallable", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def testCallable(self):\n \"\"\"\n Check that login_required is assignable to callable objects.\n \"\"\"\n class CallableView(object):\n def __call__(self, *args, **kwargs):\n pass\n login_required(CallableView())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L12_C8", "label": "expression", "type": "expression", "loc": [12, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L11_C4", "vector": [8, 2, 0.2826, 0.0652, 2, 0.79, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Check that login_required is assignable to callable objects.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L15_C8", "label": "CallableView", "type": "class", "loc": [15, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L11_C4", "vector": [3, 2, 0.3478, 0.0652, 2, 0.79, 0.5, 246, 0, 1, 0, 0, 186, 0, 0], "semantic": {"name": "CallableView", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class CallableView(object):\n def __call__(self, *args, **kwargs):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L16_C12", "label": "__call__", "type": "function", "loc": [16, 17], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L15_C8", "vector": [2, 3, 0.3587, 0.0435, 3, 0.93, 0.0, 319, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "__call__", "arg_names": ["self", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __call__(self, *args, **kwargs):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L18_C8", "label": "login_required()", "type": "expression", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L11_C4", "vector": [8, 2, 0.3913, 0.0217, 2, 0.79, 1.0, 779, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "login_required", "arg_names": [], "import_names": [], "rhs_call_name": "login_required", "annotation": ""}, "snippet": " login_required(CallableView())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L20_C4", "label": "testView", "type": "function", "loc": [20, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "vector": [2, 1, 0.5, 0.1522, 1, 0.56, 0.6, 340, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "testView", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def testView(self):\n \"\"\"\n Check that login_required is assignable to normal views.\n \"\"\"\n def normal_view(request):\n pass\n login_required(normal_view)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L21_C8", "label": "expression", "type": "expression", "loc": [21, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L20_C4", "vector": [8, 2, 0.4783, 0.0652, 2, 0.95, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Check that login_required is assignable to normal views.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L24_C8", "label": "normal_view", "type": "function", "loc": [24, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L20_C4", "vector": [2, 2, 0.5326, 0.0435, 2, 0.95, 0.5, 814, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "normal_view", "arg_names": ["request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def normal_view(request):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L26_C8", "label": "login_required()", "type": "expression", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L20_C4", "vector": [8, 2, 0.5652, 0.0217, 2, 0.95, 1.0, 779, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "login_required", "arg_names": [], "import_names": [], "rhs_call_name": "login_required", "annotation": ""}, "snippet": " login_required(normal_view)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "label": "testLoginRequired", "type": "function", "loc": [28, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "vector": [2, 1, 0.7174, 0.2391, 1, 0.56, 0.8, 441, 0, 3, 0, 0, 0, 0, 6], "semantic": {"name": "testLoginRequired", "arg_names": ["self", "view_url", "login_url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def testLoginRequired(self, view_url='/login_required/', login_url=settings.LOGIN_URL):\n \"\"\"\n Check that login_required works on a simple view wrapped in a\n login_required decorator.\n \"\"\"\n response = self.client.get(view_url)\n self.assertEqual(response.status_code, 302)\n self.assert_(login_url in response['Location'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L29_C8", "label": "expression", "type": "expression", "loc": [29, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "vector": [8, 2, 0.663, 0.087, 2, 0.91, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Check that login_required works on a simple view wrapped in a\n login_required decorator.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Assign_L33_C8", "label": "response = get()", "type": "assigned_variable", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "vector": [14, 2, 0.7174, 0.0217, 2, 0.91, 0.1667, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get(view_url)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L34_C8", "label": "assertEqual()", "type": "expression", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "vector": [8, 2, 0.7391, 0.0217, 2, 0.91, 0.3333, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(response.status_code, 302)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L35_C8", "label": "assert_()", "type": "expression", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "vector": [8, 2, 0.7609, 0.0217, 2, 0.91, 0.5, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(login_url in response['Location'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L36_C8", "label": "login()", "type": "expression", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "vector": [8, 2, 0.7826, 0.0217, 2, 0.91, 0.6667, 724, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " self.login()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Assign_L37_C8", "label": "response = get()", "type": "assigned_variable", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "vector": [14, 2, 0.8043, 0.0217, 2, 0.91, 0.8333, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get(view_url)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L38_C8", "label": "assertEqual()", "type": "expression", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "vector": [8, 2, 0.8261, 0.0217, 2, 0.91, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L40_C4", "label": "testLoginRequiredNextUrl", "type": "function", "loc": [40, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "vector": [2, 1, 0.9348, 0.1522, 1, 0.56, 1.0, 112, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "testLoginRequiredNextUrl", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def testLoginRequiredNextUrl(self):\n \"\"\"\n Check that login_required works on a simple view wrapped in a\n login_required decorator with a login_url set.\n \"\"\"\n self.testLoginRequired(view_url='/login_required_login_url/',\n login_url='/somewhere/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L41_C8", "label": "expression", "type": "expression", "loc": [41, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L40_C4", "vector": [8, 2, 0.9239, 0.087, 2, 0.79, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Check that login_required works on a simple view wrapped in a\n login_required decorator with a login_url set.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L45_C8", "label": "testLoginRequired()", "type": "expression", "loc": [45, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L40_C4", "vector": [8, 2, 0.9891, 0.0435, 2, 0.79, 1.0, 441, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "testLoginRequired", "arg_names": [], "import_names": [], "rhs_call_name": "testLoginRequired", "annotation": ""}, "snippet": " self.testLoginRequired(view_url='/login_required_login_url/',\n login_url='/somewhere/')"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L15_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L16_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Assign_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Assign_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98609:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98609:Expr_L45_C8"}] |
from datetime import date, timedelta
from django.conf import settings
from django.contrib.auth.models import User, AnonymousUser
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.test import TestCase
class TokenGeneratorTest(TestCase):
def test_make_token(self):
"""
Ensure that we can make a token and that it is valid
"""
user = User.objects.create_user('tokentestuser', 'test2@example.com', 'testpw')
p0 = PasswordResetTokenGenerator()
tk1 = p0.make_token(user)
self.assertTrue(p0.check_token(user, tk1))
def test_10265(self):
"""
Ensure that the token generated for a user created in the same request
will work correctly.
"""
# See ticket #10265
user = User.objects.create_user('comebackkid', 'test3@example.com', 'testpw')
p0 = PasswordResetTokenGenerator()
tk1 = p0.make_token(user)
reload = User.objects.get(username='comebackkid')
tk2 = p0.make_token(reload)
self.assertEqual(tk1, tk2)
def test_timeout(self):
"""
Ensure we can use the token after n days, but no greater.
"""
# Uses a mocked version of PasswordResetTokenGenerator so we can change
# the value of 'today'
class Mocked(PasswordResetTokenGenerator):
def __init__(self, today):
self._today_val = today
def _today(self):
return self._today_val
user = User.objects.create_user('tokentestuser', 'test2@example.com', 'testpw')
p0 = PasswordResetTokenGenerator()
tk1 = p0.make_token(user)
p1 = Mocked(date.today() + timedelta(settings.PASSWORD_RESET_TIMEOUT_DAYS))
self.assertTrue(p1.check_token(user, tk1))
p2 = Mocked(date.today() + timedelta(settings.PASSWORD_RESET_TIMEOUT_DAYS + 1))
self.assertFalse(p2.check_token(user, tk1))
def test_django12_hash(self):
"""
Ensure we can use the hashes generated by Django 1.2
"""
# Hard code in the Django 1.2 algorithm (not the result, as it is time
# dependent)
def _make_token(user):
from django.utils.hashcompat import sha_constructor
from django.utils.http import int_to_base36
timestamp = (date.today() - date(2001,1,1)).days
ts_b36 = int_to_base36(timestamp)
hash = sha_constructor(settings.SECRET_KEY + unicode(user.id) +
user.password + user.last_login.strftime('%Y-%m-%d %H:%M:%S') +
unicode(timestamp)).hexdigest()[::2]
return "%s-%s" % (ts_b36, hash)
user = User.objects.create_user('tokentestuser', 'test2@example.com', 'testpw')
p0 = PasswordResetTokenGenerator()
tk1 = _make_token(user)
self.assertTrue(p0.check_token(user, tk1))
| ajibawa-2023/Python-Code-Large/train/row_98610 | 47 | 74 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98610:ImportFrom_L1_C0", "label": "from datetime import date, timedelta", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0135, 0.0135, 0, 0.66, 0.0, 426, 0, 2, 0, 0, 426, 0, 0], "semantic": {"name": "datetime", "arg_names": [], "import_names": ["date", "timedelta"], "rhs_call_name": "", "annotation": ""}, "snippet": "from datetime import date, timedelta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:ImportFrom_L3_C0", "label": "from django.conf import settings", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0405, 0.0135, 0, 0.66, 0.2, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:ImportFrom_L4_C0", "label": "from django.contrib.auth.models import User, AnonymousUser", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0541, 0.0135, 0, 0.66, 0.4, 808, 0, 2, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User", "AnonymousUser"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User, AnonymousUser"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:ImportFrom_L5_C0", "label": "from django.contrib.auth.tokens import PasswordResetTokenGenerator", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0676, 0.0135, 0, 0.66, 0.6, 366, 0, 1, 0, 0, 366, 0, 0], "semantic": {"name": "django.contrib.auth.tokens", "arg_names": [], "import_names": ["PasswordResetTokenGenerator"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.tokens import PasswordResetTokenGenerator"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:ImportFrom_L6_C0", "label": "from django.test import TestCase", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0811, 0.0135, 0, 0.66, 0.8, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.test", "arg_names": [], "import_names": ["TestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.test import TestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L9_C0", "label": "TokenGeneratorTest", "type": "class", "loc": [9, 74], "level": 0, "parent": null, "vector": [3, 0, 0.5608, 0.8919, 0, 0.66, 1.0, 299, 0, 7, 0, 0, 3, 0, 37], "semantic": {"name": "TokenGeneratorTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TokenGeneratorTest(TestCase):\n\n def test_make_token(self):\n \"\"\"\n Ensure that we can make a token and that it is valid\n \"\"\"\n user = User.objects.create_user('tokentestuser', 'test2@example.com', 'testpw')\n p0 = PasswordResetTokenGenerator()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L11_C4", "label": "test_make_token", "type": "function", "loc": [11, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L9_C0", "vector": [2, 1, 0.1959, 0.1081, 1, 0.81, 0.0, 649, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_make_token", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_make_token(self):\n \"\"\"\n Ensure that we can make a token and that it is valid\n \"\"\"\n user = User.objects.create_user('tokentestuser', 'test2@example.com', 'testpw')\n p0 = PasswordResetTokenGenerator()\n tk1 = p0.make_token(user)\n self.assertTrue(p0.check_token(user, tk1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L12_C8", "label": "expression", "type": "expression", "loc": [12, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L11_C4", "vector": [8, 2, 0.1757, 0.0405, 2, 0.74, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Ensure that we can make a token and that it is valid\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L15_C8", "label": "user = create_user()", "type": "assigned_variable", "loc": [15, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L11_C4", "vector": [14, 2, 0.2027, 0.0135, 2, 0.74, 0.25, 503, 3, 3, 0, 0, 946, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " user = User.objects.create_user('tokentestuser', 'test2@example.com', 'testpw')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L16_C8", "label": "p0 = PasswordResetTokenGenerator()", "type": "assigned_variable", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L11_C4", "vector": [14, 2, 0.2162, 0.0135, 2, 0.74, 0.5, 477, 3, 0, 0, 0, 474, 10, 1], "semantic": {"name": "p0", "arg_names": [], "import_names": [], "rhs_call_name": "PasswordResetTokenGenerator", "annotation": ""}, "snippet": " p0 = PasswordResetTokenGenerator()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L17_C8", "label": "tk1 = make_token()", "type": "assigned_variable", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L11_C4", "vector": [14, 2, 0.2297, 0.0135, 2, 0.74, 0.75, 246, 3, 1, 0, 0, 485, 10, 1], "semantic": {"name": "tk1", "arg_names": [], "import_names": [], "rhs_call_name": "make_token", "annotation": ""}, "snippet": " tk1 = p0.make_token(user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L18_C8", "label": "assertTrue()", "type": "expression", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L11_C4", "vector": [8, 2, 0.2432, 0.0135, 2, 0.74, 1.0, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(p0.check_token(user, tk1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "label": "test_10265", "type": "function", "loc": [20, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L9_C0", "vector": [2, 1, 0.3446, 0.1622, 1, 0.81, 0.3333, 424, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_10265", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_10265(self):\n \"\"\"\n Ensure that the token generated for a user created in the same request\n will work correctly.\n \"\"\"\n # See ticket #10265\n user = User.objects.create_user('comebackkid', 'test3@example.com', 'testpw')\n p0 = PasswordResetTokenGenerator()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L21_C8", "label": "expression", "type": "expression", "loc": [21, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "vector": [8, 2, 0.3041, 0.0541, 2, 0.42, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Ensure that the token generated for a user created in the same request\n will work correctly.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L26_C8", "label": "user = create_user()", "type": "assigned_variable", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "vector": [14, 2, 0.3514, 0.0135, 2, 0.42, 0.1667, 503, 3, 3, 0, 0, 946, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " user = User.objects.create_user('comebackkid', 'test3@example.com', 'testpw')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L27_C8", "label": "p0 = PasswordResetTokenGenerator()", "type": "assigned_variable", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "vector": [14, 2, 0.3649, 0.0135, 2, 0.42, 0.3333, 477, 3, 0, 0, 0, 474, 10, 1], "semantic": {"name": "p0", "arg_names": [], "import_names": [], "rhs_call_name": "PasswordResetTokenGenerator", "annotation": ""}, "snippet": " p0 = PasswordResetTokenGenerator()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L28_C8", "label": "tk1 = make_token()", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "vector": [14, 2, 0.3784, 0.0135, 2, 0.42, 0.5, 246, 3, 1, 0, 0, 485, 10, 1], "semantic": {"name": "tk1", "arg_names": [], "import_names": [], "rhs_call_name": "make_token", "annotation": ""}, "snippet": " tk1 = p0.make_token(user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L29_C8", "label": "reload = get()", "type": "assigned_variable", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "vector": [14, 2, 0.3919, 0.0135, 2, 0.42, 0.6667, 959, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "reload", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " reload = User.objects.get(username='comebackkid')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L30_C8", "label": "tk2 = make_token()", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "vector": [14, 2, 0.4054, 0.0135, 2, 0.42, 0.8333, 401, 3, 1, 0, 0, 485, 10, 1], "semantic": {"name": "tk2", "arg_names": [], "import_names": [], "rhs_call_name": "make_token", "annotation": ""}, "snippet": " tk2 = p0.make_token(reload)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L31_C8", "label": "assertEqual()", "type": "expression", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "vector": [8, 2, 0.4189, 0.0135, 2, 0.42, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(tk1, tk2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "label": "test_timeout", "type": "function", "loc": [33, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L9_C0", "vector": [2, 1, 0.5743, 0.2703, 1, 0.81, 0.6667, 828, 0, 1, 1, 0, 0, 0, 13], "semantic": {"name": "test_timeout", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_timeout(self):\n \"\"\"\n Ensure we can use the token after n days, but no greater.\n \"\"\"\n # Uses a mocked version of PasswordResetTokenGenerator so we can change\n # the value of 'today'\n class Mocked(PasswordResetTokenGenerator):\n def __init__(self, today):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L34_C8", "label": "expression", "type": "expression", "loc": [34, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "vector": [8, 2, 0.473, 0.0405, 2, 0.71, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Ensure we can use the token after n days, but no greater.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L39_C8", "label": "Mocked", "type": "class", "loc": [39, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "vector": [3, 2, 0.5541, 0.0676, 2, 0.71, 0.125, 104, 0, 2, 0, 0, 474, 0, 0], "semantic": {"name": "Mocked", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Mocked(PasswordResetTokenGenerator):\n def __init__(self, today):\n self._today_val = today\n def _today(self):\n return self._today_val"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L40_C12", "label": "__init__", "type": "function", "loc": [40, 41], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L39_C8", "vector": [2, 3, 0.5473, 0.027, 3, 0.57, 0.0, 555, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "today"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, today):\n self._today_val = today"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L41_C16", "label": "self._today_val =", "type": "assigned_variable", "loc": [41, 41], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L40_C12", "vector": [14, 4, 0.5541, 0.0135, 4, 0.04, 0.0, 319, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._today_val", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._today_val = today"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L42_C12", "label": "_today", "type": "function", "loc": [42, 43], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L39_C8", "vector": [2, 3, 0.5743, 0.027, 3, 0.57, 1.0, 779, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "_today", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _today(self):\n return self._today_val"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Return_L43_C16", "label": "return", "type": "return", "loc": [43, 43], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L42_C12", "vector": [13, 4, 0.5811, 0.0135, 4, 0.93, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._today_val"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L45_C8", "label": "user = create_user()", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "vector": [14, 2, 0.6081, 0.0135, 2, 0.71, 0.25, 503, 3, 3, 0, 0, 946, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " user = User.objects.create_user('tokentestuser', 'test2@example.com', 'testpw')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L46_C8", "label": "p0 = PasswordResetTokenGenerator()", "type": "assigned_variable", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "vector": [14, 2, 0.6216, 0.0135, 2, 0.71, 0.375, 477, 3, 0, 0, 0, 474, 10, 1], "semantic": {"name": "p0", "arg_names": [], "import_names": [], "rhs_call_name": "PasswordResetTokenGenerator", "annotation": ""}, "snippet": " p0 = PasswordResetTokenGenerator()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L47_C8", "label": "tk1 = make_token()", "type": "assigned_variable", "loc": [47, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "vector": [14, 2, 0.6351, 0.0135, 2, 0.71, 0.5, 246, 3, 1, 0, 0, 485, 10, 1], "semantic": {"name": "tk1", "arg_names": [], "import_names": [], "rhs_call_name": "make_token", "annotation": ""}, "snippet": " tk1 = p0.make_token(user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L48_C8", "label": "p1 = Mocked()", "type": "assigned_variable", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "vector": [14, 2, 0.6486, 0.0135, 2, 0.71, 0.625, 87, 3, 1, 0, 0, 104, 10, 3], "semantic": {"name": "p1", "arg_names": [], "import_names": [], "rhs_call_name": "Mocked", "annotation": ""}, "snippet": " p1 = Mocked(date.today() + timedelta(settings.PASSWORD_RESET_TIMEOUT_DAYS))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L49_C8", "label": "assertTrue()", "type": "expression", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "vector": [8, 2, 0.6622, 0.0135, 2, 0.71, 0.75, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(p1.check_token(user, tk1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L51_C8", "label": "p2 = Mocked()", "type": "assigned_variable", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "vector": [14, 2, 0.6892, 0.0135, 2, 0.71, 0.875, 843, 3, 1, 0, 0, 104, 10, 3], "semantic": {"name": "p2", "arg_names": [], "import_names": [], "rhs_call_name": "Mocked", "annotation": ""}, "snippet": " p2 = Mocked(date.today() + timedelta(settings.PASSWORD_RESET_TIMEOUT_DAYS + 1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L52_C8", "label": "assertFalse()", "type": "expression", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "vector": [8, 2, 0.7027, 0.0135, 2, 0.71, 1.0, 861, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(p2.check_token(user, tk1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "label": "test_django12_hash", "type": "function", "loc": [54, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L9_C0", "vector": [2, 1, 0.8649, 0.2838, 1, 0.81, 1.0, 188, 0, 1, 1, 0, 0, 0, 13], "semantic": {"name": "test_django12_hash", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_django12_hash(self):\n \"\"\"\n Ensure we can use the hashes generated by Django 1.2\n \"\"\"\n # Hard code in the Django 1.2 algorithm (not the result, as it is time\n # dependent)\n def _make_token(user):\n from django.utils.hashcompat import sha_constructor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L55_C8", "label": "expression", "type": "expression", "loc": [55, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "vector": [8, 2, 0.7568, 0.0405, 2, 0.95, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Ensure we can use the hashes generated by Django 1.2\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "label": "_make_token", "type": "function", "loc": [60, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "vector": [2, 2, 0.8716, 0.1351, 2, 0.95, 0.2, 914, 0, 1, 1, 0, 0, 0, 8], "semantic": {"name": "_make_token", "arg_names": ["user"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _make_token(user):\n from django.utils.hashcompat import sha_constructor\n from django.utils.http import int_to_base36\n\n timestamp = (date.today() - date(2001,1,1)).days\n ts_b36 = int_to_base36(timestamp)\n hash = sha_constructor(settings.SECRET_KEY + unicode(user.id) +\n user.password + user.last_login.strftime('%Y-%m-%d %H:%M:%S') +"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:ImportFrom_L61_C12", "label": "from django.utils.hashcompat import sha_constructor", "type": "import", "loc": [61, 61], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "vector": [1, 3, 0.8243, 0.0135, 3, 0.8, 0.0, 474, 0, 1, 0, 0, 474, 0, 0], "semantic": {"name": "django.utils.hashcompat", "arg_names": [], "import_names": ["sha_constructor"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.utils.hashcompat import sha_constructor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:ImportFrom_L62_C12", "label": "from django.utils.http import int_to_base36", "type": "import", "loc": [62, 62], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "vector": [1, 3, 0.8378, 0.0135, 3, 0.8, 0.2, 516, 0, 1, 0, 0, 516, 0, 0], "semantic": {"name": "django.utils.http", "arg_names": [], "import_names": ["int_to_base36"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.utils.http import int_to_base36"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L64_C12", "label": "timestamp =", "type": "assigned_variable", "loc": [64, 64], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "vector": [14, 3, 0.8649, 0.0135, 3, 0.8, 0.4, 834, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "timestamp", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " timestamp = (date.today() - date(2001,1,1)).days"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L65_C12", "label": "ts_b36 = int_to_base36()", "type": "assigned_variable", "loc": [65, 65], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "vector": [14, 3, 0.8784, 0.0135, 3, 0.8, 0.6, 349, 3, 1, 0, 0, 465, 10, 1], "semantic": {"name": "ts_b36", "arg_names": [], "import_names": [], "rhs_call_name": "int_to_base36", "annotation": ""}, "snippet": " ts_b36 = int_to_base36(timestamp)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L66_C12", "label": "hash =", "type": "assigned_variable", "loc": [66, 68], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "vector": [14, 3, 0.9054, 0.0405, 3, 0.8, 0.8, 58, 6, 0, 0, 0, 0, 0, 5], "semantic": {"name": "hash", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " hash = sha_constructor(settings.SECRET_KEY + unicode(user.id) +\n user.password + user.last_login.strftime('%Y-%m-%d %H:%M:%S') +\n unicode(timestamp)).hexdigest()[::2]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Return_L69_C12", "label": "return", "type": "return", "loc": [69, 69], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "vector": [13, 3, 0.9324, 0.0135, 3, 0.8, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"%s-%s\" % (ts_b36, hash)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L71_C8", "label": "user = create_user()", "type": "assigned_variable", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "vector": [14, 2, 0.9595, 0.0135, 2, 0.95, 0.4, 503, 3, 3, 0, 0, 946, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "create_user", "annotation": ""}, "snippet": " user = User.objects.create_user('tokentestuser', 'test2@example.com', 'testpw')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L72_C8", "label": "p0 = PasswordResetTokenGenerator()", "type": "assigned_variable", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "vector": [14, 2, 0.973, 0.0135, 2, 0.95, 0.6, 477, 3, 0, 0, 0, 474, 10, 1], "semantic": {"name": "p0", "arg_names": [], "import_names": [], "rhs_call_name": "PasswordResetTokenGenerator", "annotation": ""}, "snippet": " p0 = PasswordResetTokenGenerator()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L73_C8", "label": "tk1 = _make_token()", "type": "assigned_variable", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "vector": [14, 2, 0.9865, 0.0135, 2, 0.95, 0.8, 246, 3, 1, 0, 0, 914, 10, 1], "semantic": {"name": "tk1", "arg_names": [], "import_names": [], "rhs_call_name": "_make_token", "annotation": ""}, "snippet": " tk1 = _make_token(user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L74_C8", "label": "assertTrue()", "type": "expression", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "vector": [8, 2, 1.0, 0.0135, 2, 0.95, 1.0, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue(p0.check_token(user, tk1))"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L40_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L40_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L41_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L42_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L42_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Return_L43_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:ImportFrom_L61_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:ImportFrom_L62_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L64_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L65_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L66_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L60_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Return_L69_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Assign_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98610:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98610:Expr_L74_C8"}] |
import os
import re
import urllib
from django.conf import settings
from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.sites.models import Site, RequestSite
from django.contrib.auth.models import User
from django.test import TestCase
from django.core import mail
from django.core.urlresolvers import reverse
class AuthViewsTestCase(TestCase):
"""
Helper base class for all the follow test cases.
"""
fixtures = ['authtestdata.json']
urls = 'django.contrib.auth.tests.urls'
def setUp(self):
self.old_LANGUAGES = settings.LANGUAGES
self.old_LANGUAGE_CODE = settings.LANGUAGE_CODE
settings.LANGUAGES = (('en', 'English'),)
settings.LANGUAGE_CODE = 'en'
self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
settings.TEMPLATE_DIRS = (
os.path.join(
os.path.dirname(__file__),
'templates'
)
,)
def tearDown(self):
settings.LANGUAGES = self.old_LANGUAGES
settings.LANGUAGE_CODE = self.old_LANGUAGE_CODE
settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
def login(self, password='password'):
response = self.client.post('/login/', {
'username': 'testclient',
'password': password
}
)
self.assertEquals(response.status_code, 302)
self.assert_(response['Location'].endswith(settings.LOGIN_REDIRECT_URL))
self.assert_(SESSION_KEY in self.client.session)
class PasswordResetTest(AuthViewsTestCase):
def test_email_not_found(self):
"Error is raised if the provided email address isn't currently registered"
response = self.client.get('/password_reset/')
self.assertEquals(response.status_code, 200)
response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'})
self.assertContains(response, "That e-mail address doesn't have an associated user account")
self.assertEquals(len(mail.outbox), 0)
def test_email_found(self):
"Email is sent if a valid email address is provided for password reset"
response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})
self.assertEquals(response.status_code, 302)
self.assertEquals(len(mail.outbox), 1)
self.assert_("http://" in mail.outbox[0].body)
self.assertEquals(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)
def test_email_found_custom_from(self):
"Email is sent if a valid email address is provided for password reset when a custom from_email is provided."
response = self.client.post('/password_reset_from_email/', {'email': 'staffmember@example.com'})
self.assertEquals(response.status_code, 302)
self.assertEquals(len(mail.outbox), 1)
self.assertEquals("staffmember@example.com", mail.outbox[0].from_email)
def _test_confirm_start(self):
# Start by creating the email
response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})
self.assertEquals(response.status_code, 302)
self.assertEquals(len(mail.outbox), 1)
return self._read_signup_email(mail.outbox[0])
def _read_signup_email(self, email):
urlmatch = re.search(r"https?://[^/]*(/.*reset/\S*)", email.body)
self.assert_(urlmatch is not None, "No URL found in sent email")
return urlmatch.group(), urlmatch.groups()[0]
def test_confirm_valid(self):
url, path = self._test_confirm_start()
response = self.client.get(path)
# redirect to a 'complete' page:
self.assertEquals(response.status_code, 200)
self.assert_("Please enter your new password" in response.content)
def test_confirm_invalid(self):
url, path = self._test_confirm_start()
# Let's munge the token in the path, but keep the same length,
# in case the URLconf will reject a different length.
path = path[:-5] + ("0"*4) + path[-1]
response = self.client.get(path)
self.assertEquals(response.status_code, 200)
self.assert_("The password reset link was invalid" in response.content)
def test_confirm_invalid_user(self):
# Ensure that we get a 200 response for a non-existant user, not a 404
response = self.client.get('/reset/123456-1-1/')
self.assertEquals(response.status_code, 200)
self.assert_("The password reset link was invalid" in response.content)
def test_confirm_invalid_post(self):
# Same as test_confirm_invalid, but trying
# to do a POST instead.
url, path = self._test_confirm_start()
path = path[:-5] + ("0"*4) + path[-1]
response = self.client.post(path, {'new_password1': 'anewpassword',
'new_password2':' anewpassword'})
# Check the password has not been changed
u = User.objects.get(email='staffmember@example.com')
self.assert_(not u.check_password("anewpassword"))
def test_confirm_complete(self):
url, path = self._test_confirm_start()
response = self.client.post(path, {'new_password1': 'anewpassword',
'new_password2': 'anewpassword'})
# It redirects us to a 'complete' page:
self.assertEquals(response.status_code, 302)
# Check the password has been changed
u = User.objects.get(email='staffmember@example.com')
self.assert_(u.check_password("anewpassword"))
# Check we can't use the link again
response = self.client.get(path)
self.assertEquals(response.status_code, 200)
self.assert_("The password reset link was invalid" in response.content)
def test_confirm_different_passwords(self):
url, path = self._test_confirm_start()
response = self.client.post(path, {'new_password1': 'anewpassword',
'new_password2':' x'})
self.assertEquals(response.status_code, 200)
self.assert_("The two password fields didn't match" in response.content)
class ChangePasswordTest(AuthViewsTestCase):
def fail_login(self, password='password'):
response = self.client.post('/login/', {
'username': 'testclient',
'password': password
}
)
self.assertEquals(response.status_code, 200)
self.assert_("Please enter a correct username and password. Note that both fields are case-sensitive." in response.content)
def logout(self):
response = self.client.get('/logout/')
def test_password_change_fails_with_invalid_old_password(self):
self.login()
response = self.client.post('/password_change/', {
'old_password': 'donuts',
'new_password1': 'password1',
'new_password2': 'password1',
}
)
self.assertEquals(response.status_code, 200)
self.assert_("Your old password was entered incorrectly. Please enter it again." in response.content)
def test_password_change_fails_with_mismatched_passwords(self):
self.login()
response = self.client.post('/password_change/', {
'old_password': 'password',
'new_password1': 'password1',
'new_password2': 'donuts',
}
)
self.assertEquals(response.status_code, 200)
self.assert_("The two password fields didn't match." in response.content)
def test_password_change_succeeds(self):
self.login()
response = self.client.post('/password_change/', {
'old_password': 'password',
'new_password1': 'password1',
'new_password2': 'password1',
}
)
self.assertEquals(response.status_code, 302)
self.assert_(response['Location'].endswith('/password_change/done/'))
self.fail_login()
self.login(password='password1')
class LoginTest(AuthViewsTestCase):
def test_current_site_in_context_after_login(self):
response = self.client.get(reverse('django.contrib.auth.views.login'))
self.assertEquals(response.status_code, 200)
site = Site.objects.get_current()
self.assertEquals(response.context['site'], site)
self.assertEquals(response.context['site_name'], site.name)
self.assert_(isinstance(response.context['form'], AuthenticationForm),
'Login form is not an AuthenticationForm')
def test_security_check(self, password='password'):
login_url = reverse('django.contrib.auth.views.login')
# Those URLs should not pass the security check
for bad_url in ('http://example.com',
'https://example.com',
'ftp://exampel.com',
'//example.com'):
nasty_url = '%(url)s?%(next)s=%(bad_url)s' % {
'url': login_url,
'next': REDIRECT_FIELD_NAME,
'bad_url': urllib.quote(bad_url)
}
response = self.client.post(nasty_url, {
'username': 'testclient',
'password': password,
}
)
self.assertEquals(response.status_code, 302)
self.assertFalse(bad_url in response['Location'], "%s should be blocked" % bad_url)
# Now, these URLs have an other URL as a GET parameter and therefore
# should be allowed
for url_ in ('http://example.com', 'https://example.com',
'ftp://exampel.com', '//example.com'):
safe_url = '%(url)s?%(next)s=/view/?param=%(safe_param)s' % {
'url': login_url,
'next': REDIRECT_FIELD_NAME,
'safe_param': urllib.quote(url_)
}
response = self.client.post(safe_url, {
'username': 'testclient',
'password': password,
}
)
self.assertEquals(response.status_code, 302)
self.assertTrue('/view/?param=%s' % url_ in response['Location'], "/view/?param=%s should be allowed" % url_)
class LogoutTest(AuthViewsTestCase):
urls = 'django.contrib.auth.tests.urls'
def confirm_logged_out(self):
self.assert_(SESSION_KEY not in self.client.session)
def test_logout_default(self):
"Logout without next_page option renders the default template"
self.login()
response = self.client.get('/logout/')
self.assertEquals(200, response.status_code)
self.assert_('Logged out' in response.content)
self.confirm_logged_out()
def test_14377(self):
# Bug 14377
self.login()
response = self.client.get('/logout/')
self.assertTrue('site' in response.context)
def test_logout_with_next_page_specified(self):
"Logout with next_page option given redirects to specified resource"
self.login()
response = self.client.get('/logout/next_page/')
self.assertEqual(response.status_code, 302)
self.assert_(response['Location'].endswith('/somewhere/'))
self.confirm_logged_out()
def test_logout_with_redirect_argument(self):
"Logout with query string redirects to specified resource"
self.login()
response = self.client.get('/logout/?next=/login/')
self.assertEqual(response.status_code, 302)
self.assert_(response['Location'].endswith('/login/'))
self.confirm_logged_out()
def test_logout_with_custom_redirect_argument(self):
"Logout with custom query string redirects to specified resource"
self.login()
response = self.client.get('/logout/custom_query/?follow=/somewhere/')
self.assertEqual(response.status_code, 302)
self.assert_(response['Location'].endswith('/somewhere/'))
self.confirm_logged_out()
| ajibawa-2023/Python-Code-Large/train/row_98611 | 176 | 285 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Import_L1_C0", "label": "os import os", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0035, 0.0035, 0, 0.66, 0.0, 688, 0, 1, 0, 0, 688, 0, 0], "semantic": {"name": "os", "arg_names": [], "import_names": ["os"], "rhs_call_name": "", "annotation": ""}, "snippet": "import os"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Import_L2_C0", "label": "re import re", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.007, 0.0035, 0, 0.66, 0.0667, 540, 0, 1, 0, 0, 540, 0, 0], "semantic": {"name": "re", "arg_names": [], "import_names": ["re"], "rhs_call_name": "", "annotation": ""}, "snippet": "import re"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Import_L3_C0", "label": "urllib import urllib", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0105, 0.0035, 0, 0.66, 0.1333, 614, 0, 1, 0, 0, 614, 0, 0], "semantic": {"name": "urllib", "arg_names": [], "import_names": ["urllib"], "rhs_call_name": "", "annotation": ""}, "snippet": "import urllib"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ImportFrom_L5_C0", "label": "from django.conf import settings", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0175, 0.0035, 0, 0.66, 0.2, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ImportFrom_L6_C0", "label": "from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0211, 0.0035, 0, 0.66, 0.2667, 895, 0, 2, 0, 0, 895, 0, 0], "semantic": {"name": "django.contrib.auth", "arg_names": [], "import_names": ["SESSION_KEY", "REDIRECT_FIELD_NAME"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ImportFrom_L7_C0", "label": "from django.contrib.auth.forms import AuthenticationForm", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0246, 0.0035, 0, 0.66, 0.3333, 579, 0, 1, 0, 0, 579, 0, 0], "semantic": {"name": "django.contrib.auth.forms", "arg_names": [], "import_names": ["AuthenticationForm"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.forms import AuthenticationForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ImportFrom_L8_C0", "label": "from django.contrib.sites.models import Site, RequestSite", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0281, 0.0035, 0, 0.66, 0.4, 890, 0, 2, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sites.models", "arg_names": [], "import_names": ["Site", "RequestSite"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sites.models import Site, RequestSite"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ImportFrom_L9_C0", "label": "from django.contrib.auth.models import User", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0316, 0.0035, 0, 0.66, 0.4667, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ImportFrom_L10_C0", "label": "from django.test import TestCase", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0351, 0.0035, 0, 0.66, 0.5333, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.test", "arg_names": [], "import_names": ["TestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.test import TestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ImportFrom_L11_C0", "label": "from django.core import mail", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0386, 0.0035, 0, 0.66, 0.6, 913, 0, 1, 0, 0, 913, 0, 0], "semantic": {"name": "django.core", "arg_names": [], "import_names": ["mail"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core import mail"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ImportFrom_L12_C0", "label": "from django.core.urlresolvers import reverse", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0421, 0.0035, 0, 0.66, 0.6667, 749, 0, 1, 0, 0, 749, 0, 0], "semantic": {"name": "django.core.urlresolvers", "arg_names": [], "import_names": ["reverse"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.urlresolvers import reverse"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "label": "AuthViewsTestCase", "type": "class", "loc": [14, 47], "level": 0, "parent": null, "vector": [3, 0, 0.107, 0.1193, 0, 0.66, 0.7333, 308, 0, 3, 0, 0, 3, 0, 7], "semantic": {"name": "AuthViewsTestCase", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AuthViewsTestCase(TestCase):\n \"\"\"\n Helper base class for all the follow test cases.\n \"\"\"\n fixtures = ['authtestdata.json']\n urls = 'django.contrib.auth.tests.urls'\n\n def setUp(self):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L15_C4", "label": "expression", "type": "expression", "loc": [15, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "vector": [8, 1, 0.0561, 0.0105, 1, 0.08, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Helper base class for all the follow test cases.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L18_C4", "label": "fixtures =", "type": "assigned_variable", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "vector": [14, 1, 0.0632, 0.0035, 1, 0.08, 0.2, 752, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "fixtures", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fixtures = ['authtestdata.json']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L19_C4", "label": "urls =", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "vector": [14, 1, 0.0667, 0.0035, 1, 0.08, 0.4, 260, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "urls", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " urls = 'django.contrib.auth.tests.urls'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "label": "setUp", "type": "function", "loc": [21, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "vector": [2, 1, 0.093, 0.0421, 1, 0.08, 0.6, 952, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "setUp", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def setUp(self):\n self.old_LANGUAGES = settings.LANGUAGES\n self.old_LANGUAGE_CODE = settings.LANGUAGE_CODE\n settings.LANGUAGES = (('en', 'English'),)\n settings.LANGUAGE_CODE = 'en'\n self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS\n settings.TEMPLATE_DIRS = (\n os.path.join("}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L22_C8", "label": "self.old_LANGUAGES =", "type": "assigned_variable", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "vector": [14, 2, 0.0772, 0.0035, 2, 0.1, 0.0, 164, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.old_LANGUAGES", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.old_LANGUAGES = settings.LANGUAGES"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L23_C8", "label": "self.old_LANGUAGE_CODE =", "type": "assigned_variable", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "vector": [14, 2, 0.0807, 0.0035, 2, 0.1, 0.2, 207, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.old_LANGUAGE_CODE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.old_LANGUAGE_CODE = settings.LANGUAGE_CODE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L24_C8", "label": "settings.LANGUAGES =", "type": "assigned_variable", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "vector": [14, 2, 0.0842, 0.0035, 2, 0.1, 0.4, 88, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "settings.LANGUAGES", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.LANGUAGES = (('en', 'English'),)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L25_C8", "label": "settings.LANGUAGE_CODE =", "type": "assigned_variable", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "vector": [14, 2, 0.0877, 0.0035, 2, 0.1, 0.6, 919, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "settings.LANGUAGE_CODE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.LANGUAGE_CODE = 'en'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L26_C8", "label": "self.old_TEMPLATE_DIRS =", "type": "assigned_variable", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "vector": [14, 2, 0.0912, 0.0035, 2, 0.1, 0.8, 161, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.old_TEMPLATE_DIRS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L27_C8", "label": "settings.TEMPLATE_DIRS =", "type": "assigned_variable", "loc": [27, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "vector": [14, 2, 0.1035, 0.0211, 2, 0.1, 1.0, 983, 0, 0, 0, 0, 0, 8, 2], "semantic": {"name": "settings.TEMPLATE_DIRS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.TEMPLATE_DIRS = (\n os.path.join(\n os.path.dirname(__file__),\n 'templates'\n )\n ,)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L34_C4", "label": "tearDown", "type": "function", "loc": [34, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "vector": [2, 1, 0.1246, 0.014, 1, 0.08, 0.8, 530, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "tearDown", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def tearDown(self):\n settings.LANGUAGES = self.old_LANGUAGES\n settings.LANGUAGE_CODE = self.old_LANGUAGE_CODE\n settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L35_C8", "label": "settings.LANGUAGES =", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L34_C4", "vector": [14, 2, 0.1228, 0.0035, 2, 0.75, 0.0, 88, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "settings.LANGUAGES", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.LANGUAGES = self.old_LANGUAGES"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L36_C8", "label": "settings.LANGUAGE_CODE =", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L34_C4", "vector": [14, 2, 0.1263, 0.0035, 2, 0.75, 0.5, 919, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "settings.LANGUAGE_CODE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.LANGUAGE_CODE = self.old_LANGUAGE_CODE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L37_C8", "label": "settings.TEMPLATE_DIRS =", "type": "assigned_variable", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L34_C4", "vector": [14, 2, 0.1298, 0.0035, 2, 0.75, 1.0, 983, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "settings.TEMPLATE_DIRS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L39_C4", "label": "login", "type": "function", "loc": [39, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "vector": [2, 1, 0.1509, 0.0316, 1, 0.08, 1.0, 724, 0, 2, 0, 0, 0, 0, 5], "semantic": {"name": "login", "arg_names": ["self", "password"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def login(self, password='password'):\n response = self.client.post('/login/', {\n 'username': 'testclient',\n 'password': password\n }\n )\n self.assertEquals(response.status_code, 302)\n self.assert_(response['Location'].endswith(settings.LOGIN_REDIRECT_URL))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L40_C8", "label": "response = post()", "type": "assigned_variable", "loc": [40, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L39_C4", "vector": [14, 2, 0.1474, 0.0175, 2, 0.5, 0.0, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post('/login/', {\n 'username': 'testclient',\n 'password': password\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L45_C8", "label": "assertEquals()", "type": "expression", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L39_C4", "vector": [8, 2, 0.1579, 0.0035, 2, 0.5, 0.3333, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 302)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L46_C8", "label": "assert_()", "type": "expression", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L39_C4", "vector": [8, 2, 0.1614, 0.0035, 2, 0.5, 0.6667, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(response['Location'].endswith(settings.LOGIN_REDIRECT_URL))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L47_C8", "label": "assert_()", "type": "expression", "loc": [47, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L39_C4", "vector": [8, 2, 0.1649, 0.0035, 2, 0.5, 1.0, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(SESSION_KEY in self.client.session)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "label": "PasswordResetTest", "type": "class", "loc": [49, 141], "level": 0, "parent": null, "vector": [3, 0, 0.3333, 0.3263, 0, 0.66, 0.8, 160, 0, 11, 0, 0, 308, 0, 55], "semantic": {"name": "PasswordResetTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PasswordResetTest(AuthViewsTestCase):\n\n def test_email_not_found(self):\n \"Error is raised if the provided email address isn't currently registered\"\n response = self.client.get('/password_reset/')\n self.assertEquals(response.status_code, 200)\n response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'})\n self.assertContains(response, \"That e-mail address doesn't have an associated user account\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "label": "test_email_not_found", "type": "function", "loc": [51, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "vector": [2, 1, 0.1895, 0.0246, 1, 0.84, 0.0, 455, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_email_not_found", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_email_not_found(self):\n \"Error is raised if the provided email address isn't currently registered\"\n response = self.client.get('/password_reset/')\n self.assertEquals(response.status_code, 200)\n response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'})\n self.assertContains(response, \"That e-mail address doesn't have an associated user account\")\n self.assertEquals(len(mail.outbox), 0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L52_C8", "label": "expression", "type": "expression", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "vector": [8, 2, 0.1825, 0.0035, 2, 0.54, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Error is raised if the provided email address isn't currently registered\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L53_C8", "label": "response = get()", "type": "assigned_variable", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "vector": [14, 2, 0.186, 0.0035, 2, 0.54, 0.2, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/password_reset/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L54_C8", "label": "assertEquals()", "type": "expression", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "vector": [8, 2, 0.1895, 0.0035, 2, 0.54, 0.4, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L55_C8", "label": "response = post()", "type": "assigned_variable", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "vector": [14, 2, 0.193, 0.0035, 2, 0.54, 0.6, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L56_C8", "label": "assertContains()", "type": "expression", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "vector": [8, 2, 0.1965, 0.0035, 2, 0.54, 0.8, 335, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertContains", "arg_names": [], "import_names": [], "rhs_call_name": "assertContains", "annotation": ""}, "snippet": " self.assertContains(response, \"That e-mail address doesn't have an associated user account\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L57_C8", "label": "assertEquals()", "type": "expression", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "vector": [8, 2, 0.2, 0.0035, 2, 0.54, 1.0, 60, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(len(mail.outbox), 0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "label": "test_email_found", "type": "function", "loc": [59, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "vector": [2, 1, 0.2175, 0.0246, 1, 0.84, 0.1, 29, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_email_found", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_email_found(self):\n \"Email is sent if a valid email address is provided for password reset\"\n response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})\n self.assertEquals(response.status_code, 302)\n self.assertEquals(len(mail.outbox), 1)\n self.assert_(\"http://\" in mail.outbox[0].body)\n self.assertEquals(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L60_C8", "label": "expression", "type": "expression", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "vector": [8, 2, 0.2105, 0.0035, 2, 0.39, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Email is sent if a valid email address is provided for password reset\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L61_C8", "label": "response = post()", "type": "assigned_variable", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "vector": [14, 2, 0.214, 0.0035, 2, 0.39, 0.2, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L62_C8", "label": "assertEquals()", "type": "expression", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "vector": [8, 2, 0.2175, 0.0035, 2, 0.39, 0.4, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 302)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L63_C8", "label": "assertEquals()", "type": "expression", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "vector": [8, 2, 0.2211, 0.0035, 2, 0.39, 0.6, 60, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(len(mail.outbox), 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L64_C8", "label": "assert_()", "type": "expression", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "vector": [8, 2, 0.2246, 0.0035, 2, 0.39, 0.8, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(\"http://\" in mail.outbox[0].body)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L65_C8", "label": "assertEquals()", "type": "expression", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "vector": [8, 2, 0.2281, 0.0035, 2, 0.39, 1.0, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L67_C4", "label": "test_email_found_custom_from", "type": "function", "loc": [67, 72], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "vector": [2, 1, 0.2439, 0.0211, 1, 0.84, 0.2, 571, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_email_found_custom_from", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_email_found_custom_from(self):\n \"Email is sent if a valid email address is provided for password reset when a custom from_email is provided.\"\n response = self.client.post('/password_reset_from_email/', {'email': 'staffmember@example.com'})\n self.assertEquals(response.status_code, 302)\n self.assertEquals(len(mail.outbox), 1)\n self.assertEquals(\"staffmember@example.com\", mail.outbox[0].from_email)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L68_C8", "label": "expression", "type": "expression", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L67_C4", "vector": [8, 2, 0.2386, 0.0035, 2, 0.31, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Email is sent if a valid email address is provided for password reset when a custom from_email is provided.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L69_C8", "label": "response = post()", "type": "assigned_variable", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L67_C4", "vector": [14, 2, 0.2421, 0.0035, 2, 0.31, 0.25, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post('/password_reset_from_email/', {'email': 'staffmember@example.com'})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L70_C8", "label": "assertEquals()", "type": "expression", "loc": [70, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L67_C4", "vector": [8, 2, 0.2456, 0.0035, 2, 0.31, 0.5, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 302)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L71_C8", "label": "assertEquals()", "type": "expression", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L67_C4", "vector": [8, 2, 0.2491, 0.0035, 2, 0.31, 0.75, 60, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(len(mail.outbox), 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L72_C8", "label": "assertEquals()", "type": "expression", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L67_C4", "vector": [8, 2, 0.2526, 0.0035, 2, 0.31, 1.0, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(\"staffmember@example.com\", mail.outbox[0].from_email)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L74_C4", "label": "_test_confirm_start", "type": "function", "loc": [74, 79], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "vector": [2, 1, 0.2684, 0.0211, 1, 0.84, 0.3, 660, 0, 1, 1, 0, 0, 0, 5], "semantic": {"name": "_test_confirm_start", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _test_confirm_start(self):\n # Start by creating the email\n response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})\n self.assertEquals(response.status_code, 302)\n self.assertEquals(len(mail.outbox), 1)\n return self._read_signup_email(mail.outbox[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L76_C8", "label": "response = post()", "type": "assigned_variable", "loc": [76, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L74_C4", "vector": [14, 2, 0.2667, 0.0035, 2, 0.01, 0.0, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L77_C8", "label": "assertEquals()", "type": "expression", "loc": [77, 77], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L74_C4", "vector": [8, 2, 0.2702, 0.0035, 2, 0.01, 0.3333, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 302)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L78_C8", "label": "assertEquals()", "type": "expression", "loc": [78, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L74_C4", "vector": [8, 2, 0.2737, 0.0035, 2, 0.01, 0.6667, 60, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(len(mail.outbox), 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Return_L79_C8", "label": "return", "type": "return", "loc": [79, 79], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L74_C4", "vector": [13, 2, 0.2772, 0.0035, 2, 0.01, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._read_signup_email(mail.outbox[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L81_C4", "label": "_read_signup_email", "type": "function", "loc": [81, 84], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "vector": [2, 1, 0.2895, 0.014, 1, 0.84, 0.4, 176, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "_read_signup_email", "arg_names": ["self", "email"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _read_signup_email(self, email):\n urlmatch = re.search(r\"https?://[^/]*(/.*reset/\\S*)\", email.body)\n self.assert_(urlmatch is not None, \"No URL found in sent email\")\n return urlmatch.group(), urlmatch.groups()[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L82_C8", "label": "urlmatch = search()", "type": "assigned_variable", "loc": [82, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L81_C4", "vector": [14, 2, 0.2877, 0.0035, 2, 0.08, 0.0, 132, 3, 2, 0, 0, 163, 10, 1], "semantic": {"name": "urlmatch", "arg_names": [], "import_names": [], "rhs_call_name": "search", "annotation": ""}, "snippet": " urlmatch = re.search(r\"https?://[^/]*(/.*reset/\\S*)\", email.body)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L83_C8", "label": "assert_()", "type": "expression", "loc": [83, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L81_C4", "vector": [8, 2, 0.2912, 0.0035, 2, 0.08, 0.5, 17, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(urlmatch is not None, \"No URL found in sent email\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Return_L84_C8", "label": "return", "type": "return", "loc": [84, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L81_C4", "vector": [13, 2, 0.2947, 0.0035, 2, 0.08, 1.0, 0, 0, 0, 0, 0, 0, 8, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return urlmatch.group(), urlmatch.groups()[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L86_C4", "label": "test_confirm_valid", "type": "function", "loc": [86, 91], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "vector": [2, 1, 0.3105, 0.0211, 1, 0.84, 0.5, 491, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_confirm_valid", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_confirm_valid(self):\n url, path = self._test_confirm_start()\n response = self.client.get(path)\n # redirect to a 'complete' page:\n self.assertEquals(response.status_code, 200)\n self.assert_(\"Please enter your new password\" in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L87_C8", "label": "url, path = _test_confirm_start()", "type": "assigned_variable", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L86_C4", "vector": [14, 2, 0.3053, 0.0035, 2, 0.86, 0.0, 183, 3, 0, 0, 0, 660, 10, 1], "semantic": {"name": "url, path", "arg_names": [], "import_names": [], "rhs_call_name": "_test_confirm_start", "annotation": ""}, "snippet": " url, path = self._test_confirm_start()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L88_C8", "label": "response = get()", "type": "assigned_variable", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L86_C4", "vector": [14, 2, 0.3088, 0.0035, 2, 0.86, 0.3333, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get(path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L90_C8", "label": "assertEquals()", "type": "expression", "loc": [90, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L86_C4", "vector": [8, 2, 0.3158, 0.0035, 2, 0.86, 0.6667, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L91_C8", "label": "assert_()", "type": "expression", "loc": [91, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L86_C4", "vector": [8, 2, 0.3193, 0.0035, 2, 0.86, 1.0, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(\"Please enter your new password\" in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L93_C4", "label": "test_confirm_invalid", "type": "function", "loc": [93, 101], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "vector": [2, 1, 0.3404, 0.0316, 1, 0.84, 0.6, 949, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_confirm_invalid", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_confirm_invalid(self):\n url, path = self._test_confirm_start()\n # Let's munge the token in the path, but keep the same length,\n # in case the URLconf will reject a different length.\n path = path[:-5] + (\"0\"*4) + path[-1]\n\n response = self.client.get(path)\n self.assertEquals(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L94_C8", "label": "url, path = _test_confirm_start()", "type": "assigned_variable", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L93_C4", "vector": [14, 2, 0.3298, 0.0035, 2, 0.25, 0.0, 183, 3, 0, 0, 0, 660, 10, 1], "semantic": {"name": "url, path", "arg_names": [], "import_names": [], "rhs_call_name": "_test_confirm_start", "annotation": ""}, "snippet": " url, path = self._test_confirm_start()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L97_C8", "label": "path =", "type": "assigned_variable", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L93_C4", "vector": [14, 2, 0.3404, 0.0035, 2, 0.25, 0.25, 358, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "path", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " path = path[:-5] + (\"0\"*4) + path[-1]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L99_C8", "label": "response = get()", "type": "assigned_variable", "loc": [99, 99], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L93_C4", "vector": [14, 2, 0.3474, 0.0035, 2, 0.25, 0.5, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get(path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L100_C8", "label": "assertEquals()", "type": "expression", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L93_C4", "vector": [8, 2, 0.3509, 0.0035, 2, 0.25, 0.75, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L101_C8", "label": "assert_()", "type": "expression", "loc": [101, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L93_C4", "vector": [8, 2, 0.3544, 0.0035, 2, 0.25, 1.0, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(\"The password reset link was invalid\" in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L103_C4", "label": "test_confirm_invalid_user", "type": "function", "loc": [103, 107], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "vector": [2, 1, 0.3684, 0.0175, 1, 0.84, 0.7, 855, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "test_confirm_invalid_user", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_confirm_invalid_user(self):\n # Ensure that we get a 200 response for a non-existant user, not a 404\n response = self.client.get('/reset/123456-1-1/')\n self.assertEquals(response.status_code, 200)\n self.assert_(\"The password reset link was invalid\" in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L105_C8", "label": "response = get()", "type": "assigned_variable", "loc": [105, 105], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L103_C4", "vector": [14, 2, 0.3684, 0.0035, 2, 0.03, 0.0, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/reset/123456-1-1/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L106_C8", "label": "assertEquals()", "type": "expression", "loc": [106, 106], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L103_C4", "vector": [8, 2, 0.3719, 0.0035, 2, 0.03, 0.5, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L107_C8", "label": "assert_()", "type": "expression", "loc": [107, 107], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L103_C4", "vector": [8, 2, 0.3754, 0.0035, 2, 0.03, 1.0, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(\"The password reset link was invalid\" in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L109_C4", "label": "test_confirm_invalid_post", "type": "function", "loc": [109, 119], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "vector": [2, 1, 0.4, 0.0386, 1, 0.84, 0.8, 52, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_confirm_invalid_post", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_confirm_invalid_post(self):\n # Same as test_confirm_invalid, but trying\n # to do a POST instead.\n url, path = self._test_confirm_start()\n path = path[:-5] + (\"0\"*4) + path[-1]\n\n response = self.client.post(path, {'new_password1': 'anewpassword',\n 'new_password2':' anewpassword'})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L112_C8", "label": "url, path = _test_confirm_start()", "type": "assigned_variable", "loc": [112, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L109_C4", "vector": [14, 2, 0.393, 0.0035, 2, 0.13, 0.0, 183, 3, 0, 0, 0, 660, 10, 1], "semantic": {"name": "url, path", "arg_names": [], "import_names": [], "rhs_call_name": "_test_confirm_start", "annotation": ""}, "snippet": " url, path = self._test_confirm_start()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L113_C8", "label": "path =", "type": "assigned_variable", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L109_C4", "vector": [14, 2, 0.3965, 0.0035, 2, 0.13, 0.25, 358, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "path", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " path = path[:-5] + (\"0\"*4) + path[-1]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L115_C8", "label": "response = post()", "type": "assigned_variable", "loc": [115, 116], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L109_C4", "vector": [14, 2, 0.4053, 0.007, 2, 0.13, 0.5, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post(path, {'new_password1': 'anewpassword',\n 'new_password2':' anewpassword'})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L118_C8", "label": "u = get()", "type": "assigned_variable", "loc": [118, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L109_C4", "vector": [14, 2, 0.414, 0.0035, 2, 0.13, 0.75, 609, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "u", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " u = User.objects.get(email='staffmember@example.com')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L119_C8", "label": "assert_()", "type": "expression", "loc": [119, 119], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L109_C4", "vector": [8, 2, 0.4175, 0.0035, 2, 0.13, 1.0, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(not u.check_password(\"anewpassword\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "label": "test_confirm_complete", "type": "function", "loc": [121, 134], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "vector": [2, 1, 0.4474, 0.0491, 1, 0.84, 0.9, 976, 0, 1, 0, 0, 0, 0, 9], "semantic": {"name": "test_confirm_complete", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_confirm_complete(self):\n url, path = self._test_confirm_start()\n response = self.client.post(path, {'new_password1': 'anewpassword',\n 'new_password2': 'anewpassword'})\n # It redirects us to a 'complete' page:\n self.assertEquals(response.status_code, 302)\n # Check the password has been changed\n u = User.objects.get(email='staffmember@example.com')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L122_C8", "label": "url, path = _test_confirm_start()", "type": "assigned_variable", "loc": [122, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "vector": [14, 2, 0.4281, 0.0035, 2, 0.41, 0.0, 183, 3, 0, 0, 0, 660, 10, 1], "semantic": {"name": "url, path", "arg_names": [], "import_names": [], "rhs_call_name": "_test_confirm_start", "annotation": ""}, "snippet": " url, path = self._test_confirm_start()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L123_C8", "label": "response = post()", "type": "assigned_variable", "loc": [123, 124], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "vector": [14, 2, 0.4333, 0.007, 2, 0.41, 0.1429, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post(path, {'new_password1': 'anewpassword',\n 'new_password2': 'anewpassword'})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L126_C8", "label": "assertEquals()", "type": "expression", "loc": [126, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "vector": [8, 2, 0.4421, 0.0035, 2, 0.41, 0.2857, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 302)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L128_C8", "label": "u = get()", "type": "assigned_variable", "loc": [128, 128], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "vector": [14, 2, 0.4491, 0.0035, 2, 0.41, 0.4286, 609, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "u", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " u = User.objects.get(email='staffmember@example.com')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L129_C8", "label": "assert_()", "type": "expression", "loc": [129, 129], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "vector": [8, 2, 0.4526, 0.0035, 2, 0.41, 0.5714, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(u.check_password(\"anewpassword\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L132_C8", "label": "response = get()", "type": "assigned_variable", "loc": [132, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "vector": [14, 2, 0.4632, 0.0035, 2, 0.41, 0.7143, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get(path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L133_C8", "label": "assertEquals()", "type": "expression", "loc": [133, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "vector": [8, 2, 0.4667, 0.0035, 2, 0.41, 0.8571, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L134_C8", "label": "assert_()", "type": "expression", "loc": [134, 134], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "vector": [8, 2, 0.4702, 0.0035, 2, 0.41, 1.0, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(\"The password reset link was invalid\" in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L136_C4", "label": "test_confirm_different_passwords", "type": "function", "loc": [136, 141], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "vector": [2, 1, 0.486, 0.0211, 1, 0.84, 1.0, 907, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_confirm_different_passwords", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_confirm_different_passwords(self):\n url, path = self._test_confirm_start()\n response = self.client.post(path, {'new_password1': 'anewpassword',\n 'new_password2':' x'})\n self.assertEquals(response.status_code, 200)\n self.assert_(\"The two password fields didn't match\" in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L137_C8", "label": "url, path = _test_confirm_start()", "type": "assigned_variable", "loc": [137, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L136_C4", "vector": [14, 2, 0.4807, 0.0035, 2, 0.38, 0.0, 183, 3, 0, 0, 0, 660, 10, 1], "semantic": {"name": "url, path", "arg_names": [], "import_names": [], "rhs_call_name": "_test_confirm_start", "annotation": ""}, "snippet": " url, path = self._test_confirm_start()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L138_C8", "label": "response = post()", "type": "assigned_variable", "loc": [138, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L136_C4", "vector": [14, 2, 0.486, 0.007, 2, 0.38, 0.3333, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post(path, {'new_password1': 'anewpassword',\n 'new_password2':' x'})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L140_C8", "label": "assertEquals()", "type": "expression", "loc": [140, 140], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L136_C4", "vector": [8, 2, 0.4912, 0.0035, 2, 0.38, 0.6667, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L141_C8", "label": "assert_()", "type": "expression", "loc": [141, 141], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L136_C4", "vector": [8, 2, 0.4947, 0.0035, 2, 0.38, 1.0, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(\"The two password fields didn't match\" in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L143_C0", "label": "ChangePasswordTest", "type": "class", "loc": [143, 190], "level": 0, "parent": null, "vector": [3, 0, 0.5842, 0.1684, 0, 0.66, 0.8667, 216, 0, 5, 0, 0, 308, 0, 19], "semantic": {"name": "ChangePasswordTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ChangePasswordTest(AuthViewsTestCase):\n\n def fail_login(self, password='password'):\n response = self.client.post('/login/', {\n 'username': 'testclient',\n 'password': password\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L145_C4", "label": "fail_login", "type": "function", "loc": [145, 152], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L143_C0", "vector": [2, 1, 0.5211, 0.0281, 1, 0.37, 0.0, 731, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "fail_login", "arg_names": ["self", "password"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def fail_login(self, password='password'):\n response = self.client.post('/login/', {\n 'username': 'testclient',\n 'password': password\n }\n )\n self.assertEquals(response.status_code, 200)\n self.assert_(\"Please enter a correct username and password. Note that both fields are case-sensitive.\" in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L146_C8", "label": "response = post()", "type": "assigned_variable", "loc": [146, 150], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L145_C4", "vector": [14, 2, 0.5193, 0.0175, 2, 0.1, 0.0, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post('/login/', {\n 'username': 'testclient',\n 'password': password\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L151_C8", "label": "assertEquals()", "type": "expression", "loc": [151, 151], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L145_C4", "vector": [8, 2, 0.5298, 0.0035, 2, 0.1, 0.5, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L152_C8", "label": "assert_()", "type": "expression", "loc": [152, 152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L145_C4", "vector": [8, 2, 0.5333, 0.0035, 2, 0.1, 1.0, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(\"Please enter a correct username and password. Note that both fields are case-sensitive.\" in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L154_C4", "label": "logout", "type": "function", "loc": [154, 155], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L143_C0", "vector": [2, 1, 0.5421, 0.007, 1, 0.37, 0.25, 525, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "logout", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def logout(self):\n response = self.client.get('/logout/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L155_C8", "label": "response = get()", "type": "assigned_variable", "loc": [155, 155], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L154_C4", "vector": [14, 2, 0.5439, 0.0035, 2, 0.43, 0.0, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/logout/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L157_C4", "label": "test_password_change_fails_with_invalid_old_password", "type": "function", "loc": [157, 166], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L143_C0", "vector": [2, 1, 0.5667, 0.0351, 1, 0.37, 0.5, 921, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_password_change_fails_with_invalid_old_password", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_password_change_fails_with_invalid_old_password(self):\n self.login()\n response = self.client.post('/password_change/', {\n 'old_password': 'donuts',\n 'new_password1': 'password1',\n 'new_password2': 'password1',\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L158_C8", "label": "login()", "type": "expression", "loc": [158, 158], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L157_C4", "vector": [8, 2, 0.5544, 0.0035, 2, 0.38, 0.0, 724, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " self.login()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L159_C8", "label": "response = post()", "type": "assigned_variable", "loc": [159, 164], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L157_C4", "vector": [14, 2, 0.5667, 0.0211, 2, 0.38, 0.3333, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post('/password_change/', {\n 'old_password': 'donuts',\n 'new_password1': 'password1',\n 'new_password2': 'password1',\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L165_C8", "label": "assertEquals()", "type": "expression", "loc": [165, 165], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L157_C4", "vector": [8, 2, 0.5789, 0.0035, 2, 0.38, 0.6667, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L166_C8", "label": "assert_()", "type": "expression", "loc": [166, 166], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L157_C4", "vector": [8, 2, 0.5825, 0.0035, 2, 0.38, 1.0, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(\"Your old password was entered incorrectly. Please enter it again.\" in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L168_C4", "label": "test_password_change_fails_with_mismatched_passwords", "type": "function", "loc": [168, 177], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L143_C0", "vector": [2, 1, 0.6053, 0.0351, 1, 0.37, 0.75, 857, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_password_change_fails_with_mismatched_passwords", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_password_change_fails_with_mismatched_passwords(self):\n self.login()\n response = self.client.post('/password_change/', {\n 'old_password': 'password',\n 'new_password1': 'password1',\n 'new_password2': 'donuts',\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L169_C8", "label": "login()", "type": "expression", "loc": [169, 169], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L168_C4", "vector": [8, 2, 0.593, 0.0035, 2, 0.71, 0.0, 724, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " self.login()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L170_C8", "label": "response = post()", "type": "assigned_variable", "loc": [170, 175], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L168_C4", "vector": [14, 2, 0.6053, 0.0211, 2, 0.71, 0.3333, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post('/password_change/', {\n 'old_password': 'password',\n 'new_password1': 'password1',\n 'new_password2': 'donuts',\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L176_C8", "label": "assertEquals()", "type": "expression", "loc": [176, 176], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L168_C4", "vector": [8, 2, 0.6175, 0.0035, 2, 0.71, 0.6667, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L177_C8", "label": "assert_()", "type": "expression", "loc": [177, 177], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L168_C4", "vector": [8, 2, 0.6211, 0.0035, 2, 0.71, 1.0, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(\"The two password fields didn't match.\" in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "label": "test_password_change_succeeds", "type": "function", "loc": [179, 190], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L143_C0", "vector": [2, 1, 0.6474, 0.0421, 1, 0.37, 1.0, 266, 0, 1, 0, 0, 0, 0, 7], "semantic": {"name": "test_password_change_succeeds", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_password_change_succeeds(self):\n self.login()\n response = self.client.post('/password_change/', {\n 'old_password': 'password',\n 'new_password1': 'password1',\n 'new_password2': 'password1',\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L180_C8", "label": "login()", "type": "expression", "loc": [180, 180], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "vector": [8, 2, 0.6316, 0.0035, 2, 0.91, 0.0, 724, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " self.login()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L181_C8", "label": "response = post()", "type": "assigned_variable", "loc": [181, 186], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "vector": [14, 2, 0.6439, 0.0211, 2, 0.91, 0.2, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post('/password_change/', {\n 'old_password': 'password',\n 'new_password1': 'password1',\n 'new_password2': 'password1',\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L187_C8", "label": "assertEquals()", "type": "expression", "loc": [187, 187], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "vector": [8, 2, 0.6561, 0.0035, 2, 0.91, 0.4, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 302)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L188_C8", "label": "assert_()", "type": "expression", "loc": [188, 188], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "vector": [8, 2, 0.6596, 0.0035, 2, 0.91, 0.6, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(response['Location'].endswith('/password_change/done/'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L189_C8", "label": "fail_login()", "type": "expression", "loc": [189, 189], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "vector": [8, 2, 0.6632, 0.0035, 2, 0.91, 0.8, 731, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "fail_login", "arg_names": [], "import_names": [], "rhs_call_name": "fail_login", "annotation": ""}, "snippet": " self.fail_login()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L190_C8", "label": "login()", "type": "expression", "loc": [190, 190], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "vector": [8, 2, 0.6667, 0.0035, 2, 0.91, 1.0, 724, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " self.login(password='password1')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L192_C0", "label": "LoginTest", "type": "class", "loc": [192, 240], "level": 0, "parent": null, "vector": [3, 0, 0.7579, 0.1719, 0, 0.66, 0.9333, 355, 0, 2, 0, 0, 308, 0, 17], "semantic": {"name": "LoginTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class LoginTest(AuthViewsTestCase):\n\n def test_current_site_in_context_after_login(self):\n response = self.client.get(reverse('django.contrib.auth.views.login'))\n self.assertEquals(response.status_code, 200)\n site = Site.objects.get_current()\n self.assertEquals(response.context['site'], site)\n self.assertEquals(response.context['site_name'], site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "label": "test_current_site_in_context_after_login", "type": "function", "loc": [194, 201], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L192_C0", "vector": [2, 1, 0.693, 0.0281, 1, 0.97, 0.0, 551, 0, 1, 0, 0, 0, 0, 8], "semantic": {"name": "test_current_site_in_context_after_login", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_current_site_in_context_after_login(self):\n response = self.client.get(reverse('django.contrib.auth.views.login'))\n self.assertEquals(response.status_code, 200)\n site = Site.objects.get_current()\n self.assertEquals(response.context['site'], site)\n self.assertEquals(response.context['site_name'], site.name)\n self.assert_(isinstance(response.context['form'], AuthenticationForm), \n 'Login form is not an AuthenticationForm')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L195_C8", "label": "response = get()", "type": "assigned_variable", "loc": [195, 195], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "vector": [14, 2, 0.6842, 0.0035, 2, 0.6, 0.0, 511, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get(reverse('django.contrib.auth.views.login'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L196_C8", "label": "assertEquals()", "type": "expression", "loc": [196, 196], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "vector": [8, 2, 0.6877, 0.0035, 2, 0.6, 0.2, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L197_C8", "label": "site = get_current()", "type": "assigned_variable", "loc": [197, 197], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "vector": [14, 2, 0.6912, 0.0035, 2, 0.6, 0.4, 681, 3, 0, 0, 0, 632, 10, 1], "semantic": {"name": "site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current", "annotation": ""}, "snippet": " site = Site.objects.get_current()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L198_C8", "label": "assertEquals()", "type": "expression", "loc": [198, 198], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "vector": [8, 2, 0.6947, 0.0035, 2, 0.6, 0.6, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.context['site'], site)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L199_C8", "label": "assertEquals()", "type": "expression", "loc": [199, 199], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "vector": [8, 2, 0.6982, 0.0035, 2, 0.6, 0.8, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.context['site_name'], site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L200_C8", "label": "assert_()", "type": "expression", "loc": [200, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "vector": [8, 2, 0.7035, 0.007, 2, 0.6, 1.0, 17, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(isinstance(response.context['form'], AuthenticationForm), \n 'Login form is not an AuthenticationForm')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L203_C4", "label": "test_security_check", "type": "function", "loc": [203, 240], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L192_C0", "vector": [2, 1, 0.7772, 0.1333, 1, 0.97, 1.0, 513, 0, 2, 0, 0, 0, 0, 9], "semantic": {"name": "test_security_check", "arg_names": ["self", "password"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_security_check(self, password='password'):\n login_url = reverse('django.contrib.auth.views.login')\n\n # Those URLs should not pass the security check\n for bad_url in ('http://example.com',\n 'https://example.com',\n 'ftp://exampel.com',\n '//example.com'):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L204_C8", "label": "login_url = reverse()", "type": "assigned_variable", "loc": [204, 204], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L203_C4", "vector": [14, 2, 0.7158, 0.0035, 2, 0.55, 0.0, 704, 3, 1, 0, 0, 109, 10, 1], "semantic": {"name": "login_url", "arg_names": [], "import_names": [], "rhs_call_name": "reverse", "annotation": ""}, "snippet": " login_url = reverse('django.contrib.auth.views.login')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L207_C8", "label": "for bad_url", "type": "for", "loc": [207, 223], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L203_C4", "vector": [6, 2, 0.7544, 0.0596, 2, 0.55, 0.5, 18, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "bad_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for bad_url in ('http://example.com',\n 'https://example.com',\n 'ftp://exampel.com',\n '//example.com'):\n\n nasty_url = '%(url)s?%(next)s=%(bad_url)s' % {\n 'url': login_url,\n 'next': REDIRECT_FIELD_NAME,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L212_C12", "label": "nasty_url =", "type": "assigned_variable", "loc": [212, 216], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L207_C8", "vector": [14, 3, 0.7509, 0.0175, 3, 0.41, 0.0, 813, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "nasty_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " nasty_url = '%(url)s?%(next)s=%(bad_url)s' % {\n 'url': login_url,\n 'next': REDIRECT_FIELD_NAME,\n 'bad_url': urllib.quote(bad_url)\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L217_C12", "label": "response = post()", "type": "assigned_variable", "loc": [217, 221], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L207_C8", "vector": [14, 3, 0.7684, 0.0175, 3, 0.41, 0.3333, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post(nasty_url, {\n 'username': 'testclient',\n 'password': password,\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L222_C12", "label": "assertEquals()", "type": "expression", "loc": [222, 222], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L207_C8", "vector": [8, 3, 0.7789, 0.0035, 3, 0.41, 0.6667, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 302)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L223_C12", "label": "assertFalse()", "type": "expression", "loc": [223, 223], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L207_C8", "vector": [8, 3, 0.7825, 0.0035, 3, 0.41, 1.0, 861, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertFalse", "arg_names": [], "import_names": [], "rhs_call_name": "assertFalse", "annotation": ""}, "snippet": " self.assertFalse(bad_url in response['Location'], \"%s should be blocked\" % bad_url)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L227_C8", "label": "for url_", "type": "for", "loc": [227, 240], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L203_C4", "vector": [6, 2, 0.8193, 0.0491, 2, 0.55, 1.0, 912, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "url_", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for url_ in ('http://example.com', 'https://example.com',\n 'ftp://exampel.com', '//example.com'):\n safe_url = '%(url)s?%(next)s=/view/?param=%(safe_param)s' % {\n 'url': login_url,\n 'next': REDIRECT_FIELD_NAME,\n 'safe_param': urllib.quote(url_)\n }\n response = self.client.post(safe_url, {"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L229_C12", "label": "safe_url =", "type": "assigned_variable", "loc": [229, 233], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L227_C8", "vector": [14, 3, 0.8105, 0.0175, 3, 0.32, 0.0, 734, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "safe_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " safe_url = '%(url)s?%(next)s=/view/?param=%(safe_param)s' % {\n 'url': login_url,\n 'next': REDIRECT_FIELD_NAME,\n 'safe_param': urllib.quote(url_)\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L234_C12", "label": "response = post()", "type": "assigned_variable", "loc": [234, 238], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L227_C8", "vector": [14, 3, 0.8281, 0.0175, 3, 0.32, 0.3333, 511, 3, 2, 0, 0, 304, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "post", "annotation": ""}, "snippet": " response = self.client.post(safe_url, {\n 'username': 'testclient',\n 'password': password,\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L239_C12", "label": "assertEquals()", "type": "expression", "loc": [239, 239], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L227_C8", "vector": [8, 3, 0.8386, 0.0035, 3, 0.32, 0.6667, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(response.status_code, 302)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L240_C12", "label": "assertTrue()", "type": "expression", "loc": [240, 240], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L227_C8", "vector": [8, 3, 0.8421, 0.0035, 3, 0.32, 1.0, 170, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue('/view/?param=%s' % url_ in response['Location'], \"/view/?param=%s should be allowed\" % url_)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "label": "LogoutTest", "type": "class", "loc": [243, 285], "level": 0, "parent": null, "vector": [3, 0, 0.9263, 0.1509, 0, 0.66, 1.0, 438, 0, 6, 0, 0, 308, 0, 27], "semantic": {"name": "LogoutTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class LogoutTest(AuthViewsTestCase):\n urls = 'django.contrib.auth.tests.urls'\n\n def confirm_logged_out(self):\n self.assert_(SESSION_KEY not in self.client.session)\n\n def test_logout_default(self):\n \"Logout without next_page option renders the default template\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L244_C4", "label": "urls =", "type": "assigned_variable", "loc": [244, 244], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "vector": [14, 1, 0.8561, 0.0035, 1, 0.9, 0.0, 260, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "urls", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " urls = 'django.contrib.auth.tests.urls'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L246_C4", "label": "confirm_logged_out", "type": "function", "loc": [246, 247], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "vector": [2, 1, 0.8649, 0.007, 1, 0.9, 0.1667, 751, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "confirm_logged_out", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def confirm_logged_out(self):\n self.assert_(SESSION_KEY not in self.client.session)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L247_C8", "label": "assert_()", "type": "expression", "loc": [247, 247], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L246_C4", "vector": [8, 2, 0.8667, 0.0035, 2, 0.56, 0.0, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(SESSION_KEY not in self.client.session)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "label": "test_logout_default", "type": "function", "loc": [249, 255], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "vector": [2, 1, 0.8842, 0.0246, 1, 0.9, 0.3333, 984, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_logout_default", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_logout_default(self):\n \"Logout without next_page option renders the default template\"\n self.login()\n response = self.client.get('/logout/')\n self.assertEquals(200, response.status_code)\n self.assert_('Logged out' in response.content)\n self.confirm_logged_out()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L250_C8", "label": "expression", "type": "expression", "loc": [250, 250], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "vector": [8, 2, 0.8772, 0.0035, 2, 0.07, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Logout without next_page option renders the default template\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L251_C8", "label": "login()", "type": "expression", "loc": [251, 251], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "vector": [8, 2, 0.8807, 0.0035, 2, 0.07, 0.2, 724, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " self.login()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L252_C8", "label": "response = get()", "type": "assigned_variable", "loc": [252, 252], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "vector": [14, 2, 0.8842, 0.0035, 2, 0.07, 0.4, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/logout/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L253_C8", "label": "assertEquals()", "type": "expression", "loc": [253, 253], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "vector": [8, 2, 0.8877, 0.0035, 2, 0.07, 0.6, 60, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEquals", "arg_names": [], "import_names": [], "rhs_call_name": "assertEquals", "annotation": ""}, "snippet": " self.assertEquals(200, response.status_code)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L254_C8", "label": "assert_()", "type": "expression", "loc": [254, 254], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "vector": [8, 2, 0.8912, 0.0035, 2, 0.07, 0.8, 17, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_('Logged out' in response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L255_C8", "label": "confirm_logged_out()", "type": "expression", "loc": [255, 255], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "vector": [8, 2, 0.8947, 0.0035, 2, 0.07, 1.0, 751, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "confirm_logged_out", "arg_names": [], "import_names": [], "rhs_call_name": "confirm_logged_out", "annotation": ""}, "snippet": " self.confirm_logged_out()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L257_C4", "label": "test_14377", "type": "function", "loc": [257, 261], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "vector": [2, 1, 0.9088, 0.0175, 1, 0.9, 0.5, 665, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "test_14377", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_14377(self):\n # Bug 14377\n self.login()\n response = self.client.get('/logout/')\n self.assertTrue('site' in response.context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L259_C8", "label": "login()", "type": "expression", "loc": [259, 259], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L257_C4", "vector": [8, 2, 0.9088, 0.0035, 2, 0.69, 0.0, 724, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " self.login()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L260_C8", "label": "response = get()", "type": "assigned_variable", "loc": [260, 260], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L257_C4", "vector": [14, 2, 0.9123, 0.0035, 2, 0.69, 0.5, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/logout/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L261_C8", "label": "assertTrue()", "type": "expression", "loc": [261, 261], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L257_C4", "vector": [8, 2, 0.9158, 0.0035, 2, 0.69, 1.0, 170, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " self.assertTrue('site' in response.context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "label": "test_logout_with_next_page_specified", "type": "function", "loc": [263, 269], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "vector": [2, 1, 0.9333, 0.0246, 1, 0.9, 0.6667, 277, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_logout_with_next_page_specified", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_logout_with_next_page_specified(self): \n \"Logout with next_page option given redirects to specified resource\"\n self.login()\n response = self.client.get('/logout/next_page/')\n self.assertEqual(response.status_code, 302)\n self.assert_(response['Location'].endswith('/somewhere/'))\n self.confirm_logged_out()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L264_C8", "label": "expression", "type": "expression", "loc": [264, 264], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "vector": [8, 2, 0.9263, 0.0035, 2, 0.62, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Logout with next_page option given redirects to specified resource\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L265_C8", "label": "login()", "type": "expression", "loc": [265, 265], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "vector": [8, 2, 0.9298, 0.0035, 2, 0.62, 0.2, 724, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " self.login()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L266_C8", "label": "response = get()", "type": "assigned_variable", "loc": [266, 266], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "vector": [14, 2, 0.9333, 0.0035, 2, 0.62, 0.4, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/logout/next_page/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L267_C8", "label": "assertEqual()", "type": "expression", "loc": [267, 267], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "vector": [8, 2, 0.9368, 0.0035, 2, 0.62, 0.6, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(response.status_code, 302)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L268_C8", "label": "assert_()", "type": "expression", "loc": [268, 268], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "vector": [8, 2, 0.9404, 0.0035, 2, 0.62, 0.8, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(response['Location'].endswith('/somewhere/'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L269_C8", "label": "confirm_logged_out()", "type": "expression", "loc": [269, 269], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "vector": [8, 2, 0.9439, 0.0035, 2, 0.62, 1.0, 751, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "confirm_logged_out", "arg_names": [], "import_names": [], "rhs_call_name": "confirm_logged_out", "annotation": ""}, "snippet": " self.confirm_logged_out()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "label": "test_logout_with_redirect_argument", "type": "function", "loc": [271, 277], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "vector": [2, 1, 0.9614, 0.0246, 1, 0.9, 0.8333, 804, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_logout_with_redirect_argument", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_logout_with_redirect_argument(self):\n \"Logout with query string redirects to specified resource\"\n self.login()\n response = self.client.get('/logout/?next=/login/')\n self.assertEqual(response.status_code, 302)\n self.assert_(response['Location'].endswith('/login/'))\n self.confirm_logged_out()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L272_C8", "label": "expression", "type": "expression", "loc": [272, 272], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "vector": [8, 2, 0.9544, 0.0035, 2, 0.78, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Logout with query string redirects to specified resource\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L273_C8", "label": "login()", "type": "expression", "loc": [273, 273], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "vector": [8, 2, 0.9579, 0.0035, 2, 0.78, 0.2, 724, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " self.login()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L274_C8", "label": "response = get()", "type": "assigned_variable", "loc": [274, 274], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "vector": [14, 2, 0.9614, 0.0035, 2, 0.78, 0.4, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/logout/?next=/login/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L275_C8", "label": "assertEqual()", "type": "expression", "loc": [275, 275], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "vector": [8, 2, 0.9649, 0.0035, 2, 0.78, 0.6, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(response.status_code, 302)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L276_C8", "label": "assert_()", "type": "expression", "loc": [276, 276], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "vector": [8, 2, 0.9684, 0.0035, 2, 0.78, 0.8, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(response['Location'].endswith('/login/'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L277_C8", "label": "confirm_logged_out()", "type": "expression", "loc": [277, 277], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "vector": [8, 2, 0.9719, 0.0035, 2, 0.78, 1.0, 751, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "confirm_logged_out", "arg_names": [], "import_names": [], "rhs_call_name": "confirm_logged_out", "annotation": ""}, "snippet": " self.confirm_logged_out()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "label": "test_logout_with_custom_redirect_argument", "type": "function", "loc": [279, 285], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "vector": [2, 1, 0.9895, 0.0246, 1, 0.9, 1.0, 296, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_logout_with_custom_redirect_argument", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_logout_with_custom_redirect_argument(self):\n \"Logout with custom query string redirects to specified resource\"\n self.login()\n response = self.client.get('/logout/custom_query/?follow=/somewhere/')\n self.assertEqual(response.status_code, 302)\n self.assert_(response['Location'].endswith('/somewhere/'))\n self.confirm_logged_out()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L280_C8", "label": "expression", "type": "expression", "loc": [280, 280], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "vector": [8, 2, 0.9825, 0.0035, 2, 0.88, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Logout with custom query string redirects to specified resource\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L281_C8", "label": "login()", "type": "expression", "loc": [281, 281], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "vector": [8, 2, 0.986, 0.0035, 2, 0.88, 0.2, 724, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " self.login()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L282_C8", "label": "response = get()", "type": "assigned_variable", "loc": [282, 282], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "vector": [14, 2, 0.9895, 0.0035, 2, 0.88, 0.4, 511, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = self.client.get('/logout/custom_query/?follow=/somewhere/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L283_C8", "label": "assertEqual()", "type": "expression", "loc": [283, 283], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "vector": [8, 2, 0.993, 0.0035, 2, 0.88, 0.6, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(response.status_code, 302)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L284_C8", "label": "assert_()", "type": "expression", "loc": [284, 284], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "vector": [8, 2, 0.9965, 0.0035, 2, 0.88, 0.8, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(response['Location'].endswith('/somewhere/'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L285_C8", "label": "confirm_logged_out()", "type": "expression", "loc": [285, 285], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "vector": [8, 2, 1.0, 0.0035, 2, 0.88, 1.0, 751, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "confirm_logged_out", "arg_names": [], "import_names": [], "rhs_call_name": "confirm_logged_out", "annotation": ""}, "snippet": " self.confirm_logged_out()"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L74_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Return_L79_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L81_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L81_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L81_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L83_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L81_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Return_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L86_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L93_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L99_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L103_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L103_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L105_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L103_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L106_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L103_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L109_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L112_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L115_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L122_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L123_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L129_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L132_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L121_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L134_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L136_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L137_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L138_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L141_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L143_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L145_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L145_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L146_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L145_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L151_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L145_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L152_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L143_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L154_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L154_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L155_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L143_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L157_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L157_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L158_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L157_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L159_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L157_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L165_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L157_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L143_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L168_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L168_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L169_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L168_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L170_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L168_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L176_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L168_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L177_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L143_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L180_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L181_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L187_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L188_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L189_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L190_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L195_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L197_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L198_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L199_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L194_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L200_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L203_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L203_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L204_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L203_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L207_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L207_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L212_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L207_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L217_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L207_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L222_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L207_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L223_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L203_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L227_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L227_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L229_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L227_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L234_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L227_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L239_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:For_L227_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L240_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L244_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L246_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L247_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L250_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L251_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L252_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L253_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L254_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L255_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L257_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L257_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L259_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L257_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L260_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L257_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L261_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L264_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L265_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L266_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L267_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L268_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L269_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L272_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L273_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L274_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L275_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L276_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L271_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L277_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:ClassDef_L243_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L280_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L281_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Assign_L282_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L283_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L284_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98611:FunctionDef_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98611:Expr_L285_C8"}] |
from django.contrib.auth.tests.auth_backends import BackendTest, RowlevelBackendTest, AnonymousUserBackendTest, NoAnonymousUserBackendTest
from django.contrib.auth.tests.basic import BasicTestCase
from django.contrib.auth.tests.decorators import LoginRequiredTestCase
from django.contrib.auth.tests.forms import UserCreationFormTest, AuthenticationFormTest, SetPasswordFormTest, PasswordChangeFormTest, UserChangeFormTest, PasswordResetFormTest
from django.contrib.auth.tests.remote_user \
import RemoteUserTest, RemoteUserNoCreateTest, RemoteUserCustomTest
from django.contrib.auth.tests.models import ProfileTestCase
from django.contrib.auth.tests.tokens import TokenGeneratorTest
from django.contrib.auth.tests.views \
import PasswordResetTest, ChangePasswordTest, LoginTest, LogoutTest
# The password for the fixture data users is 'password'
| ajibawa-2023/Python-Code-Large/train/row_98612 | 8 | 12 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98612:ImportFrom_L1_C0", "label": "from django.contrib.auth.tests.auth_backends import BackendTest, RowlevelBackendTest, AnonymousUserBackendTest\u2026", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0833, 0.0833, 0, 0.66, 0.0, 769, 0, 4, 0, 0, 769, 0, 0], "semantic": {"name": "django.contrib.auth.tests.auth_backends", "arg_names": [], "import_names": ["BackendTest", "RowlevelBackendTest", "AnonymousUserBackendTest", "NoAnonymousUserBackendTest"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.tests.auth_backends import BackendTest, RowlevelBackendTest, AnonymousUserBackendTest, NoAnonymousUserBackendTest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98612:ImportFrom_L2_C0", "label": "from django.contrib.auth.tests.basic import BasicTestCase", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1667, 0.0833, 0, 0.66, 0.1429, 879, 0, 1, 0, 0, 879, 0, 0], "semantic": {"name": "django.contrib.auth.tests.basic", "arg_names": [], "import_names": ["BasicTestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.tests.basic import BasicTestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98612:ImportFrom_L3_C0", "label": "from django.contrib.auth.tests.decorators import LoginRequiredTestCase", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.25, 0.0833, 0, 0.66, 0.2857, 250, 0, 1, 0, 0, 250, 0, 0], "semantic": {"name": "django.contrib.auth.tests.decorators", "arg_names": [], "import_names": ["LoginRequiredTestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.tests.decorators import LoginRequiredTestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98612:ImportFrom_L4_C0", "label": "from django.contrib.auth.tests.forms import UserCreationFormTest, AuthenticationFormTest, SetPasswordFormTest\u2026", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.3333, 0.0833, 0, 0.66, 0.4286, 405, 0, 6, 0, 0, 405, 0, 0], "semantic": {"name": "django.contrib.auth.tests.forms", "arg_names": [], "import_names": ["UserCreationFormTest", "AuthenticationFormTest", "SetPasswordFormTest", "PasswordChangeFormTest", "UserChangeFormTest", "PasswordResetFormTest"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.tests.forms import UserCreationFormTest, AuthenticationFormTest, SetPasswordFormTest, PasswordChangeFormTest, UserChangeFormTest, PasswordResetFormTest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98612:ImportFrom_L5_C0", "label": "from django.contrib.auth.tests.remote_user import RemoteUserTest, RemoteUserNoCreateTest, RemoteUserCustomTest", "type": "import", "loc": [5, 6], "level": 0, "parent": null, "vector": [1, 0, 0.4583, 0.1667, 0, 0.66, 0.5714, 466, 0, 3, 0, 0, 466, 0, 0], "semantic": {"name": "django.contrib.auth.tests.remote_user", "arg_names": [], "import_names": ["RemoteUserTest", "RemoteUserNoCreateTest", "RemoteUserCustomTest"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.tests.remote_user \\\n import RemoteUserTest, RemoteUserNoCreateTest, RemoteUserCustomTest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98612:ImportFrom_L7_C0", "label": "from django.contrib.auth.tests.models import ProfileTestCase", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.5833, 0.0833, 0, 0.66, 0.7143, 137, 0, 1, 0, 0, 137, 0, 0], "semantic": {"name": "django.contrib.auth.tests.models", "arg_names": [], "import_names": ["ProfileTestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.tests.models import ProfileTestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98612:ImportFrom_L8_C0", "label": "from django.contrib.auth.tests.tokens import TokenGeneratorTest", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.6667, 0.0833, 0, 0.66, 0.8571, 611, 0, 1, 0, 0, 611, 0, 0], "semantic": {"name": "django.contrib.auth.tests.tokens", "arg_names": [], "import_names": ["TokenGeneratorTest"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.tests.tokens import TokenGeneratorTest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98612:ImportFrom_L9_C0", "label": "from django.contrib.auth.tests.views import PasswordResetTest, ChangePasswordTest, LoginTest\u2026", "type": "import", "loc": [9, 10], "level": 0, "parent": null, "vector": [1, 0, 0.7917, 0.1667, 0, 0.66, 1.0, 405, 0, 4, 0, 0, 405, 0, 0], "semantic": {"name": "django.contrib.auth.tests.views", "arg_names": [], "import_names": ["PasswordResetTest", "ChangePasswordTest", "LoginTest", "LogoutTest"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.tests.views \\\n import PasswordResetTest, ChangePasswordTest, LoginTest, LogoutTest"}] | [] |
# These URLs are normally mapped to /admin/urls.py. This URLs file is
# provided as a convenience to those who want to deploy these URLs elsewhere.
# This file is also used to provide a reliable view deployment for test purposes.
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^login/$', 'django.contrib.auth.views.login'),
(r'^logout/$', 'django.contrib.auth.views.logout'),
(r'^password_change/$', 'django.contrib.auth.views.password_change'),
(r'^password_change/done/$', 'django.contrib.auth.views.password_change_done'),
(r'^password_reset/$', 'django.contrib.auth.views.password_reset'),
(r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done'),
(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm'),
(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),
)
| ajibawa-2023/Python-Code-Large/train/row_98613 | 2 | 17 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98613:ImportFrom_L5_C0", "label": "from django.conf.urls.defaults import *", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.2941, 0.0588, 0, 0.66, 0.0, 341, 0, 1, 0, 0, 341, 0, 0], "semantic": {"name": "django.conf.urls.defaults", "arg_names": [], "import_names": ["*"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf.urls.defaults import *"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98613:Assign_L7_C0", "label": "urlpatterns = patterns()", "type": "assigned_variable", "loc": [7, 16], "level": 0, "parent": null, "vector": [14, 0, 0.6765, 0.5882, 0, 0.66, 1.0, 990, 3, 9, 0, 0, 75, 10, 1], "semantic": {"name": "urlpatterns", "arg_names": [], "import_names": [], "rhs_call_name": "patterns", "annotation": ""}, "snippet": "urlpatterns = patterns('',\n (r'^login/$', 'django.contrib.auth.views.login'),\n (r'^logout/$', 'django.contrib.auth.views.logout'),\n (r'^password_change/$', 'django.contrib.auth.views.password_change'),\n (r'^password_change/done/$', 'django.contrib.auth.views.password_change_done'),\n (r'^password_reset/$', 'django.contrib.auth.views.password_reset'),\n (r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done'),\n (r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm'),"}] | [] |
from django.contrib import auth
from django.core.exceptions import ImproperlyConfigured
class LazyUser(object):
def __get__(self, request, obj_type=None):
if not hasattr(request, '_cached_user'):
from django.contrib.auth import get_user
request._cached_user = get_user(request)
return request._cached_user
class AuthenticationMiddleware(object):
def process_request(self, request):
assert hasattr(request, 'session'), "The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'."
request.__class__.user = LazyUser()
return None
class RemoteUserMiddleware(object):
"""
Middleware for utilizing Web-server-provided authentication.
If request.user is not authenticated, then this middleware attempts to
authenticate the username passed in the ``REMOTE_USER`` request header.
If authentication is successful, the user is automatically logged in to
persist the user in the session.
The header used is configurable and defaults to ``REMOTE_USER``. Subclass
this class and change the ``header`` attribute if you need to use a
different header.
"""
# Name of request header to grab username from. This will be the key as
# used in the request.META dictionary, i.e. the normalization of headers to
# all uppercase and the addition of "HTTP_" prefix apply.
header = "REMOTE_USER"
def process_request(self, request):
# AuthenticationMiddleware is required so that request.user exists.
if not hasattr(request, 'user'):
raise ImproperlyConfigured(
"The Django remote user auth middleware requires the"
" authentication middleware to be installed. Edit your"
" MIDDLEWARE_CLASSES setting to insert"
" 'django.contrib.auth.middleware.AuthenticationMiddleware'"
" before the RemoteUserMiddleware class.")
try:
username = request.META[self.header]
except KeyError:
# If specified header doesn't exist then return (leaving
# request.user set to AnonymousUser by the
# AuthenticationMiddleware).
return
# If the user is already authenticated and that user is the user we are
# getting passed in the headers, then the correct user is already
# persisted in the session and we don't need to continue.
if request.user.is_authenticated():
if request.user.username == self.clean_username(username, request):
return
# We are seeing this user for the first time in this session, attempt
# to authenticate the user.
user = auth.authenticate(remote_user=username)
if user:
# User is valid. Set request.user and persist user in the session
# by logging the user in.
request.user = user
auth.login(request, user)
def clean_username(self, username, request):
"""
Allows the backend to clean the username, if the backend defines a
clean_username method.
"""
backend_str = request.session[auth.BACKEND_SESSION_KEY]
backend = auth.load_backend(backend_str)
try:
username = backend.clean_username(username)
except AttributeError: # Backend has no clean_username method.
pass
return username
| ajibawa-2023/Python-Code-Large/train/row_98614 | 34 | 81 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98614:ImportFrom_L1_C0", "label": "from django.contrib import auth", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0123, 0.0123, 0, 0.66, 0.0, 302, 0, 1, 0, 0, 302, 0, 0], "semantic": {"name": "django.contrib", "arg_names": [], "import_names": ["auth"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib import auth"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:ImportFrom_L2_C0", "label": "from django.core.exceptions import ImproperlyConfigured", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0247, 0.0123, 0, 0.66, 0.25, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["ImproperlyConfigured"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import ImproperlyConfigured"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L5_C0", "label": "LazyUser", "type": "class", "loc": [5, 10], "level": 0, "parent": null, "vector": [3, 0, 0.0926, 0.0741, 0, 0.66, 0.5, 55, 0, 1, 0, 0, 186, 0, 2], "semantic": {"name": "LazyUser", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class LazyUser(object):\n def __get__(self, request, obj_type=None):\n if not hasattr(request, '_cached_user'):\n from django.contrib.auth import get_user\n request._cached_user = get_user(request)\n return request._cached_user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L6_C4", "label": "__get__", "type": "function", "loc": [6, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L5_C0", "vector": [2, 1, 0.0988, 0.0617, 1, 0.99, 0.0, 93, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "__get__", "arg_names": ["self", "request", "obj_type"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __get__(self, request, obj_type=None):\n if not hasattr(request, '_cached_user'):\n from django.contrib.auth import get_user\n request._cached_user = get_user(request)\n return request._cached_user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L7_C8", "label": "if", "type": "if", "loc": [7, 9], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L6_C4", "vector": [4, 2, 0.0988, 0.037, 2, 0.92, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(request, '_cached_user'):\n from django.contrib.auth import get_user\n request._cached_user = get_user(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:ImportFrom_L8_C12", "label": "from django.contrib.auth import get_user", "type": "import", "loc": [8, 8], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L7_C8", "vector": [1, 3, 0.0988, 0.0123, 3, 0.86, 0.0, 895, 0, 1, 0, 0, 895, 0, 0], "semantic": {"name": "django.contrib.auth", "arg_names": [], "import_names": ["get_user"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.auth import get_user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L9_C12", "label": "request._cached_user = get_user()", "type": "assigned_variable", "loc": [9, 9], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L7_C8", "vector": [14, 3, 0.1111, 0.0123, 3, 0.86, 1.0, 789, 3, 1, 0, 0, 174, 10, 1], "semantic": {"name": "request._cached_user", "arg_names": [], "import_names": [], "rhs_call_name": "get_user", "annotation": ""}, "snippet": " request._cached_user = get_user(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Return_L10_C8", "label": "return", "type": "return", "loc": [10, 10], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L6_C4", "vector": [13, 2, 0.1235, 0.0123, 2, 0.92, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return request._cached_user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L13_C0", "label": "AuthenticationMiddleware", "type": "class", "loc": [13, 17], "level": 0, "parent": null, "vector": [3, 0, 0.1852, 0.0617, 0, 0.66, 0.75, 799, 0, 1, 0, 0, 186, 0, 2], "semantic": {"name": "AuthenticationMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AuthenticationMiddleware(object):\n def process_request(self, request):\n assert hasattr(request, 'session'), \"The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'.\"\n request.__class__.user = LazyUser()\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L14_C4", "label": "process_request", "type": "function", "loc": [14, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L13_C0", "vector": [2, 1, 0.1914, 0.0494, 1, 0.68, 0.0, 81, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "process_request", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_request(self, request):\n assert hasattr(request, 'session'), \"The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'.\"\n request.__class__.user = LazyUser()\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L16_C8", "label": "request.__class__.user = LazyUser()", "type": "assigned_variable", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L14_C4", "vector": [14, 2, 0.1975, 0.0123, 2, 0.98, 0.0, 512, 3, 0, 0, 0, 55, 10, 1], "semantic": {"name": "request.__class__.user", "arg_names": [], "import_names": [], "rhs_call_name": "LazyUser", "annotation": ""}, "snippet": " request.__class__.user = LazyUser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Return_L17_C8", "label": "return", "type": "return", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L14_C4", "vector": [13, 2, 0.2099, 0.0123, 2, 0.98, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L20_C0", "label": "RemoteUserMiddleware", "type": "class", "loc": [20, 81], "level": 0, "parent": null, "vector": [3, 0, 0.6235, 0.7654, 0, 0.66, 1.0, 376, 0, 2, 0, 0, 186, 0, 8], "semantic": {"name": "RemoteUserMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RemoteUserMiddleware(object):\n \"\"\"\n Middleware for utilizing Web-server-provided authentication.\n\n If request.user is not authenticated, then this middleware attempts to\n authenticate the username passed in the ``REMOTE_USER`` request header.\n If authentication is successful, the user is automatically logged in to\n persist the user in the session."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Expr_L21_C4", "label": "expression", "type": "expression", "loc": [21, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L20_C0", "vector": [8, 1, 0.3272, 0.1481, 1, 0.3, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Middleware for utilizing Web-server-provided authentication.\n\n If request.user is not authenticated, then this middleware attempts to\n authenticate the username passed in the ``REMOTE_USER`` request header.\n If authentication is successful, the user is automatically logged in to\n persist the user in the session.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L37_C4", "label": "header =", "type": "assigned_variable", "loc": [37, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L20_C0", "vector": [14, 1, 0.4568, 0.0123, 1, 0.3, 0.3333, 481, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "header", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " header = \"REMOTE_USER\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L39_C4", "label": "process_request", "type": "function", "loc": [39, 68], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L20_C0", "vector": [2, 1, 0.6605, 0.3704, 1, 0.3, 0.6667, 81, 0, 2, 0, 0, 0, 0, 6], "semantic": {"name": "process_request", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_request(self, request):\n # AuthenticationMiddleware is required so that request.user exists.\n if not hasattr(request, 'user'):\n raise ImproperlyConfigured(\n \"The Django remote user auth middleware requires the\"\n \" authentication middleware to be installed. Edit your\"\n \" MIDDLEWARE_CLASSES setting to insert\"\n \" 'django.contrib.auth.middleware.AuthenticationMiddleware'\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L41_C8", "label": "if", "type": "if", "loc": [41, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L39_C4", "vector": [4, 2, 0.5432, 0.0864, 2, 0.54, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(request, 'user'):\n raise ImproperlyConfigured(\n \"The Django remote user auth middleware requires the\"\n \" authentication middleware to be installed. Edit your\"\n \" MIDDLEWARE_CLASSES setting to insert\"\n \" 'django.contrib.auth.middleware.AuthenticationMiddleware'\"\n \" before the RemoteUserMiddleware class.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Try_L48_C8", "label": "try", "type": "try", "loc": [48, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L39_C4", "vector": [7, 2, 0.6296, 0.0864, 2, 0.54, 0.25, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n username = request.META[self.header]\n except KeyError:\n # If specified header doesn't exist then return (leaving\n # request.user set to AnonymousUser by the\n # AuthenticationMiddleware).\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L49_C12", "label": "username =", "type": "assigned_variable", "loc": [49, 49], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:Try_L48_C8", "vector": [14, 3, 0.6049, 0.0123, 3, 0.71, 0.0, 718, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " username = request.META[self.header]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Return_L54_C12", "label": "return", "type": "return", "loc": [54, 54], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:Try_L48_C8", "vector": [13, 3, 0.6667, 0.0123, 3, 0.71, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L58_C8", "label": "if", "type": "if", "loc": [58, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L39_C4", "vector": [4, 2, 0.7284, 0.037, 2, 0.54, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.user.is_authenticated():\n if request.user.username == self.clean_username(username, request):\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L59_C12", "label": "if", "type": "if", "loc": [59, 60], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L58_C8", "vector": [4, 3, 0.7346, 0.0247, 3, 0.23, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.user.username == self.clean_username(username, request):\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Return_L60_C16", "label": "return", "type": "return", "loc": [60, 60], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L59_C12", "vector": [13, 4, 0.7407, 0.0123, 4, 0.56, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L63_C8", "label": "user = authenticate()", "type": "assigned_variable", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L39_C4", "vector": [14, 2, 0.7778, 0.0123, 2, 0.54, 0.75, 503, 3, 1, 0, 0, 751, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "authenticate", "annotation": ""}, "snippet": " user = auth.authenticate(remote_user=username)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L64_C8", "label": "if", "type": "if", "loc": [64, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L39_C4", "vector": [4, 2, 0.8148, 0.0617, 2, 0.54, 1.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user:\n # User is valid. Set request.user and persist user in the session\n # by logging the user in.\n request.user = user\n auth.login(request, user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L67_C12", "label": "request.user =", "type": "assigned_variable", "loc": [67, 67], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L64_C8", "vector": [14, 3, 0.8272, 0.0123, 3, 0.71, 0.0, 12, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "request.user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " request.user = user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Expr_L68_C12", "label": "login()", "type": "expression", "loc": [68, 68], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L64_C8", "vector": [8, 3, 0.8395, 0.0123, 3, 0.71, 1.0, 724, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " auth.login(request, user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L70_C4", "label": "clean_username", "type": "function", "loc": [70, 81], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L20_C0", "vector": [2, 1, 0.9321, 0.1481, 1, 0.3, 1.0, 629, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "clean_username", "arg_names": ["self", "username", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clean_username(self, username, request):\n \"\"\"\n Allows the backend to clean the username, if the backend defines a\n clean_username method.\n \"\"\"\n backend_str = request.session[auth.BACKEND_SESSION_KEY]\n backend = auth.load_backend(backend_str)\n try:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Expr_L71_C8", "label": "expression", "type": "expression", "loc": [71, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L70_C4", "vector": [8, 2, 0.8951, 0.0494, 2, 0.71, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Allows the backend to clean the username, if the backend defines a\n clean_username method.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L75_C8", "label": "backend_str =", "type": "assigned_variable", "loc": [75, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L70_C4", "vector": [14, 2, 0.9259, 0.0123, 2, 0.71, 0.25, 956, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "backend_str", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " backend_str = request.session[auth.BACKEND_SESSION_KEY]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L76_C8", "label": "backend = load_backend()", "type": "assigned_variable", "loc": [76, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L70_C4", "vector": [14, 2, 0.9383, 0.0123, 2, 0.71, 0.5, 631, 3, 1, 0, 0, 221, 10, 1], "semantic": {"name": "backend", "arg_names": [], "import_names": [], "rhs_call_name": "load_backend", "annotation": ""}, "snippet": " backend = auth.load_backend(backend_str)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Try_L77_C8", "label": "try", "type": "try", "loc": [77, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L70_C4", "vector": [7, 2, 0.9691, 0.0494, 2, 0.71, 0.75, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n username = backend.clean_username(username)\n except AttributeError: # Backend has no clean_username method.\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L78_C12", "label": "username = clean_username()", "type": "assigned_variable", "loc": [78, 78], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:Try_L77_C8", "vector": [14, 3, 0.963, 0.0123, 3, 0.22, 0.0, 718, 3, 1, 0, 0, 629, 10, 1], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "clean_username", "annotation": ""}, "snippet": " username = backend.clean_username(username)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98614:Return_L81_C8", "label": "return", "type": "return", "loc": [81, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L70_C4", "vector": [13, 2, 1.0, 0.0123, 2, 0.71, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return username"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L7_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L7_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:ImportFrom_L8_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L7_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L9_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Return_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Return_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Expr_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Try_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:Try_L48_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L49_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:Try_L48_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Return_L54_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L58_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L59_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L59_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Return_L60_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L64_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L67_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:If_L64_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Expr_L68_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L70_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L70_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Expr_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L70_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L70_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L70_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Try_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:Try_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Assign_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98614:FunctionDef_L70_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98614:Return_L81_C8"}] |
try:
from functools import update_wrapper, wraps
except ImportError:
from django.utils.functional import update_wrapper, wraps # Python 2.4 fallback.
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.http import HttpResponseRedirect
from django.utils.decorators import available_attrs
from django.utils.http import urlquote
def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):
"""
Decorator for views that checks that the user passes the given test,
redirecting to the log-in page if necessary. The test should be a callable
that takes the user object and returns True if the user passes.
"""
if not login_url:
from django.conf import settings
login_url = settings.LOGIN_URL
def decorator(view_func):
def _wrapped_view(request, *args, **kwargs):
if test_func(request.user):
return view_func(request, *args, **kwargs)
path = urlquote(request.get_full_path())
tup = login_url, redirect_field_name, path
return HttpResponseRedirect('%s?%s=%s' % tup)
return wraps(view_func, assigned=available_attrs(view_func))(_wrapped_view)
return decorator
def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None):
"""
Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary.
"""
actual_decorator = user_passes_test(
lambda u: u.is_authenticated(),
login_url=login_url,
redirect_field_name=redirect_field_name
)
if function:
return actual_decorator(function)
return actual_decorator
def permission_required(perm, login_url=None):
"""
Decorator for views that checks whether a user has a particular permission
enabled, redirecting to the log-in page if necessary.
"""
return user_passes_test(lambda u: u.has_perm(perm), login_url=login_url)
| ajibawa-2023/Python-Code-Large/train/row_98615 | 30 | 53 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Try_L1_C0", "label": "try", "type": "try", "loc": [1, 4], "level": 0, "parent": null, "vector": [7, 0, 0.0472, 0.0755, 0, 0.66, 0.0, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "try:\n from functools import update_wrapper, wraps\nexcept ImportError:\n from django.utils.functional import update_wrapper, wraps # Python 2.4 fallback."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:ImportFrom_L2_C4", "label": "from functools import update_wrapper, wraps", "type": "import", "loc": [2, 2], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:Try_L1_C0", "vector": [1, 1, 0.0377, 0.0189, 1, 0.06, 0.0, 711, 0, 2, 0, 0, 711, 0, 0], "semantic": {"name": "functools", "arg_names": [], "import_names": ["update_wrapper", "wraps"], "rhs_call_name": "", "annotation": ""}, "snippet": " from functools import update_wrapper, wraps"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:ImportFrom_L4_C4", "label": "from django.utils.functional import update_wrapper, wraps", "type": "import", "loc": [4, 4], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:Try_L1_C0", "vector": [1, 1, 0.0755, 0.0189, 1, 0.06, 0.0, 375, 0, 2, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.functional", "arg_names": [], "import_names": ["update_wrapper", "wraps"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.utils.functional import update_wrapper, wraps # Python 2.4 fallback."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:ImportFrom_L6_C0", "label": "from django.contrib.auth import REDIRECT_FIELD_NAME", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.1132, 0.0189, 0, 0.66, 0.1429, 895, 0, 1, 0, 0, 895, 0, 0], "semantic": {"name": "django.contrib.auth", "arg_names": [], "import_names": ["REDIRECT_FIELD_NAME"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth import REDIRECT_FIELD_NAME"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:ImportFrom_L7_C0", "label": "from django.http import HttpResponseRedirect", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.1321, 0.0189, 0, 0.66, 0.2857, 779, 0, 1, 0, 0, 779, 0, 0], "semantic": {"name": "django.http", "arg_names": [], "import_names": ["HttpResponseRedirect"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.http import HttpResponseRedirect"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:ImportFrom_L8_C0", "label": "from django.utils.decorators import available_attrs", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.1509, 0.0189, 0, 0.66, 0.4286, 532, 0, 1, 0, 0, 532, 0, 0], "semantic": {"name": "django.utils.decorators", "arg_names": [], "import_names": ["available_attrs"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.decorators import available_attrs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:ImportFrom_L9_C0", "label": "from django.utils.http import urlquote", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.1698, 0.0189, 0, 0.66, 0.5714, 516, 0, 1, 0, 0, 516, 0, 0], "semantic": {"name": "django.utils.http", "arg_names": [], "import_names": ["urlquote"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.http import urlquote"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L12_C0", "label": "user_passes_test", "type": "function", "loc": [12, 30], "level": 0, "parent": null, "vector": [2, 0, 0.3962, 0.3585, 0, 0.66, 0.7143, 983, 0, 3, 1, 0, 0, 0, 8], "semantic": {"name": "user_passes_test", "arg_names": ["test_func", "login_url", "redirect_field_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):\n \"\"\"\n Decorator for views that checks that the user passes the given test,\n redirecting to the log-in page if necessary. The test should be a callable\n that takes the user object and returns True if the user passes.\n \"\"\"\n if not login_url:\n from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Expr_L13_C4", "label": "expression", "type": "expression", "loc": [13, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L12_C0", "vector": [8, 1, 0.283, 0.0943, 1, 0.99, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Decorator for views that checks that the user passes the given test,\n redirecting to the log-in page if necessary. The test should be a callable\n that takes the user object and returns True if the user passes.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L18_C4", "label": "if", "type": "if", "loc": [18, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L12_C0", "vector": [4, 1, 0.3585, 0.0566, 1, 0.99, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not login_url:\n from django.conf import settings\n login_url = settings.LOGIN_URL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:ImportFrom_L19_C8", "label": "from django.conf import settings", "type": "import", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L18_C4", "vector": [1, 2, 0.3585, 0.0189, 2, 0.08, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Assign_L20_C8", "label": "login_url =", "type": "assigned_variable", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L18_C4", "vector": [14, 2, 0.3774, 0.0189, 2, 0.08, 1.0, 704, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "login_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " login_url = settings.LOGIN_URL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L22_C4", "label": "decorator", "type": "function", "loc": [22, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L12_C0", "vector": [2, 1, 0.4811, 0.1509, 1, 0.99, 0.6667, 373, 0, 1, 1, 0, 0, 0, 8], "semantic": {"name": "decorator", "arg_names": ["view_func"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def decorator(view_func):\n def _wrapped_view(request, *args, **kwargs):\n if test_func(request.user):\n return view_func(request, *args, **kwargs)\n path = urlquote(request.get_full_path())\n tup = login_url, redirect_field_name, path\n return HttpResponseRedirect('%s?%s=%s' % tup)\n return wraps(view_func, assigned=available_attrs(view_func))(_wrapped_view)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L23_C8", "label": "_wrapped_view", "type": "function", "loc": [23, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L22_C4", "vector": [2, 2, 0.4811, 0.1132, 2, 0.37, 0.0, 656, 0, 3, 1, 0, 0, 0, 5], "semantic": {"name": "_wrapped_view", "arg_names": ["request", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _wrapped_view(request, *args, **kwargs):\n if test_func(request.user):\n return view_func(request, *args, **kwargs)\n path = urlquote(request.get_full_path())\n tup = login_url, redirect_field_name, path\n return HttpResponseRedirect('%s?%s=%s' % tup)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L24_C12", "label": "if", "type": "if", "loc": [24, 25], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L23_C8", "vector": [4, 3, 0.4623, 0.0377, 3, 0.14, 0.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if test_func(request.user):\n return view_func(request, *args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L25_C16", "label": "return", "type": "return", "loc": [25, 25], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L24_C12", "vector": [13, 4, 0.4717, 0.0189, 4, 0.12, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return view_func(request, *args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Assign_L26_C12", "label": "path = urlquote()", "type": "assigned_variable", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L23_C8", "vector": [14, 3, 0.4906, 0.0189, 3, 0.14, 0.3333, 358, 3, 1, 0, 0, 6, 10, 2], "semantic": {"name": "path", "arg_names": [], "import_names": [], "rhs_call_name": "urlquote", "annotation": ""}, "snippet": " path = urlquote(request.get_full_path())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Assign_L27_C12", "label": "tup =", "type": "assigned_variable", "loc": [27, 27], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L23_C8", "vector": [14, 3, 0.5094, 0.0189, 3, 0.14, 0.6667, 218, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "tup", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tup = login_url, redirect_field_name, path"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L28_C12", "label": "return", "type": "return", "loc": [28, 28], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L23_C8", "vector": [13, 3, 0.5283, 0.0189, 3, 0.14, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect('%s?%s=%s' % tup)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L29_C8", "label": "return", "type": "return", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L22_C4", "vector": [13, 2, 0.5472, 0.0189, 2, 0.37, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return wraps(view_func, assigned=available_attrs(view_func))(_wrapped_view)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L30_C4", "label": "return", "type": "return", "loc": [30, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L12_C0", "vector": [13, 1, 0.566, 0.0189, 1, 0.99, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return decorator"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L33_C0", "label": "login_required", "type": "function", "loc": [33, 45], "level": 0, "parent": null, "vector": [2, 0, 0.7358, 0.2453, 0, 0.66, 0.8571, 779, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "login_required", "arg_names": ["function", "redirect_field_name", "login_url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None):\n \"\"\"\n Decorator for views that checks that the user is logged in, redirecting\n to the log-in page if necessary.\n \"\"\"\n actual_decorator = user_passes_test(\n lambda u: u.is_authenticated(),\n login_url=login_url,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Expr_L34_C4", "label": "expression", "type": "expression", "loc": [34, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L33_C0", "vector": [8, 1, 0.6698, 0.0755, 1, 0.01, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Decorator for views that checks that the user is logged in, redirecting\n to the log-in page if necessary.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Assign_L38_C4", "label": "actual_decorator = user_passes_test()", "type": "assigned_variable", "loc": [38, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L33_C0", "vector": [14, 1, 0.7547, 0.0943, 1, 0.01, 0.3333, 587, 3, 3, 0, 0, 983, 10, 2], "semantic": {"name": "actual_decorator", "arg_names": [], "import_names": [], "rhs_call_name": "user_passes_test", "annotation": ""}, "snippet": " actual_decorator = user_passes_test(\n lambda u: u.is_authenticated(),\n login_url=login_url,\n redirect_field_name=redirect_field_name\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L43_C4", "label": "if", "type": "if", "loc": [43, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L33_C0", "vector": [4, 1, 0.8208, 0.0377, 1, 0.01, 0.6667, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if function:\n return actual_decorator(function)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L44_C8", "label": "return", "type": "return", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L43_C4", "vector": [13, 2, 0.8302, 0.0189, 2, 0.76, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return actual_decorator(function)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L45_C4", "label": "return", "type": "return", "loc": [45, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L33_C0", "vector": [13, 1, 0.8491, 0.0189, 1, 0.01, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return actual_decorator"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L48_C0", "label": "permission_required", "type": "function", "loc": [48, 53], "level": 0, "parent": null, "vector": [2, 0, 0.9528, 0.1132, 0, 0.66, 1.0, 125, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "permission_required", "arg_names": ["perm", "login_url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def permission_required(perm, login_url=None):\n \"\"\"\n Decorator for views that checks whether a user has a particular permission\n enabled, redirecting to the log-in page if necessary.\n \"\"\"\n return user_passes_test(lambda u: u.has_perm(perm), login_url=login_url)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Expr_L49_C4", "label": "expression", "type": "expression", "loc": [49, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L48_C0", "vector": [8, 1, 0.9528, 0.0755, 1, 0.45, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Decorator for views that checks whether a user has a particular permission\n enabled, redirecting to the log-in page if necessary.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L53_C4", "label": "return", "type": "return", "loc": [53, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L48_C0", "vector": [13, 1, 1.0, 0.0189, 1, 0.45, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return user_passes_test(lambda u: u.has_perm(perm), login_url=login_url)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98615:Try_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:ImportFrom_L2_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:Try_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:ImportFrom_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Expr_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:ImportFrom_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Assign_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L24_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L24_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L25_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Assign_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Assign_L27_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Expr_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Assign_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:If_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L48_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Expr_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98615:FunctionDef_L48_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98615:Return_L53_C4"}] |
from django import template
from django.db import transaction
from django.conf import settings
from django.contrib import admin
from django.contrib.auth.forms import UserCreationForm, UserChangeForm, AdminPasswordChangeForm
from django.contrib.auth.models import User, Group
from django.contrib import messages
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.utils.html import escape
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext, ugettext_lazy as _
from django.views.decorators.csrf import csrf_protect
csrf_protect_m = method_decorator(csrf_protect)
class GroupAdmin(admin.ModelAdmin):
search_fields = ('name',)
ordering = ('name',)
filter_horizontal = ('permissions',)
class UserAdmin(admin.ModelAdmin):
add_form_template = 'admin/auth/user/add_form.html'
change_user_password_template = None
fieldsets = (
(None, {'fields': ('username', 'password')}),
(_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
(_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', 'user_permissions')}),
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
(_('Groups'), {'fields': ('groups',)}),
)
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('username', 'password1', 'password2')}
),
)
form = UserChangeForm
add_form = UserCreationForm
change_password_form = AdminPasswordChangeForm
list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff')
list_filter = ('is_staff', 'is_superuser', 'is_active')
search_fields = ('username', 'first_name', 'last_name', 'email')
ordering = ('username',)
filter_horizontal = ('user_permissions',)
def __call__(self, request, url):
# this should not be here, but must be due to the way __call__ routes
# in ModelAdmin.
if url is None:
return self.changelist_view(request)
if url.endswith('password'):
return self.user_change_password(request, url.split('/')[0])
return super(UserAdmin, self).__call__(request, url)
def get_fieldsets(self, request, obj=None):
if not obj:
return self.add_fieldsets
return super(UserAdmin, self).get_fieldsets(request, obj)
def get_form(self, request, obj=None, **kwargs):
"""
Use special form during user creation
"""
defaults = {}
if obj is None:
defaults.update({
'form': self.add_form,
'fields': admin.util.flatten_fieldsets(self.add_fieldsets),
})
defaults.update(kwargs)
return super(UserAdmin, self).get_form(request, obj, **defaults)
def get_urls(self):
from django.conf.urls.defaults import patterns
return patterns('',
(r'^(\d+)/password/$', self.admin_site.admin_view(self.user_change_password))
) + super(UserAdmin, self).get_urls()
@csrf_protect_m
@transaction.commit_on_success
def add_view(self, request, form_url='', extra_context=None):
# It's an error for a user to have add permission but NOT change
# permission for users. If we allowed such users to add users, they
# could create superusers, which would mean they would essentially have
# the permission to change users. To avoid the problem entirely, we
# disallow users from adding users if they don't have change
# permission.
if not self.has_change_permission(request):
if self.has_add_permission(request) and settings.DEBUG:
# Raise Http404 in debug mode so that the user gets a helpful
# error message.
raise Http404('Your user does not have the "Change user" permission. In order to add users, Django requires that your user account have both the "Add user" and "Change user" permissions set.')
raise PermissionDenied
if extra_context is None:
extra_context = {}
defaults = {
'auto_populated_fields': (),
'username_help_text': self.model._meta.get_field('username').help_text,
}
extra_context.update(defaults)
return super(UserAdmin, self).add_view(request, form_url, extra_context)
def user_change_password(self, request, id):
if not self.has_change_permission(request):
raise PermissionDenied
user = get_object_or_404(self.model, pk=id)
if request.method == 'POST':
form = self.change_password_form(user, request.POST)
if form.is_valid():
new_user = form.save()
msg = ugettext('Password changed successfully.')
messages.success(request, msg)
return HttpResponseRedirect('..')
else:
form = self.change_password_form(user)
fieldsets = [(None, {'fields': form.base_fields.keys()})]
adminForm = admin.helpers.AdminForm(form, fieldsets, {})
return render_to_response(self.change_user_password_template or 'admin/auth/user/change_password.html', {
'title': _('Change password: %s') % escape(user.username),
'adminForm': adminForm,
'form': form,
'is_popup': '_popup' in request.REQUEST,
'add': True,
'change': False,
'has_delete_permission': False,
'has_change_permission': True,
'has_absolute_url': False,
'opts': self.model._meta,
'original': user,
'save_as': False,
'show_save': True,
'root_path': self.admin_site.root_path,
}, context_instance=RequestContext(request))
admin.site.register(Group, GroupAdmin)
admin.site.register(User, UserAdmin)
| ajibawa-2023/Python-Code-Large/train/row_98616 | 77 | 143 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L1_C0", "label": "from django import template", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.007, 0.007, 0, 0.66, 0.0, 294, 0, 1, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["template"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django import template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L2_C0", "label": "from django.db import transaction", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.014, 0.007, 0, 0.66, 0.0526, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["transaction"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import transaction"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L3_C0", "label": "from django.conf import settings", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.021, 0.007, 0, 0.66, 0.1053, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L4_C0", "label": "from django.contrib import admin", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.028, 0.007, 0, 0.66, 0.1579, 302, 0, 1, 0, 0, 302, 0, 0], "semantic": {"name": "django.contrib", "arg_names": [], "import_names": ["admin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib import admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L5_C0", "label": "from django.contrib.auth.forms import UserCreationForm, UserChangeForm, AdminPasswordChangeForm", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.035, 0.007, 0, 0.66, 0.2105, 579, 0, 3, 0, 0, 579, 0, 0], "semantic": {"name": "django.contrib.auth.forms", "arg_names": [], "import_names": ["UserCreationForm", "UserChangeForm", "AdminPasswordChangeForm"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.forms import UserCreationForm, UserChangeForm, AdminPasswordChangeForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L6_C0", "label": "from django.contrib.auth.models import User, Group", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.042, 0.007, 0, 0.66, 0.2632, 808, 0, 2, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User", "Group"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User, Group"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L7_C0", "label": "from django.contrib import messages", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.049, 0.007, 0, 0.66, 0.3158, 302, 0, 1, 0, 0, 302, 0, 0], "semantic": {"name": "django.contrib", "arg_names": [], "import_names": ["messages"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib import messages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L8_C0", "label": "from django.core.exceptions import PermissionDenied", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0559, 0.007, 0, 0.66, 0.3684, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["PermissionDenied"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import PermissionDenied"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L9_C0", "label": "from django.http import HttpResponseRedirect, Http404", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0629, 0.007, 0, 0.66, 0.4211, 779, 0, 2, 0, 0, 779, 0, 0], "semantic": {"name": "django.http", "arg_names": [], "import_names": ["HttpResponseRedirect", "Http404"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.http import HttpResponseRedirect, Http404"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L10_C0", "label": "from django.shortcuts import render_to_response, get_object_or_404", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0699, 0.007, 0, 0.66, 0.4737, 852, 0, 2, 0, 0, 852, 0, 0], "semantic": {"name": "django.shortcuts", "arg_names": [], "import_names": ["render_to_response", "get_object_or_404"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.shortcuts import render_to_response, get_object_or_404"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L11_C0", "label": "from django.template import RequestContext", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0769, 0.007, 0, 0.66, 0.5263, 213, 0, 1, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["RequestContext"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import RequestContext"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L12_C0", "label": "from django.utils.html import escape", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0839, 0.007, 0, 0.66, 0.5789, 535, 0, 1, 0, 0, 535, 0, 0], "semantic": {"name": "django.utils.html", "arg_names": [], "import_names": ["escape"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.html import escape"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L13_C0", "label": "from django.utils.decorators import method_decorator", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0909, 0.007, 0, 0.66, 0.6316, 532, 0, 1, 0, 0, 532, 0, 0], "semantic": {"name": "django.utils.decorators", "arg_names": [], "import_names": ["method_decorator"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.decorators import method_decorator"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L14_C0", "label": "from django.utils.translation import ugettext, _", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.0979, 0.007, 0, 0.66, 0.6842, 389, 0, 2, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["ugettext", "_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext, ugettext_lazy as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L15_C0", "label": "from django.views.decorators.csrf import csrf_protect", "type": "import", "loc": [15, 15], "level": 0, "parent": null, "vector": [1, 0, 0.1049, 0.007, 0, 0.66, 0.7368, 456, 0, 1, 0, 0, 456, 0, 0], "semantic": {"name": "django.views.decorators.csrf", "arg_names": [], "import_names": ["csrf_protect"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.views.decorators.csrf import csrf_protect"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L17_C0", "label": "csrf_protect_m = method_decorator()", "type": "assigned_variable", "loc": [17, 17], "level": 0, "parent": null, "vector": [14, 0, 0.1189, 0.007, 0, 0.66, 0.7895, 580, 3, 1, 0, 0, 421, 10, 1], "semantic": {"name": "csrf_protect_m", "arg_names": [], "import_names": [], "rhs_call_name": "method_decorator", "annotation": ""}, "snippet": "csrf_protect_m = method_decorator(csrf_protect)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L19_C0", "label": "GroupAdmin", "type": "class", "loc": [19, 22], "level": 0, "parent": null, "vector": [3, 0, 0.1434, 0.028, 0, 0.66, 0.8421, 995, 0, 0, 0, 0, 823, 0, 0], "semantic": {"name": "GroupAdmin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GroupAdmin(admin.ModelAdmin):\n search_fields = ('name',)\n ordering = ('name',)\n filter_horizontal = ('permissions',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L20_C4", "label": "search_fields =", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L19_C0", "vector": [14, 1, 0.1399, 0.007, 1, 0.12, 0.0, 834, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "search_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " search_fields = ('name',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L21_C4", "label": "ordering =", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L19_C0", "vector": [14, 1, 0.1469, 0.007, 1, 0.12, 0.5, 656, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "ordering", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ordering = ('name',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L22_C4", "label": "filter_horizontal =", "type": "assigned_variable", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L19_C0", "vector": [14, 1, 0.1538, 0.007, 1, 0.12, 1.0, 258, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "filter_horizontal", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " filter_horizontal = ('permissions',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "label": "UserAdmin", "type": "class", "loc": [24, 138], "level": 0, "parent": null, "vector": [3, 0, 0.5664, 0.8042, 0, 0.66, 0.8947, 683, 0, 6, 0, 0, 823, 0, 43], "semantic": {"name": "UserAdmin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class UserAdmin(admin.ModelAdmin):\n add_form_template = 'admin/auth/user/add_form.html'\n change_user_password_template = None\n fieldsets = (\n (None, {'fields': ('username', 'password')}),\n (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),\n (_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', 'user_permissions')}),\n (_('Important dates'), {'fields': ('last_login', 'date_joined')}),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L25_C4", "label": "add_form_template =", "type": "assigned_variable", "loc": [25, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [14, 1, 0.1748, 0.007, 1, 0.06, 0.0, 405, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "add_form_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " add_form_template = 'admin/auth/user/add_form.html'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L26_C4", "label": "change_user_password_template =", "type": "assigned_variable", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [14, 1, 0.1818, 0.007, 1, 0.06, 0.0588, 820, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "change_user_password_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " change_user_password_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L27_C4", "label": "fieldsets =", "type": "assigned_variable", "loc": [27, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [14, 1, 0.2098, 0.049, 1, 0.06, 0.1176, 340, 0, 0, 0, 0, 0, 8, 4], "semantic": {"name": "fieldsets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fieldsets = (\n (None, {'fields': ('username', 'password')}),\n (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),\n (_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', 'user_permissions')}),\n (_('Important dates'), {'fields': ('last_login', 'date_joined')}),\n (_('Groups'), {'fields': ('groups',)}),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L34_C4", "label": "add_fieldsets =", "type": "assigned_variable", "loc": [34, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [14, 1, 0.2552, 0.042, 1, 0.06, 0.1765, 761, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "add_fieldsets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " add_fieldsets = (\n (None, {\n 'classes': ('wide',),\n 'fields': ('username', 'password1', 'password2')}\n ),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L40_C4", "label": "form =", "type": "assigned_variable", "loc": [40, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [14, 1, 0.2797, 0.007, 1, 0.06, 0.2353, 761, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " form = UserChangeForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L41_C4", "label": "add_form =", "type": "assigned_variable", "loc": [41, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [14, 1, 0.2867, 0.007, 1, 0.06, 0.2941, 988, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "add_form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " add_form = UserCreationForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L42_C4", "label": "change_password_form =", "type": "assigned_variable", "loc": [42, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [14, 1, 0.2937, 0.007, 1, 0.06, 0.3529, 113, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "change_password_form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " change_password_form = AdminPasswordChangeForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L43_C4", "label": "list_display =", "type": "assigned_variable", "loc": [43, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [14, 1, 0.3007, 0.007, 1, 0.06, 0.4118, 489, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "list_display", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L44_C4", "label": "list_filter =", "type": "assigned_variable", "loc": [44, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [14, 1, 0.3077, 0.007, 1, 0.06, 0.4706, 851, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "list_filter", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_filter = ('is_staff', 'is_superuser', 'is_active')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L45_C4", "label": "search_fields =", "type": "assigned_variable", "loc": [45, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [14, 1, 0.3147, 0.007, 1, 0.06, 0.5294, 834, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "search_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " search_fields = ('username', 'first_name', 'last_name', 'email')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L46_C4", "label": "ordering =", "type": "assigned_variable", "loc": [46, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [14, 1, 0.3217, 0.007, 1, 0.06, 0.5882, 656, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "ordering", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ordering = ('username',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L47_C4", "label": "filter_horizontal =", "type": "assigned_variable", "loc": [47, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [14, 1, 0.3287, 0.007, 1, 0.06, 0.6471, 258, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "filter_horizontal", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " filter_horizontal = ('user_permissions',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L49_C4", "label": "__call__", "type": "function", "loc": [49, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [2, 1, 0.3671, 0.0559, 1, 0.06, 0.7059, 319, 0, 3, 1, 0, 0, 0, 6], "semantic": {"name": "__call__", "arg_names": ["self", "request", "url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __call__(self, request, url):\n # this should not be here, but must be due to the way __call__ routes\n # in ModelAdmin.\n if url is None:\n return self.changelist_view(request)\n if url.endswith('password'):\n return self.user_change_password(request, url.split('/')[0])\n return super(UserAdmin, self).__call__(request, url)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L52_C8", "label": "if", "type": "if", "loc": [52, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L49_C4", "vector": [4, 2, 0.3671, 0.014, 2, 0.41, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if url is None:\n return self.changelist_view(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L53_C12", "label": "return", "type": "return", "loc": [53, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L52_C8", "vector": [13, 3, 0.3706, 0.007, 3, 0.99, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.changelist_view(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L54_C8", "label": "if", "type": "if", "loc": [54, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L49_C4", "vector": [4, 2, 0.3811, 0.014, 2, 0.41, 0.5, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if url.endswith('password'):\n return self.user_change_password(request, url.split('/')[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L55_C12", "label": "return", "type": "return", "loc": [55, 55], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L54_C8", "vector": [13, 3, 0.3846, 0.007, 3, 0.56, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.user_change_password(request, url.split('/')[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L56_C8", "label": "return", "type": "return", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L49_C4", "vector": [13, 2, 0.3916, 0.007, 2, 0.41, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return super(UserAdmin, self).__call__(request, url)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L58_C4", "label": "get_fieldsets", "type": "function", "loc": [58, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [2, 1, 0.4161, 0.028, 1, 0.06, 0.7647, 273, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "get_fieldsets", "arg_names": ["self", "request", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_fieldsets(self, request, obj=None):\n if not obj:\n return self.add_fieldsets\n return super(UserAdmin, self).get_fieldsets(request, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L59_C8", "label": "if", "type": "if", "loc": [59, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L58_C4", "vector": [4, 2, 0.4161, 0.014, 2, 0.34, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not obj:\n return self.add_fieldsets"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L60_C12", "label": "return", "type": "return", "loc": [60, 60], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L59_C8", "vector": [13, 3, 0.4196, 0.007, 3, 0.61, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.add_fieldsets"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L61_C8", "label": "return", "type": "return", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L58_C4", "vector": [13, 2, 0.4266, 0.007, 2, 0.34, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return super(UserAdmin, self).get_fieldsets(request, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L63_C4", "label": "get_form", "type": "function", "loc": [63, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [2, 1, 0.479, 0.0839, 1, 0.06, 0.8235, 265, 0, 4, 1, 0, 0, 0, 5], "semantic": {"name": "get_form", "arg_names": ["self", "request", "obj", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_form(self, request, obj=None, **kwargs):\n \"\"\"\n Use special form during user creation\n \"\"\"\n defaults = {}\n if obj is None:\n defaults.update({\n 'form': self.add_form,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Expr_L64_C8", "label": "expression", "type": "expression", "loc": [64, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L63_C4", "vector": [8, 2, 0.4545, 0.021, 2, 0.08, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Use special form during user creation\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L67_C8", "label": "defaults =", "type": "assigned_variable", "loc": [67, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L63_C4", "vector": [14, 2, 0.4685, 0.007, 2, 0.08, 0.25, 233, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "defaults", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L68_C8", "label": "if", "type": "if", "loc": [68, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L63_C4", "vector": [4, 2, 0.4895, 0.035, 2, 0.08, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if obj is None:\n defaults.update({\n 'form': self.add_form,\n 'fields': admin.util.flatten_fieldsets(self.add_fieldsets),\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Expr_L69_C12", "label": "update()", "type": "expression", "loc": [69, 72], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L68_C8", "vector": [8, 3, 0.493, 0.028, 3, 0.23, 0.0, 637, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " defaults.update({\n 'form': self.add_form,\n 'fields': admin.util.flatten_fieldsets(self.add_fieldsets),\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Expr_L73_C8", "label": "update()", "type": "expression", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L63_C4", "vector": [8, 2, 0.5105, 0.007, 2, 0.08, 0.75, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " defaults.update(kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L74_C8", "label": "return", "type": "return", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L63_C4", "vector": [13, 2, 0.5175, 0.007, 2, 0.08, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return super(UserAdmin, self).get_form(request, obj, **defaults)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L76_C4", "label": "get_urls", "type": "function", "loc": [76, 80], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [2, 1, 0.5455, 0.035, 1, 0.06, 0.8824, 974, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "get_urls", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_urls(self):\n from django.conf.urls.defaults import patterns\n return patterns('',\n (r'^(\\d+)/password/$', self.admin_site.admin_view(self.user_change_password))\n ) + super(UserAdmin, self).get_urls()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L77_C8", "label": "from django.conf.urls.defaults import patterns", "type": "import", "loc": [77, 77], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L76_C4", "vector": [1, 2, 0.5385, 0.007, 2, 0.74, 0.0, 341, 0, 1, 0, 0, 341, 0, 0], "semantic": {"name": "django.conf.urls.defaults", "arg_names": [], "import_names": ["patterns"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.conf.urls.defaults import patterns"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L78_C8", "label": "return", "type": "return", "loc": [78, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L76_C4", "vector": [13, 2, 0.5524, 0.021, 2, 0.74, 1.0, 0, 4, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return patterns('',\n (r'^(\\d+)/password/$', self.admin_site.admin_view(self.user_change_password))\n ) + super(UserAdmin, self).get_urls()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L84_C4", "label": "add_view", "type": "function", "loc": [84, 104], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [2, 1, 0.6573, 0.1469, 1, 0.06, 0.9412, 840, 0, 4, 1, 0, 0, 0, 7], "semantic": {"name": "add_view", "arg_names": ["self", "request", "form_url", "extra_context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_view(self, request, form_url='', extra_context=None):\n # It's an error for a user to have add permission but NOT change\n # permission for users. If we allowed such users to add users, they\n # could create superusers, which would mean they would essentially have\n # the permission to change users. To avoid the problem entirely, we\n # disallow users from adding users if they don't have change\n # permission.\n if not self.has_change_permission(request):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L91_C8", "label": "if", "type": "if", "loc": [91, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L84_C4", "vector": [4, 2, 0.6538, 0.042, 2, 0.41, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.has_change_permission(request):\n if self.has_add_permission(request) and settings.DEBUG:\n # Raise Http404 in debug mode so that the user gets a helpful\n # error message.\n raise Http404('Your user does not have the \"Change user\" permission. In order to add users, Django requires that your user account have both the \"Add user\" and \"Change user\" permissions set.')\n raise PermissionDenied"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L92_C12", "label": "if", "type": "if", "loc": [92, 95], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L91_C8", "vector": [4, 3, 0.6538, 0.028, 3, 0.38, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.has_add_permission(request) and settings.DEBUG:\n # Raise Http404 in debug mode so that the user gets a helpful\n # error message.\n raise Http404('Your user does not have the \"Change user\" permission. In order to add users, Django requires that your user account have both the \"Add user\" and \"Change user\" permissions set.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L97_C8", "label": "if", "type": "if", "loc": [97, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L84_C4", "vector": [4, 2, 0.6818, 0.014, 2, 0.41, 0.25, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if extra_context is None:\n extra_context = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L98_C12", "label": "extra_context =", "type": "assigned_variable", "loc": [98, 98], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L97_C8", "vector": [14, 3, 0.6853, 0.007, 3, 0.98, 0.0, 751, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "extra_context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " extra_context = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L99_C8", "label": "defaults =", "type": "assigned_variable", "loc": [99, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L84_C4", "vector": [14, 2, 0.7028, 0.028, 2, 0.41, 0.5, 233, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "defaults", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults = {\n 'auto_populated_fields': (),\n 'username_help_text': self.model._meta.get_field('username').help_text,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Expr_L103_C8", "label": "update()", "type": "expression", "loc": [103, 103], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L84_C4", "vector": [8, 2, 0.7203, 0.007, 2, 0.41, 0.75, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " extra_context.update(defaults)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L104_C8", "label": "return", "type": "return", "loc": [104, 104], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L84_C4", "vector": [13, 2, 0.7273, 0.007, 2, 0.41, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return super(UserAdmin, self).add_view(request, form_url, extra_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "label": "user_change_password", "type": "function", "loc": [106, 138], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "vector": [2, 1, 0.8531, 0.2308, 1, 0.06, 1.0, 249, 0, 3, 1, 0, 0, 0, 15], "semantic": {"name": "user_change_password", "arg_names": ["self", "request", "id"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def user_change_password(self, request, id):\n if not self.has_change_permission(request):\n raise PermissionDenied\n user = get_object_or_404(self.model, pk=id)\n if request.method == 'POST':\n form = self.change_password_form(user, request.POST)\n if form.is_valid():\n new_user = form.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L107_C8", "label": "if", "type": "if", "loc": [107, 108], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "vector": [4, 2, 0.7517, 0.014, 2, 0.89, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.has_change_permission(request):\n raise PermissionDenied"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L109_C8", "label": "user = get_object_or_404()", "type": "assigned_variable", "loc": [109, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "vector": [14, 2, 0.7622, 0.007, 2, 0.89, 0.2, 503, 3, 2, 0, 0, 611, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get_object_or_404", "annotation": ""}, "snippet": " user = get_object_or_404(self.model, pk=id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L110_C8", "label": "if", "type": "if", "loc": [110, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "vector": [4, 2, 0.7972, 0.0629, 2, 0.89, 0.4, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.method == 'POST':\n form = self.change_password_form(user, request.POST)\n if form.is_valid():\n new_user = form.save()\n msg = ugettext('Password changed successfully.')\n messages.success(request, msg)\n return HttpResponseRedirect('..')\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L111_C12", "label": "form = change_password_form()", "type": "assigned_variable", "loc": [111, 111], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L110_C8", "vector": [14, 3, 0.7762, 0.007, 3, 0.09, 0.0, 761, 3, 2, 0, 0, 113, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "change_password_form", "annotation": ""}, "snippet": " form = self.change_password_form(user, request.POST)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L112_C12", "label": "if", "type": "if", "loc": [112, 116], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L110_C8", "vector": [4, 3, 0.7972, 0.035, 3, 0.09, 0.5, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.is_valid():\n new_user = form.save()\n msg = ugettext('Password changed successfully.')\n messages.success(request, msg)\n return HttpResponseRedirect('..')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L113_C16", "label": "new_user = save()", "type": "assigned_variable", "loc": [113, 113], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L112_C12", "vector": [14, 4, 0.7902, 0.007, 4, 0.57, 0.0, 932, 3, 0, 0, 0, 928, 10, 1], "semantic": {"name": "new_user", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " new_user = form.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L114_C16", "label": "msg = ugettext()", "type": "assigned_variable", "loc": [114, 114], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L112_C12", "vector": [14, 4, 0.7972, 0.007, 4, 0.57, 0.3333, 712, 3, 1, 0, 0, 461, 10, 1], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "ugettext", "annotation": ""}, "snippet": " msg = ugettext('Password changed successfully.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Expr_L115_C16", "label": "success()", "type": "expression", "loc": [115, 115], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L112_C12", "vector": [8, 4, 0.8042, 0.007, 4, 0.57, 0.6667, 761, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "success", "arg_names": [], "import_names": [], "rhs_call_name": "success", "annotation": ""}, "snippet": " messages.success(request, msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L116_C16", "label": "return", "type": "return", "loc": [116, 116], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L112_C12", "vector": [13, 4, 0.8112, 0.007, 4, 0.57, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect('..')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L118_C12", "label": "form = change_password_form()", "type": "assigned_variable", "loc": [118, 118], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L110_C8", "vector": [14, 3, 0.8252, 0.007, 3, 0.09, 1.0, 761, 3, 1, 0, 0, 113, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "change_password_form", "annotation": ""}, "snippet": " form = self.change_password_form(user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L120_C8", "label": "fieldsets =", "type": "assigned_variable", "loc": [120, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "vector": [14, 2, 0.8392, 0.007, 2, 0.89, 0.6, 340, 0, 0, 0, 0, 0, 5, 1], "semantic": {"name": "fieldsets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fieldsets = [(None, {'fields': form.base_fields.keys()})]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L121_C8", "label": "adminForm = AdminForm()", "type": "assigned_variable", "loc": [121, 121], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "vector": [14, 2, 0.8462, 0.007, 2, 0.89, 0.8, 130, 3, 3, 0, 0, 529, 10, 1], "semantic": {"name": "adminForm", "arg_names": [], "import_names": [], "rhs_call_name": "AdminForm", "annotation": ""}, "snippet": " adminForm = admin.helpers.AdminForm(form, fieldsets, {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L123_C8", "label": "return", "type": "return", "loc": [123, 138], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "vector": [13, 2, 0.9126, 0.1119, 2, 0.89, 1.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(self.change_user_password_template or 'admin/auth/user/change_password.html', {\n 'title': _('Change password: %s') % escape(user.username),\n 'adminForm': adminForm,\n 'form': form,\n 'is_popup': '_popup' in request.REQUEST,\n 'add': True,\n 'change': False,\n 'has_delete_permission': False,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Expr_L141_C0", "label": "register()", "type": "expression", "loc": [141, 141], "level": 0, "parent": null, "vector": [8, 0, 0.986, 0.007, 0, 0.66, 0.9474, 276, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "register", "annotation": ""}, "snippet": "admin.site.register(Group, GroupAdmin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98616:Expr_L142_C0", "label": "register()", "type": "expression", "loc": [142, 142], "level": 0, "parent": null, "vector": [8, 0, 0.993, 0.007, 0, 0.66, 1.0, 276, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "register", "annotation": ""}, "snippet": "admin.site.register(User, UserAdmin)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L52_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L53_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L54_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L55_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L58_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L59_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L60_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Expr_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Expr_L69_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Expr_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L76_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:ImportFrom_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L84_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L84_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L91_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L92_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L84_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L97_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L98_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L84_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L99_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L84_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Expr_L103_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L84_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L104_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L110_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L111_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L110_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L112_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L112_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L113_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L112_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L114_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L112_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Expr_L115_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L112_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L116_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:If_L110_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L118_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L120_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Assign_L121_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98616:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98616:Return_L123_C8"}] |
"""
Management utility to create superusers.
"""
import getpass
import os
import re
import sys
from optparse import make_option
from django.contrib.auth.models import User
from django.core import exceptions
from django.core.management.base import BaseCommand, CommandError
from django.utils.translation import ugettext as _
RE_VALID_USERNAME = re.compile('[\w.@+-]+$')
EMAIL_RE = re.compile(
r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"' # quoted-string
r')@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}$', re.IGNORECASE) # domain
def is_valid_email(value):
if not EMAIL_RE.search(value):
raise exceptions.ValidationError(_('Enter a valid e-mail address.'))
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option('--username', dest='username', default=None,
help='Specifies the username for the superuser.'),
make_option('--email', dest='email', default=None,
help='Specifies the email address for the superuser.'),
make_option('--noinput', action='store_false', dest='interactive', default=True,
help='Tells Django to NOT prompt the user for input of any kind. ' \
'You must use --username and --email with --noinput, and ' \
'superusers created with --noinput will not be able to log in ' \
'until they\'re given a valid password.'),
)
help = 'Used to create a superuser.'
def handle(self, *args, **options):
username = options.get('username', None)
email = options.get('email', None)
interactive = options.get('interactive')
verbosity = int(options.get('verbosity', 1))
# Do quick and dirty validation if --noinput
if not interactive:
if not username or not email:
raise CommandError("You must use --username and --email with --noinput.")
if not RE_VALID_USERNAME.match(username):
raise CommandError("Invalid username. Use only letters, digits, and underscores")
try:
is_valid_email(email)
except exceptions.ValidationError:
raise CommandError("Invalid email address.")
password = ''
# Try to determine the current system user's username to use as a default.
try:
import pwd
default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower()
except (ImportError, KeyError):
# KeyError will be raised by getpwuid() if there is no
# corresponding entry in the /etc/passwd file (a very restricted
# chroot environment, for example).
default_username = ''
# Determine whether the default username is taken, so we don't display
# it as an option.
if default_username:
try:
User.objects.get(username=default_username)
except User.DoesNotExist:
pass
else:
default_username = ''
# Prompt for username/email/password. Enclose this whole thing in a
# try/except to trap for a keyboard interrupt and exit gracefully.
if interactive:
try:
# Get a username
while 1:
if not username:
input_msg = 'Username'
if default_username:
input_msg += ' (Leave blank to use %r)' % default_username
username = raw_input(input_msg + ': ')
if default_username and username == '':
username = default_username
if not RE_VALID_USERNAME.match(username):
sys.stderr.write("Error: That username is invalid. Use only letters, digits and underscores.\n")
username = None
continue
try:
User.objects.get(username=username)
except User.DoesNotExist:
break
else:
sys.stderr.write("Error: That username is already taken.\n")
username = None
# Get an email
while 1:
if not email:
email = raw_input('E-mail address: ')
try:
is_valid_email(email)
except exceptions.ValidationError:
sys.stderr.write("Error: That e-mail address is invalid.\n")
email = None
else:
break
# Get a password
while 1:
if not password:
password = getpass.getpass()
password2 = getpass.getpass('Password (again): ')
if password != password2:
sys.stderr.write("Error: Your passwords didn't match.\n")
password = None
continue
if password.strip() == '':
sys.stderr.write("Error: Blank passwords aren't allowed.\n")
password = None
continue
break
except KeyboardInterrupt:
sys.stderr.write("\nOperation cancelled.\n")
sys.exit(1)
User.objects.create_superuser(username, email, password)
if verbosity >= 1:
self.stdout.write("Superuser created successfully.\n")
| ajibawa-2023/Python-Code-Large/train/row_98617 | 74 | 138 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.0145, 0.0217, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nManagement utility to create superusers.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Import_L5_C0", "label": "getpass import getpass", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0362, 0.0072, 0, 0.66, 0.0769, 784, 0, 1, 0, 0, 784, 0, 0], "semantic": {"name": "getpass", "arg_names": [], "import_names": ["getpass"], "rhs_call_name": "", "annotation": ""}, "snippet": "import getpass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Import_L6_C0", "label": "os import os", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0435, 0.0072, 0, 0.66, 0.1538, 688, 0, 1, 0, 0, 688, 0, 0], "semantic": {"name": "os", "arg_names": [], "import_names": ["os"], "rhs_call_name": "", "annotation": ""}, "snippet": "import os"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Import_L7_C0", "label": "re import re", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0507, 0.0072, 0, 0.66, 0.2308, 540, 0, 1, 0, 0, 540, 0, 0], "semantic": {"name": "re", "arg_names": [], "import_names": ["re"], "rhs_call_name": "", "annotation": ""}, "snippet": "import re"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Import_L8_C0", "label": "sys import sys", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.058, 0.0072, 0, 0.66, 0.3077, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["sys"], "rhs_call_name": "", "annotation": ""}, "snippet": "import sys"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:ImportFrom_L9_C0", "label": "from optparse import make_option", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0652, 0.0072, 0, 0.66, 0.3846, 323, 0, 1, 0, 0, 323, 0, 0], "semantic": {"name": "optparse", "arg_names": [], "import_names": ["make_option"], "rhs_call_name": "", "annotation": ""}, "snippet": "from optparse import make_option"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:ImportFrom_L10_C0", "label": "from django.contrib.auth.models import User", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0725, 0.0072, 0, 0.66, 0.4615, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:ImportFrom_L11_C0", "label": "from django.core import exceptions", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0797, 0.0072, 0, 0.66, 0.5385, 913, 0, 1, 0, 0, 913, 0, 0], "semantic": {"name": "django.core", "arg_names": [], "import_names": ["exceptions"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core import exceptions"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:ImportFrom_L12_C0", "label": "from django.core.management.base import BaseCommand, CommandError", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.087, 0.0072, 0, 0.66, 0.6154, 931, 0, 2, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["BaseCommand", "CommandError"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import BaseCommand, CommandError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:ImportFrom_L13_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0942, 0.0072, 0, 0.66, 0.6923, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L15_C0", "label": "RE_VALID_USERNAME = compile()", "type": "assigned_variable", "loc": [15, 15], "level": 0, "parent": null, "vector": [14, 0, 0.1087, 0.0072, 0, 0.66, 0.7692, 423, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "RE_VALID_USERNAME", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": "RE_VALID_USERNAME = re.compile('[\\w.@+-]+$')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L17_C0", "label": "EMAIL_RE = compile()", "type": "assigned_variable", "loc": [17, 20], "level": 0, "parent": null, "vector": [14, 0, 0.1341, 0.029, 0, 0.66, 0.8462, 481, 3, 2, 0, 0, 821, 10, 1], "semantic": {"name": "EMAIL_RE", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": "EMAIL_RE = re.compile(\n r\"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*\" # dot-atom\n r'|^\"([\\001-\\010\\013\\014\\016-\\037!#-\\[\\]-\\177]|\\\\[\\001-\\011\\013\\014\\016-\\177])*\"' # quoted-string\n r')@(?:[A-Z0-9-]+\\.)+[A-Z]{2,6}$', re.IGNORECASE) # domain"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L22_C0", "label": "is_valid_email", "type": "function", "loc": [22, 24], "level": 0, "parent": null, "vector": [2, 0, 0.1667, 0.0217, 0, 0.66, 0.9231, 433, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "is_valid_email", "arg_names": ["value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def is_valid_email(value):\n if not EMAIL_RE.search(value):\n raise exceptions.ValidationError(_('Enter a valid e-mail address.'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L23_C4", "label": "if", "type": "if", "loc": [23, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L22_C0", "vector": [4, 1, 0.1703, 0.0145, 1, 0.34, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not EMAIL_RE.search(value):\n raise exceptions.ValidationError(_('Enter a valid e-mail address.'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:ClassDef_L26_C0", "label": "Command", "type": "class", "loc": [26, 137], "level": 0, "parent": null, "vector": [3, 0, 0.5906, 0.8116, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 564, 0, 35], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(BaseCommand):\n option_list = BaseCommand.option_list + (\n make_option('--username', dest='username', default=None,\n help='Specifies the username for the superuser.'),\n make_option('--email', dest='email', default=None,\n help='Specifies the email address for the superuser.'),\n make_option('--noinput', action='store_false', dest='interactive', default=True,\n help='Tells Django to NOT prompt the user for input of any kind. ' \\"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L27_C4", "label": "option_list =", "type": "assigned_variable", "loc": [27, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:ClassDef_L26_C0", "vector": [14, 1, 0.2319, 0.0797, 1, 0.05, 0.0, 318, 4, 0, 0, 0, 0, 0, 3], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = BaseCommand.option_list + (\n make_option('--username', dest='username', default=None,\n help='Specifies the username for the superuser.'),\n make_option('--email', dest='email', default=None,\n help='Specifies the email address for the superuser.'),\n make_option('--noinput', action='store_false', dest='interactive', default=True,\n help='Tells Django to NOT prompt the user for input of any kind. ' \\\n 'You must use --username and --email with --noinput, and ' \\"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L38_C4", "label": "help =", "type": "assigned_variable", "loc": [38, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:ClassDef_L26_C0", "vector": [14, 1, 0.2754, 0.0072, 1, 0.05, 0.5, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = 'Used to create a superuser.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "label": "handle", "type": "function", "loc": [40, 137], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:ClassDef_L26_C0", "vector": [2, 1, 0.6413, 0.7101, 1, 0.05, 1.0, 346, 0, 3, 0, 0, 0, 0, 32], "semantic": {"name": "handle", "arg_names": ["self", "args", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle(self, *args, **options):\n username = options.get('username', None)\n email = options.get('email', None)\n interactive = options.get('interactive')\n verbosity = int(options.get('verbosity', 1))\n\n # Do quick and dirty validation if --noinput\n if not interactive:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L41_C8", "label": "username = get()", "type": "assigned_variable", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "vector": [14, 2, 0.2971, 0.0072, 2, 0.71, 0.0, 718, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " username = options.get('username', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L42_C8", "label": "email = get()", "type": "assigned_variable", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "vector": [14, 2, 0.3043, 0.0072, 2, 0.71, 0.1, 413, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "email", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " email = options.get('email', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L43_C8", "label": "interactive = get()", "type": "assigned_variable", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "vector": [14, 2, 0.3116, 0.0072, 2, 0.71, 0.2, 348, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "interactive", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " interactive = options.get('interactive')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L44_C8", "label": "verbosity = int()", "type": "assigned_variable", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "vector": [14, 2, 0.3188, 0.0072, 2, 0.71, 0.3, 582, 3, 1, 0, 0, 901, 10, 2], "semantic": {"name": "verbosity", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " verbosity = int(options.get('verbosity', 1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L47_C8", "label": "if", "type": "if", "loc": [47, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "vector": [4, 2, 0.3696, 0.0652, 2, 0.71, 0.4, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not interactive:\n if not username or not email:\n raise CommandError(\"You must use --username and --email with --noinput.\")\n if not RE_VALID_USERNAME.match(username):\n raise CommandError(\"Invalid username. Use only letters, digits, and underscores\")\n try:\n is_valid_email(email)\n except exceptions.ValidationError:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L48_C12", "label": "if", "type": "if", "loc": [48, 49], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L47_C8", "vector": [4, 3, 0.3514, 0.0145, 3, 0.91, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not username or not email:\n raise CommandError(\"You must use --username and --email with --noinput.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L50_C12", "label": "if", "type": "if", "loc": [50, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L47_C8", "vector": [4, 3, 0.3659, 0.0145, 3, 0.91, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not RE_VALID_USERNAME.match(username):\n raise CommandError(\"Invalid username. Use only letters, digits, and underscores\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L52_C12", "label": "try", "type": "try", "loc": [52, 55], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L47_C8", "vector": [7, 3, 0.3877, 0.029, 3, 0.91, 1.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n is_valid_email(email)\n except exceptions.ValidationError:\n raise CommandError(\"Invalid email address.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L53_C16", "label": "is_valid_email()", "type": "expression", "loc": [53, 53], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L52_C12", "vector": [8, 4, 0.3841, 0.0072, 4, 0.31, 0.0, 433, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "is_valid_email", "arg_names": [], "import_names": [], "rhs_call_name": "is_valid_email", "annotation": ""}, "snippet": " is_valid_email(email)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L57_C8", "label": "password =", "type": "assigned_variable", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "vector": [14, 2, 0.413, 0.0072, 2, 0.71, 0.5, 489, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "password", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " password = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L60_C8", "label": "try", "type": "try", "loc": [60, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "vector": [7, 2, 0.4601, 0.058, 2, 0.71, 0.6, 0, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n import pwd\n default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower()\n except (ImportError, KeyError):\n # KeyError will be raised by getpwuid() if there is no\n # corresponding entry in the /etc/passwd file (a very restricted\n # chroot environment, for example).\n default_username = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Import_L61_C12", "label": "pwd import pwd", "type": "import", "loc": [61, 61], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L60_C8", "vector": [1, 3, 0.442, 0.0072, 3, 0.19, 0.0, 116, 0, 1, 0, 0, 116, 0, 0], "semantic": {"name": "pwd", "arg_names": [], "import_names": ["pwd"], "rhs_call_name": "", "annotation": ""}, "snippet": " import pwd"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L62_C12", "label": "default_username = lower()", "type": "assigned_variable", "loc": [62, 62], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L60_C8", "vector": [14, 3, 0.4493, 0.0072, 3, 0.19, 1.0, 514, 3, 0, 0, 0, 432, 10, 4], "semantic": {"name": "default_username", "arg_names": [], "import_names": [], "rhs_call_name": "lower", "annotation": ""}, "snippet": " default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L67_C12", "label": "default_username =", "type": "assigned_variable", "loc": [67, 67], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L60_C8", "vector": [14, 3, 0.4855, 0.0072, 3, 0.19, 0.0, 514, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "default_username", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " default_username = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L71_C8", "label": "if", "type": "if", "loc": [71, 77], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "vector": [4, 2, 0.5362, 0.0507, 2, 0.71, 0.7, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if default_username:\n try:\n User.objects.get(username=default_username)\n except User.DoesNotExist:\n pass\n else:\n default_username = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L72_C12", "label": "try", "type": "try", "loc": [72, 77], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L71_C8", "vector": [7, 3, 0.5399, 0.0435, 3, 0.36, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n User.objects.get(username=default_username)\n except User.DoesNotExist:\n pass\n else:\n default_username = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L73_C16", "label": "get()", "type": "expression", "loc": [73, 73], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L72_C12", "vector": [8, 4, 0.529, 0.0072, 4, 0.77, 0.0, 607, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "get", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " User.objects.get(username=default_username)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L77_C16", "label": "default_username =", "type": "assigned_variable", "loc": [77, 77], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L72_C12", "vector": [14, 4, 0.558, 0.0072, 4, 0.77, 1.0, 514, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "default_username", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " default_username = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L81_C8", "label": "if", "type": "if", "loc": [81, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "vector": [4, 2, 0.7754, 0.3841, 2, 0.71, 0.8, 0, 2, 0, 0, 0, 0, 0, 15], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if interactive:\n try:\n\n # Get a username\n while 1:\n if not username:\n input_msg = 'Username'\n if default_username:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L82_C12", "label": "try", "type": "try", "loc": [82, 133], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L81_C8", "vector": [7, 3, 0.779, 0.3768, 3, 0.25, 0.0, 0, 0, 1, 0, 0, 0, 0, 15], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n\n # Get a username\n while 1:\n if not username:\n input_msg = 'Username'\n if default_username:\n input_msg += ' (Leave blank to use %r)' % default_username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L85_C16", "label": "while", "type": "while", "loc": [85, 103], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L82_C12", "vector": [5, 4, 0.6812, 0.1377, 4, 0.38, 0.0, 0, 1, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while 1:\n if not username:\n input_msg = 'Username'\n if default_username:\n input_msg += ' (Leave blank to use %r)' % default_username\n username = raw_input(input_msg + ': ')\n if default_username and username == '':\n username = default_username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L86_C20", "label": "if", "type": "if", "loc": [86, 90], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L85_C16", "vector": [4, 5, 0.6377, 0.0362, 5, 0.46, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not username:\n input_msg = 'Username'\n if default_username:\n input_msg += ' (Leave blank to use %r)' % default_username\n username = raw_input(input_msg + ': ')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L87_C24", "label": "input_msg =", "type": "assigned_variable", "loc": [87, 87], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L86_C20", "vector": [14, 6, 0.6304, 0.0072, 6, 0.96, 0.0, 684, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "input_msg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " input_msg = 'Username'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L88_C24", "label": "if", "type": "if", "loc": [88, 89], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L86_C20", "vector": [4, 6, 0.6413, 0.0145, 6, 0.96, 0.5, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if default_username:\n input_msg += ' (Leave blank to use %r)' % default_username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L90_C24", "label": "username = raw_input()", "type": "assigned_variable", "loc": [90, 90], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L86_C20", "vector": [14, 6, 0.6522, 0.0072, 6, 0.96, 1.0, 718, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "raw_input", "annotation": ""}, "snippet": " username = raw_input(input_msg + ': ')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L91_C20", "label": "if", "type": "if", "loc": [91, 92], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L85_C16", "vector": [4, 5, 0.663, 0.0145, 5, 0.46, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if default_username and username == '':\n username = default_username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L92_C24", "label": "username =", "type": "assigned_variable", "loc": [92, 92], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L91_C20", "vector": [14, 6, 0.6667, 0.0072, 6, 0.89, 0.0, 718, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " username = default_username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L93_C20", "label": "if", "type": "if", "loc": [93, 96], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L85_C16", "vector": [4, 5, 0.6848, 0.029, 5, 0.46, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not RE_VALID_USERNAME.match(username):\n sys.stderr.write(\"Error: That username is invalid. Use only letters, digits and underscores.\\n\")\n username = None\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L94_C24", "label": "write()", "type": "expression", "loc": [94, 94], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L93_C20", "vector": [8, 6, 0.6812, 0.0072, 6, 0.06, 0.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stderr.write(\"Error: That username is invalid. Use only letters, digits and underscores.\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L95_C24", "label": "username =", "type": "assigned_variable", "loc": [95, 95], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L93_C20", "vector": [14, 6, 0.6884, 0.0072, 6, 0.06, 1.0, 718, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " username = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L97_C20", "label": "try", "type": "try", "loc": [97, 103], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L85_C16", "vector": [7, 5, 0.7246, 0.0507, 5, 0.46, 1.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n User.objects.get(username=username)\n except User.DoesNotExist:\n break\n else:\n sys.stderr.write(\"Error: That username is already taken.\\n\")\n username = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L98_C24", "label": "get()", "type": "expression", "loc": [98, 98], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L97_C20", "vector": [8, 6, 0.7101, 0.0072, 6, 0.7, 0.0, 607, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "get", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " User.objects.get(username=username)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L102_C24", "label": "write()", "type": "expression", "loc": [102, 102], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L97_C20", "vector": [8, 6, 0.7391, 0.0072, 6, 0.7, 0.5, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stderr.write(\"Error: That username is already taken.\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L103_C24", "label": "username =", "type": "assigned_variable", "loc": [103, 103], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L97_C20", "vector": [14, 6, 0.7464, 0.0072, 6, 0.7, 1.0, 718, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " username = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L106_C16", "label": "while", "type": "while", "loc": [106, 115], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L82_C12", "vector": [5, 4, 0.8007, 0.0725, 4, 0.38, 0.5, 0, 1, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while 1:\n if not email:\n email = raw_input('E-mail address: ')\n try:\n is_valid_email(email)\n except exceptions.ValidationError:\n sys.stderr.write(\"Error: That e-mail address is invalid.\\n\")\n email = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L107_C20", "label": "if", "type": "if", "loc": [107, 108], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L106_C16", "vector": [4, 5, 0.779, 0.0145, 5, 0.8, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not email:\n email = raw_input('E-mail address: ')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L108_C24", "label": "email = raw_input()", "type": "assigned_variable", "loc": [108, 108], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L107_C20", "vector": [14, 6, 0.7826, 0.0072, 6, 0.96, 0.0, 413, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "email", "arg_names": [], "import_names": [], "rhs_call_name": "raw_input", "annotation": ""}, "snippet": " email = raw_input('E-mail address: ')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L109_C20", "label": "try", "type": "try", "loc": [109, 115], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L106_C16", "vector": [7, 5, 0.8116, 0.0507, 5, 0.8, 1.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n is_valid_email(email)\n except exceptions.ValidationError:\n sys.stderr.write(\"Error: That e-mail address is invalid.\\n\")\n email = None\n else:\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L110_C24", "label": "is_valid_email()", "type": "expression", "loc": [110, 110], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L109_C20", "vector": [8, 6, 0.7971, 0.0072, 6, 0.58, 0.0, 433, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "is_valid_email", "arg_names": [], "import_names": [], "rhs_call_name": "is_valid_email", "annotation": ""}, "snippet": " is_valid_email(email)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L112_C24", "label": "write()", "type": "expression", "loc": [112, 112], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L109_C20", "vector": [8, 6, 0.8116, 0.0072, 6, 0.58, 0.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stderr.write(\"Error: That e-mail address is invalid.\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L113_C24", "label": "email =", "type": "assigned_variable", "loc": [113, 113], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L109_C20", "vector": [14, 6, 0.8188, 0.0072, 6, 0.58, 1.0, 413, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "email", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " email = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L118_C16", "label": "while", "type": "while", "loc": [118, 130], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L82_C12", "vector": [5, 4, 0.8986, 0.0942, 4, 0.38, 1.0, 0, 1, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while 1:\n if not password:\n password = getpass.getpass()\n password2 = getpass.getpass('Password (again): ')\n if password != password2:\n sys.stderr.write(\"Error: Your passwords didn't match.\\n\")\n password = None\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L119_C20", "label": "if", "type": "if", "loc": [119, 125], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L118_C16", "vector": [4, 5, 0.8841, 0.0507, 5, 0.8, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not password:\n password = getpass.getpass()\n password2 = getpass.getpass('Password (again): ')\n if password != password2:\n sys.stderr.write(\"Error: Your passwords didn't match.\\n\")\n password = None\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L120_C24", "label": "password = getpass()", "type": "assigned_variable", "loc": [120, 120], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L119_C20", "vector": [14, 6, 0.8696, 0.0072, 6, 0.04, 0.0, 489, 3, 0, 0, 0, 784, 10, 1], "semantic": {"name": "password", "arg_names": [], "import_names": [], "rhs_call_name": "getpass", "annotation": ""}, "snippet": " password = getpass.getpass()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L121_C24", "label": "password2 = getpass()", "type": "assigned_variable", "loc": [121, 121], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L119_C20", "vector": [14, 6, 0.8768, 0.0072, 6, 0.04, 0.5, 314, 3, 1, 0, 0, 784, 10, 1], "semantic": {"name": "password2", "arg_names": [], "import_names": [], "rhs_call_name": "getpass", "annotation": ""}, "snippet": " password2 = getpass.getpass('Password (again): ')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L122_C24", "label": "if", "type": "if", "loc": [122, 125], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L119_C20", "vector": [4, 6, 0.8949, 0.029, 6, 0.04, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if password != password2:\n sys.stderr.write(\"Error: Your passwords didn't match.\\n\")\n password = None\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L123_C28", "label": "write()", "type": "expression", "loc": [123, 123], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L122_C24", "vector": [8, 7, 0.8913, 0.0072, 7, 0.36, 0.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stderr.write(\"Error: Your passwords didn't match.\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L124_C28", "label": "password =", "type": "assigned_variable", "loc": [124, 124], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L122_C24", "vector": [14, 7, 0.8986, 0.0072, 7, 0.36, 1.0, 489, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "password", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " password = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L126_C20", "label": "if", "type": "if", "loc": [126, 129], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L118_C16", "vector": [4, 5, 0.9239, 0.029, 5, 0.8, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if password.strip() == '':\n sys.stderr.write(\"Error: Blank passwords aren't allowed.\\n\")\n password = None\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L127_C24", "label": "write()", "type": "expression", "loc": [127, 127], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L126_C20", "vector": [8, 6, 0.9203, 0.0072, 6, 0.49, 0.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stderr.write(\"Error: Blank passwords aren't allowed.\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L128_C24", "label": "password =", "type": "assigned_variable", "loc": [128, 128], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L126_C20", "vector": [14, 6, 0.9275, 0.0072, 6, 0.49, 1.0, 489, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "password", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " password = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L132_C16", "label": "write()", "type": "expression", "loc": [132, 132], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L82_C12", "vector": [8, 4, 0.9565, 0.0072, 4, 0.38, 0.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stderr.write(\"\\nOperation cancelled.\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L133_C16", "label": "exit()", "type": "expression", "loc": [133, 133], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L82_C12", "vector": [8, 4, 0.9638, 0.0072, 4, 0.38, 1.0, 436, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "exit", "arg_names": [], "import_names": [], "rhs_call_name": "exit", "annotation": ""}, "snippet": " sys.exit(1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L135_C8", "label": "create_superuser()", "type": "expression", "loc": [135, 135], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "vector": [8, 2, 0.9783, 0.0072, 2, 0.71, 0.9, 149, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "create_superuser", "arg_names": [], "import_names": [], "rhs_call_name": "create_superuser", "annotation": ""}, "snippet": " User.objects.create_superuser(username, email, password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L136_C8", "label": "if", "type": "if", "loc": [136, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "vector": [4, 2, 0.9891, 0.0145, 2, 0.71, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if verbosity >= 1:\n self.stdout.write(\"Superuser created successfully.\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L137_C10", "label": "write()", "type": "expression", "loc": [137, 137], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L136_C8", "vector": [8, 3, 0.9928, 0.0072, 3, 0.15, 0.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " self.stdout.write(\"Superuser created successfully.\\n\")"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:ClassDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:ClassDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:ClassDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L47_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L48_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L47_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L47_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L52_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L52_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L53_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L60_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Import_L61_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L60_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L62_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L60_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L67_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L71_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L72_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L72_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L73_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L72_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L77_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L81_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L81_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L82_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L82_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L85_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L85_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L86_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L86_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L87_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L86_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L88_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L86_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L90_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L85_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L91_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L91_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L92_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L85_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L93_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L93_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L94_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L93_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L95_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L85_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L97_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L97_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L98_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L97_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L102_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L97_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L103_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L82_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L106_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L106_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L107_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L107_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L108_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L106_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L109_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L109_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L110_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L109_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L112_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L109_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L113_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L82_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L118_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L118_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L119_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L119_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L120_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L119_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L121_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L119_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L122_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L122_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L123_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L122_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L124_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:While_L118_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L126_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L126_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L127_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L126_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Assign_L128_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L82_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L132_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:Try_L82_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L133_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L135_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98617:If_L136_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98617:Expr_L137_C10"}] |
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User
import getpass
class Command(BaseCommand):
help = "Change a user's password for django.contrib.auth."
requires_model_validation = False
def _get_pass(self, prompt="Password: "):
p = getpass.getpass(prompt=prompt)
if not p:
raise CommandError("aborted")
return p
def handle(self, *args, **options):
if len(args) > 1:
raise CommandError("need exactly one or zero arguments for username")
if args:
username, = args
else:
username = getpass.getuser()
try:
u = User.objects.get(username=username)
except User.DoesNotExist:
raise CommandError("user '%s' does not exist" % username)
print "Changing password for user '%s'" % u.username
MAX_TRIES = 3
count = 0
p1, p2 = 1, 2 # To make them initially mismatch.
while p1 != p2 and count < MAX_TRIES:
p1 = self._get_pass()
p2 = self._get_pass("Password (again): ")
if p1 != p2:
print "Passwords do not match. Please try again."
count = count + 1
if count == MAX_TRIES:
raise CommandError("Aborting password change for user '%s' after %s attempts" % (username, count))
u.set_password(p1)
u.save()
return "Password changed successfully for user '%s'" % u.username
| ajibawa-2023/Python-Code-Large/train/row_98618 | 31 | 48 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98618:ImportFrom_L1_C0", "label": "from django.core.management.base import BaseCommand, CommandError", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0208, 0.0208, 0, 0.66, 0.0, 931, 0, 2, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["BaseCommand", "CommandError"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import BaseCommand, CommandError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:ImportFrom_L2_C0", "label": "from django.contrib.auth.models import User", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0417, 0.0208, 0, 0.66, 0.3333, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Import_L3_C0", "label": "getpass import getpass", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0625, 0.0208, 0, 0.66, 0.6667, 784, 0, 1, 0, 0, 784, 0, 0], "semantic": {"name": "getpass", "arg_names": [], "import_names": ["getpass"], "rhs_call_name": "", "annotation": ""}, "snippet": "import getpass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:ClassDef_L5_C0", "label": "Command", "type": "class", "loc": [5, 48], "level": 0, "parent": null, "vector": [3, 0, 0.5521, 0.9167, 0, 0.66, 1.0, 73, 0, 2, 0, 0, 564, 0, 14], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(BaseCommand):\n help = \"Change a user's password for django.contrib.auth.\"\n\n requires_model_validation = False\n\n def _get_pass(self, prompt=\"Password: \"):\n p = getpass.getpass(prompt=prompt)\n if not p:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L6_C4", "label": "help =", "type": "assigned_variable", "loc": [6, 6], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:ClassDef_L5_C0", "vector": [14, 1, 0.125, 0.0208, 1, 0.82, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Change a user's password for django.contrib.auth.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L8_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:ClassDef_L5_C0", "vector": [14, 1, 0.1667, 0.0208, 1, 0.82, 0.3333, 343, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "requires_model_validation", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " requires_model_validation = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L10_C4", "label": "_get_pass", "type": "function", "loc": [10, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:ClassDef_L5_C0", "vector": [2, 1, 0.25, 0.1042, 1, 0.82, 0.6667, 307, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "_get_pass", "arg_names": ["self", "prompt"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_pass(self, prompt=\"Password: \"):\n p = getpass.getpass(prompt=prompt)\n if not p:\n raise CommandError(\"aborted\")\n return p"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L11_C8", "label": "p = getpass()", "type": "assigned_variable", "loc": [11, 11], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L10_C4", "vector": [14, 2, 0.2292, 0.0208, 2, 0.88, 0.0, 491, 3, 1, 0, 0, 784, 10, 1], "semantic": {"name": "p", "arg_names": [], "import_names": [], "rhs_call_name": "getpass", "annotation": ""}, "snippet": " p = getpass.getpass(prompt=prompt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L12_C8", "label": "if", "type": "if", "loc": [12, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L10_C4", "vector": [4, 2, 0.2604, 0.0417, 2, 0.88, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not p:\n raise CommandError(\"aborted\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Return_L14_C8", "label": "return", "type": "return", "loc": [14, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L10_C4", "vector": [13, 2, 0.2917, 0.0208, 2, 0.88, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return p"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "label": "handle", "type": "function", "loc": [16, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:ClassDef_L5_C0", "vector": [2, 1, 0.6667, 0.6875, 1, 0.82, 1.0, 346, 0, 3, 1, 0, 0, 0, 12], "semantic": {"name": "handle", "arg_names": ["self", "args", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle(self, *args, **options):\n if len(args) > 1:\n raise CommandError(\"need exactly one or zero arguments for username\")\n\n if args:\n username, = args\n else:\n username = getpass.getuser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L17_C8", "label": "if", "type": "if", "loc": [17, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "vector": [4, 2, 0.3646, 0.0417, 2, 0.46, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(args) > 1:\n raise CommandError(\"need exactly one or zero arguments for username\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L20_C8", "label": "if", "type": "if", "loc": [20, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "vector": [4, 2, 0.4479, 0.0833, 2, 0.46, 0.0909, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if args:\n username, = args\n else:\n username = getpass.getuser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L21_C12", "label": "username =", "type": "assigned_variable", "loc": [21, 21], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L20_C8", "vector": [14, 3, 0.4375, 0.0208, 3, 0.4, 0.0, 718, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " username, = args"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L23_C12", "label": "username = getuser()", "type": "assigned_variable", "loc": [23, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L20_C8", "vector": [14, 3, 0.4792, 0.0208, 3, 0.4, 1.0, 718, 3, 0, 0, 0, 610, 10, 1], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "getuser", "annotation": ""}, "snippet": " username = getpass.getuser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Try_L25_C8", "label": "try", "type": "try", "loc": [25, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "vector": [7, 2, 0.5521, 0.0833, 2, 0.46, 0.1818, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n u = User.objects.get(username=username)\n except User.DoesNotExist:\n raise CommandError(\"user '%s' does not exist\" % username)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L26_C12", "label": "u = get()", "type": "assigned_variable", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:Try_L25_C8", "vector": [14, 3, 0.5417, 0.0208, 3, 0.87, 0.0, 609, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "u", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " u = User.objects.get(username=username)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Expr_L30_C8", "label": "print()", "type": "expression", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "vector": [8, 2, 0.625, 0.0208, 2, 0.46, 0.2727, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\"Changing password for user '%s'\" % u.username)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L32_C8", "label": "MAX_TRIES =", "type": "assigned_variable", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "vector": [14, 2, 0.6667, 0.0208, 2, 0.46, 0.3636, 608, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "MAX_TRIES", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " MAX_TRIES = 3"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L33_C8", "label": "count =", "type": "assigned_variable", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "vector": [14, 2, 0.6875, 0.0208, 2, 0.46, 0.4545, 778, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "count", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " count = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L34_C8", "label": "p1, p2 =", "type": "assigned_variable", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "vector": [14, 2, 0.7083, 0.0208, 2, 0.46, 0.5455, 581, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "p1, p2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " p1, p2 = 1, 2 # To make them initially mismatch."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:While_L35_C8", "label": "while", "type": "while", "loc": [35, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "vector": [5, 2, 0.7812, 0.125, 2, 0.46, 0.6364, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while p1 != p2 and count < MAX_TRIES:\n p1 = self._get_pass()\n p2 = self._get_pass(\"Password (again): \")\n if p1 != p2:\n print(\"Passwords do not match. Please try again.\")\n count = count + 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L36_C12", "label": "p1 = _get_pass()", "type": "assigned_variable", "loc": [36, 36], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:While_L35_C8", "vector": [14, 3, 0.75, 0.0208, 3, 0.42, 0.0, 87, 3, 0, 0, 0, 307, 10, 1], "semantic": {"name": "p1", "arg_names": [], "import_names": [], "rhs_call_name": "_get_pass", "annotation": ""}, "snippet": " p1 = self._get_pass()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L37_C12", "label": "p2 = _get_pass()", "type": "assigned_variable", "loc": [37, 37], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:While_L35_C8", "vector": [14, 3, 0.7708, 0.0208, 3, 0.42, 0.5, 843, 3, 1, 0, 0, 307, 10, 1], "semantic": {"name": "p2", "arg_names": [], "import_names": [], "rhs_call_name": "_get_pass", "annotation": ""}, "snippet": " p2 = self._get_pass(\"Password (again): \")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L38_C12", "label": "if", "type": "if", "loc": [38, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:While_L35_C8", "vector": [4, 3, 0.8125, 0.0625, 3, 0.42, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if p1 != p2:\n print(\"Passwords do not match. Please try again.\")\n count = count + 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Expr_L39_C16", "label": "print()", "type": "expression", "loc": [39, 39], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L38_C12", "vector": [8, 4, 0.8125, 0.0208, 4, 0.24, 0.0, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\"Passwords do not match. Please try again.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L40_C16", "label": "count =", "type": "assigned_variable", "loc": [40, 40], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L38_C12", "vector": [14, 4, 0.8333, 0.0208, 4, 0.24, 1.0, 778, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "count", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " count = count + 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L42_C8", "label": "if", "type": "if", "loc": [42, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "vector": [4, 2, 0.8854, 0.0417, 2, 0.46, 0.7273, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if count == MAX_TRIES:\n raise CommandError(\"Aborting password change for user '%s' after %s attempts\" % (username, count))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Expr_L45_C8", "label": "set_password()", "type": "expression", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "vector": [8, 2, 0.9375, 0.0208, 2, 0.46, 0.8182, 803, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "set_password", "arg_names": [], "import_names": [], "rhs_call_name": "set_password", "annotation": ""}, "snippet": " u.set_password(p1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Expr_L46_C8", "label": "save()", "type": "expression", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "vector": [8, 2, 0.9583, 0.0208, 2, 0.46, 0.9091, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " u.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98618:Return_L48_C8", "label": "return", "type": "return", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "vector": [13, 2, 1.0, 0.0208, 2, 0.46, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"Password changed successfully for user '%s'\" % u.username"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98618:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Return_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L20_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L21_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L20_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L23_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Try_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:Try_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Expr_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:While_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:While_L35_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L36_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:While_L35_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:While_L35_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L38_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Expr_L39_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Assign_L40_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:If_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Expr_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Expr_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98618:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98618:Return_L48_C8"}] |
"""
Creates permissions for all installed apps that need permissions.
"""
from django.contrib.auth import models as auth_app
from django.db.models import get_models, signals
def _get_permission_codename(action, opts):
return u'%s_%s' % (action, opts.object_name.lower())
def _get_all_permissions(opts):
"Returns (codename, name) for all permissions in the given opts."
perms = []
for action in ('add', 'change', 'delete'):
perms.append((_get_permission_codename(action, opts), u'Can %s %s' % (action, opts.verbose_name_raw)))
return perms + list(opts.permissions)
def create_permissions(app, created_models, verbosity, **kwargs):
from django.contrib.contenttypes.models import ContentType
app_models = get_models(app)
# This will hold the permissions we're looking for as
# (content_type, (codename, name))
searched_perms = set()
# The codenames and ctypes that should exist.
ctypes = set()
for klass in app_models:
ctype = ContentType.objects.get_for_model(klass)
ctypes.add(ctype)
for perm in _get_all_permissions(klass._meta):
searched_perms.add((ctype, perm))
# Find all the Permissions that have a context_type for a model we're
# looking for. We don't need to check for codenames since we already have
# a list of the ones we're going to create.
all_perms = set()
ctypes_pks = set(ct.pk for ct in ctypes)
for ctype, codename in auth_app.Permission.objects.all().values_list(
'content_type', 'codename')[:1000000]:
if ctype in ctypes_pks:
all_perms.add((ctype, codename))
for ctype, (codename, name) in searched_perms:
# If the permissions exists, move on.
if (ctype.pk, codename) in all_perms:
continue
p = auth_app.Permission.objects.create(
codename=codename,
name=name,
content_type=ctype
)
if verbosity >= 2:
print "Adding permission '%s'" % p
def create_superuser(app, created_models, verbosity, **kwargs):
from django.core.management import call_command
if auth_app.User in created_models and kwargs.get('interactive', True):
msg = ("\nYou just installed Django's auth system, which means you "
"don't have any superusers defined.\nWould you like to create one "
"now? (yes/no): ")
confirm = raw_input(msg)
while 1:
if confirm not in ('yes', 'no'):
confirm = raw_input('Please enter either "yes" or "no": ')
continue
if confirm == 'yes':
call_command("createsuperuser", interactive=True)
break
signals.post_syncdb.connect(create_permissions,
dispatch_uid = "django.contrib.auth.management.create_permissions")
signals.post_syncdb.connect(create_superuser,
sender=auth_app, dispatch_uid = "django.contrib.auth.management.create_superuser")
| ajibawa-2023/Python-Code-Large/train/row_98619 | 43 | 77 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.026, 0.039, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nCreates permissions for all installed apps that need permissions.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:ImportFrom_L5_C0", "label": "from django.contrib.auth import auth_app", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0649, 0.013, 0, 0.66, 0.125, 895, 0, 1, 0, 0, 895, 0, 0], "semantic": {"name": "django.contrib.auth", "arg_names": [], "import_names": ["auth_app"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth import models as auth_app"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:ImportFrom_L6_C0", "label": "from django.db.models import get_models, signals", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0779, 0.013, 0, 0.66, 0.25, 680, 0, 2, 0, 0, 680, 0, 0], "semantic": {"name": "django.db.models", "arg_names": [], "import_names": ["get_models", "signals"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models import get_models, signals"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L9_C0", "label": "_get_permission_codename", "type": "function", "loc": [9, 10], "level": 0, "parent": null, "vector": [2, 0, 0.1234, 0.026, 0, 0.66, 0.375, 341, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "_get_permission_codename", "arg_names": ["action", "opts"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _get_permission_codename(action, opts):\n return u'%s_%s' % (action, opts.object_name.lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Return_L10_C4", "label": "return", "type": "return", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L9_C0", "vector": [13, 1, 0.1299, 0.013, 1, 0.11, 0.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'%s_%s' % (action, opts.object_name.lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L12_C0", "label": "_get_all_permissions", "type": "function", "loc": [12, 17], "level": 0, "parent": null, "vector": [2, 0, 0.1883, 0.0779, 0, 0.66, 0.5, 619, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "_get_all_permissions", "arg_names": ["opts"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _get_all_permissions(opts):\n \"Returns (codename, name) for all permissions in the given opts.\"\n perms = []\n for action in ('add', 'change', 'delete'):\n perms.append((_get_permission_codename(action, opts), u'Can %s %s' % (action, opts.verbose_name_raw)))\n return perms + list(opts.permissions)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L13_C4", "label": "expression", "type": "expression", "loc": [13, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L12_C0", "vector": [8, 1, 0.1688, 0.013, 1, 0.45, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns (codename, name) for all permissions in the given opts.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L14_C4", "label": "perms =", "type": "assigned_variable", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L12_C0", "vector": [14, 1, 0.1818, 0.013, 1, 0.45, 0.3333, 840, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "perms", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " perms = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L15_C4", "label": "for action", "type": "for", "loc": [15, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L12_C0", "vector": [6, 1, 0.2013, 0.026, 1, 0.45, 0.6667, 422, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "action", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for action in ('add', 'change', 'delete'):\n perms.append((_get_permission_codename(action, opts), u'Can %s %s' % (action, opts.verbose_name_raw)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L16_C8", "label": "append()", "type": "expression", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L15_C4", "vector": [8, 2, 0.2078, 0.013, 2, 0.32, 0.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " perms.append((_get_permission_codename(action, opts), u'Can %s %s' % (action, opts.verbose_name_raw)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Return_L17_C4", "label": "return", "type": "return", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L12_C0", "vector": [13, 1, 0.2208, 0.013, 1, 0.45, 1.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return perms + list(opts.permissions)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "label": "create_permissions", "type": "function", "loc": [19, 55], "level": 0, "parent": null, "vector": [2, 0, 0.4805, 0.4805, 0, 0.66, 0.625, 168, 0, 4, 0, 0, 0, 0, 14], "semantic": {"name": "create_permissions", "arg_names": ["app", "created_models", "verbosity", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def create_permissions(app, created_models, verbosity, **kwargs):\n from django.contrib.contenttypes.models import ContentType\n\n app_models = get_models(app)\n\n # This will hold the permissions we're looking for as\n # (content_type, (codename, name))\n searched_perms = set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:ImportFrom_L20_C4", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "vector": [1, 1, 0.2597, 0.013, 1, 0.02, 0.0, 469, 0, 1, 0, 0, 469, 0, 0], "semantic": {"name": "django.contrib.contenttypes.models", "arg_names": [], "import_names": ["ContentType"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.contenttypes.models import ContentType"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L22_C4", "label": "app_models = get_models()", "type": "assigned_variable", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "vector": [14, 1, 0.2857, 0.013, 1, 0.02, 0.125, 621, 3, 1, 0, 0, 404, 10, 1], "semantic": {"name": "app_models", "arg_names": [], "import_names": [], "rhs_call_name": "get_models", "annotation": ""}, "snippet": " app_models = get_models(app)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L26_C4", "label": "searched_perms = set()", "type": "assigned_variable", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "vector": [14, 1, 0.3377, 0.013, 1, 0.02, 0.25, 211, 3, 0, 0, 0, 21, 10, 1], "semantic": {"name": "searched_perms", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " searched_perms = set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L28_C4", "label": "ctypes = set()", "type": "assigned_variable", "loc": [28, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "vector": [14, 1, 0.3636, 0.013, 1, 0.02, 0.375, 182, 3, 0, 0, 0, 21, 10, 1], "semantic": {"name": "ctypes", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " ctypes = set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L29_C4", "label": "for klass", "type": "for", "loc": [29, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "vector": [6, 1, 0.4026, 0.0649, 1, 0.02, 0.5, 35, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "klass", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for klass in app_models:\n ctype = ContentType.objects.get_for_model(klass)\n ctypes.add(ctype)\n for perm in _get_all_permissions(klass._meta):\n searched_perms.add((ctype, perm))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L30_C8", "label": "ctype = get_for_model()", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L29_C4", "vector": [14, 2, 0.3896, 0.013, 2, 0.76, 0.0, 53, 3, 1, 0, 0, 752, 10, 1], "semantic": {"name": "ctype", "arg_names": [], "import_names": [], "rhs_call_name": "get_for_model", "annotation": ""}, "snippet": " ctype = ContentType.objects.get_for_model(klass)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L31_C8", "label": "add()", "type": "expression", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L29_C4", "vector": [8, 2, 0.4026, 0.013, 2, 0.76, 0.5, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " ctypes.add(ctype)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L32_C8", "label": "for perm", "type": "for", "loc": [32, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L29_C4", "vector": [6, 2, 0.4221, 0.026, 2, 0.76, 1.0, 339, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "perm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for perm in _get_all_permissions(klass._meta):\n searched_perms.add((ctype, perm))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L33_C12", "label": "add()", "type": "expression", "loc": [33, 33], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L32_C8", "vector": [8, 3, 0.4286, 0.013, 3, 0.93, 0.0, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " searched_perms.add((ctype, perm))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L38_C4", "label": "all_perms = set()", "type": "assigned_variable", "loc": [38, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "vector": [14, 1, 0.4935, 0.013, 1, 0.02, 0.625, 699, 3, 0, 0, 0, 21, 10, 1], "semantic": {"name": "all_perms", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " all_perms = set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L39_C4", "label": "ctypes_pks = set()", "type": "assigned_variable", "loc": [39, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "vector": [14, 1, 0.5065, 0.013, 1, 0.02, 0.75, 729, 3, 1, 0, 0, 21, 10, 1], "semantic": {"name": "ctypes_pks", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " ctypes_pks = set(ct.pk for ct in ctypes)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L40_C4", "label": "for ctype, codename", "type": "for", "loc": [40, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "vector": [6, 1, 0.539, 0.0519, 1, 0.02, 0.875, 598, 6, 0, 0, 0, 0, 0, 3], "semantic": {"name": "ctype, codename", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for ctype, codename in auth_app.Permission.objects.all().values_list(\n 'content_type', 'codename')[:1000000]:\n if ctype in ctypes_pks:\n all_perms.add((ctype, codename))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L42_C8", "label": "if", "type": "if", "loc": [42, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L40_C4", "vector": [4, 2, 0.5519, 0.026, 2, 0.89, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ctype in ctypes_pks:\n all_perms.add((ctype, codename))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L43_C12", "label": "add()", "type": "expression", "loc": [43, 43], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L42_C8", "vector": [8, 3, 0.5584, 0.013, 3, 0.57, 0.0, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " all_perms.add((ctype, codename))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L45_C4", "label": "for ctype", "type": "for", "loc": [45, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "vector": [6, 1, 0.6494, 0.1429, 1, 0.02, 1.0, 53, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "ctype", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for ctype, (codename, name) in searched_perms:\n # If the permissions exists, move on.\n if (ctype.pk, codename) in all_perms:\n continue\n p = auth_app.Permission.objects.create(\n codename=codename,\n name=name,\n content_type=ctype"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L47_C8", "label": "if", "type": "if", "loc": [47, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L45_C4", "vector": [4, 2, 0.6169, 0.026, 2, 0.71, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if (ctype.pk, codename) in all_perms:\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L49_C8", "label": "p = create()", "type": "assigned_variable", "loc": [49, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L45_C4", "vector": [14, 2, 0.6623, 0.0649, 2, 0.71, 0.5, 491, 3, 3, 0, 0, 316, 10, 1], "semantic": {"name": "p", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " p = auth_app.Permission.objects.create(\n codename=codename,\n name=name,\n content_type=ctype\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L54_C8", "label": "if", "type": "if", "loc": [54, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L45_C4", "vector": [4, 2, 0.7078, 0.026, 2, 0.71, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if verbosity >= 2:\n print(\"Adding permission '%s'\" % p)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L55_C12", "label": "print()", "type": "expression", "loc": [55, 55], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L54_C8", "vector": [8, 3, 0.7143, 0.013, 3, 0.43, 0.0, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\"Adding permission '%s'\" % p)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L58_C0", "label": "create_superuser", "type": "function", "loc": [58, 72], "level": 0, "parent": null, "vector": [2, 0, 0.8442, 0.1948, 0, 0.66, 0.75, 149, 0, 4, 0, 0, 0, 0, 4], "semantic": {"name": "create_superuser", "arg_names": ["app", "created_models", "verbosity", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def create_superuser(app, created_models, verbosity, **kwargs):\n from django.core.management import call_command\n\n if auth_app.User in created_models and kwargs.get('interactive', True):\n msg = (\"\\nYou just installed Django's auth system, which means you \"\n \"don't have any superusers defined.\\nWould you like to create one \"\n \"now? (yes/no): \")\n confirm = raw_input(msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:ImportFrom_L59_C4", "label": "from django.core.management import call_command", "type": "import", "loc": [59, 59], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L58_C0", "vector": [1, 1, 0.7662, 0.013, 1, 0.51, 0.0, 879, 0, 1, 0, 0, 879, 0, 0], "semantic": {"name": "django.core.management", "arg_names": [], "import_names": ["call_command"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.core.management import call_command"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L61_C4", "label": "if", "type": "if", "loc": [61, 72], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L58_C0", "vector": [4, 1, 0.8636, 0.1558, 1, 0.51, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if auth_app.User in created_models and kwargs.get('interactive', True):\n msg = (\"\\nYou just installed Django's auth system, which means you \"\n \"don't have any superusers defined.\\nWould you like to create one \"\n \"now? (yes/no): \")\n confirm = raw_input(msg)\n while 1:\n if confirm not in ('yes', 'no'):\n confirm = raw_input('Please enter either \"yes\" or \"no\": ')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L62_C8", "label": "msg =", "type": "assigned_variable", "loc": [62, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L61_C4", "vector": [14, 2, 0.8182, 0.039, 2, 0.06, 0.0, 712, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " msg = (\"\\nYou just installed Django's auth system, which means you \"\n \"don't have any superusers defined.\\nWould you like to create one \"\n \"now? (yes/no): \")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L65_C8", "label": "confirm = raw_input()", "type": "assigned_variable", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L61_C4", "vector": [14, 2, 0.8442, 0.013, 2, 0.06, 0.5, 488, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "confirm", "arg_names": [], "import_names": [], "rhs_call_name": "raw_input", "annotation": ""}, "snippet": " confirm = raw_input(msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:While_L66_C8", "label": "while", "type": "while", "loc": [66, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L61_C4", "vector": [5, 2, 0.8961, 0.0909, 2, 0.06, 1.0, 0, 1, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while 1:\n if confirm not in ('yes', 'no'):\n confirm = raw_input('Please enter either \"yes\" or \"no\": ')\n continue\n if confirm == 'yes':\n call_command(\"createsuperuser\", interactive=True)\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L67_C12", "label": "if", "type": "if", "loc": [67, 69], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:While_L66_C8", "vector": [4, 3, 0.8831, 0.039, 3, 0.78, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if confirm not in ('yes', 'no'):\n confirm = raw_input('Please enter either \"yes\" or \"no\": ')\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L68_C16", "label": "confirm = raw_input()", "type": "assigned_variable", "loc": [68, 68], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L67_C12", "vector": [14, 4, 0.8831, 0.013, 4, 0.88, 0.0, 488, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "confirm", "arg_names": [], "import_names": [], "rhs_call_name": "raw_input", "annotation": ""}, "snippet": " confirm = raw_input('Please enter either \"yes\" or \"no\": ')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L70_C12", "label": "if", "type": "if", "loc": [70, 71], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:While_L66_C8", "vector": [4, 3, 0.9156, 0.026, 3, 0.78, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if confirm == 'yes':\n call_command(\"createsuperuser\", interactive=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L71_C16", "label": "call_command()", "type": "expression", "loc": [71, 71], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L70_C12", "vector": [8, 4, 0.9221, 0.013, 4, 0.68, 0.0, 587, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "call_command", "arg_names": [], "import_names": [], "rhs_call_name": "call_command", "annotation": ""}, "snippet": " call_command(\"createsuperuser\", interactive=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L74_C0", "label": "connect()", "type": "expression", "loc": [74, 75], "level": 0, "parent": null, "vector": [8, 0, 0.9675, 0.026, 0, 0.66, 0.875, 242, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "connect", "arg_names": [], "import_names": [], "rhs_call_name": "connect", "annotation": ""}, "snippet": "signals.post_syncdb.connect(create_permissions,\n dispatch_uid = \"django.contrib.auth.management.create_permissions\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L76_C0", "label": "connect()", "type": "expression", "loc": [76, 77], "level": 0, "parent": null, "vector": [8, 0, 0.9935, 0.026, 0, 0.66, 1.0, 242, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "connect", "arg_names": [], "import_names": [], "rhs_call_name": "connect", "annotation": ""}, "snippet": "signals.post_syncdb.connect(create_superuser,\n sender=auth_app, dispatch_uid = \"django.contrib.auth.management.create_superuser\")"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Return_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Return_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:ImportFrom_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L32_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L33_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L42_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L43_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:For_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L54_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L55_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L58_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:ImportFrom_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:FunctionDef_L58_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L61_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L61_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L61_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L61_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:While_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:While_L66_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L67_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L67_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Assign_L68_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:While_L66_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L70_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98619:If_L70_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98619:Expr_L71_C16"}] |
from datetime import date
from django.conf import settings
from django.utils.hashcompat import sha_constructor
from django.utils.http import int_to_base36, base36_to_int
from django.utils.crypto import constant_time_compare, salted_hmac
class PasswordResetTokenGenerator(object):
"""
Strategy object used to generate and check tokens for the password
reset mechanism.
"""
def make_token(self, user):
"""
Returns a token that can be used once to do a password reset
for the given user.
"""
return self._make_token_with_timestamp(user, self._num_days(self._today()))
def check_token(self, user, token):
"""
Check that a password reset token is correct for a given user.
"""
# Parse the token
try:
ts_b36, hash = token.split("-")
except ValueError:
return False
try:
ts = base36_to_int(ts_b36)
except ValueError:
return False
# Check that the timestamp/uid has not been tampered with
if not constant_time_compare(self._make_token_with_timestamp(user, ts), token):
# Fallback to Django 1.2 method for compatibility.
# PendingDeprecationWarning <- here to remind us to remove this in
# Django 1.5
if not constant_time_compare(self._make_token_with_timestamp_old(user, ts), token):
return False
# Check the timestamp is within limit
if (self._num_days(self._today()) - ts) > settings.PASSWORD_RESET_TIMEOUT_DAYS:
return False
return True
def _make_token_with_timestamp(self, user, timestamp):
# timestamp is number of days since 2001-1-1. Converted to
# base 36, this gives us a 3 digit string until about 2121
ts_b36 = int_to_base36(timestamp)
# By hashing on the internal state of the user and using state
# that is sure to change (the password salt will change as soon as
# the password is set, at least for current Django auth, and
# last_login will also change), we produce a hash that will be
# invalid as soon as it is used.
# We limit the hash to 20 chars to keep URL short
key_salt = "django.contrib.auth.tokens.PasswordResetTokenGenerator"
value = unicode(user.id) + \
user.password + user.last_login.strftime('%Y-%m-%d %H:%M:%S') + \
unicode(timestamp)
hash = salted_hmac(key_salt, value).hexdigest()[::2]
return "%s-%s" % (ts_b36, hash)
def _make_token_with_timestamp_old(self, user, timestamp):
# The Django 1.2 method
ts_b36 = int_to_base36(timestamp)
hash = sha_constructor(settings.SECRET_KEY + unicode(user.id) +
user.password + user.last_login.strftime('%Y-%m-%d %H:%M:%S') +
unicode(timestamp)).hexdigest()[::2]
return "%s-%s" % (ts_b36, hash)
def _num_days(self, dt):
return (dt - date(2001,1,1)).days
def _today(self):
# Used for mocking in tests
return date.today()
default_token_generator = PasswordResetTokenGenerator()
| ajibawa-2023/Python-Code-Large/train/row_98620 | 39 | 82 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98620:ImportFrom_L1_C0", "label": "from datetime import date", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0122, 0.0122, 0, 0.66, 0.0, 426, 0, 1, 0, 0, 426, 0, 0], "semantic": {"name": "datetime", "arg_names": [], "import_names": ["date"], "rhs_call_name": "", "annotation": ""}, "snippet": "from datetime import date"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:ImportFrom_L3_C0", "label": "from django.conf import settings", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0366, 0.0122, 0, 0.66, 0.1667, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:ImportFrom_L4_C0", "label": "from django.utils.hashcompat import sha_constructor", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0488, 0.0122, 0, 0.66, 0.3333, 474, 0, 1, 0, 0, 474, 0, 0], "semantic": {"name": "django.utils.hashcompat", "arg_names": [], "import_names": ["sha_constructor"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.hashcompat import sha_constructor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:ImportFrom_L5_C0", "label": "from django.utils.http import int_to_base36, base36_to_int", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.061, 0.0122, 0, 0.66, 0.5, 516, 0, 2, 0, 0, 516, 0, 0], "semantic": {"name": "django.utils.http", "arg_names": [], "import_names": ["int_to_base36", "base36_to_int"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.http import int_to_base36, base36_to_int"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:ImportFrom_L6_C0", "label": "from django.utils.crypto import constant_time_compare, salted_hmac", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0732, 0.0122, 0, 0.66, 0.6667, 657, 0, 2, 0, 0, 657, 0, 0], "semantic": {"name": "django.utils.crypto", "arg_names": [], "import_names": ["constant_time_compare", "salted_hmac"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.crypto import constant_time_compare, salted_hmac"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "label": "PasswordResetTokenGenerator", "type": "class", "loc": [8, 80], "level": 0, "parent": null, "vector": [3, 0, 0.5366, 0.8902, 0, 0.66, 0.8333, 474, 0, 6, 0, 0, 186, 0, 25], "semantic": {"name": "PasswordResetTokenGenerator", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PasswordResetTokenGenerator(object):\n \"\"\"\n Strategy object used to generate and check tokens for the password\n reset mechanism.\n \"\"\"\n def make_token(self, user):\n \"\"\"\n Returns a token that can be used once to do a password reset"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Expr_L9_C4", "label": "expression", "type": "expression", "loc": [9, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "vector": [8, 1, 0.128, 0.0488, 1, 0.78, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Strategy object used to generate and check tokens for the password\n reset mechanism.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L13_C4", "label": "make_token", "type": "function", "loc": [13, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "vector": [2, 1, 0.189, 0.0732, 1, 0.78, 0.1667, 485, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "make_token", "arg_names": ["self", "user"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def make_token(self, user):\n \"\"\"\n Returns a token that can be used once to do a password reset\n for the given user.\n \"\"\"\n return self._make_token_with_timestamp(user, self._num_days(self._today()))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Expr_L14_C8", "label": "expression", "type": "expression", "loc": [14, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L13_C4", "vector": [8, 2, 0.189, 0.0488, 2, 0.27, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a token that can be used once to do a password reset\n for the given user.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L18_C8", "label": "return", "type": "return", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L13_C4", "vector": [13, 2, 0.2195, 0.0122, 2, 0.27, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._make_token_with_timestamp(user, self._num_days(self._today()))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "label": "check_token", "type": "function", "loc": [20, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "vector": [2, 1, 0.4085, 0.3415, 1, 0.78, 0.3333, 635, 0, 3, 1, 0, 0, 0, 8], "semantic": {"name": "check_token", "arg_names": ["self", "user", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def check_token(self, user, token):\n \"\"\"\n Check that a password reset token is correct for a given user.\n \"\"\"\n # Parse the token\n try:\n ts_b36, hash = token.split(\"-\")\n except ValueError:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Expr_L21_C8", "label": "expression", "type": "expression", "loc": [21, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "vector": [8, 2, 0.2683, 0.0366, 2, 0.75, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Check that a password reset token is correct for a given user.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Try_L25_C8", "label": "try", "type": "try", "loc": [25, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "vector": [7, 2, 0.3232, 0.0488, 2, 0.75, 0.2, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n ts_b36, hash = token.split(\"-\")\n except ValueError:\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L26_C12", "label": "ts_b36, hash = split()", "type": "assigned_variable", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:Try_L25_C8", "vector": [14, 3, 0.3171, 0.0122, 3, 0.78, 0.0, 941, 3, 1, 0, 0, 908, 10, 1], "semantic": {"name": "ts_b36, hash", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " ts_b36, hash = token.split(\"-\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L28_C12", "label": "return", "type": "return", "loc": [28, 28], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:Try_L25_C8", "vector": [13, 3, 0.3415, 0.0122, 3, 0.78, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Try_L30_C8", "label": "try", "type": "try", "loc": [30, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "vector": [7, 2, 0.3841, 0.0488, 2, 0.75, 0.4, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n ts = base36_to_int(ts_b36)\n except ValueError:\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L31_C12", "label": "ts = base36_to_int()", "type": "assigned_variable", "loc": [31, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:Try_L30_C8", "vector": [14, 3, 0.378, 0.0122, 3, 0.34, 0.0, 278, 3, 1, 0, 0, 582, 10, 1], "semantic": {"name": "ts", "arg_names": [], "import_names": [], "rhs_call_name": "base36_to_int", "annotation": ""}, "snippet": " ts = base36_to_int(ts_b36)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L33_C12", "label": "return", "type": "return", "loc": [33, 33], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:Try_L30_C8", "vector": [13, 3, 0.4024, 0.0122, 3, 0.34, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:If_L36_C8", "label": "if", "type": "if", "loc": [36, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "vector": [4, 2, 0.4695, 0.0732, 2, 0.75, 0.6, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not constant_time_compare(self._make_token_with_timestamp(user, ts), token):\n # Fallback to Django 1.2 method for compatibility.\n # PendingDeprecationWarning <- here to remind us to remove this in\n # Django 1.5\n if not constant_time_compare(self._make_token_with_timestamp_old(user, ts), token):\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:If_L40_C12", "label": "if", "type": "if", "loc": [40, 41], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:If_L36_C8", "vector": [4, 3, 0.4939, 0.0244, 3, 0.51, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not constant_time_compare(self._make_token_with_timestamp_old(user, ts), token):\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L41_C16", "label": "return", "type": "return", "loc": [41, 41], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:If_L40_C12", "vector": [13, 4, 0.5, 0.0122, 4, 0.36, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:If_L44_C8", "label": "if", "type": "if", "loc": [44, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "vector": [4, 2, 0.5427, 0.0244, 2, 0.75, 0.8, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if (self._num_days(self._today()) - ts) > settings.PASSWORD_RESET_TIMEOUT_DAYS:\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L45_C12", "label": "return", "type": "return", "loc": [45, 45], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:If_L44_C8", "vector": [13, 3, 0.5488, 0.0122, 3, 0.16, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L47_C8", "label": "return", "type": "return", "loc": [47, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "vector": [13, 2, 0.5732, 0.0122, 2, 0.75, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L49_C4", "label": "_make_token_with_timestamp", "type": "function", "loc": [49, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "vector": [2, 1, 0.6951, 0.2073, 1, 0.78, 0.5, 817, 0, 3, 1, 0, 0, 0, 6], "semantic": {"name": "_make_token_with_timestamp", "arg_names": ["self", "user", "timestamp"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _make_token_with_timestamp(self, user, timestamp):\n # timestamp is number of days since 2001-1-1. Converted to\n # base 36, this gives us a 3 digit string until about 2121\n ts_b36 = int_to_base36(timestamp)\n\n # By hashing on the internal state of the user and using state\n # that is sure to change (the password salt will change as soon as\n # the password is set, at least for current Django auth, and"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L52_C8", "label": "ts_b36 = int_to_base36()", "type": "assigned_variable", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L49_C4", "vector": [14, 2, 0.6341, 0.0122, 2, 0.86, 0.0, 349, 3, 1, 0, 0, 465, 10, 1], "semantic": {"name": "ts_b36", "arg_names": [], "import_names": [], "rhs_call_name": "int_to_base36", "annotation": ""}, "snippet": " ts_b36 = int_to_base36(timestamp)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L60_C8", "label": "key_salt =", "type": "assigned_variable", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L49_C4", "vector": [14, 2, 0.7317, 0.0122, 2, 0.86, 0.25, 643, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "key_salt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " key_salt = \"django.contrib.auth.tokens.PasswordResetTokenGenerator\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L61_C8", "label": "value =", "type": "assigned_variable", "loc": [61, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L49_C4", "vector": [14, 2, 0.7561, 0.0366, 2, 0.86, 0.5, 441, 4, 0, 0, 0, 0, 0, 3], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " value = unicode(user.id) + \\\n user.password + user.last_login.strftime('%Y-%m-%d %H:%M:%S') + \\\n unicode(timestamp)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L64_C8", "label": "hash =", "type": "assigned_variable", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L49_C4", "vector": [14, 2, 0.7805, 0.0122, 2, 0.86, 0.75, 58, 6, 0, 0, 0, 0, 0, 2], "semantic": {"name": "hash", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " hash = salted_hmac(key_salt, value).hexdigest()[::2]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L65_C8", "label": "return", "type": "return", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L49_C4", "vector": [13, 2, 0.7927, 0.0122, 2, 0.86, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"%s-%s\" % (ts_b36, hash)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L67_C4", "label": "_make_token_with_timestamp_old", "type": "function", "loc": [67, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "vector": [2, 1, 0.8537, 0.0854, 1, 0.78, 0.6667, 663, 0, 3, 1, 0, 0, 0, 6], "semantic": {"name": "_make_token_with_timestamp_old", "arg_names": ["self", "user", "timestamp"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _make_token_with_timestamp_old(self, user, timestamp):\n # The Django 1.2 method\n ts_b36 = int_to_base36(timestamp)\n hash = sha_constructor(settings.SECRET_KEY + unicode(user.id) +\n user.password + user.last_login.strftime('%Y-%m-%d %H:%M:%S') +\n unicode(timestamp)).hexdigest()[::2]\n return \"%s-%s\" % (ts_b36, hash)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L69_C8", "label": "ts_b36 = int_to_base36()", "type": "assigned_variable", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L67_C4", "vector": [14, 2, 0.8415, 0.0122, 2, 0.42, 0.0, 349, 3, 1, 0, 0, 465, 10, 1], "semantic": {"name": "ts_b36", "arg_names": [], "import_names": [], "rhs_call_name": "int_to_base36", "annotation": ""}, "snippet": " ts_b36 = int_to_base36(timestamp)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L70_C8", "label": "hash =", "type": "assigned_variable", "loc": [70, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L67_C4", "vector": [14, 2, 0.8659, 0.0366, 2, 0.42, 0.5, 58, 6, 0, 0, 0, 0, 0, 5], "semantic": {"name": "hash", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " hash = sha_constructor(settings.SECRET_KEY + unicode(user.id) +\n user.password + user.last_login.strftime('%Y-%m-%d %H:%M:%S') +\n unicode(timestamp)).hexdigest()[::2]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L73_C8", "label": "return", "type": "return", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L67_C4", "vector": [13, 2, 0.8902, 0.0122, 2, 0.42, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"%s-%s\" % (ts_b36, hash)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L75_C4", "label": "_num_days", "type": "function", "loc": [75, 76], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "vector": [2, 1, 0.9207, 0.0244, 1, 0.78, 0.8333, 624, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "_num_days", "arg_names": ["self", "dt"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _num_days(self, dt):\n return (dt - date(2001,1,1)).days"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L76_C8", "label": "return", "type": "return", "loc": [76, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L75_C4", "vector": [13, 2, 0.9268, 0.0122, 2, 0.96, 0.0, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return (dt - date(2001,1,1)).days"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L78_C4", "label": "_today", "type": "function", "loc": [78, 80], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "vector": [2, 1, 0.9634, 0.0366, 1, 0.78, 1.0, 779, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "_today", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _today(self):\n # Used for mocking in tests\n return date.today()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L80_C8", "label": "return", "type": "return", "loc": [80, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L78_C4", "vector": [13, 2, 0.9756, 0.0122, 2, 0.22, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return date.today()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L82_C0", "label": "default_token_generator = PasswordResetTokenGenerator()", "type": "assigned_variable", "loc": [82, 82], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0122, 0, 0.66, 1.0, 333, 3, 0, 0, 0, 474, 10, 1], "semantic": {"name": "default_token_generator", "arg_names": [], "import_names": [], "rhs_call_name": "PasswordResetTokenGenerator", "annotation": ""}, "snippet": "default_token_generator = PasswordResetTokenGenerator()"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Expr_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Expr_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Expr_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Try_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:Try_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:Try_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Try_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:Try_L30_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L31_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:Try_L30_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L33_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:If_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:If_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:If_L40_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:If_L40_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L41_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:If_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:If_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L45_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Assign_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L75_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L78_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98620:FunctionDef_L78_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98620:Return_L80_C8"}] |
import re
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
# Avoid shadowing the login() view below.
from django.contrib.auth import login as auth_login
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.forms import PasswordResetForm, SetPasswordForm, PasswordChangeForm
from django.contrib.auth.tokens import default_token_generator
from django.views.decorators.csrf import csrf_protect
from django.core.urlresolvers import reverse
from django.shortcuts import render_to_response, get_object_or_404
from django.contrib.sites.models import get_current_site
from django.http import HttpResponseRedirect, Http404
from django.template import RequestContext
from django.utils.http import urlquote, base36_to_int
from django.utils.translation import ugettext as _
from django.contrib.auth.models import User
from django.views.decorators.cache import never_cache
@csrf_protect
@never_cache
def login(request, template_name='registration/login.html',
redirect_field_name=REDIRECT_FIELD_NAME,
authentication_form=AuthenticationForm):
"""Displays the login form and handles the login action."""
redirect_to = request.REQUEST.get(redirect_field_name, '')
if request.method == "POST":
form = authentication_form(data=request.POST)
if form.is_valid():
# Light security check -- make sure redirect_to isn't garbage.
if not redirect_to or ' ' in redirect_to:
redirect_to = settings.LOGIN_REDIRECT_URL
# Heavier security check -- redirects to http://example.com should
# not be allowed, but things like /view/?param=http://example.com
# should be allowed. This regex checks if there is a '//' *before* a
# question mark.
elif '//' in redirect_to and re.match(r'[^\?]*//', redirect_to):
redirect_to = settings.LOGIN_REDIRECT_URL
# Okay, security checks complete. Log the user in.
auth_login(request, form.get_user())
if request.session.test_cookie_worked():
request.session.delete_test_cookie()
return HttpResponseRedirect(redirect_to)
else:
form = authentication_form(request)
request.session.set_test_cookie()
current_site = get_current_site(request)
return render_to_response(template_name, {
'form': form,
redirect_field_name: redirect_to,
'site': current_site,
'site_name': current_site.name,
}, context_instance=RequestContext(request))
def logout(request, next_page=None, template_name='registration/logged_out.html', redirect_field_name=REDIRECT_FIELD_NAME):
"Logs out the user and displays 'You are logged out' message."
from django.contrib.auth import logout
logout(request)
if next_page is None:
redirect_to = request.REQUEST.get(redirect_field_name, '')
if redirect_to:
return HttpResponseRedirect(redirect_to)
else:
current_site = get_current_site(request)
return render_to_response(template_name, {
'site': current_site,
'site_name': current_site.name,
'title': _('Logged out')
}, context_instance=RequestContext(request))
else:
# Redirect to this page until the session has been cleared.
return HttpResponseRedirect(next_page or request.path)
def logout_then_login(request, login_url=None):
"Logs out the user if he is logged in. Then redirects to the log-in page."
if not login_url:
login_url = settings.LOGIN_URL
return logout(request, login_url)
def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):
"Redirects the user to the login page, passing the given 'next' page"
if not login_url:
login_url = settings.LOGIN_URL
return HttpResponseRedirect('%s?%s=%s' % (login_url, urlquote(redirect_field_name), urlquote(next)))
# 4 views for password reset:
# - password_reset sends the mail
# - password_reset_done shows a success message for the above
# - password_reset_confirm checks the link the user clicked and
# prompts for a new password
# - password_reset_complete shows a success message for the above
@csrf_protect
def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html',
email_template_name='registration/password_reset_email.html',
password_reset_form=PasswordResetForm, token_generator=default_token_generator,
post_reset_redirect=None, from_email=None):
if post_reset_redirect is None:
post_reset_redirect = reverse('django.contrib.auth.views.password_reset_done')
if request.method == "POST":
form = password_reset_form(request.POST)
if form.is_valid():
opts = {}
opts['use_https'] = request.is_secure()
opts['token_generator'] = token_generator
opts['from_email'] = from_email
opts['email_template_name'] = email_template_name
opts['request'] = request
if is_admin_site:
opts['domain_override'] = request.META['HTTP_HOST']
form.save(**opts)
return HttpResponseRedirect(post_reset_redirect)
else:
form = password_reset_form()
return render_to_response(template_name, {
'form': form,
}, context_instance=RequestContext(request))
def password_reset_done(request, template_name='registration/password_reset_done.html'):
return render_to_response(template_name, context_instance=RequestContext(request))
# Doesn't need csrf_protect since no-one can guess the URL
def password_reset_confirm(request, uidb36=None, token=None, template_name='registration/password_reset_confirm.html',
token_generator=default_token_generator, set_password_form=SetPasswordForm,
post_reset_redirect=None):
"""
View that checks the hash in a password reset link and presents a
form for entering a new password.
"""
assert uidb36 is not None and token is not None # checked by URLconf
if post_reset_redirect is None:
post_reset_redirect = reverse('django.contrib.auth.views.password_reset_complete')
try:
uid_int = base36_to_int(uidb36)
user = User.objects.get(id=uid_int)
except (ValueError, User.DoesNotExist):
user = None
context_instance = RequestContext(request)
if user is not None and token_generator.check_token(user, token):
context_instance['validlink'] = True
if request.method == 'POST':
form = set_password_form(user, request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect(post_reset_redirect)
else:
form = set_password_form(None)
else:
context_instance['validlink'] = False
form = None
context_instance['form'] = form
return render_to_response(template_name, context_instance=context_instance)
def password_reset_complete(request, template_name='registration/password_reset_complete.html'):
return render_to_response(template_name, context_instance=RequestContext(request,
{'login_url': settings.LOGIN_URL}))
@csrf_protect
@login_required
def password_change(request, template_name='registration/password_change_form.html',
post_change_redirect=None, password_change_form=PasswordChangeForm):
if post_change_redirect is None:
post_change_redirect = reverse('django.contrib.auth.views.password_change_done')
if request.method == "POST":
form = password_change_form(user=request.user, data=request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect(post_change_redirect)
else:
form = password_change_form(user=request.user)
return render_to_response(template_name, {
'form': form,
}, context_instance=RequestContext(request))
def password_change_done(request, template_name='registration/password_change_done.html'):
return render_to_response(template_name, context_instance=RequestContext(request))
| ajibawa-2023/Python-Code-Large/train/row_98621 | 112 | 189 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Import_L1_C0", "label": "re import re", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0053, 0.0053, 0, 0.66, 0.0, 540, 0, 1, 0, 0, 540, 0, 0], "semantic": {"name": "re", "arg_names": [], "import_names": ["re"], "rhs_call_name": "", "annotation": ""}, "snippet": "import re"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L2_C0", "label": "from django.conf import settings", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0106, 0.0053, 0, 0.66, 0.037, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L3_C0", "label": "from django.contrib.auth import REDIRECT_FIELD_NAME", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0159, 0.0053, 0, 0.66, 0.0741, 895, 0, 1, 0, 0, 895, 0, 0], "semantic": {"name": "django.contrib.auth", "arg_names": [], "import_names": ["REDIRECT_FIELD_NAME"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth import REDIRECT_FIELD_NAME"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L5_C0", "label": "from django.contrib.auth import auth_login", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0265, 0.0053, 0, 0.66, 0.1111, 895, 0, 1, 0, 0, 895, 0, 0], "semantic": {"name": "django.contrib.auth", "arg_names": [], "import_names": ["auth_login"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth import login as auth_login"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L6_C0", "label": "from django.contrib.auth.decorators import login_required", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0317, 0.0053, 0, 0.66, 0.1481, 885, 0, 1, 0, 0, 885, 0, 0], "semantic": {"name": "django.contrib.auth.decorators", "arg_names": [], "import_names": ["login_required"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.decorators import login_required"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L7_C0", "label": "from django.contrib.auth.forms import AuthenticationForm", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.037, 0.0053, 0, 0.66, 0.1852, 579, 0, 1, 0, 0, 579, 0, 0], "semantic": {"name": "django.contrib.auth.forms", "arg_names": [], "import_names": ["AuthenticationForm"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.forms import AuthenticationForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L8_C0", "label": "from django.contrib.auth.forms import PasswordResetForm, SetPasswordForm, PasswordChangeForm", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0423, 0.0053, 0, 0.66, 0.2222, 579, 0, 3, 0, 0, 579, 0, 0], "semantic": {"name": "django.contrib.auth.forms", "arg_names": [], "import_names": ["PasswordResetForm", "SetPasswordForm", "PasswordChangeForm"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.forms import PasswordResetForm, SetPasswordForm, PasswordChangeForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L9_C0", "label": "from django.contrib.auth.tokens import default_token_generator", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0476, 0.0053, 0, 0.66, 0.2593, 366, 0, 1, 0, 0, 366, 0, 0], "semantic": {"name": "django.contrib.auth.tokens", "arg_names": [], "import_names": ["default_token_generator"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.tokens import default_token_generator"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L10_C0", "label": "from django.views.decorators.csrf import csrf_protect", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0529, 0.0053, 0, 0.66, 0.2963, 456, 0, 1, 0, 0, 456, 0, 0], "semantic": {"name": "django.views.decorators.csrf", "arg_names": [], "import_names": ["csrf_protect"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.views.decorators.csrf import csrf_protect"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L11_C0", "label": "from django.core.urlresolvers import reverse", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0582, 0.0053, 0, 0.66, 0.3333, 749, 0, 1, 0, 0, 749, 0, 0], "semantic": {"name": "django.core.urlresolvers", "arg_names": [], "import_names": ["reverse"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.urlresolvers import reverse"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L12_C0", "label": "from django.shortcuts import render_to_response, get_object_or_404", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0635, 0.0053, 0, 0.66, 0.3704, 852, 0, 2, 0, 0, 852, 0, 0], "semantic": {"name": "django.shortcuts", "arg_names": [], "import_names": ["render_to_response", "get_object_or_404"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.shortcuts import render_to_response, get_object_or_404"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L13_C0", "label": "from django.contrib.sites.models import get_current_site", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0688, 0.0053, 0, 0.66, 0.4074, 890, 0, 1, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sites.models", "arg_names": [], "import_names": ["get_current_site"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sites.models import get_current_site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L14_C0", "label": "from django.http import HttpResponseRedirect, Http404", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.0741, 0.0053, 0, 0.66, 0.4444, 779, 0, 2, 0, 0, 779, 0, 0], "semantic": {"name": "django.http", "arg_names": [], "import_names": ["HttpResponseRedirect", "Http404"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.http import HttpResponseRedirect, Http404"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L15_C0", "label": "from django.template import RequestContext", "type": "import", "loc": [15, 15], "level": 0, "parent": null, "vector": [1, 0, 0.0794, 0.0053, 0, 0.66, 0.4815, 213, 0, 1, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["RequestContext"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import RequestContext"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L16_C0", "label": "from django.utils.http import urlquote, base36_to_int", "type": "import", "loc": [16, 16], "level": 0, "parent": null, "vector": [1, 0, 0.0847, 0.0053, 0, 0.66, 0.5185, 516, 0, 2, 0, 0, 516, 0, 0], "semantic": {"name": "django.utils.http", "arg_names": [], "import_names": ["urlquote", "base36_to_int"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.http import urlquote, base36_to_int"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L17_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [17, 17], "level": 0, "parent": null, "vector": [1, 0, 0.0899, 0.0053, 0, 0.66, 0.5556, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L18_C0", "label": "from django.contrib.auth.models import User", "type": "import", "loc": [18, 18], "level": 0, "parent": null, "vector": [1, 0, 0.0952, 0.0053, 0, 0.66, 0.5926, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L19_C0", "label": "from django.views.decorators.cache import never_cache", "type": "import", "loc": [19, 19], "level": 0, "parent": null, "vector": [1, 0, 0.1005, 0.0053, 0, 0.66, 0.6296, 305, 0, 1, 0, 0, 305, 0, 0], "semantic": {"name": "django.views.decorators.cache", "arg_names": [], "import_names": ["never_cache"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.views.decorators.cache import never_cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "label": "login", "type": "function", "loc": [23, 64], "level": 0, "parent": null, "vector": [2, 0, 0.2302, 0.2222, 0, 0.66, 0.6667, 724, 0, 4, 1, 0, 0, 0, 14], "semantic": {"name": "login", "arg_names": ["request", "template_name", "redirect_field_name", "authentication_form"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def login(request, template_name='registration/login.html',\n redirect_field_name=REDIRECT_FIELD_NAME,\n authentication_form=AuthenticationForm):\n \"\"\"Displays the login form and handles the login action.\"\"\"\n\n redirect_to = request.REQUEST.get(redirect_field_name, '')\n\n if request.method == \"POST\":"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L26_C4", "label": "expression", "type": "expression", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "vector": [8, 1, 0.1376, 0.0053, 1, 0.24, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Displays the login form and handles the login action.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L28_C4", "label": "redirect_to = get()", "type": "assigned_variable", "loc": [28, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "vector": [14, 1, 0.1481, 0.0053, 1, 0.24, 0.2, 754, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "redirect_to", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " redirect_to = request.REQUEST.get(redirect_field_name, '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L30_C4", "label": "if", "type": "if", "loc": [30, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "vector": [4, 1, 0.2196, 0.127, 1, 0.24, 0.4, 0, 0, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.method == \"POST\":\n form = authentication_form(data=request.POST)\n if form.is_valid():\n # Light security check -- make sure redirect_to isn't garbage.\n if not redirect_to or ' ' in redirect_to:\n redirect_to = settings.LOGIN_REDIRECT_URL\n\n # Heavier security check -- redirects to http://example.com should"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L31_C8", "label": "form = authentication_form()", "type": "assigned_variable", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L30_C4", "vector": [14, 2, 0.164, 0.0053, 2, 0.29, 0.0, 761, 3, 1, 0, 0, 317, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "authentication_form", "annotation": ""}, "snippet": " form = authentication_form(data=request.POST)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L32_C8", "label": "if", "type": "if", "loc": [32, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L30_C4", "vector": [4, 2, 0.2169, 0.1005, 2, 0.29, 0.5, 0, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.is_valid():\n # Light security check -- make sure redirect_to isn't garbage.\n if not redirect_to or ' ' in redirect_to:\n redirect_to = settings.LOGIN_REDIRECT_URL\n\n # Heavier security check -- redirects to http://example.com should\n # not be allowed, but things like /view/?param=http://example.com\n # should be allowed. This regex checks if there is a '//' *before* a"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L34_C12", "label": "if", "type": "if", "loc": [34, 42], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L32_C8", "vector": [4, 3, 0.2011, 0.0476, 3, 0.22, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not redirect_to or ' ' in redirect_to:\n redirect_to = settings.LOGIN_REDIRECT_URL\n\n # Heavier security check -- redirects to http://example.com should\n # not be allowed, but things like /view/?param=http://example.com\n # should be allowed. This regex checks if there is a '//' *before* a\n # question mark.\n elif '//' in redirect_to and re.match(r'[^\\?]*//', redirect_to):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L35_C16", "label": "redirect_to =", "type": "assigned_variable", "loc": [35, 35], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L34_C12", "vector": [14, 4, 0.1852, 0.0053, 4, 0.2, 0.0, 754, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "redirect_to", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " redirect_to = settings.LOGIN_REDIRECT_URL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L41_C12", "label": "if", "type": "if", "loc": [41, 42], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L34_C12", "vector": [4, 4, 0.2196, 0.0106, 4, 0.2, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif '//' in redirect_to and re.match(r'[^\\?]*//', redirect_to):\n redirect_to = settings.LOGIN_REDIRECT_URL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L42_C20", "label": "redirect_to =", "type": "assigned_variable", "loc": [42, 42], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L41_C12", "vector": [14, 5, 0.2222, 0.0053, 5, 0.08, 0.0, 754, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "redirect_to", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " redirect_to = settings.LOGIN_REDIRECT_URL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L45_C12", "label": "auth_login()", "type": "expression", "loc": [45, 45], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L32_C8", "vector": [8, 3, 0.2381, 0.0053, 3, 0.22, 0.3333, 858, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "auth_login", "arg_names": [], "import_names": [], "rhs_call_name": "auth_login", "annotation": ""}, "snippet": " auth_login(request, form.get_user())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L47_C12", "label": "if", "type": "if", "loc": [47, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L32_C8", "vector": [4, 3, 0.2513, 0.0106, 3, 0.22, 0.6667, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.session.test_cookie_worked():\n request.session.delete_test_cookie()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L48_C16", "label": "delete_test_cookie()", "type": "expression", "loc": [48, 48], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L47_C12", "vector": [8, 4, 0.254, 0.0053, 4, 0.14, 0.0, 358, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete_test_cookie", "arg_names": [], "import_names": [], "rhs_call_name": "delete_test_cookie", "annotation": ""}, "snippet": " request.session.delete_test_cookie()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L50_C12", "label": "return", "type": "return", "loc": [50, 50], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L32_C8", "vector": [13, 3, 0.2646, 0.0053, 3, 0.22, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(redirect_to)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L53_C8", "label": "form = authentication_form()", "type": "assigned_variable", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L30_C4", "vector": [14, 2, 0.2804, 0.0053, 2, 0.29, 1.0, 761, 3, 1, 0, 0, 317, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "authentication_form", "annotation": ""}, "snippet": " form = authentication_form(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L55_C4", "label": "set_test_cookie()", "type": "expression", "loc": [55, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "vector": [8, 1, 0.291, 0.0053, 1, 0.24, 0.6, 915, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "set_test_cookie", "arg_names": [], "import_names": [], "rhs_call_name": "set_test_cookie", "annotation": ""}, "snippet": " request.session.set_test_cookie()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L57_C4", "label": "current_site = get_current_site()", "type": "assigned_variable", "loc": [57, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "vector": [14, 1, 0.3016, 0.0053, 1, 0.24, 0.8, 725, 3, 1, 0, 0, 760, 10, 1], "semantic": {"name": "current_site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current_site", "annotation": ""}, "snippet": " current_site = get_current_site(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L59_C4", "label": "return", "type": "return", "loc": [59, 64], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "vector": [13, 1, 0.3254, 0.0317, 1, 0.24, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(template_name, {\n 'form': form,\n redirect_field_name: redirect_to,\n 'site': current_site,\n 'site_name': current_site.name,\n }, context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L66_C0", "label": "logout", "type": "function", "loc": [66, 83], "level": 0, "parent": null, "vector": [2, 0, 0.3942, 0.0952, 0, 0.66, 0.7037, 525, 0, 4, 1, 0, 0, 0, 8], "semantic": {"name": "logout", "arg_names": ["request", "next_page", "template_name", "redirect_field_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def logout(request, next_page=None, template_name='registration/logged_out.html', redirect_field_name=REDIRECT_FIELD_NAME):\n \"Logs out the user and displays 'You are logged out' message.\"\n from django.contrib.auth import logout\n logout(request)\n if next_page is None:\n redirect_to = request.REQUEST.get(redirect_field_name, '')\n if redirect_to:\n return HttpResponseRedirect(redirect_to)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L67_C4", "label": "expression", "type": "expression", "loc": [67, 67], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L66_C0", "vector": [8, 1, 0.3545, 0.0053, 1, 0.91, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Logs out the user and displays 'You are logged out' message.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L68_C4", "label": "from django.contrib.auth import logout", "type": "import", "loc": [68, 68], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L66_C0", "vector": [1, 1, 0.3598, 0.0053, 1, 0.91, 0.3333, 895, 0, 1, 0, 0, 895, 0, 0], "semantic": {"name": "django.contrib.auth", "arg_names": [], "import_names": ["logout"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.auth import logout"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L69_C4", "label": "logout()", "type": "expression", "loc": [69, 69], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L66_C0", "vector": [8, 1, 0.3651, 0.0053, 1, 0.91, 0.6667, 525, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "logout", "arg_names": [], "import_names": [], "rhs_call_name": "logout", "annotation": ""}, "snippet": " logout(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L70_C4", "label": "if", "type": "if", "loc": [70, 83], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L66_C0", "vector": [4, 1, 0.4048, 0.0741, 1, 0.91, 1.0, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if next_page is None:\n redirect_to = request.REQUEST.get(redirect_field_name, '')\n if redirect_to:\n return HttpResponseRedirect(redirect_to)\n else:\n current_site = get_current_site(request)\n return render_to_response(template_name, {\n 'site': current_site,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L71_C8", "label": "redirect_to = get()", "type": "assigned_variable", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L70_C4", "vector": [14, 2, 0.3757, 0.0053, 2, 0.35, 0.0, 754, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "redirect_to", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " redirect_to = request.REQUEST.get(redirect_field_name, '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L72_C8", "label": "if", "type": "if", "loc": [72, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L70_C4", "vector": [4, 2, 0.4021, 0.0476, 2, 0.35, 0.5, 0, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if redirect_to:\n return HttpResponseRedirect(redirect_to)\n else:\n current_site = get_current_site(request)\n return render_to_response(template_name, {\n 'site': current_site,\n 'site_name': current_site.name,\n 'title': _('Logged out')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L73_C12", "label": "return", "type": "return", "loc": [73, 73], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L72_C8", "vector": [13, 3, 0.3862, 0.0053, 3, 0.24, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(redirect_to)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L75_C12", "label": "current_site = get_current_site()", "type": "assigned_variable", "loc": [75, 75], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L72_C8", "vector": [14, 3, 0.3968, 0.0053, 3, 0.24, 0.5, 725, 3, 1, 0, 0, 760, 10, 1], "semantic": {"name": "current_site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current_site", "annotation": ""}, "snippet": " current_site = get_current_site(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L76_C12", "label": "return", "type": "return", "loc": [76, 80], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L72_C8", "vector": [13, 3, 0.4127, 0.0265, 3, 0.24, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(template_name, {\n 'site': current_site,\n 'site_name': current_site.name,\n 'title': _('Logged out')\n }, context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L83_C8", "label": "return", "type": "return", "loc": [83, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L70_C4", "vector": [13, 2, 0.4392, 0.0053, 2, 0.35, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(next_page or request.path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L85_C0", "label": "logout_then_login", "type": "function", "loc": [85, 89], "level": 0, "parent": null, "vector": [2, 0, 0.4603, 0.0265, 0, 0.66, 0.7407, 307, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "logout_then_login", "arg_names": ["request", "login_url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def logout_then_login(request, login_url=None):\n \"Logs out the user if he is logged in. Then redirects to the log-in page.\"\n if not login_url:\n login_url = settings.LOGIN_URL\n return logout(request, login_url)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L86_C4", "label": "expression", "type": "expression", "loc": [86, 86], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L85_C0", "vector": [8, 1, 0.455, 0.0053, 1, 0.31, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Logs out the user if he is logged in. Then redirects to the log-in page.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L87_C4", "label": "if", "type": "if", "loc": [87, 88], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L85_C0", "vector": [4, 1, 0.463, 0.0106, 1, 0.31, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not login_url:\n login_url = settings.LOGIN_URL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L88_C8", "label": "login_url =", "type": "assigned_variable", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L87_C4", "vector": [14, 2, 0.4656, 0.0053, 2, 0.25, 0.0, 704, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "login_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " login_url = settings.LOGIN_URL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L89_C4", "label": "return", "type": "return", "loc": [89, 89], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L85_C0", "vector": [13, 1, 0.4709, 0.0053, 1, 0.31, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return logout(request, login_url)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L91_C0", "label": "redirect_to_login", "type": "function", "loc": [91, 95], "level": 0, "parent": null, "vector": [2, 0, 0.4921, 0.0265, 0, 0.66, 0.7778, 251, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "redirect_to_login", "arg_names": ["next", "login_url", "redirect_field_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):\n \"Redirects the user to the login page, passing the given 'next' page\"\n if not login_url:\n login_url = settings.LOGIN_URL\n return HttpResponseRedirect('%s?%s=%s' % (login_url, urlquote(redirect_field_name), urlquote(next)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L92_C4", "label": "expression", "type": "expression", "loc": [92, 92], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L91_C0", "vector": [8, 1, 0.4868, 0.0053, 1, 0.12, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Redirects the user to the login page, passing the given 'next' page\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L93_C4", "label": "if", "type": "if", "loc": [93, 94], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L91_C0", "vector": [4, 1, 0.4947, 0.0106, 1, 0.12, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not login_url:\n login_url = settings.LOGIN_URL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L94_C8", "label": "login_url =", "type": "assigned_variable", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L93_C4", "vector": [14, 2, 0.4974, 0.0053, 2, 0.25, 0.0, 704, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "login_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " login_url = settings.LOGIN_URL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L95_C4", "label": "return", "type": "return", "loc": [95, 95], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L91_C0", "vector": [13, 1, 0.5026, 0.0053, 1, 0.12, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect('%s?%s=%s' % (login_url, urlquote(redirect_field_name), urlquote(next)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L105_C0", "label": "password_reset", "type": "function", "loc": [105, 128], "level": 0, "parent": null, "vector": [2, 0, 0.6164, 0.127, 0, 0.66, 0.8148, 708, 0, 8, 1, 0, 0, 0, 9], "semantic": {"name": "password_reset", "arg_names": ["request", "is_admin_site", "template_name", "email_template_name", "password_reset_form", "token_generator", "post_reset_redirect", "from_email"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html',\n email_template_name='registration/password_reset_email.html',\n password_reset_form=PasswordResetForm, token_generator=default_token_generator,\n post_reset_redirect=None, from_email=None):\n if post_reset_redirect is None:\n post_reset_redirect = reverse('django.contrib.auth.views.password_reset_done')\n if request.method == \"POST\":\n form = password_reset_form(request.POST)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L109_C4", "label": "if", "type": "if", "loc": [109, 110], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L105_C0", "vector": [4, 1, 0.5794, 0.0106, 1, 0.65, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if post_reset_redirect is None:\n post_reset_redirect = reverse('django.contrib.auth.views.password_reset_done')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L110_C8", "label": "post_reset_redirect = reverse()", "type": "assigned_variable", "loc": [110, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L109_C4", "vector": [14, 2, 0.582, 0.0053, 2, 0.85, 0.0, 448, 3, 1, 0, 0, 109, 10, 1], "semantic": {"name": "post_reset_redirect", "arg_names": [], "import_names": [], "rhs_call_name": "reverse", "annotation": ""}, "snippet": " post_reset_redirect = reverse('django.contrib.auth.views.password_reset_done')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L111_C4", "label": "if", "type": "if", "loc": [111, 125], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L105_C0", "vector": [4, 1, 0.6243, 0.0794, 1, 0.65, 0.5, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.method == \"POST\":\n form = password_reset_form(request.POST)\n if form.is_valid():\n opts = {}\n opts['use_https'] = request.is_secure()\n opts['token_generator'] = token_generator\n opts['from_email'] = from_email\n opts['email_template_name'] = email_template_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L112_C8", "label": "form = password_reset_form()", "type": "assigned_variable", "loc": [112, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L111_C4", "vector": [14, 2, 0.5926, 0.0053, 2, 0.27, 0.0, 761, 3, 1, 0, 0, 27, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "password_reset_form", "annotation": ""}, "snippet": " form = password_reset_form(request.POST)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "label": "if", "type": "if", "loc": [113, 123], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L111_C4", "vector": [4, 2, 0.6243, 0.0582, 2, 0.27, 0.5, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.is_valid():\n opts = {}\n opts['use_https'] = request.is_secure()\n opts['token_generator'] = token_generator\n opts['from_email'] = from_email\n opts['email_template_name'] = email_template_name\n opts['request'] = request\n if is_admin_site:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L114_C12", "label": "opts =", "type": "assigned_variable", "loc": [114, 114], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "vector": [14, 3, 0.6032, 0.0053, 3, 0.58, 0.0, 631, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L115_C12", "label": " = is_secure()", "type": "assigned_variable", "loc": [115, 115], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "vector": [14, 3, 0.6085, 0.0053, 3, 0.58, 0.125, 0, 3, 0, 0, 0, 797, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "is_secure", "annotation": ""}, "snippet": " opts['use_https'] = request.is_secure()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L116_C12", "label": "assign", "type": "assigned_variable", "loc": [116, 116], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "vector": [14, 3, 0.6138, 0.0053, 3, 0.58, 0.25, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts['token_generator'] = token_generator"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L117_C12", "label": "assign", "type": "assigned_variable", "loc": [117, 117], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "vector": [14, 3, 0.619, 0.0053, 3, 0.58, 0.375, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts['from_email'] = from_email"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L118_C12", "label": "assign", "type": "assigned_variable", "loc": [118, 118], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "vector": [14, 3, 0.6243, 0.0053, 3, 0.58, 0.5, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts['email_template_name'] = email_template_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L119_C12", "label": "assign", "type": "assigned_variable", "loc": [119, 119], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "vector": [14, 3, 0.6296, 0.0053, 3, 0.58, 0.625, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts['request'] = request"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L120_C12", "label": "if", "type": "if", "loc": [120, 121], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "vector": [4, 3, 0.6376, 0.0106, 3, 0.58, 0.75, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if is_admin_site:\n opts['domain_override'] = request.META['HTTP_HOST']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L121_C16", "label": "assign", "type": "assigned_variable", "loc": [121, 121], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L120_C12", "vector": [14, 4, 0.6402, 0.0053, 4, 0.54, 0.0, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts['domain_override'] = request.META['HTTP_HOST']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L122_C12", "label": "save()", "type": "expression", "loc": [122, 122], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "vector": [8, 3, 0.6455, 0.0053, 3, 0.58, 0.875, 928, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " form.save(**opts)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L123_C12", "label": "return", "type": "return", "loc": [123, 123], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "vector": [13, 3, 0.6508, 0.0053, 3, 0.58, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(post_reset_redirect)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L125_C8", "label": "form = password_reset_form()", "type": "assigned_variable", "loc": [125, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L111_C4", "vector": [14, 2, 0.6614, 0.0053, 2, 0.27, 1.0, 761, 3, 0, 0, 0, 27, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "password_reset_form", "annotation": ""}, "snippet": " form = password_reset_form()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L126_C4", "label": "return", "type": "return", "loc": [126, 128], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L105_C0", "vector": [13, 1, 0.672, 0.0159, 1, 0.65, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(template_name, {\n 'form': form,\n }, context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L130_C0", "label": "password_reset_done", "type": "function", "loc": [130, 131], "level": 0, "parent": null, "vector": [2, 0, 0.6905, 0.0106, 0, 0.66, 0.8519, 942, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "password_reset_done", "arg_names": ["request", "template_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def password_reset_done(request, template_name='registration/password_reset_done.html'):\n return render_to_response(template_name, context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L131_C4", "label": "return", "type": "return", "loc": [131, 131], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L130_C0", "vector": [13, 1, 0.6931, 0.0053, 1, 0.54, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(template_name, context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "label": "password_reset_confirm", "type": "function", "loc": [134, 165], "level": 0, "parent": null, "vector": [2, 0, 0.791, 0.1693, 0, 0.66, 0.8889, 657, 0, 7, 1, 0, 0, 0, 11], "semantic": {"name": "password_reset_confirm", "arg_names": ["request", "uidb36", "token", "template_name", "token_generator", "set_password_form", "post_reset_redirect"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def password_reset_confirm(request, uidb36=None, token=None, template_name='registration/password_reset_confirm.html',\n token_generator=default_token_generator, set_password_form=SetPasswordForm,\n post_reset_redirect=None):\n \"\"\"\n View that checks the hash in a password reset link and presents a\n form for entering a new password.\n \"\"\"\n assert uidb36 is not None and token is not None # checked by URLconf"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L137_C4", "label": "expression", "type": "expression", "loc": [137, 140], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "vector": [8, 1, 0.7328, 0.0212, 1, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n View that checks the hash in a password reset link and presents a\n form for entering a new password.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L142_C4", "label": "if", "type": "if", "loc": [142, 143], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "vector": [4, 1, 0.754, 0.0106, 1, 0.66, 0.1667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if post_reset_redirect is None:\n post_reset_redirect = reverse('django.contrib.auth.views.password_reset_complete')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L143_C8", "label": "post_reset_redirect = reverse()", "type": "assigned_variable", "loc": [143, 143], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L142_C4", "vector": [14, 2, 0.7566, 0.0053, 2, 0.89, 0.0, 448, 3, 1, 0, 0, 109, 10, 1], "semantic": {"name": "post_reset_redirect", "arg_names": [], "import_names": [], "rhs_call_name": "reverse", "annotation": ""}, "snippet": " post_reset_redirect = reverse('django.contrib.auth.views.password_reset_complete')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Try_L144_C4", "label": "try", "type": "try", "loc": [144, 148], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "vector": [7, 1, 0.7725, 0.0265, 1, 0.66, 0.3333, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n uid_int = base36_to_int(uidb36)\n user = User.objects.get(id=uid_int)\n except (ValueError, User.DoesNotExist):\n user = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L145_C8", "label": "uid_int = base36_to_int()", "type": "assigned_variable", "loc": [145, 145], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:Try_L144_C4", "vector": [14, 2, 0.7672, 0.0053, 2, 0.25, 0.0, 631, 3, 1, 0, 0, 582, 10, 1], "semantic": {"name": "uid_int", "arg_names": [], "import_names": [], "rhs_call_name": "base36_to_int", "annotation": ""}, "snippet": " uid_int = base36_to_int(uidb36)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L146_C8", "label": "user = get()", "type": "assigned_variable", "loc": [146, 146], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:Try_L144_C4", "vector": [14, 2, 0.7725, 0.0053, 2, 0.25, 1.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(id=uid_int)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L148_C8", "label": "user =", "type": "assigned_variable", "loc": [148, 148], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:Try_L144_C4", "vector": [14, 2, 0.7831, 0.0053, 2, 0.25, 0.0, 503, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L150_C4", "label": "context_instance = RequestContext()", "type": "assigned_variable", "loc": [150, 150], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "vector": [14, 1, 0.7937, 0.0053, 1, 0.66, 0.5, 723, 3, 1, 0, 0, 47, 10, 1], "semantic": {"name": "context_instance", "arg_names": [], "import_names": [], "rhs_call_name": "RequestContext", "annotation": ""}, "snippet": " context_instance = RequestContext(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L152_C4", "label": "if", "type": "if", "loc": [152, 163], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "vector": [4, 1, 0.8333, 0.0635, 1, 0.66, 0.6667, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user is not None and token_generator.check_token(user, token):\n context_instance['validlink'] = True\n if request.method == 'POST':\n form = set_password_form(user, request.POST)\n if form.is_valid():\n form.save()\n return HttpResponseRedirect(post_reset_redirect)\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L153_C8", "label": "assign", "type": "assigned_variable", "loc": [153, 153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L152_C4", "vector": [14, 2, 0.8095, 0.0053, 2, 0.89, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context_instance['validlink'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L154_C8", "label": "if", "type": "if", "loc": [154, 160], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L152_C4", "vector": [4, 2, 0.8307, 0.037, 2, 0.89, 0.3333, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.method == 'POST':\n form = set_password_form(user, request.POST)\n if form.is_valid():\n form.save()\n return HttpResponseRedirect(post_reset_redirect)\n else:\n form = set_password_form(None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L155_C12", "label": "form = set_password_form()", "type": "assigned_variable", "loc": [155, 155], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L154_C8", "vector": [14, 3, 0.8201, 0.0053, 3, 0.66, 0.0, 761, 3, 2, 0, 0, 888, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "set_password_form", "annotation": ""}, "snippet": " form = set_password_form(user, request.POST)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L156_C12", "label": "if", "type": "if", "loc": [156, 158], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L154_C8", "vector": [4, 3, 0.8307, 0.0159, 3, 0.66, 0.5, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.is_valid():\n form.save()\n return HttpResponseRedirect(post_reset_redirect)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L157_C16", "label": "save()", "type": "expression", "loc": [157, 157], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L156_C12", "vector": [8, 4, 0.8307, 0.0053, 4, 0.91, 0.0, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " form.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L158_C16", "label": "return", "type": "return", "loc": [158, 158], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L156_C12", "vector": [13, 4, 0.836, 0.0053, 4, 0.91, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(post_reset_redirect)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L160_C12", "label": "form = set_password_form()", "type": "assigned_variable", "loc": [160, 160], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L154_C8", "vector": [14, 3, 0.8466, 0.0053, 3, 0.66, 1.0, 761, 3, 1, 0, 0, 888, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "set_password_form", "annotation": ""}, "snippet": " form = set_password_form(None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L162_C8", "label": "assign", "type": "assigned_variable", "loc": [162, 162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L152_C4", "vector": [14, 2, 0.8571, 0.0053, 2, 0.89, 0.6667, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context_instance['validlink'] = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L163_C8", "label": "form =", "type": "assigned_variable", "loc": [163, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L152_C4", "vector": [14, 2, 0.8624, 0.0053, 2, 0.89, 1.0, 761, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " form = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L164_C4", "label": "assign", "type": "assigned_variable", "loc": [164, 164], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "vector": [14, 1, 0.8677, 0.0053, 1, 0.66, 0.8333, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context_instance['form'] = form"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L165_C4", "label": "return", "type": "return", "loc": [165, 165], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "vector": [13, 1, 0.873, 0.0053, 1, 0.66, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(template_name, context_instance=context_instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L167_C0", "label": "password_reset_complete", "type": "function", "loc": [167, 169], "level": 0, "parent": null, "vector": [2, 0, 0.8889, 0.0159, 0, 0.66, 0.9259, 905, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "password_reset_complete", "arg_names": ["request", "template_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def password_reset_complete(request, template_name='registration/password_reset_complete.html'):\n return render_to_response(template_name, context_instance=RequestContext(request,\n {'login_url': settings.LOGIN_URL}))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L168_C4", "label": "return", "type": "return", "loc": [168, 169], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L167_C0", "vector": [13, 1, 0.8915, 0.0106, 1, 0.34, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(template_name, context_instance=RequestContext(request,\n {'login_url': settings.LOGIN_URL}))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L173_C0", "label": "password_change", "type": "function", "loc": [173, 186], "level": 0, "parent": null, "vector": [2, 0, 0.9497, 0.0741, 0, 0.66, 0.963, 272, 0, 4, 1, 0, 0, 0, 8], "semantic": {"name": "password_change", "arg_names": ["request", "template_name", "post_change_redirect", "password_change_form"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def password_change(request, template_name='registration/password_change_form.html',\n post_change_redirect=None, password_change_form=PasswordChangeForm):\n if post_change_redirect is None:\n post_change_redirect = reverse('django.contrib.auth.views.password_change_done')\n if request.method == \"POST\":\n form = password_change_form(user=request.user, data=request.POST)\n if form.is_valid():\n form.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L175_C4", "label": "if", "type": "if", "loc": [175, 176], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L173_C0", "vector": [4, 1, 0.9286, 0.0106, 1, 0.52, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if post_change_redirect is None:\n post_change_redirect = reverse('django.contrib.auth.views.password_change_done')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L176_C8", "label": "post_change_redirect = reverse()", "type": "assigned_variable", "loc": [176, 176], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L175_C4", "vector": [14, 2, 0.9312, 0.0053, 2, 0.02, 0.0, 992, 3, 1, 0, 0, 109, 10, 1], "semantic": {"name": "post_change_redirect", "arg_names": [], "import_names": [], "rhs_call_name": "reverse", "annotation": ""}, "snippet": " post_change_redirect = reverse('django.contrib.auth.views.password_change_done')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L177_C4", "label": "if", "type": "if", "loc": [177, 183], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L173_C0", "vector": [4, 1, 0.9524, 0.037, 1, 0.52, 0.5, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.method == \"POST\":\n form = password_change_form(user=request.user, data=request.POST)\n if form.is_valid():\n form.save()\n return HttpResponseRedirect(post_change_redirect)\n else:\n form = password_change_form(user=request.user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L178_C8", "label": "form = password_change_form()", "type": "assigned_variable", "loc": [178, 178], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L177_C4", "vector": [14, 2, 0.9418, 0.0053, 2, 0.66, 0.0, 761, 3, 2, 0, 0, 486, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "password_change_form", "annotation": ""}, "snippet": " form = password_change_form(user=request.user, data=request.POST)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L179_C8", "label": "if", "type": "if", "loc": [179, 181], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L177_C4", "vector": [4, 2, 0.9524, 0.0159, 2, 0.66, 0.5, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.is_valid():\n form.save()\n return HttpResponseRedirect(post_change_redirect)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L180_C12", "label": "save()", "type": "expression", "loc": [180, 180], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L179_C8", "vector": [8, 3, 0.9524, 0.0053, 3, 0.86, 0.0, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " form.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L181_C12", "label": "return", "type": "return", "loc": [181, 181], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L179_C8", "vector": [13, 3, 0.9577, 0.0053, 3, 0.86, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(post_change_redirect)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L183_C8", "label": "form = password_change_form()", "type": "assigned_variable", "loc": [183, 183], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L177_C4", "vector": [14, 2, 0.9683, 0.0053, 2, 0.66, 1.0, 761, 3, 1, 0, 0, 486, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "password_change_form", "annotation": ""}, "snippet": " form = password_change_form(user=request.user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L184_C4", "label": "return", "type": "return", "loc": [184, 186], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L173_C0", "vector": [13, 1, 0.9788, 0.0159, 1, 0.52, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(template_name, {\n 'form': form,\n }, context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L188_C0", "label": "password_change_done", "type": "function", "loc": [188, 189], "level": 0, "parent": null, "vector": [2, 0, 0.9974, 0.0106, 0, 0.66, 1.0, 29, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "password_change_done", "arg_names": ["request", "template_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def password_change_done(request, template_name='registration/password_change_done.html'):\n return render_to_response(template_name, context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L189_C4", "label": "return", "type": "return", "loc": [189, 189], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L188_C0", "vector": [13, 1, 1.0, 0.0053, 1, 0.32, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(template_name, context_instance=RequestContext(request))"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L32_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L34_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L34_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L35_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L34_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L41_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L41_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L42_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L32_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L45_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L32_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L47_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L47_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L48_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L32_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L57_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:ImportFrom_L68_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L70_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L70_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L70_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L72_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L73_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L72_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L75_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L72_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L76_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L70_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L83_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L85_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L86_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L85_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L87_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L87_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L85_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L89_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L91_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L92_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L91_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L93_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L91_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L95_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L105_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L109_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L105_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L111_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L112_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L114_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L115_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L116_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L117_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L118_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L119_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L120_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L120_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L121_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L122_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L123_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L105_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L126_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L130_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L131_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L137_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L142_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L142_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L143_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Try_L144_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:Try_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L145_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:Try_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L146_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:Try_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L148_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L150_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L152_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L152_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L153_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L152_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L154_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L155_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L154_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L156_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L156_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L157_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L156_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L158_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L154_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L160_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L152_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L152_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L164_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L134_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L165_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L167_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L168_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L173_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L175_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L175_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L176_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L173_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L177_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L177_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L178_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L177_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L179_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L179_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Expr_L180_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L179_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L181_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:If_L177_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Assign_L183_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L173_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L184_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98621:FunctionDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98621:Return_L189_C4"}] |
from django.db import models
from django.contrib.sites.models import Site
from django.utils.translation import ugettext_lazy as _
class Redirect(models.Model):
site = models.ForeignKey(Site)
old_path = models.CharField(_('redirect from'), max_length=200, db_index=True,
help_text=_("This should be an absolute path, excluding the domain name. Example: '/events/search/'."))
new_path = models.CharField(_('redirect to'), max_length=200, blank=True,
help_text=_("This can be either an absolute path (as above) or a full URL starting with 'http://'."))
class Meta:
verbose_name = _('redirect')
verbose_name_plural = _('redirects')
db_table = 'django_redirect'
unique_together=(('site', 'old_path'),)
ordering = ('old_path',)
def __unicode__(self):
return "%s ---> %s" % (self.old_path, self.new_path)
| ajibawa-2023/Python-Code-Large/train/row_98623 | 15 | 20 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98623:ImportFrom_L1_C0", "label": "from django.db import models", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.05, 0.05, 0, 0.66, 0.0, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:ImportFrom_L2_C0", "label": "from django.contrib.sites.models import Site", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1, 0.05, 0, 0.66, 0.3333, 890, 0, 1, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sites.models", "arg_names": [], "import_names": ["Site"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sites.models import Site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:ImportFrom_L3_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.15, 0.05, 0, 0.66, 0.6667, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext_lazy as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L5_C0", "label": "Redirect", "type": "class", "loc": [5, 20], "level": 0, "parent": null, "vector": [3, 0, 0.625, 0.8, 0, 0.66, 1.0, 949, 0, 1, 0, 0, 996, 0, 9], "semantic": {"name": "Redirect", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Redirect(models.Model):\n site = models.ForeignKey(Site)\n old_path = models.CharField(_('redirect from'), max_length=200, db_index=True,\n help_text=_(\"This should be an absolute path, excluding the domain name. Example: '/events/search/'.\"))\n new_path = models.CharField(_('redirect to'), max_length=200, blank=True,\n help_text=_(\"This can be either an absolute path (as above) or a full URL starting with 'http://'.\"))\n\n class Meta:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L6_C4", "label": "site = ForeignKey()", "type": "assigned_variable", "loc": [6, 6], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L5_C0", "vector": [14, 1, 0.3, 0.05, 1, 0.28, 0.0, 681, 3, 1, 0, 0, 140, 10, 1], "semantic": {"name": "site", "arg_names": [], "import_names": [], "rhs_call_name": "ForeignKey", "annotation": ""}, "snippet": " site = models.ForeignKey(Site)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L7_C4", "label": "old_path = CharField()", "type": "assigned_variable", "loc": [7, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L5_C0", "vector": [14, 1, 0.375, 0.1, 1, 0.28, 0.25, 351, 3, 4, 0, 0, 952, 10, 3], "semantic": {"name": "old_path", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " old_path = models.CharField(_('redirect from'), max_length=200, db_index=True,\n help_text=_(\"This should be an absolute path, excluding the domain name. Example: '/events/search/'.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L9_C4", "label": "new_path = CharField()", "type": "assigned_variable", "loc": [9, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L5_C0", "vector": [14, 1, 0.475, 0.1, 1, 0.28, 0.5, 204, 3, 4, 0, 0, 952, 10, 3], "semantic": {"name": "new_path", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " new_path = models.CharField(_('redirect to'), max_length=200, blank=True,\n help_text=_(\"This can be either an absolute path (as above) or a full URL starting with 'http://'.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L12_C4", "label": "Meta", "type": "class", "loc": [12, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L5_C0", "vector": [3, 1, 0.725, 0.3, 1, 0.28, 0.75, 130, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "Meta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Meta:\n verbose_name = _('redirect')\n verbose_name_plural = _('redirects')\n db_table = 'django_redirect'\n unique_together=(('site', 'old_path'),)\n ordering = ('old_path',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L13_C8", "label": "verbose_name = _()", "type": "assigned_variable", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L12_C4", "vector": [14, 2, 0.65, 0.05, 2, 0.17, 0.0, 616, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "verbose_name", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " verbose_name = _('redirect')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L14_C8", "label": "verbose_name_plural = _()", "type": "assigned_variable", "loc": [14, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L12_C4", "vector": [14, 2, 0.7, 0.05, 2, 0.17, 0.25, 329, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "verbose_name_plural", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " verbose_name_plural = _('redirects')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L15_C8", "label": "db_table =", "type": "assigned_variable", "loc": [15, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L12_C4", "vector": [14, 2, 0.75, 0.05, 2, 0.17, 0.5, 111, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "db_table", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " db_table = 'django_redirect'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L16_C8", "label": "unique_together =", "type": "assigned_variable", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L12_C4", "vector": [14, 2, 0.8, 0.05, 2, 0.17, 0.75, 846, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "unique_together", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " unique_together=(('site', 'old_path'),)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L17_C8", "label": "ordering =", "type": "assigned_variable", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L12_C4", "vector": [14, 2, 0.85, 0.05, 2, 0.17, 1.0, 656, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "ordering", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ordering = ('old_path',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:FunctionDef_L19_C4", "label": "__unicode__", "type": "function", "loc": [19, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L5_C0", "vector": [2, 1, 0.975, 0.1, 1, 0.28, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return \"%s ---> %s\" % (self.old_path, self.new_path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98623:Return_L20_C8", "label": "return", "type": "return", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98623:FunctionDef_L19_C4", "vector": [13, 2, 1.0, 0.05, 2, 0.49, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"%s ---> %s\" % (self.old_path, self.new_path)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98623:Assign_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98623:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98623:FunctionDef_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98623:FunctionDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98623:Return_L20_C8"}] |
from django.contrib.redirects.models import Redirect
from django import http
from django.conf import settings
class RedirectFallbackMiddleware(object):
def process_response(self, request, response):
if response.status_code != 404:
return response # No need to check for a redirect for non-404 responses.
path = request.get_full_path()
try:
r = Redirect.objects.get(site__id__exact=settings.SITE_ID, old_path=path)
except Redirect.DoesNotExist:
r = None
if r is None and settings.APPEND_SLASH:
# Try removing the trailing slash.
try:
r = Redirect.objects.get(site__id__exact=settings.SITE_ID,
old_path=path[:path.rfind('/')]+path[path.rfind('/')+1:])
except Redirect.DoesNotExist:
pass
if r is not None:
if r.new_path == '':
return http.HttpResponseGone()
return http.HttpResponsePermanentRedirect(r.new_path)
# No redirect was found. Return the response.
return response
| ajibawa-2023/Python-Code-Large/train/row_98624 | 19 | 27 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98624:ImportFrom_L1_C0", "label": "from django.contrib.redirects.models import Redirect", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.037, 0.037, 0, 0.66, 0.0, 909, 0, 1, 0, 0, 909, 0, 0], "semantic": {"name": "django.contrib.redirects.models", "arg_names": [], "import_names": ["Redirect"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.redirects.models import Redirect"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:ImportFrom_L2_C0", "label": "from django import http", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0741, 0.037, 0, 0.66, 0.3333, 294, 0, 1, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["http"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django import http"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:ImportFrom_L3_C0", "label": "from django.conf import settings", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.1111, 0.037, 0, 0.66, 0.6667, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:ClassDef_L5_C0", "label": "RedirectFallbackMiddleware", "type": "class", "loc": [5, 27], "level": 0, "parent": null, "vector": [3, 0, 0.5926, 0.8519, 0, 0.66, 1.0, 187, 0, 1, 0, 0, 186, 0, 7], "semantic": {"name": "RedirectFallbackMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RedirectFallbackMiddleware(object):\n def process_response(self, request, response):\n if response.status_code != 404:\n return response # No need to check for a redirect for non-404 responses.\n path = request.get_full_path()\n try:\n r = Redirect.objects.get(site__id__exact=settings.SITE_ID, old_path=path)\n except Redirect.DoesNotExist:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "label": "process_response", "type": "function", "loc": [6, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:ClassDef_L5_C0", "vector": [2, 1, 0.6111, 0.8148, 1, 0.76, 0.0, 298, 0, 3, 1, 0, 0, 0, 7], "semantic": {"name": "process_response", "arg_names": ["self", "request", "response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_response(self, request, response):\n if response.status_code != 404:\n return response # No need to check for a redirect for non-404 responses.\n path = request.get_full_path()\n try:\n r = Redirect.objects.get(site__id__exact=settings.SITE_ID, old_path=path)\n except Redirect.DoesNotExist:\n r = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L7_C8", "label": "if", "type": "if", "loc": [7, 8], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "vector": [4, 2, 0.2778, 0.0741, 2, 0.5, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response.status_code != 404:\n return response # No need to check for a redirect for non-404 responses."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:Return_L8_C12", "label": "return", "type": "return", "loc": [8, 8], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L7_C8", "vector": [13, 3, 0.2963, 0.037, 3, 0.1, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return response # No need to check for a redirect for non-404 responses."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:Assign_L9_C8", "label": "path = get_full_path()", "type": "assigned_variable", "loc": [9, 9], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "vector": [14, 2, 0.3333, 0.037, 2, 0.5, 0.2, 358, 3, 0, 0, 0, 451, 10, 1], "semantic": {"name": "path", "arg_names": [], "import_names": [], "rhs_call_name": "get_full_path", "annotation": ""}, "snippet": " path = request.get_full_path()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:Try_L10_C8", "label": "try", "type": "try", "loc": [10, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "vector": [7, 2, 0.4259, 0.1481, 2, 0.5, 0.4, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n r = Redirect.objects.get(site__id__exact=settings.SITE_ID, old_path=path)\n except Redirect.DoesNotExist:\n r = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:Assign_L11_C12", "label": "r = get()", "type": "assigned_variable", "loc": [11, 11], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:Try_L10_C8", "vector": [14, 3, 0.4074, 0.037, 3, 0.55, 0.0, 436, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "r", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " r = Redirect.objects.get(site__id__exact=settings.SITE_ID, old_path=path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:Assign_L13_C12", "label": "r =", "type": "assigned_variable", "loc": [13, 13], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:Try_L10_C8", "vector": [14, 3, 0.4815, 0.037, 3, 0.55, 0.0, 436, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "r", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " r = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L14_C8", "label": "if", "type": "if", "loc": [14, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "vector": [4, 2, 0.6296, 0.2593, 2, 0.5, 0.6, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r is None and settings.APPEND_SLASH:\n # Try removing the trailing slash.\n try:\n r = Redirect.objects.get(site__id__exact=settings.SITE_ID,\n old_path=path[:path.rfind('/')]+path[path.rfind('/')+1:])\n except Redirect.DoesNotExist:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:Try_L16_C12", "label": "try", "type": "try", "loc": [16, 20], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L14_C8", "vector": [7, 3, 0.6667, 0.1852, 3, 0.95, 0.0, 0, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n r = Redirect.objects.get(site__id__exact=settings.SITE_ID,\n old_path=path[:path.rfind('/')]+path[path.rfind('/')+1:])\n except Redirect.DoesNotExist:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:Assign_L17_C16", "label": "r = get()", "type": "assigned_variable", "loc": [17, 18], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:Try_L16_C12", "vector": [14, 4, 0.6481, 0.0741, 4, 0.39, 0.0, 436, 3, 2, 0, 0, 607, 10, 3], "semantic": {"name": "r", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " r = Redirect.objects.get(site__id__exact=settings.SITE_ID,\n old_path=path[:path.rfind('/')]+path[path.rfind('/')+1:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L21_C8", "label": "if", "type": "if", "loc": [21, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "vector": [4, 2, 0.8333, 0.1481, 2, 0.5, 0.8, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r is not None:\n if r.new_path == '':\n return http.HttpResponseGone()\n return http.HttpResponsePermanentRedirect(r.new_path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L22_C12", "label": "if", "type": "if", "loc": [22, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L21_C8", "vector": [4, 3, 0.8333, 0.0741, 3, 0.04, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.new_path == '':\n return http.HttpResponseGone()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:Return_L23_C16", "label": "return", "type": "return", "loc": [23, 23], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L22_C12", "vector": [13, 4, 0.8519, 0.037, 4, 0.82, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return http.HttpResponseGone()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:Return_L24_C12", "label": "return", "type": "return", "loc": [24, 24], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L21_C8", "vector": [13, 3, 0.8889, 0.037, 3, 0.04, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return http.HttpResponsePermanentRedirect(r.new_path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98624:Return_L27_C8", "label": "return", "type": "return", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "vector": [13, 2, 1.0, 0.037, 2, 0.5, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return response"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98624:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L7_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L7_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:Return_L8_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:Try_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:Try_L10_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:Assign_L11_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:Try_L10_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:Assign_L13_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L14_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:Try_L16_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:Try_L16_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:Assign_L17_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L21_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L22_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L22_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:Return_L23_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:If_L21_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:Return_L24_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98624:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98624:Return_L27_C8"}] |
from django.contrib import admin
from django.contrib.redirects.models import Redirect
class RedirectAdmin(admin.ModelAdmin):
list_display = ('old_path', 'new_path')
list_filter = ('site',)
search_fields = ('old_path', 'new_path')
radio_fields = {'site': admin.VERTICAL}
admin.site.register(Redirect, RedirectAdmin) | ajibawa-2023/Python-Code-Large/train/row_98625 | 8 | 11 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98625:ImportFrom_L2_C0", "label": "from django.contrib import admin", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1818, 0.0909, 0, 0.66, 0.0, 302, 0, 1, 0, 0, 302, 0, 0], "semantic": {"name": "django.contrib", "arg_names": [], "import_names": ["admin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib import admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98625:ImportFrom_L3_C0", "label": "from django.contrib.redirects.models import Redirect", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.2727, 0.0909, 0, 0.66, 0.3333, 909, 0, 1, 0, 0, 909, 0, 0], "semantic": {"name": "django.contrib.redirects.models", "arg_names": [], "import_names": ["Redirect"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.redirects.models import Redirect"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98625:ClassDef_L5_C0", "label": "RedirectAdmin", "type": "class", "loc": [5, 9], "level": 0, "parent": null, "vector": [3, 0, 0.6364, 0.4545, 0, 0.66, 0.6667, 825, 0, 0, 0, 0, 823, 0, 0], "semantic": {"name": "RedirectAdmin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RedirectAdmin(admin.ModelAdmin):\n list_display = ('old_path', 'new_path')\n list_filter = ('site',)\n search_fields = ('old_path', 'new_path')\n radio_fields = {'site': admin.VERTICAL}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98625:Assign_L6_C4", "label": "list_display =", "type": "assigned_variable", "loc": [6, 6], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98625:ClassDef_L5_C0", "vector": [14, 1, 0.5455, 0.0909, 1, 0.17, 0.0, 489, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "list_display", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_display = ('old_path', 'new_path')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98625:Assign_L7_C4", "label": "list_filter =", "type": "assigned_variable", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98625:ClassDef_L5_C0", "vector": [14, 1, 0.6364, 0.0909, 1, 0.17, 0.3333, 851, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "list_filter", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_filter = ('site',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98625:Assign_L8_C4", "label": "search_fields =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98625:ClassDef_L5_C0", "vector": [14, 1, 0.7273, 0.0909, 1, 0.17, 0.6667, 834, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "search_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " search_fields = ('old_path', 'new_path')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98625:Assign_L9_C4", "label": "radio_fields =", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98625:ClassDef_L5_C0", "vector": [14, 1, 0.8182, 0.0909, 1, 0.17, 1.0, 348, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "radio_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " radio_fields = {'site': admin.VERTICAL}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98625:Expr_L11_C0", "label": "register()", "type": "expression", "loc": [11, 11], "level": 0, "parent": null, "vector": [8, 0, 1.0, 0.0909, 0, 0.66, 1.0, 276, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "register", "annotation": ""}, "snippet": "admin.site.register(Redirect, RedirectAdmin)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98625:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98625:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98625:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98625:Assign_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98625:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98625:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98625:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98625:Assign_L9_C4"}] |
# Empty models.py to allow for specifying admindocs as a test label.
| ajibawa-2023/Python-Code-Large/train/row_98626 | 0 | 1 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [] | [] |
from django.db import models
class CustomField(models.Field):
description = "A custom field type"
class DescriptionLackingField(models.Field):
pass
| ajibawa-2023/Python-Code-Large/train/row_98627 | 4 | 7 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98627:ImportFrom_L1_C0", "label": "from django.db import models", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.1429, 0.1429, 0, 0.66, 0.0, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98627:ClassDef_L3_C0", "label": "CustomField", "type": "class", "loc": [3, 4], "level": 0, "parent": null, "vector": [3, 0, 0.5, 0.2857, 0, 0.66, 0.5, 771, 0, 0, 0, 0, 922, 0, 0], "semantic": {"name": "CustomField", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CustomField(models.Field):\n description = \"A custom field type\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98627:Assign_L4_C4", "label": "description =", "type": "assigned_variable", "loc": [4, 4], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98627:ClassDef_L3_C0", "vector": [14, 1, 0.5714, 0.1429, 1, 0.7, 0.0, 306, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "description", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " description = \"A custom field type\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98627:ClassDef_L6_C0", "label": "DescriptionLackingField", "type": "class", "loc": [6, 7], "level": 0, "parent": null, "vector": [3, 0, 0.9286, 0.2857, 0, 0.66, 1.0, 22, 0, 0, 0, 0, 922, 0, 0], "semantic": {"name": "DescriptionLackingField", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DescriptionLackingField(models.Field):\n pass"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98627:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98627:Assign_L4_C4"}] |
from django.contrib.admindocs import views
from django.db.models import fields as builtin_fields
from django.utils import unittest
import fields
class TestFieldType(unittest.TestCase):
def setUp(self):
pass
def test_field_name(self):
self.assertRaises(AttributeError,
views.get_readable_field_data_type, "NotAField"
)
def test_builtin_fields(self):
self.assertEqual(
views.get_readable_field_data_type(builtin_fields.BooleanField()),
u'Boolean (Either True or False)'
)
def test_custom_fields(self):
self.assertEqual(
views.get_readable_field_data_type(fields.CustomField()),
u'A custom field type'
)
self.assertEqual(
views.get_readable_field_data_type(fields.DescriptionLackingField()),
u'Field of type: DescriptionLackingField'
)
| ajibawa-2023/Python-Code-Large/train/row_98628 | 13 | 31 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98628:ImportFrom_L1_C0", "label": "from django.contrib.admindocs import views", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0323, 0.0323, 0, 0.66, 0.0, 601, 0, 1, 0, 0, 601, 0, 0], "semantic": {"name": "django.contrib.admindocs", "arg_names": [], "import_names": ["views"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admindocs import views"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98628:ImportFrom_L2_C0", "label": "from django.db.models import builtin_fields", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0645, 0.0323, 0, 0.66, 0.25, 680, 0, 1, 0, 0, 680, 0, 0], "semantic": {"name": "django.db.models", "arg_names": [], "import_names": ["builtin_fields"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models import fields as builtin_fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98628:ImportFrom_L3_C0", "label": "from django.utils import unittest", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0968, 0.0323, 0, 0.66, 0.5, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["unittest"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import unittest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98628:Import_L5_C0", "label": "fields import fields", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.1613, 0.0323, 0, 0.66, 0.75, 358, 0, 1, 0, 0, 358, 0, 0], "semantic": {"name": "fields", "arg_names": [], "import_names": ["fields"], "rhs_call_name": "", "annotation": ""}, "snippet": "import fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98628:ClassDef_L8_C0", "label": "TestFieldType", "type": "class", "loc": [8, 31], "level": 0, "parent": null, "vector": [3, 0, 0.629, 0.7742, 0, 0.66, 1.0, 394, 0, 4, 0, 0, 878, 0, 10], "semantic": {"name": "TestFieldType", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TestFieldType(unittest.TestCase):\n def setUp(self):\n pass\n\n def test_field_name(self):\n self.assertRaises(AttributeError,\n views.get_readable_field_data_type, \"NotAField\"\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L9_C4", "label": "setUp", "type": "function", "loc": [9, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98628:ClassDef_L8_C0", "vector": [2, 1, 0.3065, 0.0645, 1, 0.0, 0.0, 952, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "setUp", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def setUp(self):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L12_C4", "label": "test_field_name", "type": "function", "loc": [12, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98628:ClassDef_L8_C0", "vector": [2, 1, 0.4355, 0.129, 1, 0.0, 0.3333, 559, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "test_field_name", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_field_name(self):\n self.assertRaises(AttributeError,\n views.get_readable_field_data_type, \"NotAField\"\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98628:Expr_L13_C8", "label": "assertRaises()", "type": "expression", "loc": [13, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L12_C4", "vector": [8, 2, 0.4516, 0.0968, 2, 0.35, 0.0, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(AttributeError,\n views.get_readable_field_data_type, \"NotAField\"\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L17_C4", "label": "test_builtin_fields", "type": "function", "loc": [17, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98628:ClassDef_L8_C0", "vector": [2, 1, 0.6129, 0.1613, 1, 0.0, 0.6667, 481, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "test_builtin_fields", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_builtin_fields(self):\n self.assertEqual(\n views.get_readable_field_data_type(builtin_fields.BooleanField()),\n u'Boolean (Either True or False)'\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98628:Expr_L18_C8", "label": "assertEqual()", "type": "expression", "loc": [18, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L17_C4", "vector": [8, 2, 0.629, 0.129, 2, 0.75, 0.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(\n views.get_readable_field_data_type(builtin_fields.BooleanField()),\n u'Boolean (Either True or False)'\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L23_C4", "label": "test_custom_fields", "type": "function", "loc": [23, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98628:ClassDef_L8_C0", "vector": [2, 1, 0.871, 0.2903, 1, 0.0, 1.0, 261, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_custom_fields", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_custom_fields(self):\n self.assertEqual(\n views.get_readable_field_data_type(fields.CustomField()),\n u'A custom field type'\n )\n self.assertEqual(\n views.get_readable_field_data_type(fields.DescriptionLackingField()),\n u'Field of type: DescriptionLackingField'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98628:Expr_L24_C8", "label": "assertEqual()", "type": "expression", "loc": [24, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L23_C4", "vector": [8, 2, 0.8226, 0.129, 2, 0.52, 0.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(\n views.get_readable_field_data_type(fields.CustomField()),\n u'A custom field type'\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98628:Expr_L28_C8", "label": "assertEqual()", "type": "expression", "loc": [28, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L23_C4", "vector": [8, 2, 0.9516, 0.129, 2, 0.52, 1.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(\n views.get_readable_field_data_type(fields.DescriptionLackingField()),\n u'Field of type: DescriptionLackingField'\n )"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98628:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98628:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98628:Expr_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98628:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98628:Expr_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98628:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L23_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98628:Expr_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98628:FunctionDef_L23_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98628:Expr_L28_C8"}] |
from django.conf.urls.defaults import *
from django.contrib.admindocs import views
urlpatterns = patterns('',
url('^$',
views.doc_index,
name='django-admindocs-docroot'
),
url('^bookmarklets/$',
views.bookmarklets,
name='django-admindocs-bookmarklets'
),
url('^tags/$',
views.template_tag_index,
name='django-admindocs-tags'
),
url('^filters/$',
views.template_filter_index,
name='django-admindocs-filters'
),
url('^views/$',
views.view_index,
name='django-admindocs-views-index'
),
url('^views/(?P<view>[^/]+)/$',
views.view_detail,
name='django-admindocs-views-detail'
),
url('^models/$',
views.model_index,
name='django-admindocs-models-index'
),
url('^models/(?P<app_label>[^\.]+)\.(?P<model_name>[^/]+)/$',
views.model_detail,
name='django-admindocs-models-detail'
),
url('^templates/(?P<template>.*)/$',
views.template_detail,
name='django-admindocs-templates'
),
)
| ajibawa-2023/Python-Code-Large/train/row_98629 | 3 | 41 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98629:ImportFrom_L1_C0", "label": "from django.conf.urls.defaults import *", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0244, 0.0244, 0, 0.66, 0.0, 341, 0, 1, 0, 0, 341, 0, 0], "semantic": {"name": "django.conf.urls.defaults", "arg_names": [], "import_names": ["*"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf.urls.defaults import *"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98629:ImportFrom_L2_C0", "label": "from django.contrib.admindocs import views", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0488, 0.0244, 0, 0.66, 0.5, 601, 0, 1, 0, 0, 601, 0, 0], "semantic": {"name": "django.contrib.admindocs", "arg_names": [], "import_names": ["views"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admindocs import views"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98629:Assign_L4_C0", "label": "urlpatterns = patterns()", "type": "assigned_variable", "loc": [4, 41], "level": 0, "parent": null, "vector": [14, 0, 0.5488, 0.9268, 0, 0.66, 1.0, 990, 3, 10, 0, 0, 75, 10, 10], "semantic": {"name": "urlpatterns", "arg_names": [], "import_names": [], "rhs_call_name": "patterns", "annotation": ""}, "snippet": "urlpatterns = patterns('',\n url('^$',\n views.doc_index,\n name='django-admindocs-docroot'\n ),\n url('^bookmarklets/$',\n views.bookmarklets,\n name='django-admindocs-bookmarklets'"}] | [] |
"Misc. utility functions/classes for admin documentation generator."
import re
from email.Parser import HeaderParser
from email.Errors import HeaderParseError
from django.utils.safestring import mark_safe
from django.core.urlresolvers import reverse
from django.utils.encoding import smart_str
try:
import docutils.core
import docutils.nodes
import docutils.parsers.rst.roles
except ImportError:
docutils_is_available = False
else:
docutils_is_available = True
def trim_docstring(docstring):
"""
Uniformly trims leading/trailing whitespace from docstrings.
Based on http://www.python.org/peps/pep-0257.html#handling-docstring-indentation
"""
if not docstring or not docstring.strip():
return ''
# Convert tabs to spaces and split into lines
lines = docstring.expandtabs().splitlines()
indent = min([len(line) - len(line.lstrip()) for line in lines if line.lstrip()])
trimmed = [lines[0].lstrip()] + [line[indent:].rstrip() for line in lines[1:]]
return "\n".join(trimmed).strip()
def parse_docstring(docstring):
"""
Parse out the parts of a docstring. Returns (title, body, metadata).
"""
docstring = trim_docstring(docstring)
parts = re.split(r'\n{2,}', docstring)
title = parts[0]
if len(parts) == 1:
body = ''
metadata = {}
else:
parser = HeaderParser()
try:
metadata = parser.parsestr(parts[-1])
except HeaderParseError:
metadata = {}
body = "\n\n".join(parts[1:])
else:
metadata = dict(metadata.items())
if metadata:
body = "\n\n".join(parts[1:-1])
else:
body = "\n\n".join(parts[1:])
return title, body, metadata
def parse_rst(text, default_reference_context, thing_being_parsed=None):
"""
Convert the string from reST to an XHTML fragment.
"""
overrides = {
'doctitle_xform' : True,
'inital_header_level' : 3,
"default_reference_context" : default_reference_context,
"link_base" : reverse('django-admindocs-docroot').rstrip('/')
}
if thing_being_parsed:
thing_being_parsed = smart_str("<%s>" % thing_being_parsed)
parts = docutils.core.publish_parts(text, source_path=thing_being_parsed,
destination_path=None, writer_name='html',
settings_overrides=overrides)
return mark_safe(parts['fragment'])
#
# reST roles
#
ROLES = {
'model' : '%s/models/%s/',
'view' : '%s/views/%s/',
'template' : '%s/templates/%s/',
'filter' : '%s/filters/#%s',
'tag' : '%s/tags/#%s',
}
def create_reference_role(rolename, urlbase):
def _role(name, rawtext, text, lineno, inliner, options=None, content=None):
if options is None: options = {}
if content is None: content = []
node = docutils.nodes.reference(rawtext, text, refuri=(urlbase % (inliner.document.settings.link_base, text.lower())), **options)
return [node], []
docutils.parsers.rst.roles.register_canonical_role(rolename, _role)
def default_reference_role(name, rawtext, text, lineno, inliner, options=None, content=None):
if options is None: options = {}
if content is None: content = []
context = inliner.document.settings.default_reference_context
node = docutils.nodes.reference(rawtext, text, refuri=(ROLES[context] % (inliner.document.settings.link_base, text.lower())), **options)
return [node], []
if docutils_is_available:
docutils.parsers.rst.roles.register_canonical_role('cmsreference', default_reference_role)
docutils.parsers.rst.roles.DEFAULT_INTERPRETED_ROLE = 'cmsreference'
for name, urlbase in ROLES.items():
create_reference_role(name, urlbase)
| ajibawa-2023/Python-Code-Large/train/row_98630 | 69 | 105 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 1], "level": 0, "parent": null, "vector": [8, 0, 0.0095, 0.0095, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"Misc. utility functions/classes for admin documentation generator.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Import_L3_C0", "label": "re import re", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0286, 0.0095, 0, 0.66, 0.0714, 540, 0, 1, 0, 0, 540, 0, 0], "semantic": {"name": "re", "arg_names": [], "import_names": ["re"], "rhs_call_name": "", "annotation": ""}, "snippet": "import re"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:ImportFrom_L4_C0", "label": "from email.Parser import HeaderParser", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0381, 0.0095, 0, 0.66, 0.1429, 621, 0, 1, 0, 0, 621, 0, 0], "semantic": {"name": "email.Parser", "arg_names": [], "import_names": ["HeaderParser"], "rhs_call_name": "", "annotation": ""}, "snippet": "from email.Parser import HeaderParser"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:ImportFrom_L5_C0", "label": "from email.Errors import HeaderParseError", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0476, 0.0095, 0, 0.66, 0.2143, 684, 0, 1, 0, 0, 684, 0, 0], "semantic": {"name": "email.Errors", "arg_names": [], "import_names": ["HeaderParseError"], "rhs_call_name": "", "annotation": ""}, "snippet": "from email.Errors import HeaderParseError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:ImportFrom_L6_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0571, 0.0095, 0, 0.66, 0.2857, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.safestring", "arg_names": [], "import_names": ["mark_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.safestring import mark_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:ImportFrom_L7_C0", "label": "from django.core.urlresolvers import reverse", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0667, 0.0095, 0, 0.66, 0.3571, 749, 0, 1, 0, 0, 749, 0, 0], "semantic": {"name": "django.core.urlresolvers", "arg_names": [], "import_names": ["reverse"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.urlresolvers import reverse"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:ImportFrom_L8_C0", "label": "from django.utils.encoding import smart_str", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0762, 0.0095, 0, 0.66, 0.4286, 96, 0, 1, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_str"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_str"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L9_C0", "label": "try", "type": "try", "loc": [9, 16], "level": 0, "parent": null, "vector": [7, 0, 0.119, 0.0762, 0, 0.66, 0.5, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "try:\n import docutils.core\n import docutils.nodes\n import docutils.parsers.rst.roles\nexcept ImportError:\n docutils_is_available = False\nelse:\n docutils_is_available = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Import_L10_C4", "label": "docutils.core import docutils.core", "type": "import", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L9_C0", "vector": [1, 1, 0.0952, 0.0095, 1, 0.72, 0.0, 219, 0, 1, 0, 0, 219, 0, 0], "semantic": {"name": "docutils.core", "arg_names": [], "import_names": ["docutils.core"], "rhs_call_name": "", "annotation": ""}, "snippet": " import docutils.core"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Import_L11_C4", "label": "docutils.nodes import docutils.nodes", "type": "import", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L9_C0", "vector": [1, 1, 0.1048, 0.0095, 1, 0.72, 0.3333, 127, 0, 1, 0, 0, 127, 0, 0], "semantic": {"name": "docutils.nodes", "arg_names": [], "import_names": ["docutils.nodes"], "rhs_call_name": "", "annotation": ""}, "snippet": " import docutils.nodes"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Import_L12_C4", "label": "docutils.parsers.rst.roles import docutils.parsers.rst.roles", "type": "import", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L9_C0", "vector": [1, 1, 0.1143, 0.0095, 1, 0.72, 0.6667, 114, 0, 1, 0, 0, 114, 0, 0], "semantic": {"name": "docutils.parsers.rst.roles", "arg_names": [], "import_names": ["docutils.parsers.rst.roles"], "rhs_call_name": "", "annotation": ""}, "snippet": " import docutils.parsers.rst.roles"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L14_C4", "label": "docutils_is_available =", "type": "assigned_variable", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L9_C0", "vector": [14, 1, 0.1333, 0.0095, 1, 0.72, 0.0, 751, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "docutils_is_available", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " docutils_is_available = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L16_C4", "label": "docutils_is_available =", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L9_C0", "vector": [14, 1, 0.1524, 0.0095, 1, 0.72, 1.0, 751, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "docutils_is_available", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " docutils_is_available = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "label": "trim_docstring", "type": "function", "loc": [18, 30], "level": 0, "parent": null, "vector": [2, 0, 0.2286, 0.1238, 0, 0.66, 0.5714, 484, 0, 1, 1, 0, 0, 0, 12], "semantic": {"name": "trim_docstring", "arg_names": ["docstring"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def trim_docstring(docstring):\n \"\"\"\n Uniformly trims leading/trailing whitespace from docstrings.\n\n Based on http://www.python.org/peps/pep-0257.html#handling-docstring-indentation\n \"\"\"\n if not docstring or not docstring.strip():\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L19_C4", "label": "expression", "type": "expression", "loc": [19, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "vector": [8, 1, 0.2, 0.0476, 1, 0.19, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Uniformly trims leading/trailing whitespace from docstrings.\n\n Based on http://www.python.org/peps/pep-0257.html#handling-docstring-indentation\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L24_C4", "label": "if", "type": "if", "loc": [24, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "vector": [4, 1, 0.2333, 0.019, 1, 0.19, 0.2, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not docstring or not docstring.strip():\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Return_L25_C8", "label": "return", "type": "return", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L24_C4", "vector": [13, 2, 0.2381, 0.0095, 2, 0.12, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L27_C4", "label": "lines = splitlines()", "type": "assigned_variable", "loc": [27, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "vector": [14, 1, 0.2571, 0.0095, 1, 0.19, 0.4, 73, 3, 0, 0, 0, 296, 10, 2], "semantic": {"name": "lines", "arg_names": [], "import_names": [], "rhs_call_name": "splitlines", "annotation": ""}, "snippet": " lines = docstring.expandtabs().splitlines()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L28_C4", "label": "indent = min()", "type": "assigned_variable", "loc": [28, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "vector": [14, 1, 0.2667, 0.0095, 1, 0.19, 0.6, 231, 3, 1, 0, 0, 867, 10, 5], "semantic": {"name": "indent", "arg_names": [], "import_names": [], "rhs_call_name": "min", "annotation": ""}, "snippet": " indent = min([len(line) - len(line.lstrip()) for line in lines if line.lstrip()])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L29_C4", "label": "trimmed =", "type": "assigned_variable", "loc": [29, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "vector": [14, 1, 0.2762, 0.0095, 1, 0.19, 0.8, 830, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "trimmed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " trimmed = [lines[0].lstrip()] + [line[indent:].rstrip() for line in lines[1:]]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Return_L30_C4", "label": "return", "type": "return", "loc": [30, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "vector": [13, 1, 0.2857, 0.0095, 1, 0.19, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"\\n\".join(trimmed).strip()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "label": "parse_docstring", "type": "function", "loc": [32, 55], "level": 0, "parent": null, "vector": [2, 0, 0.4143, 0.2286, 0, 0.66, 0.6429, 369, 0, 1, 1, 0, 0, 0, 10], "semantic": {"name": "parse_docstring", "arg_names": ["docstring"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def parse_docstring(docstring):\n \"\"\"\n Parse out the parts of a docstring. Returns (title, body, metadata).\n \"\"\"\n docstring = trim_docstring(docstring)\n parts = re.split(r'\\n{2,}', docstring)\n title = parts[0]\n if len(parts) == 1:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L33_C4", "label": "expression", "type": "expression", "loc": [33, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "vector": [8, 1, 0.3238, 0.0286, 1, 0.17, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Parse out the parts of a docstring. Returns (title, body, metadata).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L36_C4", "label": "docstring = trim_docstring()", "type": "assigned_variable", "loc": [36, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "vector": [14, 1, 0.3429, 0.0095, 1, 0.17, 0.2, 464, 3, 1, 0, 0, 484, 10, 1], "semantic": {"name": "docstring", "arg_names": [], "import_names": [], "rhs_call_name": "trim_docstring", "annotation": ""}, "snippet": " docstring = trim_docstring(docstring)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L37_C4", "label": "parts = split()", "type": "assigned_variable", "loc": [37, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "vector": [14, 1, 0.3524, 0.0095, 1, 0.17, 0.4, 13, 3, 2, 0, 0, 908, 10, 1], "semantic": {"name": "parts", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " parts = re.split(r'\\n{2,}', docstring)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L38_C4", "label": "title =", "type": "assigned_variable", "loc": [38, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "vector": [14, 1, 0.3619, 0.0095, 1, 0.17, 0.6, 48, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "title", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " title = parts[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L39_C4", "label": "if", "type": "if", "loc": [39, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "vector": [4, 1, 0.4429, 0.1524, 1, 0.17, 0.8, 0, 0, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(parts) == 1:\n body = ''\n metadata = {}\n else:\n parser = HeaderParser()\n try:\n metadata = parser.parsestr(parts[-1])\n except HeaderParseError:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L40_C8", "label": "body =", "type": "assigned_variable", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L39_C4", "vector": [14, 2, 0.381, 0.0095, 2, 0.81, 0.0, 477, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "body", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " body = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L41_C8", "label": "metadata =", "type": "assigned_variable", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L39_C4", "vector": [14, 2, 0.3905, 0.0095, 2, 0.81, 0.3333, 933, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "metadata", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " metadata = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L43_C8", "label": "parser = HeaderParser()", "type": "assigned_variable", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L39_C4", "vector": [14, 2, 0.4095, 0.0095, 2, 0.81, 0.6667, 968, 3, 0, 0, 0, 540, 10, 1], "semantic": {"name": "parser", "arg_names": [], "import_names": [], "rhs_call_name": "HeaderParser", "annotation": ""}, "snippet": " parser = HeaderParser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L44_C8", "label": "try", "type": "try", "loc": [44, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L39_C4", "vector": [7, 2, 0.4667, 0.1048, 2, 0.81, 1.0, 0, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n metadata = parser.parsestr(parts[-1])\n except HeaderParseError:\n metadata = {}\n body = \"\\n\\n\".join(parts[1:])\n else:\n metadata = dict(metadata.items())\n if metadata:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L45_C12", "label": "metadata = parsestr()", "type": "assigned_variable", "loc": [45, 45], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L44_C8", "vector": [14, 3, 0.4286, 0.0095, 3, 0.71, 0.0, 933, 3, 1, 0, 0, 781, 10, 1], "semantic": {"name": "metadata", "arg_names": [], "import_names": [], "rhs_call_name": "parsestr", "annotation": ""}, "snippet": " metadata = parser.parsestr(parts[-1])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L47_C12", "label": "metadata =", "type": "assigned_variable", "loc": [47, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L44_C8", "vector": [14, 3, 0.4476, 0.0095, 3, 0.71, 0.0, 933, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "metadata", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " metadata = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L48_C12", "label": "body = join()", "type": "assigned_variable", "loc": [48, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L44_C8", "vector": [14, 3, 0.4571, 0.0095, 3, 0.71, 1.0, 477, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "body", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " body = \"\\n\\n\".join(parts[1:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L50_C12", "label": "metadata = dict()", "type": "assigned_variable", "loc": [50, 50], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L44_C8", "vector": [14, 3, 0.4762, 0.0095, 3, 0.71, 0.5, 933, 3, 1, 0, 0, 827, 10, 2], "semantic": {"name": "metadata", "arg_names": [], "import_names": [], "rhs_call_name": "dict", "annotation": ""}, "snippet": " metadata = dict(metadata.items())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L51_C12", "label": "if", "type": "if", "loc": [51, 54], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L44_C8", "vector": [4, 3, 0.5, 0.0381, 3, 0.71, 1.0, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if metadata:\n body = \"\\n\\n\".join(parts[1:-1])\n else:\n body = \"\\n\\n\".join(parts[1:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L52_C16", "label": "body = join()", "type": "assigned_variable", "loc": [52, 52], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L51_C12", "vector": [14, 4, 0.4952, 0.0095, 4, 0.06, 0.0, 477, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "body", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " body = \"\\n\\n\".join(parts[1:-1])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L54_C16", "label": "body = join()", "type": "assigned_variable", "loc": [54, 54], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L51_C12", "vector": [14, 4, 0.5143, 0.0095, 4, 0.06, 1.0, 477, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "body", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " body = \"\\n\\n\".join(parts[1:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Return_L55_C4", "label": "return", "type": "return", "loc": [55, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "vector": [13, 1, 0.5238, 0.0095, 1, 0.17, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return title, body, metadata"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L57_C0", "label": "parse_rst", "type": "function", "loc": [57, 72], "level": 0, "parent": null, "vector": [2, 0, 0.6143, 0.1524, 0, 0.66, 0.7143, 417, 0, 3, 1, 0, 0, 0, 5], "semantic": {"name": "parse_rst", "arg_names": ["text", "default_reference_context", "thing_being_parsed"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def parse_rst(text, default_reference_context, thing_being_parsed=None):\n \"\"\"\n Convert the string from reST to an XHTML fragment.\n \"\"\"\n overrides = {\n 'doctitle_xform' : True,\n 'inital_header_level' : 3,\n \"default_reference_context\" : default_reference_context,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L58_C4", "label": "expression", "type": "expression", "loc": [58, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L57_C0", "vector": [8, 1, 0.5619, 0.0286, 1, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Convert the string from reST to an XHTML fragment.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L61_C4", "label": "overrides =", "type": "assigned_variable", "loc": [61, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L57_C0", "vector": [14, 1, 0.6048, 0.0571, 1, 0.66, 0.25, 53, 0, 0, 0, 0, 0, 6, 2], "semantic": {"name": "overrides", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " overrides = {\n 'doctitle_xform' : True,\n 'inital_header_level' : 3,\n \"default_reference_context\" : default_reference_context,\n \"link_base\" : reverse('django-admindocs-docroot').rstrip('/')\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L67_C4", "label": "if", "type": "if", "loc": [67, 68], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L57_C0", "vector": [4, 1, 0.6429, 0.019, 1, 0.66, 0.5, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if thing_being_parsed:\n thing_being_parsed = smart_str(\"<%s>\" % thing_being_parsed)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L68_C8", "label": "thing_being_parsed = smart_str()", "type": "assigned_variable", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L67_C4", "vector": [14, 2, 0.6476, 0.0095, 2, 0.68, 0.0, 541, 3, 1, 0, 0, 820, 10, 1], "semantic": {"name": "thing_being_parsed", "arg_names": [], "import_names": [], "rhs_call_name": "smart_str", "annotation": ""}, "snippet": " thing_being_parsed = smart_str(\"<%s>\" % thing_being_parsed)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L69_C4", "label": "parts = publish_parts()", "type": "assigned_variable", "loc": [69, 71], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L57_C0", "vector": [14, 1, 0.6667, 0.0286, 1, 0.66, 0.75, 13, 3, 5, 0, 0, 559, 10, 1], "semantic": {"name": "parts", "arg_names": [], "import_names": [], "rhs_call_name": "publish_parts", "annotation": ""}, "snippet": " parts = docutils.core.publish_parts(text, source_path=thing_being_parsed,\n destination_path=None, writer_name='html',\n settings_overrides=overrides)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Return_L72_C4", "label": "return", "type": "return", "loc": [72, 72], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L57_C0", "vector": [13, 1, 0.6857, 0.0095, 1, 0.66, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(parts['fragment'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L77_C0", "label": "ROLES =", "type": "assigned_variable", "loc": [77, 83], "level": 0, "parent": null, "vector": [14, 0, 0.7619, 0.0667, 0, 0.66, 0.7857, 720, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "ROLES", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "ROLES = {\n 'model' : '%s/models/%s/',\n 'view' : '%s/views/%s/',\n 'template' : '%s/templates/%s/',\n 'filter' : '%s/filters/#%s',\n 'tag' : '%s/tags/#%s',\n}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L85_C0", "label": "create_reference_role", "type": "function", "loc": [85, 91], "level": 0, "parent": null, "vector": [2, 0, 0.8381, 0.0667, 0, 0.66, 0.8571, 971, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "create_reference_role", "arg_names": ["rolename", "urlbase"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def create_reference_role(rolename, urlbase):\n def _role(name, rawtext, text, lineno, inliner, options=None, content=None):\n if options is None: options = {}\n if content is None: content = []\n node = docutils.nodes.reference(rawtext, text, refuri=(urlbase % (inliner.document.settings.link_base, text.lower())), **options)\n return [node], []\n docutils.parsers.rst.roles.register_canonical_role(rolename, _role)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L86_C4", "label": "_role", "type": "function", "loc": [86, 90], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L85_C0", "vector": [2, 1, 0.8381, 0.0476, 1, 0.64, 0.0, 747, 0, 7, 1, 0, 0, 0, 2], "semantic": {"name": "_role", "arg_names": ["name", "rawtext", "text", "lineno", "inliner", "options", "content"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _role(name, rawtext, text, lineno, inliner, options=None, content=None):\n if options is None: options = {}\n if content is None: content = []\n node = docutils.nodes.reference(rawtext, text, refuri=(urlbase % (inliner.document.settings.link_base, text.lower())), **options)\n return [node], []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L87_C8", "label": "if", "type": "if", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L86_C4", "vector": [4, 2, 0.8286, 0.0095, 2, 0.46, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if options is None: options = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L87_C28", "label": "options =", "type": "assigned_variable", "loc": [87, 87], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L87_C8", "vector": [14, 3, 0.8286, 0.0095, 3, 0.91, 0.0, 707, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "options", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if options is None: options = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L88_C8", "label": "if", "type": "if", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L86_C4", "vector": [4, 2, 0.8381, 0.0095, 2, 0.46, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if content is None: content = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L88_C28", "label": "content =", "type": "assigned_variable", "loc": [88, 88], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L88_C8", "vector": [14, 3, 0.8381, 0.0095, 3, 0.2, 0.0, 273, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "content", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if content is None: content = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L89_C8", "label": "node = reference()", "type": "assigned_variable", "loc": [89, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L86_C4", "vector": [14, 2, 0.8476, 0.0095, 2, 0.46, 0.6667, 772, 3, 4, 0, 0, 503, 10, 2], "semantic": {"name": "node", "arg_names": [], "import_names": [], "rhs_call_name": "reference", "annotation": ""}, "snippet": " node = docutils.nodes.reference(rawtext, text, refuri=(urlbase % (inliner.document.settings.link_base, text.lower())), **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Return_L90_C8", "label": "return", "type": "return", "loc": [90, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L86_C4", "vector": [13, 2, 0.8571, 0.0095, 2, 0.46, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [node], []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L91_C4", "label": "register_canonical_role()", "type": "expression", "loc": [91, 91], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L85_C0", "vector": [8, 1, 0.8667, 0.0095, 1, 0.64, 1.0, 278, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "register_canonical_role", "arg_names": [], "import_names": [], "rhs_call_name": "register_canonical_role", "annotation": ""}, "snippet": " docutils.parsers.rst.roles.register_canonical_role(rolename, _role)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L93_C0", "label": "default_reference_role", "type": "function", "loc": [93, 98], "level": 0, "parent": null, "vector": [2, 0, 0.9095, 0.0571, 0, 0.66, 0.9286, 17, 0, 7, 1, 0, 0, 0, 2], "semantic": {"name": "default_reference_role", "arg_names": ["name", "rawtext", "text", "lineno", "inliner", "options", "content"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def default_reference_role(name, rawtext, text, lineno, inliner, options=None, content=None):\n if options is None: options = {}\n if content is None: content = []\n context = inliner.document.settings.default_reference_context\n node = docutils.nodes.reference(rawtext, text, refuri=(ROLES[context] % (inliner.document.settings.link_base, text.lower())), **options)\n return [node], []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L94_C4", "label": "if", "type": "if", "loc": [94, 94], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L93_C0", "vector": [4, 1, 0.8952, 0.0095, 1, 0.99, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if options is None: options = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L94_C24", "label": "options =", "type": "assigned_variable", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L94_C4", "vector": [14, 2, 0.8952, 0.0095, 2, 0.82, 0.0, 707, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "options", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if options is None: options = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L95_C4", "label": "if", "type": "if", "loc": [95, 95], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L93_C0", "vector": [4, 1, 0.9048, 0.0095, 1, 0.99, 0.25, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if content is None: content = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L95_C24", "label": "content =", "type": "assigned_variable", "loc": [95, 95], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L95_C4", "vector": [14, 2, 0.9048, 0.0095, 2, 0.73, 0.0, 273, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "content", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if content is None: content = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L96_C4", "label": "context =", "type": "assigned_variable", "loc": [96, 96], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L93_C0", "vector": [14, 1, 0.9143, 0.0095, 1, 0.99, 0.5, 954, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context = inliner.document.settings.default_reference_context"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L97_C4", "label": "node = reference()", "type": "assigned_variable", "loc": [97, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L93_C0", "vector": [14, 1, 0.9238, 0.0095, 1, 0.99, 0.75, 772, 3, 4, 0, 0, 503, 10, 2], "semantic": {"name": "node", "arg_names": [], "import_names": [], "rhs_call_name": "reference", "annotation": ""}, "snippet": " node = docutils.nodes.reference(rawtext, text, refuri=(ROLES[context] % (inliner.document.settings.link_base, text.lower())), **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Return_L98_C4", "label": "return", "type": "return", "loc": [98, 98], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L93_C0", "vector": [13, 1, 0.9333, 0.0095, 1, 0.99, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [node], []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L100_C0", "label": "if", "type": "if", "loc": [100, 105], "level": 0, "parent": null, "vector": [4, 0, 0.9762, 0.0571, 0, 0.66, 1.0, 0, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if docutils_is_available:\n docutils.parsers.rst.roles.register_canonical_role('cmsreference', default_reference_role)\n docutils.parsers.rst.roles.DEFAULT_INTERPRETED_ROLE = 'cmsreference'\n\n for name, urlbase in ROLES.items():\n create_reference_role(name, urlbase)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L101_C4", "label": "register_canonical_role()", "type": "expression", "loc": [101, 101], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L100_C0", "vector": [8, 1, 0.9619, 0.0095, 1, 0.28, 0.0, 278, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "register_canonical_role", "arg_names": [], "import_names": [], "rhs_call_name": "register_canonical_role", "annotation": ""}, "snippet": " docutils.parsers.rst.roles.register_canonical_role('cmsreference', default_reference_role)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L102_C4", "label": "docutils.parsers.rst.roles.DEFAULT_INTERPRETED_ROLE =", "type": "assigned_variable", "loc": [102, 102], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L100_C0", "vector": [14, 1, 0.9714, 0.0095, 1, 0.28, 0.5, 289, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "docutils.parsers.rst.roles.DEFAULT_INTERPRETED_ROLE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " docutils.parsers.rst.roles.DEFAULT_INTERPRETED_ROLE = 'cmsreference'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:For_L104_C4", "label": "for name, urlbase", "type": "for", "loc": [104, 105], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L100_C0", "vector": [6, 1, 0.9952, 0.019, 1, 0.28, 1.0, 634, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "name, urlbase", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name, urlbase in ROLES.items():\n create_reference_role(name, urlbase)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L105_C8", "label": "create_reference_role()", "type": "expression", "loc": [105, 105], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98630:For_L104_C4", "vector": [8, 2, 1.0, 0.0095, 2, 0.02, 0.0, 971, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "create_reference_role", "arg_names": [], "import_names": [], "rhs_call_name": "create_reference_role", "annotation": ""}, "snippet": " create_reference_role(name, urlbase)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Import_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Import_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Import_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Return_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Return_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L45_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L47_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L48_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:Try_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L51_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L51_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L52_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L51_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L54_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Return_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L58_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L61_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Return_L72_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L85_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L86_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L87_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L87_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L88_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L88_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Return_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L85_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L91_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L93_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L94_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L94_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L93_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L95_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L95_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L95_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L93_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L96_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L93_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L97_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:FunctionDef_L93_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Return_L98_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L100_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L101_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L100_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Assign_L102_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:If_L100_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:For_L104_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98630:For_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98630:Expr_L105_C8"}] |
from django.db import models
from django.utils.translation import ugettext_lazy as _
SITE_CACHE = {}
class SiteManager(models.Manager):
def get_current(self):
"""
Returns the current ``Site`` based on the SITE_ID in the
project's settings. The ``Site`` object is cached the first
time it's retrieved from the database.
"""
from django.conf import settings
try:
sid = settings.SITE_ID
except AttributeError:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured("You're using the Django \"sites framework\" without having set the SITE_ID setting. Create a site in your database and set the SITE_ID setting to fix this error.")
try:
current_site = SITE_CACHE[sid]
except KeyError:
current_site = self.get(pk=sid)
SITE_CACHE[sid] = current_site
return current_site
def clear_cache(self):
"""Clears the ``Site`` object cache."""
global SITE_CACHE
SITE_CACHE = {}
class Site(models.Model):
domain = models.CharField(_('domain name'), max_length=100)
name = models.CharField(_('display name'), max_length=50)
objects = SiteManager()
class Meta:
db_table = 'django_site'
verbose_name = _('site')
verbose_name_plural = _('sites')
ordering = ('domain',)
def __unicode__(self):
return self.domain
def save(self, *args, **kwargs):
super(Site, self).save(*args, **kwargs)
# Cached information will likely be incorrect now.
if self.id in SITE_CACHE:
del SITE_CACHE[self.id]
def delete(self):
pk = self.pk
super(Site, self).delete()
try:
del SITE_CACHE[pk]
except KeyError:
pass
class RequestSite(object):
"""
A class that shares the primary interface of Site (i.e., it has
``domain`` and ``name`` attributes) but gets its data from a Django
HttpRequest object rather than from a database.
The save() and delete() methods raise NotImplementedError.
"""
def __init__(self, request):
self.domain = self.name = request.get_host()
def __unicode__(self):
return self.domain
def save(self, force_insert=False, force_update=False):
raise NotImplementedError('RequestSite cannot be saved.')
def delete(self):
raise NotImplementedError('RequestSite cannot be deleted.')
def get_current_site(request):
"""
Checks if contrib.sites is installed and returns either the current
``Site`` object or a ``RequestSite`` object based on the request.
"""
if Site._meta.installed:
current_site = Site.objects.get_current()
else:
current_site = RequestSite(request)
return current_site
| ajibawa-2023/Python-Code-Large/train/row_98632 | 50 | 95 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98632:ImportFrom_L1_C0", "label": "from django.db import models", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0105, 0.0105, 0, 0.66, 0.0, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:ImportFrom_L2_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0211, 0.0105, 0, 0.66, 0.1667, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext_lazy as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L5_C0", "label": "SITE_CACHE =", "type": "assigned_variable", "loc": [5, 5], "level": 0, "parent": null, "vector": [14, 0, 0.0526, 0.0105, 0, 0.66, 0.3333, 59, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "SITE_CACHE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SITE_CACHE = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L8_C0", "label": "SiteManager", "type": "class", "loc": [8, 32], "level": 0, "parent": null, "vector": [3, 0, 0.2105, 0.2632, 0, 0.66, 0.5, 78, 0, 2, 0, 0, 948, 0, 2], "semantic": {"name": "SiteManager", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SiteManager(models.Manager):\n\n def get_current(self):\n \"\"\"\n Returns the current ``Site`` based on the SITE_ID in the\n project's settings. The ``Site`` object is cached the first\n time it's retrieved from the database.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L10_C4", "label": "get_current", "type": "function", "loc": [10, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L8_C0", "vector": [2, 1, 0.1947, 0.1895, 1, 0.56, 0.0, 632, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "get_current", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_current(self):\n \"\"\"\n Returns the current ``Site`` based on the SITE_ID in the\n project's settings. The ``Site`` object is cached the first\n time it's retrieved from the database.\n \"\"\"\n from django.conf import settings\n try:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Expr_L11_C8", "label": "expression", "type": "expression", "loc": [11, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L10_C4", "vector": [8, 2, 0.1368, 0.0526, 2, 0.4, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns the current ``Site`` based on the SITE_ID in the\n project's settings. The ``Site`` object is cached the first\n time it's retrieved from the database.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:ImportFrom_L16_C8", "label": "from django.conf import settings", "type": "import", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L10_C4", "vector": [1, 2, 0.1684, 0.0105, 2, 0.4, 0.25, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L17_C8", "label": "try", "type": "try", "loc": [17, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L10_C4", "vector": [7, 2, 0.2, 0.0526, 2, 0.4, 0.5, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n sid = settings.SITE_ID\n except AttributeError:\n from django.core.exceptions import ImproperlyConfigured\n raise ImproperlyConfigured(\"You're using the Django \\\"sites framework\\\" without having set the SITE_ID setting. Create a site in your database and set the SITE_ID setting to fix this error.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L18_C12", "label": "sid =", "type": "assigned_variable", "loc": [18, 18], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L17_C8", "vector": [14, 3, 0.1895, 0.0105, 3, 0.54, 0.0, 440, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "sid", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " sid = settings.SITE_ID"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:ImportFrom_L20_C12", "label": "from django.core.exceptions import ImproperlyConfigured", "type": "import", "loc": [20, 20], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L17_C8", "vector": [1, 3, 0.2105, 0.0105, 3, 0.54, 0.0, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["ImproperlyConfigured"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.core.exceptions import ImproperlyConfigured"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L22_C8", "label": "try", "type": "try", "loc": [22, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L10_C4", "vector": [7, 2, 0.2526, 0.0526, 2, 0.4, 0.75, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n current_site = SITE_CACHE[sid]\n except KeyError:\n current_site = self.get(pk=sid)\n SITE_CACHE[sid] = current_site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L23_C12", "label": "current_site =", "type": "assigned_variable", "loc": [23, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L22_C8", "vector": [14, 3, 0.2421, 0.0105, 3, 0.04, 0.0, 725, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "current_site", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " current_site = SITE_CACHE[sid]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L25_C12", "label": "current_site = get()", "type": "assigned_variable", "loc": [25, 25], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L22_C8", "vector": [14, 3, 0.2632, 0.0105, 3, 0.04, 0.0, 725, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "current_site", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " current_site = self.get(pk=sid)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L26_C12", "label": "assign", "type": "assigned_variable", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L22_C8", "vector": [14, 3, 0.2737, 0.0105, 3, 0.04, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " SITE_CACHE[sid] = current_site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Return_L27_C8", "label": "return", "type": "return", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L10_C4", "vector": [13, 2, 0.2842, 0.0105, 2, 0.4, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return current_site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L29_C4", "label": "clear_cache", "type": "function", "loc": [29, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L8_C0", "vector": [2, 1, 0.3211, 0.0421, 1, 0.56, 1.0, 808, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "clear_cache", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clear_cache(self):\n \"\"\"Clears the ``Site`` object cache.\"\"\"\n global SITE_CACHE\n SITE_CACHE = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Expr_L30_C8", "label": "expression", "type": "expression", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L29_C4", "vector": [8, 2, 0.3158, 0.0105, 2, 0.03, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Clears the ``Site`` object cache.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L32_C8", "label": "SITE_CACHE =", "type": "assigned_variable", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L29_C4", "vector": [14, 2, 0.3368, 0.0105, 2, 0.03, 1.0, 59, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "SITE_CACHE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " SITE_CACHE = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "label": "Site", "type": "class", "loc": [35, 62], "level": 0, "parent": null, "vector": [3, 0, 0.5105, 0.2947, 0, 0.66, 0.6667, 695, 0, 3, 0, 0, 996, 0, 11], "semantic": {"name": "Site", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Site(models.Model):\n\n domain = models.CharField(_('domain name'), max_length=100)\n name = models.CharField(_('display name'), max_length=50)\n objects = SiteManager()\n\n class Meta:\n db_table = 'django_site'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L37_C4", "label": "domain = CharField()", "type": "assigned_variable", "loc": [37, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "vector": [14, 1, 0.3895, 0.0105, 1, 0.51, 0.0, 438, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "domain", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " domain = models.CharField(_('domain name'), max_length=100)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L38_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [38, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "vector": [14, 1, 0.4, 0.0105, 1, 0.51, 0.1667, 57, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(_('display name'), max_length=50)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L39_C4", "label": "objects = SiteManager()", "type": "assigned_variable", "loc": [39, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "vector": [14, 1, 0.4105, 0.0105, 1, 0.51, 0.3333, 550, 3, 0, 0, 0, 78, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "SiteManager", "annotation": ""}, "snippet": " objects = SiteManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L41_C4", "label": "Meta", "type": "class", "loc": [41, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "vector": [3, 1, 0.4526, 0.0526, 1, 0.51, 0.5, 130, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "Meta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Meta:\n db_table = 'django_site'\n verbose_name = _('site')\n verbose_name_plural = _('sites')\n ordering = ('domain',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L42_C8", "label": "db_table =", "type": "assigned_variable", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L41_C4", "vector": [14, 2, 0.4421, 0.0105, 2, 0.66, 0.0, 111, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "db_table", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " db_table = 'django_site'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L43_C8", "label": "verbose_name = _()", "type": "assigned_variable", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L41_C4", "vector": [14, 2, 0.4526, 0.0105, 2, 0.66, 0.3333, 616, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "verbose_name", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " verbose_name = _('site')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L44_C8", "label": "verbose_name_plural = _()", "type": "assigned_variable", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L41_C4", "vector": [14, 2, 0.4632, 0.0105, 2, 0.66, 0.6667, 329, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "verbose_name_plural", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " verbose_name_plural = _('sites')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L45_C8", "label": "ordering =", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L41_C4", "vector": [14, 2, 0.4737, 0.0105, 2, 0.66, 1.0, 656, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "ordering", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ordering = ('domain',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L47_C4", "label": "__unicode__", "type": "function", "loc": [47, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "vector": [2, 1, 0.5, 0.0211, 1, 0.51, 0.6667, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return self.domain"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Return_L48_C8", "label": "return", "type": "return", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L47_C4", "vector": [13, 2, 0.5053, 0.0105, 2, 0.6, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.domain"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L50_C4", "label": "save", "type": "function", "loc": [50, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "vector": [2, 1, 0.5474, 0.0526, 1, 0.51, 0.8333, 928, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "save", "arg_names": ["self", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save(self, *args, **kwargs):\n super(Site, self).save(*args, **kwargs)\n # Cached information will likely be incorrect now.\n if self.id in SITE_CACHE:\n del SITE_CACHE[self.id]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Expr_L51_C8", "label": "save()", "type": "expression", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L50_C4", "vector": [8, 2, 0.5368, 0.0105, 2, 0.68, 0.0, 928, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " super(Site, self).save(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:If_L53_C8", "label": "if", "type": "if", "loc": [53, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L50_C4", "vector": [4, 2, 0.5632, 0.0211, 2, 0.68, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.id in SITE_CACHE:\n del SITE_CACHE[self.id]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L56_C4", "label": "delete", "type": "function", "loc": [56, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "vector": [2, 1, 0.6211, 0.0737, 1, 0.51, 1.0, 266, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "delete", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def delete(self):\n pk = self.pk\n super(Site, self).delete()\n try:\n del SITE_CACHE[pk]\n except KeyError:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L57_C8", "label": "pk =", "type": "assigned_variable", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L56_C4", "vector": [14, 2, 0.6, 0.0105, 2, 0.79, 0.0, 164, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "pk", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pk = self.pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Expr_L58_C8", "label": "delete()", "type": "expression", "loc": [58, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L56_C4", "vector": [8, 2, 0.6105, 0.0105, 2, 0.79, 0.5, 266, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " super(Site, self).delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L59_C8", "label": "try", "type": "try", "loc": [59, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L56_C4", "vector": [7, 2, 0.6368, 0.0421, 2, 0.79, 1.0, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n del SITE_CACHE[pk]\n except KeyError:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L65_C0", "label": "RequestSite", "type": "class", "loc": [65, 83], "level": 0, "parent": null, "vector": [3, 0, 0.7789, 0.2, 0, 0.66, 0.8333, 14, 0, 4, 0, 0, 186, 0, 3], "semantic": {"name": "RequestSite", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RequestSite(object):\n \"\"\"\n A class that shares the primary interface of Site (i.e., it has\n ``domain`` and ``name`` attributes) but gets its data from a Django\n HttpRequest object rather than from a database.\n\n The save() and delete() methods raise NotImplementedError.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Expr_L66_C4", "label": "expression", "type": "expression", "loc": [66, 72], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L65_C0", "vector": [8, 1, 0.7263, 0.0737, 1, 0.65, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A class that shares the primary interface of Site (i.e., it has\n ``domain`` and ``name`` attributes) but gets its data from a Django\n HttpRequest object rather than from a database.\n\n The save() and delete() methods raise NotImplementedError.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L73_C4", "label": "__init__", "type": "function", "loc": [73, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L65_C0", "vector": [2, 1, 0.7737, 0.0211, 1, 0.65, 0.25, 555, 0, 2, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, request):\n self.domain = self.name = request.get_host()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L74_C8", "label": "self.domain = get_host()", "type": "assigned_variable", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L73_C4", "vector": [14, 2, 0.7789, 0.0105, 2, 0.66, 0.0, 208, 3, 0, 0, 0, 946, 10, 1], "semantic": {"name": "self.domain", "arg_names": [], "import_names": [], "rhs_call_name": "get_host", "annotation": ""}, "snippet": " self.domain = self.name = request.get_host()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L76_C4", "label": "__unicode__", "type": "function", "loc": [76, 77], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L65_C0", "vector": [2, 1, 0.8053, 0.0211, 1, 0.65, 0.5, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return self.domain"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Return_L77_C8", "label": "return", "type": "return", "loc": [77, 77], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L76_C4", "vector": [13, 2, 0.8105, 0.0105, 2, 0.95, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.domain"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L79_C4", "label": "save", "type": "function", "loc": [79, 80], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L65_C0", "vector": [2, 1, 0.8368, 0.0211, 1, 0.65, 0.75, 928, 0, 3, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": ["self", "force_insert", "force_update"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save(self, force_insert=False, force_update=False):\n raise NotImplementedError('RequestSite cannot be saved.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L82_C4", "label": "delete", "type": "function", "loc": [82, 83], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L65_C0", "vector": [2, 1, 0.8684, 0.0211, 1, 0.65, 1.0, 266, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def delete(self):\n raise NotImplementedError('RequestSite cannot be deleted.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L86_C0", "label": "get_current_site", "type": "function", "loc": [86, 95], "level": 0, "parent": null, "vector": [2, 0, 0.9526, 0.1053, 0, 0.66, 1.0, 760, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "get_current_site", "arg_names": ["request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_current_site(request):\n \"\"\"\n Checks if contrib.sites is installed and returns either the current\n ``Site`` object or a ``RequestSite`` object based on the request.\n \"\"\"\n if Site._meta.installed:\n current_site = Site.objects.get_current()\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Expr_L87_C4", "label": "expression", "type": "expression", "loc": [87, 90], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L86_C0", "vector": [8, 1, 0.9316, 0.0421, 1, 0.97, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Checks if contrib.sites is installed and returns either the current\n ``Site`` object or a ``RequestSite`` object based on the request.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:If_L91_C4", "label": "if", "type": "if", "loc": [91, 94], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L86_C0", "vector": [4, 1, 0.9737, 0.0421, 1, 0.97, 0.5, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if Site._meta.installed:\n current_site = Site.objects.get_current()\n else:\n current_site = RequestSite(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L92_C8", "label": "current_site = get_current()", "type": "assigned_variable", "loc": [92, 92], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:If_L91_C4", "vector": [14, 2, 0.9684, 0.0105, 2, 0.6, 0.0, 725, 3, 0, 0, 0, 632, 10, 1], "semantic": {"name": "current_site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current", "annotation": ""}, "snippet": " current_site = Site.objects.get_current()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L94_C8", "label": "current_site = RequestSite()", "type": "assigned_variable", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:If_L91_C4", "vector": [14, 2, 0.9895, 0.0105, 2, 0.6, 1.0, 725, 3, 1, 0, 0, 14, 10, 1], "semantic": {"name": "current_site", "arg_names": [], "import_names": [], "rhs_call_name": "RequestSite", "annotation": ""}, "snippet": " current_site = RequestSite(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98632:Return_L95_C4", "label": "return", "type": "return", "loc": [95, 95], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L86_C0", "vector": [13, 1, 1.0, 0.0105, 1, 0.97, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return current_site"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Expr_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:ImportFrom_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L17_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L18_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L17_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:ImportFrom_L20_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L23_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L25_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Return_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Expr_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L47_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Return_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Expr_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:If_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Expr_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Try_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L65_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Expr_L66_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L65_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L73_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L73_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L65_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L76_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Return_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L65_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L79_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:ClassDef_L65_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L82_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L86_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Expr_L87_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L86_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:If_L91_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:If_L91_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L92_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:If_L91_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Assign_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98632:FunctionDef_L86_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98632:Return_L95_C4"}] |
from django.conf import settings
from django.contrib.sites.models import Site, RequestSite, get_current_site
from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpRequest
from django.test import TestCase
class SitesFrameworkTests(TestCase):
def setUp(self):
Site(id=settings.SITE_ID, domain="example.com", name="example.com").save()
self.old_Site_meta_installed = Site._meta.installed
Site._meta.installed = True
def tearDown(self):
Site._meta.installed = self.old_Site_meta_installed
def test_site_manager(self):
# Make sure that get_current() does not return a deleted Site object.
s = Site.objects.get_current()
self.assert_(isinstance(s, Site))
s.delete()
self.assertRaises(ObjectDoesNotExist, Site.objects.get_current)
def test_site_cache(self):
# After updating a Site object (e.g. via the admin), we shouldn't return a
# bogus value from the SITE_CACHE.
site = Site.objects.get_current()
self.assertEqual(u"example.com", site.name)
s2 = Site.objects.get(id=settings.SITE_ID)
s2.name = "Example site"
s2.save()
site = Site.objects.get_current()
self.assertEqual(u"Example site", site.name)
def test_get_current_site(self):
# Test that the correct Site object is returned
request = HttpRequest()
request.META = {
"SERVER_NAME": "example.com",
"SERVER_PORT": "80",
}
site = get_current_site(request)
self.assert_(isinstance(site, Site))
self.assertEqual(site.id, settings.SITE_ID)
# Test that an exception is raised if the sites framework is installed
# but there is no matching Site
site.delete()
self.assertRaises(ObjectDoesNotExist, get_current_site, request)
# A RequestSite is returned if the sites framework is not installed
Site._meta.installed = False
site = get_current_site(request)
self.assert_(isinstance(site, RequestSite))
self.assertEqual(site.name, u"example.com")
| ajibawa-2023/Python-Code-Large/train/row_98633 | 37 | 56 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98633:ImportFrom_L1_C0", "label": "from django.conf import settings", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0179, 0.0179, 0, 0.66, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:ImportFrom_L2_C0", "label": "from django.contrib.sites.models import Site, RequestSite, get_current_site", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0357, 0.0179, 0, 0.66, 0.2, 890, 0, 3, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sites.models", "arg_names": [], "import_names": ["Site", "RequestSite", "get_current_site"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sites.models import Site, RequestSite, get_current_site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:ImportFrom_L3_C0", "label": "from django.core.exceptions import ObjectDoesNotExist", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0536, 0.0179, 0, 0.66, 0.4, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["ObjectDoesNotExist"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import ObjectDoesNotExist"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:ImportFrom_L4_C0", "label": "from django.http import HttpRequest", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0714, 0.0179, 0, 0.66, 0.6, 779, 0, 1, 0, 0, 779, 0, 0], "semantic": {"name": "django.http", "arg_names": [], "import_names": ["HttpRequest"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.http import HttpRequest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:ImportFrom_L5_C0", "label": "from django.test import TestCase", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0893, 0.0179, 0, 0.66, 0.8, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.test", "arg_names": [], "import_names": ["TestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.test import TestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:ClassDef_L8_C0", "label": "SitesFrameworkTests", "type": "class", "loc": [8, 56], "level": 0, "parent": null, "vector": [3, 0, 0.5714, 0.875, 0, 0.66, 1.0, 61, 0, 5, 0, 0, 3, 0, 24], "semantic": {"name": "SitesFrameworkTests", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SitesFrameworkTests(TestCase):\n\n def setUp(self):\n Site(id=settings.SITE_ID, domain=\"example.com\", name=\"example.com\").save()\n self.old_Site_meta_installed = Site._meta.installed\n Site._meta.installed = True\n\n def tearDown(self):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L10_C4", "label": "setUp", "type": "function", "loc": [10, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:ClassDef_L8_C0", "vector": [2, 1, 0.2054, 0.0714, 1, 0.42, 0.0, 952, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "setUp", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def setUp(self):\n Site(id=settings.SITE_ID, domain=\"example.com\", name=\"example.com\").save()\n self.old_Site_meta_installed = Site._meta.installed\n Site._meta.installed = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L11_C8", "label": "save()", "type": "expression", "loc": [11, 11], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L10_C4", "vector": [8, 2, 0.1964, 0.0179, 2, 0.81, 0.0, 928, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " Site(id=settings.SITE_ID, domain=\"example.com\", name=\"example.com\").save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L12_C8", "label": "self.old_Site_meta_installed =", "type": "assigned_variable", "loc": [12, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L10_C4", "vector": [14, 2, 0.2143, 0.0179, 2, 0.81, 0.5, 681, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.old_Site_meta_installed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.old_Site_meta_installed = Site._meta.installed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L13_C8", "label": "Site._meta.installed =", "type": "assigned_variable", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L10_C4", "vector": [14, 2, 0.2321, 0.0179, 2, 0.81, 1.0, 863, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "Site._meta.installed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " Site._meta.installed = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L15_C4", "label": "tearDown", "type": "function", "loc": [15, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:ClassDef_L8_C0", "vector": [2, 1, 0.2768, 0.0357, 1, 0.42, 0.25, 530, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "tearDown", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def tearDown(self):\n Site._meta.installed = self.old_Site_meta_installed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L16_C8", "label": "Site._meta.installed =", "type": "assigned_variable", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L15_C4", "vector": [14, 2, 0.2857, 0.0179, 2, 0.86, 0.0, 863, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "Site._meta.installed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " Site._meta.installed = self.old_Site_meta_installed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L18_C4", "label": "test_site_manager", "type": "function", "loc": [18, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:ClassDef_L8_C0", "vector": [2, 1, 0.3661, 0.1071, 1, 0.42, 0.5, 670, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_site_manager", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_site_manager(self):\n # Make sure that get_current() does not return a deleted Site object.\n s = Site.objects.get_current()\n self.assert_(isinstance(s, Site))\n s.delete()\n self.assertRaises(ObjectDoesNotExist, Site.objects.get_current)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L20_C8", "label": "s = get_current()", "type": "assigned_variable", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L18_C4", "vector": [14, 2, 0.3571, 0.0179, 2, 0.05, 0.0, 553, 3, 0, 0, 0, 632, 10, 1], "semantic": {"name": "s", "arg_names": [], "import_names": [], "rhs_call_name": "get_current", "annotation": ""}, "snippet": " s = Site.objects.get_current()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L21_C8", "label": "assert_()", "type": "expression", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L18_C4", "vector": [8, 2, 0.375, 0.0179, 2, 0.05, 0.3333, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(isinstance(s, Site))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L22_C8", "label": "delete()", "type": "expression", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L18_C4", "vector": [8, 2, 0.3929, 0.0179, 2, 0.05, 0.6667, 266, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " s.delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L23_C8", "label": "assertRaises()", "type": "expression", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L18_C4", "vector": [8, 2, 0.4107, 0.0179, 2, 0.05, 1.0, 11, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ObjectDoesNotExist, Site.objects.get_current)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "label": "test_site_cache", "type": "function", "loc": [25, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:ClassDef_L8_C0", "vector": [2, 1, 0.5268, 0.1786, 1, 0.42, 0.75, 176, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_site_cache", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_site_cache(self):\n # After updating a Site object (e.g. via the admin), we shouldn't return a\n # bogus value from the SITE_CACHE.\n site = Site.objects.get_current()\n self.assertEqual(u\"example.com\", site.name)\n s2 = Site.objects.get(id=settings.SITE_ID)\n s2.name = \"Example site\"\n s2.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L28_C8", "label": "site = get_current()", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "vector": [14, 2, 0.5, 0.0179, 2, 0.82, 0.0, 681, 3, 0, 0, 0, 632, 10, 1], "semantic": {"name": "site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current", "annotation": ""}, "snippet": " site = Site.objects.get_current()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L29_C8", "label": "assertEqual()", "type": "expression", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "vector": [8, 2, 0.5179, 0.0179, 2, 0.82, 0.1667, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(u\"example.com\", site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L30_C8", "label": "s2 = get()", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "vector": [14, 2, 0.5357, 0.0179, 2, 0.82, 0.3333, 448, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "s2", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " s2 = Site.objects.get(id=settings.SITE_ID)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L31_C8", "label": "s2.name =", "type": "assigned_variable", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "vector": [14, 2, 0.5536, 0.0179, 2, 0.82, 0.5, 961, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "s2.name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " s2.name = \"Example site\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L32_C8", "label": "save()", "type": "expression", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "vector": [8, 2, 0.5714, 0.0179, 2, 0.82, 0.6667, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " s2.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L33_C8", "label": "site = get_current()", "type": "assigned_variable", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "vector": [14, 2, 0.5893, 0.0179, 2, 0.82, 0.8333, 681, 3, 0, 0, 0, 632, 10, 1], "semantic": {"name": "site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current", "annotation": ""}, "snippet": " site = Site.objects.get_current()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L34_C8", "label": "assertEqual()", "type": "expression", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "vector": [8, 2, 0.6071, 0.0179, 2, 0.82, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(u\"Example site\", site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "label": "test_get_current_site", "type": "function", "loc": [36, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:ClassDef_L8_C0", "vector": [2, 1, 0.8214, 0.375, 1, 0.42, 1.0, 64, 0, 1, 0, 0, 0, 0, 11], "semantic": {"name": "test_get_current_site", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_get_current_site(self):\n # Test that the correct Site object is returned\n request = HttpRequest()\n request.META = {\n \"SERVER_NAME\": \"example.com\",\n \"SERVER_PORT\": \"80\",\n }\n site = get_current_site(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L38_C8", "label": "request = HttpRequest()", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "vector": [14, 2, 0.6786, 0.0179, 2, 0.69, 0.0, 50, 3, 0, 0, 0, 159, 10, 1], "semantic": {"name": "request", "arg_names": [], "import_names": [], "rhs_call_name": "HttpRequest", "annotation": ""}, "snippet": " request = HttpRequest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L39_C8", "label": "request.META =", "type": "assigned_variable", "loc": [39, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "vector": [14, 2, 0.7232, 0.0714, 2, 0.69, 0.1, 65, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "request.META", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " request.META = {\n \"SERVER_NAME\": \"example.com\",\n \"SERVER_PORT\": \"80\",\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L43_C8", "label": "site = get_current_site()", "type": "assigned_variable", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "vector": [14, 2, 0.7679, 0.0179, 2, 0.69, 0.2, 681, 3, 1, 0, 0, 760, 10, 1], "semantic": {"name": "site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current_site", "annotation": ""}, "snippet": " site = get_current_site(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L44_C8", "label": "assert_()", "type": "expression", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "vector": [8, 2, 0.7857, 0.0179, 2, 0.69, 0.3, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(isinstance(site, Site))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L45_C8", "label": "assertEqual()", "type": "expression", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "vector": [8, 2, 0.8036, 0.0179, 2, 0.69, 0.4, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(site.id, settings.SITE_ID)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L49_C8", "label": "delete()", "type": "expression", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "vector": [8, 2, 0.875, 0.0179, 2, 0.69, 0.5, 266, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " site.delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L50_C8", "label": "assertRaises()", "type": "expression", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "vector": [8, 2, 0.8929, 0.0179, 2, 0.69, 0.6, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ObjectDoesNotExist, get_current_site, request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L53_C8", "label": "Site._meta.installed =", "type": "assigned_variable", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "vector": [14, 2, 0.9464, 0.0179, 2, 0.69, 0.7, 863, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "Site._meta.installed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " Site._meta.installed = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L54_C8", "label": "site = get_current_site()", "type": "assigned_variable", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "vector": [14, 2, 0.9643, 0.0179, 2, 0.69, 0.8, 681, 3, 1, 0, 0, 760, 10, 1], "semantic": {"name": "site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current_site", "annotation": ""}, "snippet": " site = get_current_site(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L55_C8", "label": "assert_()", "type": "expression", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "vector": [8, 2, 0.9821, 0.0179, 2, 0.69, 0.9, 17, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assert_", "arg_names": [], "import_names": [], "rhs_call_name": "assert_", "annotation": ""}, "snippet": " self.assert_(isinstance(site, RequestSite))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L56_C8", "label": "assertEqual()", "type": "expression", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "vector": [8, 2, 1.0, 0.0179, 2, 0.69, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(site.name, u\"example.com\")"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98633:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Assign_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98633:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98633:Expr_L56_C8"}] |
from django.conf import settings
from django.db import models
from django.db.models.fields import FieldDoesNotExist
class CurrentSiteManager(models.Manager):
"Use this to limit objects to those associated with the current site."
def __init__(self, field_name=None):
super(CurrentSiteManager, self).__init__()
self.__field_name = field_name
self.__is_validated = False
def _validate_field_name(self):
field_names = self.model._meta.get_all_field_names()
# If a custom name is provided, make sure the field exists on the model
if self.__field_name is not None and self.__field_name not in field_names:
raise ValueError("%s couldn't find a field named %s in %s." % \
(self.__class__.__name__, self.__field_name, self.model._meta.object_name))
# Otherwise, see if there is a field called either 'site' or 'sites'
else:
for potential_name in ['site', 'sites']:
if potential_name in field_names:
self.__field_name = potential_name
self.__is_validated = True
break
# Now do a type check on the field (FK or M2M only)
try:
field = self.model._meta.get_field(self.__field_name)
if not isinstance(field, (models.ForeignKey, models.ManyToManyField)):
raise TypeError("%s must be a ForeignKey or ManyToManyField." %self.__field_name)
except FieldDoesNotExist:
raise ValueError("%s couldn't find a field named %s in %s." % \
(self.__class__.__name__, self.__field_name, self.model._meta.object_name))
self.__is_validated = True
def get_query_set(self):
if not self.__is_validated:
self._validate_field_name()
return super(CurrentSiteManager, self).get_query_set().filter(**{self.__field_name + '__id__exact': settings.SITE_ID})
| ajibawa-2023/Python-Code-Large/train/row_98634 | 24 | 41 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98634:ImportFrom_L1_C0", "label": "from django.conf import settings", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0244, 0.0244, 0, 0.66, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:ImportFrom_L2_C0", "label": "from django.db import models", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0488, 0.0244, 0, 0.66, 0.3333, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:ImportFrom_L3_C0", "label": "from django.db.models.fields import FieldDoesNotExist", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0732, 0.0244, 0, 0.66, 0.6667, 5, 0, 1, 0, 0, 5, 0, 0], "semantic": {"name": "django.db.models.fields", "arg_names": [], "import_names": ["FieldDoesNotExist"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models.fields import FieldDoesNotExist"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:ClassDef_L5_C0", "label": "CurrentSiteManager", "type": "class", "loc": [5, 41], "level": 0, "parent": null, "vector": [3, 0, 0.561, 0.9024, 0, 0.66, 1.0, 18, 0, 3, 0, 0, 948, 0, 12], "semantic": {"name": "CurrentSiteManager", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CurrentSiteManager(models.Manager):\n \"Use this to limit objects to those associated with the current site.\"\n def __init__(self, field_name=None):\n super(CurrentSiteManager, self).__init__()\n self.__field_name = field_name\n self.__is_validated = False\n \n def _validate_field_name(self):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:Expr_L6_C4", "label": "expression", "type": "expression", "loc": [6, 6], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:ClassDef_L5_C0", "vector": [8, 1, 0.1463, 0.0244, 1, 0.86, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Use this to limit objects to those associated with the current site.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L7_C4", "label": "__init__", "type": "function", "loc": [7, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:ClassDef_L5_C0", "vector": [2, 1, 0.2073, 0.0976, 1, 0.86, 0.3333, 555, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "field_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, field_name=None):\n super(CurrentSiteManager, self).__init__()\n self.__field_name = field_name\n self.__is_validated = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:Expr_L8_C8", "label": "__init__()", "type": "expression", "loc": [8, 8], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L7_C4", "vector": [8, 2, 0.1951, 0.0244, 2, 0.03, 0.0, 555, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(CurrentSiteManager, self).__init__()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L9_C8", "label": "self.__field_name =", "type": "assigned_variable", "loc": [9, 9], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L7_C4", "vector": [14, 2, 0.2195, 0.0244, 2, 0.03, 0.5, 837, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.__field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.__field_name = field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L10_C8", "label": "self.__is_validated =", "type": "assigned_variable", "loc": [10, 10], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L7_C4", "vector": [14, 2, 0.2439, 0.0244, 2, 0.03, 1.0, 157, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self.__is_validated", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.__is_validated = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L12_C4", "label": "_validate_field_name", "type": "function", "loc": [12, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:ClassDef_L5_C0", "vector": [2, 1, 0.5854, 0.6098, 1, 0.86, 0.6667, 440, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "_validate_field_name", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _validate_field_name(self):\n field_names = self.model._meta.get_all_field_names()\n \n # If a custom name is provided, make sure the field exists on the model\n if self.__field_name is not None and self.__field_name not in field_names:\n raise ValueError(\"%s couldn't find a field named %s in %s.\" % \\\n (self.__class__.__name__, self.__field_name, self.model._meta.object_name))\n "}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L13_C8", "label": "field_names = get_all_field_names()", "type": "assigned_variable", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L12_C4", "vector": [14, 2, 0.3171, 0.0244, 2, 0.18, 0.0, 723, 3, 0, 0, 0, 732, 10, 1], "semantic": {"name": "field_names", "arg_names": [], "import_names": [], "rhs_call_name": "get_all_field_names", "annotation": ""}, "snippet": " field_names = self.model._meta.get_all_field_names()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L16_C8", "label": "if", "type": "if", "loc": [16, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L12_C4", "vector": [4, 2, 0.5122, 0.2683, 2, 0.18, 0.3333, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.__field_name is not None and self.__field_name not in field_names:\n raise ValueError(\"%s couldn't find a field named %s in %s.\" % \\\n (self.__class__.__name__, self.__field_name, self.model._meta.object_name))\n \n # Otherwise, see if there is a field called either 'site' or 'sites'\n else:\n for potential_name in ['site', 'sites']:\n if potential_name in field_names:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:For_L22_C12", "label": "for potential_name", "type": "for", "loc": [22, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L16_C8", "vector": [6, 3, 0.5854, 0.122, 3, 0.81, 0.0, 191, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "potential_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for potential_name in ['site', 'sites']:\n if potential_name in field_names:\n self.__field_name = potential_name\n self.__is_validated = True\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L23_C16", "label": "if", "type": "if", "loc": [23, 26], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:For_L22_C12", "vector": [4, 4, 0.5976, 0.0976, 4, 0.4, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if potential_name in field_names:\n self.__field_name = potential_name\n self.__is_validated = True\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L24_C20", "label": "self.__field_name =", "type": "assigned_variable", "loc": [24, 24], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L23_C16", "vector": [14, 5, 0.5854, 0.0244, 5, 0.35, 0.0, 837, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.__field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.__field_name = potential_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L25_C20", "label": "self.__is_validated =", "type": "assigned_variable", "loc": [25, 25], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L23_C16", "vector": [14, 5, 0.6098, 0.0244, 5, 0.35, 1.0, 157, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self.__is_validated", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.__is_validated = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:Try_L29_C8", "label": "try", "type": "try", "loc": [29, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L12_C4", "vector": [7, 2, 0.7805, 0.1707, 2, 0.18, 0.6667, 0, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n field = self.model._meta.get_field(self.__field_name)\n if not isinstance(field, (models.ForeignKey, models.ManyToManyField)):\n raise TypeError(\"%s must be a ForeignKey or ManyToManyField.\" %self.__field_name)\n except FieldDoesNotExist:\n raise ValueError(\"%s couldn't find a field named %s in %s.\" % \\\n (self.__class__.__name__, self.__field_name, self.model._meta.object_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L30_C12", "label": "field = get_field()", "type": "assigned_variable", "loc": [30, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:Try_L29_C8", "vector": [14, 3, 0.7317, 0.0244, 3, 0.42, 0.0, 480, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " field = self.model._meta.get_field(self.__field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L31_C12", "label": "if", "type": "if", "loc": [31, 32], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:Try_L29_C8", "vector": [4, 3, 0.7683, 0.0488, 3, 0.42, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(field, (models.ForeignKey, models.ManyToManyField)):\n raise TypeError(\"%s must be a ForeignKey or ManyToManyField.\" %self.__field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L36_C8", "label": "self.__is_validated =", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L12_C4", "vector": [14, 2, 0.878, 0.0244, 2, 0.18, 1.0, 157, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self.__is_validated", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.__is_validated = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L38_C4", "label": "get_query_set", "type": "function", "loc": [38, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:ClassDef_L5_C0", "vector": [2, 1, 0.9634, 0.0976, 1, 0.86, 1.0, 696, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "get_query_set", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_query_set(self):\n if not self.__is_validated:\n self._validate_field_name()\n return super(CurrentSiteManager, self).get_query_set().filter(**{self.__field_name + '__id__exact': settings.SITE_ID})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L39_C8", "label": "if", "type": "if", "loc": [39, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L38_C4", "vector": [4, 2, 0.9634, 0.0488, 2, 0.99, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.__is_validated:\n self._validate_field_name()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:Expr_L40_C12", "label": "_validate_field_name()", "type": "expression", "loc": [40, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L39_C8", "vector": [8, 3, 0.9756, 0.0244, 3, 0.71, 0.0, 440, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "_validate_field_name", "arg_names": [], "import_names": [], "rhs_call_name": "_validate_field_name", "annotation": ""}, "snippet": " self._validate_field_name()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98634:Return_L41_C8", "label": "return", "type": "return", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L38_C4", "vector": [13, 2, 1.0, 0.0244, 2, 0.99, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return super(CurrentSiteManager, self).get_query_set().filter(**{self.__field_name + '__id__exact': settings.SITE_ID})"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98634:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:Expr_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:Expr_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L16_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:For_L22_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:For_L22_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L23_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L23_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L24_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L23_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L25_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:Try_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:Try_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:Try_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L31_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L38_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:If_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:Expr_L40_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98634:FunctionDef_L38_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98634:Return_L41_C8"}] |
from django.contrib import admin
from django.contrib.sites.models import Site
class SiteAdmin(admin.ModelAdmin):
list_display = ('domain', 'name')
search_fields = ('domain', 'name')
admin.site.register(Site, SiteAdmin) | ajibawa-2023/Python-Code-Large/train/row_98635 | 6 | 9 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98635:ImportFrom_L1_C0", "label": "from django.contrib import admin", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.1111, 0.1111, 0, 0.66, 0.0, 302, 0, 1, 0, 0, 302, 0, 0], "semantic": {"name": "django.contrib", "arg_names": [], "import_names": ["admin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib import admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98635:ImportFrom_L2_C0", "label": "from django.contrib.sites.models import Site", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.2222, 0.1111, 0, 0.66, 0.3333, 890, 0, 1, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sites.models", "arg_names": [], "import_names": ["Site"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sites.models import Site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98635:ClassDef_L5_C0", "label": "SiteAdmin", "type": "class", "loc": [5, 7], "level": 0, "parent": null, "vector": [3, 0, 0.6667, 0.3333, 0, 0.66, 0.6667, 927, 0, 0, 0, 0, 823, 0, 0], "semantic": {"name": "SiteAdmin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SiteAdmin(admin.ModelAdmin):\n list_display = ('domain', 'name')\n search_fields = ('domain', 'name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98635:Assign_L6_C4", "label": "list_display =", "type": "assigned_variable", "loc": [6, 6], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98635:ClassDef_L5_C0", "vector": [14, 1, 0.6667, 0.1111, 1, 0.45, 0.0, 489, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "list_display", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_display = ('domain', 'name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98635:Assign_L7_C4", "label": "search_fields =", "type": "assigned_variable", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98635:ClassDef_L5_C0", "vector": [14, 1, 0.7778, 0.1111, 1, 0.45, 1.0, 834, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "search_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " search_fields = ('domain', 'name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98635:Expr_L9_C0", "label": "register()", "type": "expression", "loc": [9, 9], "level": 0, "parent": null, "vector": [8, 0, 1.0, 0.1111, 0, 0.66, 1.0, 276, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "register", "annotation": ""}, "snippet": "admin.site.register(Site, SiteAdmin)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98635:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98635:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98635:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98635:Assign_L7_C4"}] |
"""
Creates the default Site object.
"""
from django.db.models import signals
from django.contrib.sites.models import Site
from django.contrib.sites import models as site_app
def create_default_site(app, created_models, verbosity, db, **kwargs):
if Site in created_models:
if verbosity >= 2:
print "Creating example.com Site object"
s = Site(domain="example.com", name="example.com")
s.save(using=db)
Site.objects.clear_cache()
signals.post_syncdb.connect(create_default_site, sender=site_app)
| ajibawa-2023/Python-Code-Large/train/row_98636 | 12 | 17 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98636:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.1176, 0.1765, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nCreates the default Site object.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98636:ImportFrom_L5_C0", "label": "from django.db.models import signals", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.2941, 0.0588, 0, 0.66, 0.2, 680, 0, 1, 0, 0, 680, 0, 0], "semantic": {"name": "django.db.models", "arg_names": [], "import_names": ["signals"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models import signals"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98636:ImportFrom_L6_C0", "label": "from django.contrib.sites.models import Site", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.3529, 0.0588, 0, 0.66, 0.4, 890, 0, 1, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sites.models", "arg_names": [], "import_names": ["Site"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sites.models import Site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98636:ImportFrom_L7_C0", "label": "from django.contrib.sites import site_app", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.4118, 0.0588, 0, 0.66, 0.6, 5, 0, 1, 0, 0, 5, 0, 0], "semantic": {"name": "django.contrib.sites", "arg_names": [], "import_names": ["site_app"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sites import models as site_app"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98636:FunctionDef_L9_C0", "label": "create_default_site", "type": "function", "loc": [9, 15], "level": 0, "parent": null, "vector": [2, 0, 0.7059, 0.4118, 0, 0.66, 0.8, 811, 0, 5, 0, 0, 0, 0, 4], "semantic": {"name": "create_default_site", "arg_names": ["app", "created_models", "verbosity", "db", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def create_default_site(app, created_models, verbosity, db, **kwargs):\n if Site in created_models:\n if verbosity >= 2:\n print(\"Creating example.com Site object\")\n s = Site(domain=\"example.com\", name=\"example.com\")\n s.save(using=db)\n Site.objects.clear_cache()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98636:If_L10_C4", "label": "if", "type": "if", "loc": [10, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98636:FunctionDef_L9_C0", "vector": [4, 1, 0.7059, 0.2941, 1, 0.58, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if Site in created_models:\n if verbosity >= 2:\n print(\"Creating example.com Site object\")\n s = Site(domain=\"example.com\", name=\"example.com\")\n s.save(using=db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98636:If_L11_C8", "label": "if", "type": "if", "loc": [11, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98636:If_L10_C4", "vector": [4, 2, 0.6765, 0.1176, 2, 0.43, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if verbosity >= 2:\n print(\"Creating example.com Site object\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98636:Expr_L12_C12", "label": "print()", "type": "expression", "loc": [12, 12], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98636:If_L11_C8", "vector": [8, 3, 0.7059, 0.0588, 3, 0.36, 0.0, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\"Creating example.com Site object\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98636:Assign_L13_C8", "label": "s = Site()", "type": "assigned_variable", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98636:If_L10_C4", "vector": [14, 2, 0.7647, 0.0588, 2, 0.43, 0.5, 553, 3, 2, 0, 0, 695, 10, 1], "semantic": {"name": "s", "arg_names": [], "import_names": [], "rhs_call_name": "Site", "annotation": ""}, "snippet": " s = Site(domain=\"example.com\", name=\"example.com\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98636:Expr_L14_C8", "label": "save()", "type": "expression", "loc": [14, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98636:If_L10_C4", "vector": [8, 2, 0.8235, 0.0588, 2, 0.43, 1.0, 928, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " s.save(using=db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98636:Expr_L15_C4", "label": "clear_cache()", "type": "expression", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98636:FunctionDef_L9_C0", "vector": [8, 1, 0.8824, 0.0588, 1, 0.58, 1.0, 808, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "clear_cache", "arg_names": [], "import_names": [], "rhs_call_name": "clear_cache", "annotation": ""}, "snippet": " Site.objects.clear_cache()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98636:Expr_L17_C0", "label": "connect()", "type": "expression", "loc": [17, 17], "level": 0, "parent": null, "vector": [8, 0, 1.0, 0.0588, 0, 0.66, 1.0, 242, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "connect", "arg_names": [], "import_names": [], "rhs_call_name": "connect", "annotation": ""}, "snippet": "signals.post_syncdb.connect(create_default_site, sender=site_app)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98636:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98636:If_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98636:If_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98636:If_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98636:If_L11_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98636:Expr_L12_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98636:If_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98636:Assign_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98636:If_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98636:Expr_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98636:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98636:Expr_L15_C4"}] |
from django.contrib.admin.filterspecs import FilterSpec
from django.contrib.admin.options import IncorrectLookupParameters
from django.contrib.admin.util import quote
from django.core.paginator import Paginator, InvalidPage
from django.db import models
from django.utils.encoding import force_unicode, smart_str
from django.utils.translation import ugettext
from django.utils.http import urlencode
import operator
# The system will display a "Show all" link on the change list only if the
# total result count is less than or equal to this setting.
MAX_SHOW_ALL_ALLOWED = 200
# Changelist settings
ALL_VAR = 'all'
ORDER_VAR = 'o'
ORDER_TYPE_VAR = 'ot'
PAGE_VAR = 'p'
SEARCH_VAR = 'q'
TO_FIELD_VAR = 't'
IS_POPUP_VAR = 'pop'
ERROR_FLAG = 'e'
# Text to display within change-list table cells if the value is blank.
EMPTY_CHANGELIST_VALUE = '(None)'
class ChangeList(object):
def __init__(self, request, model, list_display, list_display_links, list_filter, date_hierarchy, search_fields, list_select_related, list_per_page, list_editable, model_admin):
self.model = model
self.opts = model._meta
self.lookup_opts = self.opts
self.root_query_set = model_admin.queryset(request)
self.list_display = list_display
self.list_display_links = list_display_links
self.list_filter = list_filter
self.date_hierarchy = date_hierarchy
self.search_fields = search_fields
self.list_select_related = list_select_related
self.list_per_page = list_per_page
self.list_editable = list_editable
self.model_admin = model_admin
# Get search parameters from the query string.
try:
self.page_num = int(request.GET.get(PAGE_VAR, 0))
except ValueError:
self.page_num = 0
self.show_all = ALL_VAR in request.GET
self.is_popup = IS_POPUP_VAR in request.GET
self.to_field = request.GET.get(TO_FIELD_VAR)
self.params = dict(request.GET.items())
if PAGE_VAR in self.params:
del self.params[PAGE_VAR]
if TO_FIELD_VAR in self.params:
del self.params[TO_FIELD_VAR]
if ERROR_FLAG in self.params:
del self.params[ERROR_FLAG]
self.order_field, self.order_type = self.get_ordering()
self.query = request.GET.get(SEARCH_VAR, '')
self.query_set = self.get_query_set()
self.get_results(request)
self.title = (self.is_popup and ugettext('Select %s') % force_unicode(self.opts.verbose_name) or ugettext('Select %s to change') % force_unicode(self.opts.verbose_name))
self.filter_specs, self.has_filters = self.get_filters(request)
self.pk_attname = self.lookup_opts.pk.attname
def get_filters(self, request):
filter_specs = []
if self.list_filter:
filter_fields = [self.lookup_opts.get_field(field_name) for field_name in self.list_filter]
for f in filter_fields:
spec = FilterSpec.create(f, request, self.params, self.model, self.model_admin)
if spec and spec.has_output():
filter_specs.append(spec)
return filter_specs, bool(filter_specs)
def get_query_string(self, new_params=None, remove=None):
if new_params is None: new_params = {}
if remove is None: remove = []
p = self.params.copy()
for r in remove:
for k in p.keys():
if k.startswith(r):
del p[k]
for k, v in new_params.items():
if v is None:
if k in p:
del p[k]
else:
p[k] = v
return '?%s' % urlencode(p)
def get_results(self, request):
paginator = Paginator(self.query_set, self.list_per_page)
# Get the number of objects, with admin filters applied.
result_count = paginator.count
# Get the total number of objects, with no admin filters applied.
# Perform a slight optimization: Check to see whether any filters were
# given. If not, use paginator.hits to calculate the number of objects,
# because we've already done paginator.hits and the value is cached.
if not self.query_set.query.where:
full_result_count = result_count
else:
full_result_count = self.root_query_set.count()
can_show_all = result_count <= MAX_SHOW_ALL_ALLOWED
multi_page = result_count > self.list_per_page
# Get the list of objects to display on this page.
if (self.show_all and can_show_all) or not multi_page:
result_list = self.query_set._clone()
else:
try:
result_list = paginator.page(self.page_num+1).object_list
except InvalidPage:
result_list = ()
self.result_count = result_count
self.full_result_count = full_result_count
self.result_list = result_list
self.can_show_all = can_show_all
self.multi_page = multi_page
self.paginator = paginator
def get_ordering(self):
lookup_opts, params = self.lookup_opts, self.params
# For ordering, first check the "ordering" parameter in the admin
# options, then check the object's default ordering. If neither of
# those exist, order descending by ID by default. Finally, look for
# manually-specified ordering from the query string.
ordering = self.model_admin.ordering or lookup_opts.ordering or ['-' + lookup_opts.pk.name]
if ordering[0].startswith('-'):
order_field, order_type = ordering[0][1:], 'desc'
else:
order_field, order_type = ordering[0], 'asc'
if ORDER_VAR in params:
try:
field_name = self.list_display[int(params[ORDER_VAR])]
try:
f = lookup_opts.get_field(field_name)
except models.FieldDoesNotExist:
# See whether field_name is a name of a non-field
# that allows sorting.
try:
if callable(field_name):
attr = field_name
elif hasattr(self.model_admin, field_name):
attr = getattr(self.model_admin, field_name)
else:
attr = getattr(self.model, field_name)
order_field = attr.admin_order_field
except AttributeError:
pass
else:
order_field = f.name
except (IndexError, ValueError):
pass # Invalid ordering specified. Just use the default.
if ORDER_TYPE_VAR in params and params[ORDER_TYPE_VAR] in ('asc', 'desc'):
order_type = params[ORDER_TYPE_VAR]
return order_field, order_type
def get_query_set(self):
qs = self.root_query_set
lookup_params = self.params.copy() # a dictionary of the query string
for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR):
if i in lookup_params:
del lookup_params[i]
for key, value in lookup_params.items():
if not isinstance(key, str):
# 'key' will be used as a keyword argument later, so Python
# requires it to be a string.
del lookup_params[key]
lookup_params[smart_str(key)] = value
# if key ends with __in, split parameter into separate values
if key.endswith('__in'):
lookup_params[key] = value.split(',')
# if key ends with __isnull, special case '' and false
if key.endswith('__isnull'):
if value.lower() in ('', 'false'):
lookup_params[key] = False
else:
lookup_params[key] = True
# Apply lookup parameters from the query string.
try:
qs = qs.filter(**lookup_params)
# Naked except! Because we don't have any other way of validating "params".
# They might be invalid if the keyword arguments are incorrect, or if the
# values are not in the correct type, so we might get FieldError, ValueError,
# ValicationError, or ? from a custom field that raises yet something else
# when handed impossible data.
except:
raise IncorrectLookupParameters
# Use select_related() if one of the list_display options is a field
# with a relationship and the provided queryset doesn't already have
# select_related defined.
if not qs.query.select_related:
if self.list_select_related:
qs = qs.select_related()
else:
for field_name in self.list_display:
try:
f = self.lookup_opts.get_field(field_name)
except models.FieldDoesNotExist:
pass
else:
if isinstance(f.rel, models.ManyToOneRel):
qs = qs.select_related()
break
# Set ordering.
if self.order_field:
qs = qs.order_by('%s%s' % ((self.order_type == 'desc' and '-' or ''), self.order_field))
# Apply keyword searches.
def construct_search(field_name):
if field_name.startswith('^'):
return "%s__istartswith" % field_name[1:]
elif field_name.startswith('='):
return "%s__iexact" % field_name[1:]
elif field_name.startswith('@'):
return "%s__search" % field_name[1:]
else:
return "%s__icontains" % field_name
if self.search_fields and self.query:
for bit in self.query.split():
or_queries = [models.Q(**{construct_search(str(field_name)): bit}) for field_name in self.search_fields]
qs = qs.filter(reduce(operator.or_, or_queries))
for field_name in self.search_fields:
if '__' in field_name:
qs = qs.distinct()
break
return qs
def url_for_result(self, result):
return "%s/" % quote(getattr(result, self.pk_attname))
| ajibawa-2023/Python-Code-Large/train/row_98637 | 159 | 244 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98637:ImportFrom_L1_C0", "label": "from django.contrib.admin.filterspecs import FilterSpec", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0041, 0.0041, 0, 0.66, 0.0, 229, 0, 1, 0, 0, 229, 0, 0], "semantic": {"name": "django.contrib.admin.filterspecs", "arg_names": [], "import_names": ["FilterSpec"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.filterspecs import FilterSpec"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:ImportFrom_L2_C0", "label": "from django.contrib.admin.options import IncorrectLookupParameters", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0082, 0.0041, 0, 0.66, 0.0526, 84, 0, 1, 0, 0, 84, 0, 0], "semantic": {"name": "django.contrib.admin.options", "arg_names": [], "import_names": ["IncorrectLookupParameters"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.options import IncorrectLookupParameters"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:ImportFrom_L3_C0", "label": "from django.contrib.admin.util import quote", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0123, 0.0041, 0, 0.66, 0.1053, 69, 0, 1, 0, 0, 69, 0, 0], "semantic": {"name": "django.contrib.admin.util", "arg_names": [], "import_names": ["quote"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.util import quote"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:ImportFrom_L4_C0", "label": "from django.core.paginator import Paginator, InvalidPage", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0164, 0.0041, 0, 0.66, 0.1579, 831, 0, 2, 0, 0, 831, 0, 0], "semantic": {"name": "django.core.paginator", "arg_names": [], "import_names": ["Paginator", "InvalidPage"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.paginator import Paginator, InvalidPage"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:ImportFrom_L5_C0", "label": "from django.db import models", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0205, 0.0041, 0, 0.66, 0.2105, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:ImportFrom_L6_C0", "label": "from django.utils.encoding import force_unicode, smart_str", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0246, 0.0041, 0, 0.66, 0.2632, 96, 0, 2, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["force_unicode", "smart_str"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import force_unicode, smart_str"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:ImportFrom_L7_C0", "label": "from django.utils.translation import ugettext", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0287, 0.0041, 0, 0.66, 0.3158, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["ugettext"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:ImportFrom_L8_C0", "label": "from django.utils.http import urlencode", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0328, 0.0041, 0, 0.66, 0.3684, 516, 0, 1, 0, 0, 516, 0, 0], "semantic": {"name": "django.utils.http", "arg_names": [], "import_names": ["urlencode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.http import urlencode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Import_L9_C0", "label": "operator import operator", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0369, 0.0041, 0, 0.66, 0.4211, 616, 0, 1, 0, 0, 616, 0, 0], "semantic": {"name": "operator", "arg_names": [], "import_names": ["operator"], "rhs_call_name": "", "annotation": ""}, "snippet": "import operator"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L13_C0", "label": "MAX_SHOW_ALL_ALLOWED =", "type": "assigned_variable", "loc": [13, 13], "level": 0, "parent": null, "vector": [14, 0, 0.0533, 0.0041, 0, 0.66, 0.4737, 638, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "MAX_SHOW_ALL_ALLOWED", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "MAX_SHOW_ALL_ALLOWED = 200"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L16_C0", "label": "ALL_VAR =", "type": "assigned_variable", "loc": [16, 16], "level": 0, "parent": null, "vector": [14, 0, 0.0656, 0.0041, 0, 0.66, 0.5263, 508, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "ALL_VAR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "ALL_VAR = 'all'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L17_C0", "label": "ORDER_VAR =", "type": "assigned_variable", "loc": [17, 17], "level": 0, "parent": null, "vector": [14, 0, 0.0697, 0.0041, 0, 0.66, 0.5789, 584, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "ORDER_VAR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "ORDER_VAR = 'o'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L18_C0", "label": "ORDER_TYPE_VAR =", "type": "assigned_variable", "loc": [18, 18], "level": 0, "parent": null, "vector": [14, 0, 0.0738, 0.0041, 0, 0.66, 0.6316, 362, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "ORDER_TYPE_VAR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "ORDER_TYPE_VAR = 'ot'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L19_C0", "label": "PAGE_VAR =", "type": "assigned_variable", "loc": [19, 19], "level": 0, "parent": null, "vector": [14, 0, 0.0779, 0.0041, 0, 0.66, 0.6842, 802, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "PAGE_VAR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "PAGE_VAR = 'p'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L20_C0", "label": "SEARCH_VAR =", "type": "assigned_variable", "loc": [20, 20], "level": 0, "parent": null, "vector": [14, 0, 0.082, 0.0041, 0, 0.66, 0.7368, 420, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "SEARCH_VAR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SEARCH_VAR = 'q'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L21_C0", "label": "TO_FIELD_VAR =", "type": "assigned_variable", "loc": [21, 21], "level": 0, "parent": null, "vector": [14, 0, 0.0861, 0.0041, 0, 0.66, 0.7895, 619, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "TO_FIELD_VAR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "TO_FIELD_VAR = 't'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L22_C0", "label": "IS_POPUP_VAR =", "type": "assigned_variable", "loc": [22, 22], "level": 0, "parent": null, "vector": [14, 0, 0.0902, 0.0041, 0, 0.66, 0.8421, 978, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "IS_POPUP_VAR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "IS_POPUP_VAR = 'pop'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L23_C0", "label": "ERROR_FLAG =", "type": "assigned_variable", "loc": [23, 23], "level": 0, "parent": null, "vector": [14, 0, 0.0943, 0.0041, 0, 0.66, 0.8947, 674, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "ERROR_FLAG", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "ERROR_FLAG = 'e'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L26_C0", "label": "EMPTY_CHANGELIST_VALUE =", "type": "assigned_variable", "loc": [26, 26], "level": 0, "parent": null, "vector": [14, 0, 0.1066, 0.0041, 0, 0.66, 0.9474, 495, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "EMPTY_CHANGELIST_VALUE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "EMPTY_CHANGELIST_VALUE = '(None)'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "label": "ChangeList", "type": "class", "loc": [28, 244], "level": 0, "parent": null, "vector": [3, 0, 0.5574, 0.8893, 0, 0.66, 1.0, 574, 0, 8, 0, 0, 186, 0, 62], "semantic": {"name": "ChangeList", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ChangeList(object):\n def __init__(self, request, model, list_display, list_display_links, list_filter, date_hierarchy, search_fields, list_select_related, list_per_page, list_editable, model_admin):\n self.model = model\n self.opts = model._meta\n self.lookup_opts = self.opts\n self.root_query_set = model_admin.queryset(request)\n self.list_display = list_display\n self.list_display_links = list_display_links"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "label": "__init__", "type": "function", "loc": [29, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "vector": [2, 1, 0.1947, 0.1557, 1, 0.25, 0.0, 555, 0, 12, 0, 0, 0, 0, 15], "semantic": {"name": "__init__", "arg_names": ["self", "request", "model", "list_display", "list_display_links", "list_filter", "date_hierarchy", "search_fields", "list_select_related", "list_per_page", "list_editable", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, request, model, list_display, list_display_links, list_filter, date_hierarchy, search_fields, list_select_related, list_per_page, list_editable, model_admin):\n self.model = model\n self.opts = model._meta\n self.lookup_opts = self.opts\n self.root_query_set = model_admin.queryset(request)\n self.list_display = list_display\n self.list_display_links = list_display_links\n self.list_filter = list_filter"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L30_C8", "label": "self.model =", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.123, 0.0041, 2, 0.31, 0.0, 81, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model = model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L31_C8", "label": "self.opts =", "type": "assigned_variable", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.127, 0.0041, 2, 0.31, 0.037, 26, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.opts = model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L32_C8", "label": "self.lookup_opts =", "type": "assigned_variable", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.1311, 0.0041, 2, 0.31, 0.0741, 854, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.lookup_opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.lookup_opts = self.opts"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L33_C8", "label": "self.root_query_set = queryset()", "type": "assigned_variable", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.1352, 0.0041, 2, 0.31, 0.1111, 614, 3, 1, 0, 0, 38, 10, 1], "semantic": {"name": "self.root_query_set", "arg_names": [], "import_names": [], "rhs_call_name": "queryset", "annotation": ""}, "snippet": " self.root_query_set = model_admin.queryset(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L34_C8", "label": "self.list_display =", "type": "assigned_variable", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.1393, 0.0041, 2, 0.31, 0.1481, 341, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.list_display", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.list_display = list_display"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L35_C8", "label": "self.list_display_links =", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.1434, 0.0041, 2, 0.31, 0.1852, 586, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.list_display_links", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.list_display_links = list_display_links"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L36_C8", "label": "self.list_filter =", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.1475, 0.0041, 2, 0.31, 0.2222, 530, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.list_filter", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.list_filter = list_filter"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L37_C8", "label": "self.date_hierarchy =", "type": "assigned_variable", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.1516, 0.0041, 2, 0.31, 0.2593, 509, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.date_hierarchy", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.date_hierarchy = date_hierarchy"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L38_C8", "label": "self.search_fields =", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.1557, 0.0041, 2, 0.31, 0.2963, 293, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.search_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.search_fields = search_fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L39_C8", "label": "self.list_select_related =", "type": "assigned_variable", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.1598, 0.0041, 2, 0.31, 0.3333, 162, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.list_select_related", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.list_select_related = list_select_related"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L40_C8", "label": "self.list_per_page =", "type": "assigned_variable", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.1639, 0.0041, 2, 0.31, 0.3704, 412, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.list_per_page", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.list_per_page = list_per_page"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L41_C8", "label": "self.list_editable =", "type": "assigned_variable", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.168, 0.0041, 2, 0.31, 0.4074, 963, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.list_editable", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.list_editable = list_editable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L42_C8", "label": "self.model_admin =", "type": "assigned_variable", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.1721, 0.0041, 2, 0.31, 0.4444, 2, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.model_admin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model_admin = model_admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L45_C8", "label": "try", "type": "try", "loc": [45, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [7, 2, 0.1906, 0.0164, 2, 0.31, 0.4815, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n self.page_num = int(request.GET.get(PAGE_VAR, 0))\n except ValueError:\n self.page_num = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L46_C12", "label": "self.page_num = int()", "type": "assigned_variable", "loc": [46, 46], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L45_C8", "vector": [14, 3, 0.1885, 0.0041, 3, 0.43, 0.0, 141, 3, 1, 0, 0, 901, 10, 2], "semantic": {"name": "self.page_num", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " self.page_num = int(request.GET.get(PAGE_VAR, 0))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L48_C12", "label": "self.page_num =", "type": "assigned_variable", "loc": [48, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L45_C8", "vector": [14, 3, 0.1967, 0.0041, 3, 0.43, 0.0, 141, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "self.page_num", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.page_num = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L49_C8", "label": "self.show_all =", "type": "assigned_variable", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.2008, 0.0041, 2, 0.31, 0.5185, 143, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.show_all", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.show_all = ALL_VAR in request.GET"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L50_C8", "label": "self.is_popup =", "type": "assigned_variable", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.2049, 0.0041, 2, 0.31, 0.5556, 149, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.is_popup", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.is_popup = IS_POPUP_VAR in request.GET"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L51_C8", "label": "self.to_field = get()", "type": "assigned_variable", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.209, 0.0041, 2, 0.31, 0.5926, 292, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "self.to_field", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " self.to_field = request.GET.get(TO_FIELD_VAR)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L52_C8", "label": "self.params = dict()", "type": "assigned_variable", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.2131, 0.0041, 2, 0.31, 0.6296, 402, 3, 1, 0, 0, 827, 10, 2], "semantic": {"name": "self.params", "arg_names": [], "import_names": [], "rhs_call_name": "dict", "annotation": ""}, "snippet": " self.params = dict(request.GET.items())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L53_C8", "label": "if", "type": "if", "loc": [53, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [4, 2, 0.2193, 0.0082, 2, 0.31, 0.6667, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if PAGE_VAR in self.params:\n del self.params[PAGE_VAR]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L55_C8", "label": "if", "type": "if", "loc": [55, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [4, 2, 0.2275, 0.0082, 2, 0.31, 0.7037, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if TO_FIELD_VAR in self.params:\n del self.params[TO_FIELD_VAR]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L57_C8", "label": "if", "type": "if", "loc": [57, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [4, 2, 0.2357, 0.0082, 2, 0.31, 0.7407, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ERROR_FLAG in self.params:\n del self.params[ERROR_FLAG]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L60_C8", "label": " = get_ordering()", "type": "assigned_variable", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.2459, 0.0041, 2, 0.31, 0.7778, 0, 3, 0, 0, 0, 452, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get_ordering", "annotation": ""}, "snippet": " self.order_field, self.order_type = self.get_ordering()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L61_C8", "label": "self.query = get()", "type": "assigned_variable", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.25, 0.0041, 2, 0.31, 0.8148, 241, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "self.query", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " self.query = request.GET.get(SEARCH_VAR, '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L62_C8", "label": "self.query_set = get_query_set()", "type": "assigned_variable", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.2541, 0.0041, 2, 0.31, 0.8519, 42, 3, 0, 0, 0, 696, 10, 1], "semantic": {"name": "self.query_set", "arg_names": [], "import_names": [], "rhs_call_name": "get_query_set", "annotation": ""}, "snippet": " self.query_set = self.get_query_set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Expr_L63_C8", "label": "get_results()", "type": "expression", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [8, 2, 0.2582, 0.0041, 2, 0.31, 0.8889, 409, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "get_results", "arg_names": [], "import_names": [], "rhs_call_name": "get_results", "annotation": ""}, "snippet": " self.get_results(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L64_C8", "label": "self.title =", "type": "assigned_variable", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.2623, 0.0041, 2, 0.31, 0.9259, 629, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "self.title", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.title = (self.is_popup and ugettext('Select %s') % force_unicode(self.opts.verbose_name) or ugettext('Select %s to change') % force_unicode(self.opts.verbose_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L65_C8", "label": " = get_filters()", "type": "assigned_variable", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.2664, 0.0041, 2, 0.31, 0.963, 0, 3, 1, 0, 0, 19, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get_filters", "annotation": ""}, "snippet": " self.filter_specs, self.has_filters = self.get_filters(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L66_C8", "label": "self.pk_attname =", "type": "assigned_variable", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "vector": [14, 2, 0.2705, 0.0041, 2, 0.31, 1.0, 515, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.pk_attname", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.pk_attname = self.lookup_opts.pk.attname"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L68_C4", "label": "get_filters", "type": "function", "loc": [68, 76], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "vector": [2, 1, 0.2951, 0.0369, 1, 0.25, 0.1667, 19, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "get_filters", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_filters(self, request):\n filter_specs = []\n if self.list_filter:\n filter_fields = [self.lookup_opts.get_field(field_name) for field_name in self.list_filter]\n for f in filter_fields:\n spec = FilterSpec.create(f, request, self.params, self.model, self.model_admin)\n if spec and spec.has_output():\n filter_specs.append(spec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L69_C8", "label": "filter_specs =", "type": "assigned_variable", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L68_C4", "vector": [14, 2, 0.2828, 0.0041, 2, 0.1, 0.0, 355, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "filter_specs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " filter_specs = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L70_C8", "label": "if", "type": "if", "loc": [70, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L68_C4", "vector": [4, 2, 0.2971, 0.0246, 2, 0.1, 0.5, 0, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.list_filter:\n filter_fields = [self.lookup_opts.get_field(field_name) for field_name in self.list_filter]\n for f in filter_fields:\n spec = FilterSpec.create(f, request, self.params, self.model, self.model_admin)\n if spec and spec.has_output():\n filter_specs.append(spec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L71_C12", "label": "filter_fields =", "type": "assigned_variable", "loc": [71, 71], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L70_C8", "vector": [14, 3, 0.291, 0.0041, 3, 0.54, 0.0, 117, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "filter_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " filter_fields = [self.lookup_opts.get_field(field_name) for field_name in self.list_filter]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L72_C12", "label": "for f", "type": "for", "loc": [72, 75], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L70_C8", "vector": [6, 3, 0.3012, 0.0164, 3, 0.54, 1.0, 899, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for f in filter_fields:\n spec = FilterSpec.create(f, request, self.params, self.model, self.model_admin)\n if spec and spec.has_output():\n filter_specs.append(spec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L73_C16", "label": "spec = create()", "type": "assigned_variable", "loc": [73, 73], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L72_C12", "vector": [14, 4, 0.2992, 0.0041, 4, 0.79, 0.0, 271, 3, 5, 0, 0, 316, 10, 1], "semantic": {"name": "spec", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " spec = FilterSpec.create(f, request, self.params, self.model, self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L74_C16", "label": "if", "type": "if", "loc": [74, 75], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L72_C12", "vector": [4, 4, 0.3053, 0.0082, 4, 0.79, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if spec and spec.has_output():\n filter_specs.append(spec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Expr_L75_C20", "label": "append()", "type": "expression", "loc": [75, 75], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L74_C16", "vector": [8, 5, 0.3074, 0.0041, 5, 0.9, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " filter_specs.append(spec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L76_C8", "label": "return", "type": "return", "loc": [76, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L68_C4", "vector": [13, 2, 0.3115, 0.0041, 2, 0.1, 1.0, 0, 0, 0, 0, 0, 0, 8, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return filter_specs, bool(filter_specs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "label": "get_query_string", "type": "function", "loc": [78, 92], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "vector": [2, 1, 0.3484, 0.0615, 1, 0.25, 0.3333, 641, 0, 3, 1, 0, 0, 0, 5], "semantic": {"name": "get_query_string", "arg_names": ["self", "new_params", "remove"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_query_string(self, new_params=None, remove=None):\n if new_params is None: new_params = {}\n if remove is None: remove = []\n p = self.params.copy()\n for r in remove:\n for k in p.keys():\n if k.startswith(r):\n del p[k]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L79_C8", "label": "if", "type": "if", "loc": [79, 79], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "vector": [4, 2, 0.3238, 0.0041, 2, 0.48, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if new_params is None: new_params = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L79_C31", "label": "new_params =", "type": "assigned_variable", "loc": [79, 79], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L79_C8", "vector": [14, 3, 0.3238, 0.0041, 3, 0.27, 0.0, 907, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "new_params", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if new_params is None: new_params = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L80_C8", "label": "if", "type": "if", "loc": [80, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "vector": [4, 2, 0.3279, 0.0041, 2, 0.48, 0.2, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if remove is None: remove = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L80_C27", "label": "remove =", "type": "assigned_variable", "loc": [80, 80], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L80_C8", "vector": [14, 3, 0.3279, 0.0041, 3, 0.86, 0.0, 185, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "remove", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if remove is None: remove = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L81_C8", "label": "p = copy()", "type": "assigned_variable", "loc": [81, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "vector": [14, 2, 0.332, 0.0041, 2, 0.48, 0.4, 491, 3, 0, 0, 0, 739, 10, 1], "semantic": {"name": "p", "arg_names": [], "import_names": [], "rhs_call_name": "copy", "annotation": ""}, "snippet": " p = self.params.copy()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L82_C8", "label": "for r", "type": "for", "loc": [82, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "vector": [6, 2, 0.3422, 0.0164, 2, 0.48, 0.6, 436, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "r", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for r in remove:\n for k in p.keys():\n if k.startswith(r):\n del p[k]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L83_C12", "label": "for k", "type": "for", "loc": [83, 85], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L82_C8", "vector": [6, 3, 0.3443, 0.0123, 3, 0.4, 0.0, 954, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "k", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for k in p.keys():\n if k.startswith(r):\n del p[k]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L84_C16", "label": "if", "type": "if", "loc": [84, 85], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L83_C12", "vector": [4, 4, 0.3463, 0.0082, 4, 0.4, 0.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if k.startswith(r):\n del p[k]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L86_C8", "label": "for k, v", "type": "for", "loc": [86, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "vector": [6, 2, 0.3627, 0.0246, 2, 0.48, 0.8, 867, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "k, v", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for k, v in new_params.items():\n if v is None:\n if k in p:\n del p[k]\n else:\n p[k] = v"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L87_C12", "label": "if", "type": "if", "loc": [87, 91], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L86_C8", "vector": [4, 3, 0.3648, 0.0205, 3, 0.73, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if v is None:\n if k in p:\n del p[k]\n else:\n p[k] = v"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L88_C16", "label": "if", "type": "if", "loc": [88, 89], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L87_C12", "vector": [4, 4, 0.3627, 0.0082, 4, 0.98, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if k in p:\n del p[k]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L91_C16", "label": "assign", "type": "assigned_variable", "loc": [91, 91], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L87_C12", "vector": [14, 4, 0.373, 0.0041, 4, 0.98, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " p[k] = v"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L92_C8", "label": "return", "type": "return", "loc": [92, 92], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "vector": [13, 2, 0.377, 0.0041, 2, 0.48, 1.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '?%s' % urlencode(p)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "label": "get_results", "type": "function", "loc": [94, 125], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "vector": [2, 1, 0.4488, 0.1311, 1, 0.25, 0.5, 409, 0, 2, 0, 0, 0, 0, 4], "semantic": {"name": "get_results", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_results(self, request):\n paginator = Paginator(self.query_set, self.list_per_page)\n # Get the number of objects, with admin filters applied.\n result_count = paginator.count\n\n # Get the total number of objects, with no admin filters applied.\n # Perform a slight optimization: Check to see whether any filters were\n # given. If not, use paginator.hits to calculate the number of objects,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L95_C8", "label": "paginator = Paginator()", "type": "assigned_variable", "loc": [95, 95], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "vector": [14, 2, 0.3893, 0.0041, 2, 0.95, 0.0, 711, 3, 2, 0, 0, 148, 10, 1], "semantic": {"name": "paginator", "arg_names": [], "import_names": [], "rhs_call_name": "Paginator", "annotation": ""}, "snippet": " paginator = Paginator(self.query_set, self.list_per_page)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L97_C8", "label": "result_count =", "type": "assigned_variable", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "vector": [14, 2, 0.3975, 0.0041, 2, 0.95, 0.0909, 442, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "result_count", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result_count = paginator.count"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L103_C8", "label": "if", "type": "if", "loc": [103, 106], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "vector": [4, 2, 0.4283, 0.0164, 2, 0.95, 0.1818, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.query_set.query.where:\n full_result_count = result_count\n else:\n full_result_count = self.root_query_set.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L104_C12", "label": "full_result_count =", "type": "assigned_variable", "loc": [104, 104], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L103_C8", "vector": [14, 3, 0.4262, 0.0041, 3, 0.07, 0.0, 130, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "full_result_count", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " full_result_count = result_count"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L106_C12", "label": "full_result_count = count()", "type": "assigned_variable", "loc": [106, 106], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L103_C8", "vector": [14, 3, 0.4344, 0.0041, 3, 0.07, 1.0, 130, 3, 0, 0, 0, 778, 10, 1], "semantic": {"name": "full_result_count", "arg_names": [], "import_names": [], "rhs_call_name": "count", "annotation": ""}, "snippet": " full_result_count = self.root_query_set.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L108_C8", "label": "can_show_all =", "type": "assigned_variable", "loc": [108, 108], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "vector": [14, 2, 0.4426, 0.0041, 2, 0.95, 0.2727, 15, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "can_show_all", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " can_show_all = result_count <= MAX_SHOW_ALL_ALLOWED"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L109_C8", "label": "multi_page =", "type": "assigned_variable", "loc": [109, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "vector": [14, 2, 0.4467, 0.0041, 2, 0.95, 0.3636, 658, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "multi_page", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " multi_page = result_count > self.list_per_page"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L112_C8", "label": "if", "type": "if", "loc": [112, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "vector": [4, 2, 0.4713, 0.0287, 2, 0.95, 0.4545, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if (self.show_all and can_show_all) or not multi_page:\n result_list = self.query_set._clone()\n else:\n try:\n result_list = paginator.page(self.page_num+1).object_list\n except InvalidPage:\n result_list = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L113_C12", "label": "result_list = _clone()", "type": "assigned_variable", "loc": [113, 113], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L112_C8", "vector": [14, 3, 0.4631, 0.0041, 3, 0.79, 0.0, 587, 3, 0, 0, 0, 617, 10, 1], "semantic": {"name": "result_list", "arg_names": [], "import_names": [], "rhs_call_name": "_clone", "annotation": ""}, "snippet": " result_list = self.query_set._clone()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L115_C12", "label": "try", "type": "try", "loc": [115, 118], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L112_C8", "vector": [7, 3, 0.4775, 0.0164, 3, 0.79, 1.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n result_list = paginator.page(self.page_num+1).object_list\n except InvalidPage:\n result_list = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L116_C16", "label": "result_list =", "type": "assigned_variable", "loc": [116, 116], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L115_C12", "vector": [14, 4, 0.4754, 0.0041, 4, 0.42, 0.0, 587, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "result_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result_list = paginator.page(self.page_num+1).object_list"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L118_C16", "label": "result_list =", "type": "assigned_variable", "loc": [118, 118], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L115_C12", "vector": [14, 4, 0.4836, 0.0041, 4, 0.42, 0.0, 587, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "result_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result_list = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L120_C8", "label": "self.result_count =", "type": "assigned_variable", "loc": [120, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "vector": [14, 2, 0.4918, 0.0041, 2, 0.95, 0.5455, 86, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.result_count", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.result_count = result_count"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L121_C8", "label": "self.full_result_count =", "type": "assigned_variable", "loc": [121, 121], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "vector": [14, 2, 0.4959, 0.0041, 2, 0.95, 0.6364, 818, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.full_result_count", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.full_result_count = full_result_count"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L122_C8", "label": "self.result_list =", "type": "assigned_variable", "loc": [122, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "vector": [14, 2, 0.5, 0.0041, 2, 0.95, 0.7273, 50, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.result_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.result_list = result_list"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L123_C8", "label": "self.can_show_all =", "type": "assigned_variable", "loc": [123, 123], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "vector": [14, 2, 0.5041, 0.0041, 2, 0.95, 0.8182, 752, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.can_show_all", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.can_show_all = can_show_all"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L124_C8", "label": "self.multi_page =", "type": "assigned_variable", "loc": [124, 124], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "vector": [14, 2, 0.5082, 0.0041, 2, 0.95, 0.9091, 418, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.multi_page", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.multi_page = multi_page"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L125_C8", "label": "self.paginator =", "type": "assigned_variable", "loc": [125, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "vector": [14, 2, 0.5123, 0.0041, 2, 0.95, 1.0, 618, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.paginator", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.paginator = paginator"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "label": "get_ordering", "type": "function", "loc": [127, 163], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "vector": [2, 1, 0.5943, 0.1516, 1, 0.25, 0.6667, 452, 0, 1, 1, 0, 0, 0, 7], "semantic": {"name": "get_ordering", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_ordering(self):\n lookup_opts, params = self.lookup_opts, self.params\n # For ordering, first check the \"ordering\" parameter in the admin\n # options, then check the object's default ordering. If neither of\n # those exist, order descending by ID by default. Finally, look for\n # manually-specified ordering from the query string.\n ordering = self.model_admin.ordering or lookup_opts.ordering or ['-' + lookup_opts.pk.name]\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L128_C8", "label": "lookup_opts, params =", "type": "assigned_variable", "loc": [128, 128], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "vector": [14, 2, 0.5246, 0.0041, 2, 0.78, 0.0, 536, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "lookup_opts, params", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lookup_opts, params = self.lookup_opts, self.params"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L133_C8", "label": "ordering =", "type": "assigned_variable", "loc": [133, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "vector": [14, 2, 0.5451, 0.0041, 2, 0.78, 0.2, 656, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "ordering", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ordering = self.model_admin.ordering or lookup_opts.ordering or ['-' + lookup_opts.pk.name]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L135_C8", "label": "if", "type": "if", "loc": [135, 138], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "vector": [4, 2, 0.5594, 0.0164, 2, 0.78, 0.4, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ordering[0].startswith('-'):\n order_field, order_type = ordering[0][1:], 'desc'\n else:\n order_field, order_type = ordering[0], 'asc'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L136_C12", "label": "order_field, order_type =", "type": "assigned_variable", "loc": [136, 136], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L135_C8", "vector": [14, 3, 0.5574, 0.0041, 3, 0.39, 0.0, 64, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "order_field, order_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " order_field, order_type = ordering[0][1:], 'desc'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L138_C12", "label": "order_field, order_type =", "type": "assigned_variable", "loc": [138, 138], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L135_C8", "vector": [14, 3, 0.5656, 0.0041, 3, 0.39, 1.0, 64, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "order_field, order_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " order_field, order_type = ordering[0], 'asc'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L139_C8", "label": "if", "type": "if", "loc": [139, 160], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "vector": [4, 2, 0.6127, 0.0902, 2, 0.78, 0.6, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ORDER_VAR in params:\n try:\n field_name = self.list_display[int(params[ORDER_VAR])]\n try:\n f = lookup_opts.get_field(field_name)\n except models.FieldDoesNotExist:\n # See whether field_name is a name of a non-field\n # that allows sorting."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L140_C12", "label": "try", "type": "try", "loc": [140, 160], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L139_C8", "vector": [7, 3, 0.6148, 0.0861, 3, 0.05, 0.0, 0, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n field_name = self.list_display[int(params[ORDER_VAR])]\n try:\n f = lookup_opts.get_field(field_name)\n except models.FieldDoesNotExist:\n # See whether field_name is a name of a non-field\n # that allows sorting.\n try:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L141_C16", "label": "field_name =", "type": "assigned_variable", "loc": [141, 141], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L140_C12", "vector": [14, 4, 0.5779, 0.0041, 4, 0.33, 0.0, 918, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_name = self.list_display[int(params[ORDER_VAR])]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L142_C16", "label": "try", "type": "try", "loc": [142, 158], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L140_C12", "vector": [7, 4, 0.6148, 0.0697, 4, 0.33, 1.0, 0, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n f = lookup_opts.get_field(field_name)\n except models.FieldDoesNotExist:\n # See whether field_name is a name of a non-field\n # that allows sorting.\n try:\n if callable(field_name):\n attr = field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L143_C20", "label": "f = get_field()", "type": "assigned_variable", "loc": [143, 143], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L142_C16", "vector": [14, 5, 0.5861, 0.0041, 5, 0.88, 0.0, 899, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = lookup_opts.get_field(field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L147_C20", "label": "try", "type": "try", "loc": [147, 156], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L142_C16", "vector": [7, 5, 0.6209, 0.041, 5, 0.88, 0.0, 0, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n if callable(field_name):\n attr = field_name\n elif hasattr(self.model_admin, field_name):\n attr = getattr(self.model_admin, field_name)\n else:\n attr = getattr(self.model, field_name)\n order_field = attr.admin_order_field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L148_C24", "label": "if", "type": "if", "loc": [148, 153], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L147_C20", "vector": [4, 6, 0.6168, 0.0246, 6, 0.29, 0.0, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if callable(field_name):\n attr = field_name\n elif hasattr(self.model_admin, field_name):\n attr = getattr(self.model_admin, field_name)\n else:\n attr = getattr(self.model, field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L149_C28", "label": "attr =", "type": "assigned_variable", "loc": [149, 149], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L148_C24", "vector": [14, 7, 0.6107, 0.0041, 7, 0.34, 0.0, 400, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attr = field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L150_C24", "label": "if", "type": "if", "loc": [150, 153], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L148_C24", "vector": [4, 7, 0.6209, 0.0164, 7, 0.34, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif hasattr(self.model_admin, field_name):\n attr = getattr(self.model_admin, field_name)\n else:\n attr = getattr(self.model, field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L151_C28", "label": "attr = getattr()", "type": "assigned_variable", "loc": [151, 151], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L150_C24", "vector": [14, 8, 0.6189, 0.0041, 8, 0.41, 0.0, 400, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " attr = getattr(self.model_admin, field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L153_C28", "label": "attr = getattr()", "type": "assigned_variable", "loc": [153, 153], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L150_C24", "vector": [14, 8, 0.627, 0.0041, 8, 0.41, 1.0, 400, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " attr = getattr(self.model, field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L154_C24", "label": "order_field =", "type": "assigned_variable", "loc": [154, 154], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L147_C20", "vector": [14, 6, 0.6311, 0.0041, 6, 0.29, 1.0, 329, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "order_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " order_field = attr.admin_order_field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L158_C20", "label": "order_field =", "type": "assigned_variable", "loc": [158, 158], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L142_C16", "vector": [14, 5, 0.6475, 0.0041, 5, 0.88, 1.0, 329, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "order_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " order_field = f.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L161_C8", "label": "if", "type": "if", "loc": [161, 162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "vector": [4, 2, 0.6619, 0.0082, 2, 0.78, 0.8, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ORDER_TYPE_VAR in params and params[ORDER_TYPE_VAR] in ('asc', 'desc'):\n order_type = params[ORDER_TYPE_VAR]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L162_C12", "label": "order_type =", "type": "assigned_variable", "loc": [162, 162], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L161_C8", "vector": [14, 3, 0.6639, 0.0041, 3, 0.39, 0.0, 892, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "order_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " order_type = params[ORDER_TYPE_VAR]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L163_C8", "label": "return", "type": "return", "loc": [163, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "vector": [13, 2, 0.668, 0.0041, 2, 0.78, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return order_field, order_type"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "label": "get_query_set", "type": "function", "loc": [165, 241], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "vector": [2, 1, 0.832, 0.3156, 1, 0.25, 0.8333, 696, 0, 1, 1, 0, 0, 0, 24], "semantic": {"name": "get_query_set", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_query_set(self):\n qs = self.root_query_set\n lookup_params = self.params.copy() # a dictionary of the query string\n for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR):\n if i in lookup_params:\n del lookup_params[i]\n for key, value in lookup_params.items():\n if not isinstance(key, str):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L166_C8", "label": "qs =", "type": "assigned_variable", "loc": [166, 166], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "vector": [14, 2, 0.6803, 0.0041, 2, 0.98, 0.0, 251, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " qs = self.root_query_set"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L167_C8", "label": "lookup_params = copy()", "type": "assigned_variable", "loc": [167, 167], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "vector": [14, 2, 0.6844, 0.0041, 2, 0.98, 0.1111, 500, 3, 0, 0, 0, 739, 10, 1], "semantic": {"name": "lookup_params", "arg_names": [], "import_names": [], "rhs_call_name": "copy", "annotation": ""}, "snippet": " lookup_params = self.params.copy() # a dictionary of the query string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L168_C8", "label": "for i", "type": "for", "loc": [168, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "vector": [6, 2, 0.6926, 0.0123, 2, 0.98, 0.2222, 826, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "i", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR):\n if i in lookup_params:\n del lookup_params[i]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L169_C12", "label": "if", "type": "if", "loc": [169, 170], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L168_C8", "vector": [4, 3, 0.6947, 0.0082, 3, 0.54, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if i in lookup_params:\n del lookup_params[i]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L171_C8", "label": "for key, value", "type": "for", "loc": [171, 187], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "vector": [6, 2, 0.7336, 0.0697, 2, 0.98, 0.3333, 839, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "key, value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for key, value in lookup_params.items():\n if not isinstance(key, str):\n # 'key' will be used as a keyword argument later, so Python\n # requires it to be a string.\n del lookup_params[key]\n lookup_params[smart_str(key)] = value\n\n # if key ends with __in, split parameter into separate values"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L172_C12", "label": "if", "type": "if", "loc": [172, 176], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L171_C8", "vector": [4, 3, 0.7131, 0.0205, 3, 0.28, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(key, str):\n # 'key' will be used as a keyword argument later, so Python\n # requires it to be a string.\n del lookup_params[key]\n lookup_params[smart_str(key)] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L176_C16", "label": "assign", "type": "assigned_variable", "loc": [176, 176], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L172_C12", "vector": [14, 4, 0.7213, 0.0041, 4, 0.67, 0.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lookup_params[smart_str(key)] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L179_C12", "label": "if", "type": "if", "loc": [179, 180], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L171_C8", "vector": [4, 3, 0.7357, 0.0082, 3, 0.28, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if key.endswith('__in'):\n lookup_params[key] = value.split(',')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L180_C16", "label": " = split()", "type": "assigned_variable", "loc": [180, 180], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L179_C12", "vector": [14, 4, 0.7377, 0.0041, 4, 0.84, 0.0, 0, 3, 1, 0, 0, 908, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " lookup_params[key] = value.split(',')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L183_C12", "label": "if", "type": "if", "loc": [183, 187], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L171_C8", "vector": [4, 3, 0.7582, 0.0205, 3, 0.28, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if key.endswith('__isnull'):\n if value.lower() in ('', 'false'):\n lookup_params[key] = False\n else:\n lookup_params[key] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L184_C16", "label": "if", "type": "if", "loc": [184, 187], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L183_C12", "vector": [4, 4, 0.7602, 0.0164, 4, 0.84, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value.lower() in ('', 'false'):\n lookup_params[key] = False\n else:\n lookup_params[key] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L185_C20", "label": "assign", "type": "assigned_variable", "loc": [185, 185], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L184_C16", "vector": [14, 5, 0.7582, 0.0041, 5, 0.54, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lookup_params[key] = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L187_C20", "label": "assign", "type": "assigned_variable", "loc": [187, 187], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L184_C16", "vector": [14, 5, 0.7664, 0.0041, 5, 0.54, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lookup_params[key] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L190_C8", "label": "try", "type": "try", "loc": [190, 198], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "vector": [7, 2, 0.7951, 0.0369, 2, 0.98, 0.4444, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n qs = qs.filter(**lookup_params)\n # Naked except! Because we don't have any other way of validating \"params\".\n # They might be invalid if the keyword arguments are incorrect, or if the\n # values are not in the correct type, so we might get FieldError, ValueError,\n # ValicationError, or ? from a custom field that raises yet something else \n # when handed impossible data.\n except:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L191_C12", "label": "qs = filter()", "type": "assigned_variable", "loc": [191, 191], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L190_C8", "vector": [14, 3, 0.7828, 0.0041, 3, 0.98, 0.0, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = qs.filter(**lookup_params)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L203_C8", "label": "if", "type": "if", "loc": [203, 215], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "vector": [4, 2, 0.8566, 0.0533, 2, 0.98, 0.5556, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not qs.query.select_related:\n if self.list_select_related:\n qs = qs.select_related()\n else:\n for field_name in self.list_display:\n try:\n f = self.lookup_opts.get_field(field_name)\n except models.FieldDoesNotExist:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L204_C12", "label": "if", "type": "if", "loc": [204, 215], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L203_C8", "vector": [4, 3, 0.8586, 0.0492, 3, 0.26, 0.0, 0, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.list_select_related:\n qs = qs.select_related()\n else:\n for field_name in self.list_display:\n try:\n f = self.lookup_opts.get_field(field_name)\n except models.FieldDoesNotExist:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L205_C16", "label": "qs = select_related()", "type": "assigned_variable", "loc": [205, 205], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L204_C12", "vector": [14, 4, 0.8402, 0.0041, 4, 0.41, 0.0, 251, 3, 0, 0, 0, 595, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "select_related", "annotation": ""}, "snippet": " qs = qs.select_related()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L207_C16", "label": "for field_name", "type": "for", "loc": [207, 215], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L204_C12", "vector": [6, 4, 0.8648, 0.0369, 4, 0.41, 1.0, 918, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field_name in self.list_display:\n try:\n f = self.lookup_opts.get_field(field_name)\n except models.FieldDoesNotExist:\n pass\n else:\n if isinstance(f.rel, models.ManyToOneRel):\n qs = qs.select_related()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L208_C20", "label": "try", "type": "try", "loc": [208, 215], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L207_C16", "vector": [7, 5, 0.8668, 0.0328, 5, 0.68, 0.0, 0, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n f = self.lookup_opts.get_field(field_name)\n except models.FieldDoesNotExist:\n pass\n else:\n if isinstance(f.rel, models.ManyToOneRel):\n qs = qs.select_related()\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L209_C24", "label": "f = get_field()", "type": "assigned_variable", "loc": [209, 209], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L208_C20", "vector": [14, 6, 0.8566, 0.0041, 6, 0.02, 0.0, 899, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = self.lookup_opts.get_field(field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L213_C24", "label": "if", "type": "if", "loc": [213, 215], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L208_C20", "vector": [4, 6, 0.877, 0.0123, 6, 0.02, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f.rel, models.ManyToOneRel):\n qs = qs.select_related()\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L214_C28", "label": "qs = select_related()", "type": "assigned_variable", "loc": [214, 214], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L213_C24", "vector": [14, 7, 0.877, 0.0041, 7, 0.73, 0.0, 251, 3, 0, 0, 0, 595, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "select_related", "annotation": ""}, "snippet": " qs = qs.select_related()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L218_C8", "label": "if", "type": "if", "loc": [218, 219], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "vector": [4, 2, 0.8955, 0.0082, 2, 0.98, 0.6667, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.order_field:\n qs = qs.order_by('%s%s' % ((self.order_type == 'desc' and '-' or ''), self.order_field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L219_C12", "label": "qs = order_by()", "type": "assigned_variable", "loc": [219, 219], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L218_C8", "vector": [14, 3, 0.8975, 0.0041, 3, 0.57, 0.0, 251, 3, 1, 0, 0, 23, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "order_by", "annotation": ""}, "snippet": " qs = qs.order_by('%s%s' % ((self.order_type == 'desc' and '-' or ''), self.order_field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L222_C8", "label": "construct_search", "type": "function", "loc": [222, 230], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "vector": [2, 2, 0.9262, 0.0369, 2, 0.98, 0.7778, 200, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "construct_search", "arg_names": ["field_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def construct_search(field_name):\n if field_name.startswith('^'):\n return \"%s__istartswith\" % field_name[1:]\n elif field_name.startswith('='):\n return \"%s__iexact\" % field_name[1:]\n elif field_name.startswith('@'):\n return \"%s__search\" % field_name[1:]\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L223_C12", "label": "if", "type": "if", "loc": [223, 230], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L222_C8", "vector": [4, 3, 0.9283, 0.0328, 3, 0.89, 0.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_name.startswith('^'):\n return \"%s__istartswith\" % field_name[1:]\n elif field_name.startswith('='):\n return \"%s__iexact\" % field_name[1:]\n elif field_name.startswith('@'):\n return \"%s__search\" % field_name[1:]\n else:\n return \"%s__icontains\" % field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L224_C16", "label": "return", "type": "return", "loc": [224, 224], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L223_C12", "vector": [13, 4, 0.918, 0.0041, 4, 0.62, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"%s__istartswith\" % field_name[1:]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L225_C12", "label": "if", "type": "if", "loc": [225, 230], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L223_C12", "vector": [4, 4, 0.9324, 0.0246, 4, 0.62, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif field_name.startswith('='):\n return \"%s__iexact\" % field_name[1:]\n elif field_name.startswith('@'):\n return \"%s__search\" % field_name[1:]\n else:\n return \"%s__icontains\" % field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L226_C16", "label": "return", "type": "return", "loc": [226, 226], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L225_C12", "vector": [13, 5, 0.9262, 0.0041, 5, 0.81, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"%s__iexact\" % field_name[1:]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L227_C12", "label": "if", "type": "if", "loc": [227, 230], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L225_C12", "vector": [4, 5, 0.9365, 0.0164, 5, 0.81, 1.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif field_name.startswith('@'):\n return \"%s__search\" % field_name[1:]\n else:\n return \"%s__icontains\" % field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L228_C16", "label": "return", "type": "return", "loc": [228, 228], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L227_C12", "vector": [13, 6, 0.9344, 0.0041, 6, 0.22, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"%s__search\" % field_name[1:]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L230_C16", "label": "return", "type": "return", "loc": [230, 230], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L227_C12", "vector": [13, 6, 0.9426, 0.0041, 6, 0.22, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"%s__icontains\" % field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L232_C8", "label": "if", "type": "if", "loc": [232, 239], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "vector": [4, 2, 0.9652, 0.0328, 2, 0.98, 0.8889, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.search_fields and self.query:\n for bit in self.query.split():\n or_queries = [models.Q(**{construct_search(str(field_name)): bit}) for field_name in self.search_fields]\n qs = qs.filter(reduce(operator.or_, or_queries))\n for field_name in self.search_fields:\n if '__' in field_name:\n qs = qs.distinct()\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L233_C12", "label": "for bit", "type": "for", "loc": [233, 235], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L232_C8", "vector": [6, 3, 0.959, 0.0123, 3, 0.98, 0.0, 835, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "bit", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for bit in self.query.split():\n or_queries = [models.Q(**{construct_search(str(field_name)): bit}) for field_name in self.search_fields]\n qs = qs.filter(reduce(operator.or_, or_queries))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L234_C16", "label": "or_queries =", "type": "assigned_variable", "loc": [234, 234], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L233_C12", "vector": [14, 4, 0.959, 0.0041, 4, 0.04, 0.0, 888, 5, 0, 0, 0, 0, 0, 3], "semantic": {"name": "or_queries", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " or_queries = [models.Q(**{construct_search(str(field_name)): bit}) for field_name in self.search_fields]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L235_C16", "label": "qs = filter()", "type": "assigned_variable", "loc": [235, 235], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L233_C12", "vector": [14, 4, 0.9631, 0.0041, 4, 0.04, 1.0, 251, 3, 1, 0, 0, 526, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = qs.filter(reduce(operator.or_, or_queries))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L236_C12", "label": "for field_name", "type": "for", "loc": [236, 239], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L232_C8", "vector": [6, 3, 0.9734, 0.0164, 3, 0.98, 1.0, 918, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field_name in self.search_fields:\n if '__' in field_name:\n qs = qs.distinct()\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L237_C16", "label": "if", "type": "if", "loc": [237, 239], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L236_C12", "vector": [4, 4, 0.9754, 0.0123, 4, 0.23, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if '__' in field_name:\n qs = qs.distinct()\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L238_C20", "label": "qs = distinct()", "type": "assigned_variable", "loc": [238, 238], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L237_C16", "vector": [14, 5, 0.9754, 0.0041, 5, 0.11, 0.0, 251, 3, 0, 0, 0, 934, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "distinct", "annotation": ""}, "snippet": " qs = qs.distinct()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L241_C8", "label": "return", "type": "return", "loc": [241, 241], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "vector": [13, 2, 0.9877, 0.0041, 2, 0.98, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return qs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L243_C4", "label": "url_for_result", "type": "function", "loc": [243, 244], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "vector": [2, 1, 0.998, 0.0082, 1, 0.25, 1.0, 778, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "url_for_result", "arg_names": ["self", "result"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def url_for_result(self, result):\n return \"%s/\" % quote(getattr(result, self.pk_attname))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L244_C8", "label": "return", "type": "return", "loc": [244, 244], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L243_C4", "vector": [13, 2, 1.0, 0.0041, 2, 0.45, 0.0, 0, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"%s/\" % quote(getattr(result, self.pk_attname))"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L45_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L46_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L45_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L48_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Expr_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L68_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L70_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L71_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L70_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L72_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L72_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L73_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L72_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L74_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L74_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Expr_L75_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L79_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L79_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L79_C31"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L80_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L80_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L81_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L82_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L83_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L83_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L84_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L86_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L87_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L87_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L88_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L87_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L91_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L78_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L92_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L103_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L103_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L104_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L103_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L106_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L108_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L112_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L112_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L113_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L112_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L115_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L115_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L116_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L115_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L118_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L120_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L121_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L122_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L123_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L124_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L135_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L135_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L136_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L135_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L138_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L139_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L139_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L140_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L140_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L141_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L140_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L142_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L142_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L143_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L142_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L147_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L147_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L148_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L148_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L149_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L148_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L150_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L150_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L151_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L150_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L153_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L147_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L154_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L142_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L158_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L161_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L161_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L162_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L127_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L167_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L168_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L168_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L169_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L171_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L171_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L172_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L172_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L176_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L171_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L179_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L179_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L180_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L171_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L183_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L183_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L184_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L184_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L185_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L184_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L187_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L190_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L190_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L191_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L203_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L203_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L204_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L204_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L205_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L204_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L207_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L207_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L208_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L208_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L209_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:Try_L208_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L213_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L213_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L214_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L218_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L218_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L219_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L222_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L222_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L223_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L223_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L224_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L223_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L225_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L225_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L226_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L225_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L227_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L227_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L228_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L227_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L230_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L232_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L232_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L233_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L233_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L234_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L233_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L235_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L232_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L236_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:For_L236_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L237_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:If_L237_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Assign_L238_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L241_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:ClassDef_L28_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L243_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98637:FunctionDef_L243_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98637:Return_L244_C8"}] |
try:
from functools import wraps
except ImportError:
from django.utils.functional import wraps # Python 2.4 fallback.
from django import http, template
from django.contrib.auth.models import User
from django.contrib.auth import authenticate, login
from django.shortcuts import render_to_response
from django.utils.translation import ugettext_lazy, ugettext as _
ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.")
LOGIN_FORM_KEY = 'this_is_the_login_form'
def _display_login_form(request, error_message=''):
request.session.set_test_cookie()
return render_to_response('admin/login.html', {
'title': _('Log in'),
'app_path': request.get_full_path(),
'error_message': error_message
}, context_instance=template.RequestContext(request))
def staff_member_required(view_func):
"""
Decorator for views that checks that the user is logged in and is a staff
member, displaying the login page if necessary.
"""
def _checklogin(request, *args, **kwargs):
if request.user.is_active and request.user.is_staff:
# The user is valid. Continue to the admin page.
return view_func(request, *args, **kwargs)
assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'."
# If this isn't already the login page, display it.
if LOGIN_FORM_KEY not in request.POST:
if request.POST:
message = _("Please log in again, because your session has expired.")
else:
message = ""
return _display_login_form(request, message)
# Check that the user accepts cookies.
if not request.session.test_cookie_worked():
message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.")
return _display_login_form(request, message)
else:
request.session.delete_test_cookie()
# Check the password.
username = request.POST.get('username', None)
password = request.POST.get('password', None)
user = authenticate(username=username, password=password)
if user is None:
message = ERROR_MESSAGE
if '@' in username:
# Mistakenly entered e-mail address instead of username? Look it up.
users = list(User.objects.filter(email=username))
if len(users) == 1 and users[0].check_password(password):
message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username
else:
# Either we cannot find the user, or if more than 1
# we cannot guess which user is the correct one.
message = _("Usernames cannot contain the '@' character.")
return _display_login_form(request, message)
# The user data is correct; log in the user in and continue.
else:
if user.is_active and user.is_staff:
login(request, user)
return http.HttpResponseRedirect(request.get_full_path())
else:
return _display_login_form(request, ERROR_MESSAGE)
return wraps(view_func)(_checklogin)
| ajibawa-2023/Python-Code-Large/train/row_98638 | 43 | 75 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Try_L1_C0", "label": "try", "type": "try", "loc": [1, 4], "level": 0, "parent": null, "vector": [7, 0, 0.0333, 0.0533, 0, 0.66, 0.0, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "try:\n from functools import wraps\nexcept ImportError:\n from django.utils.functional import wraps # Python 2.4 fallback."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:ImportFrom_L2_C4", "label": "from functools import wraps", "type": "import", "loc": [2, 2], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:Try_L1_C0", "vector": [1, 1, 0.0267, 0.0133, 1, 0.37, 0.0, 711, 0, 1, 0, 0, 711, 0, 0], "semantic": {"name": "functools", "arg_names": [], "import_names": ["wraps"], "rhs_call_name": "", "annotation": ""}, "snippet": " from functools import wraps"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:ImportFrom_L4_C4", "label": "from django.utils.functional import wraps", "type": "import", "loc": [4, 4], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:Try_L1_C0", "vector": [1, 1, 0.0533, 0.0133, 1, 0.37, 0.0, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.functional", "arg_names": [], "import_names": ["wraps"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.utils.functional import wraps # Python 2.4 fallback."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:ImportFrom_L6_C0", "label": "from django import http, template", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.08, 0.0133, 0, 0.66, 0.1111, 294, 0, 2, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["http", "template"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django import http, template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:ImportFrom_L7_C0", "label": "from django.contrib.auth.models import User", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0933, 0.0133, 0, 0.66, 0.2222, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:ImportFrom_L8_C0", "label": "from django.contrib.auth import authenticate, login", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.1067, 0.0133, 0, 0.66, 0.3333, 895, 0, 2, 0, 0, 895, 0, 0], "semantic": {"name": "django.contrib.auth", "arg_names": [], "import_names": ["authenticate", "login"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth import authenticate, login"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:ImportFrom_L9_C0", "label": "from django.shortcuts import render_to_response", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.12, 0.0133, 0, 0.66, 0.4444, 852, 0, 1, 0, 0, 852, 0, 0], "semantic": {"name": "django.shortcuts", "arg_names": [], "import_names": ["render_to_response"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.shortcuts import render_to_response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:ImportFrom_L10_C0", "label": "from django.utils.translation import ugettext_lazy, _", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.1333, 0.0133, 0, 0.66, 0.5556, 389, 0, 2, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["ugettext_lazy", "_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext_lazy, ugettext as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L12_C0", "label": "ERROR_MESSAGE = ugettext_lazy()", "type": "assigned_variable", "loc": [12, 12], "level": 0, "parent": null, "vector": [14, 0, 0.16, 0.0133, 0, 0.66, 0.6667, 310, 3, 1, 0, 0, 532, 10, 1], "semantic": {"name": "ERROR_MESSAGE", "arg_names": [], "import_names": [], "rhs_call_name": "ugettext_lazy", "annotation": ""}, "snippet": "ERROR_MESSAGE = ugettext_lazy(\"Please enter a correct username and password. Note that both fields are case-sensitive.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L13_C0", "label": "LOGIN_FORM_KEY =", "type": "assigned_variable", "loc": [13, 13], "level": 0, "parent": null, "vector": [14, 0, 0.1733, 0.0133, 0, 0.66, 0.7778, 993, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "LOGIN_FORM_KEY", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "LOGIN_FORM_KEY = 'this_is_the_login_form'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L15_C0", "label": "_display_login_form", "type": "function", "loc": [15, 21], "level": 0, "parent": null, "vector": [2, 0, 0.24, 0.0933, 0, 0.66, 0.8889, 370, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "_display_login_form", "arg_names": ["request", "error_message"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _display_login_form(request, error_message=''):\n request.session.set_test_cookie()\n return render_to_response('admin/login.html', {\n 'title': _('Log in'),\n 'app_path': request.get_full_path(),\n 'error_message': error_message\n }, context_instance=template.RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Expr_L16_C4", "label": "set_test_cookie()", "type": "expression", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L15_C0", "vector": [8, 1, 0.2133, 0.0133, 1, 0.09, 0.0, 915, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "set_test_cookie", "arg_names": [], "import_names": [], "rhs_call_name": "set_test_cookie", "annotation": ""}, "snippet": " request.session.set_test_cookie()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L17_C4", "label": "return", "type": "return", "loc": [17, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L15_C0", "vector": [13, 1, 0.2533, 0.0667, 1, 0.09, 1.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response('admin/login.html', {\n 'title': _('Log in'),\n 'app_path': request.get_full_path(),\n 'error_message': error_message\n }, context_instance=template.RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L23_C0", "label": "staff_member_required", "type": "function", "loc": [23, 75], "level": 0, "parent": null, "vector": [2, 0, 0.6533, 0.7067, 0, 0.66, 1.0, 20, 0, 1, 1, 0, 0, 0, 24], "semantic": {"name": "staff_member_required", "arg_names": ["view_func"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def staff_member_required(view_func):\n \"\"\"\n Decorator for views that checks that the user is logged in and is a staff\n member, displaying the login page if necessary.\n \"\"\"\n def _checklogin(request, *args, **kwargs):\n if request.user.is_active and request.user.is_staff:\n # The user is valid. Continue to the admin page."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Expr_L24_C4", "label": "expression", "type": "expression", "loc": [24, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L23_C0", "vector": [8, 1, 0.34, 0.0533, 1, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Decorator for views that checks that the user is logged in and is a staff\n member, displaying the login page if necessary.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "label": "_checklogin", "type": "function", "loc": [28, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L23_C0", "vector": [2, 1, 0.6733, 0.6133, 1, 0.66, 0.5, 462, 0, 3, 1, 0, 0, 0, 22], "semantic": {"name": "_checklogin", "arg_names": ["request", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _checklogin(request, *args, **kwargs):\n if request.user.is_active and request.user.is_staff:\n # The user is valid. Continue to the admin page.\n return view_func(request, *args, **kwargs)\n\n assert hasattr(request, 'session'), \"The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'.\"\n\n # If this isn't already the login page, display it."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L29_C8", "label": "if", "type": "if", "loc": [29, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "vector": [4, 2, 0.4, 0.04, 2, 0.91, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.user.is_active and request.user.is_staff:\n # The user is valid. Continue to the admin page.\n return view_func(request, *args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L31_C12", "label": "return", "type": "return", "loc": [31, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L29_C8", "vector": [13, 3, 0.4133, 0.0133, 3, 0.65, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return view_func(request, *args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L36_C8", "label": "if", "type": "if", "loc": [36, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "vector": [4, 2, 0.5133, 0.08, 2, 0.91, 0.1667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if LOGIN_FORM_KEY not in request.POST:\n if request.POST:\n message = _(\"Please log in again, because your session has expired.\")\n else:\n message = \"\"\n return _display_login_form(request, message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L37_C12", "label": "if", "type": "if", "loc": [37, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L36_C8", "vector": [4, 3, 0.5133, 0.0533, 3, 0.16, 0.0, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.POST:\n message = _(\"Please log in again, because your session has expired.\")\n else:\n message = \"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L38_C16", "label": "message = _()", "type": "assigned_variable", "loc": [38, 38], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L37_C12", "vector": [14, 4, 0.5067, 0.0133, 4, 0.24, 0.0, 635, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " message = _(\"Please log in again, because your session has expired.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L40_C16", "label": "message =", "type": "assigned_variable", "loc": [40, 40], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L37_C12", "vector": [14, 4, 0.5333, 0.0133, 4, 0.24, 1.0, 635, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " message = \"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L41_C12", "label": "return", "type": "return", "loc": [41, 41], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L36_C8", "vector": [13, 3, 0.5467, 0.0133, 3, 0.16, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _display_login_form(request, message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L44_C8", "label": "if", "type": "if", "loc": [44, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "vector": [4, 2, 0.6133, 0.0667, 2, 0.91, 0.3333, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not request.session.test_cookie_worked():\n message = _(\"Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.\")\n return _display_login_form(request, message)\n else:\n request.session.delete_test_cookie()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L45_C12", "label": "message = _()", "type": "assigned_variable", "loc": [45, 45], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L44_C8", "vector": [14, 3, 0.6, 0.0133, 3, 0.63, 0.0, 635, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " message = _(\"Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L46_C12", "label": "return", "type": "return", "loc": [46, 46], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L44_C8", "vector": [13, 3, 0.6133, 0.0133, 3, 0.63, 0.5, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _display_login_form(request, message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Expr_L48_C12", "label": "delete_test_cookie()", "type": "expression", "loc": [48, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L44_C8", "vector": [8, 3, 0.64, 0.0133, 3, 0.63, 1.0, 358, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete_test_cookie", "arg_names": [], "import_names": [], "rhs_call_name": "delete_test_cookie", "annotation": ""}, "snippet": " request.session.delete_test_cookie()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L51_C8", "label": "username = get()", "type": "assigned_variable", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "vector": [14, 2, 0.68, 0.0133, 2, 0.91, 0.5, 718, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " username = request.POST.get('username', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L52_C8", "label": "password = get()", "type": "assigned_variable", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "vector": [14, 2, 0.6933, 0.0133, 2, 0.91, 0.6667, 489, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "password", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " password = request.POST.get('password', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L53_C8", "label": "user = authenticate()", "type": "assigned_variable", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "vector": [14, 2, 0.7067, 0.0133, 2, 0.91, 0.8333, 503, 3, 2, 0, 0, 751, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "authenticate", "annotation": ""}, "snippet": " user = authenticate(username=username, password=password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L54_C8", "label": "if", "type": "if", "loc": [54, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "vector": [4, 2, 0.8467, 0.2667, 2, 0.91, 1.0, 0, 0, 0, 0, 0, 0, 0, 11], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user is None:\n message = ERROR_MESSAGE\n if '@' in username:\n # Mistakenly entered e-mail address instead of username? Look it up.\n users = list(User.objects.filter(email=username))\n if len(users) == 1 and users[0].check_password(password):\n message = _(\"Your e-mail address is not your username. Try '%s' instead.\") % users[0].username\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L55_C12", "label": "message =", "type": "assigned_variable", "loc": [55, 55], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L54_C8", "vector": [14, 3, 0.7333, 0.0133, 3, 0.81, 0.0, 635, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " message = ERROR_MESSAGE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L56_C12", "label": "if", "type": "if", "loc": [56, 64], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L54_C8", "vector": [4, 3, 0.8, 0.12, 3, 0.81, 0.3333, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if '@' in username:\n # Mistakenly entered e-mail address instead of username? Look it up.\n users = list(User.objects.filter(email=username))\n if len(users) == 1 and users[0].check_password(password):\n message = _(\"Your e-mail address is not your username. Try '%s' instead.\") % users[0].username\n else:\n # Either we cannot find the user, or if more than 1\n # we cannot guess which user is the correct one."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L58_C16", "label": "users = list()", "type": "assigned_variable", "loc": [58, 58], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L56_C12", "vector": [14, 4, 0.7733, 0.0133, 4, 0.16, 0.0, 395, 3, 1, 0, 0, 430, 10, 2], "semantic": {"name": "users", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " users = list(User.objects.filter(email=username))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L59_C16", "label": "if", "type": "if", "loc": [59, 64], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L56_C12", "vector": [4, 4, 0.82, 0.08, 4, 0.16, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(users) == 1 and users[0].check_password(password):\n message = _(\"Your e-mail address is not your username. Try '%s' instead.\") % users[0].username\n else:\n # Either we cannot find the user, or if more than 1\n # we cannot guess which user is the correct one.\n message = _(\"Usernames cannot contain the '@' character.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L60_C20", "label": "message =", "type": "assigned_variable", "loc": [60, 60], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L59_C16", "vector": [14, 5, 0.8, 0.0133, 5, 0.78, 0.0, 635, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " message = _(\"Your e-mail address is not your username. Try '%s' instead.\") % users[0].username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L64_C20", "label": "message = _()", "type": "assigned_variable", "loc": [64, 64], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L59_C16", "vector": [14, 5, 0.8533, 0.0133, 5, 0.78, 1.0, 635, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " message = _(\"Usernames cannot contain the '@' character.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L65_C12", "label": "return", "type": "return", "loc": [65, 65], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L54_C8", "vector": [13, 3, 0.8667, 0.0133, 3, 0.81, 0.6667, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _display_login_form(request, message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L69_C12", "label": "if", "type": "if", "loc": [69, 73], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L54_C8", "vector": [4, 3, 0.9467, 0.0667, 3, 0.81, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user.is_active and user.is_staff:\n login(request, user)\n return http.HttpResponseRedirect(request.get_full_path())\n else:\n return _display_login_form(request, ERROR_MESSAGE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Expr_L70_C16", "label": "login()", "type": "expression", "loc": [70, 70], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L69_C12", "vector": [8, 4, 0.9333, 0.0133, 4, 0.67, 0.0, 724, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " login(request, user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L71_C16", "label": "return", "type": "return", "loc": [71, 71], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L69_C12", "vector": [13, 4, 0.9467, 0.0133, 4, 0.67, 0.5, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return http.HttpResponseRedirect(request.get_full_path())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L73_C16", "label": "return", "type": "return", "loc": [73, 73], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L69_C12", "vector": [13, 4, 0.9733, 0.0133, 4, 0.67, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _display_login_form(request, ERROR_MESSAGE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L75_C4", "label": "return", "type": "return", "loc": [75, 75], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L23_C0", "vector": [13, 1, 1.0, 0.0133, 1, 0.66, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return wraps(view_func)(_checklogin)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98638:Try_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:ImportFrom_L2_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:Try_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:ImportFrom_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Expr_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Expr_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L31_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L37_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L38_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L37_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L40_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L41_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L45_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L46_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Expr_L48_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L54_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L55_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L54_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L56_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L56_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L58_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L56_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L59_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L59_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L60_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L59_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Assign_L64_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L54_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L65_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L54_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L69_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L69_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Expr_L70_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L69_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L71_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:If_L69_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L73_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98638:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98638:Return_L75_C4"}] |
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User
from django.contrib.admin.util import quote
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.utils.safestring import mark_safe
ADDITION = 1
CHANGE = 2
DELETION = 3
class LogEntryManager(models.Manager):
def log_action(self, user_id, content_type_id, object_id, object_repr, action_flag, change_message=''):
e = self.model(None, None, user_id, content_type_id, smart_unicode(object_id), object_repr[:200], action_flag, change_message)
e.save()
class LogEntry(models.Model):
action_time = models.DateTimeField(_('action time'), auto_now=True)
user = models.ForeignKey(User)
content_type = models.ForeignKey(ContentType, blank=True, null=True)
object_id = models.TextField(_('object id'), blank=True, null=True)
object_repr = models.CharField(_('object repr'), max_length=200)
action_flag = models.PositiveSmallIntegerField(_('action flag'))
change_message = models.TextField(_('change message'), blank=True)
objects = LogEntryManager()
class Meta:
verbose_name = _('log entry')
verbose_name_plural = _('log entries')
db_table = 'django_admin_log'
ordering = ('-action_time',)
def __repr__(self):
return smart_unicode(self.action_time)
def is_addition(self):
return self.action_flag == ADDITION
def is_change(self):
return self.action_flag == CHANGE
def is_deletion(self):
return self.action_flag == DELETION
def get_edited_object(self):
"Returns the edited object represented by this log entry"
return self.content_type.get_object_for_this_type(pk=self.object_id)
def get_admin_url(self):
"""
Returns the admin URL to edit the object represented by this log entry.
This is relative to the Django admin index page.
"""
return mark_safe(u"%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, quote(self.object_id)))
| ajibawa-2023/Python-Code-Large/train/row_98639 | 42 | 54 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98639:ImportFrom_L1_C0", "label": "from django.db import models", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0185, 0.0185, 0, 0.66, 0.0, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:ImportFrom_L2_C0", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.037, 0.0185, 0, 0.66, 0.0909, 469, 0, 1, 0, 0, 469, 0, 0], "semantic": {"name": "django.contrib.contenttypes.models", "arg_names": [], "import_names": ["ContentType"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.contenttypes.models import ContentType"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:ImportFrom_L3_C0", "label": "from django.contrib.auth.models import User", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0556, 0.0185, 0, 0.66, 0.1818, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth.models import User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:ImportFrom_L4_C0", "label": "from django.contrib.admin.util import quote", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0741, 0.0185, 0, 0.66, 0.2727, 69, 0, 1, 0, 0, 69, 0, 0], "semantic": {"name": "django.contrib.admin.util", "arg_names": [], "import_names": ["quote"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.util import quote"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:ImportFrom_L5_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0926, 0.0185, 0, 0.66, 0.3636, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext_lazy as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:ImportFrom_L6_C0", "label": "from django.utils.encoding import smart_unicode", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.1111, 0.0185, 0, 0.66, 0.4545, 96, 0, 1, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_unicode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_unicode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:ImportFrom_L7_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.1296, 0.0185, 0, 0.66, 0.5455, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.safestring", "arg_names": [], "import_names": ["mark_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.safestring import mark_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L9_C0", "label": "ADDITION =", "type": "assigned_variable", "loc": [9, 9], "level": 0, "parent": null, "vector": [14, 0, 0.1667, 0.0185, 0, 0.66, 0.6364, 371, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "ADDITION", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "ADDITION = 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L10_C0", "label": "CHANGE =", "type": "assigned_variable", "loc": [10, 10], "level": 0, "parent": null, "vector": [14, 0, 0.1852, 0.0185, 0, 0.66, 0.7273, 232, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "CHANGE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "CHANGE = 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L11_C0", "label": "DELETION =", "type": "assigned_variable", "loc": [11, 11], "level": 0, "parent": null, "vector": [14, 0, 0.2037, 0.0185, 0, 0.66, 0.8182, 300, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "DELETION", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DELETION = 3"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L13_C0", "label": "LogEntryManager", "type": "class", "loc": [13, 16], "level": 0, "parent": null, "vector": [3, 0, 0.2685, 0.0741, 0, 0.66, 0.9091, 739, 0, 1, 0, 0, 948, 0, 3], "semantic": {"name": "LogEntryManager", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class LogEntryManager(models.Manager):\n def log_action(self, user_id, content_type_id, object_id, object_repr, action_flag, change_message=''):\n e = self.model(None, None, user_id, content_type_id, smart_unicode(object_id), object_repr[:200], action_flag, change_message)\n e.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L14_C4", "label": "log_action", "type": "function", "loc": [14, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L13_C0", "vector": [2, 1, 0.2778, 0.0556, 1, 0.0, 0.0, 230, 0, 7, 0, 0, 0, 0, 3], "semantic": {"name": "log_action", "arg_names": ["self", "user_id", "content_type_id", "object_id", "object_repr", "action_flag", "change_message"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def log_action(self, user_id, content_type_id, object_id, object_repr, action_flag, change_message=''):\n e = self.model(None, None, user_id, content_type_id, smart_unicode(object_id), object_repr[:200], action_flag, change_message)\n e.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L15_C8", "label": "e = model()", "type": "assigned_variable", "loc": [15, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L14_C4", "vector": [14, 2, 0.2778, 0.0185, 2, 0.03, 0.0, 175, 3, 8, 0, 0, 722, 10, 2], "semantic": {"name": "e", "arg_names": [], "import_names": [], "rhs_call_name": "model", "annotation": ""}, "snippet": " e = self.model(None, None, user_id, content_type_id, smart_unicode(object_id), object_repr[:200], action_flag, change_message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Expr_L16_C8", "label": "save()", "type": "expression", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L14_C4", "vector": [8, 2, 0.2963, 0.0185, 2, 0.03, 1.0, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " e.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "label": "LogEntry", "type": "class", "loc": [18, 54], "level": 0, "parent": null, "vector": [3, 0, 0.6667, 0.6852, 0, 0.66, 1.0, 48, 0, 6, 0, 0, 996, 0, 19], "semantic": {"name": "LogEntry", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class LogEntry(models.Model):\n action_time = models.DateTimeField(_('action time'), auto_now=True)\n user = models.ForeignKey(User)\n content_type = models.ForeignKey(ContentType, blank=True, null=True)\n object_id = models.TextField(_('object id'), blank=True, null=True)\n object_repr = models.CharField(_('object repr'), max_length=200)\n action_flag = models.PositiveSmallIntegerField(_('action flag'))\n change_message = models.TextField(_('change message'), blank=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L19_C4", "label": "action_time = DateTimeField()", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [14, 1, 0.3519, 0.0185, 1, 0.53, 0.0, 491, 3, 2, 0, 0, 789, 10, 2], "semantic": {"name": "action_time", "arg_names": [], "import_names": [], "rhs_call_name": "DateTimeField", "annotation": ""}, "snippet": " action_time = models.DateTimeField(_('action time'), auto_now=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L20_C4", "label": "user = ForeignKey()", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [14, 1, 0.3704, 0.0185, 1, 0.53, 0.0714, 503, 3, 1, 0, 0, 140, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "ForeignKey", "annotation": ""}, "snippet": " user = models.ForeignKey(User)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L21_C4", "label": "content_type = ForeignKey()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [14, 1, 0.3889, 0.0185, 1, 0.53, 0.1429, 610, 3, 3, 0, 0, 140, 10, 1], "semantic": {"name": "content_type", "arg_names": [], "import_names": [], "rhs_call_name": "ForeignKey", "annotation": ""}, "snippet": " content_type = models.ForeignKey(ContentType, blank=True, null=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L22_C4", "label": "object_id = TextField()", "type": "assigned_variable", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [14, 1, 0.4074, 0.0185, 1, 0.53, 0.2143, 992, 3, 3, 0, 0, 612, 10, 2], "semantic": {"name": "object_id", "arg_names": [], "import_names": [], "rhs_call_name": "TextField", "annotation": ""}, "snippet": " object_id = models.TextField(_('object id'), blank=True, null=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L23_C4", "label": "object_repr = CharField()", "type": "assigned_variable", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [14, 1, 0.4259, 0.0185, 1, 0.53, 0.2857, 275, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "object_repr", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " object_repr = models.CharField(_('object repr'), max_length=200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L24_C4", "label": "action_flag = PositiveSmallIntegerField()", "type": "assigned_variable", "loc": [24, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [14, 1, 0.4444, 0.0185, 1, 0.53, 0.3571, 231, 3, 1, 0, 0, 974, 10, 2], "semantic": {"name": "action_flag", "arg_names": [], "import_names": [], "rhs_call_name": "PositiveSmallIntegerField", "annotation": ""}, "snippet": " action_flag = models.PositiveSmallIntegerField(_('action flag'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L25_C4", "label": "change_message = TextField()", "type": "assigned_variable", "loc": [25, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [14, 1, 0.463, 0.0185, 1, 0.53, 0.4286, 306, 3, 2, 0, 0, 612, 10, 2], "semantic": {"name": "change_message", "arg_names": [], "import_names": [], "rhs_call_name": "TextField", "annotation": ""}, "snippet": " change_message = models.TextField(_('change message'), blank=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L26_C4", "label": "objects = LogEntryManager()", "type": "assigned_variable", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [14, 1, 0.4815, 0.0185, 1, 0.53, 0.5, 550, 3, 0, 0, 0, 739, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "LogEntryManager", "annotation": ""}, "snippet": " objects = LogEntryManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L27_C4", "label": "Meta", "type": "class", "loc": [27, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [3, 1, 0.537, 0.0926, 1, 0.53, 0.5714, 130, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "Meta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Meta:\n verbose_name = _('log entry')\n verbose_name_plural = _('log entries')\n db_table = 'django_admin_log'\n ordering = ('-action_time',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L28_C8", "label": "verbose_name = _()", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L27_C4", "vector": [14, 2, 0.5185, 0.0185, 2, 0.28, 0.0, 616, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "verbose_name", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " verbose_name = _('log entry')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L29_C8", "label": "verbose_name_plural = _()", "type": "assigned_variable", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L27_C4", "vector": [14, 2, 0.537, 0.0185, 2, 0.28, 0.3333, 329, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "verbose_name_plural", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " verbose_name_plural = _('log entries')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L30_C8", "label": "db_table =", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L27_C4", "vector": [14, 2, 0.5556, 0.0185, 2, 0.28, 0.6667, 111, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "db_table", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " db_table = 'django_admin_log'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L31_C8", "label": "ordering =", "type": "assigned_variable", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L27_C4", "vector": [14, 2, 0.5741, 0.0185, 2, 0.28, 1.0, 656, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "ordering", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ordering = ('-action_time',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L33_C4", "label": "__repr__", "type": "function", "loc": [33, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [2, 1, 0.6204, 0.037, 1, 0.53, 0.6429, 204, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "__repr__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __repr__(self):\n return smart_unicode(self.action_time)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Return_L34_C8", "label": "return", "type": "return", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L33_C4", "vector": [13, 2, 0.6296, 0.0185, 2, 0.47, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return smart_unicode(self.action_time)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L36_C4", "label": "is_addition", "type": "function", "loc": [36, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [2, 1, 0.6759, 0.037, 1, 0.53, 0.7143, 671, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "is_addition", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def is_addition(self):\n return self.action_flag == ADDITION"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Return_L37_C8", "label": "return", "type": "return", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L36_C4", "vector": [13, 2, 0.6852, 0.0185, 2, 0.92, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.action_flag == ADDITION"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L39_C4", "label": "is_change", "type": "function", "loc": [39, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [2, 1, 0.7315, 0.037, 1, 0.53, 0.7857, 333, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "is_change", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def is_change(self):\n return self.action_flag == CHANGE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Return_L40_C8", "label": "return", "type": "return", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L39_C4", "vector": [13, 2, 0.7407, 0.0185, 2, 0.73, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.action_flag == CHANGE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L42_C4", "label": "is_deletion", "type": "function", "loc": [42, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [2, 1, 0.787, 0.037, 1, 0.53, 0.8571, 584, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "is_deletion", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def is_deletion(self):\n return self.action_flag == DELETION"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Return_L43_C8", "label": "return", "type": "return", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L42_C4", "vector": [13, 2, 0.7963, 0.0185, 2, 0.42, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.action_flag == DELETION"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L45_C4", "label": "get_edited_object", "type": "function", "loc": [45, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [2, 1, 0.8519, 0.0556, 1, 0.53, 0.9286, 36, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "get_edited_object", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_edited_object(self):\n \"Returns the edited object represented by this log entry\"\n return self.content_type.get_object_for_this_type(pk=self.object_id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Expr_L46_C8", "label": "expression", "type": "expression", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L45_C4", "vector": [8, 2, 0.8519, 0.0185, 2, 0.64, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the edited object represented by this log entry\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Return_L47_C8", "label": "return", "type": "return", "loc": [47, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L45_C4", "vector": [13, 2, 0.8704, 0.0185, 2, 0.64, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.content_type.get_object_for_this_type(pk=self.object_id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L49_C4", "label": "get_admin_url", "type": "function", "loc": [49, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "vector": [2, 1, 0.9537, 0.1111, 1, 0.53, 1.0, 912, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "get_admin_url", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_admin_url(self):\n \"\"\"\n Returns the admin URL to edit the object represented by this log entry.\n This is relative to the Django admin index page.\n \"\"\"\n return mark_safe(u\"%s/%s/%s/\" % (self.content_type.app_label, self.content_type.model, quote(self.object_id)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Expr_L50_C8", "label": "expression", "type": "expression", "loc": [50, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L49_C4", "vector": [8, 2, 0.9537, 0.0741, 2, 0.13, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns the admin URL to edit the object represented by this log entry.\n This is relative to the Django admin index page.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98639:Return_L54_C8", "label": "return", "type": "return", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L49_C4", "vector": [13, 2, 1.0, 0.0185, 2, 0.13, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u\"%s/%s/%s/\" % (self.content_type.app_label, self.content_type.model, quote(self.object_id)))"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Expr_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Assign_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Return_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Return_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Return_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Return_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Expr_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Return_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Expr_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98639:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98639:Return_L54_C8"}] |
#!/usr/bin/env python
import os
import optparse
import subprocess
import sys
here = os.path.dirname(__file__)
def main():
usage = "usage: %prog [file1..fileN]"
description = """With no file paths given this script will automatically
compress all jQuery-based files of the admin app. Requires the Google Closure
Compiler library and Java version 6 or later."""
parser = optparse.OptionParser(usage, description=description)
parser.add_option("-c", dest="compiler", default="~/bin/compiler.jar",
help="path to Closure Compiler jar file")
parser.add_option("-v", "--verbose",
action="store_true", dest="verbose")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose")
(options, args) = parser.parse_args()
compiler = os.path.expanduser(options.compiler)
if not os.path.exists(compiler):
sys.exit("Google Closure compiler jar file %s not found. Please use the -c option to specify the path." % compiler)
if not args:
if options.verbose:
sys.stdout.write("No filenames given; defaulting to admin scripts\n")
args = [os.path.join(here, f) for f in [
"actions.js", "collapse.js", "inlines.js", "prepopulate.js"]]
for arg in args:
if not arg.endswith(".js"):
arg = arg + ".js"
to_compress = os.path.expanduser(arg)
if os.path.exists(to_compress):
to_compress_min = "%s.min.js" % "".join(arg.rsplit(".js"))
cmd = "java -jar %s --js %s --js_output_file %s" % (compiler, to_compress, to_compress_min)
if options.verbose:
sys.stdout.write("Running: %s\n" % cmd)
subprocess.call(cmd.split())
else:
sys.stdout.write("File %s not found. Sure it exists?\n" % to_compress)
if __name__ == '__main__':
main()
| ajibawa-2023/Python-Code-Large/train/row_98640 | 33 | 47 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Import_L2_C0", "label": "os import os", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0426, 0.0213, 0, 0.66, 0.0, 688, 0, 1, 0, 0, 688, 0, 0], "semantic": {"name": "os", "arg_names": [], "import_names": ["os"], "rhs_call_name": "", "annotation": ""}, "snippet": "import os"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Import_L3_C0", "label": "optparse import optparse", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0638, 0.0213, 0, 0.66, 0.1667, 323, 0, 1, 0, 0, 323, 0, 0], "semantic": {"name": "optparse", "arg_names": [], "import_names": ["optparse"], "rhs_call_name": "", "annotation": ""}, "snippet": "import optparse"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Import_L4_C0", "label": "subprocess import subprocess", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0851, 0.0213, 0, 0.66, 0.3333, 394, 0, 1, 0, 0, 394, 0, 0], "semantic": {"name": "subprocess", "arg_names": [], "import_names": ["subprocess"], "rhs_call_name": "", "annotation": ""}, "snippet": "import subprocess"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Import_L5_C0", "label": "sys import sys", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.1064, 0.0213, 0, 0.66, 0.5, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["sys"], "rhs_call_name": "", "annotation": ""}, "snippet": "import sys"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L7_C0", "label": "here = dirname()", "type": "assigned_variable", "loc": [7, 7], "level": 0, "parent": null, "vector": [14, 0, 0.1489, 0.0213, 0, 0.66, 0.6667, 507, 3, 1, 0, 0, 959, 10, 1], "semantic": {"name": "here", "arg_names": [], "import_names": [], "rhs_call_name": "dirname", "annotation": ""}, "snippet": "here = os.path.dirname(__file__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "label": "main", "type": "function", "loc": [9, 44], "level": 0, "parent": null, "vector": [2, 0, 0.5638, 0.766, 0, 0.66, 0.8333, 624, 0, 0, 0, 0, 0, 0, 19], "semantic": {"name": "main", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def main():\n usage = \"usage: %prog [file1..fileN]\"\n description = \"\"\"With no file paths given this script will automatically\ncompress all jQuery-based files of the admin app. Requires the Google Closure\nCompiler library and Java version 6 or later.\"\"\"\n parser = optparse.OptionParser(usage, description=description)\n parser.add_option(\"-c\", dest=\"compiler\", default=\"~/bin/compiler.jar\",\n help=\"path to Closure Compiler jar file\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L10_C4", "label": "usage =", "type": "assigned_variable", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "vector": [14, 1, 0.2128, 0.0213, 1, 0.91, 0.0, 129, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "usage", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " usage = \"usage: %prog [file1..fileN]\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L11_C4", "label": "description =", "type": "assigned_variable", "loc": [11, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "vector": [14, 1, 0.2553, 0.0638, 1, 0.91, 0.1, 306, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "description", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " description = \"\"\"With no file paths given this script will automatically\ncompress all jQuery-based files of the admin app. Requires the Google Closure\nCompiler library and Java version 6 or later.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L14_C4", "label": "parser = OptionParser()", "type": "assigned_variable", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "vector": [14, 1, 0.2979, 0.0213, 1, 0.91, 0.2, 968, 3, 2, 0, 0, 894, 10, 1], "semantic": {"name": "parser", "arg_names": [], "import_names": [], "rhs_call_name": "OptionParser", "annotation": ""}, "snippet": " parser = optparse.OptionParser(usage, description=description)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L15_C4", "label": "add_option()", "type": "expression", "loc": [15, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "vector": [8, 1, 0.3298, 0.0426, 1, 0.91, 0.3, 176, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "add_option", "arg_names": [], "import_names": [], "rhs_call_name": "add_option", "annotation": ""}, "snippet": " parser.add_option(\"-c\", dest=\"compiler\", default=\"~/bin/compiler.jar\",\n help=\"path to Closure Compiler jar file\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L17_C4", "label": "add_option()", "type": "expression", "loc": [17, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "vector": [8, 1, 0.3723, 0.0426, 1, 0.91, 0.4, 176, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "add_option", "arg_names": [], "import_names": [], "rhs_call_name": "add_option", "annotation": ""}, "snippet": " parser.add_option(\"-v\", \"--verbose\",\n action=\"store_true\", dest=\"verbose\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L19_C4", "label": "add_option()", "type": "expression", "loc": [19, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "vector": [8, 1, 0.4149, 0.0426, 1, 0.91, 0.5, 176, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "add_option", "arg_names": [], "import_names": [], "rhs_call_name": "add_option", "annotation": ""}, "snippet": " parser.add_option(\"-q\", \"--quiet\",\n action=\"store_false\", dest=\"verbose\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L21_C4", "label": "options, args = parse_args()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "vector": [14, 1, 0.4468, 0.0213, 1, 0.91, 0.6, 584, 3, 0, 0, 0, 187, 10, 1], "semantic": {"name": "options, args", "arg_names": [], "import_names": [], "rhs_call_name": "parse_args", "annotation": ""}, "snippet": " (options, args) = parser.parse_args()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L23_C4", "label": "compiler = expanduser()", "type": "assigned_variable", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "vector": [14, 1, 0.4894, 0.0213, 1, 0.91, 0.7, 738, 3, 1, 0, 0, 116, 10, 1], "semantic": {"name": "compiler", "arg_names": [], "import_names": [], "rhs_call_name": "expanduser", "annotation": ""}, "snippet": " compiler = os.path.expanduser(options.compiler)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L24_C4", "label": "if", "type": "if", "loc": [24, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "vector": [4, 1, 0.5213, 0.0426, 1, 0.91, 0.8, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not os.path.exists(compiler):\n sys.exit(\"Google Closure compiler jar file %s not found. Please use the -c option to specify the path.\" % compiler)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L25_C8", "label": "exit()", "type": "expression", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L24_C4", "vector": [8, 2, 0.5319, 0.0213, 2, 0.36, 0.0, 436, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "exit", "arg_names": [], "import_names": [], "rhs_call_name": "exit", "annotation": ""}, "snippet": " sys.exit(\"Google Closure compiler jar file %s not found. Please use the -c option to specify the path.\" % compiler)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L27_C4", "label": "if", "type": "if", "loc": [27, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "vector": [4, 1, 0.617, 0.1064, 1, 0.91, 0.9, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not args:\n if options.verbose:\n sys.stdout.write(\"No filenames given; defaulting to admin scripts\\n\")\n args = [os.path.join(here, f) for f in [\n \"actions.js\", \"collapse.js\", \"inlines.js\", \"prepopulate.js\"]]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L28_C8", "label": "if", "type": "if", "loc": [28, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L27_C4", "vector": [4, 2, 0.6064, 0.0426, 2, 0.0, 0.0, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if options.verbose:\n sys.stdout.write(\"No filenames given; defaulting to admin scripts\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L29_C12", "label": "write()", "type": "expression", "loc": [29, 29], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L28_C8", "vector": [8, 3, 0.617, 0.0213, 3, 0.05, 0.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stdout.write(\"No filenames given; defaulting to admin scripts\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L30_C8", "label": "args =", "type": "assigned_variable", "loc": [30, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L27_C4", "vector": [14, 2, 0.6489, 0.0426, 2, 0.0, 1.0, 805, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " args = [os.path.join(here, f) for f in [\n \"actions.js\", \"collapse.js\", \"inlines.js\", \"prepopulate.js\"]]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:For_L33_C4", "label": "for arg", "type": "for", "loc": [33, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "vector": [6, 1, 0.8191, 0.2553, 1, 0.91, 1.0, 447, 2, 0, 0, 0, 0, 0, 9], "semantic": {"name": "arg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for arg in args:\n if not arg.endswith(\".js\"):\n arg = arg + \".js\"\n to_compress = os.path.expanduser(arg)\n if os.path.exists(to_compress):\n to_compress_min = \"%s.min.js\" % \"\".join(arg.rsplit(\".js\"))\n cmd = \"java -jar %s --js %s --js_output_file %s\" % (compiler, to_compress, to_compress_min)\n if options.verbose:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L34_C8", "label": "if", "type": "if", "loc": [34, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:For_L33_C4", "vector": [4, 2, 0.734, 0.0426, 2, 0.69, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not arg.endswith(\".js\"):\n arg = arg + \".js\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L35_C12", "label": "arg =", "type": "assigned_variable", "loc": [35, 35], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L34_C8", "vector": [14, 3, 0.7447, 0.0213, 3, 0.12, 0.0, 447, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "arg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " arg = arg + \".js\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L36_C8", "label": "to_compress = expanduser()", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:For_L33_C4", "vector": [14, 2, 0.766, 0.0213, 2, 0.69, 0.5, 332, 3, 1, 0, 0, 116, 10, 1], "semantic": {"name": "to_compress", "arg_names": [], "import_names": [], "rhs_call_name": "expanduser", "annotation": ""}, "snippet": " to_compress = os.path.expanduser(arg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L37_C8", "label": "if", "type": "if", "loc": [37, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:For_L33_C4", "vector": [4, 2, 0.8617, 0.1702, 2, 0.69, 1.0, 0, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if os.path.exists(to_compress):\n to_compress_min = \"%s.min.js\" % \"\".join(arg.rsplit(\".js\"))\n cmd = \"java -jar %s --js %s --js_output_file %s\" % (compiler, to_compress, to_compress_min)\n if options.verbose:\n sys.stdout.write(\"Running: %s\\n\" % cmd)\n subprocess.call(cmd.split())\n else:\n sys.stdout.write(\"File %s not found. Sure it exists?\\n\" % to_compress)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L38_C12", "label": "to_compress_min =", "type": "assigned_variable", "loc": [38, 38], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L37_C8", "vector": [14, 3, 0.8085, 0.0213, 3, 0.86, 0.0, 857, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "to_compress_min", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " to_compress_min = \"%s.min.js\" % \"\".join(arg.rsplit(\".js\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L39_C12", "label": "cmd =", "type": "assigned_variable", "loc": [39, 39], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L37_C8", "vector": [14, 3, 0.8298, 0.0213, 3, 0.86, 0.25, 604, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "cmd", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cmd = \"java -jar %s --js %s --js_output_file %s\" % (compiler, to_compress, to_compress_min)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L40_C12", "label": "if", "type": "if", "loc": [40, 41], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L37_C8", "vector": [4, 3, 0.8617, 0.0426, 3, 0.86, 0.5, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if options.verbose:\n sys.stdout.write(\"Running: %s\\n\" % cmd)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L41_C16", "label": "write()", "type": "expression", "loc": [41, 41], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L40_C12", "vector": [8, 4, 0.8723, 0.0213, 4, 0.67, 0.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stdout.write(\"Running: %s\\n\" % cmd)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L42_C12", "label": "call()", "type": "expression", "loc": [42, 42], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L37_C8", "vector": [8, 3, 0.8936, 0.0213, 3, 0.86, 0.75, 832, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "call", "arg_names": [], "import_names": [], "rhs_call_name": "call", "annotation": ""}, "snippet": " subprocess.call(cmd.split())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L44_C12", "label": "write()", "type": "expression", "loc": [44, 44], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L37_C8", "vector": [8, 3, 0.9362, 0.0213, 3, 0.86, 1.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stdout.write(\"File %s not found. Sure it exists?\\n\" % to_compress)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L46_C0", "label": "if", "type": "if", "loc": [46, 47], "level": 0, "parent": null, "vector": [4, 0, 0.9894, 0.0426, 0, 0.66, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if __name__ == '__main__':\n main()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L47_C4", "label": "main()", "type": "expression", "loc": [47, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L46_C0", "vector": [8, 1, 1.0, 0.0213, 1, 0.28, 0.0, 624, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "main", "arg_names": [], "import_names": [], "rhs_call_name": "main", "annotation": ""}, "snippet": " main()"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L28_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L29_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:For_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:For_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L34_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L35_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:For_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:For_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L38_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Assign_L39_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L40_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L40_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L41_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L42_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L44_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98640:If_L46_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98640:Expr_L47_C4"}] |
#!/usr/bin/env python
import os
import optparse
import subprocess
import sys
here = os.path.dirname(__file__)
def main():
usage = "usage: %prog [file1..fileN]"
description = """With no file paths given this script will automatically
compress all jQuery-based files of the admin app. Requires the Google Closure
Compiler library and Java version 6 or later."""
parser = optparse.OptionParser(usage, description=description)
parser.add_option("-c", dest="compiler", default="~/bin/compiler.jar",
help="path to Closure Compiler jar file")
parser.add_option("-v", "--verbose",
action="store_true", dest="verbose")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose")
(options, args) = parser.parse_args()
compiler = os.path.expanduser(options.compiler)
if not os.path.exists(compiler):
sys.exit("Google Closure compiler jar file %s not found. Please use the -c option to specify the path." % compiler)
if not args:
if options.verbose:
sys.stdout.write("No filenames given; defaulting to admin scripts\n")
args = [os.path.join(here, f) for f in [
"actions.js", "collapse.js", "inlines.js", "prepopulate.js"]]
for arg in args:
if not arg.endswith(".js"):
arg = arg + ".js"
to_compress = os.path.expanduser(arg)
if os.path.exists(to_compress):
to_compress_min = "%s.min.js" % "".join(arg.rsplit(".js"))
cmd = "java -jar %s --js %s --js_output_file %s" % (compiler, to_compress, to_compress_min)
if options.verbose:
sys.stdout.write("Running: %s\n" % cmd)
subprocess.call(cmd.split())
else:
sys.stdout.write("File %s not found. Sure it exists?\n" % to_compress)
if __name__ == '__main__':
main()
| ajibawa-2023/Python-Code-Large/train/row_98641 | 33 | 47 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Import_L2_C0", "label": "os import os", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0426, 0.0213, 0, 0.66, 0.0, 688, 0, 1, 0, 0, 688, 0, 0], "semantic": {"name": "os", "arg_names": [], "import_names": ["os"], "rhs_call_name": "", "annotation": ""}, "snippet": "import os"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Import_L3_C0", "label": "optparse import optparse", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0638, 0.0213, 0, 0.66, 0.1667, 323, 0, 1, 0, 0, 323, 0, 0], "semantic": {"name": "optparse", "arg_names": [], "import_names": ["optparse"], "rhs_call_name": "", "annotation": ""}, "snippet": "import optparse"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Import_L4_C0", "label": "subprocess import subprocess", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0851, 0.0213, 0, 0.66, 0.3333, 394, 0, 1, 0, 0, 394, 0, 0], "semantic": {"name": "subprocess", "arg_names": [], "import_names": ["subprocess"], "rhs_call_name": "", "annotation": ""}, "snippet": "import subprocess"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Import_L5_C0", "label": "sys import sys", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.1064, 0.0213, 0, 0.66, 0.5, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["sys"], "rhs_call_name": "", "annotation": ""}, "snippet": "import sys"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L7_C0", "label": "here = dirname()", "type": "assigned_variable", "loc": [7, 7], "level": 0, "parent": null, "vector": [14, 0, 0.1489, 0.0213, 0, 0.66, 0.6667, 507, 3, 1, 0, 0, 959, 10, 1], "semantic": {"name": "here", "arg_names": [], "import_names": [], "rhs_call_name": "dirname", "annotation": ""}, "snippet": "here = os.path.dirname(__file__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "label": "main", "type": "function", "loc": [9, 44], "level": 0, "parent": null, "vector": [2, 0, 0.5638, 0.766, 0, 0.66, 0.8333, 624, 0, 0, 0, 0, 0, 0, 19], "semantic": {"name": "main", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def main():\n usage = \"usage: %prog [file1..fileN]\"\n description = \"\"\"With no file paths given this script will automatically\ncompress all jQuery-based files of the admin app. Requires the Google Closure\nCompiler library and Java version 6 or later.\"\"\"\n parser = optparse.OptionParser(usage, description=description)\n parser.add_option(\"-c\", dest=\"compiler\", default=\"~/bin/compiler.jar\",\n help=\"path to Closure Compiler jar file\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L10_C4", "label": "usage =", "type": "assigned_variable", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "vector": [14, 1, 0.2128, 0.0213, 1, 0.03, 0.0, 129, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "usage", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " usage = \"usage: %prog [file1..fileN]\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L11_C4", "label": "description =", "type": "assigned_variable", "loc": [11, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "vector": [14, 1, 0.2553, 0.0638, 1, 0.03, 0.1, 306, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "description", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " description = \"\"\"With no file paths given this script will automatically\ncompress all jQuery-based files of the admin app. Requires the Google Closure\nCompiler library and Java version 6 or later.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L14_C4", "label": "parser = OptionParser()", "type": "assigned_variable", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "vector": [14, 1, 0.2979, 0.0213, 1, 0.03, 0.2, 968, 3, 2, 0, 0, 894, 10, 1], "semantic": {"name": "parser", "arg_names": [], "import_names": [], "rhs_call_name": "OptionParser", "annotation": ""}, "snippet": " parser = optparse.OptionParser(usage, description=description)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L15_C4", "label": "add_option()", "type": "expression", "loc": [15, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "vector": [8, 1, 0.3298, 0.0426, 1, 0.03, 0.3, 176, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "add_option", "arg_names": [], "import_names": [], "rhs_call_name": "add_option", "annotation": ""}, "snippet": " parser.add_option(\"-c\", dest=\"compiler\", default=\"~/bin/compiler.jar\",\n help=\"path to Closure Compiler jar file\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L17_C4", "label": "add_option()", "type": "expression", "loc": [17, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "vector": [8, 1, 0.3723, 0.0426, 1, 0.03, 0.4, 176, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "add_option", "arg_names": [], "import_names": [], "rhs_call_name": "add_option", "annotation": ""}, "snippet": " parser.add_option(\"-v\", \"--verbose\",\n action=\"store_true\", dest=\"verbose\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L19_C4", "label": "add_option()", "type": "expression", "loc": [19, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "vector": [8, 1, 0.4149, 0.0426, 1, 0.03, 0.5, 176, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "add_option", "arg_names": [], "import_names": [], "rhs_call_name": "add_option", "annotation": ""}, "snippet": " parser.add_option(\"-q\", \"--quiet\",\n action=\"store_false\", dest=\"verbose\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L21_C4", "label": "options, args = parse_args()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "vector": [14, 1, 0.4468, 0.0213, 1, 0.03, 0.6, 584, 3, 0, 0, 0, 187, 10, 1], "semantic": {"name": "options, args", "arg_names": [], "import_names": [], "rhs_call_name": "parse_args", "annotation": ""}, "snippet": " (options, args) = parser.parse_args()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L23_C4", "label": "compiler = expanduser()", "type": "assigned_variable", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "vector": [14, 1, 0.4894, 0.0213, 1, 0.03, 0.7, 738, 3, 1, 0, 0, 116, 10, 1], "semantic": {"name": "compiler", "arg_names": [], "import_names": [], "rhs_call_name": "expanduser", "annotation": ""}, "snippet": " compiler = os.path.expanduser(options.compiler)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L24_C4", "label": "if", "type": "if", "loc": [24, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "vector": [4, 1, 0.5213, 0.0426, 1, 0.03, 0.8, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not os.path.exists(compiler):\n sys.exit(\"Google Closure compiler jar file %s not found. Please use the -c option to specify the path.\" % compiler)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L25_C8", "label": "exit()", "type": "expression", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L24_C4", "vector": [8, 2, 0.5319, 0.0213, 2, 0.67, 0.0, 436, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "exit", "arg_names": [], "import_names": [], "rhs_call_name": "exit", "annotation": ""}, "snippet": " sys.exit(\"Google Closure compiler jar file %s not found. Please use the -c option to specify the path.\" % compiler)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L27_C4", "label": "if", "type": "if", "loc": [27, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "vector": [4, 1, 0.617, 0.1064, 1, 0.03, 0.9, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not args:\n if options.verbose:\n sys.stdout.write(\"No filenames given; defaulting to admin scripts\\n\")\n args = [os.path.join(here, f) for f in [\n \"actions.js\", \"collapse.js\", \"inlines.js\", \"prepopulate.js\"]]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L28_C8", "label": "if", "type": "if", "loc": [28, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L27_C4", "vector": [4, 2, 0.6064, 0.0426, 2, 0.74, 0.0, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if options.verbose:\n sys.stdout.write(\"No filenames given; defaulting to admin scripts\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L29_C12", "label": "write()", "type": "expression", "loc": [29, 29], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L28_C8", "vector": [8, 3, 0.617, 0.0213, 3, 0.3, 0.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stdout.write(\"No filenames given; defaulting to admin scripts\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L30_C8", "label": "args =", "type": "assigned_variable", "loc": [30, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L27_C4", "vector": [14, 2, 0.6489, 0.0426, 2, 0.74, 1.0, 805, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " args = [os.path.join(here, f) for f in [\n \"actions.js\", \"collapse.js\", \"inlines.js\", \"prepopulate.js\"]]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:For_L33_C4", "label": "for arg", "type": "for", "loc": [33, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "vector": [6, 1, 0.8191, 0.2553, 1, 0.03, 1.0, 447, 2, 0, 0, 0, 0, 0, 9], "semantic": {"name": "arg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for arg in args:\n if not arg.endswith(\".js\"):\n arg = arg + \".js\"\n to_compress = os.path.expanduser(arg)\n if os.path.exists(to_compress):\n to_compress_min = \"%s.min.js\" % \"\".join(arg.rsplit(\".js\"))\n cmd = \"java -jar %s --js %s --js_output_file %s\" % (compiler, to_compress, to_compress_min)\n if options.verbose:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L34_C8", "label": "if", "type": "if", "loc": [34, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:For_L33_C4", "vector": [4, 2, 0.734, 0.0426, 2, 0.67, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not arg.endswith(\".js\"):\n arg = arg + \".js\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L35_C12", "label": "arg =", "type": "assigned_variable", "loc": [35, 35], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L34_C8", "vector": [14, 3, 0.7447, 0.0213, 3, 0.91, 0.0, 447, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "arg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " arg = arg + \".js\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L36_C8", "label": "to_compress = expanduser()", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:For_L33_C4", "vector": [14, 2, 0.766, 0.0213, 2, 0.67, 0.5, 332, 3, 1, 0, 0, 116, 10, 1], "semantic": {"name": "to_compress", "arg_names": [], "import_names": [], "rhs_call_name": "expanduser", "annotation": ""}, "snippet": " to_compress = os.path.expanduser(arg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L37_C8", "label": "if", "type": "if", "loc": [37, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:For_L33_C4", "vector": [4, 2, 0.8617, 0.1702, 2, 0.67, 1.0, 0, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if os.path.exists(to_compress):\n to_compress_min = \"%s.min.js\" % \"\".join(arg.rsplit(\".js\"))\n cmd = \"java -jar %s --js %s --js_output_file %s\" % (compiler, to_compress, to_compress_min)\n if options.verbose:\n sys.stdout.write(\"Running: %s\\n\" % cmd)\n subprocess.call(cmd.split())\n else:\n sys.stdout.write(\"File %s not found. Sure it exists?\\n\" % to_compress)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L38_C12", "label": "to_compress_min =", "type": "assigned_variable", "loc": [38, 38], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L37_C8", "vector": [14, 3, 0.8085, 0.0213, 3, 0.6, 0.0, 857, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "to_compress_min", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " to_compress_min = \"%s.min.js\" % \"\".join(arg.rsplit(\".js\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L39_C12", "label": "cmd =", "type": "assigned_variable", "loc": [39, 39], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L37_C8", "vector": [14, 3, 0.8298, 0.0213, 3, 0.6, 0.25, 604, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "cmd", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cmd = \"java -jar %s --js %s --js_output_file %s\" % (compiler, to_compress, to_compress_min)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L40_C12", "label": "if", "type": "if", "loc": [40, 41], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L37_C8", "vector": [4, 3, 0.8617, 0.0426, 3, 0.6, 0.5, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if options.verbose:\n sys.stdout.write(\"Running: %s\\n\" % cmd)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L41_C16", "label": "write()", "type": "expression", "loc": [41, 41], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L40_C12", "vector": [8, 4, 0.8723, 0.0213, 4, 0.16, 0.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stdout.write(\"Running: %s\\n\" % cmd)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L42_C12", "label": "call()", "type": "expression", "loc": [42, 42], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L37_C8", "vector": [8, 3, 0.8936, 0.0213, 3, 0.6, 0.75, 832, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "call", "arg_names": [], "import_names": [], "rhs_call_name": "call", "annotation": ""}, "snippet": " subprocess.call(cmd.split())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L44_C12", "label": "write()", "type": "expression", "loc": [44, 44], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L37_C8", "vector": [8, 3, 0.9362, 0.0213, 3, 0.6, 1.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stdout.write(\"File %s not found. Sure it exists?\\n\" % to_compress)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L46_C0", "label": "if", "type": "if", "loc": [46, 47], "level": 0, "parent": null, "vector": [4, 0, 0.9894, 0.0426, 0, 0.66, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if __name__ == '__main__':\n main()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L47_C4", "label": "main()", "type": "expression", "loc": [47, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L46_C0", "vector": [8, 1, 1.0, 0.0213, 1, 0.84, 0.0, 624, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "main", "arg_names": [], "import_names": [], "rhs_call_name": "main", "annotation": ""}, "snippet": " main()"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L28_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L29_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:For_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:For_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L34_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L35_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:For_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:For_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L38_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Assign_L39_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L40_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L40_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L41_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L42_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L44_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98641:If_L46_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98641:Expr_L47_C4"}] |
"""
FilterSpec encapsulates the logic for displaying filters in the Django admin.
Filters are specified in models with the "list_filter" option.
Each filter subclass knows how to display a filter for a field that passes a
certain test -- e.g. being a DateField or ForeignKey.
"""
from django.db import models
from django.utils.encoding import smart_unicode, iri_to_uri
from django.utils.translation import ugettext as _
from django.utils.html import escape
from django.utils.safestring import mark_safe
import datetime
class FilterSpec(object):
filter_specs = []
def __init__(self, f, request, params, model, model_admin):
self.field = f
self.params = params
def register(cls, test, factory):
cls.filter_specs.append((test, factory))
register = classmethod(register)
def create(cls, f, request, params, model, model_admin):
for test, factory in cls.filter_specs:
if test(f):
return factory(f, request, params, model, model_admin)
create = classmethod(create)
def has_output(self):
return True
def choices(self, cl):
raise NotImplementedError()
def title(self):
return self.field.verbose_name
def output(self, cl):
t = []
if self.has_output():
t.append(_(u'<h3>By %s:</h3>\n<ul>\n') % escape(self.title()))
for choice in self.choices(cl):
t.append(u'<li%s><a href="%s">%s</a></li>\n' % \
((choice['selected'] and ' class="selected"' or ''),
iri_to_uri(choice['query_string']),
choice['display']))
t.append('</ul>\n\n')
return mark_safe("".join(t))
class RelatedFilterSpec(FilterSpec):
def __init__(self, f, request, params, model, model_admin):
super(RelatedFilterSpec, self).__init__(f, request, params, model, model_admin)
if isinstance(f, models.ManyToManyField):
self.lookup_title = f.rel.to._meta.verbose_name
else:
self.lookup_title = f.verbose_name
rel_name = f.rel.get_related_field().name
self.lookup_kwarg = '%s__%s__exact' % (f.name, rel_name)
self.lookup_val = request.GET.get(self.lookup_kwarg, None)
self.lookup_choices = f.get_choices(include_blank=False)
def has_output(self):
return len(self.lookup_choices) > 1
def title(self):
return self.lookup_title
def choices(self, cl):
yield {'selected': self.lookup_val is None,
'query_string': cl.get_query_string({}, [self.lookup_kwarg]),
'display': _('All')}
for pk_val, val in self.lookup_choices:
yield {'selected': self.lookup_val == smart_unicode(pk_val),
'query_string': cl.get_query_string({self.lookup_kwarg: pk_val}),
'display': val}
FilterSpec.register(lambda f: bool(f.rel), RelatedFilterSpec)
class ChoicesFilterSpec(FilterSpec):
def __init__(self, f, request, params, model, model_admin):
super(ChoicesFilterSpec, self).__init__(f, request, params, model, model_admin)
self.lookup_kwarg = '%s__exact' % f.name
self.lookup_val = request.GET.get(self.lookup_kwarg, None)
def choices(self, cl):
yield {'selected': self.lookup_val is None,
'query_string': cl.get_query_string({}, [self.lookup_kwarg]),
'display': _('All')}
for k, v in self.field.flatchoices:
yield {'selected': smart_unicode(k) == self.lookup_val,
'query_string': cl.get_query_string({self.lookup_kwarg: k}),
'display': v}
FilterSpec.register(lambda f: bool(f.choices), ChoicesFilterSpec)
class DateFieldFilterSpec(FilterSpec):
def __init__(self, f, request, params, model, model_admin):
super(DateFieldFilterSpec, self).__init__(f, request, params, model, model_admin)
self.field_generic = '%s__' % self.field.name
self.date_params = dict([(k, v) for k, v in params.items() if k.startswith(self.field_generic)])
today = datetime.date.today()
one_week_ago = today - datetime.timedelta(days=7)
today_str = isinstance(self.field, models.DateTimeField) and today.strftime('%Y-%m-%d 23:59:59') or today.strftime('%Y-%m-%d')
self.links = (
(_('Any date'), {}),
(_('Today'), {'%s__year' % self.field.name: str(today.year),
'%s__month' % self.field.name: str(today.month),
'%s__day' % self.field.name: str(today.day)}),
(_('Past 7 days'), {'%s__gte' % self.field.name: one_week_ago.strftime('%Y-%m-%d'),
'%s__lte' % f.name: today_str}),
(_('This month'), {'%s__year' % self.field.name: str(today.year),
'%s__month' % f.name: str(today.month)}),
(_('This year'), {'%s__year' % self.field.name: str(today.year)})
)
def title(self):
return self.field.verbose_name
def choices(self, cl):
for title, param_dict in self.links:
yield {'selected': self.date_params == param_dict,
'query_string': cl.get_query_string(param_dict, [self.field_generic]),
'display': title}
FilterSpec.register(lambda f: isinstance(f, models.DateField), DateFieldFilterSpec)
class BooleanFieldFilterSpec(FilterSpec):
def __init__(self, f, request, params, model, model_admin):
super(BooleanFieldFilterSpec, self).__init__(f, request, params, model, model_admin)
self.lookup_kwarg = '%s__exact' % f.name
self.lookup_kwarg2 = '%s__isnull' % f.name
self.lookup_val = request.GET.get(self.lookup_kwarg, None)
self.lookup_val2 = request.GET.get(self.lookup_kwarg2, None)
def title(self):
return self.field.verbose_name
def choices(self, cl):
for k, v in ((_('All'), None), (_('Yes'), '1'), (_('No'), '0')):
yield {'selected': self.lookup_val == v and not self.lookup_val2,
'query_string': cl.get_query_string({self.lookup_kwarg: v}, [self.lookup_kwarg2]),
'display': k}
if isinstance(self.field, models.NullBooleanField):
yield {'selected': self.lookup_val2 == 'True',
'query_string': cl.get_query_string({self.lookup_kwarg2: 'True'}, [self.lookup_kwarg]),
'display': _('Unknown')}
FilterSpec.register(lambda f: isinstance(f, models.BooleanField) or isinstance(f, models.NullBooleanField), BooleanFieldFilterSpec)
# This should be registered last, because it's a last resort. For example,
# if a field is eligible to use the BooleanFieldFilterSpec, that'd be much
# more appropriate, and the AllValuesFilterSpec won't get used for it.
class AllValuesFilterSpec(FilterSpec):
def __init__(self, f, request, params, model, model_admin):
super(AllValuesFilterSpec, self).__init__(f, request, params, model, model_admin)
self.lookup_val = request.GET.get(f.name, None)
self.lookup_choices = model_admin.queryset(request).distinct().order_by(f.name).values(f.name)
def title(self):
return self.field.verbose_name
def choices(self, cl):
yield {'selected': self.lookup_val is None,
'query_string': cl.get_query_string({}, [self.field.name]),
'display': _('All')}
for val in self.lookup_choices:
val = smart_unicode(val[self.field.name])
yield {'selected': self.lookup_val == val,
'query_string': cl.get_query_string({self.field.name: val}),
'display': val}
FilterSpec.register(lambda f: True, AllValuesFilterSpec)
| ajibawa-2023/Python-Code-Large/train/row_98642 | 105 | 179 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 7], "level": 0, "parent": null, "vector": [8, 0, 0.0223, 0.0391, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nFilterSpec encapsulates the logic for displaying filters in the Django admin.\nFilters are specified in models with the \"list_filter\" option.\n\nEach filter subclass knows how to display a filter for a field that passes a\ncertain test -- e.g. being a DateField or ForeignKey.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:ImportFrom_L9_C0", "label": "from django.db import models", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0503, 0.0056, 0, 0.66, 0.0588, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:ImportFrom_L10_C0", "label": "from django.utils.encoding import smart_unicode, iri_to_uri", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0559, 0.0056, 0, 0.66, 0.1176, 96, 0, 2, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_unicode", "iri_to_uri"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_unicode, iri_to_uri"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:ImportFrom_L11_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0615, 0.0056, 0, 0.66, 0.1765, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:ImportFrom_L12_C0", "label": "from django.utils.html import escape", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.067, 0.0056, 0, 0.66, 0.2353, 535, 0, 1, 0, 0, 535, 0, 0], "semantic": {"name": "django.utils.html", "arg_names": [], "import_names": ["escape"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.html import escape"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:ImportFrom_L13_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0726, 0.0056, 0, 0.66, 0.2941, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.safestring", "arg_names": [], "import_names": ["mark_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.safestring import mark_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Import_L14_C0", "label": "datetime import datetime", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.0782, 0.0056, 0, 0.66, 0.3529, 426, 0, 1, 0, 0, 426, 0, 0], "semantic": {"name": "datetime", "arg_names": [], "import_names": ["datetime"], "rhs_call_name": "", "annotation": ""}, "snippet": "import datetime"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "label": "FilterSpec", "type": "class", "loc": [16, 52], "level": 0, "parent": null, "vector": [3, 0, 0.1899, 0.2067, 0, 0.66, 0.4118, 253, 0, 7, 0, 0, 186, 0, 17], "semantic": {"name": "FilterSpec", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class FilterSpec(object):\n filter_specs = []\n def __init__(self, f, request, params, model, model_admin):\n self.field = f\n self.params = params\n\n def register(cls, test, factory):\n cls.filter_specs.append((test, factory))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L17_C4", "label": "filter_specs =", "type": "assigned_variable", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "vector": [14, 1, 0.095, 0.0056, 1, 0.37, 0.0, 355, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "filter_specs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " filter_specs = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L18_C4", "label": "__init__", "type": "function", "loc": [18, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "vector": [2, 1, 0.1061, 0.0168, 1, 0.37, 0.1111, 555, 0, 6, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "f", "request", "params", "model", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, f, request, params, model, model_admin):\n self.field = f\n self.params = params"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L19_C8", "label": "self.field =", "type": "assigned_variable", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L18_C4", "vector": [14, 2, 0.1061, 0.0056, 2, 0.52, 0.0, 951, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.field = f"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L20_C8", "label": "self.params =", "type": "assigned_variable", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L18_C4", "vector": [14, 2, 0.1117, 0.0056, 2, 0.52, 1.0, 402, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.params", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.params = params"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L22_C4", "label": "register", "type": "function", "loc": [22, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "vector": [2, 1, 0.1257, 0.0112, 1, 0.37, 0.2222, 276, 0, 3, 0, 0, 0, 0, 1], "semantic": {"name": "register", "arg_names": ["cls", "test", "factory"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def register(cls, test, factory):\n cls.filter_specs.append((test, factory))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L23_C8", "label": "append()", "type": "expression", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L22_C4", "vector": [8, 2, 0.1285, 0.0056, 2, 0.28, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " cls.filter_specs.append((test, factory))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L24_C4", "label": "register = classmethod()", "type": "assigned_variable", "loc": [24, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "vector": [14, 1, 0.1341, 0.0056, 1, 0.37, 0.3333, 276, 3, 1, 0, 0, 76, 10, 1], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "classmethod", "annotation": ""}, "snippet": " register = classmethod(register)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L26_C4", "label": "create", "type": "function", "loc": [26, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "vector": [2, 1, 0.1536, 0.0223, 1, 0.37, 0.4444, 316, 0, 6, 1, 0, 0, 0, 2], "semantic": {"name": "create", "arg_names": ["cls", "f", "request", "params", "model", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def create(cls, f, request, params, model, model_admin):\n for test, factory in cls.filter_specs:\n if test(f):\n return factory(f, request, params, model, model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L27_C8", "label": "for test, factory", "type": "for", "loc": [27, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L26_C4", "vector": [6, 2, 0.1564, 0.0168, 2, 0.28, 0.0, 940, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "test, factory", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for test, factory in cls.filter_specs:\n if test(f):\n return factory(f, request, params, model, model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L28_C12", "label": "if", "type": "if", "loc": [28, 29], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L27_C8", "vector": [4, 3, 0.1592, 0.0112, 3, 0.47, 0.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if test(f):\n return factory(f, request, params, model, model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L29_C16", "label": "return", "type": "return", "loc": [29, 29], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L28_C12", "vector": [13, 4, 0.162, 0.0056, 4, 0.66, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return factory(f, request, params, model, model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L30_C4", "label": "create = classmethod()", "type": "assigned_variable", "loc": [30, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "vector": [14, 1, 0.1676, 0.0056, 1, 0.37, 0.5556, 316, 3, 1, 0, 0, 76, 10, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "classmethod", "annotation": ""}, "snippet": " create = classmethod(create)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L32_C4", "label": "has_output", "type": "function", "loc": [32, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "vector": [2, 1, 0.1816, 0.0112, 1, 0.37, 0.6667, 460, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "has_output", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_output(self):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L33_C8", "label": "return", "type": "return", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L32_C4", "vector": [13, 2, 0.1844, 0.0056, 2, 0.71, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L35_C4", "label": "choices", "type": "function", "loc": [35, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "vector": [2, 1, 0.1983, 0.0112, 1, 0.37, 0.7778, 405, 0, 2, 0, 0, 0, 0, 1], "semantic": {"name": "choices", "arg_names": ["self", "cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def choices(self, cl):\n raise NotImplementedError()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L38_C4", "label": "title", "type": "function", "loc": [38, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "vector": [2, 1, 0.2151, 0.0112, 1, 0.37, 0.8889, 48, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "title", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def title(self):\n return self.field.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L39_C8", "label": "return", "type": "return", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L38_C4", "vector": [13, 2, 0.2179, 0.0056, 2, 0.46, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.field.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L41_C4", "label": "output", "type": "function", "loc": [41, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "vector": [2, 1, 0.2598, 0.067, 1, 0.37, 1.0, 886, 0, 2, 1, 0, 0, 0, 11], "semantic": {"name": "output", "arg_names": ["self", "cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def output(self, cl):\n t = []\n if self.has_output():\n t.append(_(u'<h3>By %s:</h3>\\n<ul>\\n') % escape(self.title()))\n\n for choice in self.choices(cl):\n t.append(u'<li%s><a href=\"%s\">%s</a></li>\\n' % \\\n ((choice['selected'] and ' class=\"selected\"' or ''),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L42_C8", "label": "t =", "type": "assigned_variable", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L41_C4", "vector": [14, 2, 0.2346, 0.0056, 2, 0.58, 0.0, 15, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "t", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " t = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L43_C8", "label": "if", "type": "if", "loc": [43, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L41_C4", "vector": [4, 2, 0.2626, 0.0503, 2, 0.58, 0.5, 0, 3, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.has_output():\n t.append(_(u'<h3>By %s:</h3>\\n<ul>\\n') % escape(self.title()))\n\n for choice in self.choices(cl):\n t.append(u'<li%s><a href=\"%s\">%s</a></li>\\n' % \\\n ((choice['selected'] and ' class=\"selected\"' or ''),\n iri_to_uri(choice['query_string']),\n choice['display']))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L44_C12", "label": "append()", "type": "expression", "loc": [44, 44], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L43_C8", "vector": [8, 3, 0.2458, 0.0056, 3, 0.36, 0.0, 243, 3, 1, 0, 0, 0, 0, 4], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " t.append(_(u'<h3>By %s:</h3>\\n<ul>\\n') % escape(self.title()))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L46_C12", "label": "for choice", "type": "for", "loc": [46, 50], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L43_C8", "vector": [6, 3, 0.2682, 0.0279, 3, 0.36, 0.5, 30, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "choice", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for choice in self.choices(cl):\n t.append(u'<li%s><a href=\"%s\">%s</a></li>\\n' % \\\n ((choice['selected'] and ' class=\"selected\"' or ''),\n iri_to_uri(choice['query_string']),\n choice['display']))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L47_C16", "label": "append()", "type": "expression", "loc": [47, 50], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L46_C12", "vector": [8, 4, 0.2709, 0.0223, 4, 0.47, 0.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " t.append(u'<li%s><a href=\"%s\">%s</a></li>\\n' % \\\n ((choice['selected'] and ' class=\"selected\"' or ''),\n iri_to_uri(choice['query_string']),\n choice['display']))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L51_C12", "label": "append()", "type": "expression", "loc": [51, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L43_C8", "vector": [8, 3, 0.2849, 0.0056, 3, 0.36, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " t.append('</ul>\\n\\n')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L52_C8", "label": "return", "type": "return", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L41_C4", "vector": [13, 2, 0.2905, 0.0056, 2, 0.58, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(\"\".join(t))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L54_C0", "label": "RelatedFilterSpec", "type": "class", "loc": [54, 79], "level": 0, "parent": null, "vector": [3, 0, 0.3715, 0.1453, 0, 0.66, 0.4706, 695, 0, 4, 0, 0, 253, 0, 11], "semantic": {"name": "RelatedFilterSpec", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RelatedFilterSpec(FilterSpec):\n def __init__(self, f, request, params, model, model_admin):\n super(RelatedFilterSpec, self).__init__(f, request, params, model, model_admin)\n if isinstance(f, models.ManyToManyField):\n self.lookup_title = f.rel.to._meta.verbose_name\n else:\n self.lookup_title = f.verbose_name\n rel_name = f.rel.get_related_field().name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "label": "__init__", "type": "function", "loc": [55, 64], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L54_C0", "vector": [2, 1, 0.3324, 0.0559, 1, 0.77, 0.0, 555, 0, 6, 0, 0, 0, 0, 6], "semantic": {"name": "__init__", "arg_names": ["self", "f", "request", "params", "model", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, f, request, params, model, model_admin):\n super(RelatedFilterSpec, self).__init__(f, request, params, model, model_admin)\n if isinstance(f, models.ManyToManyField):\n self.lookup_title = f.rel.to._meta.verbose_name\n else:\n self.lookup_title = f.verbose_name\n rel_name = f.rel.get_related_field().name\n self.lookup_kwarg = '%s__%s__exact' % (f.name, rel_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L56_C8", "label": "__init__()", "type": "expression", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "vector": [8, 2, 0.3128, 0.0056, 2, 0.17, 0.0, 555, 3, 5, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(RelatedFilterSpec, self).__init__(f, request, params, model, model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L57_C8", "label": "if", "type": "if", "loc": [57, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "vector": [4, 2, 0.3268, 0.0223, 2, 0.17, 0.2, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f, models.ManyToManyField):\n self.lookup_title = f.rel.to._meta.verbose_name\n else:\n self.lookup_title = f.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L58_C12", "label": "self.lookup_title =", "type": "assigned_variable", "loc": [58, 58], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L57_C8", "vector": [14, 3, 0.324, 0.0056, 3, 0.09, 0.0, 640, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.lookup_title", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.lookup_title = f.rel.to._meta.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L60_C12", "label": "self.lookup_title =", "type": "assigned_variable", "loc": [60, 60], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L57_C8", "vector": [14, 3, 0.3352, 0.0056, 3, 0.09, 1.0, 640, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.lookup_title", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.lookup_title = f.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L61_C8", "label": "rel_name =", "type": "assigned_variable", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "vector": [14, 2, 0.3408, 0.0056, 2, 0.17, 0.4, 705, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "rel_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " rel_name = f.rel.get_related_field().name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L62_C8", "label": "self.lookup_kwarg =", "type": "assigned_variable", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "vector": [14, 2, 0.3464, 0.0056, 2, 0.17, 0.6, 144, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.lookup_kwarg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.lookup_kwarg = '%s__%s__exact' % (f.name, rel_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L63_C8", "label": "self.lookup_val = get()", "type": "assigned_variable", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "vector": [14, 2, 0.352, 0.0056, 2, 0.17, 0.8, 292, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "self.lookup_val", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " self.lookup_val = request.GET.get(self.lookup_kwarg, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L64_C8", "label": "self.lookup_choices = get_choices()", "type": "assigned_variable", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "vector": [14, 2, 0.3575, 0.0056, 2, 0.17, 1.0, 468, 3, 1, 0, 0, 452, 10, 1], "semantic": {"name": "self.lookup_choices", "arg_names": [], "import_names": [], "rhs_call_name": "get_choices", "annotation": ""}, "snippet": " self.lookup_choices = f.get_choices(include_blank=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L66_C4", "label": "has_output", "type": "function", "loc": [66, 67], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L54_C0", "vector": [2, 1, 0.3715, 0.0112, 1, 0.77, 0.3333, 460, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "has_output", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_output(self):\n return len(self.lookup_choices) > 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L67_C8", "label": "return", "type": "return", "loc": [67, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L66_C4", "vector": [13, 2, 0.3743, 0.0056, 2, 0.75, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return len(self.lookup_choices) > 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L69_C4", "label": "title", "type": "function", "loc": [69, 70], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L54_C0", "vector": [2, 1, 0.3883, 0.0112, 1, 0.77, 0.6667, 48, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "title", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def title(self):\n return self.lookup_title"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L70_C8", "label": "return", "type": "return", "loc": [70, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L69_C4", "vector": [13, 2, 0.3911, 0.0056, 2, 0.84, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.lookup_title"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L72_C4", "label": "choices", "type": "function", "loc": [72, 79], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L54_C0", "vector": [2, 1, 0.4218, 0.0447, 1, 0.77, 1.0, 405, 0, 2, 0, 0, 0, 0, 4], "semantic": {"name": "choices", "arg_names": ["self", "cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def choices(self, cl):\n yield {'selected': self.lookup_val is None,\n 'query_string': cl.get_query_string({}, [self.lookup_kwarg]),\n 'display': _('All')}\n for pk_val, val in self.lookup_choices:\n yield {'selected': self.lookup_val == smart_unicode(pk_val),\n 'query_string': cl.get_query_string({self.lookup_kwarg: pk_val}),\n 'display': val}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L73_C8", "label": "expression", "type": "expression", "loc": [73, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L72_C4", "vector": [8, 2, 0.4134, 0.0168, 2, 0.07, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {'selected': self.lookup_val is None,\n 'query_string': cl.get_query_string({}, [self.lookup_kwarg]),\n 'display': _('All')}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L76_C8", "label": "for pk_val, val", "type": "for", "loc": [76, 79], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L72_C4", "vector": [6, 2, 0.433, 0.0223, 2, 0.07, 1.0, 156, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "pk_val, val", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for pk_val, val in self.lookup_choices:\n yield {'selected': self.lookup_val == smart_unicode(pk_val),\n 'query_string': cl.get_query_string({self.lookup_kwarg: pk_val}),\n 'display': val}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L77_C12", "label": "expression", "type": "expression", "loc": [77, 79], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L76_C8", "vector": [8, 3, 0.4358, 0.0168, 3, 0.22, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {'selected': self.lookup_val == smart_unicode(pk_val),\n 'query_string': cl.get_query_string({self.lookup_kwarg: pk_val}),\n 'display': val}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L81_C0", "label": "register()", "type": "expression", "loc": [81, 81], "level": 0, "parent": null, "vector": [8, 0, 0.4525, 0.0056, 0, 0.66, 0.5294, 276, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "register", "annotation": ""}, "snippet": "FilterSpec.register(lambda f: bool(f.rel), RelatedFilterSpec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L83_C0", "label": "ChoicesFilterSpec", "type": "class", "loc": [83, 96], "level": 0, "parent": null, "vector": [3, 0, 0.5, 0.0782, 0, 0.66, 0.5882, 649, 0, 2, 0, 0, 253, 0, 7], "semantic": {"name": "ChoicesFilterSpec", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ChoicesFilterSpec(FilterSpec):\n def __init__(self, f, request, params, model, model_admin):\n super(ChoicesFilterSpec, self).__init__(f, request, params, model, model_admin)\n self.lookup_kwarg = '%s__exact' % f.name\n self.lookup_val = request.GET.get(self.lookup_kwarg, None)\n\n def choices(self, cl):\n yield {'selected': self.lookup_val is None,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L84_C4", "label": "__init__", "type": "function", "loc": [84, 87], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L83_C0", "vector": [2, 1, 0.4777, 0.0223, 1, 0.76, 0.0, 555, 0, 6, 0, 0, 0, 0, 3], "semantic": {"name": "__init__", "arg_names": ["self", "f", "request", "params", "model", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, f, request, params, model, model_admin):\n super(ChoicesFilterSpec, self).__init__(f, request, params, model, model_admin)\n self.lookup_kwarg = '%s__exact' % f.name\n self.lookup_val = request.GET.get(self.lookup_kwarg, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L85_C8", "label": "__init__()", "type": "expression", "loc": [85, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L84_C4", "vector": [8, 2, 0.4749, 0.0056, 2, 0.89, 0.0, 555, 3, 5, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(ChoicesFilterSpec, self).__init__(f, request, params, model, model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L86_C8", "label": "self.lookup_kwarg =", "type": "assigned_variable", "loc": [86, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L84_C4", "vector": [14, 2, 0.4804, 0.0056, 2, 0.89, 0.5, 144, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.lookup_kwarg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.lookup_kwarg = '%s__exact' % f.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L87_C8", "label": "self.lookup_val = get()", "type": "assigned_variable", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L84_C4", "vector": [14, 2, 0.486, 0.0056, 2, 0.89, 1.0, 292, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "self.lookup_val", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " self.lookup_val = request.GET.get(self.lookup_kwarg, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L89_C4", "label": "choices", "type": "function", "loc": [89, 96], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L83_C0", "vector": [2, 1, 0.5168, 0.0447, 1, 0.76, 1.0, 405, 0, 2, 0, 0, 0, 0, 4], "semantic": {"name": "choices", "arg_names": ["self", "cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def choices(self, cl):\n yield {'selected': self.lookup_val is None,\n 'query_string': cl.get_query_string({}, [self.lookup_kwarg]),\n 'display': _('All')}\n for k, v in self.field.flatchoices:\n yield {'selected': smart_unicode(k) == self.lookup_val,\n 'query_string': cl.get_query_string({self.lookup_kwarg: k}),\n 'display': v}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L90_C8", "label": "expression", "type": "expression", "loc": [90, 92], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L89_C4", "vector": [8, 2, 0.5084, 0.0168, 2, 0.12, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {'selected': self.lookup_val is None,\n 'query_string': cl.get_query_string({}, [self.lookup_kwarg]),\n 'display': _('All')}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L93_C8", "label": "for k, v", "type": "for", "loc": [93, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L89_C4", "vector": [6, 2, 0.5279, 0.0223, 2, 0.12, 1.0, 867, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "k, v", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for k, v in self.field.flatchoices:\n yield {'selected': smart_unicode(k) == self.lookup_val,\n 'query_string': cl.get_query_string({self.lookup_kwarg: k}),\n 'display': v}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L94_C12", "label": "expression", "type": "expression", "loc": [94, 96], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L93_C8", "vector": [8, 3, 0.5307, 0.0168, 3, 0.21, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {'selected': smart_unicode(k) == self.lookup_val,\n 'query_string': cl.get_query_string({self.lookup_kwarg: k}),\n 'display': v}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L98_C0", "label": "register()", "type": "expression", "loc": [98, 98], "level": 0, "parent": null, "vector": [8, 0, 0.5475, 0.0056, 0, 0.66, 0.6471, 276, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "register", "annotation": ""}, "snippet": "FilterSpec.register(lambda f: bool(f.choices), ChoicesFilterSpec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L100_C0", "label": "DateFieldFilterSpec", "type": "class", "loc": [100, 131], "level": 0, "parent": null, "vector": [3, 0, 0.6453, 0.1788, 0, 0.66, 0.7059, 58, 0, 3, 0, 0, 253, 0, 23], "semantic": {"name": "DateFieldFilterSpec", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DateFieldFilterSpec(FilterSpec):\n def __init__(self, f, request, params, model, model_admin):\n super(DateFieldFilterSpec, self).__init__(f, request, params, model, model_admin)\n\n self.field_generic = '%s__' % self.field.name\n\n self.date_params = dict([(k, v) for k, v in params.items() if k.startswith(self.field_generic)])\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "label": "__init__", "type": "function", "loc": [101, 122], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L100_C0", "vector": [2, 1, 0.6229, 0.1229, 1, 0.26, 0.0, 555, 0, 6, 0, 0, 0, 0, 22], "semantic": {"name": "__init__", "arg_names": ["self", "f", "request", "params", "model", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, f, request, params, model, model_admin):\n super(DateFieldFilterSpec, self).__init__(f, request, params, model, model_admin)\n\n self.field_generic = '%s__' % self.field.name\n\n self.date_params = dict([(k, v) for k, v in params.items() if k.startswith(self.field_generic)])\n\n today = datetime.date.today()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L102_C8", "label": "__init__()", "type": "expression", "loc": [102, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "vector": [8, 2, 0.5698, 0.0056, 2, 0.16, 0.0, 555, 3, 5, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(DateFieldFilterSpec, self).__init__(f, request, params, model, model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L104_C8", "label": "self.field_generic =", "type": "assigned_variable", "loc": [104, 104], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "vector": [14, 2, 0.581, 0.0056, 2, 0.16, 0.1667, 640, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.field_generic", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.field_generic = '%s__' % self.field.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L106_C8", "label": "self.date_params = dict()", "type": "assigned_variable", "loc": [106, 106], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "vector": [14, 2, 0.5922, 0.0056, 2, 0.16, 0.3333, 806, 3, 1, 0, 0, 827, 10, 3], "semantic": {"name": "self.date_params", "arg_names": [], "import_names": [], "rhs_call_name": "dict", "annotation": ""}, "snippet": " self.date_params = dict([(k, v) for k, v in params.items() if k.startswith(self.field_generic)])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L108_C8", "label": "today = today()", "type": "assigned_variable", "loc": [108, 108], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "vector": [14, 2, 0.6034, 0.0056, 2, 0.16, 0.5, 788, 3, 0, 0, 0, 788, 10, 1], "semantic": {"name": "today", "arg_names": [], "import_names": [], "rhs_call_name": "today", "annotation": ""}, "snippet": " today = datetime.date.today()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L109_C8", "label": "one_week_ago =", "type": "assigned_variable", "loc": [109, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "vector": [14, 2, 0.6089, 0.0056, 2, 0.16, 0.6667, 406, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "one_week_ago", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " one_week_ago = today - datetime.timedelta(days=7)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L110_C8", "label": "today_str =", "type": "assigned_variable", "loc": [110, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "vector": [14, 2, 0.6145, 0.0056, 2, 0.16, 0.8333, 355, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "today_str", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " today_str = isinstance(self.field, models.DateTimeField) and today.strftime('%Y-%m-%d 23:59:59') or today.strftime('%Y-%m-%d')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L112_C8", "label": "self.links =", "type": "assigned_variable", "loc": [112, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "vector": [14, 2, 0.6536, 0.0615, 2, 0.16, 1.0, 458, 0, 0, 0, 0, 0, 8, 12], "semantic": {"name": "self.links", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.links = (\n (_('Any date'), {}),\n (_('Today'), {'%s__year' % self.field.name: str(today.year),\n '%s__month' % self.field.name: str(today.month),\n '%s__day' % self.field.name: str(today.day)}),\n (_('Past 7 days'), {'%s__gte' % self.field.name: one_week_ago.strftime('%Y-%m-%d'),\n '%s__lte' % f.name: today_str}),\n (_('This month'), {'%s__year' % self.field.name: str(today.year),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L124_C4", "label": "title", "type": "function", "loc": [124, 125], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L100_C0", "vector": [2, 1, 0.6955, 0.0112, 1, 0.26, 0.5, 48, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "title", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def title(self):\n return self.field.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L125_C8", "label": "return", "type": "return", "loc": [125, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L124_C4", "vector": [13, 2, 0.6983, 0.0056, 2, 0.06, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.field.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L127_C4", "label": "choices", "type": "function", "loc": [127, 131], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L100_C0", "vector": [2, 1, 0.7207, 0.0279, 1, 0.26, 1.0, 405, 0, 2, 0, 0, 0, 0, 1], "semantic": {"name": "choices", "arg_names": ["self", "cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def choices(self, cl):\n for title, param_dict in self.links:\n yield {'selected': self.date_params == param_dict,\n 'query_string': cl.get_query_string(param_dict, [self.field_generic]),\n 'display': title}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L128_C8", "label": "for title, param_dict", "type": "for", "loc": [128, 131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L127_C4", "vector": [6, 2, 0.7235, 0.0223, 2, 0.68, 0.0, 415, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "title, param_dict", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for title, param_dict in self.links:\n yield {'selected': self.date_params == param_dict,\n 'query_string': cl.get_query_string(param_dict, [self.field_generic]),\n 'display': title}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L129_C12", "label": "expression", "type": "expression", "loc": [129, 131], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L128_C8", "vector": [8, 3, 0.7263, 0.0168, 3, 0.59, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {'selected': self.date_params == param_dict,\n 'query_string': cl.get_query_string(param_dict, [self.field_generic]),\n 'display': title}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L133_C0", "label": "register()", "type": "expression", "loc": [133, 133], "level": 0, "parent": null, "vector": [8, 0, 0.743, 0.0056, 0, 0.66, 0.7647, 276, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "register", "annotation": ""}, "snippet": "FilterSpec.register(lambda f: isinstance(f, models.DateField), DateFieldFilterSpec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L135_C0", "label": "BooleanFieldFilterSpec", "type": "class", "loc": [135, 154], "level": 0, "parent": null, "vector": [3, 0, 0.8073, 0.1117, 0, 0.66, 0.8235, 551, 0, 3, 0, 0, 253, 0, 11], "semantic": {"name": "BooleanFieldFilterSpec", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class BooleanFieldFilterSpec(FilterSpec):\n def __init__(self, f, request, params, model, model_admin):\n super(BooleanFieldFilterSpec, self).__init__(f, request, params, model, model_admin)\n self.lookup_kwarg = '%s__exact' % f.name\n self.lookup_kwarg2 = '%s__isnull' % f.name\n self.lookup_val = request.GET.get(self.lookup_kwarg, None)\n self.lookup_val2 = request.GET.get(self.lookup_kwarg2, None)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L136_C4", "label": "__init__", "type": "function", "loc": [136, 141], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L135_C0", "vector": [2, 1, 0.7737, 0.0335, 1, 0.82, 0.0, 555, 0, 6, 0, 0, 0, 0, 4], "semantic": {"name": "__init__", "arg_names": ["self", "f", "request", "params", "model", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, f, request, params, model, model_admin):\n super(BooleanFieldFilterSpec, self).__init__(f, request, params, model, model_admin)\n self.lookup_kwarg = '%s__exact' % f.name\n self.lookup_kwarg2 = '%s__isnull' % f.name\n self.lookup_val = request.GET.get(self.lookup_kwarg, None)\n self.lookup_val2 = request.GET.get(self.lookup_kwarg2, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L137_C8", "label": "__init__()", "type": "expression", "loc": [137, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L136_C4", "vector": [8, 2, 0.7654, 0.0056, 2, 0.97, 0.0, 555, 3, 5, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(BooleanFieldFilterSpec, self).__init__(f, request, params, model, model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L138_C8", "label": "self.lookup_kwarg =", "type": "assigned_variable", "loc": [138, 138], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L136_C4", "vector": [14, 2, 0.7709, 0.0056, 2, 0.97, 0.25, 144, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.lookup_kwarg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.lookup_kwarg = '%s__exact' % f.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L139_C8", "label": "self.lookup_kwarg2 =", "type": "assigned_variable", "loc": [139, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L136_C4", "vector": [14, 2, 0.7765, 0.0056, 2, 0.97, 0.5, 429, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.lookup_kwarg2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.lookup_kwarg2 = '%s__isnull' % f.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L140_C8", "label": "self.lookup_val = get()", "type": "assigned_variable", "loc": [140, 140], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L136_C4", "vector": [14, 2, 0.7821, 0.0056, 2, 0.97, 0.75, 292, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "self.lookup_val", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " self.lookup_val = request.GET.get(self.lookup_kwarg, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L141_C8", "label": "self.lookup_val2 = get()", "type": "assigned_variable", "loc": [141, 141], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L136_C4", "vector": [14, 2, 0.7877, 0.0056, 2, 0.97, 1.0, 399, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "self.lookup_val2", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " self.lookup_val2 = request.GET.get(self.lookup_kwarg2, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L143_C4", "label": "title", "type": "function", "loc": [143, 144], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L135_C0", "vector": [2, 1, 0.8017, 0.0112, 1, 0.82, 0.5, 48, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "title", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def title(self):\n return self.field.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L144_C8", "label": "return", "type": "return", "loc": [144, 144], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L143_C4", "vector": [13, 2, 0.8045, 0.0056, 2, 0.94, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.field.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L146_C4", "label": "choices", "type": "function", "loc": [146, 154], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L135_C0", "vector": [2, 1, 0.838, 0.0503, 1, 0.82, 1.0, 405, 0, 2, 0, 0, 0, 0, 7], "semantic": {"name": "choices", "arg_names": ["self", "cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def choices(self, cl):\n for k, v in ((_('All'), None), (_('Yes'), '1'), (_('No'), '0')):\n yield {'selected': self.lookup_val == v and not self.lookup_val2,\n 'query_string': cl.get_query_string({self.lookup_kwarg: v}, [self.lookup_kwarg2]),\n 'display': k}\n if isinstance(self.field, models.NullBooleanField):\n yield {'selected': self.lookup_val2 == 'True',\n 'query_string': cl.get_query_string({self.lookup_kwarg2: 'True'}, [self.lookup_kwarg]),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L147_C8", "label": "for k, v", "type": "for", "loc": [147, 150], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L146_C4", "vector": [6, 2, 0.8296, 0.0223, 2, 0.16, 0.0, 867, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "k, v", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for k, v in ((_('All'), None), (_('Yes'), '1'), (_('No'), '0')):\n yield {'selected': self.lookup_val == v and not self.lookup_val2,\n 'query_string': cl.get_query_string({self.lookup_kwarg: v}, [self.lookup_kwarg2]),\n 'display': k}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L148_C12", "label": "expression", "type": "expression", "loc": [148, 150], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L147_C8", "vector": [8, 3, 0.8324, 0.0168, 3, 0.57, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {'selected': self.lookup_val == v and not self.lookup_val2,\n 'query_string': cl.get_query_string({self.lookup_kwarg: v}, [self.lookup_kwarg2]),\n 'display': k}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L151_C8", "label": "if", "type": "if", "loc": [151, 154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L146_C4", "vector": [4, 2, 0.852, 0.0223, 2, 0.16, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(self.field, models.NullBooleanField):\n yield {'selected': self.lookup_val2 == 'True',\n 'query_string': cl.get_query_string({self.lookup_kwarg2: 'True'}, [self.lookup_kwarg]),\n 'display': _('Unknown')}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L152_C12", "label": "expression", "type": "expression", "loc": [152, 154], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L151_C8", "vector": [8, 3, 0.8547, 0.0168, 3, 0.6, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {'selected': self.lookup_val2 == 'True',\n 'query_string': cl.get_query_string({self.lookup_kwarg2: 'True'}, [self.lookup_kwarg]),\n 'display': _('Unknown')}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L156_C0", "label": "register()", "type": "expression", "loc": [156, 156], "level": 0, "parent": null, "vector": [8, 0, 0.8715, 0.0056, 0, 0.66, 0.8824, 276, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "register", "annotation": ""}, "snippet": "FilterSpec.register(lambda f: isinstance(f, models.BooleanField) or isinstance(f, models.NullBooleanField), BooleanFieldFilterSpec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L161_C0", "label": "AllValuesFilterSpec", "type": "class", "loc": [161, 178], "level": 0, "parent": null, "vector": [3, 0, 0.9469, 0.1006, 0, 0.66, 0.9412, 488, 0, 3, 0, 0, 253, 0, 11], "semantic": {"name": "AllValuesFilterSpec", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AllValuesFilterSpec(FilterSpec):\n def __init__(self, f, request, params, model, model_admin):\n super(AllValuesFilterSpec, self).__init__(f, request, params, model, model_admin)\n self.lookup_val = request.GET.get(f.name, None)\n self.lookup_choices = model_admin.queryset(request).distinct().order_by(f.name).values(f.name)\n\n def title(self):\n return self.field.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L162_C4", "label": "__init__", "type": "function", "loc": [162, 165], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L161_C0", "vector": [2, 1, 0.9134, 0.0223, 1, 0.73, 0.0, 555, 0, 6, 0, 0, 0, 0, 7], "semantic": {"name": "__init__", "arg_names": ["self", "f", "request", "params", "model", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, f, request, params, model, model_admin):\n super(AllValuesFilterSpec, self).__init__(f, request, params, model, model_admin)\n self.lookup_val = request.GET.get(f.name, None)\n self.lookup_choices = model_admin.queryset(request).distinct().order_by(f.name).values(f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L163_C8", "label": "__init__()", "type": "expression", "loc": [163, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L162_C4", "vector": [8, 2, 0.9106, 0.0056, 2, 0.37, 0.0, 555, 3, 5, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(AllValuesFilterSpec, self).__init__(f, request, params, model, model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L164_C8", "label": "self.lookup_val = get()", "type": "assigned_variable", "loc": [164, 164], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L162_C4", "vector": [14, 2, 0.9162, 0.0056, 2, 0.37, 0.5, 292, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "self.lookup_val", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " self.lookup_val = request.GET.get(f.name, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L165_C8", "label": "self.lookup_choices = values()", "type": "assigned_variable", "loc": [165, 165], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L162_C4", "vector": [14, 2, 0.9218, 0.0056, 2, 0.37, 1.0, 468, 3, 1, 0, 0, 721, 10, 4], "semantic": {"name": "self.lookup_choices", "arg_names": [], "import_names": [], "rhs_call_name": "values", "annotation": ""}, "snippet": " self.lookup_choices = model_admin.queryset(request).distinct().order_by(f.name).values(f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L167_C4", "label": "title", "type": "function", "loc": [167, 168], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L161_C0", "vector": [2, 1, 0.9358, 0.0112, 1, 0.73, 0.5, 48, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "title", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def title(self):\n return self.field.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L168_C8", "label": "return", "type": "return", "loc": [168, 168], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L167_C4", "vector": [13, 2, 0.9385, 0.0056, 2, 0.71, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.field.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L170_C4", "label": "choices", "type": "function", "loc": [170, 178], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L161_C0", "vector": [2, 1, 0.9721, 0.0503, 1, 0.73, 1.0, 405, 0, 2, 0, 0, 0, 0, 4], "semantic": {"name": "choices", "arg_names": ["self", "cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def choices(self, cl):\n yield {'selected': self.lookup_val is None,\n 'query_string': cl.get_query_string({}, [self.field.name]),\n 'display': _('All')}\n for val in self.lookup_choices:\n val = smart_unicode(val[self.field.name])\n yield {'selected': self.lookup_val == val,\n 'query_string': cl.get_query_string({self.field.name: val}),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L171_C8", "label": "expression", "type": "expression", "loc": [171, 173], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L170_C4", "vector": [8, 2, 0.9609, 0.0168, 2, 0.72, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {'selected': self.lookup_val is None,\n 'query_string': cl.get_query_string({}, [self.field.name]),\n 'display': _('All')}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L174_C8", "label": "for val", "type": "for", "loc": [174, 178], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L170_C4", "vector": [6, 2, 0.9832, 0.0279, 2, 0.72, 1.0, 618, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "val", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for val in self.lookup_choices:\n val = smart_unicode(val[self.field.name])\n yield {'selected': self.lookup_val == val,\n 'query_string': cl.get_query_string({self.field.name: val}),\n 'display': val}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L175_C12", "label": "val = smart_unicode()", "type": "assigned_variable", "loc": [175, 175], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L174_C8", "vector": [14, 3, 0.9777, 0.0056, 3, 0.42, 0.0, 618, 3, 1, 0, 0, 349, 10, 1], "semantic": {"name": "val", "arg_names": [], "import_names": [], "rhs_call_name": "smart_unicode", "annotation": ""}, "snippet": " val = smart_unicode(val[self.field.name])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L176_C12", "label": "expression", "type": "expression", "loc": [176, 178], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L174_C8", "vector": [8, 3, 0.9888, 0.0168, 3, 0.42, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {'selected': self.lookup_val == val,\n 'query_string': cl.get_query_string({self.field.name: val}),\n 'display': val}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L179_C0", "label": "register()", "type": "expression", "loc": [179, 179], "level": 0, "parent": null, "vector": [8, 0, 1.0, 0.0056, 0, 0.66, 1.0, 276, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "register", "annotation": ""}, "snippet": "FilterSpec.register(lambda f: True, AllValuesFilterSpec)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L28_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L29_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L32_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L35_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L38_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L43_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L44_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L43_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L46_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L46_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L47_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L43_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L51_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L54_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L57_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L58_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L57_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L60_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L55_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L54_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L66_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L54_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L54_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L72_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L72_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L72_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L76_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L77_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L84_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L84_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L84_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L84_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L89_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L89_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L89_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L93_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L93_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L94_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L100_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L102_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L104_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L106_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L108_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L101_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L112_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L100_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L124_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L124_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L100_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L127_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L127_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L128_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L129_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L135_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L136_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L137_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L138_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L139_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L141_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L135_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L143_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L143_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L144_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L135_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L146_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L147_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L147_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L148_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L151_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:If_L151_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L152_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L161_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L162_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L162_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L162_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L164_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L162_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L165_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L161_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L167_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L167_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Return_L168_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:ClassDef_L161_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L170_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L170_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L171_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:FunctionDef_L170_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L174_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L174_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Assign_L175_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98642:For_L174_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98642:Expr_L176_C12"}] |
from django import template
register = template.Library()
def prepopulated_fields_js(context):
"""
Creates a list of prepopulated_fields that should render Javascript for
the prepopulated fields for both the admin form and inlines.
"""
prepopulated_fields = []
if context['add'] and 'adminform' in context:
prepopulated_fields.extend(context['adminform'].prepopulated_fields)
if 'inline_admin_formsets' in context:
for inline_admin_formset in context['inline_admin_formsets']:
for inline_admin_form in inline_admin_formset:
if inline_admin_form.original is None:
prepopulated_fields.extend(inline_admin_form.prepopulated_fields)
context.update({'prepopulated_fields': prepopulated_fields})
return context
prepopulated_fields_js = register.inclusion_tag('admin/prepopulated_fields_js.html', takes_context=True)(prepopulated_fields_js)
def submit_row(context):
"""
Displays the row of buttons for delete and save.
"""
opts = context['opts']
change = context['change']
is_popup = context['is_popup']
save_as = context['save_as']
return {
'onclick_attrib': (opts.get_ordered_objects() and change
and 'onclick="submitOrderForm();"' or ''),
'show_delete_link': (not is_popup and context['has_delete_permission']
and (change or context['show_delete'])),
'show_save_as_new': not is_popup and change and save_as,
'show_save_and_add_another': context['has_add_permission'] and
not is_popup and (not save_as or context['add']),
'show_save_and_continue': not is_popup and context['has_change_permission'],
'is_popup': is_popup,
'show_save': True
}
submit_row = register.inclusion_tag('admin/submit_line.html', takes_context=True)(submit_row)
| ajibawa-2023/Python-Code-Large/train/row_98643 | 23 | 42 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98643:ImportFrom_L1_C0", "label": "from django import template", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0238, 0.0238, 0, 0.66, 0.0, 294, 0, 1, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["template"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django import template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L3_C0", "label": "register = Library()", "type": "assigned_variable", "loc": [3, 3], "level": 0, "parent": null, "vector": [14, 0, 0.0714, 0.0238, 0, 0.66, 0.2, 276, 3, 0, 0, 0, 77, 10, 1], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "Library", "annotation": ""}, "snippet": "register = template.Library()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "label": "prepopulated_fields_js", "type": "function", "loc": [5, 19], "level": 0, "parent": null, "vector": [2, 0, 0.2857, 0.3571, 0, 0.66, 0.4, 694, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "prepopulated_fields_js", "arg_names": ["context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def prepopulated_fields_js(context):\n \"\"\"\n Creates a list of prepopulated_fields that should render Javascript for\n the prepopulated fields for both the admin form and inlines.\n \"\"\"\n prepopulated_fields = []\n if context['add'] and 'adminform' in context:\n prepopulated_fields.extend(context['adminform'].prepopulated_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Expr_L6_C4", "label": "expression", "type": "expression", "loc": [6, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "vector": [8, 1, 0.1786, 0.0952, 1, 0.23, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Creates a list of prepopulated_fields that should render Javascript for\n the prepopulated fields for both the admin form and inlines.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L10_C4", "label": "prepopulated_fields =", "type": "assigned_variable", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "vector": [14, 1, 0.2381, 0.0238, 1, 0.23, 0.2, 127, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "prepopulated_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prepopulated_fields = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:If_L11_C4", "label": "if", "type": "if", "loc": [11, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "vector": [4, 1, 0.2738, 0.0476, 1, 0.23, 0.4, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if context['add'] and 'adminform' in context:\n prepopulated_fields.extend(context['adminform'].prepopulated_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Expr_L12_C8", "label": "extend()", "type": "expression", "loc": [12, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:If_L11_C4", "vector": [8, 2, 0.2857, 0.0238, 2, 0.0, 0.0, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " prepopulated_fields.extend(context['adminform'].prepopulated_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:If_L13_C4", "label": "if", "type": "if", "loc": [13, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "vector": [4, 1, 0.3571, 0.119, 1, 0.23, 0.6, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'inline_admin_formsets' in context:\n for inline_admin_formset in context['inline_admin_formsets']:\n for inline_admin_form in inline_admin_formset:\n if inline_admin_form.original is None:\n prepopulated_fields.extend(inline_admin_form.prepopulated_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:For_L14_C8", "label": "for inline_admin_formset", "type": "for", "loc": [14, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:If_L13_C4", "vector": [6, 2, 0.369, 0.0952, 2, 0.07, 0.0, 318, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "inline_admin_formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for inline_admin_formset in context['inline_admin_formsets']:\n for inline_admin_form in inline_admin_formset:\n if inline_admin_form.original is None:\n prepopulated_fields.extend(inline_admin_form.prepopulated_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:For_L15_C12", "label": "for inline_admin_form", "type": "for", "loc": [15, 17], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:For_L14_C8", "vector": [6, 3, 0.381, 0.0714, 3, 0.1, 0.0, 663, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "inline_admin_form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for inline_admin_form in inline_admin_formset:\n if inline_admin_form.original is None:\n prepopulated_fields.extend(inline_admin_form.prepopulated_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:If_L16_C16", "label": "if", "type": "if", "loc": [16, 17], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:For_L15_C12", "vector": [4, 4, 0.3929, 0.0476, 4, 0.72, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if inline_admin_form.original is None:\n prepopulated_fields.extend(inline_admin_form.prepopulated_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Expr_L17_C20", "label": "extend()", "type": "expression", "loc": [17, 17], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:If_L16_C16", "vector": [8, 5, 0.4048, 0.0238, 5, 0.69, 0.0, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " prepopulated_fields.extend(inline_admin_form.prepopulated_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Expr_L18_C4", "label": "update()", "type": "expression", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "vector": [8, 1, 0.4286, 0.0238, 1, 0.23, 0.8, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " context.update({'prepopulated_fields': prepopulated_fields})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Return_L19_C4", "label": "return", "type": "return", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "vector": [13, 1, 0.4524, 0.0238, 1, 0.23, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return context"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L20_C0", "label": "prepopulated_fields_js =", "type": "assigned_variable", "loc": [20, 20], "level": 0, "parent": null, "vector": [14, 0, 0.4762, 0.0238, 0, 0.66, 0.6, 694, 3, 1, 0, 0, 0, 10, 2], "semantic": {"name": "prepopulated_fields_js", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "prepopulated_fields_js = register.inclusion_tag('admin/prepopulated_fields_js.html', takes_context=True)(prepopulated_fields_js)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "label": "submit_row", "type": "function", "loc": [22, 41], "level": 0, "parent": null, "vector": [2, 0, 0.75, 0.4762, 0, 0.66, 0.8, 627, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "submit_row", "arg_names": ["context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def submit_row(context):\n \"\"\"\n Displays the row of buttons for delete and save. \n \"\"\"\n opts = context['opts']\n change = context['change']\n is_popup = context['is_popup']\n save_as = context['save_as']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Expr_L23_C4", "label": "expression", "type": "expression", "loc": [23, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "vector": [8, 1, 0.5714, 0.0714, 1, 0.8, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Displays the row of buttons for delete and save. \n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L26_C4", "label": "opts =", "type": "assigned_variable", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "vector": [14, 1, 0.619, 0.0238, 1, 0.8, 0.2, 631, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = context['opts']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L27_C4", "label": "change =", "type": "assigned_variable", "loc": [27, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "vector": [14, 1, 0.6429, 0.0238, 1, 0.8, 0.4, 787, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "change", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " change = context['change']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L28_C4", "label": "is_popup =", "type": "assigned_variable", "loc": [28, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "vector": [14, 1, 0.6667, 0.0238, 1, 0.8, 0.6, 789, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "is_popup", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " is_popup = context['is_popup']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L29_C4", "label": "save_as =", "type": "assigned_variable", "loc": [29, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "vector": [14, 1, 0.6905, 0.0238, 1, 0.8, 0.8, 755, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "save_as", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " save_as = context['save_as']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Return_L30_C4", "label": "return", "type": "return", "loc": [30, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "vector": [13, 1, 0.8452, 0.2857, 1, 0.8, 1.0, 0, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {\n 'onclick_attrib': (opts.get_ordered_objects() and change\n and 'onclick=\"submitOrderForm();\"' or ''),\n 'show_delete_link': (not is_popup and context['has_delete_permission']\n and (change or context['show_delete'])),\n 'show_save_as_new': not is_popup and change and save_as,\n 'show_save_and_add_another': context['has_add_permission'] and \n not is_popup and (not save_as or context['add']),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L42_C0", "label": "submit_row =", "type": "assigned_variable", "loc": [42, 42], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0238, 0, 0.66, 1.0, 627, 3, 1, 0, 0, 0, 10, 2], "semantic": {"name": "submit_row", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "submit_row = register.inclusion_tag('admin/submit_line.html', takes_context=True)(submit_row)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:Expr_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:If_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:If_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:Expr_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:If_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:If_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:For_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:For_L14_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:For_L15_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:For_L15_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:If_L16_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:If_L16_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:Expr_L17_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:Expr_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:Return_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:Expr_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:Assign_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98643:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98643:Return_L30_C4"}] |
from django.template import Library
from django.utils.encoding import iri_to_uri
register = Library()
def admin_media_prefix():
"""
Returns the string contained in the setting ADMIN_MEDIA_PREFIX.
"""
try:
from django.conf import settings
except ImportError:
return ''
return iri_to_uri(settings.ADMIN_MEDIA_PREFIX)
admin_media_prefix = register.simple_tag(admin_media_prefix)
| ajibawa-2023/Python-Code-Large/train/row_98644 | 10 | 15 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98644:ImportFrom_L1_C0", "label": "from django.template import Library", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0667, 0.0667, 0, 0.66, 0.0, 213, 0, 1, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["Library"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import Library"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98644:ImportFrom_L2_C0", "label": "from django.utils.encoding import iri_to_uri", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1333, 0.0667, 0, 0.66, 0.25, 96, 0, 1, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["iri_to_uri"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import iri_to_uri"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98644:Assign_L4_C0", "label": "register = Library()", "type": "assigned_variable", "loc": [4, 4], "level": 0, "parent": null, "vector": [14, 0, 0.2667, 0.0667, 0, 0.66, 0.5, 276, 3, 0, 0, 0, 77, 10, 1], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "Library", "annotation": ""}, "snippet": "register = Library()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98644:FunctionDef_L6_C0", "label": "admin_media_prefix", "type": "function", "loc": [6, 14], "level": 0, "parent": null, "vector": [2, 0, 0.6667, 0.6, 0, 0.66, 0.75, 536, 0, 0, 1, 0, 0, 0, 1], "semantic": {"name": "admin_media_prefix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def admin_media_prefix():\n \"\"\"\n Returns the string contained in the setting ADMIN_MEDIA_PREFIX.\n \"\"\"\n try:\n from django.conf import settings\n except ImportError:\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98644:Expr_L7_C4", "label": "expression", "type": "expression", "loc": [7, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98644:FunctionDef_L6_C0", "vector": [8, 1, 0.5333, 0.2, 1, 0.1, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns the string contained in the setting ADMIN_MEDIA_PREFIX.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98644:Try_L10_C4", "label": "try", "type": "try", "loc": [10, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98644:FunctionDef_L6_C0", "vector": [7, 1, 0.7667, 0.2667, 1, 0.1, 0.5, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n from django.conf import settings\n except ImportError:\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98644:ImportFrom_L11_C8", "label": "from django.conf import settings", "type": "import", "loc": [11, 11], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98644:Try_L10_C4", "vector": [1, 2, 0.7333, 0.0667, 2, 0.85, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98644:Return_L13_C8", "label": "return", "type": "return", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98644:Try_L10_C4", "vector": [13, 2, 0.8667, 0.0667, 2, 0.85, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98644:Return_L14_C4", "label": "return", "type": "return", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98644:FunctionDef_L6_C0", "vector": [13, 1, 0.9333, 0.0667, 1, 0.1, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return iri_to_uri(settings.ADMIN_MEDIA_PREFIX)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98644:Assign_L15_C0", "label": "admin_media_prefix = simple_tag()", "type": "assigned_variable", "loc": [15, 15], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0667, 0, 0.66, 1.0, 536, 3, 1, 0, 0, 123, 10, 1], "semantic": {"name": "admin_media_prefix", "arg_names": [], "import_names": [], "rhs_call_name": "simple_tag", "annotation": ""}, "snippet": "admin_media_prefix = register.simple_tag(admin_media_prefix)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98644:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98644:Expr_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98644:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98644:Try_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98644:Try_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98644:ImportFrom_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98644:Try_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98644:Return_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98644:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98644:Return_L14_C4"}] |
from django import template
from django.contrib.admin.models import LogEntry
register = template.Library()
class AdminLogNode(template.Node):
def __init__(self, limit, varname, user):
self.limit, self.varname, self.user = limit, varname, user
def __repr__(self):
return "<GetAdminLog Node>"
def render(self, context):
if self.user is None:
context[self.varname] = LogEntry.objects.all().select_related('content_type', 'user')[:self.limit]
else:
user_id = self.user
if not user_id.isdigit():
user_id = context[self.user].id
context[self.varname] = LogEntry.objects.filter(user__id__exact=user_id).select_related('content_type', 'user')[:self.limit]
return ''
class DoGetAdminLog:
"""
Populates a template variable with the admin log for the given criteria.
Usage::
{% get_admin_log [limit] as [varname] for_user [context_var_containing_user_obj] %}
Examples::
{% get_admin_log 10 as admin_log for_user 23 %}
{% get_admin_log 10 as admin_log for_user user %}
{% get_admin_log 10 as admin_log %}
Note that ``context_var_containing_user_obj`` can be a hard-coded integer
(user ID) or the name of a template context variable containing the user
object whose ID you want.
"""
def __init__(self, tag_name):
self.tag_name = tag_name
def __call__(self, parser, token):
tokens = token.contents.split()
if len(tokens) < 4:
raise template.TemplateSyntaxError("'%s' statements require two arguments" % self.tag_name)
if not tokens[1].isdigit():
raise template.TemplateSyntaxError("First argument in '%s' must be an integer" % self.tag_name)
if tokens[2] != 'as':
raise template.TemplateSyntaxError("Second argument in '%s' must be 'as'" % self.tag_name)
if len(tokens) > 4:
if tokens[4] != 'for_user':
raise template.TemplateSyntaxError("Fourth argument in '%s' must be 'for_user'" % self.tag_name)
return AdminLogNode(limit=tokens[1], varname=tokens[3], user=(len(tokens) > 5 and tokens[5] or None))
register.tag('get_admin_log', DoGetAdminLog('get_admin_log'))
| ajibawa-2023/Python-Code-Large/train/row_98645 | 29 | 57 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98645:ImportFrom_L1_C0", "label": "from django import template", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0175, 0.0175, 0, 0.66, 0.0, 294, 0, 1, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["template"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django import template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:ImportFrom_L2_C0", "label": "from django.contrib.admin.models import LogEntry", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0351, 0.0175, 0, 0.66, 0.2, 408, 0, 1, 0, 0, 408, 0, 0], "semantic": {"name": "django.contrib.admin.models", "arg_names": [], "import_names": ["LogEntry"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.models import LogEntry"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L4_C0", "label": "register = Library()", "type": "assigned_variable", "loc": [4, 4], "level": 0, "parent": null, "vector": [14, 0, 0.0702, 0.0175, 0, 0.66, 0.4, 276, 3, 0, 0, 0, 77, 10, 1], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "Library", "annotation": ""}, "snippet": "register = template.Library()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L6_C0", "label": "AdminLogNode", "type": "class", "loc": [6, 21], "level": 0, "parent": null, "vector": [3, 0, 0.2368, 0.2807, 0, 0.66, 0.6, 216, 0, 3, 0, 0, 586, 0, 5], "semantic": {"name": "AdminLogNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminLogNode(template.Node):\n def __init__(self, limit, varname, user):\n self.limit, self.varname, self.user = limit, varname, user\n\n def __repr__(self):\n return \"<GetAdminLog Node>\"\n\n def render(self, context):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L7_C4", "label": "__init__", "type": "function", "loc": [7, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L6_C0", "vector": [2, 1, 0.1316, 0.0351, 1, 0.73, 0.0, 555, 0, 4, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "limit", "varname", "user"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, limit, varname, user):\n self.limit, self.varname, self.user = limit, varname, user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L8_C8", "label": "assign", "type": "assigned_variable", "loc": [8, 8], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L7_C4", "vector": [14, 2, 0.1404, 0.0175, 2, 0.34, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.limit, self.varname, self.user = limit, varname, user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L10_C4", "label": "__repr__", "type": "function", "loc": [10, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L6_C0", "vector": [2, 1, 0.1842, 0.0351, 1, 0.73, 0.5, 204, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__repr__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __repr__(self):\n return \"<GetAdminLog Node>\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Return_L11_C8", "label": "return", "type": "return", "loc": [11, 11], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L10_C4", "vector": [13, 2, 0.193, 0.0175, 2, 0.58, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"<GetAdminLog Node>\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L13_C4", "label": "render", "type": "function", "loc": [13, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L6_C0", "vector": [2, 1, 0.2982, 0.1579, 1, 0.73, 1.0, 24, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "render", "arg_names": ["self", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self, context):\n if self.user is None:\n context[self.varname] = LogEntry.objects.all().select_related('content_type', 'user')[:self.limit]\n else:\n user_id = self.user\n if not user_id.isdigit():\n user_id = context[self.user].id\n context[self.varname] = LogEntry.objects.filter(user__id__exact=user_id).select_related('content_type', 'user')[:self.limit]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L14_C8", "label": "if", "type": "if", "loc": [14, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L13_C4", "vector": [4, 2, 0.2982, 0.1228, 2, 0.14, 0.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.user is None:\n context[self.varname] = LogEntry.objects.all().select_related('content_type', 'user')[:self.limit]\n else:\n user_id = self.user\n if not user_id.isdigit():\n user_id = context[self.user].id\n context[self.varname] = LogEntry.objects.filter(user__id__exact=user_id).select_related('content_type', 'user')[:self.limit]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L15_C12", "label": "assign", "type": "assigned_variable", "loc": [15, 15], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L14_C8", "vector": [14, 3, 0.2632, 0.0175, 3, 0.3, 0.0, 0, 6, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context[self.varname] = LogEntry.objects.all().select_related('content_type', 'user')[:self.limit]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L17_C12", "label": "user_id =", "type": "assigned_variable", "loc": [17, 17], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L14_C8", "vector": [14, 3, 0.2982, 0.0175, 3, 0.3, 0.3333, 843, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "user_id", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user_id = self.user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L18_C12", "label": "if", "type": "if", "loc": [18, 19], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L14_C8", "vector": [4, 3, 0.3246, 0.0351, 3, 0.3, 0.6667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not user_id.isdigit():\n user_id = context[self.user].id"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L19_C16", "label": "user_id =", "type": "assigned_variable", "loc": [19, 19], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L18_C12", "vector": [14, 4, 0.3333, 0.0175, 4, 0.31, 0.0, 843, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "user_id", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user_id = context[self.user].id"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L20_C12", "label": "assign", "type": "assigned_variable", "loc": [20, 20], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L14_C8", "vector": [14, 3, 0.3509, 0.0175, 3, 0.3, 1.0, 0, 6, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context[self.varname] = LogEntry.objects.filter(user__id__exact=user_id).select_related('content_type', 'user')[:self.limit]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Return_L21_C8", "label": "return", "type": "return", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L13_C4", "vector": [13, 2, 0.3684, 0.0175, 2, 0.14, 1.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L23_C0", "label": "DoGetAdminLog", "type": "class", "loc": [23, 55], "level": 0, "parent": null, "vector": [3, 0, 0.6842, 0.5789, 0, 0.66, 0.8, 510, 0, 2, 0, 0, 0, 0, 10], "semantic": {"name": "DoGetAdminLog", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DoGetAdminLog:\n \"\"\"\n Populates a template variable with the admin log for the given criteria.\n\n Usage::\n\n {% get_admin_log [limit] as [varname] for_user [context_var_containing_user_obj] %}\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Expr_L24_C4", "label": "expression", "type": "expression", "loc": [24, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L23_C0", "vector": [8, 1, 0.5614, 0.2982, 1, 0.3, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Populates a template variable with the admin log for the given criteria.\n\n Usage::\n\n {% get_admin_log [limit] as [varname] for_user [context_var_containing_user_obj] %}\n\n Examples::"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L41_C4", "label": "__init__", "type": "function", "loc": [41, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L23_C0", "vector": [2, 1, 0.7281, 0.0351, 1, 0.3, 0.5, 555, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "tag_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, tag_name):\n self.tag_name = tag_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L42_C8", "label": "self.tag_name =", "type": "assigned_variable", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L41_C4", "vector": [14, 2, 0.7368, 0.0175, 2, 0.85, 0.0, 996, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.tag_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.tag_name = tag_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "label": "__call__", "type": "function", "loc": [44, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L23_C0", "vector": [2, 1, 0.8684, 0.2105, 1, 0.3, 1.0, 319, 0, 3, 1, 0, 0, 0, 10], "semantic": {"name": "__call__", "arg_names": ["self", "parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __call__(self, parser, token):\n tokens = token.contents.split()\n if len(tokens) < 4:\n raise template.TemplateSyntaxError(\"'%s' statements require two arguments\" % self.tag_name)\n if not tokens[1].isdigit():\n raise template.TemplateSyntaxError(\"First argument in '%s' must be an integer\" % self.tag_name)\n if tokens[2] != 'as':\n raise template.TemplateSyntaxError(\"Second argument in '%s' must be 'as'\" % self.tag_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L45_C8", "label": "tokens = split()", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "vector": [14, 2, 0.7895, 0.0175, 2, 0.97, 0.0, 700, 3, 0, 0, 0, 908, 10, 1], "semantic": {"name": "tokens", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " tokens = token.contents.split()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L46_C8", "label": "if", "type": "if", "loc": [46, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "vector": [4, 2, 0.8158, 0.0351, 2, 0.97, 0.2, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(tokens) < 4:\n raise template.TemplateSyntaxError(\"'%s' statements require two arguments\" % self.tag_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L48_C8", "label": "if", "type": "if", "loc": [48, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "vector": [4, 2, 0.8509, 0.0351, 2, 0.97, 0.4, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not tokens[1].isdigit():\n raise template.TemplateSyntaxError(\"First argument in '%s' must be an integer\" % self.tag_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L50_C8", "label": "if", "type": "if", "loc": [50, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "vector": [4, 2, 0.886, 0.0351, 2, 0.97, 0.6, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if tokens[2] != 'as':\n raise template.TemplateSyntaxError(\"Second argument in '%s' must be 'as'\" % self.tag_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L52_C8", "label": "if", "type": "if", "loc": [52, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "vector": [4, 2, 0.9298, 0.0526, 2, 0.97, 0.8, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(tokens) > 4:\n if tokens[4] != 'for_user':\n raise template.TemplateSyntaxError(\"Fourth argument in '%s' must be 'for_user'\" % self.tag_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L53_C12", "label": "if", "type": "if", "loc": [53, 54], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L52_C8", "vector": [4, 3, 0.9386, 0.0351, 3, 0.25, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if tokens[4] != 'for_user':\n raise template.TemplateSyntaxError(\"Fourth argument in '%s' must be 'for_user'\" % self.tag_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Return_L55_C8", "label": "return", "type": "return", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "vector": [13, 2, 0.9649, 0.0175, 2, 0.97, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return AdminLogNode(limit=tokens[1], varname=tokens[3], user=(len(tokens) > 5 and tokens[5] or None))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98645:Expr_L57_C0", "label": "tag()", "type": "expression", "loc": [57, 57], "level": 0, "parent": null, "vector": [8, 0, 1.0, 0.0175, 0, 0.66, 1.0, 732, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "register.tag('get_admin_log', DoGetAdminLog('get_admin_log'))"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:Return_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L14_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L15_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L14_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L17_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L14_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L18_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L18_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L19_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L14_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L20_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:Return_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:Expr_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:ClassDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L52_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:If_L53_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98645:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98645:Return_L55_C8"}] |
import datetime
from django.conf import settings
from django.contrib.admin.util import lookup_field, display_for_field, label_for_field
from django.contrib.admin.views.main import ALL_VAR, EMPTY_CHANGELIST_VALUE
from django.contrib.admin.views.main import ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR, SEARCH_VAR
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.utils import formats
from django.utils.html import escape, conditional_escape
from django.utils.safestring import mark_safe
from django.utils.text import capfirst
from django.utils.translation import ugettext as _
from django.utils.encoding import smart_unicode, force_unicode
from django.template import Library
register = Library()
DOT = '.'
def paginator_number(cl,i):
"""
Generates an individual page index link in a paginated list.
"""
if i == DOT:
return u'... '
elif i == cl.page_num:
return mark_safe(u'<span class="this-page">%d</span> ' % (i+1))
else:
return mark_safe(u'<a href="%s"%s>%d</a> ' % (escape(cl.get_query_string({PAGE_VAR: i})), (i == cl.paginator.num_pages-1 and ' class="end"' or ''), i+1))
paginator_number = register.simple_tag(paginator_number)
def pagination(cl):
"""
Generates the series of links to the pages in a paginated list.
"""
paginator, page_num = cl.paginator, cl.page_num
pagination_required = (not cl.show_all or not cl.can_show_all) and cl.multi_page
if not pagination_required:
page_range = []
else:
ON_EACH_SIDE = 3
ON_ENDS = 2
# If there are 10 or fewer pages, display links to every page.
# Otherwise, do some fancy
if paginator.num_pages <= 10:
page_range = range(paginator.num_pages)
else:
# Insert "smart" pagination links, so that there are always ON_ENDS
# links at either end of the list of pages, and there are always
# ON_EACH_SIDE links at either end of the "current page" link.
page_range = []
if page_num > (ON_EACH_SIDE + ON_ENDS):
page_range.extend(range(0, ON_EACH_SIDE - 1))
page_range.append(DOT)
page_range.extend(range(page_num - ON_EACH_SIDE, page_num + 1))
else:
page_range.extend(range(0, page_num + 1))
if page_num < (paginator.num_pages - ON_EACH_SIDE - ON_ENDS - 1):
page_range.extend(range(page_num + 1, page_num + ON_EACH_SIDE + 1))
page_range.append(DOT)
page_range.extend(range(paginator.num_pages - ON_ENDS, paginator.num_pages))
else:
page_range.extend(range(page_num + 1, paginator.num_pages))
need_show_all_link = cl.can_show_all and not cl.show_all and cl.multi_page
return {
'cl': cl,
'pagination_required': pagination_required,
'show_all_url': need_show_all_link and cl.get_query_string({ALL_VAR: ''}),
'page_range': page_range,
'ALL_VAR': ALL_VAR,
'1': 1,
}
pagination = register.inclusion_tag('admin/pagination.html')(pagination)
def result_headers(cl):
"""
Generates the list column headers.
"""
lookup_opts = cl.lookup_opts
for i, field_name in enumerate(cl.list_display):
header, attr = label_for_field(field_name, cl.model,
model_admin = cl.model_admin,
return_attr = True
)
if attr:
# if the field is the action checkbox: no sorting and special class
if field_name == 'action_checkbox':
yield {
"text": header,
"class_attrib": mark_safe(' class="action-checkbox-column"')
}
continue
# It is a non-field, but perhaps one that is sortable
admin_order_field = getattr(attr, "admin_order_field", None)
if not admin_order_field:
yield {"text": header}
continue
# So this _is_ a sortable non-field. Go to the yield
# after the else clause.
else:
admin_order_field = None
th_classes = []
new_order_type = 'asc'
if field_name == cl.order_field or admin_order_field == cl.order_field:
th_classes.append('sorted %sending' % cl.order_type.lower())
new_order_type = {'asc': 'desc', 'desc': 'asc'}[cl.order_type.lower()]
yield {
"text": header,
"sortable": True,
"url": cl.get_query_string({ORDER_VAR: i, ORDER_TYPE_VAR: new_order_type}),
"class_attrib": mark_safe(th_classes and ' class="%s"' % ' '.join(th_classes) or '')
}
def _boolean_icon(field_val):
BOOLEAN_MAPPING = {True: 'yes', False: 'no', None: 'unknown'}
return mark_safe(u'<img src="%simg/admin/icon-%s.gif" alt="%s" />' % (settings.ADMIN_MEDIA_PREFIX, BOOLEAN_MAPPING[field_val], field_val))
def items_for_result(cl, result, form):
"""
Generates the actual list of data.
"""
first = True
pk = cl.lookup_opts.pk.attname
for field_name in cl.list_display:
row_class = ''
try:
f, attr, value = lookup_field(field_name, result, cl.model_admin)
except (AttributeError, ObjectDoesNotExist):
result_repr = EMPTY_CHANGELIST_VALUE
else:
if f is None:
allow_tags = getattr(attr, 'allow_tags', False)
boolean = getattr(attr, 'boolean', False)
if boolean:
allow_tags = True
result_repr = _boolean_icon(value)
else:
result_repr = smart_unicode(value)
# Strip HTML tags in the resulting text, except if the
# function has an "allow_tags" attribute set to True.
if not allow_tags:
result_repr = escape(result_repr)
else:
result_repr = mark_safe(result_repr)
else:
if value is None:
result_repr = EMPTY_CHANGELIST_VALUE
if isinstance(f.rel, models.ManyToOneRel):
result_repr = escape(getattr(result, f.name))
else:
result_repr = display_for_field(value, f)
if isinstance(f, models.DateField) or isinstance(f, models.TimeField):
row_class = ' class="nowrap"'
if force_unicode(result_repr) == '':
result_repr = mark_safe(' ')
# If list_display_links not defined, add the link tag to the first field
if (first and not cl.list_display_links) or field_name in cl.list_display_links:
table_tag = {True:'th', False:'td'}[first]
first = False
url = cl.url_for_result(result)
# Convert the pk to something that can be used in Javascript.
# Problem cases are long ints (23L) and non-ASCII strings.
if cl.to_field:
attr = str(cl.to_field)
else:
attr = pk
value = result.serializable_value(attr)
result_id = repr(force_unicode(value))[1:]
yield mark_safe(u'<%s%s><a href="%s"%s>%s</a></%s>' % \
(table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %s); return false;"' % result_id or ''), conditional_escape(result_repr), table_tag))
else:
# By default the fields come from ModelAdmin.list_editable, but if we pull
# the fields out of the form instead of list_editable custom admins
# can provide fields on a per request basis
if form and field_name in form.fields:
bf = form[field_name]
result_repr = mark_safe(force_unicode(bf.errors) + force_unicode(bf))
else:
result_repr = conditional_escape(result_repr)
yield mark_safe(u'<td%s>%s</td>' % (row_class, result_repr))
if form and not form[cl.model._meta.pk.name].is_hidden:
yield mark_safe(u'<td>%s</td>' % force_unicode(form[cl.model._meta.pk.name]))
def results(cl):
if cl.formset:
for res, form in zip(cl.result_list, cl.formset.forms):
yield list(items_for_result(cl, res, form))
else:
for res in cl.result_list:
yield list(items_for_result(cl, res, None))
def result_hidden_fields(cl):
if cl.formset:
for res, form in zip(cl.result_list, cl.formset.forms):
if form[cl.model._meta.pk.name].is_hidden:
yield mark_safe(force_unicode(form[cl.model._meta.pk.name]))
def result_list(cl):
"""
Displays the headers and data list together
"""
return {'cl': cl,
'result_hidden_fields': list(result_hidden_fields(cl)),
'result_headers': list(result_headers(cl)),
'results': list(results(cl))}
result_list = register.inclusion_tag("admin/change_list_results.html")(result_list)
def date_hierarchy(cl):
"""
Displays the date hierarchy for date drill-down functionality.
"""
if cl.date_hierarchy:
field_name = cl.date_hierarchy
year_field = '%s__year' % field_name
month_field = '%s__month' % field_name
day_field = '%s__day' % field_name
field_generic = '%s__' % field_name
year_lookup = cl.params.get(year_field)
month_lookup = cl.params.get(month_field)
day_lookup = cl.params.get(day_field)
link = lambda d: cl.get_query_string(d, [field_generic])
if year_lookup and month_lookup and day_lookup:
day = datetime.date(int(year_lookup), int(month_lookup), int(day_lookup))
return {
'show': True,
'back': {
'link': link({year_field: year_lookup, month_field: month_lookup}),
'title': capfirst(formats.date_format(day, 'YEAR_MONTH_FORMAT'))
},
'choices': [{'title': capfirst(formats.date_format(day, 'MONTH_DAY_FORMAT'))}]
}
elif year_lookup and month_lookup:
days = cl.query_set.filter(**{year_field: year_lookup, month_field: month_lookup}).dates(field_name, 'day')
return {
'show': True,
'back': {
'link': link({year_field: year_lookup}),
'title': year_lookup
},
'choices': [{
'link': link({year_field: year_lookup, month_field: month_lookup, day_field: day.day}),
'title': capfirst(formats.date_format(day, 'MONTH_DAY_FORMAT'))
} for day in days]
}
elif year_lookup:
months = cl.query_set.filter(**{year_field: year_lookup}).dates(field_name, 'month')
return {
'show' : True,
'back': {
'link' : link({}),
'title': _('All dates')
},
'choices': [{
'link': link({year_field: year_lookup, month_field: month.month}),
'title': capfirst(formats.date_format(month, 'YEAR_MONTH_FORMAT'))
} for month in months]
}
else:
years = cl.query_set.dates(field_name, 'year')
return {
'show': True,
'choices': [{
'link': link({year_field: str(year.year)}),
'title': str(year.year),
} for year in years]
}
date_hierarchy = register.inclusion_tag('admin/date_hierarchy.html')(date_hierarchy)
def search_form(cl):
"""
Displays a search form for searching the list.
"""
return {
'cl': cl,
'show_result_count': cl.result_count != cl.full_result_count,
'search_var': SEARCH_VAR
}
search_form = register.inclusion_tag('admin/search_form.html')(search_form)
def admin_list_filter(cl, spec):
return {'title': spec.title(), 'choices' : list(spec.choices(cl))}
admin_list_filter = register.inclusion_tag('admin/filter.html')(admin_list_filter)
def admin_actions(context):
"""
Track the number of times the action field has been rendered on the page,
so we know which value to use.
"""
context['action_index'] = context.get('action_index', -1) + 1
return context
admin_actions = register.inclusion_tag("admin/actions.html", takes_context=True)(admin_actions)
| ajibawa-2023/Python-Code-Large/train/row_98646 | 165 | 303 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Import_L1_C0", "label": "datetime import datetime", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0033, 0.0033, 0, 0.66, 0.0, 426, 0, 1, 0, 0, 426, 0, 0], "semantic": {"name": "datetime", "arg_names": [], "import_names": ["datetime"], "rhs_call_name": "", "annotation": ""}, "snippet": "import datetime"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L3_C0", "label": "from django.conf import settings", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0099, 0.0033, 0, 0.66, 0.0294, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L4_C0", "label": "from django.contrib.admin.util import lookup_field, display_for_field, label_for_field", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0132, 0.0033, 0, 0.66, 0.0588, 69, 0, 3, 0, 0, 69, 0, 0], "semantic": {"name": "django.contrib.admin.util", "arg_names": [], "import_names": ["lookup_field", "display_for_field", "label_for_field"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.util import lookup_field, display_for_field, label_for_field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L5_C0", "label": "from django.contrib.admin.views.main import ALL_VAR, EMPTY_CHANGELIST_VALUE", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0165, 0.0033, 0, 0.66, 0.0882, 696, 0, 2, 0, 0, 696, 0, 0], "semantic": {"name": "django.contrib.admin.views.main", "arg_names": [], "import_names": ["ALL_VAR", "EMPTY_CHANGELIST_VALUE"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.views.main import ALL_VAR, EMPTY_CHANGELIST_VALUE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L6_C0", "label": "from django.contrib.admin.views.main import ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR\u2026", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0198, 0.0033, 0, 0.66, 0.1176, 696, 0, 4, 0, 0, 696, 0, 0], "semantic": {"name": "django.contrib.admin.views.main", "arg_names": [], "import_names": ["ORDER_VAR", "ORDER_TYPE_VAR", "PAGE_VAR", "SEARCH_VAR"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.views.main import ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR, SEARCH_VAR"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L7_C0", "label": "from django.core.exceptions import ObjectDoesNotExist", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0231, 0.0033, 0, 0.66, 0.1471, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["ObjectDoesNotExist"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import ObjectDoesNotExist"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L8_C0", "label": "from django.db import models", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0264, 0.0033, 0, 0.66, 0.1765, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L9_C0", "label": "from django.utils import formats", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0297, 0.0033, 0, 0.66, 0.2059, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["formats"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import formats"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L10_C0", "label": "from django.utils.html import escape, conditional_escape", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.033, 0.0033, 0, 0.66, 0.2353, 535, 0, 2, 0, 0, 535, 0, 0], "semantic": {"name": "django.utils.html", "arg_names": [], "import_names": ["escape", "conditional_escape"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.html import escape, conditional_escape"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L11_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0363, 0.0033, 0, 0.66, 0.2647, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.safestring", "arg_names": [], "import_names": ["mark_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.safestring import mark_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L12_C0", "label": "from django.utils.text import capfirst", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0396, 0.0033, 0, 0.66, 0.2941, 590, 0, 1, 0, 0, 590, 0, 0], "semantic": {"name": "django.utils.text", "arg_names": [], "import_names": ["capfirst"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.text import capfirst"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L13_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0429, 0.0033, 0, 0.66, 0.3235, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L14_C0", "label": "from django.utils.encoding import smart_unicode, force_unicode", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.0462, 0.0033, 0, 0.66, 0.3529, 96, 0, 2, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_unicode", "force_unicode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_unicode, force_unicode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:ImportFrom_L15_C0", "label": "from django.template import Library", "type": "import", "loc": [15, 15], "level": 0, "parent": null, "vector": [1, 0, 0.0495, 0.0033, 0, 0.66, 0.3824, 213, 0, 1, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["Library"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import Library"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L18_C0", "label": "register = Library()", "type": "assigned_variable", "loc": [18, 18], "level": 0, "parent": null, "vector": [14, 0, 0.0594, 0.0033, 0, 0.66, 0.4118, 276, 3, 0, 0, 0, 77, 10, 1], "semantic": {"name": "register", "arg_names": [], "import_names": [], "rhs_call_name": "Library", "annotation": ""}, "snippet": "register = Library()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L20_C0", "label": "DOT =", "type": "assigned_variable", "loc": [20, 20], "level": 0, "parent": null, "vector": [14, 0, 0.066, 0.0033, 0, 0.66, 0.4412, 613, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DOT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DOT = '.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L22_C0", "label": "paginator_number", "type": "function", "loc": [22, 31], "level": 0, "parent": null, "vector": [2, 0, 0.0875, 0.033, 0, 0.66, 0.4706, 220, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "paginator_number", "arg_names": ["cl", "i"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def paginator_number(cl,i):\n \"\"\"\n Generates an individual page index link in a paginated list.\n \"\"\"\n if i == DOT:\n return u'... '\n elif i == cl.page_num:\n return mark_safe(u'<span class=\"this-page\">%d</span> ' % (i+1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L23_C4", "label": "expression", "type": "expression", "loc": [23, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L22_C0", "vector": [8, 1, 0.0792, 0.0099, 1, 0.35, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Generates an individual page index link in a paginated list.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L26_C4", "label": "if", "type": "if", "loc": [26, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L22_C0", "vector": [4, 1, 0.0941, 0.0198, 1, 0.35, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if i == DOT:\n return u'... '\n elif i == cl.page_num:\n return mark_safe(u'<span class=\"this-page\">%d</span> ' % (i+1))\n else:\n return mark_safe(u'<a href=\"%s\"%s>%d</a> ' % (escape(cl.get_query_string({PAGE_VAR: i})), (i == cl.paginator.num_pages-1 and ' class=\"end\"' or ''), i+1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L27_C8", "label": "return", "type": "return", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L26_C4", "vector": [13, 2, 0.0891, 0.0033, 2, 0.26, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'... '"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L28_C4", "label": "if", "type": "if", "loc": [28, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L26_C4", "vector": [4, 2, 0.0974, 0.0132, 2, 0.26, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif i == cl.page_num:\n return mark_safe(u'<span class=\"this-page\">%d</span> ' % (i+1))\n else:\n return mark_safe(u'<a href=\"%s\"%s>%d</a> ' % (escape(cl.get_query_string({PAGE_VAR: i})), (i == cl.paginator.num_pages-1 and ' class=\"end\"' or ''), i+1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L29_C8", "label": "return", "type": "return", "loc": [29, 29], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L28_C4", "vector": [13, 3, 0.0957, 0.0033, 3, 0.3, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u'<span class=\"this-page\">%d</span> ' % (i+1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L31_C8", "label": "return", "type": "return", "loc": [31, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L28_C4", "vector": [13, 3, 0.1023, 0.0033, 3, 0.3, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u'<a href=\"%s\"%s>%d</a> ' % (escape(cl.get_query_string({PAGE_VAR: i})), (i == cl.paginator.num_pages-1 and ' class=\"end\"' or ''), i+1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L32_C0", "label": "paginator_number = simple_tag()", "type": "assigned_variable", "loc": [32, 32], "level": 0, "parent": null, "vector": [14, 0, 0.1056, 0.0033, 0, 0.66, 0.5, 220, 3, 1, 0, 0, 123, 10, 1], "semantic": {"name": "paginator_number", "arg_names": [], "import_names": [], "rhs_call_name": "simple_tag", "annotation": ""}, "snippet": "paginator_number = register.simple_tag(paginator_number)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "label": "pagination", "type": "function", "loc": [34, 77], "level": 0, "parent": null, "vector": [2, 0, 0.1832, 0.1452, 0, 0.66, 0.5294, 516, 0, 1, 1, 0, 0, 0, 16], "semantic": {"name": "pagination", "arg_names": ["cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def pagination(cl):\n \"\"\"\n Generates the series of links to the pages in a paginated list.\n \"\"\"\n paginator, page_num = cl.paginator, cl.page_num\n\n pagination_required = (not cl.show_all or not cl.can_show_all) and cl.multi_page\n if not pagination_required:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L35_C4", "label": "expression", "type": "expression", "loc": [35, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "vector": [8, 1, 0.1188, 0.0099, 1, 0.72, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Generates the series of links to the pages in a paginated list.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L38_C4", "label": "paginator, page_num =", "type": "assigned_variable", "loc": [38, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "vector": [14, 1, 0.1254, 0.0033, 1, 0.72, 0.2, 546, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "paginator, page_num", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " paginator, page_num = cl.paginator, cl.page_num"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L40_C4", "label": "pagination_required =", "type": "assigned_variable", "loc": [40, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "vector": [14, 1, 0.132, 0.0033, 1, 0.72, 0.4, 473, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "pagination_required", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pagination_required = (not cl.show_all or not cl.can_show_all) and cl.multi_page"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L41_C4", "label": "if", "type": "if", "loc": [41, 67], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "vector": [4, 1, 0.1782, 0.0891, 1, 0.72, 0.6, 0, 0, 0, 0, 0, 0, 0, 15], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not pagination_required:\n page_range = []\n else:\n ON_EACH_SIDE = 3\n ON_ENDS = 2\n\n # If there are 10 or fewer pages, display links to every page.\n # Otherwise, do some fancy"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L42_C8", "label": "page_range =", "type": "assigned_variable", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L41_C4", "vector": [14, 2, 0.1386, 0.0033, 2, 0.28, 0.0, 809, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "page_range", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " page_range = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L44_C8", "label": "ON_EACH_SIDE =", "type": "assigned_variable", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L41_C4", "vector": [14, 2, 0.1452, 0.0033, 2, 0.28, 0.3333, 829, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "ON_EACH_SIDE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ON_EACH_SIDE = 3"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L45_C8", "label": "ON_ENDS =", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L41_C4", "vector": [14, 2, 0.1485, 0.0033, 2, 0.28, 0.6667, 219, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "ON_ENDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ON_ENDS = 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L49_C8", "label": "if", "type": "if", "loc": [49, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L41_C4", "vector": [4, 2, 0.1914, 0.0627, 2, 0.28, 1.0, 0, 0, 0, 0, 0, 0, 0, 15], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if paginator.num_pages <= 10:\n page_range = range(paginator.num_pages)\n else:\n # Insert \"smart\" pagination links, so that there are always ON_ENDS\n # links at either end of the list of pages, and there are always\n # ON_EACH_SIDE links at either end of the \"current page\" link.\n page_range = []\n if page_num > (ON_EACH_SIDE + ON_ENDS):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L50_C12", "label": "page_range = range()", "type": "assigned_variable", "loc": [50, 50], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L49_C8", "vector": [14, 3, 0.165, 0.0033, 3, 0.62, 0.0, 809, 3, 1, 0, 0, 816, 10, 1], "semantic": {"name": "page_range", "arg_names": [], "import_names": [], "rhs_call_name": "range", "annotation": ""}, "snippet": " page_range = range(paginator.num_pages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L55_C12", "label": "page_range =", "type": "assigned_variable", "loc": [55, 55], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L49_C8", "vector": [14, 3, 0.1815, 0.0033, 3, 0.62, 0.3333, 809, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "page_range", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " page_range = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L56_C12", "label": "if", "type": "if", "loc": [56, 61], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L49_C8", "vector": [4, 3, 0.1931, 0.0198, 3, 0.62, 0.6667, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if page_num > (ON_EACH_SIDE + ON_ENDS):\n page_range.extend(range(0, ON_EACH_SIDE - 1))\n page_range.append(DOT)\n page_range.extend(range(page_num - ON_EACH_SIDE, page_num + 1))\n else:\n page_range.extend(range(0, page_num + 1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L57_C16", "label": "extend()", "type": "expression", "loc": [57, 57], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L56_C12", "vector": [8, 4, 0.1881, 0.0033, 4, 0.31, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " page_range.extend(range(0, ON_EACH_SIDE - 1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L58_C16", "label": "append()", "type": "expression", "loc": [58, 58], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L56_C12", "vector": [8, 4, 0.1914, 0.0033, 4, 0.31, 0.3333, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " page_range.append(DOT)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L59_C16", "label": "extend()", "type": "expression", "loc": [59, 59], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L56_C12", "vector": [8, 4, 0.1947, 0.0033, 4, 0.31, 0.6667, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " page_range.extend(range(page_num - ON_EACH_SIDE, page_num + 1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L61_C16", "label": "extend()", "type": "expression", "loc": [61, 61], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L56_C12", "vector": [8, 4, 0.2013, 0.0033, 4, 0.31, 1.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " page_range.extend(range(0, page_num + 1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L62_C12", "label": "if", "type": "if", "loc": [62, 67], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L49_C8", "vector": [4, 3, 0.2129, 0.0198, 3, 0.62, 1.0, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if page_num < (paginator.num_pages - ON_EACH_SIDE - ON_ENDS - 1):\n page_range.extend(range(page_num + 1, page_num + ON_EACH_SIDE + 1))\n page_range.append(DOT)\n page_range.extend(range(paginator.num_pages - ON_ENDS, paginator.num_pages))\n else:\n page_range.extend(range(page_num + 1, paginator.num_pages))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L63_C16", "label": "extend()", "type": "expression", "loc": [63, 63], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L62_C12", "vector": [8, 4, 0.2079, 0.0033, 4, 0.84, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " page_range.extend(range(page_num + 1, page_num + ON_EACH_SIDE + 1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L64_C16", "label": "append()", "type": "expression", "loc": [64, 64], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L62_C12", "vector": [8, 4, 0.2112, 0.0033, 4, 0.84, 0.3333, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " page_range.append(DOT)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L65_C16", "label": "extend()", "type": "expression", "loc": [65, 65], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L62_C12", "vector": [8, 4, 0.2145, 0.0033, 4, 0.84, 0.6667, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " page_range.extend(range(paginator.num_pages - ON_ENDS, paginator.num_pages))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L67_C16", "label": "extend()", "type": "expression", "loc": [67, 67], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L62_C12", "vector": [8, 4, 0.2211, 0.0033, 4, 0.84, 1.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " page_range.extend(range(page_num + 1, paginator.num_pages))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L69_C4", "label": "need_show_all_link =", "type": "assigned_variable", "loc": [69, 69], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "vector": [14, 1, 0.2277, 0.0033, 1, 0.72, 0.8, 335, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "need_show_all_link", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " need_show_all_link = cl.can_show_all and not cl.show_all and cl.multi_page"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L70_C4", "label": "return", "type": "return", "loc": [70, 77], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "vector": [13, 1, 0.2426, 0.0264, 1, 0.72, 1.0, 0, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {\n 'cl': cl,\n 'pagination_required': pagination_required,\n 'show_all_url': need_show_all_link and cl.get_query_string({ALL_VAR: ''}),\n 'page_range': page_range,\n 'ALL_VAR': ALL_VAR,\n '1': 1,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L78_C0", "label": "pagination =", "type": "assigned_variable", "loc": [78, 78], "level": 0, "parent": null, "vector": [14, 0, 0.2574, 0.0033, 0, 0.66, 0.5588, 516, 3, 1, 0, 0, 0, 10, 2], "semantic": {"name": "pagination", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "pagination = register.inclusion_tag('admin/pagination.html')(pagination)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L80_C0", "label": "result_headers", "type": "function", "loc": [80, 122], "level": 0, "parent": null, "vector": [2, 0, 0.3333, 0.1419, 0, 0.66, 0.5882, 245, 0, 1, 0, 0, 0, 0, 10], "semantic": {"name": "result_headers", "arg_names": ["cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def result_headers(cl):\n \"\"\"\n Generates the list column headers.\n \"\"\"\n lookup_opts = cl.lookup_opts\n\n for i, field_name in enumerate(cl.list_display):\n header, attr = label_for_field(field_name, cl.model,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L81_C4", "label": "expression", "type": "expression", "loc": [81, 83], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L80_C0", "vector": [8, 1, 0.2706, 0.0099, 1, 0.54, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Generates the list column headers.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L84_C4", "label": "lookup_opts =", "type": "assigned_variable", "loc": [84, 84], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L80_C0", "vector": [14, 1, 0.2772, 0.0033, 1, 0.54, 0.5, 346, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "lookup_opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lookup_opts = cl.lookup_opts"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "label": "for i, field_name", "type": "for", "loc": [86, 122], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L80_C0", "vector": [6, 1, 0.3432, 0.1221, 1, 0.54, 1.0, 100, 3, 0, 0, 0, 0, 0, 10], "semantic": {"name": "i, field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, field_name in enumerate(cl.list_display):\n header, attr = label_for_field(field_name, cl.model,\n model_admin = cl.model_admin,\n return_attr = True\n )\n if attr:\n # if the field is the action checkbox: no sorting and special class\n if field_name == 'action_checkbox':"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L87_C8", "label": "header, attr = label_for_field()", "type": "assigned_variable", "loc": [87, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "vector": [14, 2, 0.2921, 0.0132, 2, 0.9, 0.0, 238, 3, 4, 0, 0, 777, 10, 1], "semantic": {"name": "header, attr", "arg_names": [], "import_names": [], "rhs_call_name": "label_for_field", "annotation": ""}, "snippet": " header, attr = label_for_field(field_name, cl.model,\n model_admin = cl.model_admin,\n return_attr = True\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L91_C8", "label": "if", "type": "if", "loc": [91, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "vector": [4, 2, 0.33, 0.0627, 2, 0.9, 0.2, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if attr:\n # if the field is the action checkbox: no sorting and special class\n if field_name == 'action_checkbox':\n yield {\n \"text\": header,\n \"class_attrib\": mark_safe(' class=\"action-checkbox-column\"')\n }\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L93_C12", "label": "if", "type": "if", "loc": [93, 98], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L91_C8", "vector": [4, 3, 0.3152, 0.0198, 3, 0.37, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_name == 'action_checkbox':\n yield {\n \"text\": header,\n \"class_attrib\": mark_safe(' class=\"action-checkbox-column\"')\n }\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L94_C16", "label": "expression", "type": "expression", "loc": [94, 97], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L93_C12", "vector": [8, 4, 0.3152, 0.0132, 4, 0.77, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {\n \"text\": header,\n \"class_attrib\": mark_safe(' class=\"action-checkbox-column\"')\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L101_C12", "label": "admin_order_field = getattr()", "type": "assigned_variable", "loc": [101, 101], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L91_C8", "vector": [14, 3, 0.3333, 0.0033, 3, 0.37, 0.3333, 363, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "admin_order_field", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " admin_order_field = getattr(attr, \"admin_order_field\", None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L102_C12", "label": "if", "type": "if", "loc": [102, 104], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L91_C8", "vector": [4, 3, 0.3399, 0.0099, 3, 0.37, 0.6667, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not admin_order_field:\n yield {\"text\": header}\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L103_C16", "label": "expression", "type": "expression", "loc": [103, 103], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L102_C12", "vector": [8, 4, 0.3399, 0.0033, 4, 0.86, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {\"text\": header}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L109_C12", "label": "admin_order_field =", "type": "assigned_variable", "loc": [109, 109], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L91_C8", "vector": [14, 3, 0.3597, 0.0033, 3, 0.37, 1.0, 363, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "admin_order_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " admin_order_field = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L111_C8", "label": "th_classes =", "type": "assigned_variable", "loc": [111, 111], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "vector": [14, 2, 0.3663, 0.0033, 2, 0.9, 0.4, 518, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "th_classes", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " th_classes = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L112_C8", "label": "new_order_type =", "type": "assigned_variable", "loc": [112, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "vector": [14, 2, 0.3696, 0.0033, 2, 0.9, 0.6, 305, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "new_order_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " new_order_type = 'asc'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L113_C8", "label": "if", "type": "if", "loc": [113, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "vector": [4, 2, 0.3762, 0.0099, 2, 0.9, 0.8, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_name == cl.order_field or admin_order_field == cl.order_field:\n th_classes.append('sorted %sending' % cl.order_type.lower())\n new_order_type = {'asc': 'desc', 'desc': 'asc'}[cl.order_type.lower()]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L114_C12", "label": "append()", "type": "expression", "loc": [114, 114], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L113_C8", "vector": [8, 3, 0.3762, 0.0033, 3, 0.53, 0.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " th_classes.append('sorted %sending' % cl.order_type.lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L115_C12", "label": "new_order_type =", "type": "assigned_variable", "loc": [115, 115], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L113_C8", "vector": [14, 3, 0.3795, 0.0033, 3, 0.53, 1.0, 305, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "new_order_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " new_order_type = {'asc': 'desc', 'desc': 'asc'}[cl.order_type.lower()]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L117_C8", "label": "expression", "type": "expression", "loc": [117, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "vector": [8, 2, 0.3944, 0.0198, 2, 0.9, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {\n \"text\": header,\n \"sortable\": True,\n \"url\": cl.get_query_string({ORDER_VAR: i, ORDER_TYPE_VAR: new_order_type}),\n \"class_attrib\": mark_safe(th_classes and ' class=\"%s\"' % ' '.join(th_classes) or '')\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L124_C0", "label": "_boolean_icon", "type": "function", "loc": [124, 126], "level": 0, "parent": null, "vector": [2, 0, 0.4125, 0.0099, 0, 0.66, 0.6176, 113, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "_boolean_icon", "arg_names": ["field_val"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _boolean_icon(field_val):\n BOOLEAN_MAPPING = {True: 'yes', False: 'no', None: 'unknown'}\n return mark_safe(u'<img src=\"%simg/admin/icon-%s.gif\" alt=\"%s\" />' % (settings.ADMIN_MEDIA_PREFIX, BOOLEAN_MAPPING[field_val], field_val))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L125_C4", "label": "BOOLEAN_MAPPING =", "type": "assigned_variable", "loc": [125, 125], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L124_C0", "vector": [14, 1, 0.4125, 0.0033, 1, 0.85, 0.0, 392, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "BOOLEAN_MAPPING", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " BOOLEAN_MAPPING = {True: 'yes', False: 'no', None: 'unknown'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L126_C4", "label": "return", "type": "return", "loc": [126, 126], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L124_C0", "vector": [13, 1, 0.4158, 0.0033, 1, 0.85, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u'<img src=\"%simg/admin/icon-%s.gif\" alt=\"%s\" />' % (settings.ADMIN_MEDIA_PREFIX, BOOLEAN_MAPPING[field_val], field_val))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L128_C0", "label": "items_for_result", "type": "function", "loc": [128, 192], "level": 0, "parent": null, "vector": [2, 0, 0.5281, 0.2145, 0, 0.66, 0.6471, 990, 0, 3, 0, 0, 0, 0, 29], "semantic": {"name": "items_for_result", "arg_names": ["cl", "result", "form"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def items_for_result(cl, result, form):\n \"\"\"\n Generates the actual list of data.\n \"\"\"\n first = True\n pk = cl.lookup_opts.pk.attname\n for field_name in cl.list_display:\n row_class = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L129_C4", "label": "expression", "type": "expression", "loc": [129, 131], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L128_C0", "vector": [8, 1, 0.429, 0.0099, 1, 0.29, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Generates the actual list of data.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L132_C4", "label": "first =", "type": "assigned_variable", "loc": [132, 132], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L128_C0", "vector": [14, 1, 0.4356, 0.0033, 1, 0.29, 0.25, 199, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "first", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " first = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L133_C4", "label": "pk =", "type": "assigned_variable", "loc": [133, 133], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L128_C0", "vector": [14, 1, 0.4389, 0.0033, 1, 0.29, 0.5, 164, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "pk", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pk = cl.lookup_opts.pk.attname"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L134_C4", "label": "for field_name", "type": "for", "loc": [134, 190], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L128_C0", "vector": [6, 1, 0.5347, 0.1881, 1, 0.29, 0.75, 918, 7, 0, 0, 0, 0, 0, 27], "semantic": {"name": "field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field_name in cl.list_display:\n row_class = ''\n try:\n f, attr, value = lookup_field(field_name, result, cl.model_admin)\n except (AttributeError, ObjectDoesNotExist):\n result_repr = EMPTY_CHANGELIST_VALUE\n else:\n if f is None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L135_C8", "label": "row_class =", "type": "assigned_variable", "loc": [135, 135], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L134_C4", "vector": [14, 2, 0.4455, 0.0033, 2, 0.6, 0.0, 739, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "row_class", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " row_class = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Try_L136_C8", "label": "try", "type": "try", "loc": [136, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L134_C4", "vector": [7, 2, 0.4934, 0.0924, 2, 0.6, 0.3333, 0, 0, 1, 0, 0, 0, 0, 13], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n f, attr, value = lookup_field(field_name, result, cl.model_admin)\n except (AttributeError, ObjectDoesNotExist):\n result_repr = EMPTY_CHANGELIST_VALUE\n else:\n if f is None:\n allow_tags = getattr(attr, 'allow_tags', False)\n boolean = getattr(attr, 'boolean', False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L137_C12", "label": "f, attr, value = lookup_field()", "type": "assigned_variable", "loc": [137, 137], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:Try_L136_C8", "vector": [14, 3, 0.4521, 0.0033, 3, 0.04, 0.0, 68, 3, 3, 0, 0, 514, 10, 1], "semantic": {"name": "f, attr, value", "arg_names": [], "import_names": [], "rhs_call_name": "lookup_field", "annotation": ""}, "snippet": " f, attr, value = lookup_field(field_name, result, cl.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L139_C12", "label": "result_repr =", "type": "assigned_variable", "loc": [139, 139], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:Try_L136_C8", "vector": [14, 3, 0.4587, 0.0033, 3, 0.04, 0.0, 760, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result_repr = EMPTY_CHANGELIST_VALUE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "label": "if", "type": "if", "loc": [141, 163], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:Try_L136_C8", "vector": [4, 3, 0.5017, 0.0759, 3, 0.04, 1.0, 0, 0, 0, 0, 0, 0, 0, 12], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f is None:\n allow_tags = getattr(attr, 'allow_tags', False)\n boolean = getattr(attr, 'boolean', False)\n if boolean:\n allow_tags = True\n result_repr = _boolean_icon(value)\n else:\n result_repr = smart_unicode(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L142_C16", "label": "allow_tags = getattr()", "type": "assigned_variable", "loc": [142, 142], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "vector": [14, 4, 0.4686, 0.0033, 4, 0.68, 0.0, 806, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "allow_tags", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " allow_tags = getattr(attr, 'allow_tags', False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L143_C16", "label": "boolean = getattr()", "type": "assigned_variable", "loc": [143, 143], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "vector": [14, 4, 0.4719, 0.0033, 4, 0.68, 0.1667, 756, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "boolean", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " boolean = getattr(attr, 'boolean', False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L144_C16", "label": "if", "type": "if", "loc": [144, 148], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "vector": [4, 4, 0.4818, 0.0165, 4, 0.68, 0.3333, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if boolean:\n allow_tags = True\n result_repr = _boolean_icon(value)\n else:\n result_repr = smart_unicode(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L145_C20", "label": "allow_tags =", "type": "assigned_variable", "loc": [145, 145], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L144_C16", "vector": [14, 5, 0.4785, 0.0033, 5, 0.64, 0.0, 806, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "allow_tags", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " allow_tags = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L146_C20", "label": "result_repr = _boolean_icon()", "type": "assigned_variable", "loc": [146, 146], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L144_C16", "vector": [14, 5, 0.4818, 0.0033, 5, 0.64, 0.5, 760, 3, 1, 0, 0, 113, 10, 1], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "_boolean_icon", "annotation": ""}, "snippet": " result_repr = _boolean_icon(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L148_C20", "label": "result_repr = smart_unicode()", "type": "assigned_variable", "loc": [148, 148], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L144_C16", "vector": [14, 5, 0.4884, 0.0033, 5, 0.64, 1.0, 760, 3, 1, 0, 0, 349, 10, 1], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "smart_unicode", "annotation": ""}, "snippet": " result_repr = smart_unicode(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L151_C16", "label": "if", "type": "if", "loc": [151, 154], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "vector": [4, 4, 0.5033, 0.0132, 4, 0.68, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not allow_tags:\n result_repr = escape(result_repr)\n else:\n result_repr = mark_safe(result_repr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L152_C20", "label": "result_repr = escape()", "type": "assigned_variable", "loc": [152, 152], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L151_C16", "vector": [14, 5, 0.5017, 0.0033, 5, 0.48, 0.0, 760, 3, 1, 0, 0, 494, 10, 1], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "escape", "annotation": ""}, "snippet": " result_repr = escape(result_repr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L154_C20", "label": "result_repr = mark_safe()", "type": "assigned_variable", "loc": [154, 154], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L151_C16", "vector": [14, 5, 0.5083, 0.0033, 5, 0.48, 1.0, 760, 3, 1, 0, 0, 159, 10, 1], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "mark_safe", "annotation": ""}, "snippet": " result_repr = mark_safe(result_repr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L156_C16", "label": "if", "type": "if", "loc": [156, 157], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "vector": [4, 4, 0.5165, 0.0066, 4, 0.68, 0.6667, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value is None:\n result_repr = EMPTY_CHANGELIST_VALUE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L157_C20", "label": "result_repr =", "type": "assigned_variable", "loc": [157, 157], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L156_C16", "vector": [14, 5, 0.5182, 0.0033, 5, 0.83, 0.0, 760, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result_repr = EMPTY_CHANGELIST_VALUE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L158_C16", "label": "if", "type": "if", "loc": [158, 161], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "vector": [4, 4, 0.5264, 0.0132, 4, 0.68, 0.8333, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f.rel, models.ManyToOneRel):\n result_repr = escape(getattr(result, f.name))\n else:\n result_repr = display_for_field(value, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L159_C20", "label": "result_repr = escape()", "type": "assigned_variable", "loc": [159, 159], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L158_C16", "vector": [14, 5, 0.5248, 0.0033, 5, 0.44, 0.0, 760, 3, 1, 0, 0, 494, 10, 2], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "escape", "annotation": ""}, "snippet": " result_repr = escape(getattr(result, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L161_C20", "label": "result_repr = display_for_field()", "type": "assigned_variable", "loc": [161, 161], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L158_C16", "vector": [14, 5, 0.5314, 0.0033, 5, 0.44, 1.0, 760, 3, 2, 0, 0, 12, 10, 1], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "display_for_field", "annotation": ""}, "snippet": " result_repr = display_for_field(value, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L162_C16", "label": "if", "type": "if", "loc": [162, 163], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "vector": [4, 4, 0.5363, 0.0066, 4, 0.68, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f, models.DateField) or isinstance(f, models.TimeField):\n row_class = ' class=\"nowrap\"'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L163_C20", "label": "row_class =", "type": "assigned_variable", "loc": [163, 163], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L162_C16", "vector": [14, 5, 0.538, 0.0033, 5, 0.79, 0.0, 739, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "row_class", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " row_class = ' class=\"nowrap\"'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L164_C8", "label": "if", "type": "if", "loc": [164, 165], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L134_C4", "vector": [4, 2, 0.5429, 0.0066, 2, 0.6, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if force_unicode(result_repr) == '':\n result_repr = mark_safe(' ')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L165_C12", "label": "result_repr = mark_safe()", "type": "assigned_variable", "loc": [165, 165], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L164_C8", "vector": [14, 3, 0.5446, 0.0033, 3, 0.48, 0.0, 760, 3, 1, 0, 0, 159, 10, 1], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "mark_safe", "annotation": ""}, "snippet": " result_repr = mark_safe(' ')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "label": "if", "type": "if", "loc": [167, 190], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L134_C4", "vector": [4, 2, 0.5891, 0.0792, 2, 0.6, 1.0, 0, 0, 0, 0, 0, 0, 0, 12], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if (first and not cl.list_display_links) or field_name in cl.list_display_links:\n table_tag = {True:'th', False:'td'}[first]\n first = False\n url = cl.url_for_result(result)\n # Convert the pk to something that can be used in Javascript.\n # Problem cases are long ints (23L) and non-ASCII strings.\n if cl.to_field:\n attr = str(cl.to_field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L168_C12", "label": "table_tag =", "type": "assigned_variable", "loc": [168, 168], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "vector": [14, 3, 0.5545, 0.0033, 3, 0.69, 0.0, 961, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "table_tag", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " table_tag = {True:'th', False:'td'}[first]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L169_C12", "label": "first =", "type": "assigned_variable", "loc": [169, 169], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "vector": [14, 3, 0.5578, 0.0033, 3, 0.69, 0.125, 199, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "first", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " first = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L170_C12", "label": "url = url_for_result()", "type": "assigned_variable", "loc": [170, 170], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "vector": [14, 3, 0.5611, 0.0033, 3, 0.69, 0.25, 789, 3, 1, 0, 0, 778, 10, 1], "semantic": {"name": "url", "arg_names": [], "import_names": [], "rhs_call_name": "url_for_result", "annotation": ""}, "snippet": " url = cl.url_for_result(result)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L173_C12", "label": "if", "type": "if", "loc": [173, 176], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "vector": [4, 3, 0.5759, 0.0132, 3, 0.69, 0.375, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cl.to_field:\n attr = str(cl.to_field)\n else:\n attr = pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L174_C16", "label": "attr = str()", "type": "assigned_variable", "loc": [174, 174], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L173_C12", "vector": [14, 4, 0.5743, 0.0033, 4, 0.76, 0.0, 400, 3, 1, 0, 0, 52, 10, 1], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "str", "annotation": ""}, "snippet": " attr = str(cl.to_field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L176_C16", "label": "attr =", "type": "assigned_variable", "loc": [176, 176], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L173_C12", "vector": [14, 4, 0.5809, 0.0033, 4, 0.76, 1.0, 400, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attr = pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L177_C12", "label": "value = serializable_value()", "type": "assigned_variable", "loc": [177, 177], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "vector": [14, 3, 0.5842, 0.0033, 3, 0.69, 0.5, 441, 3, 1, 0, 0, 905, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "serializable_value", "annotation": ""}, "snippet": " value = result.serializable_value(attr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L178_C12", "label": "result_id =", "type": "assigned_variable", "loc": [178, 178], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "vector": [14, 3, 0.5875, 0.0033, 3, 0.69, 0.625, 500, 6, 0, 0, 0, 0, 0, 2], "semantic": {"name": "result_id", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result_id = repr(force_unicode(value))[1:]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L179_C12", "label": "expression", "type": "expression", "loc": [179, 180], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "vector": [8, 3, 0.5924, 0.0066, 3, 0.69, 0.75, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield mark_safe(u'<%s%s><a href=\"%s\"%s>%s</a></%s>' % \\\n (table_tag, row_class, url, (cl.is_popup and ' onclick=\"opener.dismissRelatedLookupPopup(window, %s); return false;\"' % result_id or ''), conditional_escape(result_repr), table_tag))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L185_C12", "label": "if", "type": "if", "loc": [185, 189], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "vector": [4, 3, 0.6172, 0.0165, 3, 0.69, 0.875, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form and field_name in form.fields:\n bf = form[field_name]\n result_repr = mark_safe(force_unicode(bf.errors) + force_unicode(bf))\n else:\n result_repr = conditional_escape(result_repr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L186_C16", "label": "bf =", "type": "assigned_variable", "loc": [186, 186], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L185_C12", "vector": [14, 4, 0.6139, 0.0033, 4, 0.71, 0.0, 635, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "bf", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " bf = form[field_name]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L187_C16", "label": "result_repr = mark_safe()", "type": "assigned_variable", "loc": [187, 187], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L185_C12", "vector": [14, 4, 0.6172, 0.0033, 4, 0.71, 0.5, 760, 3, 1, 0, 0, 159, 10, 3], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "mark_safe", "annotation": ""}, "snippet": " result_repr = mark_safe(force_unicode(bf.errors) + force_unicode(bf))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L189_C16", "label": "result_repr = conditional_escape()", "type": "assigned_variable", "loc": [189, 189], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L185_C12", "vector": [14, 4, 0.6238, 0.0033, 4, 0.71, 1.0, 760, 3, 1, 0, 0, 171, 10, 1], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "conditional_escape", "annotation": ""}, "snippet": " result_repr = conditional_escape(result_repr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L190_C12", "label": "expression", "type": "expression", "loc": [190, 190], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "vector": [8, 3, 0.6271, 0.0033, 3, 0.69, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield mark_safe(u'<td%s>%s</td>' % (row_class, result_repr))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L191_C4", "label": "if", "type": "if", "loc": [191, 192], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L128_C0", "vector": [4, 1, 0.632, 0.0066, 1, 0.29, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form and not form[cl.model._meta.pk.name].is_hidden:\n yield mark_safe(u'<td>%s</td>' % force_unicode(form[cl.model._meta.pk.name]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L192_C8", "label": "expression", "type": "expression", "loc": [192, 192], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L191_C4", "vector": [8, 2, 0.6337, 0.0033, 2, 0.75, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield mark_safe(u'<td>%s</td>' % force_unicode(form[cl.model._meta.pk.name]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L194_C0", "label": "results", "type": "function", "loc": [194, 200], "level": 0, "parent": null, "vector": [2, 0, 0.6502, 0.0231, 0, 0.66, 0.6765, 143, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "results", "arg_names": ["cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def results(cl):\n if cl.formset:\n for res, form in zip(cl.result_list, cl.formset.forms):\n yield list(items_for_result(cl, res, form))\n else:\n for res in cl.result_list:\n yield list(items_for_result(cl, res, None))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L195_C4", "label": "if", "type": "if", "loc": [195, 200], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L194_C0", "vector": [4, 1, 0.6518, 0.0198, 1, 0.81, 0.0, 0, 7, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cl.formset:\n for res, form in zip(cl.result_list, cl.formset.forms):\n yield list(items_for_result(cl, res, form))\n else:\n for res in cl.result_list:\n yield list(items_for_result(cl, res, None))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L196_C8", "label": "for res, form", "type": "for", "loc": [196, 197], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L195_C4", "vector": [6, 2, 0.6485, 0.0066, 2, 0.97, 0.0, 916, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "res, form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for res, form in zip(cl.result_list, cl.formset.forms):\n yield list(items_for_result(cl, res, form))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L197_C12", "label": "expression", "type": "expression", "loc": [197, 197], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L196_C8", "vector": [8, 3, 0.6502, 0.0033, 3, 0.14, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield list(items_for_result(cl, res, form))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L199_C8", "label": "for res", "type": "for", "loc": [199, 200], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L195_C4", "vector": [6, 2, 0.6584, 0.0066, 2, 0.97, 1.0, 413, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "res", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for res in cl.result_list:\n yield list(items_for_result(cl, res, None))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L200_C12", "label": "expression", "type": "expression", "loc": [200, 200], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L199_C8", "vector": [8, 3, 0.6601, 0.0033, 3, 0.55, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield list(items_for_result(cl, res, None))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L202_C0", "label": "result_hidden_fields", "type": "function", "loc": [202, 206], "level": 0, "parent": null, "vector": [2, 0, 0.6733, 0.0165, 0, 0.66, 0.7059, 498, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "result_hidden_fields", "arg_names": ["cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def result_hidden_fields(cl):\n if cl.formset:\n for res, form in zip(cl.result_list, cl.formset.forms):\n if form[cl.model._meta.pk.name].is_hidden:\n yield mark_safe(force_unicode(form[cl.model._meta.pk.name]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L203_C4", "label": "if", "type": "if", "loc": [203, 206], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L202_C0", "vector": [4, 1, 0.6749, 0.0132, 1, 0.51, 0.0, 0, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cl.formset:\n for res, form in zip(cl.result_list, cl.formset.forms):\n if form[cl.model._meta.pk.name].is_hidden:\n yield mark_safe(force_unicode(form[cl.model._meta.pk.name]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L204_C8", "label": "for res, form", "type": "for", "loc": [204, 206], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L203_C4", "vector": [6, 2, 0.6766, 0.0099, 2, 0.08, 0.0, 916, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "res, form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for res, form in zip(cl.result_list, cl.formset.forms):\n if form[cl.model._meta.pk.name].is_hidden:\n yield mark_safe(force_unicode(form[cl.model._meta.pk.name]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L205_C12", "label": "if", "type": "if", "loc": [205, 206], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L204_C8", "vector": [4, 3, 0.6782, 0.0066, 3, 0.08, 0.0, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form[cl.model._meta.pk.name].is_hidden:\n yield mark_safe(force_unicode(form[cl.model._meta.pk.name]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L206_C16", "label": "expression", "type": "expression", "loc": [206, 206], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L205_C12", "vector": [8, 4, 0.6799, 0.0033, 4, 0.05, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield mark_safe(force_unicode(form[cl.model._meta.pk.name]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L208_C0", "label": "result_list", "type": "function", "loc": [208, 215], "level": 0, "parent": null, "vector": [2, 0, 0.698, 0.0264, 0, 0.66, 0.7353, 587, 0, 1, 1, 0, 0, 0, 6], "semantic": {"name": "result_list", "arg_names": ["cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def result_list(cl):\n \"\"\"\n Displays the headers and data list together\n \"\"\"\n return {'cl': cl,\n 'result_hidden_fields': list(result_hidden_fields(cl)),\n 'result_headers': list(result_headers(cl)),\n 'results': list(results(cl))}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L209_C4", "label": "expression", "type": "expression", "loc": [209, 211], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L208_C0", "vector": [8, 1, 0.6931, 0.0099, 1, 0.6, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Displays the headers and data list together\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L212_C4", "label": "return", "type": "return", "loc": [212, 215], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L208_C0", "vector": [13, 1, 0.7046, 0.0132, 1, 0.6, 1.0, 0, 0, 0, 0, 0, 0, 6, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {'cl': cl,\n 'result_hidden_fields': list(result_hidden_fields(cl)),\n 'result_headers': list(result_headers(cl)),\n 'results': list(results(cl))}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L216_C0", "label": "result_list =", "type": "assigned_variable", "loc": [216, 216], "level": 0, "parent": null, "vector": [14, 0, 0.7129, 0.0033, 0, 0.66, 0.7647, 587, 3, 1, 0, 0, 0, 10, 2], "semantic": {"name": "result_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "result_list = register.inclusion_tag(\"admin/change_list_results.html\")(result_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L218_C0", "label": "date_hierarchy", "type": "function", "loc": [218, 278], "level": 0, "parent": null, "vector": [2, 0, 0.8185, 0.2013, 0, 0.66, 0.7941, 317, 0, 1, 1, 0, 0, 0, 30], "semantic": {"name": "date_hierarchy", "arg_names": ["cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def date_hierarchy(cl):\n \"\"\"\n Displays the date hierarchy for date drill-down functionality.\n \"\"\"\n if cl.date_hierarchy:\n field_name = cl.date_hierarchy\n year_field = '%s__year' % field_name\n month_field = '%s__month' % field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L219_C4", "label": "expression", "type": "expression", "loc": [219, 221], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L218_C0", "vector": [8, 1, 0.7261, 0.0099, 1, 0.39, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Displays the date hierarchy for date drill-down functionality.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "label": "if", "type": "if", "loc": [222, 278], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L218_C0", "vector": [4, 1, 0.8251, 0.1881, 1, 0.39, 1.0, 0, 7, 0, 0, 0, 0, 0, 30], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cl.date_hierarchy:\n field_name = cl.date_hierarchy\n year_field = '%s__year' % field_name\n month_field = '%s__month' % field_name\n day_field = '%s__day' % field_name\n field_generic = '%s__' % field_name\n year_lookup = cl.params.get(year_field)\n month_lookup = cl.params.get(month_field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L223_C8", "label": "field_name =", "type": "assigned_variable", "loc": [223, 223], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "vector": [14, 2, 0.736, 0.0033, 2, 0.86, 0.0, 918, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_name = cl.date_hierarchy"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L224_C8", "label": "year_field =", "type": "assigned_variable", "loc": [224, 224], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "vector": [14, 2, 0.7393, 0.0033, 2, 0.86, 0.1111, 971, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "year_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " year_field = '%s__year' % field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L225_C8", "label": "month_field =", "type": "assigned_variable", "loc": [225, 225], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "vector": [14, 2, 0.7426, 0.0033, 2, 0.86, 0.2222, 461, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "month_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " month_field = '%s__month' % field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L226_C8", "label": "day_field =", "type": "assigned_variable", "loc": [226, 226], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "vector": [14, 2, 0.7459, 0.0033, 2, 0.86, 0.3333, 990, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "day_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " day_field = '%s__day' % field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L227_C8", "label": "field_generic =", "type": "assigned_variable", "loc": [227, 227], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "vector": [14, 2, 0.7492, 0.0033, 2, 0.86, 0.4444, 273, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "field_generic", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_generic = '%s__' % field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L228_C8", "label": "year_lookup = get()", "type": "assigned_variable", "loc": [228, 228], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "vector": [14, 2, 0.7525, 0.0033, 2, 0.86, 0.5556, 68, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "year_lookup", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " year_lookup = cl.params.get(year_field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L229_C8", "label": "month_lookup = get()", "type": "assigned_variable", "loc": [229, 229], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "vector": [14, 2, 0.7558, 0.0033, 2, 0.86, 0.6667, 13, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "month_lookup", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " month_lookup = cl.params.get(month_field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L230_C8", "label": "day_lookup = get()", "type": "assigned_variable", "loc": [230, 230], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "vector": [14, 2, 0.7591, 0.0033, 2, 0.86, 0.7778, 727, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "day_lookup", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " day_lookup = cl.params.get(day_field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L232_C8", "label": "link =", "type": "assigned_variable", "loc": [232, 232], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "vector": [14, 2, 0.7657, 0.0033, 2, 0.86, 0.8889, 880, 9, 0, 0, 0, 0, 0, 1], "semantic": {"name": "link", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " link = lambda d: cl.get_query_string(d, [field_generic])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L234_C8", "label": "if", "type": "if", "loc": [234, 278], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "vector": [4, 2, 0.8449, 0.1485, 2, 0.86, 1.0, 0, 0, 0, 0, 0, 0, 0, 26], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if year_lookup and month_lookup and day_lookup:\n day = datetime.date(int(year_lookup), int(month_lookup), int(day_lookup))\n return {\n 'show': True,\n 'back': {\n 'link': link({year_field: year_lookup, month_field: month_lookup}),\n 'title': capfirst(formats.date_format(day, 'YEAR_MONTH_FORMAT'))\n },"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L235_C12", "label": "day = date()", "type": "assigned_variable", "loc": [235, 235], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L234_C8", "vector": [14, 3, 0.7756, 0.0033, 3, 0.18, 0.0, 878, 3, 3, 0, 0, 56, 10, 4], "semantic": {"name": "day", "arg_names": [], "import_names": [], "rhs_call_name": "date", "annotation": ""}, "snippet": " day = datetime.date(int(year_lookup), int(month_lookup), int(day_lookup))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L236_C12", "label": "return", "type": "return", "loc": [236, 243], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L234_C8", "vector": [13, 3, 0.7904, 0.0264, 3, 0.18, 0.5, 0, 0, 0, 0, 0, 0, 6, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {\n 'show': True,\n 'back': {\n 'link': link({year_field: year_lookup, month_field: month_lookup}),\n 'title': capfirst(formats.date_format(day, 'YEAR_MONTH_FORMAT'))\n },\n 'choices': [{'title': capfirst(formats.date_format(day, 'MONTH_DAY_FORMAT'))}]\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L244_C8", "label": "if", "type": "if", "loc": [244, 278], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L234_C8", "vector": [4, 3, 0.8614, 0.1155, 3, 0.18, 1.0, 0, 0, 0, 0, 0, 0, 0, 17], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif year_lookup and month_lookup:\n days = cl.query_set.filter(**{year_field: year_lookup, month_field: month_lookup}).dates(field_name, 'day')\n return {\n 'show': True,\n 'back': {\n 'link': link({year_field: year_lookup}),\n 'title': year_lookup\n },"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L245_C12", "label": "days = dates()", "type": "assigned_variable", "loc": [245, 245], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L244_C8", "vector": [14, 4, 0.8086, 0.0033, 4, 0.93, 0.0, 939, 3, 2, 0, 0, 253, 10, 2], "semantic": {"name": "days", "arg_names": [], "import_names": [], "rhs_call_name": "dates", "annotation": ""}, "snippet": " days = cl.query_set.filter(**{year_field: year_lookup, month_field: month_lookup}).dates(field_name, 'day')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L246_C12", "label": "return", "type": "return", "loc": [246, 256], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L244_C8", "vector": [13, 4, 0.8284, 0.0363, 4, 0.93, 0.5, 0, 0, 0, 0, 0, 0, 6, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {\n 'show': True,\n 'back': {\n 'link': link({year_field: year_lookup}),\n 'title': year_lookup\n },\n 'choices': [{\n 'link': link({year_field: year_lookup, month_field: month_lookup, day_field: day.day}),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L257_C8", "label": "if", "type": "if", "loc": [257, 278], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L244_C8", "vector": [4, 4, 0.8828, 0.0726, 4, 0.93, 1.0, 0, 2, 0, 0, 0, 0, 0, 11], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif year_lookup:\n months = cl.query_set.filter(**{year_field: year_lookup}).dates(field_name, 'month')\n return {\n 'show' : True,\n 'back': {\n 'link' : link({}),\n 'title': _('All dates')\n },"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L258_C12", "label": "months = dates()", "type": "assigned_variable", "loc": [258, 258], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L257_C8", "vector": [14, 5, 0.8515, 0.0033, 5, 0.68, 0.0, 458, 3, 2, 0, 0, 253, 10, 2], "semantic": {"name": "months", "arg_names": [], "import_names": [], "rhs_call_name": "dates", "annotation": ""}, "snippet": " months = cl.query_set.filter(**{year_field: year_lookup}).dates(field_name, 'month')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L259_C12", "label": "return", "type": "return", "loc": [259, 269], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L257_C8", "vector": [13, 5, 0.8713, 0.0363, 5, 0.68, 0.3333, 0, 0, 0, 0, 0, 0, 6, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {\n 'show' : True,\n 'back': {\n 'link' : link({}),\n 'title': _('All dates')\n },\n 'choices': [{\n 'link': link({year_field: year_lookup, month_field: month.month}),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L271_C12", "label": "years = dates()", "type": "assigned_variable", "loc": [271, 271], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L257_C8", "vector": [14, 5, 0.8944, 0.0033, 5, 0.68, 0.6667, 301, 3, 2, 0, 0, 253, 10, 1], "semantic": {"name": "years", "arg_names": [], "import_names": [], "rhs_call_name": "dates", "annotation": ""}, "snippet": " years = cl.query_set.dates(field_name, 'year')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L272_C12", "label": "return", "type": "return", "loc": [272, 278], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L257_C8", "vector": [13, 5, 0.9076, 0.0231, 5, 0.68, 1.0, 0, 0, 0, 0, 0, 0, 6, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {\n 'show': True,\n 'choices': [{\n 'link': link({year_field: str(year.year)}),\n 'title': str(year.year),\n } for year in years]\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L279_C0", "label": "date_hierarchy =", "type": "assigned_variable", "loc": [279, 279], "level": 0, "parent": null, "vector": [14, 0, 0.9208, 0.0033, 0, 0.66, 0.8235, 317, 3, 1, 0, 0, 0, 10, 2], "semantic": {"name": "date_hierarchy", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "date_hierarchy = register.inclusion_tag('admin/date_hierarchy.html')(date_hierarchy)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L281_C0", "label": "search_form", "type": "function", "loc": [281, 289], "level": 0, "parent": null, "vector": [2, 0, 0.9406, 0.0297, 0, 0.66, 0.8529, 367, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "search_form", "arg_names": ["cl"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def search_form(cl):\n \"\"\"\n Displays a search form for searching the list.\n \"\"\"\n return {\n 'cl': cl,\n 'show_result_count': cl.result_count != cl.full_result_count,\n 'search_var': SEARCH_VAR"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L282_C4", "label": "expression", "type": "expression", "loc": [282, 284], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L281_C0", "vector": [8, 1, 0.934, 0.0099, 1, 0.56, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Displays a search form for searching the list.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L285_C4", "label": "return", "type": "return", "loc": [285, 289], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L281_C0", "vector": [13, 1, 0.9472, 0.0165, 1, 0.56, 1.0, 0, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {\n 'cl': cl,\n 'show_result_count': cl.result_count != cl.full_result_count,\n 'search_var': SEARCH_VAR\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L290_C0", "label": "search_form =", "type": "assigned_variable", "loc": [290, 290], "level": 0, "parent": null, "vector": [14, 0, 0.9571, 0.0033, 0, 0.66, 0.8824, 367, 3, 1, 0, 0, 0, 10, 2], "semantic": {"name": "search_form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "search_form = register.inclusion_tag('admin/search_form.html')(search_form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L292_C0", "label": "admin_list_filter", "type": "function", "loc": [292, 293], "level": 0, "parent": null, "vector": [2, 0, 0.9653, 0.0066, 0, 0.66, 0.9118, 968, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "admin_list_filter", "arg_names": ["cl", "spec"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def admin_list_filter(cl, spec):\n return {'title': spec.title(), 'choices' : list(spec.choices(cl))}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L293_C4", "label": "return", "type": "return", "loc": [293, 293], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L292_C0", "vector": [13, 1, 0.967, 0.0033, 1, 0.47, 0.0, 0, 0, 0, 0, 0, 0, 6, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {'title': spec.title(), 'choices' : list(spec.choices(cl))}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L294_C0", "label": "admin_list_filter =", "type": "assigned_variable", "loc": [294, 294], "level": 0, "parent": null, "vector": [14, 0, 0.9703, 0.0033, 0, 0.66, 0.9412, 968, 3, 1, 0, 0, 0, 10, 2], "semantic": {"name": "admin_list_filter", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "admin_list_filter = register.inclusion_tag('admin/filter.html')(admin_list_filter)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L296_C0", "label": "admin_actions", "type": "function", "loc": [296, 302], "level": 0, "parent": null, "vector": [2, 0, 0.9868, 0.0231, 0, 0.66, 0.9706, 54, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "admin_actions", "arg_names": ["context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def admin_actions(context):\n \"\"\"\n Track the number of times the action field has been rendered on the page,\n so we know which value to use.\n \"\"\"\n context['action_index'] = context.get('action_index', -1) + 1\n return context"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L297_C4", "label": "expression", "type": "expression", "loc": [297, 300], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L296_C0", "vector": [8, 1, 0.9851, 0.0132, 1, 0.99, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Track the number of times the action field has been rendered on the page,\n so we know which value to use.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L301_C4", "label": "assign", "type": "assigned_variable", "loc": [301, 301], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L296_C0", "vector": [14, 1, 0.9934, 0.0033, 1, 0.99, 0.5, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context['action_index'] = context.get('action_index', -1) + 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L302_C4", "label": "return", "type": "return", "loc": [302, 302], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L296_C0", "vector": [13, 1, 0.9967, 0.0033, 1, 0.99, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return context"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L303_C0", "label": "admin_actions =", "type": "assigned_variable", "loc": [303, 303], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0033, 0, 0.66, 1.0, 54, 3, 1, 0, 0, 0, 10, 2], "semantic": {"name": "admin_actions", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "admin_actions = register.inclusion_tag(\"admin/actions.html\", takes_context=True)(admin_actions)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L35_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L55_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L56_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L56_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L57_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L56_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L58_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L56_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L59_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L56_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L61_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L62_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L62_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L63_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L62_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L64_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L62_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L65_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L62_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L67_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L34_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L70_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L80_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L81_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L80_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L84_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L80_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L91_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L93_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L93_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L94_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L91_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L101_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L91_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L102_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L102_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L103_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L91_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L109_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L111_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L112_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L114_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L113_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L115_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L117_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L124_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L125_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L124_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L126_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L128_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L129_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L128_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L132_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L128_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L133_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L128_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L134_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L135_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Try_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:Try_L136_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L137_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:Try_L136_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L139_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:Try_L136_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L142_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L143_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L144_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L144_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L145_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L144_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L146_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L144_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L148_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L151_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L151_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L152_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L151_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L154_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L156_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L156_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L157_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L158_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L158_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L159_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L158_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L161_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L162_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L162_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L163_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L164_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L164_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L165_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L168_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L169_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L170_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L173_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L173_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L174_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L173_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L176_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L177_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L178_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L179_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L185_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L185_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L186_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L185_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L187_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L185_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L189_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L167_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L190_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L128_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L191_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L191_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L192_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L194_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L195_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L195_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L197_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L195_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L199_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L199_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L200_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L202_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L203_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L203_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L204_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:For_L204_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L205_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L205_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L206_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L208_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L209_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L208_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L212_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L218_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L219_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L218_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L223_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L224_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L225_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L226_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L227_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L228_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L229_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L230_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L232_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L234_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L234_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L235_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L234_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L236_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L234_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L244_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L245_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L246_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L257_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L257_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L258_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L257_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L259_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L257_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L271_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:If_L257_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L272_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L281_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L282_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L281_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L285_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L292_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L293_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L296_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Expr_L297_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L296_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Assign_L301_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98646:FunctionDef_L296_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98646:Return_L302_C4"}] |
from django.db import models
from django.db.models.deletion import Collector
from django.db.models.related import RelatedObject
from django.forms.forms import pretty_name
from django.utils import formats
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.text import capfirst
from django.utils.encoding import force_unicode, smart_unicode, smart_str
from django.utils.translation import ungettext
from django.core.urlresolvers import reverse, NoReverseMatch
from django.utils.datastructures import SortedDict
def quote(s):
"""
Ensure that primary key values do not confuse the admin URLs by escaping
any '/', '_' and ':' characters. Similar to urllib.quote, except that the
quoting is slightly different so that it doesn't get automatically
unquoted by the Web browser.
"""
if not isinstance(s, basestring):
return s
res = list(s)
for i in range(len(res)):
c = res[i]
if c in """:/_#?;@&=+$,"<>%\\""":
res[i] = '_%02X' % ord(c)
return ''.join(res)
def unquote(s):
"""
Undo the effects of quote(). Based heavily on urllib.unquote().
"""
mychr = chr
myatoi = int
list = s.split('_')
res = [list[0]]
myappend = res.append
del list[0]
for item in list:
if item[1:2]:
try:
myappend(mychr(myatoi(item[:2], 16)) + item[2:])
except ValueError:
myappend('_' + item)
else:
myappend('_' + item)
return "".join(res)
def flatten_fieldsets(fieldsets):
"""Returns a list of field names from an admin fieldsets structure."""
field_names = []
for name, opts in fieldsets:
for field in opts['fields']:
# type checking feels dirty, but it seems like the best way here
if type(field) == tuple:
field_names.extend(field)
else:
field_names.append(field)
return field_names
def get_deleted_objects(objs, opts, user, admin_site, using):
"""
Find all objects related to ``objs`` that should also be deleted. ``objs``
must be a homogenous iterable of objects (e.g. a QuerySet).
Returns a nested list of strings suitable for display in the
template with the ``unordered_list`` filter.
"""
collector = NestedObjects(using=using)
collector.collect(objs)
perms_needed = set()
def format_callback(obj):
has_admin = obj.__class__ in admin_site._registry
opts = obj._meta
if has_admin:
admin_url = reverse('%s:%s_%s_change'
% (admin_site.name,
opts.app_label,
opts.object_name.lower()),
None, (quote(obj._get_pk_val()),))
p = '%s.%s' % (opts.app_label,
opts.get_delete_permission())
if not user.has_perm(p):
perms_needed.add(opts.verbose_name)
# Display a link to the admin page.
return mark_safe(u'%s: <a href="%s">%s</a>' %
(escape(capfirst(opts.verbose_name)),
admin_url,
escape(obj)))
else:
# Don't display link to edit, because it either has no
# admin or is edited inline.
return u'%s: %s' % (capfirst(opts.verbose_name),
force_unicode(obj))
to_delete = collector.nested(format_callback)
return to_delete, perms_needed
class NestedObjects(Collector):
def __init__(self, *args, **kwargs):
super(NestedObjects, self).__init__(*args, **kwargs)
self.edges = {} # {from_instance: [to_instances]}
def add_edge(self, source, target):
self.edges.setdefault(source, []).append(target)
def collect(self, objs, source_attr=None, **kwargs):
for obj in objs:
if source_attr:
self.add_edge(getattr(obj, source_attr), obj)
else:
self.add_edge(None, obj)
return super(NestedObjects, self).collect(objs, source_attr=source_attr, **kwargs)
def related_objects(self, related, objs):
qs = super(NestedObjects, self).related_objects(related, objs)
return qs.select_related(related.field.name)
def _nested(self, obj, seen, format_callback):
if obj in seen:
return []
seen.add(obj)
children = []
for child in self.edges.get(obj, ()):
children.extend(self._nested(child, seen, format_callback))
if format_callback:
ret = [format_callback(obj)]
else:
ret = [obj]
if children:
ret.append(children)
return ret
def nested(self, format_callback=None):
"""
Return the graph as a nested list.
"""
seen = set()
roots = []
for root in self.edges.get(None, ()):
roots.extend(self._nested(root, seen, format_callback))
return roots
def model_format_dict(obj):
"""
Return a `dict` with keys 'verbose_name' and 'verbose_name_plural',
typically for use with string formatting.
`obj` may be a `Model` instance, `Model` subclass, or `QuerySet` instance.
"""
if isinstance(obj, (models.Model, models.base.ModelBase)):
opts = obj._meta
elif isinstance(obj, models.query.QuerySet):
opts = obj.model._meta
else:
opts = obj
return {
'verbose_name': force_unicode(opts.verbose_name),
'verbose_name_plural': force_unicode(opts.verbose_name_plural)
}
def model_ngettext(obj, n=None):
"""
Return the appropriate `verbose_name` or `verbose_name_plural` value for
`obj` depending on the count `n`.
`obj` may be a `Model` instance, `Model` subclass, or `QuerySet` instance.
If `obj` is a `QuerySet` instance, `n` is optional and the length of the
`QuerySet` is used.
"""
if isinstance(obj, models.query.QuerySet):
if n is None:
n = obj.count()
obj = obj.model
d = model_format_dict(obj)
singular, plural = d["verbose_name"], d["verbose_name_plural"]
return ungettext(singular, plural, n or 0)
def lookup_field(name, obj, model_admin=None):
opts = obj._meta
try:
f = opts.get_field(name)
except models.FieldDoesNotExist:
# For non-field values, the value is either a method, property or
# returned via a callable.
if callable(name):
attr = name
value = attr(obj)
elif (model_admin is not None and hasattr(model_admin, name) and
not name == '__str__' and not name == '__unicode__'):
attr = getattr(model_admin, name)
value = attr(obj)
else:
attr = getattr(obj, name)
if callable(attr):
value = attr()
else:
value = attr
f = None
else:
attr = None
value = getattr(obj, name)
return f, attr, value
def label_for_field(name, model, model_admin=None, return_attr=False):
attr = None
try:
field = model._meta.get_field_by_name(name)[0]
if isinstance(field, RelatedObject):
label = field.opts.verbose_name
else:
label = field.verbose_name
except models.FieldDoesNotExist:
if name == "__unicode__":
label = force_unicode(model._meta.verbose_name)
elif name == "__str__":
label = smart_str(model._meta.verbose_name)
else:
if callable(name):
attr = name
elif model_admin is not None and hasattr(model_admin, name):
attr = getattr(model_admin, name)
elif hasattr(model, name):
attr = getattr(model, name)
else:
message = "Unable to lookup '%s' on %s" % (name, model._meta.object_name)
if model_admin:
message += " or %s" % (model_admin.__name__,)
raise AttributeError(message)
if hasattr(attr, "short_description"):
label = attr.short_description
elif callable(attr):
if attr.__name__ == "<lambda>":
label = "--"
else:
label = pretty_name(attr.__name__)
else:
label = pretty_name(name)
if return_attr:
return (label, attr)
else:
return label
def display_for_field(value, field):
from django.contrib.admin.templatetags.admin_list import _boolean_icon
from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
if field.flatchoices:
return dict(field.flatchoices).get(value, EMPTY_CHANGELIST_VALUE)
# NullBooleanField needs special-case null-handling, so it comes
# before the general null test.
elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):
return _boolean_icon(value)
elif value is None:
return EMPTY_CHANGELIST_VALUE
elif isinstance(field, models.DateField) or isinstance(field, models.TimeField):
return formats.localize(value)
elif isinstance(field, models.DecimalField):
return formats.number_format(value, field.decimal_places)
elif isinstance(field, models.FloatField):
return formats.number_format(value)
else:
return smart_unicode(value)
| ajibawa-2023/Python-Code-Large/train/row_98647 | 177 | 282 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L1_C0", "label": "from django.db import models", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0035, 0.0035, 0, 0.66, 0.0, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L2_C0", "label": "from django.db.models.deletion import Collector", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0071, 0.0035, 0, 0.66, 0.0476, 229, 0, 1, 0, 0, 229, 0, 0], "semantic": {"name": "django.db.models.deletion", "arg_names": [], "import_names": ["Collector"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models.deletion import Collector"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L3_C0", "label": "from django.db.models.related import RelatedObject", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0106, 0.0035, 0, 0.66, 0.0952, 859, 0, 1, 0, 0, 859, 0, 0], "semantic": {"name": "django.db.models.related", "arg_names": [], "import_names": ["RelatedObject"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models.related import RelatedObject"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L4_C0", "label": "from django.forms.forms import pretty_name", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0142, 0.0035, 0, 0.66, 0.1429, 975, 0, 1, 0, 0, 975, 0, 0], "semantic": {"name": "django.forms.forms", "arg_names": [], "import_names": ["pretty_name"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.forms.forms import pretty_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L5_C0", "label": "from django.utils import formats", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0177, 0.0035, 0, 0.66, 0.1905, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["formats"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import formats"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L6_C0", "label": "from django.utils.html import escape", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0213, 0.0035, 0, 0.66, 0.2381, 535, 0, 1, 0, 0, 535, 0, 0], "semantic": {"name": "django.utils.html", "arg_names": [], "import_names": ["escape"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.html import escape"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L7_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0248, 0.0035, 0, 0.66, 0.2857, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.safestring", "arg_names": [], "import_names": ["mark_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.safestring import mark_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L8_C0", "label": "from django.utils.text import capfirst", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0284, 0.0035, 0, 0.66, 0.3333, 590, 0, 1, 0, 0, 590, 0, 0], "semantic": {"name": "django.utils.text", "arg_names": [], "import_names": ["capfirst"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.text import capfirst"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L9_C0", "label": "from django.utils.encoding import force_unicode, smart_unicode, smart_str", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0319, 0.0035, 0, 0.66, 0.381, 96, 0, 3, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["force_unicode", "smart_unicode", "smart_str"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import force_unicode, smart_unicode, smart_str"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L10_C0", "label": "from django.utils.translation import ungettext", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0355, 0.0035, 0, 0.66, 0.4286, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["ungettext"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ungettext"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L11_C0", "label": "from django.core.urlresolvers import reverse, NoReverseMatch", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.039, 0.0035, 0, 0.66, 0.4762, 749, 0, 2, 0, 0, 749, 0, 0], "semantic": {"name": "django.core.urlresolvers", "arg_names": [], "import_names": ["reverse", "NoReverseMatch"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.urlresolvers import reverse, NoReverseMatch"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L12_C0", "label": "from django.utils.datastructures import SortedDict", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0426, 0.0035, 0, 0.66, 0.5238, 757, 0, 1, 0, 0, 757, 0, 0], "semantic": {"name": "django.utils.datastructures", "arg_names": [], "import_names": ["SortedDict"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.datastructures import SortedDict"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L15_C0", "label": "quote", "type": "function", "loc": [15, 29], "level": 0, "parent": null, "vector": [2, 0, 0.078, 0.0532, 0, 0.66, 0.5714, 79, 0, 1, 1, 0, 0, 0, 6], "semantic": {"name": "quote", "arg_names": ["s"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def quote(s):\n \"\"\"\n Ensure that primary key values do not confuse the admin URLs by escaping\n any '/', '_' and ':' characters. Similar to urllib.quote, except that the\n quoting is slightly different so that it doesn't get automatically\n unquoted by the Web browser.\n \"\"\"\n if not isinstance(s, basestring):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L16_C4", "label": "expression", "type": "expression", "loc": [16, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L15_C0", "vector": [8, 1, 0.0656, 0.0213, 1, 0.19, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Ensure that primary key values do not confuse the admin URLs by escaping\n any '/', '_' and ':' characters. Similar to urllib.quote, except that the\n quoting is slightly different so that it doesn't get automatically\n unquoted by the Web browser.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L22_C4", "label": "if", "type": "if", "loc": [22, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L15_C0", "vector": [4, 1, 0.0798, 0.0071, 1, 0.19, 0.25, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(s, basestring):\n return s"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L23_C8", "label": "return", "type": "return", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L22_C4", "vector": [13, 2, 0.0816, 0.0035, 2, 0.66, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return s"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L24_C4", "label": "res = list()", "type": "assigned_variable", "loc": [24, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L15_C0", "vector": [14, 1, 0.0851, 0.0035, 1, 0.19, 0.5, 413, 3, 1, 0, 0, 430, 10, 1], "semantic": {"name": "res", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " res = list(s)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L25_C4", "label": "for i", "type": "for", "loc": [25, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L15_C0", "vector": [6, 1, 0.094, 0.0142, 1, 0.19, 0.75, 826, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "i", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i in range(len(res)):\n c = res[i]\n if c in \"\"\":/_#?;@&=+$,\"<>%\\\\\"\"\":\n res[i] = '_%02X' % ord(c)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L26_C8", "label": "c =", "type": "assigned_variable", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L25_C4", "vector": [14, 2, 0.0922, 0.0035, 2, 0.55, 0.0, 411, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " c = res[i]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L27_C8", "label": "if", "type": "if", "loc": [27, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L25_C4", "vector": [4, 2, 0.0975, 0.0071, 2, 0.55, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if c in \"\"\":/_#?;@&=+$,\"<>%\\\\\"\"\":\n res[i] = '_%02X' % ord(c)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L28_C12", "label": "assign", "type": "assigned_variable", "loc": [28, 28], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L27_C8", "vector": [14, 3, 0.0993, 0.0035, 3, 0.57, 0.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " res[i] = '_%02X' % ord(c)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L29_C4", "label": "return", "type": "return", "loc": [29, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L15_C0", "vector": [13, 1, 0.1028, 0.0035, 1, 0.19, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''.join(res)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "label": "unquote", "type": "function", "loc": [32, 50], "level": 0, "parent": null, "vector": [2, 0, 0.1454, 0.0674, 0, 0.66, 0.619, 432, 0, 1, 1, 0, 0, 0, 7], "semantic": {"name": "unquote", "arg_names": ["s"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def unquote(s):\n \"\"\"\n Undo the effects of quote(). Based heavily on urllib.unquote().\n \"\"\"\n mychr = chr\n myatoi = int\n list = s.split('_')\n res = [list[0]]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L33_C4", "label": "expression", "type": "expression", "loc": [33, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "vector": [8, 1, 0.1206, 0.0106, 1, 0.91, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Undo the effects of quote(). Based heavily on urllib.unquote().\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L36_C4", "label": "mychr =", "type": "assigned_variable", "loc": [36, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "vector": [14, 1, 0.1277, 0.0035, 1, 0.91, 0.1429, 432, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "mychr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " mychr = chr"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L37_C4", "label": "myatoi =", "type": "assigned_variable", "loc": [37, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "vector": [14, 1, 0.1312, 0.0035, 1, 0.91, 0.2857, 389, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "myatoi", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " myatoi = int"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L38_C4", "label": "list = split()", "type": "assigned_variable", "loc": [38, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "vector": [14, 1, 0.1348, 0.0035, 1, 0.91, 0.4286, 430, 3, 1, 0, 0, 908, 10, 1], "semantic": {"name": "list", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " list = s.split('_')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L39_C4", "label": "res =", "type": "assigned_variable", "loc": [39, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "vector": [14, 1, 0.1383, 0.0035, 1, 0.91, 0.5714, 413, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "res", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " res = [list[0]]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L40_C4", "label": "myappend =", "type": "assigned_variable", "loc": [40, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "vector": [14, 1, 0.1418, 0.0035, 1, 0.91, 0.7143, 707, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "myappend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " myappend = res.append"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L42_C4", "label": "for item", "type": "for", "loc": [42, 49], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "vector": [6, 1, 0.1613, 0.0284, 1, 0.91, 0.8571, 434, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "item", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for item in list:\n if item[1:2]:\n try:\n myappend(mychr(myatoi(item[:2], 16)) + item[2:])\n except ValueError:\n myappend('_' + item)\n else:\n myappend('_' + item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L43_C8", "label": "if", "type": "if", "loc": [43, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L42_C4", "vector": [4, 2, 0.1631, 0.0248, 2, 0.58, 0.0, 0, 6, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if item[1:2]:\n try:\n myappend(mychr(myatoi(item[:2], 16)) + item[2:])\n except ValueError:\n myappend('_' + item)\n else:\n myappend('_' + item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L44_C12", "label": "try", "type": "try", "loc": [44, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L43_C8", "vector": [7, 3, 0.1613, 0.0142, 3, 0.12, 0.0, 0, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n myappend(mychr(myatoi(item[:2], 16)) + item[2:])\n except ValueError:\n myappend('_' + item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L45_C16", "label": "myappend()", "type": "expression", "loc": [45, 45], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L44_C12", "vector": [8, 4, 0.1596, 0.0035, 4, 0.36, 0.0, 707, 3, 1, 0, 0, 0, 0, 3], "semantic": {"name": "myappend", "arg_names": [], "import_names": [], "rhs_call_name": "myappend", "annotation": ""}, "snippet": " myappend(mychr(myatoi(item[:2], 16)) + item[2:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L47_C16", "label": "myappend()", "type": "expression", "loc": [47, 47], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L44_C12", "vector": [8, 4, 0.1667, 0.0035, 4, 0.36, 0.0, 707, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "myappend", "arg_names": [], "import_names": [], "rhs_call_name": "myappend", "annotation": ""}, "snippet": " myappend('_' + item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L49_C12", "label": "myappend()", "type": "expression", "loc": [49, 49], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L43_C8", "vector": [8, 3, 0.1738, 0.0035, 3, 0.12, 1.0, 707, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "myappend", "arg_names": [], "import_names": [], "rhs_call_name": "myappend", "annotation": ""}, "snippet": " myappend('_' + item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L50_C4", "label": "return", "type": "return", "loc": [50, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "vector": [13, 1, 0.1773, 0.0035, 1, 0.91, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"\".join(res)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L53_C0", "label": "flatten_fieldsets", "type": "function", "loc": [53, 63], "level": 0, "parent": null, "vector": [2, 0, 0.2057, 0.039, 0, 0.66, 0.6667, 348, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "flatten_fieldsets", "arg_names": ["fieldsets"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def flatten_fieldsets(fieldsets):\n \"\"\"Returns a list of field names from an admin fieldsets structure.\"\"\"\n field_names = []\n for name, opts in fieldsets:\n for field in opts['fields']:\n # type checking feels dirty, but it seems like the best way here\n if type(field) == tuple:\n field_names.extend(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L54_C4", "label": "expression", "type": "expression", "loc": [54, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L53_C0", "vector": [8, 1, 0.1915, 0.0035, 1, 0.91, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Returns a list of field names from an admin fieldsets structure.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L55_C4", "label": "field_names =", "type": "assigned_variable", "loc": [55, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L53_C0", "vector": [14, 1, 0.195, 0.0035, 1, 0.91, 0.3333, 723, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "field_names", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_names = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L56_C4", "label": "for name, opts", "type": "for", "loc": [56, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L53_C0", "vector": [6, 1, 0.2092, 0.0248, 1, 0.91, 0.6667, 68, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "name, opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name, opts in fieldsets:\n for field in opts['fields']:\n # type checking feels dirty, but it seems like the best way here\n if type(field) == tuple:\n field_names.extend(field)\n else:\n field_names.append(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L57_C8", "label": "for field", "type": "for", "loc": [57, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L56_C4", "vector": [6, 2, 0.211, 0.0213, 2, 0.39, 0.0, 480, 6, 0, 0, 0, 0, 0, 3], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field in opts['fields']:\n # type checking feels dirty, but it seems like the best way here\n if type(field) == tuple:\n field_names.extend(field)\n else:\n field_names.append(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L59_C12", "label": "if", "type": "if", "loc": [59, 62], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L57_C8", "vector": [4, 3, 0.2145, 0.0142, 3, 0.37, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if type(field) == tuple:\n field_names.extend(field)\n else:\n field_names.append(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L60_C16", "label": "extend()", "type": "expression", "loc": [60, 60], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L59_C12", "vector": [8, 4, 0.2128, 0.0035, 4, 0.65, 0.0, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " field_names.extend(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L62_C16", "label": "append()", "type": "expression", "loc": [62, 62], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L59_C12", "vector": [8, 4, 0.2199, 0.0035, 4, 0.65, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " field_names.append(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L63_C4", "label": "return", "type": "return", "loc": [63, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L53_C0", "vector": [13, 1, 0.2234, 0.0035, 1, 0.91, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return field_names"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "label": "get_deleted_objects", "type": "function", "loc": [66, 106], "level": 0, "parent": null, "vector": [2, 0, 0.305, 0.1454, 0, 0.66, 0.7143, 624, 0, 5, 1, 0, 0, 0, 17], "semantic": {"name": "get_deleted_objects", "arg_names": ["objs", "opts", "user", "admin_site", "using"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_deleted_objects(objs, opts, user, admin_site, using):\n \"\"\"\n Find all objects related to ``objs`` that should also be deleted. ``objs``\n must be a homogenous iterable of objects (e.g. a QuerySet).\n\n Returns a nested list of strings suitable for display in the\n template with the ``unordered_list`` filter.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L67_C4", "label": "expression", "type": "expression", "loc": [67, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "vector": [8, 1, 0.25, 0.0284, 1, 0.07, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Find all objects related to ``objs`` that should also be deleted. ``objs``\n must be a homogenous iterable of objects (e.g. a QuerySet).\n\n Returns a nested list of strings suitable for display in the\n template with the ``unordered_list`` filter.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L75_C4", "label": "collector = NestedObjects()", "type": "assigned_variable", "loc": [75, 75], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "vector": [14, 1, 0.266, 0.0035, 1, 0.07, 0.1667, 674, 3, 1, 0, 0, 19, 10, 1], "semantic": {"name": "collector", "arg_names": [], "import_names": [], "rhs_call_name": "NestedObjects", "annotation": ""}, "snippet": " collector = NestedObjects(using=using)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L76_C4", "label": "collect()", "type": "expression", "loc": [76, 76], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "vector": [8, 1, 0.2695, 0.0035, 1, 0.07, 0.3333, 34, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "collect", "arg_names": [], "import_names": [], "rhs_call_name": "collect", "annotation": ""}, "snippet": " collector.collect(objs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L77_C4", "label": "perms_needed = set()", "type": "assigned_variable", "loc": [77, 77], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "vector": [14, 1, 0.273, 0.0035, 1, 0.07, 0.5, 47, 3, 0, 0, 0, 21, 10, 1], "semantic": {"name": "perms_needed", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " perms_needed = set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L79_C4", "label": "format_callback", "type": "function", "loc": [79, 102], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "vector": [2, 1, 0.3209, 0.0851, 1, 0.07, 0.6667, 835, 0, 1, 1, 0, 0, 0, 13], "semantic": {"name": "format_callback", "arg_names": ["obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def format_callback(obj):\n has_admin = obj.__class__ in admin_site._registry\n opts = obj._meta\n\n if has_admin:\n admin_url = reverse('%s:%s_%s_change'\n % (admin_site.name,\n opts.app_label,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L80_C8", "label": "has_admin =", "type": "assigned_variable", "loc": [80, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L79_C4", "vector": [14, 2, 0.2837, 0.0035, 2, 0.13, 0.0, 63, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "has_admin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " has_admin = obj.__class__ in admin_site._registry"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L81_C8", "label": "opts =", "type": "assigned_variable", "loc": [81, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L79_C4", "vector": [14, 2, 0.2872, 0.0035, 2, 0.13, 0.5, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = obj._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L83_C8", "label": "if", "type": "if", "loc": [83, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L79_C4", "vector": [4, 2, 0.328, 0.0709, 2, 0.13, 1.0, 0, 2, 0, 0, 0, 0, 0, 13], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if has_admin:\n admin_url = reverse('%s:%s_%s_change'\n % (admin_site.name,\n opts.app_label,\n opts.object_name.lower()),\n None, (quote(obj._get_pk_val()),))\n p = '%s.%s' % (opts.app_label,\n opts.get_delete_permission())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L84_C12", "label": "admin_url = reverse()", "type": "assigned_variable", "loc": [84, 88], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L83_C8", "vector": [14, 3, 0.305, 0.0177, 3, 0.51, 0.0, 616, 3, 3, 0, 0, 109, 10, 4], "semantic": {"name": "admin_url", "arg_names": [], "import_names": [], "rhs_call_name": "reverse", "annotation": ""}, "snippet": " admin_url = reverse('%s:%s_%s_change'\n % (admin_site.name,\n opts.app_label,\n opts.object_name.lower()),\n None, (quote(obj._get_pk_val()),))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L89_C12", "label": "p =", "type": "assigned_variable", "loc": [89, 90], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L83_C8", "vector": [14, 3, 0.3174, 0.0071, 3, 0.51, 0.25, 491, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "p", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " p = '%s.%s' % (opts.app_label,\n opts.get_delete_permission())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L91_C12", "label": "if", "type": "if", "loc": [91, 92], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L83_C8", "vector": [4, 3, 0.3245, 0.0071, 3, 0.51, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not user.has_perm(p):\n perms_needed.add(opts.verbose_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L92_C16", "label": "add()", "type": "expression", "loc": [92, 92], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L91_C12", "vector": [8, 4, 0.3262, 0.0035, 4, 0.12, 0.0, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " perms_needed.add(opts.verbose_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L94_C12", "label": "return", "type": "return", "loc": [94, 97], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L83_C8", "vector": [13, 3, 0.3387, 0.0142, 3, 0.51, 0.75, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u'%s: <a href=\"%s\">%s</a>' %\n (escape(capfirst(opts.verbose_name)),\n admin_url,\n escape(obj)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L101_C12", "label": "return", "type": "return", "loc": [101, 102], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L83_C8", "vector": [13, 3, 0.3599, 0.0071, 3, 0.51, 1.0, 0, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'%s: %s' % (capfirst(opts.verbose_name),\n force_unicode(obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L104_C4", "label": "to_delete = nested()", "type": "assigned_variable", "loc": [104, 104], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "vector": [14, 1, 0.3688, 0.0035, 1, 0.07, 0.8333, 510, 3, 1, 0, 0, 855, 10, 1], "semantic": {"name": "to_delete", "arg_names": [], "import_names": [], "rhs_call_name": "nested", "annotation": ""}, "snippet": " to_delete = collector.nested(format_callback)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L106_C4", "label": "return", "type": "return", "loc": [106, 106], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "vector": [13, 1, 0.3759, 0.0035, 1, 0.07, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return to_delete, perms_needed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "label": "NestedObjects", "type": "class", "loc": [109, 153], "level": 0, "parent": null, "vector": [3, 0, 0.4645, 0.1596, 0, 0.66, 0.7619, 19, 0, 6, 0, 0, 189, 0, 22], "semantic": {"name": "NestedObjects", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class NestedObjects(Collector):\n def __init__(self, *args, **kwargs):\n super(NestedObjects, self).__init__(*args, **kwargs)\n self.edges = {} # {from_instance: [to_instances]}\n\n def add_edge(self, source, target):\n self.edges.setdefault(source, []).append(target)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L110_C4", "label": "__init__", "type": "function", "loc": [110, 112], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "vector": [2, 1, 0.3936, 0.0106, 1, 0.07, 0.0, 555, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, *args, **kwargs):\n super(NestedObjects, self).__init__(*args, **kwargs)\n self.edges = {} # {from_instance: [to_instances]}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L111_C8", "label": "__init__()", "type": "expression", "loc": [111, 111], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L110_C4", "vector": [8, 2, 0.3936, 0.0035, 2, 0.93, 0.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(NestedObjects, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L112_C8", "label": "self.edges =", "type": "assigned_variable", "loc": [112, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L110_C4", "vector": [14, 2, 0.3972, 0.0035, 2, 0.93, 1.0, 911, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "self.edges", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.edges = {} # {from_instance: [to_instances]}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L114_C4", "label": "add_edge", "type": "function", "loc": [114, 115], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "vector": [2, 1, 0.406, 0.0071, 1, 0.07, 0.2, 76, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "add_edge", "arg_names": ["self", "source", "target"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_edge(self, source, target):\n self.edges.setdefault(source, []).append(target)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L115_C8", "label": "append()", "type": "expression", "loc": [115, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L114_C4", "vector": [8, 2, 0.4078, 0.0035, 2, 0.98, 0.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " self.edges.setdefault(source, []).append(target)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L117_C4", "label": "collect", "type": "function", "loc": [117, 123], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "vector": [2, 1, 0.4255, 0.0248, 1, 0.07, 0.4, 34, 0, 4, 1, 0, 0, 0, 5], "semantic": {"name": "collect", "arg_names": ["self", "objs", "source_attr", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def collect(self, objs, source_attr=None, **kwargs):\n for obj in objs:\n if source_attr:\n self.add_edge(getattr(obj, source_attr), obj)\n else:\n self.add_edge(None, obj)\n return super(NestedObjects, self).collect(objs, source_attr=source_attr, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L118_C8", "label": "for obj", "type": "for", "loc": [118, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L117_C4", "vector": [6, 2, 0.4255, 0.0177, 2, 0.1, 0.0, 505, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for obj in objs:\n if source_attr:\n self.add_edge(getattr(obj, source_attr), obj)\n else:\n self.add_edge(None, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L119_C12", "label": "if", "type": "if", "loc": [119, 122], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L118_C8", "vector": [4, 3, 0.4273, 0.0142, 3, 0.6, 0.0, 0, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if source_attr:\n self.add_edge(getattr(obj, source_attr), obj)\n else:\n self.add_edge(None, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L120_C16", "label": "add_edge()", "type": "expression", "loc": [120, 120], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L119_C12", "vector": [8, 4, 0.4255, 0.0035, 4, 0.41, 0.0, 76, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add_edge", "arg_names": [], "import_names": [], "rhs_call_name": "add_edge", "annotation": ""}, "snippet": " self.add_edge(getattr(obj, source_attr), obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L122_C16", "label": "add_edge()", "type": "expression", "loc": [122, 122], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L119_C12", "vector": [8, 4, 0.4326, 0.0035, 4, 0.41, 1.0, 76, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add_edge", "arg_names": [], "import_names": [], "rhs_call_name": "add_edge", "annotation": ""}, "snippet": " self.add_edge(None, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L123_C8", "label": "return", "type": "return", "loc": [123, 123], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L117_C4", "vector": [13, 2, 0.4362, 0.0035, 2, 0.1, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return super(NestedObjects, self).collect(objs, source_attr=source_attr, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L125_C4", "label": "related_objects", "type": "function", "loc": [125, 127], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "vector": [2, 1, 0.4468, 0.0106, 1, 0.07, 0.6, 768, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "related_objects", "arg_names": ["self", "related", "objs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def related_objects(self, related, objs):\n qs = super(NestedObjects, self).related_objects(related, objs)\n return qs.select_related(related.field.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L126_C8", "label": "qs = related_objects()", "type": "assigned_variable", "loc": [126, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L125_C4", "vector": [14, 2, 0.4468, 0.0035, 2, 0.81, 0.0, 251, 3, 2, 0, 0, 768, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "related_objects", "annotation": ""}, "snippet": " qs = super(NestedObjects, self).related_objects(related, objs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L127_C8", "label": "return", "type": "return", "loc": [127, 127], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L125_C4", "vector": [13, 2, 0.4504, 0.0035, 2, 0.81, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return qs.select_related(related.field.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "label": "_nested", "type": "function", "loc": [129, 142], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "vector": [2, 1, 0.4805, 0.0496, 1, 0.07, 0.8, 958, 0, 4, 1, 0, 0, 0, 6], "semantic": {"name": "_nested", "arg_names": ["self", "obj", "seen", "format_callback"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _nested(self, obj, seen, format_callback):\n if obj in seen:\n return []\n seen.add(obj)\n children = []\n for child in self.edges.get(obj, ()):\n children.extend(self._nested(child, seen, format_callback))\n if format_callback:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L130_C8", "label": "if", "type": "if", "loc": [130, 131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "vector": [4, 2, 0.4628, 0.0071, 2, 0.69, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if obj in seen:\n return []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L131_C12", "label": "return", "type": "return", "loc": [131, 131], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L130_C8", "vector": [13, 3, 0.4645, 0.0035, 3, 0.98, 0.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L132_C8", "label": "add()", "type": "expression", "loc": [132, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "vector": [8, 2, 0.4681, 0.0035, 2, 0.69, 0.1667, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " seen.add(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L133_C8", "label": "children =", "type": "assigned_variable", "loc": [133, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "vector": [14, 2, 0.4716, 0.0035, 2, 0.69, 0.3333, 435, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "children", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " children = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L134_C8", "label": "for child", "type": "for", "loc": [134, 135], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "vector": [6, 2, 0.477, 0.0071, 2, 0.69, 0.5, 967, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "child", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for child in self.edges.get(obj, ()):\n children.extend(self._nested(child, seen, format_callback))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L135_C12", "label": "extend()", "type": "expression", "loc": [135, 135], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L134_C8", "vector": [8, 3, 0.4787, 0.0035, 3, 0.07, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " children.extend(self._nested(child, seen, format_callback))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L136_C8", "label": "if", "type": "if", "loc": [136, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "vector": [4, 2, 0.4876, 0.0142, 2, 0.69, 0.6667, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if format_callback:\n ret = [format_callback(obj)]\n else:\n ret = [obj]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L137_C12", "label": "ret =", "type": "assigned_variable", "loc": [137, 137], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L136_C8", "vector": [14, 3, 0.4858, 0.0035, 3, 0.6, 0.0, 501, 0, 0, 0, 0, 0, 5, 1], "semantic": {"name": "ret", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ret = [format_callback(obj)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L139_C12", "label": "ret =", "type": "assigned_variable", "loc": [139, 139], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L136_C8", "vector": [14, 3, 0.4929, 0.0035, 3, 0.6, 1.0, 501, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "ret", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ret = [obj]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L140_C8", "label": "if", "type": "if", "loc": [140, 141], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "vector": [4, 2, 0.4982, 0.0071, 2, 0.69, 0.8333, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if children:\n ret.append(children)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L141_C12", "label": "append()", "type": "expression", "loc": [141, 141], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L140_C8", "vector": [8, 3, 0.5, 0.0035, 3, 0.0, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " ret.append(children)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L142_C8", "label": "return", "type": "return", "loc": [142, 142], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "vector": [13, 2, 0.5035, 0.0035, 2, 0.69, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ret"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L144_C4", "label": "nested", "type": "function", "loc": [144, 153], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "vector": [2, 1, 0.5266, 0.0355, 1, 0.07, 1.0, 855, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "nested", "arg_names": ["self", "format_callback"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def nested(self, format_callback=None):\n \"\"\"\n Return the graph as a nested list.\n\n \"\"\"\n seen = set()\n roots = []\n for root in self.edges.get(None, ()):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L145_C8", "label": "expression", "type": "expression", "loc": [145, 148], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L144_C4", "vector": [8, 2, 0.5195, 0.0142, 2, 0.81, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Return the graph as a nested list.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L149_C8", "label": "seen = set()", "type": "assigned_variable", "loc": [149, 149], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L144_C4", "vector": [14, 2, 0.5284, 0.0035, 2, 0.81, 0.25, 212, 3, 0, 0, 0, 21, 10, 1], "semantic": {"name": "seen", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " seen = set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L150_C8", "label": "roots =", "type": "assigned_variable", "loc": [150, 150], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L144_C4", "vector": [14, 2, 0.5319, 0.0035, 2, 0.81, 0.5, 92, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "roots", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " roots = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L151_C8", "label": "for root", "type": "for", "loc": [151, 152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L144_C4", "vector": [6, 2, 0.5372, 0.0071, 2, 0.81, 0.75, 696, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "root", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for root in self.edges.get(None, ()):\n roots.extend(self._nested(root, seen, format_callback))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L152_C12", "label": "extend()", "type": "expression", "loc": [152, 152], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L151_C8", "vector": [8, 3, 0.539, 0.0035, 3, 0.88, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " roots.extend(self._nested(root, seen, format_callback))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L153_C8", "label": "return", "type": "return", "loc": [153, 153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L144_C4", "vector": [13, 2, 0.5426, 0.0035, 2, 0.81, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return roots"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L156_C0", "label": "model_format_dict", "type": "function", "loc": [156, 173], "level": 0, "parent": null, "vector": [2, 0, 0.5833, 0.0638, 0, 0.66, 0.8095, 23, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "model_format_dict", "arg_names": ["obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def model_format_dict(obj):\n \"\"\"\n Return a `dict` with keys 'verbose_name' and 'verbose_name_plural',\n typically for use with string formatting.\n\n `obj` may be a `Model` instance, `Model` subclass, or `QuerySet` instance.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L157_C4", "label": "expression", "type": "expression", "loc": [157, 163], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L156_C0", "vector": [8, 1, 0.5674, 0.0248, 1, 0.07, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Return a `dict` with keys 'verbose_name' and 'verbose_name_plural',\n typically for use with string formatting.\n\n `obj` may be a `Model` instance, `Model` subclass, or `QuerySet` instance.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L164_C4", "label": "if", "type": "if", "loc": [164, 169], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L156_C0", "vector": [4, 1, 0.5904, 0.0213, 1, 0.07, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(obj, (models.Model, models.base.ModelBase)):\n opts = obj._meta\n elif isinstance(obj, models.query.QuerySet):\n opts = obj.model._meta\n else:\n opts = obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L165_C8", "label": "opts =", "type": "assigned_variable", "loc": [165, 165], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L164_C4", "vector": [14, 2, 0.5851, 0.0035, 2, 0.69, 0.0, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = obj._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L166_C4", "label": "if", "type": "if", "loc": [166, 169], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L164_C4", "vector": [4, 2, 0.594, 0.0142, 2, 0.69, 1.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(obj, models.query.QuerySet):\n opts = obj.model._meta\n else:\n opts = obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L167_C8", "label": "opts =", "type": "assigned_variable", "loc": [167, 167], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L166_C4", "vector": [14, 3, 0.5922, 0.0035, 3, 0.35, 0.0, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = obj.model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L169_C8", "label": "opts =", "type": "assigned_variable", "loc": [169, 169], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L166_C4", "vector": [14, 3, 0.5993, 0.0035, 3, 0.35, 1.0, 631, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L170_C4", "label": "return", "type": "return", "loc": [170, 173], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L156_C0", "vector": [13, 1, 0.6082, 0.0142, 1, 0.07, 1.0, 0, 0, 0, 0, 0, 0, 6, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {\n 'verbose_name': force_unicode(opts.verbose_name),\n 'verbose_name_plural': force_unicode(opts.verbose_name_plural)\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L176_C0", "label": "model_ngettext", "type": "function", "loc": [176, 192], "level": 0, "parent": null, "vector": [2, 0, 0.6525, 0.0603, 0, 0.66, 0.8571, 922, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "model_ngettext", "arg_names": ["obj", "n"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def model_ngettext(obj, n=None):\n \"\"\"\n Return the appropriate `verbose_name` or `verbose_name_plural` value for\n `obj` depending on the count `n`.\n\n `obj` may be a `Model` instance, `Model` subclass, or `QuerySet` instance.\n If `obj` is a `QuerySet` instance, `n` is optional and the length of the\n `QuerySet` is used."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L177_C4", "label": "expression", "type": "expression", "loc": [177, 185], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L176_C0", "vector": [8, 1, 0.6418, 0.0319, 1, 0.84, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Return the appropriate `verbose_name` or `verbose_name_plural` value for\n `obj` depending on the count `n`.\n\n `obj` may be a `Model` instance, `Model` subclass, or `QuerySet` instance.\n If `obj` is a `QuerySet` instance, `n` is optional and the length of the\n `QuerySet` is used.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L186_C4", "label": "if", "type": "if", "loc": [186, 189], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L176_C0", "vector": [4, 1, 0.6649, 0.0142, 1, 0.84, 0.25, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(obj, models.query.QuerySet):\n if n is None:\n n = obj.count()\n obj = obj.model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L187_C8", "label": "if", "type": "if", "loc": [187, 188], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L186_C4", "vector": [4, 2, 0.6649, 0.0071, 2, 0.21, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if n is None:\n n = obj.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L188_C12", "label": "n = count()", "type": "assigned_variable", "loc": [188, 188], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L187_C8", "vector": [14, 3, 0.6667, 0.0035, 3, 0.69, 0.0, 773, 3, 0, 0, 0, 778, 10, 1], "semantic": {"name": "n", "arg_names": [], "import_names": [], "rhs_call_name": "count", "annotation": ""}, "snippet": " n = obj.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L189_C8", "label": "obj =", "type": "assigned_variable", "loc": [189, 189], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L186_C4", "vector": [14, 2, 0.6702, 0.0035, 2, 0.21, 1.0, 505, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " obj = obj.model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L190_C4", "label": "d = model_format_dict()", "type": "assigned_variable", "loc": [190, 190], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L176_C0", "vector": [14, 1, 0.6738, 0.0035, 1, 0.84, 0.5, 355, 3, 1, 0, 0, 23, 10, 1], "semantic": {"name": "d", "arg_names": [], "import_names": [], "rhs_call_name": "model_format_dict", "annotation": ""}, "snippet": " d = model_format_dict(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L191_C4", "label": "singular, plural =", "type": "assigned_variable", "loc": [191, 191], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L176_C0", "vector": [14, 1, 0.6773, 0.0035, 1, 0.84, 0.75, 880, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "singular, plural", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " singular, plural = d[\"verbose_name\"], d[\"verbose_name_plural\"]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L192_C4", "label": "return", "type": "return", "loc": [192, 192], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L176_C0", "vector": [13, 1, 0.6809, 0.0035, 1, 0.84, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ungettext(singular, plural, n or 0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L195_C0", "label": "lookup_field", "type": "function", "loc": [195, 219], "level": 0, "parent": null, "vector": [2, 0, 0.734, 0.0887, 0, 0.66, 0.9048, 514, 0, 3, 1, 0, 0, 0, 10], "semantic": {"name": "lookup_field", "arg_names": ["name", "obj", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def lookup_field(name, obj, model_admin=None):\n opts = obj._meta\n try:\n f = opts.get_field(name)\n except models.FieldDoesNotExist:\n # For non-field values, the value is either a method, property or\n # returned via a callable.\n if callable(name):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L196_C4", "label": "opts =", "type": "assigned_variable", "loc": [196, 196], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L195_C0", "vector": [14, 1, 0.695, 0.0035, 1, 0.95, 0.0, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = obj._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L197_C4", "label": "try", "type": "try", "loc": [197, 218], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L195_C0", "vector": [7, 1, 0.7358, 0.078, 1, 0.95, 0.5, 0, 0, 1, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n f = opts.get_field(name)\n except models.FieldDoesNotExist:\n # For non-field values, the value is either a method, property or\n # returned via a callable.\n if callable(name):\n attr = name\n value = attr(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L198_C8", "label": "f = get_field()", "type": "assigned_variable", "loc": [198, 198], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L197_C4", "vector": [14, 2, 0.7021, 0.0035, 2, 0.42, 0.0, 899, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = opts.get_field(name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L202_C8", "label": "if", "type": "if", "loc": [202, 214], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L197_C4", "vector": [4, 2, 0.7376, 0.0461, 2, 0.42, 0.0, 0, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if callable(name):\n attr = name\n value = attr(obj)\n elif (model_admin is not None and hasattr(model_admin, name) and\n not name == '__str__' and not name == '__unicode__'):\n attr = getattr(model_admin, name)\n value = attr(obj)\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L203_C12", "label": "attr =", "type": "assigned_variable", "loc": [203, 203], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L202_C8", "vector": [14, 3, 0.7199, 0.0035, 3, 0.32, 0.0, 400, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attr = name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L204_C12", "label": "value = attr()", "type": "assigned_variable", "loc": [204, 204], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L202_C8", "vector": [14, 3, 0.7234, 0.0035, 3, 0.32, 0.5, 441, 3, 1, 0, 0, 400, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "attr", "annotation": ""}, "snippet": " value = attr(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L205_C8", "label": "if", "type": "if", "loc": [205, 214], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L202_C8", "vector": [4, 3, 0.7429, 0.0355, 3, 0.32, 1.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif (model_admin is not None and hasattr(model_admin, name) and\n not name == '__str__' and not name == '__unicode__'):\n attr = getattr(model_admin, name)\n value = attr(obj)\n else:\n attr = getattr(obj, name)\n if callable(attr):\n value = attr()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L207_C12", "label": "attr = getattr()", "type": "assigned_variable", "loc": [207, 207], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L205_C8", "vector": [14, 4, 0.734, 0.0035, 4, 0.47, 0.0, 400, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " attr = getattr(model_admin, name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L208_C12", "label": "value = attr()", "type": "assigned_variable", "loc": [208, 208], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L205_C8", "vector": [14, 4, 0.7376, 0.0035, 4, 0.47, 0.3333, 441, 3, 1, 0, 0, 400, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "attr", "annotation": ""}, "snippet": " value = attr(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L210_C12", "label": "attr = getattr()", "type": "assigned_variable", "loc": [210, 210], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L205_C8", "vector": [14, 4, 0.7447, 0.0035, 4, 0.47, 0.6667, 400, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " attr = getattr(obj, name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L211_C12", "label": "if", "type": "if", "loc": [211, 214], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L205_C8", "vector": [4, 4, 0.7535, 0.0142, 4, 0.47, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if callable(attr):\n value = attr()\n else:\n value = attr"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L212_C16", "label": "value = attr()", "type": "assigned_variable", "loc": [212, 212], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L211_C12", "vector": [14, 5, 0.7518, 0.0035, 5, 0.16, 0.0, 441, 3, 0, 0, 0, 400, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "attr", "annotation": ""}, "snippet": " value = attr()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L214_C16", "label": "value =", "type": "assigned_variable", "loc": [214, 214], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L211_C12", "vector": [14, 5, 0.7589, 0.0035, 5, 0.16, 1.0, 441, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " value = attr"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L215_C8", "label": "f =", "type": "assigned_variable", "loc": [215, 215], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L197_C4", "vector": [14, 2, 0.7624, 0.0035, 2, 0.42, 1.0, 899, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " f = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L217_C8", "label": "attr =", "type": "assigned_variable", "loc": [217, 217], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L197_C4", "vector": [14, 2, 0.7695, 0.0035, 2, 0.42, 0.5, 400, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attr = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L218_C8", "label": "value = getattr()", "type": "assigned_variable", "loc": [218, 218], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L197_C4", "vector": [14, 2, 0.773, 0.0035, 2, 0.42, 1.0, 441, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " value = getattr(obj, name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L219_C4", "label": "return", "type": "return", "loc": [219, 219], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L195_C0", "vector": [13, 1, 0.7766, 0.0035, 1, 0.95, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return f, attr, value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L222_C0", "label": "label_for_field", "type": "function", "loc": [222, 260], "level": 0, "parent": null, "vector": [2, 0, 0.8546, 0.1383, 0, 0.66, 0.9524, 777, 0, 4, 1, 0, 0, 0, 14], "semantic": {"name": "label_for_field", "arg_names": ["name", "model", "model_admin", "return_attr"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def label_for_field(name, model, model_admin=None, return_attr=False):\n attr = None\n try:\n field = model._meta.get_field_by_name(name)[0]\n if isinstance(field, RelatedObject):\n label = field.opts.verbose_name\n else:\n label = field.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L223_C4", "label": "attr =", "type": "assigned_variable", "loc": [223, 223], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L222_C0", "vector": [14, 1, 0.7908, 0.0035, 1, 0.36, 0.0, 400, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attr = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L224_C4", "label": "try", "type": "try", "loc": [224, 256], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L222_C0", "vector": [7, 1, 0.8511, 0.117, 1, 0.36, 0.5, 0, 0, 1, 0, 0, 0, 0, 14], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n field = model._meta.get_field_by_name(name)[0]\n if isinstance(field, RelatedObject):\n label = field.opts.verbose_name\n else:\n label = field.verbose_name\n except models.FieldDoesNotExist:\n if name == \"__unicode__\":"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L225_C8", "label": "field =", "type": "assigned_variable", "loc": [225, 225], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L224_C4", "vector": [14, 2, 0.7979, 0.0035, 2, 0.44, 0.0, 480, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field = model._meta.get_field_by_name(name)[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L226_C8", "label": "if", "type": "if", "loc": [226, 229], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L224_C4", "vector": [4, 2, 0.8067, 0.0142, 2, 0.44, 1.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(field, RelatedObject):\n label = field.opts.verbose_name\n else:\n label = field.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L227_C12", "label": "label =", "type": "assigned_variable", "loc": [227, 227], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L226_C8", "vector": [14, 3, 0.805, 0.0035, 3, 0.75, 0.0, 811, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " label = field.opts.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L229_C12", "label": "label =", "type": "assigned_variable", "loc": [229, 229], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L226_C8", "vector": [14, 3, 0.8121, 0.0035, 3, 0.75, 1.0, 811, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " label = field.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L231_C8", "label": "if", "type": "if", "loc": [231, 256], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L224_C4", "vector": [4, 2, 0.8635, 0.0922, 2, 0.44, 0.0, 0, 0, 0, 0, 0, 0, 0, 12], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if name == \"__unicode__\":\n label = force_unicode(model._meta.verbose_name)\n elif name == \"__str__\":\n label = smart_str(model._meta.verbose_name)\n else:\n if callable(name):\n attr = name\n elif model_admin is not None and hasattr(model_admin, name):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L232_C12", "label": "label = force_unicode()", "type": "assigned_variable", "loc": [232, 232], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L231_C8", "vector": [14, 3, 0.8227, 0.0035, 3, 0.9, 0.0, 811, 3, 1, 0, 0, 870, 10, 1], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "force_unicode", "annotation": ""}, "snippet": " label = force_unicode(model._meta.verbose_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L233_C8", "label": "if", "type": "if", "loc": [233, 256], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L231_C8", "vector": [4, 3, 0.867, 0.0851, 3, 0.9, 1.0, 0, 0, 0, 0, 0, 0, 0, 11], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif name == \"__str__\":\n label = smart_str(model._meta.verbose_name)\n else:\n if callable(name):\n attr = name\n elif model_admin is not None and hasattr(model_admin, name):\n attr = getattr(model_admin, name)\n elif hasattr(model, name):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L234_C12", "label": "label = smart_str()", "type": "assigned_variable", "loc": [234, 234], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L233_C8", "vector": [14, 4, 0.8298, 0.0035, 4, 0.98, 0.0, 811, 3, 1, 0, 0, 820, 10, 1], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "smart_str", "annotation": ""}, "snippet": " label = smart_str(model._meta.verbose_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L236_C12", "label": "if", "type": "if", "loc": [236, 246], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L233_C8", "vector": [4, 4, 0.8546, 0.039, 4, 0.98, 0.5, 0, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if callable(name):\n attr = name\n elif model_admin is not None and hasattr(model_admin, name):\n attr = getattr(model_admin, name)\n elif hasattr(model, name):\n attr = getattr(model, name)\n else:\n message = \"Unable to lookup '%s' on %s\" % (name, model._meta.object_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L237_C16", "label": "attr =", "type": "assigned_variable", "loc": [237, 237], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L236_C12", "vector": [14, 5, 0.8404, 0.0035, 5, 0.5, 0.0, 400, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attr = name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L238_C12", "label": "if", "type": "if", "loc": [238, 246], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L236_C12", "vector": [4, 5, 0.8582, 0.0319, 5, 0.5, 1.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif model_admin is not None and hasattr(model_admin, name):\n attr = getattr(model_admin, name)\n elif hasattr(model, name):\n attr = getattr(model, name)\n else:\n message = \"Unable to lookup '%s' on %s\" % (name, model._meta.object_name)\n if model_admin:\n message += \" or %s\" % (model_admin.__name__,)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L239_C16", "label": "attr = getattr()", "type": "assigned_variable", "loc": [239, 239], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L238_C12", "vector": [14, 6, 0.8475, 0.0035, 6, 0.4, 0.0, 400, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " attr = getattr(model_admin, name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L240_C12", "label": "if", "type": "if", "loc": [240, 246], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L238_C12", "vector": [4, 6, 0.8617, 0.0248, 6, 0.4, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif hasattr(model, name):\n attr = getattr(model, name)\n else:\n message = \"Unable to lookup '%s' on %s\" % (name, model._meta.object_name)\n if model_admin:\n message += \" or %s\" % (model_admin.__name__,)\n raise AttributeError(message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L241_C16", "label": "attr = getattr()", "type": "assigned_variable", "loc": [241, 241], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L240_C12", "vector": [14, 7, 0.8546, 0.0035, 7, 0.76, 0.0, 400, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " attr = getattr(model, name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L243_C16", "label": "message =", "type": "assigned_variable", "loc": [243, 243], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L240_C12", "vector": [14, 7, 0.8617, 0.0035, 7, 0.76, 0.5, 635, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " message = \"Unable to lookup '%s' on %s\" % (name, model._meta.object_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L244_C16", "label": "if", "type": "if", "loc": [244, 245], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L240_C12", "vector": [4, 7, 0.867, 0.0071, 7, 0.76, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if model_admin:\n message += \" or %s\" % (model_admin.__name__,)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L248_C12", "label": "if", "type": "if", "loc": [248, 256], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L233_C8", "vector": [4, 4, 0.8936, 0.0319, 4, 0.98, 1.0, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(attr, \"short_description\"):\n label = attr.short_description\n elif callable(attr):\n if attr.__name__ == \"<lambda>\":\n label = \"--\"\n else:\n label = pretty_name(attr.__name__)\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L249_C16", "label": "label =", "type": "assigned_variable", "loc": [249, 249], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L248_C12", "vector": [14, 5, 0.883, 0.0035, 5, 0.79, 0.0, 811, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " label = attr.short_description"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L250_C12", "label": "if", "type": "if", "loc": [250, 256], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L248_C12", "vector": [4, 5, 0.8972, 0.0248, 5, 0.79, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif callable(attr):\n if attr.__name__ == \"<lambda>\":\n label = \"--\"\n else:\n label = pretty_name(attr.__name__)\n else:\n label = pretty_name(name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L251_C16", "label": "if", "type": "if", "loc": [251, 254], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L250_C12", "vector": [4, 6, 0.8954, 0.0142, 6, 0.13, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if attr.__name__ == \"<lambda>\":\n label = \"--\"\n else:\n label = pretty_name(attr.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L252_C20", "label": "label =", "type": "assigned_variable", "loc": [252, 252], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L251_C16", "vector": [14, 7, 0.8936, 0.0035, 7, 0.17, 0.0, 811, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " label = \"--\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L254_C20", "label": "label = pretty_name()", "type": "assigned_variable", "loc": [254, 254], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L251_C16", "vector": [14, 7, 0.9007, 0.0035, 7, 0.17, 1.0, 811, 3, 1, 0, 0, 689, 10, 1], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "pretty_name", "annotation": ""}, "snippet": " label = pretty_name(attr.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L256_C16", "label": "label = pretty_name()", "type": "assigned_variable", "loc": [256, 256], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L250_C12", "vector": [14, 6, 0.9078, 0.0035, 6, 0.13, 1.0, 811, 3, 1, 0, 0, 689, 10, 1], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "pretty_name", "annotation": ""}, "snippet": " label = pretty_name(name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L257_C4", "label": "if", "type": "if", "loc": [257, 260], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L222_C0", "vector": [4, 1, 0.9167, 0.0142, 1, 0.36, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if return_attr:\n return (label, attr)\n else:\n return label"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L258_C8", "label": "return", "type": "return", "loc": [258, 258], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L257_C4", "vector": [13, 2, 0.9149, 0.0035, 2, 0.82, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return (label, attr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L260_C8", "label": "return", "type": "return", "loc": [260, 260], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L257_C4", "vector": [13, 2, 0.922, 0.0035, 2, 0.82, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return label"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L263_C0", "label": "display_for_field", "type": "function", "loc": [263, 282], "level": 0, "parent": null, "vector": [2, 0, 0.9663, 0.0709, 0, 0.66, 1.0, 12, 0, 2, 1, 0, 0, 0, 13], "semantic": {"name": "display_for_field", "arg_names": ["value", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def display_for_field(value, field):\n from django.contrib.admin.templatetags.admin_list import _boolean_icon\n from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE\n\n if field.flatchoices:\n return dict(field.flatchoices).get(value, EMPTY_CHANGELIST_VALUE)\n # NullBooleanField needs special-case null-handling, so it comes\n # before the general null test."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L264_C4", "label": "from django.contrib.admin.templatetags.admin_list import _boolean_icon", "type": "import", "loc": [264, 264], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L263_C0", "vector": [1, 1, 0.9362, 0.0035, 1, 0.62, 0.0, 261, 0, 1, 0, 0, 261, 0, 0], "semantic": {"name": "django.contrib.admin.templatetags.admin_list", "arg_names": [], "import_names": ["_boolean_icon"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.templatetags.admin_list import _boolean_icon"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L265_C4", "label": "from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE", "type": "import", "loc": [265, 265], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L263_C0", "vector": [1, 1, 0.9397, 0.0035, 1, 0.62, 0.5, 696, 0, 1, 0, 0, 696, 0, 0], "semantic": {"name": "django.contrib.admin.views.main", "arg_names": [], "import_names": ["EMPTY_CHANGELIST_VALUE"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L267_C4", "label": "if", "type": "if", "loc": [267, 282], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L263_C0", "vector": [4, 1, 0.9734, 0.0567, 1, 0.62, 1.0, 0, 7, 0, 0, 0, 0, 0, 13], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.flatchoices:\n return dict(field.flatchoices).get(value, EMPTY_CHANGELIST_VALUE)\n # NullBooleanField needs special-case null-handling, so it comes\n # before the general null test.\n elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):\n return _boolean_icon(value)\n elif value is None:\n return EMPTY_CHANGELIST_VALUE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L268_C8", "label": "return", "type": "return", "loc": [268, 268], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L267_C4", "vector": [13, 2, 0.9504, 0.0035, 2, 0.64, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return dict(field.flatchoices).get(value, EMPTY_CHANGELIST_VALUE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L271_C4", "label": "if", "type": "if", "loc": [271, 282], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L267_C4", "vector": [4, 2, 0.9805, 0.0426, 2, 0.64, 1.0, 0, 0, 0, 0, 0, 0, 0, 11], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):\n return _boolean_icon(value)\n elif value is None:\n return EMPTY_CHANGELIST_VALUE\n elif isinstance(field, models.DateField) or isinstance(field, models.TimeField):\n return formats.localize(value)\n elif isinstance(field, models.DecimalField):\n return formats.number_format(value, field.decimal_places)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L272_C8", "label": "return", "type": "return", "loc": [272, 272], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L271_C4", "vector": [13, 3, 0.9645, 0.0035, 3, 0.34, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _boolean_icon(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L273_C4", "label": "if", "type": "if", "loc": [273, 282], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L271_C4", "vector": [4, 3, 0.984, 0.0355, 3, 0.34, 1.0, 0, 0, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif value is None:\n return EMPTY_CHANGELIST_VALUE\n elif isinstance(field, models.DateField) or isinstance(field, models.TimeField):\n return formats.localize(value)\n elif isinstance(field, models.DecimalField):\n return formats.number_format(value, field.decimal_places)\n elif isinstance(field, models.FloatField):\n return formats.number_format(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L274_C8", "label": "return", "type": "return", "loc": [274, 274], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L273_C4", "vector": [13, 4, 0.9716, 0.0035, 4, 0.98, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return EMPTY_CHANGELIST_VALUE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L275_C4", "label": "if", "type": "if", "loc": [275, 282], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L273_C4", "vector": [4, 4, 0.9876, 0.0284, 4, 0.98, 1.0, 0, 0, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(field, models.DateField) or isinstance(field, models.TimeField):\n return formats.localize(value)\n elif isinstance(field, models.DecimalField):\n return formats.number_format(value, field.decimal_places)\n elif isinstance(field, models.FloatField):\n return formats.number_format(value)\n else:\n return smart_unicode(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L276_C8", "label": "return", "type": "return", "loc": [276, 276], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L275_C4", "vector": [13, 5, 0.9787, 0.0035, 5, 0.89, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return formats.localize(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L277_C4", "label": "if", "type": "if", "loc": [277, 282], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L275_C4", "vector": [4, 5, 0.9911, 0.0213, 5, 0.89, 1.0, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(field, models.DecimalField):\n return formats.number_format(value, field.decimal_places)\n elif isinstance(field, models.FloatField):\n return formats.number_format(value)\n else:\n return smart_unicode(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L278_C8", "label": "return", "type": "return", "loc": [278, 278], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L277_C4", "vector": [13, 6, 0.9858, 0.0035, 6, 0.14, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return formats.number_format(value, field.decimal_places)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L279_C4", "label": "if", "type": "if", "loc": [279, 282], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L277_C4", "vector": [4, 6, 0.9947, 0.0142, 6, 0.14, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(field, models.FloatField):\n return formats.number_format(value)\n else:\n return smart_unicode(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L280_C8", "label": "return", "type": "return", "loc": [280, 280], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L279_C4", "vector": [13, 7, 0.9929, 0.0035, 7, 0.45, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return formats.number_format(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L282_C8", "label": "return", "type": "return", "loc": [282, 282], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L279_C4", "vector": [13, 7, 1.0, 0.0035, 7, 0.45, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return smart_unicode(value)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L43_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L44_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L44_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L45_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L44_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L47_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L43_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L49_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L57_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L59_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L59_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L60_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L59_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L62_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L75_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L76_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L77_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L79_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L81_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L83_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L83_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L84_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L83_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L89_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L83_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L91_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L91_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L92_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L83_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L94_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L83_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L101_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L104_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L106_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L110_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L110_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L111_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L110_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L112_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L114_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L114_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L115_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L117_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L118_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L119_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L119_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L120_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L119_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L122_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L123_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L125_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L125_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L125_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L127_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L130_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L130_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L131_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L132_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L134_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L134_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L135_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L136_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L137_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L136_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L139_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L140_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L141_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L129_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L142_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:ClassDef_L109_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L144_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L145_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L149_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L150_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L151_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:For_L151_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L152_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L153_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L156_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L157_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L156_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L164_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L164_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L165_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L164_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L166_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L166_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L167_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L166_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L169_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L156_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L170_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L176_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Expr_L177_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L176_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L186_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L186_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L187_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L187_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L188_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L186_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L189_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L176_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L190_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L176_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L191_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L176_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L192_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L195_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L196_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L195_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L197_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L197_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L198_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L197_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L202_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L202_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L203_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L202_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L204_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L202_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L205_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L205_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L207_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L205_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L208_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L205_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L210_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L205_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L211_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L211_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L212_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L211_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L214_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L197_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L215_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L197_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L217_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L197_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L218_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L195_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L219_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L222_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L223_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L222_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L224_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L224_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L225_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L224_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L226_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L226_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L227_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L226_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L229_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:Try_L224_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L231_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L231_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L232_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L231_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L233_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L233_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L234_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L233_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L236_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L236_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L237_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L236_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L238_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L238_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L239_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L238_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L240_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L240_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L241_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L240_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L243_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L240_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L244_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L233_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L248_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L248_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L249_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L248_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L250_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L250_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L251_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L251_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L252_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L251_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L254_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L250_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Assign_L256_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L222_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L257_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L257_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L258_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L257_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L260_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L263_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L264_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L263_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:ImportFrom_L265_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:FunctionDef_L263_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L267_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L267_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L268_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L267_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L271_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L271_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L272_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L271_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L273_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L274_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L275_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L275_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L276_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L275_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L277_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L277_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L278_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L277_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L279_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L280_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98647:If_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98647:Return_L282_C8"}] |
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.forms.models import (BaseModelForm, BaseModelFormSet, fields_for_model,
_get_foreign_key)
from django.contrib.admin.options import flatten_fieldsets, BaseModelAdmin
from django.contrib.admin.options import HORIZONTAL, VERTICAL
__all__ = ['validate']
def validate(cls, model):
"""
Does basic ModelAdmin option validation. Calls custom validation
classmethod in the end if it is provided in cls. The signature of the
custom validation classmethod should be: def validate(cls, model).
"""
# Before we can introspect models, they need to be fully loaded so that
# inter-relations are set up correctly. We force that here.
models.get_apps()
opts = model._meta
validate_base(cls, model)
# list_display
if hasattr(cls, 'list_display'):
check_isseq(cls, 'list_display', cls.list_display)
for idx, field in enumerate(cls.list_display):
if not callable(field):
if not hasattr(cls, field):
if not hasattr(model, field):
try:
opts.get_field(field)
except models.FieldDoesNotExist:
raise ImproperlyConfigured("%s.list_display[%d], %r is not a callable or an attribute of %r or found in the model %r."
% (cls.__name__, idx, field, cls.__name__, model._meta.object_name))
else:
# getattr(model, field) could be an X_RelatedObjectsDescriptor
f = fetch_attr(cls, model, opts, "list_display[%d]" % idx, field)
if isinstance(f, models.ManyToManyField):
raise ImproperlyConfigured("'%s.list_display[%d]', '%s' is a ManyToManyField which is not supported."
% (cls.__name__, idx, field))
# list_display_links
if hasattr(cls, 'list_display_links'):
check_isseq(cls, 'list_display_links', cls.list_display_links)
for idx, field in enumerate(cls.list_display_links):
fetch_attr(cls, model, opts, 'list_display_links[%d]' % idx, field)
if field not in cls.list_display:
raise ImproperlyConfigured("'%s.list_display_links[%d]'"
"refers to '%s' which is not defined in 'list_display'."
% (cls.__name__, idx, field))
# list_filter
if hasattr(cls, 'list_filter'):
check_isseq(cls, 'list_filter', cls.list_filter)
for idx, field in enumerate(cls.list_filter):
get_field(cls, model, opts, 'list_filter[%d]' % idx, field)
# list_per_page = 100
if hasattr(cls, 'list_per_page') and not isinstance(cls.list_per_page, int):
raise ImproperlyConfigured("'%s.list_per_page' should be a integer."
% cls.__name__)
# list_editable
if hasattr(cls, 'list_editable') and cls.list_editable:
check_isseq(cls, 'list_editable', cls.list_editable)
for idx, field_name in enumerate(cls.list_editable):
try:
field = opts.get_field_by_name(field_name)[0]
except models.FieldDoesNotExist:
raise ImproperlyConfigured("'%s.list_editable[%d]' refers to a "
"field, '%s', not defined on %s."
% (cls.__name__, idx, field_name, model.__name__))
if field_name not in cls.list_display:
raise ImproperlyConfigured("'%s.list_editable[%d]' refers to "
"'%s' which is not defined in 'list_display'."
% (cls.__name__, idx, field_name))
if field_name in cls.list_display_links:
raise ImproperlyConfigured("'%s' cannot be in both '%s.list_editable'"
" and '%s.list_display_links'"
% (field_name, cls.__name__, cls.__name__))
if not cls.list_display_links and cls.list_display[0] in cls.list_editable:
raise ImproperlyConfigured("'%s.list_editable[%d]' refers to"
" the first field in list_display, '%s', which can't be"
" used unless list_display_links is set."
% (cls.__name__, idx, cls.list_display[0]))
if not field.editable:
raise ImproperlyConfigured("'%s.list_editable[%d]' refers to a "
"field, '%s', which isn't editable through the admin."
% (cls.__name__, idx, field_name))
# search_fields = ()
if hasattr(cls, 'search_fields'):
check_isseq(cls, 'search_fields', cls.search_fields)
# date_hierarchy = None
if cls.date_hierarchy:
f = get_field(cls, model, opts, 'date_hierarchy', cls.date_hierarchy)
if not isinstance(f, (models.DateField, models.DateTimeField)):
raise ImproperlyConfigured("'%s.date_hierarchy is "
"neither an instance of DateField nor DateTimeField."
% cls.__name__)
# ordering = None
if cls.ordering:
check_isseq(cls, 'ordering', cls.ordering)
for idx, field in enumerate(cls.ordering):
if field == '?' and len(cls.ordering) != 1:
raise ImproperlyConfigured("'%s.ordering' has the random "
"ordering marker '?', but contains other fields as "
"well. Please either remove '?' or the other fields."
% cls.__name__)
if field == '?':
continue
if field.startswith('-'):
field = field[1:]
# Skip ordering in the format field1__field2 (FIXME: checking
# this format would be nice, but it's a little fiddly).
if '__' in field:
continue
get_field(cls, model, opts, 'ordering[%d]' % idx, field)
if hasattr(cls, "readonly_fields"):
check_isseq(cls, "readonly_fields", cls.readonly_fields)
for idx, field in enumerate(cls.readonly_fields):
if not callable(field):
if not hasattr(cls, field):
if not hasattr(model, field):
try:
opts.get_field(field)
except models.FieldDoesNotExist:
raise ImproperlyConfigured("%s.readonly_fields[%d], %r is not a callable or an attribute of %r or found in the model %r."
% (cls.__name__, idx, field, cls.__name__, model._meta.object_name))
# list_select_related = False
# save_as = False
# save_on_top = False
for attr in ('list_select_related', 'save_as', 'save_on_top'):
if not isinstance(getattr(cls, attr), bool):
raise ImproperlyConfigured("'%s.%s' should be a boolean."
% (cls.__name__, attr))
# inlines = []
if hasattr(cls, 'inlines'):
check_isseq(cls, 'inlines', cls.inlines)
for idx, inline in enumerate(cls.inlines):
if not issubclass(inline, BaseModelAdmin):
raise ImproperlyConfigured("'%s.inlines[%d]' does not inherit "
"from BaseModelAdmin." % (cls.__name__, idx))
if not inline.model:
raise ImproperlyConfigured("'model' is a required attribute "
"of '%s.inlines[%d]'." % (cls.__name__, idx))
if not issubclass(inline.model, models.Model):
raise ImproperlyConfigured("'%s.inlines[%d].model' does not "
"inherit from models.Model." % (cls.__name__, idx))
validate_base(inline, inline.model)
validate_inline(inline, cls, model)
def validate_inline(cls, parent, parent_model):
# model is already verified to exist and be a Model
if cls.fk_name: # default value is None
f = get_field(cls, cls.model, cls.model._meta, 'fk_name', cls.fk_name)
if not isinstance(f, models.ForeignKey):
raise ImproperlyConfigured("'%s.fk_name is not an instance of "
"models.ForeignKey." % cls.__name__)
fk = _get_foreign_key(parent_model, cls.model, fk_name=cls.fk_name, can_fail=True)
# extra = 3
if not isinstance(cls.extra, int):
raise ImproperlyConfigured("'%s.extra' should be a integer."
% cls.__name__)
# max_num = None
max_num = getattr(cls, 'max_num', None)
if max_num is not None and not isinstance(max_num, int):
raise ImproperlyConfigured("'%s.max_num' should be an integer or None (default)."
% cls.__name__)
# formset
if hasattr(cls, 'formset') and not issubclass(cls.formset, BaseModelFormSet):
raise ImproperlyConfigured("'%s.formset' does not inherit from "
"BaseModelFormSet." % cls.__name__)
# exclude
if hasattr(cls, 'exclude') and cls.exclude:
if fk and fk.name in cls.exclude:
raise ImproperlyConfigured("%s cannot exclude the field "
"'%s' - this is the foreign key to the parent model "
"%s." % (cls.__name__, fk.name, parent_model.__name__))
def validate_base(cls, model):
opts = model._meta
# raw_id_fields
if hasattr(cls, 'raw_id_fields'):
check_isseq(cls, 'raw_id_fields', cls.raw_id_fields)
for idx, field in enumerate(cls.raw_id_fields):
f = get_field(cls, model, opts, 'raw_id_fields', field)
if not isinstance(f, (models.ForeignKey, models.ManyToManyField)):
raise ImproperlyConfigured("'%s.raw_id_fields[%d]', '%s' must "
"be either a ForeignKey or ManyToManyField."
% (cls.__name__, idx, field))
# fields
if cls.fields: # default value is None
check_isseq(cls, 'fields', cls.fields)
for field in cls.fields:
if field in cls.readonly_fields:
# Stuff can be put in fields that isn't actually a model field
# if it's in readonly_fields, readonly_fields will handle the
# validation of such things.
continue
check_formfield(cls, model, opts, 'fields', field)
try:
f = opts.get_field(field)
except models.FieldDoesNotExist:
# If we can't find a field on the model that matches,
# it could be an extra field on the form.
continue
if isinstance(f, models.ManyToManyField) and not f.rel.through._meta.auto_created:
raise ImproperlyConfigured("'%s.fields' can't include the ManyToManyField "
"field '%s' because '%s' manually specifies "
"a 'through' model." % (cls.__name__, field, field))
if cls.fieldsets:
raise ImproperlyConfigured('Both fieldsets and fields are specified in %s.' % cls.__name__)
if len(cls.fields) > len(set(cls.fields)):
raise ImproperlyConfigured('There are duplicate field(s) in %s.fields' % cls.__name__)
# fieldsets
if cls.fieldsets: # default value is None
check_isseq(cls, 'fieldsets', cls.fieldsets)
for idx, fieldset in enumerate(cls.fieldsets):
check_isseq(cls, 'fieldsets[%d]' % idx, fieldset)
if len(fieldset) != 2:
raise ImproperlyConfigured("'%s.fieldsets[%d]' does not "
"have exactly two elements." % (cls.__name__, idx))
check_isdict(cls, 'fieldsets[%d][1]' % idx, fieldset[1])
if 'fields' not in fieldset[1]:
raise ImproperlyConfigured("'fields' key is required in "
"%s.fieldsets[%d][1] field options dict."
% (cls.__name__, idx))
for fields in fieldset[1]['fields']:
# The entry in fields might be a tuple. If it is a standalone
# field, make it into a tuple to make processing easier.
if type(fields) != tuple:
fields = (fields,)
for field in fields:
if field in cls.readonly_fields:
# Stuff can be put in fields that isn't actually a
# model field if it's in readonly_fields,
# readonly_fields will handle the validation of such
# things.
continue
check_formfield(cls, model, opts, "fieldsets[%d][1]['fields']" % idx, field)
try:
f = opts.get_field(field)
if isinstance(f, models.ManyToManyField) and not f.rel.through._meta.auto_created:
raise ImproperlyConfigured("'%s.fieldsets[%d][1]['fields']' "
"can't include the ManyToManyField field '%s' because "
"'%s' manually specifies a 'through' model." % (
cls.__name__, idx, field, field))
except models.FieldDoesNotExist:
# If we can't find a field on the model that matches,
# it could be an extra field on the form.
pass
flattened_fieldsets = flatten_fieldsets(cls.fieldsets)
if len(flattened_fieldsets) > len(set(flattened_fieldsets)):
raise ImproperlyConfigured('There are duplicate field(s) in %s.fieldsets' % cls.__name__)
# exclude
if cls.exclude: # default value is None
check_isseq(cls, 'exclude', cls.exclude)
for field in cls.exclude:
check_formfield(cls, model, opts, 'exclude', field)
try:
f = opts.get_field(field)
except models.FieldDoesNotExist:
# If we can't find a field on the model that matches,
# it could be an extra field on the form.
continue
if len(cls.exclude) > len(set(cls.exclude)):
raise ImproperlyConfigured('There are duplicate field(s) in %s.exclude' % cls.__name__)
# form
if hasattr(cls, 'form') and not issubclass(cls.form, BaseModelForm):
raise ImproperlyConfigured("%s.form does not inherit from "
"BaseModelForm." % cls.__name__)
# filter_vertical
if hasattr(cls, 'filter_vertical'):
check_isseq(cls, 'filter_vertical', cls.filter_vertical)
for idx, field in enumerate(cls.filter_vertical):
f = get_field(cls, model, opts, 'filter_vertical', field)
if not isinstance(f, models.ManyToManyField):
raise ImproperlyConfigured("'%s.filter_vertical[%d]' must be "
"a ManyToManyField." % (cls.__name__, idx))
# filter_horizontal
if hasattr(cls, 'filter_horizontal'):
check_isseq(cls, 'filter_horizontal', cls.filter_horizontal)
for idx, field in enumerate(cls.filter_horizontal):
f = get_field(cls, model, opts, 'filter_horizontal', field)
if not isinstance(f, models.ManyToManyField):
raise ImproperlyConfigured("'%s.filter_horizontal[%d]' must be "
"a ManyToManyField." % (cls.__name__, idx))
# radio_fields
if hasattr(cls, 'radio_fields'):
check_isdict(cls, 'radio_fields', cls.radio_fields)
for field, val in cls.radio_fields.items():
f = get_field(cls, model, opts, 'radio_fields', field)
if not (isinstance(f, models.ForeignKey) or f.choices):
raise ImproperlyConfigured("'%s.radio_fields['%s']' "
"is neither an instance of ForeignKey nor does "
"have choices set." % (cls.__name__, field))
if not val in (HORIZONTAL, VERTICAL):
raise ImproperlyConfigured("'%s.radio_fields['%s']' "
"is neither admin.HORIZONTAL nor admin.VERTICAL."
% (cls.__name__, field))
# prepopulated_fields
if hasattr(cls, 'prepopulated_fields'):
check_isdict(cls, 'prepopulated_fields', cls.prepopulated_fields)
for field, val in cls.prepopulated_fields.items():
f = get_field(cls, model, opts, 'prepopulated_fields', field)
if isinstance(f, (models.DateTimeField, models.ForeignKey,
models.ManyToManyField)):
raise ImproperlyConfigured("'%s.prepopulated_fields['%s']' "
"is either a DateTimeField, ForeignKey or "
"ManyToManyField. This isn't allowed."
% (cls.__name__, field))
check_isseq(cls, "prepopulated_fields['%s']" % field, val)
for idx, f in enumerate(val):
get_field(cls, model, opts, "prepopulated_fields['%s'][%d]" % (field, idx), f)
def check_isseq(cls, label, obj):
if not isinstance(obj, (list, tuple)):
raise ImproperlyConfigured("'%s.%s' must be a list or tuple." % (cls.__name__, label))
def check_isdict(cls, label, obj):
if not isinstance(obj, dict):
raise ImproperlyConfigured("'%s.%s' must be a dictionary." % (cls.__name__, label))
def get_field(cls, model, opts, label, field):
try:
return opts.get_field(field)
except models.FieldDoesNotExist:
raise ImproperlyConfigured("'%s.%s' refers to field '%s' that is missing from model '%s'."
% (cls.__name__, label, field, model.__name__))
def check_formfield(cls, model, opts, label, field):
if getattr(cls.form, 'base_fields', None):
try:
cls.form.base_fields[field]
except KeyError:
raise ImproperlyConfigured("'%s.%s' refers to field '%s' that "
"is missing from the form." % (cls.__name__, label, field))
else:
fields = fields_for_model(model)
try:
fields[field]
except KeyError:
raise ImproperlyConfigured("'%s.%s' refers to field '%s' that "
"is missing from the form." % (cls.__name__, label, field))
def fetch_attr(cls, model, opts, label, field):
try:
return opts.get_field(field)
except models.FieldDoesNotExist:
pass
try:
return getattr(model, field)
except AttributeError:
raise ImproperlyConfigured("'%s.%s' refers to '%s' that is neither a field, method or property of model '%s'."
% (cls.__name__, label, field, model.__name__))
| ajibawa-2023/Python-Code-Large/train/row_98648 | 169 | 378 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98648:ImportFrom_L1_C0", "label": "from django.core.exceptions import ImproperlyConfigured", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0026, 0.0026, 0, 0.66, 0.0, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["ImproperlyConfigured"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import ImproperlyConfigured"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:ImportFrom_L2_C0", "label": "from django.db import models", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0053, 0.0026, 0, 0.66, 0.0769, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:ImportFrom_L3_C0", "label": "from django.forms.models import BaseModelForm, BaseModelFormSet, fields_for_model\u2026", "type": "import", "loc": [3, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0093, 0.0053, 0, 0.66, 0.1538, 625, 0, 4, 0, 0, 625, 0, 0], "semantic": {"name": "django.forms.models", "arg_names": [], "import_names": ["BaseModelForm", "BaseModelFormSet", "fields_for_model", "_get_foreign_key"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.forms.models import (BaseModelForm, BaseModelFormSet, fields_for_model,\n _get_foreign_key)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:ImportFrom_L5_C0", "label": "from django.contrib.admin.options import flatten_fieldsets, BaseModelAdmin", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0132, 0.0026, 0, 0.66, 0.2308, 84, 0, 2, 0, 0, 84, 0, 0], "semantic": {"name": "django.contrib.admin.options", "arg_names": [], "import_names": ["flatten_fieldsets", "BaseModelAdmin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.options import flatten_fieldsets, BaseModelAdmin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:ImportFrom_L6_C0", "label": "from django.contrib.admin.options import HORIZONTAL, VERTICAL", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0159, 0.0026, 0, 0.66, 0.3077, 84, 0, 2, 0, 0, 84, 0, 0], "semantic": {"name": "django.contrib.admin.options", "arg_names": [], "import_names": ["HORIZONTAL", "VERTICAL"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.options import HORIZONTAL, VERTICAL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L9_C0", "label": "__all__ =", "type": "assigned_variable", "loc": [9, 9], "level": 0, "parent": null, "vector": [14, 0, 0.0238, 0.0026, 0, 0.66, 0.3846, 272, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "__all__", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "__all__ = ['validate']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "label": "validate", "type": "function", "loc": [11, 158], "level": 0, "parent": null, "vector": [2, 0, 0.2235, 0.3915, 0, 0.66, 0.4615, 628, 0, 2, 0, 0, 0, 0, 66], "semantic": {"name": "validate", "arg_names": ["cls", "model"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def validate(cls, model):\n \"\"\"\n Does basic ModelAdmin option validation. Calls custom validation\n classmethod in the end if it is provided in cls. The signature of the\n custom validation classmethod should be: def validate(cls, model).\n \"\"\"\n # Before we can introspect models, they need to be fully loaded so that\n # inter-relations are set up correctly. We force that here."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L12_C4", "label": "expression", "type": "expression", "loc": [12, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [8, 1, 0.037, 0.0132, 1, 0.55, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Does basic ModelAdmin option validation. Calls custom validation\n classmethod in the end if it is provided in cls. The signature of the\n custom validation classmethod should be: def validate(cls, model).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L19_C4", "label": "get_apps()", "type": "expression", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [8, 1, 0.0503, 0.0026, 1, 0.55, 0.0714, 221, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "get_apps", "arg_names": [], "import_names": [], "rhs_call_name": "get_apps", "annotation": ""}, "snippet": " models.get_apps()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L21_C4", "label": "opts =", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [14, 1, 0.0556, 0.0026, 1, 0.55, 0.1429, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L22_C4", "label": "validate_base()", "type": "expression", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [8, 1, 0.0582, 0.0026, 1, 0.55, 0.2143, 75, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "validate_base", "arg_names": [], "import_names": [], "rhs_call_name": "validate_base", "annotation": ""}, "snippet": " validate_base(cls, model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L25_C4", "label": "if", "type": "if", "loc": [25, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [4, 1, 0.0873, 0.045, 1, 0.55, 0.2857, 0, 3, 0, 0, 0, 0, 0, 11], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'list_display'):\n check_isseq(cls, 'list_display', cls.list_display)\n for idx, field in enumerate(cls.list_display):\n if not callable(field):\n if not hasattr(cls, field):\n if not hasattr(model, field):\n try:\n opts.get_field(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L26_C8", "label": "check_isseq()", "type": "expression", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L25_C4", "vector": [8, 2, 0.0688, 0.0026, 2, 0.62, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'list_display', cls.list_display)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L27_C8", "label": "for idx, field", "type": "for", "loc": [27, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L25_C4", "vector": [6, 2, 0.0899, 0.0397, 2, 0.62, 1.0, 226, 3, 0, 0, 0, 0, 0, 9], "semantic": {"name": "idx, field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for idx, field in enumerate(cls.list_display):\n if not callable(field):\n if not hasattr(cls, field):\n if not hasattr(model, field):\n try:\n opts.get_field(field)\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"%s.list_display[%d], %r is not a callable or an attribute of %r or found in the model %r.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L28_C12", "label": "if", "type": "if", "loc": [28, 41], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L27_C8", "vector": [4, 3, 0.0913, 0.037, 3, 0.23, 0.0, 0, 0, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not callable(field):\n if not hasattr(cls, field):\n if not hasattr(model, field):\n try:\n opts.get_field(field)\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"%s.list_display[%d], %r is not a callable or an attribute of %r or found in the model %r.\"\n % (cls.__name__, idx, field, cls.__name__, model._meta.object_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L29_C16", "label": "if", "type": "if", "loc": [29, 41], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L28_C12", "vector": [4, 4, 0.0926, 0.0344, 4, 0.6, 0.0, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(cls, field):\n if not hasattr(model, field):\n try:\n opts.get_field(field)\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"%s.list_display[%d], %r is not a callable or an attribute of %r or found in the model %r.\"\n % (cls.__name__, idx, field, cls.__name__, model._meta.object_name))\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L30_C20", "label": "if", "type": "if", "loc": [30, 41], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L29_C16", "vector": [4, 5, 0.0939, 0.0317, 5, 0.22, 0.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(model, field):\n try:\n opts.get_field(field)\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"%s.list_display[%d], %r is not a callable or an attribute of %r or found in the model %r.\"\n % (cls.__name__, idx, field, cls.__name__, model._meta.object_name))\n else:\n # getattr(model, field) could be an X_RelatedObjectsDescriptor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L31_C24", "label": "try", "type": "try", "loc": [31, 35], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L30_C20", "vector": [7, 6, 0.0873, 0.0132, 6, 0.33, 0.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n opts.get_field(field)\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"%s.list_display[%d], %r is not a callable or an attribute of %r or found in the model %r.\"\n % (cls.__name__, idx, field, cls.__name__, model._meta.object_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L32_C28", "label": "get_field()", "type": "expression", "loc": [32, 32], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L31_C24", "vector": [8, 7, 0.0847, 0.0026, 7, 0.25, 0.0, 389, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "get_field", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " opts.get_field(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L38_C24", "label": "f = fetch_attr()", "type": "assigned_variable", "loc": [38, 38], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L30_C20", "vector": [14, 6, 0.1005, 0.0026, 6, 0.33, 0.5, 899, 3, 5, 0, 0, 963, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "fetch_attr", "annotation": ""}, "snippet": " f = fetch_attr(cls, model, opts, \"list_display[%d]\" % idx, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L39_C24", "label": "if", "type": "if", "loc": [39, 41], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L30_C20", "vector": [4, 6, 0.1058, 0.0079, 6, 0.33, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f, models.ManyToManyField):\n raise ImproperlyConfigured(\"'%s.list_display[%d]', '%s' is a ManyToManyField which is not supported.\"\n % (cls.__name__, idx, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L44_C4", "label": "if", "type": "if", "loc": [44, 51], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [4, 1, 0.1257, 0.0212, 1, 0.55, 0.3571, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'list_display_links'):\n check_isseq(cls, 'list_display_links', cls.list_display_links)\n for idx, field in enumerate(cls.list_display_links):\n fetch_attr(cls, model, opts, 'list_display_links[%d]' % idx, field)\n if field not in cls.list_display:\n raise ImproperlyConfigured(\"'%s.list_display_links[%d]'\"\n \"refers to '%s' which is not defined in 'list_display'.\"\n % (cls.__name__, idx, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L45_C8", "label": "check_isseq()", "type": "expression", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L44_C4", "vector": [8, 2, 0.119, 0.0026, 2, 0.01, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'list_display_links', cls.list_display_links)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L46_C8", "label": "for idx, field", "type": "for", "loc": [46, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L44_C4", "vector": [6, 2, 0.1283, 0.0159, 2, 0.01, 1.0, 226, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "idx, field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for idx, field in enumerate(cls.list_display_links):\n fetch_attr(cls, model, opts, 'list_display_links[%d]' % idx, field)\n if field not in cls.list_display:\n raise ImproperlyConfigured(\"'%s.list_display_links[%d]'\"\n \"refers to '%s' which is not defined in 'list_display'.\"\n % (cls.__name__, idx, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L47_C12", "label": "fetch_attr()", "type": "expression", "loc": [47, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L46_C8", "vector": [8, 3, 0.1243, 0.0026, 3, 0.14, 0.0, 963, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "fetch_attr", "arg_names": [], "import_names": [], "rhs_call_name": "fetch_attr", "annotation": ""}, "snippet": " fetch_attr(cls, model, opts, 'list_display_links[%d]' % idx, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L48_C12", "label": "if", "type": "if", "loc": [48, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L46_C8", "vector": [4, 3, 0.131, 0.0106, 3, 0.14, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field not in cls.list_display:\n raise ImproperlyConfigured(\"'%s.list_display_links[%d]'\"\n \"refers to '%s' which is not defined in 'list_display'.\"\n % (cls.__name__, idx, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L54_C4", "label": "if", "type": "if", "loc": [54, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [4, 1, 0.1468, 0.0106, 1, 0.55, 0.4286, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'list_filter'):\n check_isseq(cls, 'list_filter', cls.list_filter)\n for idx, field in enumerate(cls.list_filter):\n get_field(cls, model, opts, 'list_filter[%d]' % idx, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L55_C8", "label": "check_isseq()", "type": "expression", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L54_C4", "vector": [8, 2, 0.1455, 0.0026, 2, 0.71, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'list_filter', cls.list_filter)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L56_C8", "label": "for idx, field", "type": "for", "loc": [56, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L54_C4", "vector": [6, 2, 0.1495, 0.0053, 2, 0.71, 1.0, 226, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "idx, field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for idx, field in enumerate(cls.list_filter):\n get_field(cls, model, opts, 'list_filter[%d]' % idx, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L57_C12", "label": "get_field()", "type": "expression", "loc": [57, 57], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L56_C8", "vector": [8, 3, 0.1508, 0.0026, 3, 0.25, 0.0, 389, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "get_field", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " get_field(cls, model, opts, 'list_filter[%d]' % idx, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L60_C4", "label": "if", "type": "if", "loc": [60, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [4, 1, 0.1614, 0.0079, 1, 0.55, 0.5, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'list_per_page') and not isinstance(cls.list_per_page, int):\n raise ImproperlyConfigured(\"'%s.list_per_page' should be a integer.\"\n % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L65_C4", "label": "if", "type": "if", "loc": [65, 90], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [4, 1, 0.205, 0.0688, 1, 0.55, 0.5714, 0, 0, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'list_editable') and cls.list_editable:\n check_isseq(cls, 'list_editable', cls.list_editable)\n for idx, field_name in enumerate(cls.list_editable):\n try:\n field = opts.get_field_by_name(field_name)[0]\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"'%s.list_editable[%d]' refers to a \"\n \"field, '%s', not defined on %s.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L66_C8", "label": "check_isseq()", "type": "expression", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L65_C4", "vector": [8, 2, 0.1746, 0.0026, 2, 0.86, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'list_editable', cls.list_editable)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L67_C8", "label": "for idx, field_name", "type": "for", "loc": [67, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L65_C4", "vector": [6, 2, 0.2077, 0.0635, 2, 0.86, 1.0, 873, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "idx, field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for idx, field_name in enumerate(cls.list_editable):\n try:\n field = opts.get_field_by_name(field_name)[0]\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"'%s.list_editable[%d]' refers to a \"\n \"field, '%s', not defined on %s.\"\n % (cls.__name__, idx, field_name, model.__name__))\n if field_name not in cls.list_display:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L68_C12", "label": "try", "type": "try", "loc": [68, 73], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L67_C8", "vector": [7, 3, 0.1865, 0.0159, 3, 0.73, 0.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n field = opts.get_field_by_name(field_name)[0]\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"'%s.list_editable[%d]' refers to a \"\n \"field, '%s', not defined on %s.\"\n % (cls.__name__, idx, field_name, model.__name__))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L69_C16", "label": "field =", "type": "assigned_variable", "loc": [69, 69], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L68_C12", "vector": [14, 4, 0.1825, 0.0026, 4, 0.72, 0.0, 480, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field = opts.get_field_by_name(field_name)[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L74_C12", "label": "if", "type": "if", "loc": [74, 77], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L67_C8", "vector": [4, 3, 0.1997, 0.0106, 3, 0.73, 0.25, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_name not in cls.list_display:\n raise ImproperlyConfigured(\"'%s.list_editable[%d]' refers to \"\n \"'%s' which is not defined in 'list_display'.\"\n % (cls.__name__, idx, field_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L78_C12", "label": "if", "type": "if", "loc": [78, 81], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L67_C8", "vector": [4, 3, 0.2103, 0.0106, 3, 0.73, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_name in cls.list_display_links:\n raise ImproperlyConfigured(\"'%s' cannot be in both '%s.list_editable'\"\n \" and '%s.list_display_links'\"\n % (field_name, cls.__name__, cls.__name__))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L82_C12", "label": "if", "type": "if", "loc": [82, 86], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L67_C8", "vector": [4, 3, 0.2222, 0.0132, 3, 0.73, 0.75, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not cls.list_display_links and cls.list_display[0] in cls.list_editable:\n raise ImproperlyConfigured(\"'%s.list_editable[%d]' refers to\"\n \" the first field in list_display, '%s', which can't be\"\n \" used unless list_display_links is set.\"\n % (cls.__name__, idx, cls.list_display[0]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L87_C12", "label": "if", "type": "if", "loc": [87, 90], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L67_C8", "vector": [4, 3, 0.2341, 0.0106, 3, 0.73, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not field.editable:\n raise ImproperlyConfigured(\"'%s.list_editable[%d]' refers to a \"\n \"field, '%s', which isn't editable through the admin.\"\n % (cls.__name__, idx, field_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L93_C4", "label": "if", "type": "if", "loc": [93, 94], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [4, 1, 0.2474, 0.0053, 1, 0.55, 0.6429, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'search_fields'):\n check_isseq(cls, 'search_fields', cls.search_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L94_C8", "label": "check_isseq()", "type": "expression", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L93_C4", "vector": [8, 2, 0.2487, 0.0026, 2, 0.51, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'search_fields', cls.search_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L97_C4", "label": "if", "type": "if", "loc": [97, 102], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [4, 1, 0.2632, 0.0159, 1, 0.55, 0.7143, 0, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cls.date_hierarchy:\n f = get_field(cls, model, opts, 'date_hierarchy', cls.date_hierarchy)\n if not isinstance(f, (models.DateField, models.DateTimeField)):\n raise ImproperlyConfigured(\"'%s.date_hierarchy is \"\n \"neither an instance of DateField nor DateTimeField.\"\n % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L98_C8", "label": "f = get_field()", "type": "assigned_variable", "loc": [98, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L97_C4", "vector": [14, 2, 0.2593, 0.0026, 2, 0.83, 0.0, 899, 3, 5, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = get_field(cls, model, opts, 'date_hierarchy', cls.date_hierarchy)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L99_C8", "label": "if", "type": "if", "loc": [99, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L97_C4", "vector": [4, 2, 0.2659, 0.0106, 2, 0.83, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(f, (models.DateField, models.DateTimeField)):\n raise ImproperlyConfigured(\"'%s.date_hierarchy is \"\n \"neither an instance of DateField nor DateTimeField.\"\n % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L105_C4", "label": "if", "type": "if", "loc": [105, 121], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [4, 1, 0.2989, 0.045, 1, 0.55, 0.7857, 0, 7, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cls.ordering:\n check_isseq(cls, 'ordering', cls.ordering)\n for idx, field in enumerate(cls.ordering):\n if field == '?' and len(cls.ordering) != 1:\n raise ImproperlyConfigured(\"'%s.ordering' has the random \"\n \"ordering marker '?', but contains other fields as \"\n \"well. Please either remove '?' or the other fields.\"\n % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L106_C8", "label": "check_isseq()", "type": "expression", "loc": [106, 106], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L105_C4", "vector": [8, 2, 0.2804, 0.0026, 2, 0.87, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'ordering', cls.ordering)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L107_C8", "label": "for idx, field", "type": "for", "loc": [107, 121], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L105_C4", "vector": [6, 2, 0.3016, 0.0397, 2, 0.87, 1.0, 226, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "idx, field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for idx, field in enumerate(cls.ordering):\n if field == '?' and len(cls.ordering) != 1:\n raise ImproperlyConfigured(\"'%s.ordering' has the random \"\n \"ordering marker '?', but contains other fields as \"\n \"well. Please either remove '?' or the other fields.\"\n % cls.__name__)\n if field == '?':\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L108_C12", "label": "if", "type": "if", "loc": [108, 112], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L107_C8", "vector": [4, 3, 0.291, 0.0132, 3, 0.11, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field == '?' and len(cls.ordering) != 1:\n raise ImproperlyConfigured(\"'%s.ordering' has the random \"\n \"ordering marker '?', but contains other fields as \"\n \"well. Please either remove '?' or the other fields.\"\n % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L113_C12", "label": "if", "type": "if", "loc": [113, 114], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L107_C8", "vector": [4, 3, 0.3003, 0.0053, 3, 0.11, 0.25, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field == '?':\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L115_C12", "label": "if", "type": "if", "loc": [115, 116], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L107_C8", "vector": [4, 3, 0.3056, 0.0053, 3, 0.11, 0.5, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.startswith('-'):\n field = field[1:]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L116_C16", "label": "field =", "type": "assigned_variable", "loc": [116, 116], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L115_C12", "vector": [14, 4, 0.3069, 0.0026, 4, 0.93, 0.0, 480, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field = field[1:]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L119_C12", "label": "if", "type": "if", "loc": [119, 120], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L107_C8", "vector": [4, 3, 0.3161, 0.0053, 3, 0.11, 0.75, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if '__' in field:\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L121_C12", "label": "get_field()", "type": "expression", "loc": [121, 121], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L107_C8", "vector": [8, 3, 0.3201, 0.0026, 3, 0.11, 1.0, 389, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "get_field", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " get_field(cls, model, opts, 'ordering[%d]' % idx, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L123_C4", "label": "if", "type": "if", "loc": [123, 133], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [4, 1, 0.3386, 0.0291, 1, 0.55, 0.8571, 0, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, \"readonly_fields\"):\n check_isseq(cls, \"readonly_fields\", cls.readonly_fields)\n for idx, field in enumerate(cls.readonly_fields):\n if not callable(field):\n if not hasattr(cls, field):\n if not hasattr(model, field):\n try:\n opts.get_field(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L124_C8", "label": "check_isseq()", "type": "expression", "loc": [124, 124], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L123_C4", "vector": [8, 2, 0.328, 0.0026, 2, 0.92, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, \"readonly_fields\", cls.readonly_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L125_C8", "label": "for idx, field", "type": "for", "loc": [125, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L123_C4", "vector": [6, 2, 0.3413, 0.0238, 2, 0.92, 1.0, 226, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "idx, field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for idx, field in enumerate(cls.readonly_fields):\n if not callable(field):\n if not hasattr(cls, field):\n if not hasattr(model, field):\n try:\n opts.get_field(field)\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"%s.readonly_fields[%d], %r is not a callable or an attribute of %r or found in the model %r.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L126_C12", "label": "if", "type": "if", "loc": [126, 133], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L125_C8", "vector": [4, 3, 0.3426, 0.0212, 3, 0.25, 0.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not callable(field):\n if not hasattr(cls, field):\n if not hasattr(model, field):\n try:\n opts.get_field(field)\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"%s.readonly_fields[%d], %r is not a callable or an attribute of %r or found in the model %r.\"\n % (cls.__name__, idx, field, cls.__name__, model._meta.object_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L127_C16", "label": "if", "type": "if", "loc": [127, 133], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L126_C12", "vector": [4, 4, 0.3439, 0.0185, 4, 0.09, 0.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(cls, field):\n if not hasattr(model, field):\n try:\n opts.get_field(field)\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"%s.readonly_fields[%d], %r is not a callable or an attribute of %r or found in the model %r.\"\n % (cls.__name__, idx, field, cls.__name__, model._meta.object_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L128_C20", "label": "if", "type": "if", "loc": [128, 133], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L127_C16", "vector": [4, 5, 0.3452, 0.0159, 5, 0.34, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(model, field):\n try:\n opts.get_field(field)\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"%s.readonly_fields[%d], %r is not a callable or an attribute of %r or found in the model %r.\"\n % (cls.__name__, idx, field, cls.__name__, model._meta.object_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L129_C24", "label": "try", "type": "try", "loc": [129, 133], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L128_C20", "vector": [7, 6, 0.3466, 0.0132, 6, 0.25, 0.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n opts.get_field(field)\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"%s.readonly_fields[%d], %r is not a callable or an attribute of %r or found in the model %r.\"\n % (cls.__name__, idx, field, cls.__name__, model._meta.object_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L130_C28", "label": "get_field()", "type": "expression", "loc": [130, 130], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L129_C24", "vector": [8, 7, 0.3439, 0.0026, 7, 0.27, 0.0, 389, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "get_field", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " opts.get_field(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L138_C4", "label": "for attr", "type": "for", "loc": [138, 141], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [6, 1, 0.369, 0.0106, 1, 0.55, 0.9286, 400, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "attr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for attr in ('list_select_related', 'save_as', 'save_on_top'):\n if not isinstance(getattr(cls, attr), bool):\n raise ImproperlyConfigured(\"'%s.%s' should be a boolean.\"\n % (cls.__name__, attr))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L139_C8", "label": "if", "type": "if", "loc": [139, 141], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L138_C4", "vector": [4, 2, 0.3704, 0.0079, 2, 0.34, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(getattr(cls, attr), bool):\n raise ImproperlyConfigured(\"'%s.%s' should be a boolean.\"\n % (cls.__name__, attr))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L145_C4", "label": "if", "type": "if", "loc": [145, 158], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "vector": [4, 1, 0.4008, 0.037, 1, 0.55, 1.0, 0, 3, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'inlines'):\n check_isseq(cls, 'inlines', cls.inlines)\n for idx, inline in enumerate(cls.inlines):\n if not issubclass(inline, BaseModelAdmin):\n raise ImproperlyConfigured(\"'%s.inlines[%d]' does not inherit \"\n \"from BaseModelAdmin.\" % (cls.__name__, idx))\n if not inline.model:\n raise ImproperlyConfigured(\"'model' is a required attribute \""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L146_C8", "label": "check_isseq()", "type": "expression", "loc": [146, 146], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L145_C4", "vector": [8, 2, 0.3862, 0.0026, 2, 0.64, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'inlines', cls.inlines)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L147_C8", "label": "for idx, inline", "type": "for", "loc": [147, 158], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L145_C4", "vector": [6, 2, 0.4034, 0.0317, 2, 0.64, 1.0, 984, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "idx, inline", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for idx, inline in enumerate(cls.inlines):\n if not issubclass(inline, BaseModelAdmin):\n raise ImproperlyConfigured(\"'%s.inlines[%d]' does not inherit \"\n \"from BaseModelAdmin.\" % (cls.__name__, idx))\n if not inline.model:\n raise ImproperlyConfigured(\"'model' is a required attribute \"\n \"of '%s.inlines[%d]'.\" % (cls.__name__, idx))\n if not issubclass(inline.model, models.Model):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L148_C12", "label": "if", "type": "if", "loc": [148, 150], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L147_C8", "vector": [4, 3, 0.3942, 0.0079, 3, 0.41, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not issubclass(inline, BaseModelAdmin):\n raise ImproperlyConfigured(\"'%s.inlines[%d]' does not inherit \"\n \"from BaseModelAdmin.\" % (cls.__name__, idx))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L151_C12", "label": "if", "type": "if", "loc": [151, 153], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L147_C8", "vector": [4, 3, 0.4021, 0.0079, 3, 0.41, 0.25, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not inline.model:\n raise ImproperlyConfigured(\"'model' is a required attribute \"\n \"of '%s.inlines[%d]'.\" % (cls.__name__, idx))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L154_C12", "label": "if", "type": "if", "loc": [154, 156], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L147_C8", "vector": [4, 3, 0.4101, 0.0079, 3, 0.41, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not issubclass(inline.model, models.Model):\n raise ImproperlyConfigured(\"'%s.inlines[%d].model' does not \"\n \"inherit from models.Model.\" % (cls.__name__, idx))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L157_C12", "label": "validate_base()", "type": "expression", "loc": [157, 157], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L147_C8", "vector": [8, 3, 0.4153, 0.0026, 3, 0.41, 0.75, 75, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "validate_base", "arg_names": [], "import_names": [], "rhs_call_name": "validate_base", "annotation": ""}, "snippet": " validate_base(inline, inline.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L158_C12", "label": "validate_inline()", "type": "expression", "loc": [158, 158], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L147_C8", "vector": [8, 3, 0.418, 0.0026, 3, 0.41, 1.0, 225, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "validate_inline", "arg_names": [], "import_names": [], "rhs_call_name": "validate_inline", "annotation": ""}, "snippet": " validate_inline(inline, cls, model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "label": "validate_inline", "type": "function", "loc": [160, 192], "level": 0, "parent": null, "vector": [2, 0, 0.4656, 0.0873, 0, 0.66, 0.5385, 225, 0, 3, 0, 0, 0, 0, 14], "semantic": {"name": "validate_inline", "arg_names": ["cls", "parent", "parent_model"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def validate_inline(cls, parent, parent_model):\n\n # model is already verified to exist and be a Model\n if cls.fk_name: # default value is None\n f = get_field(cls, cls.model, cls.model._meta, 'fk_name', cls.fk_name)\n if not isinstance(f, models.ForeignKey):\n raise ImproperlyConfigured(\"'%s.fk_name is not an instance of \"\n \"models.ForeignKey.\" % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L163_C4", "label": "if", "type": "if", "loc": [163, 167], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "vector": [4, 1, 0.4365, 0.0132, 1, 0.15, 0.0, 0, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cls.fk_name: # default value is None\n f = get_field(cls, cls.model, cls.model._meta, 'fk_name', cls.fk_name)\n if not isinstance(f, models.ForeignKey):\n raise ImproperlyConfigured(\"'%s.fk_name is not an instance of \"\n \"models.ForeignKey.\" % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L164_C8", "label": "f = get_field()", "type": "assigned_variable", "loc": [164, 164], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L163_C4", "vector": [14, 2, 0.4339, 0.0026, 2, 0.13, 0.0, 899, 3, 5, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = get_field(cls, cls.model, cls.model._meta, 'fk_name', cls.fk_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L165_C8", "label": "if", "type": "if", "loc": [165, 167], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L163_C4", "vector": [4, 2, 0.4392, 0.0079, 2, 0.13, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(f, models.ForeignKey):\n raise ImproperlyConfigured(\"'%s.fk_name is not an instance of \"\n \"models.ForeignKey.\" % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L169_C4", "label": "fk = _get_foreign_key()", "type": "assigned_variable", "loc": [169, 169], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "vector": [14, 1, 0.4471, 0.0026, 1, 0.15, 0.1667, 714, 3, 4, 0, 0, 425, 10, 1], "semantic": {"name": "fk", "arg_names": [], "import_names": [], "rhs_call_name": "_get_foreign_key", "annotation": ""}, "snippet": " fk = _get_foreign_key(parent_model, cls.model, fk_name=cls.fk_name, can_fail=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L172_C4", "label": "if", "type": "if", "loc": [172, 174], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "vector": [4, 1, 0.4577, 0.0079, 1, 0.15, 0.3333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(cls.extra, int):\n raise ImproperlyConfigured(\"'%s.extra' should be a integer.\"\n % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L177_C4", "label": "max_num = getattr()", "type": "assigned_variable", "loc": [177, 177], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "vector": [14, 1, 0.4683, 0.0026, 1, 0.15, 0.5, 607, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "max_num", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " max_num = getattr(cls, 'max_num', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L178_C4", "label": "if", "type": "if", "loc": [178, 180], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "vector": [4, 1, 0.4735, 0.0079, 1, 0.15, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if max_num is not None and not isinstance(max_num, int):\n raise ImproperlyConfigured(\"'%s.max_num' should be an integer or None (default).\"\n % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L183_C4", "label": "if", "type": "if", "loc": [183, 185], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "vector": [4, 1, 0.4868, 0.0079, 1, 0.15, 0.8333, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'formset') and not issubclass(cls.formset, BaseModelFormSet):\n raise ImproperlyConfigured(\"'%s.formset' does not inherit from \"\n \"BaseModelFormSet.\" % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L188_C4", "label": "if", "type": "if", "loc": [188, 192], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "vector": [4, 1, 0.5026, 0.0132, 1, 0.15, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'exclude') and cls.exclude:\n if fk and fk.name in cls.exclude:\n raise ImproperlyConfigured(\"%s cannot exclude the field \"\n \"'%s' - this is the foreign key to the parent model \"\n \"%s.\" % (cls.__name__, fk.name, parent_model.__name__))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L189_C8", "label": "if", "type": "if", "loc": [189, 192], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L188_C4", "vector": [4, 2, 0.504, 0.0106, 2, 0.96, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if fk and fk.name in cls.exclude:\n raise ImproperlyConfigured(\"%s cannot exclude the field \"\n \"'%s' - this is the foreign key to the parent model \"\n \"%s.\" % (cls.__name__, fk.name, parent_model.__name__))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "label": "validate_base", "type": "function", "loc": [194, 337], "level": 0, "parent": null, "vector": [2, 0, 0.7024, 0.381, 0, 0.66, 0.6154, 75, 0, 2, 0, 0, 0, 0, 71], "semantic": {"name": "validate_base", "arg_names": ["cls", "model"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def validate_base(cls, model):\n opts = model._meta\n\n # raw_id_fields\n if hasattr(cls, 'raw_id_fields'):\n check_isseq(cls, 'raw_id_fields', cls.raw_id_fields)\n for idx, field in enumerate(cls.raw_id_fields):\n f = get_field(cls, model, opts, 'raw_id_fields', field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L195_C4", "label": "opts =", "type": "assigned_variable", "loc": [195, 195], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "vector": [14, 1, 0.5159, 0.0026, 1, 0.24, 0.0, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L198_C4", "label": "if", "type": "if", "loc": [198, 205], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "vector": [4, 1, 0.5331, 0.0212, 1, 0.24, 0.1111, 0, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'raw_id_fields'):\n check_isseq(cls, 'raw_id_fields', cls.raw_id_fields)\n for idx, field in enumerate(cls.raw_id_fields):\n f = get_field(cls, model, opts, 'raw_id_fields', field)\n if not isinstance(f, (models.ForeignKey, models.ManyToManyField)):\n raise ImproperlyConfigured(\"'%s.raw_id_fields[%d]', '%s' must \"\n \"be either a ForeignKey or ManyToManyField.\"\n % (cls.__name__, idx, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L199_C8", "label": "check_isseq()", "type": "expression", "loc": [199, 199], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L198_C4", "vector": [8, 2, 0.5265, 0.0026, 2, 0.58, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'raw_id_fields', cls.raw_id_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L200_C8", "label": "for idx, field", "type": "for", "loc": [200, 205], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L198_C4", "vector": [6, 2, 0.5357, 0.0159, 2, 0.58, 1.0, 226, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "idx, field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for idx, field in enumerate(cls.raw_id_fields):\n f = get_field(cls, model, opts, 'raw_id_fields', field)\n if not isinstance(f, (models.ForeignKey, models.ManyToManyField)):\n raise ImproperlyConfigured(\"'%s.raw_id_fields[%d]', '%s' must \"\n \"be either a ForeignKey or ManyToManyField.\"\n % (cls.__name__, idx, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L201_C12", "label": "f = get_field()", "type": "assigned_variable", "loc": [201, 201], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L200_C8", "vector": [14, 3, 0.5317, 0.0026, 3, 0.74, 0.0, 899, 3, 5, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = get_field(cls, model, opts, 'raw_id_fields', field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L202_C12", "label": "if", "type": "if", "loc": [202, 205], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L200_C8", "vector": [4, 3, 0.5384, 0.0106, 3, 0.74, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(f, (models.ForeignKey, models.ManyToManyField)):\n raise ImproperlyConfigured(\"'%s.raw_id_fields[%d]', '%s' must \"\n \"be either a ForeignKey or ManyToManyField.\"\n % (cls.__name__, idx, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L208_C4", "label": "if", "type": "if", "loc": [208, 230], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "vector": [4, 1, 0.5794, 0.0608, 1, 0.24, 0.2222, 0, 7, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cls.fields: # default value is None\n check_isseq(cls, 'fields', cls.fields)\n for field in cls.fields:\n if field in cls.readonly_fields:\n # Stuff can be put in fields that isn't actually a model field\n # if it's in readonly_fields, readonly_fields will handle the\n # validation of such things.\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L209_C8", "label": "check_isseq()", "type": "expression", "loc": [209, 209], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L208_C4", "vector": [8, 2, 0.5529, 0.0026, 2, 0.73, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'fields', cls.fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L210_C8", "label": "for field", "type": "for", "loc": [210, 226], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L208_C4", "vector": [6, 2, 0.5767, 0.045, 2, 0.73, 0.3333, 480, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field in cls.fields:\n if field in cls.readonly_fields:\n # Stuff can be put in fields that isn't actually a model field\n # if it's in readonly_fields, readonly_fields will handle the\n # validation of such things.\n continue\n check_formfield(cls, model, opts, 'fields', field)\n try:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L211_C12", "label": "if", "type": "if", "loc": [211, 215], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L210_C8", "vector": [4, 3, 0.5635, 0.0132, 3, 0.39, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field in cls.readonly_fields:\n # Stuff can be put in fields that isn't actually a model field\n # if it's in readonly_fields, readonly_fields will handle the\n # validation of such things.\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L216_C12", "label": "check_formfield()", "type": "expression", "loc": [216, 216], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L210_C8", "vector": [8, 3, 0.5714, 0.0026, 3, 0.39, 0.3333, 879, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "check_formfield", "arg_names": [], "import_names": [], "rhs_call_name": "check_formfield", "annotation": ""}, "snippet": " check_formfield(cls, model, opts, 'fields', field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L217_C12", "label": "try", "type": "try", "loc": [217, 222], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L210_C8", "vector": [7, 3, 0.5807, 0.0159, 3, 0.39, 0.6667, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n f = opts.get_field(field)\n except models.FieldDoesNotExist:\n # If we can't find a field on the model that matches,\n # it could be an extra field on the form.\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L218_C16", "label": "f = get_field()", "type": "assigned_variable", "loc": [218, 218], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L217_C12", "vector": [14, 4, 0.5767, 0.0026, 4, 0.93, 0.0, 899, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = opts.get_field(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L223_C12", "label": "if", "type": "if", "loc": [223, 226], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L210_C8", "vector": [4, 3, 0.5939, 0.0106, 3, 0.39, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f, models.ManyToManyField) and not f.rel.through._meta.auto_created:\n raise ImproperlyConfigured(\"'%s.fields' can't include the ManyToManyField \"\n \"field '%s' because '%s' manually specifies \"\n \"a 'through' model.\" % (cls.__name__, field, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L227_C8", "label": "if", "type": "if", "loc": [227, 228], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L208_C4", "vector": [4, 2, 0.6019, 0.0053, 2, 0.73, 0.6667, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cls.fieldsets:\n raise ImproperlyConfigured('Both fieldsets and fields are specified in %s.' % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L229_C8", "label": "if", "type": "if", "loc": [229, 230], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L208_C4", "vector": [4, 2, 0.6071, 0.0053, 2, 0.73, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(cls.fields) > len(set(cls.fields)):\n raise ImproperlyConfigured('There are duplicate field(s) in %s.fields' % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L233_C4", "label": "if", "type": "if", "loc": [233, 271], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "vector": [4, 1, 0.6667, 0.1032, 1, 0.24, 0.3333, 0, 7, 0, 0, 0, 0, 0, 17], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cls.fieldsets: # default value is None\n check_isseq(cls, 'fieldsets', cls.fieldsets)\n for idx, fieldset in enumerate(cls.fieldsets):\n check_isseq(cls, 'fieldsets[%d]' % idx, fieldset)\n if len(fieldset) != 2:\n raise ImproperlyConfigured(\"'%s.fieldsets[%d]' does not \"\n \"have exactly two elements.\" % (cls.__name__, idx))\n check_isdict(cls, 'fieldsets[%d][1]' % idx, fieldset[1])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L234_C8", "label": "check_isseq()", "type": "expression", "loc": [234, 234], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L233_C4", "vector": [8, 2, 0.619, 0.0026, 2, 0.94, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'fieldsets', cls.fieldsets)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L235_C8", "label": "for idx, fieldset", "type": "for", "loc": [235, 268], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L233_C4", "vector": [6, 2, 0.6653, 0.0899, 2, 0.94, 0.3333, 784, 3, 0, 0, 0, 0, 0, 11], "semantic": {"name": "idx, fieldset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for idx, fieldset in enumerate(cls.fieldsets):\n check_isseq(cls, 'fieldsets[%d]' % idx, fieldset)\n if len(fieldset) != 2:\n raise ImproperlyConfigured(\"'%s.fieldsets[%d]' does not \"\n \"have exactly two elements.\" % (cls.__name__, idx))\n check_isdict(cls, 'fieldsets[%d][1]' % idx, fieldset[1])\n if 'fields' not in fieldset[1]:\n raise ImproperlyConfigured(\"'fields' key is required in \""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L236_C12", "label": "check_isseq()", "type": "expression", "loc": [236, 236], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L235_C8", "vector": [8, 3, 0.6243, 0.0026, 3, 0.59, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'fieldsets[%d]' % idx, fieldset)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L237_C12", "label": "if", "type": "if", "loc": [237, 239], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L235_C8", "vector": [4, 3, 0.6296, 0.0079, 3, 0.59, 0.25, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(fieldset) != 2:\n raise ImproperlyConfigured(\"'%s.fieldsets[%d]' does not \"\n \"have exactly two elements.\" % (cls.__name__, idx))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L240_C12", "label": "check_isdict()", "type": "expression", "loc": [240, 240], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L235_C8", "vector": [8, 3, 0.6349, 0.0026, 3, 0.59, 0.5, 806, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isdict", "arg_names": [], "import_names": [], "rhs_call_name": "check_isdict", "annotation": ""}, "snippet": " check_isdict(cls, 'fieldsets[%d][1]' % idx, fieldset[1])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L241_C12", "label": "if", "type": "if", "loc": [241, 244], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L235_C8", "vector": [4, 3, 0.6415, 0.0106, 3, 0.59, 0.75, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'fields' not in fieldset[1]:\n raise ImproperlyConfigured(\"'fields' key is required in \"\n \"%s.fieldsets[%d][1] field options dict.\"\n % (cls.__name__, idx))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L245_C12", "label": "for fields", "type": "for", "loc": [245, 268], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L235_C8", "vector": [6, 3, 0.6786, 0.0635, 3, 0.59, 1.0, 358, 6, 0, 0, 0, 0, 0, 5], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for fields in fieldset[1]['fields']:\n # The entry in fields might be a tuple. If it is a standalone\n # field, make it into a tuple to make processing easier.\n if type(fields) != tuple:\n fields = (fields,)\n for field in fields:\n if field in cls.readonly_fields:\n # Stuff can be put in fields that isn't actually a"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L248_C16", "label": "if", "type": "if", "loc": [248, 249], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L245_C12", "vector": [4, 4, 0.6574, 0.0053, 4, 0.56, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if type(fields) != tuple:\n fields = (fields,)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L249_C20", "label": "fields =", "type": "assigned_variable", "loc": [249, 249], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L248_C16", "vector": [14, 5, 0.6587, 0.0026, 5, 0.64, 0.0, 358, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fields = (fields,)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L250_C16", "label": "for field", "type": "for", "loc": [250, 268], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L245_C12", "vector": [6, 4, 0.6852, 0.0503, 4, 0.56, 1.0, 480, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field in fields:\n if field in cls.readonly_fields:\n # Stuff can be put in fields that isn't actually a\n # model field if it's in readonly_fields,\n # readonly_fields will handle the validation of such\n # things.\n continue\n check_formfield(cls, model, opts, \"fieldsets[%d][1]['fields']\" % idx, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L251_C20", "label": "if", "type": "if", "loc": [251, 256], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L250_C16", "vector": [4, 5, 0.6706, 0.0159, 5, 0.13, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field in cls.readonly_fields:\n # Stuff can be put in fields that isn't actually a\n # model field if it's in readonly_fields,\n # readonly_fields will handle the validation of such\n # things.\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L257_C20", "label": "check_formfield()", "type": "expression", "loc": [257, 257], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L250_C16", "vector": [8, 5, 0.6799, 0.0026, 5, 0.13, 0.5, 879, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "check_formfield", "arg_names": [], "import_names": [], "rhs_call_name": "check_formfield", "annotation": ""}, "snippet": " check_formfield(cls, model, opts, \"fieldsets[%d][1]['fields']\" % idx, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L258_C20", "label": "try", "type": "try", "loc": [258, 268], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L250_C16", "vector": [7, 5, 0.6958, 0.0291, 5, 0.13, 1.0, 0, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n f = opts.get_field(field)\n if isinstance(f, models.ManyToManyField) and not f.rel.through._meta.auto_created:\n raise ImproperlyConfigured(\"'%s.fieldsets[%d][1]['fields']' \"\n \"can't include the ManyToManyField field '%s' because \"\n \"'%s' manually specifies a 'through' model.\" % (\n cls.__name__, idx, field, field))\n except models.FieldDoesNotExist:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L259_C24", "label": "f = get_field()", "type": "assigned_variable", "loc": [259, 259], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L258_C20", "vector": [14, 6, 0.6852, 0.0026, 6, 0.32, 0.0, 899, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = opts.get_field(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L260_C24", "label": "if", "type": "if", "loc": [260, 264], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L258_C20", "vector": [4, 6, 0.6931, 0.0132, 6, 0.32, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f, models.ManyToManyField) and not f.rel.through._meta.auto_created:\n raise ImproperlyConfigured(\"'%s.fieldsets[%d][1]['fields']' \"\n \"can't include the ManyToManyField field '%s' because \"\n \"'%s' manually specifies a 'through' model.\" % (\n cls.__name__, idx, field, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L269_C8", "label": "flattened_fieldsets = flatten_fieldsets()", "type": "assigned_variable", "loc": [269, 269], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L233_C4", "vector": [14, 2, 0.7116, 0.0026, 2, 0.94, 0.6667, 16, 3, 1, 0, 0, 348, 10, 1], "semantic": {"name": "flattened_fieldsets", "arg_names": [], "import_names": [], "rhs_call_name": "flatten_fieldsets", "annotation": ""}, "snippet": " flattened_fieldsets = flatten_fieldsets(cls.fieldsets)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L270_C8", "label": "if", "type": "if", "loc": [270, 271], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L233_C4", "vector": [4, 2, 0.7156, 0.0053, 2, 0.94, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(flattened_fieldsets) > len(set(flattened_fieldsets)):\n raise ImproperlyConfigured('There are duplicate field(s) in %s.fieldsets' % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L274_C4", "label": "if", "type": "if", "loc": [274, 285], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "vector": [4, 1, 0.7394, 0.0317, 1, 0.24, 0.4444, 0, 7, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cls.exclude: # default value is None\n check_isseq(cls, 'exclude', cls.exclude)\n for field in cls.exclude:\n check_formfield(cls, model, opts, 'exclude', field)\n try:\n f = opts.get_field(field)\n except models.FieldDoesNotExist:\n # If we can't find a field on the model that matches,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L275_C8", "label": "check_isseq()", "type": "expression", "loc": [275, 275], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L274_C4", "vector": [8, 2, 0.7275, 0.0026, 2, 0.03, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'exclude', cls.exclude)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L276_C8", "label": "for field", "type": "for", "loc": [276, 283], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L274_C4", "vector": [6, 2, 0.7394, 0.0212, 2, 0.03, 0.5, 480, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field in cls.exclude:\n check_formfield(cls, model, opts, 'exclude', field)\n try:\n f = opts.get_field(field)\n except models.FieldDoesNotExist:\n # If we can't find a field on the model that matches,\n # it could be an extra field on the form.\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L277_C12", "label": "check_formfield()", "type": "expression", "loc": [277, 277], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L276_C8", "vector": [8, 3, 0.7328, 0.0026, 3, 0.86, 0.0, 879, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "check_formfield", "arg_names": [], "import_names": [], "rhs_call_name": "check_formfield", "annotation": ""}, "snippet": " check_formfield(cls, model, opts, 'exclude', field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L278_C12", "label": "try", "type": "try", "loc": [278, 283], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L276_C8", "vector": [7, 3, 0.7421, 0.0159, 3, 0.86, 1.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n f = opts.get_field(field)\n except models.FieldDoesNotExist:\n # If we can't find a field on the model that matches,\n # it could be an extra field on the form.\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L279_C16", "label": "f = get_field()", "type": "assigned_variable", "loc": [279, 279], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L278_C12", "vector": [14, 4, 0.7381, 0.0026, 4, 0.56, 0.0, 899, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = opts.get_field(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L284_C8", "label": "if", "type": "if", "loc": [284, 285], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L274_C4", "vector": [4, 2, 0.7526, 0.0053, 2, 0.03, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(cls.exclude) > len(set(cls.exclude)):\n raise ImproperlyConfigured('There are duplicate field(s) in %s.exclude' % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L288_C4", "label": "if", "type": "if", "loc": [288, 290], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "vector": [4, 1, 0.7646, 0.0079, 1, 0.24, 0.5556, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'form') and not issubclass(cls.form, BaseModelForm):\n raise ImproperlyConfigured(\"%s.form does not inherit from \"\n \"BaseModelForm.\" % cls.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L293_C4", "label": "if", "type": "if", "loc": [293, 299], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "vector": [4, 1, 0.7831, 0.0185, 1, 0.24, 0.6667, 0, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'filter_vertical'):\n check_isseq(cls, 'filter_vertical', cls.filter_vertical)\n for idx, field in enumerate(cls.filter_vertical):\n f = get_field(cls, model, opts, 'filter_vertical', field)\n if not isinstance(f, models.ManyToManyField):\n raise ImproperlyConfigured(\"'%s.filter_vertical[%d]' must be \"\n \"a ManyToManyField.\" % (cls.__name__, idx))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L294_C8", "label": "check_isseq()", "type": "expression", "loc": [294, 294], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L293_C4", "vector": [8, 2, 0.7778, 0.0026, 2, 0.36, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'filter_vertical', cls.filter_vertical)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L295_C8", "label": "for idx, field", "type": "for", "loc": [295, 299], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L293_C4", "vector": [6, 2, 0.7857, 0.0132, 2, 0.36, 1.0, 226, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "idx, field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for idx, field in enumerate(cls.filter_vertical):\n f = get_field(cls, model, opts, 'filter_vertical', field)\n if not isinstance(f, models.ManyToManyField):\n raise ImproperlyConfigured(\"'%s.filter_vertical[%d]' must be \"\n \"a ManyToManyField.\" % (cls.__name__, idx))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L296_C12", "label": "f = get_field()", "type": "assigned_variable", "loc": [296, 296], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L295_C8", "vector": [14, 3, 0.7831, 0.0026, 3, 0.56, 0.0, 899, 3, 5, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = get_field(cls, model, opts, 'filter_vertical', field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L297_C12", "label": "if", "type": "if", "loc": [297, 299], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L295_C8", "vector": [4, 3, 0.7884, 0.0079, 3, 0.56, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(f, models.ManyToManyField):\n raise ImproperlyConfigured(\"'%s.filter_vertical[%d]' must be \"\n \"a ManyToManyField.\" % (cls.__name__, idx))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L302_C4", "label": "if", "type": "if", "loc": [302, 308], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "vector": [4, 1, 0.8069, 0.0185, 1, 0.24, 0.7778, 0, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'filter_horizontal'):\n check_isseq(cls, 'filter_horizontal', cls.filter_horizontal)\n for idx, field in enumerate(cls.filter_horizontal):\n f = get_field(cls, model, opts, 'filter_horizontal', field)\n if not isinstance(f, models.ManyToManyField):\n raise ImproperlyConfigured(\"'%s.filter_horizontal[%d]' must be \"\n \"a ManyToManyField.\" % (cls.__name__, idx))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L303_C8", "label": "check_isseq()", "type": "expression", "loc": [303, 303], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L302_C4", "vector": [8, 2, 0.8016, 0.0026, 2, 0.59, 0.0, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, 'filter_horizontal', cls.filter_horizontal)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L304_C8", "label": "for idx, field", "type": "for", "loc": [304, 308], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L302_C4", "vector": [6, 2, 0.8095, 0.0132, 2, 0.59, 1.0, 226, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "idx, field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for idx, field in enumerate(cls.filter_horizontal):\n f = get_field(cls, model, opts, 'filter_horizontal', field)\n if not isinstance(f, models.ManyToManyField):\n raise ImproperlyConfigured(\"'%s.filter_horizontal[%d]' must be \"\n \"a ManyToManyField.\" % (cls.__name__, idx))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L305_C12", "label": "f = get_field()", "type": "assigned_variable", "loc": [305, 305], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L304_C8", "vector": [14, 3, 0.8069, 0.0026, 3, 0.19, 0.0, 899, 3, 5, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = get_field(cls, model, opts, 'filter_horizontal', field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L306_C12", "label": "if", "type": "if", "loc": [306, 308], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L304_C8", "vector": [4, 3, 0.8122, 0.0079, 3, 0.19, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(f, models.ManyToManyField):\n raise ImproperlyConfigured(\"'%s.filter_horizontal[%d]' must be \"\n \"a ManyToManyField.\" % (cls.__name__, idx))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L311_C4", "label": "if", "type": "if", "loc": [311, 322], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "vector": [4, 1, 0.8373, 0.0317, 1, 0.24, 0.8889, 0, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'radio_fields'):\n check_isdict(cls, 'radio_fields', cls.radio_fields)\n for field, val in cls.radio_fields.items():\n f = get_field(cls, model, opts, 'radio_fields', field)\n if not (isinstance(f, models.ForeignKey) or f.choices):\n raise ImproperlyConfigured(\"'%s.radio_fields['%s']' \"\n \"is neither an instance of ForeignKey nor does \"\n \"have choices set.\" % (cls.__name__, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L312_C8", "label": "check_isdict()", "type": "expression", "loc": [312, 312], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L311_C4", "vector": [8, 2, 0.8254, 0.0026, 2, 0.6, 0.0, 806, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isdict", "arg_names": [], "import_names": [], "rhs_call_name": "check_isdict", "annotation": ""}, "snippet": " check_isdict(cls, 'radio_fields', cls.radio_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L313_C8", "label": "for field, val", "type": "for", "loc": [313, 322], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L311_C4", "vector": [6, 2, 0.8399, 0.0265, 2, 0.6, 1.0, 343, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "field, val", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field, val in cls.radio_fields.items():\n f = get_field(cls, model, opts, 'radio_fields', field)\n if not (isinstance(f, models.ForeignKey) or f.choices):\n raise ImproperlyConfigured(\"'%s.radio_fields['%s']' \"\n \"is neither an instance of ForeignKey nor does \"\n \"have choices set.\" % (cls.__name__, field))\n if not val in (HORIZONTAL, VERTICAL):\n raise ImproperlyConfigured(\"'%s.radio_fields['%s']' \""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L314_C12", "label": "f = get_field()", "type": "assigned_variable", "loc": [314, 314], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L313_C8", "vector": [14, 3, 0.8307, 0.0026, 3, 0.65, 0.0, 899, 3, 5, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = get_field(cls, model, opts, 'radio_fields', field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L315_C12", "label": "if", "type": "if", "loc": [315, 318], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L313_C8", "vector": [4, 3, 0.8373, 0.0106, 3, 0.65, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not (isinstance(f, models.ForeignKey) or f.choices):\n raise ImproperlyConfigured(\"'%s.radio_fields['%s']' \"\n \"is neither an instance of ForeignKey nor does \"\n \"have choices set.\" % (cls.__name__, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L319_C12", "label": "if", "type": "if", "loc": [319, 322], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L313_C8", "vector": [4, 3, 0.8479, 0.0106, 3, 0.65, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not val in (HORIZONTAL, VERTICAL):\n raise ImproperlyConfigured(\"'%s.radio_fields['%s']' \"\n \"is neither admin.HORIZONTAL nor admin.VERTICAL.\"\n % (cls.__name__, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L325_C4", "label": "if", "type": "if", "loc": [325, 337], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "vector": [4, 1, 0.8757, 0.0344, 1, 0.24, 1.0, 0, 3, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(cls, 'prepopulated_fields'):\n check_isdict(cls, 'prepopulated_fields', cls.prepopulated_fields)\n for field, val in cls.prepopulated_fields.items():\n f = get_field(cls, model, opts, 'prepopulated_fields', field)\n if isinstance(f, (models.DateTimeField, models.ForeignKey,\n models.ManyToManyField)):\n raise ImproperlyConfigured(\"'%s.prepopulated_fields['%s']' \"\n \"is either a DateTimeField, ForeignKey or \""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L326_C8", "label": "check_isdict()", "type": "expression", "loc": [326, 326], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L325_C4", "vector": [8, 2, 0.8624, 0.0026, 2, 0.1, 0.0, 806, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isdict", "arg_names": [], "import_names": [], "rhs_call_name": "check_isdict", "annotation": ""}, "snippet": " check_isdict(cls, 'prepopulated_fields', cls.prepopulated_fields)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L327_C8", "label": "for field, val", "type": "for", "loc": [327, 337], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L325_C4", "vector": [6, 2, 0.8783, 0.0291, 2, 0.1, 1.0, 343, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "field, val", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field, val in cls.prepopulated_fields.items():\n f = get_field(cls, model, opts, 'prepopulated_fields', field)\n if isinstance(f, (models.DateTimeField, models.ForeignKey,\n models.ManyToManyField)):\n raise ImproperlyConfigured(\"'%s.prepopulated_fields['%s']' \"\n \"is either a DateTimeField, ForeignKey or \"\n \"ManyToManyField. This isn't allowed.\"\n % (cls.__name__, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L328_C12", "label": "f = get_field()", "type": "assigned_variable", "loc": [328, 328], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L327_C8", "vector": [14, 3, 0.8677, 0.0026, 3, 0.94, 0.0, 899, 3, 5, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = get_field(cls, model, opts, 'prepopulated_fields', field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L329_C12", "label": "if", "type": "if", "loc": [329, 334], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L327_C8", "vector": [4, 3, 0.877, 0.0159, 3, 0.94, 0.3333, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f, (models.DateTimeField, models.ForeignKey,\n models.ManyToManyField)):\n raise ImproperlyConfigured(\"'%s.prepopulated_fields['%s']' \"\n \"is either a DateTimeField, ForeignKey or \"\n \"ManyToManyField. This isn't allowed.\"\n % (cls.__name__, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L335_C12", "label": "check_isseq()", "type": "expression", "loc": [335, 335], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L327_C8", "vector": [8, 3, 0.8862, 0.0026, 3, 0.94, 0.6667, 224, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "check_isseq", "arg_names": [], "import_names": [], "rhs_call_name": "check_isseq", "annotation": ""}, "snippet": " check_isseq(cls, \"prepopulated_fields['%s']\" % field, val)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L336_C12", "label": "for idx, f", "type": "for", "loc": [336, 337], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L327_C8", "vector": [6, 3, 0.8902, 0.0053, 3, 0.94, 1.0, 966, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "idx, f", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for idx, f in enumerate(val):\n get_field(cls, model, opts, \"prepopulated_fields['%s'][%d]\" % (field, idx), f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L337_C16", "label": "get_field()", "type": "expression", "loc": [337, 337], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L336_C12", "vector": [8, 4, 0.8915, 0.0026, 4, 0.58, 0.0, 389, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "get_field", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " get_field(cls, model, opts, \"prepopulated_fields['%s'][%d]\" % (field, idx), f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L339_C0", "label": "check_isseq", "type": "function", "loc": [339, 341], "level": 0, "parent": null, "vector": [2, 0, 0.8995, 0.0079, 0, 0.66, 0.6923, 224, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "check_isseq", "arg_names": ["cls", "label", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def check_isseq(cls, label, obj):\n if not isinstance(obj, (list, tuple)):\n raise ImproperlyConfigured(\"'%s.%s' must be a list or tuple.\" % (cls.__name__, label))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L340_C4", "label": "if", "type": "if", "loc": [340, 341], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L339_C0", "vector": [4, 1, 0.9008, 0.0053, 1, 0.13, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(obj, (list, tuple)):\n raise ImproperlyConfigured(\"'%s.%s' must be a list or tuple.\" % (cls.__name__, label))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L343_C0", "label": "check_isdict", "type": "function", "loc": [343, 345], "level": 0, "parent": null, "vector": [2, 0, 0.9101, 0.0079, 0, 0.66, 0.7692, 806, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "check_isdict", "arg_names": ["cls", "label", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def check_isdict(cls, label, obj):\n if not isinstance(obj, dict):\n raise ImproperlyConfigured(\"'%s.%s' must be a dictionary.\" % (cls.__name__, label))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L344_C4", "label": "if", "type": "if", "loc": [344, 345], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L343_C0", "vector": [4, 1, 0.9114, 0.0053, 1, 0.85, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(obj, dict):\n raise ImproperlyConfigured(\"'%s.%s' must be a dictionary.\" % (cls.__name__, label))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L347_C0", "label": "get_field", "type": "function", "loc": [347, 352], "level": 0, "parent": null, "vector": [2, 0, 0.9246, 0.0159, 0, 0.66, 0.8462, 389, 0, 5, 1, 0, 0, 0, 2], "semantic": {"name": "get_field", "arg_names": ["cls", "model", "opts", "label", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_field(cls, model, opts, label, field):\n try:\n return opts.get_field(field)\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"'%s.%s' refers to field '%s' that is missing from model '%s'.\"\n % (cls.__name__, label, field, model.__name__))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L348_C4", "label": "try", "type": "try", "loc": [348, 352], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L347_C0", "vector": [7, 1, 0.9259, 0.0132, 1, 0.69, 0.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n return opts.get_field(field)\n except models.FieldDoesNotExist:\n raise ImproperlyConfigured(\"'%s.%s' refers to field '%s' that is missing from model '%s'.\"\n % (cls.__name__, label, field, model.__name__))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Return_L349_C8", "label": "return", "type": "return", "loc": [349, 349], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L348_C4", "vector": [13, 2, 0.9233, 0.0026, 2, 0.53, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return opts.get_field(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L354_C0", "label": "check_formfield", "type": "function", "loc": [354, 367], "level": 0, "parent": null, "vector": [2, 0, 0.9537, 0.037, 0, 0.66, 0.9231, 879, 0, 5, 0, 0, 0, 0, 4], "semantic": {"name": "check_formfield", "arg_names": ["cls", "model", "opts", "label", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def check_formfield(cls, model, opts, label, field):\n if getattr(cls.form, 'base_fields', None):\n try:\n cls.form.base_fields[field]\n except KeyError:\n raise ImproperlyConfigured(\"'%s.%s' refers to field '%s' that \"\n \"is missing from the form.\" % (cls.__name__, label, field))\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L355_C4", "label": "if", "type": "if", "loc": [355, 367], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L354_C0", "vector": [4, 1, 0.955, 0.0344, 1, 0.01, 0.0, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if getattr(cls.form, 'base_fields', None):\n try:\n cls.form.base_fields[field]\n except KeyError:\n raise ImproperlyConfigured(\"'%s.%s' refers to field '%s' that \"\n \"is missing from the form.\" % (cls.__name__, label, field))\n else:\n fields = fields_for_model(model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L356_C8", "label": "try", "type": "try", "loc": [356, 360], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L355_C4", "vector": [7, 2, 0.9471, 0.0132, 2, 0.57, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n cls.form.base_fields[field]\n except KeyError:\n raise ImproperlyConfigured(\"'%s.%s' refers to field '%s' that \"\n \"is missing from the form.\" % (cls.__name__, label, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L357_C12", "label": "expression", "type": "expression", "loc": [357, 357], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L356_C8", "vector": [8, 3, 0.9444, 0.0026, 3, 0.14, 0.0, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cls.form.base_fields[field]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L362_C8", "label": "fields = fields_for_model()", "type": "assigned_variable", "loc": [362, 362], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L355_C4", "vector": [14, 2, 0.9577, 0.0026, 2, 0.57, 0.5, 358, 3, 1, 0, 0, 464, 10, 1], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "fields_for_model", "annotation": ""}, "snippet": " fields = fields_for_model(model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L363_C8", "label": "try", "type": "try", "loc": [363, 367], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L355_C4", "vector": [7, 2, 0.9656, 0.0132, 2, 0.57, 1.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n fields[field]\n except KeyError:\n raise ImproperlyConfigured(\"'%s.%s' refers to field '%s' that \"\n \"is missing from the form.\" % (cls.__name__, label, field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L364_C12", "label": "expression", "type": "expression", "loc": [364, 364], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L363_C8", "vector": [8, 3, 0.963, 0.0026, 3, 0.98, 0.0, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fields[field]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L369_C0", "label": "fetch_attr", "type": "function", "loc": [369, 378], "level": 0, "parent": null, "vector": [2, 0, 0.9881, 0.0265, 0, 0.66, 1.0, 963, 0, 5, 1, 0, 0, 0, 3], "semantic": {"name": "fetch_attr", "arg_names": ["cls", "model", "opts", "label", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def fetch_attr(cls, model, opts, label, field):\n try:\n return opts.get_field(field)\n except models.FieldDoesNotExist:\n pass\n try:\n return getattr(model, field)\n except AttributeError:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L370_C4", "label": "try", "type": "try", "loc": [370, 373], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L369_C0", "vector": [7, 1, 0.9828, 0.0106, 1, 0.93, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n return opts.get_field(field)\n except models.FieldDoesNotExist:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Return_L371_C8", "label": "return", "type": "return", "loc": [371, 371], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L370_C4", "vector": [13, 2, 0.9815, 0.0026, 2, 0.27, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return opts.get_field(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L374_C4", "label": "try", "type": "try", "loc": [374, 378], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L369_C0", "vector": [7, 1, 0.9947, 0.0132, 1, 0.93, 1.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n return getattr(model, field)\n except AttributeError:\n raise ImproperlyConfigured(\"'%s.%s' refers to '%s' that is neither a field, method or property of model '%s'.\"\n % (cls.__name__, label, field, model.__name__))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98648:Return_L375_C8", "label": "return", "type": "return", "loc": [375, 375], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L374_C4", "vector": [13, 2, 0.9921, 0.0026, 2, 0.32, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return getattr(model, field)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L28_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L29_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L29_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L30_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L30_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L31_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L31_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L32_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L30_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L38_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L30_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L39_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L47_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L48_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L56_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L57_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L60_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L65_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L65_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L65_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L67_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L68_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L68_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L69_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L67_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L74_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L67_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L67_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L82_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L67_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L87_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L93_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L97_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L97_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L98_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L97_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L99_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L105_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L106_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L107_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L108_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L107_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L113_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L107_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L115_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L115_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L116_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L107_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L119_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L107_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L121_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L123_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L123_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L124_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L123_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L125_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L126_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L126_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L127_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L127_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L128_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L128_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L129_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L129_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L130_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L138_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L138_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L139_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L145_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L145_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L146_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L145_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L147_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L147_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L148_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L147_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L151_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L147_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L154_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L147_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L157_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L147_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L158_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L163_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L163_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L164_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L163_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L165_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L169_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L172_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L177_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L178_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L183_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L160_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L188_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L188_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L189_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L195_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L198_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L198_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L199_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L198_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L200_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L200_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L201_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L200_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L202_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L208_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L208_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L209_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L208_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L210_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L210_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L211_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L210_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L216_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L210_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L217_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L217_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L218_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L210_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L223_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L208_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L227_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L208_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L229_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L233_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L233_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L234_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L233_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L235_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L235_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L236_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L235_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L237_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L235_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L240_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L235_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L241_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L235_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L245_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L245_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L248_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L248_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L249_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L245_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L250_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L250_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L251_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L250_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L257_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L250_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L258_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L258_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L259_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L258_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L260_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L233_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L269_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L233_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L270_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L274_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L274_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L275_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L274_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L276_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L276_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L277_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L276_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L278_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L278_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L279_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L274_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L284_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L288_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L293_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L293_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L294_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L293_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L295_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L295_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L296_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L295_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L297_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L302_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L302_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L303_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L302_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L304_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L304_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L305_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L304_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L306_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L311_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L311_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L312_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L311_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L313_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L313_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L314_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L313_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L315_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L313_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L319_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L194_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L325_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L325_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L326_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L325_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L327_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L327_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L328_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L327_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L329_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L327_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L335_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L327_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L336_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:For_L336_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L337_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L339_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L340_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L343_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L344_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L347_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L348_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L348_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Return_L349_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L354_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L355_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L355_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L356_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L356_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L357_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L355_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Assign_L362_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:If_L355_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L363_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L363_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Expr_L364_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L369_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L370_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L370_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Return_L371_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:FunctionDef_L369_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L374_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98648:Try_L374_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98648:Return_L375_C8"}] |
from django import forms
from django.conf import settings
from django.contrib.admin.util import flatten_fieldsets, lookup_field
from django.contrib.admin.util import display_for_field, label_for_field
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.fields.related import ManyToManyRel
from django.forms.util import flatatt
from django.template.defaultfilters import capfirst
from django.utils.encoding import force_unicode, smart_unicode
from django.utils.html import escape, conditional_escape
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
ACTION_CHECKBOX_NAME = '_selected_action'
class ActionForm(forms.Form):
action = forms.ChoiceField(label=_('Action:'))
select_across = forms.BooleanField(label='', required=False, initial=0,
widget=forms.HiddenInput({'class': 'select-across'}))
checkbox = forms.CheckboxInput({'class': 'action-select'}, lambda value: False)
class AdminForm(object):
def __init__(self, form, fieldsets, prepopulated_fields, readonly_fields=None, model_admin=None):
self.form, self.fieldsets = form, normalize_fieldsets(fieldsets)
self.prepopulated_fields = [{
'field': form[field_name],
'dependencies': [form[f] for f in dependencies]
} for field_name, dependencies in prepopulated_fields.items()]
self.model_admin = model_admin
if readonly_fields is None:
readonly_fields = ()
self.readonly_fields = readonly_fields
def __iter__(self):
for name, options in self.fieldsets:
yield Fieldset(self.form, name,
readonly_fields=self.readonly_fields,
model_admin=self.model_admin,
**options
)
def first_field(self):
try:
fieldset_name, fieldset_options = self.fieldsets[0]
field_name = fieldset_options['fields'][0]
if not isinstance(field_name, basestring):
field_name = field_name[0]
return self.form[field_name]
except (KeyError, IndexError):
pass
try:
return iter(self.form).next()
except StopIteration:
return None
def _media(self):
media = self.form.media
for fs in self:
media = media + fs.media
return media
media = property(_media)
class Fieldset(object):
def __init__(self, form, name=None, readonly_fields=(), fields=(), classes=(),
description=None, model_admin=None):
self.form = form
self.name, self.fields = name, fields
self.classes = u' '.join(classes)
self.description = description
self.model_admin = model_admin
self.readonly_fields = readonly_fields
def _media(self):
if 'collapse' in self.classes:
js = ['js/jquery.min.js', 'js/jquery.init.js', 'js/collapse.min.js']
return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js])
return forms.Media()
media = property(_media)
def __iter__(self):
for field in self.fields:
yield Fieldline(self.form, field, self.readonly_fields, model_admin=self.model_admin)
class Fieldline(object):
def __init__(self, form, field, readonly_fields=None, model_admin=None):
self.form = form # A django.forms.Form instance
if not hasattr(field, "__iter__"):
self.fields = [field]
else:
self.fields = field
self.model_admin = model_admin
if readonly_fields is None:
readonly_fields = ()
self.readonly_fields = readonly_fields
def __iter__(self):
for i, field in enumerate(self.fields):
if field in self.readonly_fields:
yield AdminReadonlyField(self.form, field, is_first=(i == 0),
model_admin=self.model_admin)
else:
yield AdminField(self.form, field, is_first=(i == 0))
def errors(self):
return mark_safe(u'\n'.join([self.form[f].errors.as_ul() for f in self.fields if f not in self.readonly_fields]).strip('\n'))
class AdminField(object):
def __init__(self, form, field, is_first):
self.field = form[field] # A django.forms.BoundField instance
self.is_first = is_first # Whether this field is first on the line
self.is_checkbox = isinstance(self.field.field.widget, forms.CheckboxInput)
def label_tag(self):
classes = []
if self.is_checkbox:
classes.append(u'vCheckboxLabel')
contents = force_unicode(escape(self.field.label))
else:
contents = force_unicode(escape(self.field.label)) + u':'
if self.field.field.required:
classes.append(u'required')
if not self.is_first:
classes.append(u'inline')
attrs = classes and {'class': u' '.join(classes)} or {}
return self.field.label_tag(contents=contents, attrs=attrs)
class AdminReadonlyField(object):
def __init__(self, form, field, is_first, model_admin=None):
label = label_for_field(field, form._meta.model, model_admin)
# Make self.field look a little bit like a field. This means that
# {{ field.name }} must be a useful class name to identify the field.
# For convenience, store other field-related data here too.
if callable(field):
class_name = field.__name__ != '<lambda>' and field.__name__ or ''
else:
class_name = field
self.field = {
'name': class_name,
'label': label,
'field': field,
}
self.form = form
self.model_admin = model_admin
self.is_first = is_first
self.is_checkbox = False
self.is_readonly = True
def label_tag(self):
attrs = {}
if not self.is_first:
attrs["class"] = "inline"
label = self.field['label']
contents = capfirst(force_unicode(escape(label))) + u":"
return mark_safe('<label%(attrs)s>%(contents)s</label>' % {
"attrs": flatatt(attrs),
"contents": contents,
})
def contents(self):
from django.contrib.admin.templatetags.admin_list import _boolean_icon
from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
field, obj, model_admin = self.field['field'], self.form.instance, self.model_admin
try:
f, attr, value = lookup_field(field, obj, model_admin)
except (AttributeError, ValueError, ObjectDoesNotExist):
result_repr = EMPTY_CHANGELIST_VALUE
else:
if f is None:
boolean = getattr(attr, "boolean", False)
if boolean:
result_repr = _boolean_icon(value)
else:
result_repr = smart_unicode(value)
if getattr(attr, "allow_tags", False):
result_repr = mark_safe(result_repr)
else:
if value is None:
result_repr = EMPTY_CHANGELIST_VALUE
elif isinstance(f.rel, ManyToManyRel):
result_repr = ", ".join(map(unicode, value.all()))
else:
result_repr = display_for_field(value, f)
return conditional_escape(result_repr)
class InlineAdminFormSet(object):
"""
A wrapper around an inline formset for use in the admin system.
"""
def __init__(self, inline, formset, fieldsets, readonly_fields=None, model_admin=None):
self.opts = inline
self.formset = formset
self.fieldsets = fieldsets
self.model_admin = model_admin
if readonly_fields is None:
readonly_fields = ()
self.readonly_fields = readonly_fields
def __iter__(self):
for form, original in zip(self.formset.initial_forms, self.formset.get_queryset()):
yield InlineAdminForm(self.formset, form, self.fieldsets,
self.opts.prepopulated_fields, original, self.readonly_fields,
model_admin=self.model_admin)
for form in self.formset.extra_forms:
yield InlineAdminForm(self.formset, form, self.fieldsets,
self.opts.prepopulated_fields, None, self.readonly_fields,
model_admin=self.model_admin)
yield InlineAdminForm(self.formset, self.formset.empty_form,
self.fieldsets, self.opts.prepopulated_fields, None,
self.readonly_fields, model_admin=self.model_admin)
def fields(self):
fk = getattr(self.formset, "fk", None)
for i, field in enumerate(flatten_fieldsets(self.fieldsets)):
if fk and fk.name == field:
continue
if field in self.readonly_fields:
yield {
'label': label_for_field(field, self.opts.model, self.model_admin),
'widget': {
'is_hidden': False
},
'required': False
}
else:
yield self.formset.form.base_fields[field]
def _media(self):
media = self.opts.media + self.formset.media
for fs in self:
media = media + fs.media
return media
media = property(_media)
class InlineAdminForm(AdminForm):
"""
A wrapper around an inline form for use in the admin system.
"""
def __init__(self, formset, form, fieldsets, prepopulated_fields, original,
readonly_fields=None, model_admin=None):
self.formset = formset
self.model_admin = model_admin
self.original = original
if original is not None:
self.original_content_type_id = ContentType.objects.get_for_model(original).pk
self.show_url = original and hasattr(original, 'get_absolute_url')
super(InlineAdminForm, self).__init__(form, fieldsets, prepopulated_fields,
readonly_fields, model_admin)
def __iter__(self):
for name, options in self.fieldsets:
yield InlineFieldset(self.formset, self.form, name,
self.readonly_fields, model_admin=self.model_admin, **options)
def has_auto_field(self):
if self.form._meta.model._meta.has_auto_field:
return True
# Also search any parents for an auto field.
for parent in self.form._meta.model._meta.get_parent_list():
if parent._meta.has_auto_field:
return True
return False
def field_count(self):
# tabular.html uses this function for colspan value.
num_of_fields = 0
if self.has_auto_field():
num_of_fields += 1
num_of_fields += len(self.fieldsets[0][1]["fields"])
if self.formset.can_order:
num_of_fields += 1
if self.formset.can_delete:
num_of_fields += 1
return num_of_fields
def pk_field(self):
return AdminField(self.form, self.formset._pk_field.name, False)
def fk_field(self):
fk = getattr(self.formset, "fk", None)
if fk:
return AdminField(self.form, fk.name, False)
else:
return ""
def deletion_field(self):
from django.forms.formsets import DELETION_FIELD_NAME
return AdminField(self.form, DELETION_FIELD_NAME, False)
def ordering_field(self):
from django.forms.formsets import ORDERING_FIELD_NAME
return AdminField(self.form, ORDERING_FIELD_NAME, False)
class InlineFieldset(Fieldset):
def __init__(self, formset, *args, **kwargs):
self.formset = formset
super(InlineFieldset, self).__init__(*args, **kwargs)
def __iter__(self):
fk = getattr(self.formset, "fk", None)
for field in self.fields:
if fk and fk.name == field:
continue
yield Fieldline(self.form, field, self.readonly_fields,
model_admin=self.model_admin)
class AdminErrorList(forms.util.ErrorList):
"""
Stores all errors for the form/formsets in an add/change stage view.
"""
def __init__(self, form, inline_formsets):
if form.is_bound:
self.extend(form.errors.values())
for inline_formset in inline_formsets:
self.extend(inline_formset.non_form_errors())
for errors_in_inline_form in inline_formset.errors:
self.extend(errors_in_inline_form.values())
def normalize_fieldsets(fieldsets):
"""
Make sure the keys in fieldset dictionaries are strings. Returns the
normalized data.
"""
result = []
for name, options in fieldsets:
result.append((name, normalize_dictionary(options)))
return result
def normalize_dictionary(data_dict):
"""
Converts all the keys in "data_dict" to strings. The keys must be
convertible using str().
"""
for key, value in data_dict.items():
if not isinstance(key, str):
del data_dict[key]
data_dict[str(key)] = value
return data_dict
| ajibawa-2023/Python-Code-Large/train/row_98649 | 233 | 340 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L1_C0", "label": "from django import forms", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0029, 0.0029, 0, 0.66, 0.0, 294, 0, 1, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["forms"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django import forms"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L2_C0", "label": "from django.conf import settings", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0059, 0.0029, 0, 0.66, 0.0385, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L3_C0", "label": "from django.contrib.admin.util import flatten_fieldsets, lookup_field", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0088, 0.0029, 0, 0.66, 0.0769, 69, 0, 2, 0, 0, 69, 0, 0], "semantic": {"name": "django.contrib.admin.util", "arg_names": [], "import_names": ["flatten_fieldsets", "lookup_field"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.util import flatten_fieldsets, lookup_field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L4_C0", "label": "from django.contrib.admin.util import display_for_field, label_for_field", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0118, 0.0029, 0, 0.66, 0.1154, 69, 0, 2, 0, 0, 69, 0, 0], "semantic": {"name": "django.contrib.admin.util", "arg_names": [], "import_names": ["display_for_field", "label_for_field"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.util import display_for_field, label_for_field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L5_C0", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0147, 0.0029, 0, 0.66, 0.1538, 469, 0, 1, 0, 0, 469, 0, 0], "semantic": {"name": "django.contrib.contenttypes.models", "arg_names": [], "import_names": ["ContentType"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.contenttypes.models import ContentType"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L6_C0", "label": "from django.core.exceptions import ObjectDoesNotExist", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0176, 0.0029, 0, 0.66, 0.1923, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["ObjectDoesNotExist"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import ObjectDoesNotExist"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L7_C0", "label": "from django.db.models.fields.related import ManyToManyRel", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0206, 0.0029, 0, 0.66, 0.2308, 410, 0, 1, 0, 0, 410, 0, 0], "semantic": {"name": "django.db.models.fields.related", "arg_names": [], "import_names": ["ManyToManyRel"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models.fields.related import ManyToManyRel"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L8_C0", "label": "from django.forms.util import flatatt", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0235, 0.0029, 0, 0.66, 0.2692, 332, 0, 1, 0, 0, 332, 0, 0], "semantic": {"name": "django.forms.util", "arg_names": [], "import_names": ["flatatt"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.forms.util import flatatt"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L9_C0", "label": "from django.template.defaultfilters import capfirst", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0265, 0.0029, 0, 0.66, 0.3077, 913, 0, 1, 0, 0, 913, 0, 0], "semantic": {"name": "django.template.defaultfilters", "arg_names": [], "import_names": ["capfirst"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template.defaultfilters import capfirst"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L10_C0", "label": "from django.utils.encoding import force_unicode, smart_unicode", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0294, 0.0029, 0, 0.66, 0.3462, 96, 0, 2, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["force_unicode", "smart_unicode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import force_unicode, smart_unicode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L11_C0", "label": "from django.utils.html import escape, conditional_escape", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0324, 0.0029, 0, 0.66, 0.3846, 535, 0, 2, 0, 0, 535, 0, 0], "semantic": {"name": "django.utils.html", "arg_names": [], "import_names": ["escape", "conditional_escape"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.html import escape, conditional_escape"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L12_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0353, 0.0029, 0, 0.66, 0.4231, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.safestring", "arg_names": [], "import_names": ["mark_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.safestring import mark_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L13_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0382, 0.0029, 0, 0.66, 0.4615, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext_lazy as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L16_C0", "label": "ACTION_CHECKBOX_NAME =", "type": "assigned_variable", "loc": [16, 16], "level": 0, "parent": null, "vector": [14, 0, 0.0471, 0.0029, 0, 0.66, 0.5, 515, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "ACTION_CHECKBOX_NAME", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "ACTION_CHECKBOX_NAME = '_selected_action'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L18_C0", "label": "ActionForm", "type": "class", "loc": [18, 21], "level": 0, "parent": null, "vector": [3, 0, 0.0574, 0.0118, 0, 0.66, 0.5385, 299, 0, 0, 0, 0, 953, 0, 4], "semantic": {"name": "ActionForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ActionForm(forms.Form):\n action = forms.ChoiceField(label=_('Action:'))\n select_across = forms.BooleanField(label='', required=False, initial=0,\n widget=forms.HiddenInput({'class': 'select-across'}))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L19_C4", "label": "action = ChoiceField()", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L18_C0", "vector": [14, 1, 0.0559, 0.0029, 1, 0.97, 0.0, 422, 3, 1, 0, 0, 353, 10, 2], "semantic": {"name": "action", "arg_names": [], "import_names": [], "rhs_call_name": "ChoiceField", "annotation": ""}, "snippet": " action = forms.ChoiceField(label=_('Action:'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L20_C4", "label": "select_across = BooleanField()", "type": "assigned_variable", "loc": [20, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L18_C0", "vector": [14, 1, 0.0603, 0.0059, 1, 0.97, 1.0, 934, 3, 4, 0, 0, 498, 10, 2], "semantic": {"name": "select_across", "arg_names": [], "import_names": [], "rhs_call_name": "BooleanField", "annotation": ""}, "snippet": " select_across = forms.BooleanField(label='', required=False, initial=0,\n widget=forms.HiddenInput({'class': 'select-across'}))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L23_C0", "label": "checkbox = CheckboxInput()", "type": "assigned_variable", "loc": [23, 23], "level": 0, "parent": null, "vector": [14, 0, 0.0676, 0.0029, 0, 0.66, 0.5769, 706, 3, 2, 0, 0, 609, 10, 1], "semantic": {"name": "checkbox", "arg_names": [], "import_names": [], "rhs_call_name": "CheckboxInput", "annotation": ""}, "snippet": "checkbox = forms.CheckboxInput({'class': 'action-select'}, lambda value: False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L25_C0", "label": "AdminForm", "type": "class", "loc": [25, 64], "level": 0, "parent": null, "vector": [3, 0, 0.1309, 0.1176, 0, 0.66, 0.6154, 529, 0, 4, 0, 0, 186, 0, 7], "semantic": {"name": "AdminForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminForm(object):\n def __init__(self, form, fieldsets, prepopulated_fields, readonly_fields=None, model_admin=None):\n self.form, self.fieldsets = form, normalize_fieldsets(fieldsets)\n self.prepopulated_fields = [{\n 'field': form[field_name],\n 'dependencies': [form[f] for f in dependencies]\n } for field_name, dependencies in prepopulated_fields.items()]\n self.model_admin = model_admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L26_C4", "label": "__init__", "type": "function", "loc": [26, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L25_C0", "vector": [2, 1, 0.0897, 0.0294, 1, 0.57, 0.0, 555, 0, 6, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "form", "fieldsets", "prepopulated_fields", "readonly_fields", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, form, fieldsets, prepopulated_fields, readonly_fields=None, model_admin=None):\n self.form, self.fieldsets = form, normalize_fieldsets(fieldsets)\n self.prepopulated_fields = [{\n 'field': form[field_name],\n 'dependencies': [form[f] for f in dependencies]\n } for field_name, dependencies in prepopulated_fields.items()]\n self.model_admin = model_admin\n if readonly_fields is None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L27_C8", "label": "assign", "type": "assigned_variable", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L26_C4", "vector": [14, 2, 0.0794, 0.0029, 2, 0.11, 0.0, 0, 0, 0, 0, 0, 0, 8, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.form, self.fieldsets = form, normalize_fieldsets(fieldsets)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L28_C8", "label": "self.prepopulated_fields =", "type": "assigned_variable", "loc": [28, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L26_C4", "vector": [14, 2, 0.0868, 0.0118, 2, 0.11, 0.25, 145, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "self.prepopulated_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.prepopulated_fields = [{\n 'field': form[field_name],\n 'dependencies': [form[f] for f in dependencies]\n } for field_name, dependencies in prepopulated_fields.items()]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L32_C8", "label": "self.model_admin =", "type": "assigned_variable", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L26_C4", "vector": [14, 2, 0.0941, 0.0029, 2, 0.11, 0.5, 2, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.model_admin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model_admin = model_admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L33_C8", "label": "if", "type": "if", "loc": [33, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L26_C4", "vector": [4, 2, 0.0985, 0.0059, 2, 0.11, 0.75, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if readonly_fields is None:\n readonly_fields = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L34_C12", "label": "readonly_fields =", "type": "assigned_variable", "loc": [34, 34], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L33_C8", "vector": [14, 3, 0.1, 0.0029, 3, 0.44, 0.0, 396, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "readonly_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " readonly_fields = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L35_C8", "label": "self.readonly_fields =", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L26_C4", "vector": [14, 2, 0.1029, 0.0029, 2, 0.11, 1.0, 627, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.readonly_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.readonly_fields = readonly_fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L37_C4", "label": "__iter__", "type": "function", "loc": [37, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L25_C0", "vector": [2, 1, 0.1176, 0.0206, 1, 0.57, 0.25, 891, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "__iter__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __iter__(self):\n for name, options in self.fieldsets:\n yield Fieldset(self.form, name,\n readonly_fields=self.readonly_fields,\n model_admin=self.model_admin,\n **options\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L38_C8", "label": "for name, options", "type": "for", "loc": [38, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L37_C4", "vector": [6, 2, 0.1191, 0.0176, 2, 0.02, 0.0, 992, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "name, options", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name, options in self.fieldsets:\n yield Fieldset(self.form, name,\n readonly_fields=self.readonly_fields,\n model_admin=self.model_admin,\n **options\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L39_C12", "label": "expression", "type": "expression", "loc": [39, 43], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L38_C8", "vector": [8, 3, 0.1206, 0.0147, 3, 0.19, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield Fieldset(self.form, name,\n readonly_fields=self.readonly_fields,\n model_admin=self.model_admin,\n **options\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L45_C4", "label": "first_field", "type": "function", "loc": [45, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L25_C0", "vector": [2, 1, 0.15, 0.0382, 1, 0.57, 0.5, 471, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "first_field", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def first_field(self):\n try:\n fieldset_name, fieldset_options = self.fieldsets[0]\n field_name = fieldset_options['fields'][0]\n if not isinstance(field_name, basestring):\n field_name = field_name[0]\n return self.form[field_name]\n except (KeyError, IndexError):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L46_C8", "label": "try", "type": "try", "loc": [46, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L45_C4", "vector": [7, 2, 0.1456, 0.0235, 2, 0.78, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n fieldset_name, fieldset_options = self.fieldsets[0]\n field_name = fieldset_options['fields'][0]\n if not isinstance(field_name, basestring):\n field_name = field_name[0]\n return self.form[field_name]\n except (KeyError, IndexError):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L47_C12", "label": "fieldset_name, fieldset_options =", "type": "assigned_variable", "loc": [47, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L46_C8", "vector": [14, 3, 0.1382, 0.0029, 3, 0.01, 0.0, 500, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "fieldset_name, fieldset_options", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fieldset_name, fieldset_options = self.fieldsets[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L48_C12", "label": "field_name =", "type": "assigned_variable", "loc": [48, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L46_C8", "vector": [14, 3, 0.1412, 0.0029, 3, 0.01, 0.3333, 918, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_name = fieldset_options['fields'][0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L49_C12", "label": "if", "type": "if", "loc": [49, 50], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L46_C8", "vector": [4, 3, 0.1456, 0.0059, 3, 0.01, 0.6667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(field_name, basestring):\n field_name = field_name[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L50_C16", "label": "field_name =", "type": "assigned_variable", "loc": [50, 50], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L49_C12", "vector": [14, 4, 0.1471, 0.0029, 4, 0.9, 0.0, 918, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_name = field_name[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L51_C12", "label": "return", "type": "return", "loc": [51, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L46_C8", "vector": [13, 3, 0.15, 0.0029, 3, 0.01, 1.0, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.form[field_name]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L54_C8", "label": "try", "type": "try", "loc": [54, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L45_C4", "vector": [7, 2, 0.1632, 0.0118, 2, 0.78, 1.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n return iter(self.form).next()\n except StopIteration:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L55_C12", "label": "return", "type": "return", "loc": [55, 55], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L54_C8", "vector": [13, 3, 0.1618, 0.0029, 3, 0.45, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return iter(self.form).next()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L57_C12", "label": "return", "type": "return", "loc": [57, 57], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L54_C8", "vector": [13, 3, 0.1676, 0.0029, 3, 0.45, 0.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L59_C4", "label": "_media", "type": "function", "loc": [59, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L25_C0", "vector": [2, 1, 0.1794, 0.0147, 1, 0.57, 0.75, 650, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "_media", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _media(self):\n media = self.form.media\n for fs in self:\n media = media + fs.media\n return media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L60_C8", "label": "media =", "type": "assigned_variable", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L59_C4", "vector": [14, 2, 0.1765, 0.0029, 2, 0.21, 0.0, 317, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " media = self.form.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L61_C8", "label": "for fs", "type": "for", "loc": [61, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L59_C4", "vector": [6, 2, 0.1809, 0.0059, 2, 0.21, 0.5, 245, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "fs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for fs in self:\n media = media + fs.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L62_C12", "label": "media =", "type": "assigned_variable", "loc": [62, 62], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L61_C8", "vector": [14, 3, 0.1824, 0.0029, 3, 0.44, 0.0, 317, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " media = media + fs.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L63_C8", "label": "return", "type": "return", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L59_C4", "vector": [13, 2, 0.1853, 0.0029, 2, 0.21, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L64_C4", "label": "media = property()", "type": "assigned_variable", "loc": [64, 64], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L25_C0", "vector": [14, 1, 0.1882, 0.0029, 1, 0.57, 1.0, 317, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " media = property(_media)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L66_C0", "label": "Fieldset", "type": "class", "loc": [66, 85], "level": 0, "parent": null, "vector": [3, 0, 0.2221, 0.0588, 0, 0.66, 0.6538, 644, 0, 3, 0, 0, 186, 0, 5], "semantic": {"name": "Fieldset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Fieldset(object):\n def __init__(self, form, name=None, readonly_fields=(), fields=(), classes=(),\n description=None, model_admin=None):\n self.form = form\n self.name, self.fields = name, fields\n self.classes = u' '.join(classes)\n self.description = description\n self.model_admin = model_admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "label": "__init__", "type": "function", "loc": [67, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L66_C0", "vector": [2, 1, 0.2074, 0.0235, 1, 0.5, 0.0, 555, 0, 8, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "form", "name", "readonly_fields", "fields", "classes", "description", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, form, name=None, readonly_fields=(), fields=(), classes=(),\n description=None, model_admin=None):\n self.form = form\n self.name, self.fields = name, fields\n self.classes = u' '.join(classes)\n self.description = description\n self.model_admin = model_admin\n self.readonly_fields = readonly_fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L69_C8", "label": "self.form =", "type": "assigned_variable", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "vector": [14, 2, 0.2029, 0.0029, 2, 0.16, 0.0, 704, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.form = form"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L70_C8", "label": "assign", "type": "assigned_variable", "loc": [70, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "vector": [14, 2, 0.2059, 0.0029, 2, 0.16, 0.2, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.name, self.fields = name, fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L71_C8", "label": "self.classes = join()", "type": "assigned_variable", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "vector": [14, 2, 0.2088, 0.0029, 2, 0.16, 0.4, 696, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "self.classes", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " self.classes = u' '.join(classes)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L72_C8", "label": "self.description =", "type": "assigned_variable", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "vector": [14, 2, 0.2118, 0.0029, 2, 0.16, 0.6, 171, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.description", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.description = description"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L73_C8", "label": "self.model_admin =", "type": "assigned_variable", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "vector": [14, 2, 0.2147, 0.0029, 2, 0.16, 0.8, 2, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.model_admin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model_admin = model_admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L74_C8", "label": "self.readonly_fields =", "type": "assigned_variable", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "vector": [14, 2, 0.2176, 0.0029, 2, 0.16, 1.0, 627, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.readonly_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.readonly_fields = readonly_fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L76_C4", "label": "_media", "type": "function", "loc": [76, 80], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L66_C0", "vector": [2, 1, 0.2294, 0.0147, 1, 0.5, 0.3333, 650, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "_media", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _media(self):\n if 'collapse' in self.classes:\n js = ['js/jquery.min.js', 'js/jquery.init.js', 'js/collapse.min.js']\n return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js])\n return forms.Media()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L77_C8", "label": "if", "type": "if", "loc": [77, 79], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L76_C4", "vector": [4, 2, 0.2294, 0.0088, 2, 0.13, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'collapse' in self.classes:\n js = ['js/jquery.min.js', 'js/jquery.init.js', 'js/collapse.min.js']\n return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L78_C12", "label": "js =", "type": "assigned_variable", "loc": [78, 78], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L77_C8", "vector": [14, 3, 0.2294, 0.0029, 3, 0.03, 0.0, 62, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "js", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " js = ['js/jquery.min.js', 'js/jquery.init.js', 'js/collapse.min.js']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L79_C12", "label": "return", "type": "return", "loc": [79, 79], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L77_C8", "vector": [13, 3, 0.2324, 0.0029, 3, 0.03, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L80_C8", "label": "return", "type": "return", "loc": [80, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L76_C4", "vector": [13, 2, 0.2353, 0.0029, 2, 0.13, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return forms.Media()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L81_C4", "label": "media = property()", "type": "assigned_variable", "loc": [81, 81], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L66_C0", "vector": [14, 1, 0.2382, 0.0029, 1, 0.5, 0.6667, 317, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " media = property(_media)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L83_C4", "label": "__iter__", "type": "function", "loc": [83, 85], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L66_C0", "vector": [2, 1, 0.2471, 0.0088, 1, 0.5, 1.0, 891, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "__iter__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __iter__(self):\n for field in self.fields:\n yield Fieldline(self.form, field, self.readonly_fields, model_admin=self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L84_C8", "label": "for field", "type": "for", "loc": [84, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L83_C4", "vector": [6, 2, 0.2485, 0.0059, 2, 0.87, 0.0, 480, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field in self.fields:\n yield Fieldline(self.form, field, self.readonly_fields, model_admin=self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L85_C12", "label": "expression", "type": "expression", "loc": [85, 85], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L84_C8", "vector": [8, 3, 0.25, 0.0029, 3, 0.72, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield Fieldline(self.form, field, self.readonly_fields, model_admin=self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L87_C0", "label": "Fieldline", "type": "class", "loc": [87, 108], "level": 0, "parent": null, "vector": [3, 0, 0.2868, 0.0647, 0, 0.66, 0.6923, 484, 0, 3, 0, 0, 186, 0, 8], "semantic": {"name": "Fieldline", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Fieldline(object):\n def __init__(self, form, field, readonly_fields=None, model_admin=None):\n self.form = form # A django.forms.Form instance\n if not hasattr(field, \"__iter__\"):\n self.fields = [field]\n else:\n self.fields = field\n self.model_admin = model_admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L88_C4", "label": "__init__", "type": "function", "loc": [88, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L87_C0", "vector": [2, 1, 0.2721, 0.0294, 1, 0.67, 0.0, 555, 0, 5, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "form", "field", "readonly_fields", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, form, field, readonly_fields=None, model_admin=None):\n self.form = form # A django.forms.Form instance\n if not hasattr(field, \"__iter__\"):\n self.fields = [field]\n else:\n self.fields = field\n self.model_admin = model_admin\n if readonly_fields is None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L89_C8", "label": "self.form =", "type": "assigned_variable", "loc": [89, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L88_C4", "vector": [14, 2, 0.2618, 0.0029, 2, 0.41, 0.0, 704, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.form = form # A django.forms.Form instance"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L90_C8", "label": "if", "type": "if", "loc": [90, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L88_C4", "vector": [4, 2, 0.2691, 0.0118, 2, 0.41, 0.25, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(field, \"__iter__\"):\n self.fields = [field]\n else:\n self.fields = field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L91_C12", "label": "self.fields =", "type": "assigned_variable", "loc": [91, 91], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L90_C8", "vector": [14, 3, 0.2676, 0.0029, 3, 0.23, 0.0, 318, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self.fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.fields = [field]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L93_C12", "label": "self.fields =", "type": "assigned_variable", "loc": [93, 93], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L90_C8", "vector": [14, 3, 0.2735, 0.0029, 3, 0.23, 1.0, 318, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.fields = field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L94_C8", "label": "self.model_admin =", "type": "assigned_variable", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L88_C4", "vector": [14, 2, 0.2765, 0.0029, 2, 0.41, 0.5, 2, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.model_admin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model_admin = model_admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L95_C8", "label": "if", "type": "if", "loc": [95, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L88_C4", "vector": [4, 2, 0.2809, 0.0059, 2, 0.41, 0.75, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if readonly_fields is None:\n readonly_fields = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L96_C12", "label": "readonly_fields =", "type": "assigned_variable", "loc": [96, 96], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L95_C8", "vector": [14, 3, 0.2824, 0.0029, 3, 0.07, 0.0, 396, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "readonly_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " readonly_fields = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L97_C8", "label": "self.readonly_fields =", "type": "assigned_variable", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L88_C4", "vector": [14, 2, 0.2853, 0.0029, 2, 0.41, 1.0, 627, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.readonly_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.readonly_fields = readonly_fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L99_C4", "label": "__iter__", "type": "function", "loc": [99, 105], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L87_C0", "vector": [2, 1, 0.3, 0.0206, 1, 0.67, 0.5, 891, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "__iter__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __iter__(self):\n for i, field in enumerate(self.fields):\n if field in self.readonly_fields:\n yield AdminReadonlyField(self.form, field, is_first=(i == 0),\n model_admin=self.model_admin)\n else:\n yield AdminField(self.form, field, is_first=(i == 0))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L100_C8", "label": "for i, field", "type": "for", "loc": [100, 105], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L99_C4", "vector": [6, 2, 0.3015, 0.0176, 2, 0.62, 0.0, 656, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "i, field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, field in enumerate(self.fields):\n if field in self.readonly_fields:\n yield AdminReadonlyField(self.form, field, is_first=(i == 0),\n model_admin=self.model_admin)\n else:\n yield AdminField(self.form, field, is_first=(i == 0))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L101_C12", "label": "if", "type": "if", "loc": [101, 105], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L100_C8", "vector": [4, 3, 0.3029, 0.0147, 3, 0.72, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field in self.readonly_fields:\n yield AdminReadonlyField(self.form, field, is_first=(i == 0),\n model_admin=self.model_admin)\n else:\n yield AdminField(self.form, field, is_first=(i == 0))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L102_C16", "label": "expression", "type": "expression", "loc": [102, 103], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L101_C12", "vector": [8, 4, 0.3015, 0.0059, 4, 0.38, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield AdminReadonlyField(self.form, field, is_first=(i == 0),\n model_admin=self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L105_C16", "label": "expression", "type": "expression", "loc": [105, 105], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L101_C12", "vector": [8, 4, 0.3088, 0.0029, 4, 0.38, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield AdminField(self.form, field, is_first=(i == 0))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L107_C4", "label": "errors", "type": "function", "loc": [107, 108], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L87_C0", "vector": [2, 1, 0.3162, 0.0059, 1, 0.67, 1.0, 841, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "errors", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def errors(self):\n return mark_safe(u'\\n'.join([self.form[f].errors.as_ul() for f in self.fields if f not in self.readonly_fields]).strip('\\n'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L108_C8", "label": "return", "type": "return", "loc": [108, 108], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L107_C4", "vector": [13, 2, 0.3176, 0.0029, 2, 0.94, 0.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u'\\n'.join([self.form[f].errors.as_ul() for f in self.fields if f not in self.readonly_fields]).strip('\\n'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L110_C0", "label": "AdminField", "type": "class", "loc": [110, 128], "level": 0, "parent": null, "vector": [3, 0, 0.35, 0.0559, 0, 0.66, 0.7308, 549, 0, 2, 0, 0, 186, 0, 10], "semantic": {"name": "AdminField", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminField(object):\n def __init__(self, form, field, is_first):\n self.field = form[field] # A django.forms.BoundField instance\n self.is_first = is_first # Whether this field is first on the line\n self.is_checkbox = isinstance(self.field.field.widget, forms.CheckboxInput)\n\n def label_tag(self):\n classes = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L111_C4", "label": "__init__", "type": "function", "loc": [111, 114], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L110_C0", "vector": [2, 1, 0.3309, 0.0118, 1, 0.12, 0.0, 555, 0, 4, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "form", "field", "is_first"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, form, field, is_first):\n self.field = form[field] # A django.forms.BoundField instance\n self.is_first = is_first # Whether this field is first on the line\n self.is_checkbox = isinstance(self.field.field.widget, forms.CheckboxInput)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L112_C8", "label": "self.field =", "type": "assigned_variable", "loc": [112, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L111_C4", "vector": [14, 2, 0.3294, 0.0029, 2, 0.69, 0.0, 951, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.field = form[field] # A django.forms.BoundField instance"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L113_C8", "label": "self.is_first =", "type": "assigned_variable", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L111_C4", "vector": [14, 2, 0.3324, 0.0029, 2, 0.69, 0.5, 329, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.is_first", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.is_first = is_first # Whether this field is first on the line"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L114_C8", "label": "self.is_checkbox = isinstance()", "type": "assigned_variable", "loc": [114, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L111_C4", "vector": [14, 2, 0.3353, 0.0029, 2, 0.69, 1.0, 926, 3, 2, 0, 0, 552, 10, 1], "semantic": {"name": "self.is_checkbox", "arg_names": [], "import_names": [], "rhs_call_name": "isinstance", "annotation": ""}, "snippet": " self.is_checkbox = isinstance(self.field.field.widget, forms.CheckboxInput)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "label": "label_tag", "type": "function", "loc": [116, 128], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L110_C0", "vector": [2, 1, 0.3588, 0.0382, 1, 0.12, 1.0, 775, 0, 1, 1, 0, 0, 0, 9], "semantic": {"name": "label_tag", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def label_tag(self):\n classes = []\n if self.is_checkbox:\n classes.append(u'vCheckboxLabel')\n contents = force_unicode(escape(self.field.label))\n else:\n contents = force_unicode(escape(self.field.label)) + u':'\n if self.field.field.required:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L117_C8", "label": "classes =", "type": "assigned_variable", "loc": [117, 117], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "vector": [14, 2, 0.3441, 0.0029, 2, 0.41, 0.0, 124, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "classes", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " classes = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L118_C8", "label": "if", "type": "if", "loc": [118, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "vector": [4, 2, 0.3529, 0.0147, 2, 0.41, 0.2, 0, 7, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.is_checkbox:\n classes.append(u'vCheckboxLabel')\n contents = force_unicode(escape(self.field.label))\n else:\n contents = force_unicode(escape(self.field.label)) + u':'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L119_C12", "label": "append()", "type": "expression", "loc": [119, 119], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L118_C8", "vector": [8, 3, 0.35, 0.0029, 3, 0.01, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " classes.append(u'vCheckboxLabel')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L120_C12", "label": "contents = force_unicode()", "type": "assigned_variable", "loc": [120, 120], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L118_C8", "vector": [14, 3, 0.3529, 0.0029, 3, 0.01, 0.5, 376, 3, 1, 0, 0, 870, 10, 2], "semantic": {"name": "contents", "arg_names": [], "import_names": [], "rhs_call_name": "force_unicode", "annotation": ""}, "snippet": " contents = force_unicode(escape(self.field.label))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L122_C12", "label": "contents =", "type": "assigned_variable", "loc": [122, 122], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L118_C8", "vector": [14, 3, 0.3588, 0.0029, 3, 0.01, 1.0, 376, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "contents", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " contents = force_unicode(escape(self.field.label)) + u':'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L123_C8", "label": "if", "type": "if", "loc": [123, 124], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "vector": [4, 2, 0.3632, 0.0059, 2, 0.41, 0.4, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.field.field.required:\n classes.append(u'required')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L124_C12", "label": "append()", "type": "expression", "loc": [124, 124], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L123_C8", "vector": [8, 3, 0.3647, 0.0029, 3, 0.12, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " classes.append(u'required')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L125_C8", "label": "if", "type": "if", "loc": [125, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "vector": [4, 2, 0.3691, 0.0059, 2, 0.41, 0.6, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.is_first:\n classes.append(u'inline')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L126_C12", "label": "append()", "type": "expression", "loc": [126, 126], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L125_C8", "vector": [8, 3, 0.3706, 0.0029, 3, 0.94, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " classes.append(u'inline')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L127_C8", "label": "attrs =", "type": "assigned_variable", "loc": [127, 127], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "vector": [14, 2, 0.3735, 0.0029, 2, 0.41, 0.8, 251, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs = classes and {'class': u' '.join(classes)} or {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L128_C8", "label": "return", "type": "return", "loc": [128, 128], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "vector": [13, 2, 0.3765, 0.0029, 2, 0.41, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.field.label_tag(contents=contents, attrs=attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L130_C0", "label": "AdminReadonlyField", "type": "class", "loc": [130, 186], "level": 0, "parent": null, "vector": [3, 0, 0.4647, 0.1676, 0, 0.66, 0.7692, 290, 0, 3, 0, 0, 186, 0, 19], "semantic": {"name": "AdminReadonlyField", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminReadonlyField(object):\n def __init__(self, form, field, is_first, model_admin=None):\n label = label_for_field(field, form._meta.model, model_admin)\n # Make self.field look a little bit like a field. This means that\n # {{ field.name }} must be a useful class name to identify the field.\n # For convenience, store other field-related data here too.\n if callable(field):\n class_name = field.__name__ != '<lambda>' and field.__name__ or ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "label": "__init__", "type": "function", "loc": [131, 149], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L130_C0", "vector": [2, 1, 0.4118, 0.0559, 1, 0.79, 0.0, 555, 0, 5, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "form", "field", "is_first", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, form, field, is_first, model_admin=None):\n label = label_for_field(field, form._meta.model, model_admin)\n # Make self.field look a little bit like a field. This means that\n # {{ field.name }} must be a useful class name to identify the field.\n # For convenience, store other field-related data here too.\n if callable(field):\n class_name = field.__name__ != '<lambda>' and field.__name__ or ''\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L132_C8", "label": "label = label_for_field()", "type": "assigned_variable", "loc": [132, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "vector": [14, 2, 0.3882, 0.0029, 2, 0.88, 0.0, 811, 3, 3, 0, 0, 777, 10, 1], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "label_for_field", "annotation": ""}, "snippet": " label = label_for_field(field, form._meta.model, model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L136_C8", "label": "if", "type": "if", "loc": [136, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "vector": [4, 2, 0.4044, 0.0118, 2, 0.88, 0.1429, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if callable(field):\n class_name = field.__name__ != '<lambda>' and field.__name__ or ''\n else:\n class_name = field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L137_C12", "label": "class_name =", "type": "assigned_variable", "loc": [137, 137], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L136_C8", "vector": [14, 3, 0.4029, 0.0029, 3, 0.17, 0.0, 758, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "class_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class_name = field.__name__ != '<lambda>' and field.__name__ or ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L139_C12", "label": "class_name =", "type": "assigned_variable", "loc": [139, 139], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L136_C8", "vector": [14, 3, 0.4088, 0.0029, 3, 0.17, 1.0, 758, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "class_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class_name = field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L140_C8", "label": "self.field =", "type": "assigned_variable", "loc": [140, 144], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "vector": [14, 2, 0.4176, 0.0147, 2, 0.88, 0.2857, 951, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "self.field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.field = {\n 'name': class_name,\n 'label': label,\n 'field': field,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L145_C8", "label": "self.form =", "type": "assigned_variable", "loc": [145, 145], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "vector": [14, 2, 0.4265, 0.0029, 2, 0.88, 0.4286, 704, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.form = form"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L146_C8", "label": "self.model_admin =", "type": "assigned_variable", "loc": [146, 146], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "vector": [14, 2, 0.4294, 0.0029, 2, 0.88, 0.5714, 2, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.model_admin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model_admin = model_admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L147_C8", "label": "self.is_first =", "type": "assigned_variable", "loc": [147, 147], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "vector": [14, 2, 0.4324, 0.0029, 2, 0.88, 0.7143, 329, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.is_first", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.is_first = is_first"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L148_C8", "label": "self.is_checkbox =", "type": "assigned_variable", "loc": [148, 148], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "vector": [14, 2, 0.4353, 0.0029, 2, 0.88, 0.8571, 926, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self.is_checkbox", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.is_checkbox = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L149_C8", "label": "self.is_readonly =", "type": "assigned_variable", "loc": [149, 149], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "vector": [14, 2, 0.4382, 0.0029, 2, 0.88, 1.0, 172, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self.is_readonly", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.is_readonly = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L151_C4", "label": "label_tag", "type": "function", "loc": [151, 160], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L130_C0", "vector": [2, 1, 0.4574, 0.0294, 1, 0.79, 0.5, 775, 0, 1, 1, 0, 0, 0, 5], "semantic": {"name": "label_tag", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def label_tag(self):\n attrs = {}\n if not self.is_first:\n attrs[\"class\"] = \"inline\"\n label = self.field['label']\n contents = capfirst(force_unicode(escape(label))) + u\":\"\n return mark_safe('<label%(attrs)s>%(contents)s</label>' % {\n \"attrs\": flatatt(attrs),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L152_C8", "label": "attrs =", "type": "assigned_variable", "loc": [152, 152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L151_C4", "vector": [14, 2, 0.4471, 0.0029, 2, 0.44, 0.0, 251, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L153_C8", "label": "if", "type": "if", "loc": [153, 154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L151_C4", "vector": [4, 2, 0.4515, 0.0059, 2, 0.44, 0.25, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.is_first:\n attrs[\"class\"] = \"inline\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L154_C12", "label": "assign", "type": "assigned_variable", "loc": [154, 154], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L153_C8", "vector": [14, 3, 0.4529, 0.0029, 3, 0.03, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs[\"class\"] = \"inline\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L155_C8", "label": "label =", "type": "assigned_variable", "loc": [155, 155], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L151_C4", "vector": [14, 2, 0.4559, 0.0029, 2, 0.44, 0.5, 811, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " label = self.field['label']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L156_C8", "label": "contents =", "type": "assigned_variable", "loc": [156, 156], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L151_C4", "vector": [14, 2, 0.4588, 0.0029, 2, 0.44, 0.75, 376, 4, 0, 0, 0, 0, 0, 3], "semantic": {"name": "contents", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " contents = capfirst(force_unicode(escape(label))) + u\":\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L157_C8", "label": "return", "type": "return", "loc": [157, 160], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L151_C4", "vector": [13, 2, 0.4662, 0.0118, 2, 0.44, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe('<label%(attrs)s>%(contents)s</label>' % {\n \"attrs\": flatatt(attrs),\n \"contents\": contents,\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L162_C4", "label": "contents", "type": "function", "loc": [162, 186], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L130_C0", "vector": [2, 1, 0.5118, 0.0735, 1, 0.79, 1.0, 376, 0, 1, 1, 0, 0, 0, 12], "semantic": {"name": "contents", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def contents(self):\n from django.contrib.admin.templatetags.admin_list import _boolean_icon\n from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE\n field, obj, model_admin = self.field['field'], self.form.instance, self.model_admin\n try:\n f, attr, value = lookup_field(field, obj, model_admin)\n except (AttributeError, ValueError, ObjectDoesNotExist):\n result_repr = EMPTY_CHANGELIST_VALUE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L163_C8", "label": "from django.contrib.admin.templatetags.admin_list import _boolean_icon", "type": "import", "loc": [163, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L162_C4", "vector": [1, 2, 0.4794, 0.0029, 2, 0.48, 0.0, 261, 0, 1, 0, 0, 261, 0, 0], "semantic": {"name": "django.contrib.admin.templatetags.admin_list", "arg_names": [], "import_names": ["_boolean_icon"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.templatetags.admin_list import _boolean_icon"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L164_C8", "label": "from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE", "type": "import", "loc": [164, 164], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L162_C4", "vector": [1, 2, 0.4824, 0.0029, 2, 0.48, 0.25, 696, 0, 1, 0, 0, 696, 0, 0], "semantic": {"name": "django.contrib.admin.views.main", "arg_names": [], "import_names": ["EMPTY_CHANGELIST_VALUE"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L165_C8", "label": "field, obj, model_admin =", "type": "assigned_variable", "loc": [165, 165], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L162_C4", "vector": [14, 2, 0.4853, 0.0029, 2, 0.48, 0.5, 631, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "field, obj, model_admin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field, obj, model_admin = self.field['field'], self.form.instance, self.model_admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L166_C8", "label": "try", "type": "try", "loc": [166, 185], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L162_C4", "vector": [7, 2, 0.5162, 0.0588, 2, 0.48, 0.75, 0, 0, 1, 0, 0, 0, 0, 11], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n f, attr, value = lookup_field(field, obj, model_admin)\n except (AttributeError, ValueError, ObjectDoesNotExist):\n result_repr = EMPTY_CHANGELIST_VALUE\n else:\n if f is None:\n boolean = getattr(attr, \"boolean\", False)\n if boolean:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L167_C12", "label": "f, attr, value = lookup_field()", "type": "assigned_variable", "loc": [167, 167], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L166_C8", "vector": [14, 3, 0.4912, 0.0029, 3, 0.13, 0.0, 68, 3, 3, 0, 0, 514, 10, 1], "semantic": {"name": "f, attr, value", "arg_names": [], "import_names": [], "rhs_call_name": "lookup_field", "annotation": ""}, "snippet": " f, attr, value = lookup_field(field, obj, model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L169_C12", "label": "result_repr =", "type": "assigned_variable", "loc": [169, 169], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L166_C8", "vector": [14, 3, 0.4971, 0.0029, 3, 0.13, 0.0, 760, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result_repr = EMPTY_CHANGELIST_VALUE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L171_C12", "label": "if", "type": "if", "loc": [171, 185], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L166_C8", "vector": [4, 3, 0.5235, 0.0441, 3, 0.13, 1.0, 0, 0, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f is None:\n boolean = getattr(attr, \"boolean\", False)\n if boolean:\n result_repr = _boolean_icon(value)\n else:\n result_repr = smart_unicode(value)\n if getattr(attr, \"allow_tags\", False):\n result_repr = mark_safe(result_repr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L172_C16", "label": "boolean = getattr()", "type": "assigned_variable", "loc": [172, 172], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L171_C12", "vector": [14, 4, 0.5059, 0.0029, 4, 0.91, 0.0, 756, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "boolean", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " boolean = getattr(attr, \"boolean\", False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L173_C16", "label": "if", "type": "if", "loc": [173, 178], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L171_C12", "vector": [4, 4, 0.5162, 0.0176, 4, 0.91, 0.5, 0, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if boolean:\n result_repr = _boolean_icon(value)\n else:\n result_repr = smart_unicode(value)\n if getattr(attr, \"allow_tags\", False):\n result_repr = mark_safe(result_repr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L174_C20", "label": "result_repr = _boolean_icon()", "type": "assigned_variable", "loc": [174, 174], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L173_C16", "vector": [14, 5, 0.5118, 0.0029, 5, 0.41, 0.0, 760, 3, 1, 0, 0, 113, 10, 1], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "_boolean_icon", "annotation": ""}, "snippet": " result_repr = _boolean_icon(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L176_C20", "label": "result_repr = smart_unicode()", "type": "assigned_variable", "loc": [176, 176], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L173_C16", "vector": [14, 5, 0.5176, 0.0029, 5, 0.41, 0.5, 760, 3, 1, 0, 0, 349, 10, 1], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "smart_unicode", "annotation": ""}, "snippet": " result_repr = smart_unicode(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L177_C20", "label": "if", "type": "if", "loc": [177, 178], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L173_C16", "vector": [4, 5, 0.5221, 0.0059, 5, 0.41, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if getattr(attr, \"allow_tags\", False):\n result_repr = mark_safe(result_repr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L178_C24", "label": "result_repr = mark_safe()", "type": "assigned_variable", "loc": [178, 178], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L177_C20", "vector": [14, 6, 0.5235, 0.0029, 6, 0.06, 0.0, 760, 3, 1, 0, 0, 159, 10, 1], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "mark_safe", "annotation": ""}, "snippet": " result_repr = mark_safe(result_repr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L180_C16", "label": "if", "type": "if", "loc": [180, 185], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L171_C12", "vector": [4, 4, 0.5368, 0.0176, 4, 0.91, 1.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value is None:\n result_repr = EMPTY_CHANGELIST_VALUE\n elif isinstance(f.rel, ManyToManyRel):\n result_repr = \", \".join(map(unicode, value.all()))\n else:\n result_repr = display_for_field(value, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L181_C20", "label": "result_repr =", "type": "assigned_variable", "loc": [181, 181], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L180_C16", "vector": [14, 5, 0.5324, 0.0029, 5, 0.33, 0.0, 760, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result_repr = EMPTY_CHANGELIST_VALUE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L182_C16", "label": "if", "type": "if", "loc": [182, 185], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L180_C16", "vector": [4, 5, 0.5397, 0.0118, 5, 0.33, 1.0, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(f.rel, ManyToManyRel):\n result_repr = \", \".join(map(unicode, value.all()))\n else:\n result_repr = display_for_field(value, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L183_C20", "label": "result_repr = join()", "type": "assigned_variable", "loc": [183, 183], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L182_C16", "vector": [14, 6, 0.5382, 0.0029, 6, 0.52, 0.0, 760, 3, 1, 0, 0, 933, 10, 3], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " result_repr = \", \".join(map(unicode, value.all()))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L185_C20", "label": "result_repr = display_for_field()", "type": "assigned_variable", "loc": [185, 185], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L182_C16", "vector": [14, 6, 0.5441, 0.0029, 6, 0.52, 1.0, 760, 3, 2, 0, 0, 12, 10, 1], "semantic": {"name": "result_repr", "arg_names": [], "import_names": [], "rhs_call_name": "display_for_field", "annotation": ""}, "snippet": " result_repr = display_for_field(value, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L186_C8", "label": "return", "type": "return", "loc": [186, 186], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L162_C4", "vector": [13, 2, 0.5471, 0.0029, 2, 0.48, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return conditional_escape(result_repr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "label": "InlineAdminFormSet", "type": "class", "loc": [188, 235], "level": 0, "parent": null, "vector": [3, 0, 0.6221, 0.1412, 0, 0.66, 0.8077, 185, 0, 4, 0, 0, 186, 0, 10], "semantic": {"name": "InlineAdminFormSet", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class InlineAdminFormSet(object):\n \"\"\"\n A wrapper around an inline formset for use in the admin system.\n \"\"\"\n def __init__(self, inline, formset, fieldsets, readonly_fields=None, model_admin=None):\n self.opts = inline\n self.formset = formset\n self.fieldsets = fieldsets"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L189_C4", "label": "expression", "type": "expression", "loc": [189, 191], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "vector": [8, 1, 0.5588, 0.0088, 1, 0.29, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A wrapper around an inline formset for use in the admin system.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "label": "__init__", "type": "function", "loc": [192, 199], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "vector": [2, 1, 0.575, 0.0235, 1, 0.29, 0.2, 555, 0, 6, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "inline", "formset", "fieldsets", "readonly_fields", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, inline, formset, fieldsets, readonly_fields=None, model_admin=None):\n self.opts = inline\n self.formset = formset\n self.fieldsets = fieldsets\n self.model_admin = model_admin\n if readonly_fields is None:\n readonly_fields = ()\n self.readonly_fields = readonly_fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L193_C8", "label": "self.opts =", "type": "assigned_variable", "loc": [193, 193], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "vector": [14, 2, 0.5676, 0.0029, 2, 0.26, 0.0, 26, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.opts = inline"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L194_C8", "label": "self.formset =", "type": "assigned_variable", "loc": [194, 194], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "vector": [14, 2, 0.5706, 0.0029, 2, 0.26, 0.2, 991, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.formset = formset"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L195_C8", "label": "self.fieldsets =", "type": "assigned_variable", "loc": [195, 195], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "vector": [14, 2, 0.5735, 0.0029, 2, 0.26, 0.4, 318, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.fieldsets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.fieldsets = fieldsets"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L196_C8", "label": "self.model_admin =", "type": "assigned_variable", "loc": [196, 196], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "vector": [14, 2, 0.5765, 0.0029, 2, 0.26, 0.6, 2, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.model_admin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model_admin = model_admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L197_C8", "label": "if", "type": "if", "loc": [197, 198], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "vector": [4, 2, 0.5809, 0.0059, 2, 0.26, 0.8, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if readonly_fields is None:\n readonly_fields = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L198_C12", "label": "readonly_fields =", "type": "assigned_variable", "loc": [198, 198], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L197_C8", "vector": [14, 3, 0.5824, 0.0029, 3, 0.33, 0.0, 396, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "readonly_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " readonly_fields = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L199_C8", "label": "self.readonly_fields =", "type": "assigned_variable", "loc": [199, 199], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "vector": [14, 2, 0.5853, 0.0029, 2, 0.26, 1.0, 627, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.readonly_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.readonly_fields = readonly_fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L201_C4", "label": "__iter__", "type": "function", "loc": [201, 212], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "vector": [2, 1, 0.6074, 0.0353, 1, 0.29, 0.4, 891, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "__iter__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __iter__(self):\n for form, original in zip(self.formset.initial_forms, self.formset.get_queryset()):\n yield InlineAdminForm(self.formset, form, self.fieldsets,\n self.opts.prepopulated_fields, original, self.readonly_fields,\n model_admin=self.model_admin)\n for form in self.formset.extra_forms:\n yield InlineAdminForm(self.formset, form, self.fieldsets,\n self.opts.prepopulated_fields, None, self.readonly_fields,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L202_C8", "label": "for form, original", "type": "for", "loc": [202, 205], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L201_C4", "vector": [6, 2, 0.5985, 0.0118, 2, 0.72, 0.0, 783, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "form, original", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for form, original in zip(self.formset.initial_forms, self.formset.get_queryset()):\n yield InlineAdminForm(self.formset, form, self.fieldsets,\n self.opts.prepopulated_fields, original, self.readonly_fields,\n model_admin=self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L203_C12", "label": "expression", "type": "expression", "loc": [203, 205], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L202_C8", "vector": [8, 3, 0.6, 0.0088, 3, 0.21, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield InlineAdminForm(self.formset, form, self.fieldsets,\n self.opts.prepopulated_fields, original, self.readonly_fields,\n model_admin=self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L206_C8", "label": "for form", "type": "for", "loc": [206, 209], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L201_C4", "vector": [6, 2, 0.6103, 0.0118, 2, 0.72, 0.5, 761, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for form in self.formset.extra_forms:\n yield InlineAdminForm(self.formset, form, self.fieldsets,\n self.opts.prepopulated_fields, None, self.readonly_fields,\n model_admin=self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L207_C12", "label": "expression", "type": "expression", "loc": [207, 209], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L206_C8", "vector": [8, 3, 0.6118, 0.0088, 3, 0.42, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield InlineAdminForm(self.formset, form, self.fieldsets,\n self.opts.prepopulated_fields, None, self.readonly_fields,\n model_admin=self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L210_C8", "label": "expression", "type": "expression", "loc": [210, 212], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L201_C4", "vector": [8, 2, 0.6206, 0.0088, 2, 0.72, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield InlineAdminForm(self.formset, self.formset.empty_form,\n self.fieldsets, self.opts.prepopulated_fields, None,\n self.readonly_fields, model_admin=self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L214_C4", "label": "fields", "type": "function", "loc": [214, 228], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "vector": [2, 1, 0.65, 0.0441, 1, 0.29, 0.6, 358, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "fields", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def fields(self):\n fk = getattr(self.formset, \"fk\", None)\n for i, field in enumerate(flatten_fieldsets(self.fieldsets)):\n if fk and fk.name == field:\n continue\n if field in self.readonly_fields:\n yield {\n 'label': label_for_field(field, self.opts.model, self.model_admin),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L215_C8", "label": "fk = getattr()", "type": "assigned_variable", "loc": [215, 215], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L214_C4", "vector": [14, 2, 0.6324, 0.0029, 2, 0.49, 0.0, 714, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "fk", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " fk = getattr(self.formset, \"fk\", None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L216_C8", "label": "for i, field", "type": "for", "loc": [216, 228], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L214_C4", "vector": [6, 2, 0.6529, 0.0382, 2, 0.49, 1.0, 656, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "i, field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, field in enumerate(flatten_fieldsets(self.fieldsets)):\n if fk and fk.name == field:\n continue\n if field in self.readonly_fields:\n yield {\n 'label': label_for_field(field, self.opts.model, self.model_admin),\n 'widget': {\n 'is_hidden': False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L217_C12", "label": "if", "type": "if", "loc": [217, 218], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L216_C8", "vector": [4, 3, 0.6397, 0.0059, 3, 0.41, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if fk and fk.name == field:\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L219_C12", "label": "if", "type": "if", "loc": [219, 228], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L216_C8", "vector": [4, 3, 0.6574, 0.0294, 3, 0.41, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field in self.readonly_fields:\n yield {\n 'label': label_for_field(field, self.opts.model, self.model_admin),\n 'widget': {\n 'is_hidden': False\n },\n 'required': False\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L220_C16", "label": "expression", "type": "expression", "loc": [220, 226], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L219_C12", "vector": [8, 4, 0.6559, 0.0206, 4, 0.06, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {\n 'label': label_for_field(field, self.opts.model, self.model_admin),\n 'widget': {\n 'is_hidden': False\n },\n 'required': False\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L228_C16", "label": "expression", "type": "expression", "loc": [228, 228], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L219_C12", "vector": [8, 4, 0.6706, 0.0029, 4, 0.06, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield self.formset.form.base_fields[field]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L230_C4", "label": "_media", "type": "function", "loc": [230, 234], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "vector": [2, 1, 0.6824, 0.0147, 1, 0.29, 0.8, 650, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "_media", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _media(self):\n media = self.opts.media + self.formset.media\n for fs in self:\n media = media + fs.media\n return media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L231_C8", "label": "media =", "type": "assigned_variable", "loc": [231, 231], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L230_C4", "vector": [14, 2, 0.6794, 0.0029, 2, 0.69, 0.0, 317, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " media = self.opts.media + self.formset.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L232_C8", "label": "for fs", "type": "for", "loc": [232, 233], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L230_C4", "vector": [6, 2, 0.6838, 0.0059, 2, 0.69, 0.5, 245, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "fs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for fs in self:\n media = media + fs.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L233_C12", "label": "media =", "type": "assigned_variable", "loc": [233, 233], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L232_C8", "vector": [14, 3, 0.6853, 0.0029, 3, 0.04, 0.0, 317, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " media = media + fs.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L234_C8", "label": "return", "type": "return", "loc": [234, 234], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L230_C4", "vector": [13, 2, 0.6882, 0.0029, 2, 0.69, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L235_C4", "label": "media = property()", "type": "assigned_variable", "loc": [235, 235], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "vector": [14, 1, 0.6912, 0.0029, 1, 0.29, 1.0, 317, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " media = property(_media)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "label": "InlineAdminForm", "type": "class", "loc": [237, 294], "level": 0, "parent": null, "vector": [3, 0, 0.7809, 0.1706, 0, 0.66, 0.8462, 627, 0, 8, 0, 0, 529, 0, 13], "semantic": {"name": "InlineAdminForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class InlineAdminForm(AdminForm):\n \"\"\"\n A wrapper around an inline form for use in the admin system.\n \"\"\"\n def __init__(self, formset, form, fieldsets, prepopulated_fields, original,\n readonly_fields=None, model_admin=None):\n self.formset = formset\n self.model_admin = model_admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L238_C4", "label": "expression", "type": "expression", "loc": [238, 240], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "vector": [8, 1, 0.7029, 0.0088, 1, 0.56, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A wrapper around an inline form for use in the admin system.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "label": "__init__", "type": "function", "loc": [241, 250], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "vector": [2, 1, 0.7221, 0.0294, 1, 0.56, 0.125, 555, 0, 8, 0, 0, 0, 0, 4], "semantic": {"name": "__init__", "arg_names": ["self", "formset", "form", "fieldsets", "prepopulated_fields", "original", "readonly_fields", "model_admin"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, formset, form, fieldsets, prepopulated_fields, original,\n readonly_fields=None, model_admin=None):\n self.formset = formset\n self.model_admin = model_admin\n self.original = original\n if original is not None:\n self.original_content_type_id = ContentType.objects.get_for_model(original).pk\n self.show_url = original and hasattr(original, 'get_absolute_url')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L243_C8", "label": "self.formset =", "type": "assigned_variable", "loc": [243, 243], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "vector": [14, 2, 0.7147, 0.0029, 2, 0.75, 0.0, 991, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.formset = formset"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L244_C8", "label": "self.model_admin =", "type": "assigned_variable", "loc": [244, 244], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "vector": [14, 2, 0.7176, 0.0029, 2, 0.75, 0.2, 2, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.model_admin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model_admin = model_admin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L245_C8", "label": "self.original =", "type": "assigned_variable", "loc": [245, 245], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "vector": [14, 2, 0.7206, 0.0029, 2, 0.75, 0.4, 224, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.original", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.original = original"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L246_C8", "label": "if", "type": "if", "loc": [246, 247], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "vector": [4, 2, 0.725, 0.0059, 2, 0.75, 0.6, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if original is not None:\n self.original_content_type_id = ContentType.objects.get_for_model(original).pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L247_C12", "label": "self.original_content_type_id =", "type": "assigned_variable", "loc": [247, 247], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L246_C8", "vector": [14, 3, 0.7265, 0.0029, 3, 0.39, 0.0, 307, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "self.original_content_type_id", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.original_content_type_id = ContentType.objects.get_for_model(original).pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L248_C8", "label": "self.show_url =", "type": "assigned_variable", "loc": [248, 248], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "vector": [14, 2, 0.7294, 0.0029, 2, 0.75, 0.8, 841, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "self.show_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.show_url = original and hasattr(original, 'get_absolute_url')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L249_C8", "label": "__init__()", "type": "expression", "loc": [249, 250], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "vector": [8, 2, 0.7338, 0.0059, 2, 0.75, 1.0, 555, 3, 5, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(InlineAdminForm, self).__init__(form, fieldsets, prepopulated_fields,\n readonly_fields, model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L252_C4", "label": "__iter__", "type": "function", "loc": [252, 255], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "vector": [2, 1, 0.7456, 0.0118, 1, 0.56, 0.25, 891, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "__iter__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __iter__(self):\n for name, options in self.fieldsets:\n yield InlineFieldset(self.formset, self.form, name,\n self.readonly_fields, model_admin=self.model_admin, **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L253_C8", "label": "for name, options", "type": "for", "loc": [253, 255], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L252_C4", "vector": [6, 2, 0.7471, 0.0088, 2, 0.75, 0.0, 992, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "name, options", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name, options in self.fieldsets:\n yield InlineFieldset(self.formset, self.form, name,\n self.readonly_fields, model_admin=self.model_admin, **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L254_C12", "label": "expression", "type": "expression", "loc": [254, 255], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L253_C8", "vector": [8, 3, 0.7485, 0.0059, 3, 0.69, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield InlineFieldset(self.formset, self.form, name,\n self.readonly_fields, model_admin=self.model_admin, **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L257_C4", "label": "has_auto_field", "type": "function", "loc": [257, 264], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "vector": [2, 1, 0.7662, 0.0235, 1, 0.56, 0.375, 641, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "has_auto_field", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_auto_field(self):\n if self.form._meta.model._meta.has_auto_field:\n return True\n # Also search any parents for an auto field.\n for parent in self.form._meta.model._meta.get_parent_list():\n if parent._meta.has_auto_field:\n return True\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L258_C8", "label": "if", "type": "if", "loc": [258, 259], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L257_C4", "vector": [4, 2, 0.7603, 0.0059, 2, 0.26, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.form._meta.model._meta.has_auto_field:\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L259_C12", "label": "return", "type": "return", "loc": [259, 259], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L258_C8", "vector": [13, 3, 0.7618, 0.0029, 3, 0.86, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L261_C8", "label": "for parent", "type": "for", "loc": [261, 263], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L257_C4", "vector": [6, 2, 0.7706, 0.0088, 2, 0.26, 0.5, 80, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "parent", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for parent in self.form._meta.model._meta.get_parent_list():\n if parent._meta.has_auto_field:\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L262_C12", "label": "if", "type": "if", "loc": [262, 263], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L261_C8", "vector": [4, 3, 0.7721, 0.0059, 3, 0.03, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if parent._meta.has_auto_field:\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L263_C16", "label": "return", "type": "return", "loc": [263, 263], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L262_C12", "vector": [13, 4, 0.7735, 0.0029, 4, 0.0, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L264_C8", "label": "return", "type": "return", "loc": [264, 264], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L257_C4", "vector": [13, 2, 0.7765, 0.0029, 2, 0.26, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L266_C4", "label": "field_count", "type": "function", "loc": [266, 276], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "vector": [2, 1, 0.7971, 0.0324, 1, 0.56, 0.5, 951, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "field_count", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def field_count(self):\n # tabular.html uses this function for colspan value.\n num_of_fields = 0\n if self.has_auto_field():\n num_of_fields += 1\n num_of_fields += len(self.fieldsets[0][1][\"fields\"])\n if self.formset.can_order:\n num_of_fields += 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L268_C8", "label": "num_of_fields =", "type": "assigned_variable", "loc": [268, 268], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L266_C4", "vector": [14, 2, 0.7882, 0.0029, 2, 0.62, 0.0, 399, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "num_of_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " num_of_fields = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L269_C8", "label": "if", "type": "if", "loc": [269, 270], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L266_C4", "vector": [4, 2, 0.7926, 0.0059, 2, 0.62, 0.25, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.has_auto_field():\n num_of_fields += 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L272_C8", "label": "if", "type": "if", "loc": [272, 273], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L266_C4", "vector": [4, 2, 0.8015, 0.0059, 2, 0.62, 0.5, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.formset.can_order:\n num_of_fields += 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L274_C8", "label": "if", "type": "if", "loc": [274, 275], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L266_C4", "vector": [4, 2, 0.8074, 0.0059, 2, 0.62, 0.75, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.formset.can_delete:\n num_of_fields += 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L276_C8", "label": "return", "type": "return", "loc": [276, 276], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L266_C4", "vector": [13, 2, 0.8118, 0.0029, 2, 0.62, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return num_of_fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L278_C4", "label": "pk_field", "type": "function", "loc": [278, 279], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "vector": [2, 1, 0.8191, 0.0059, 1, 0.56, 0.625, 871, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "pk_field", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def pk_field(self):\n return AdminField(self.form, self.formset._pk_field.name, False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L279_C8", "label": "return", "type": "return", "loc": [279, 279], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L278_C4", "vector": [13, 2, 0.8206, 0.0029, 2, 0.41, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return AdminField(self.form, self.formset._pk_field.name, False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L281_C4", "label": "fk_field", "type": "function", "loc": [281, 286], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "vector": [2, 1, 0.8338, 0.0176, 1, 0.56, 0.75, 45, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "fk_field", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def fk_field(self):\n fk = getattr(self.formset, \"fk\", None)\n if fk:\n return AdminField(self.form, fk.name, False)\n else:\n return \"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L282_C8", "label": "fk = getattr()", "type": "assigned_variable", "loc": [282, 282], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L281_C4", "vector": [14, 2, 0.8294, 0.0029, 2, 0.92, 0.0, 714, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "fk", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " fk = getattr(self.formset, \"fk\", None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L283_C8", "label": "if", "type": "if", "loc": [283, 286], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L281_C4", "vector": [4, 2, 0.8368, 0.0118, 2, 0.92, 1.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if fk:\n return AdminField(self.form, fk.name, False)\n else:\n return \"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L284_C12", "label": "return", "type": "return", "loc": [284, 284], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L283_C8", "vector": [13, 3, 0.8353, 0.0029, 3, 0.98, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return AdminField(self.form, fk.name, False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L286_C12", "label": "return", "type": "return", "loc": [286, 286], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L283_C8", "vector": [13, 3, 0.8412, 0.0029, 3, 0.98, 1.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L288_C4", "label": "deletion_field", "type": "function", "loc": [288, 290], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "vector": [2, 1, 0.85, 0.0088, 1, 0.56, 0.875, 379, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "deletion_field", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def deletion_field(self):\n from django.forms.formsets import DELETION_FIELD_NAME\n return AdminField(self.form, DELETION_FIELD_NAME, False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L289_C8", "label": "from django.forms.formsets import DELETION_FIELD_NAME", "type": "import", "loc": [289, 289], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L288_C4", "vector": [1, 2, 0.85, 0.0029, 2, 0.3, 0.0, 42, 0, 1, 0, 0, 42, 0, 0], "semantic": {"name": "django.forms.formsets", "arg_names": [], "import_names": ["DELETION_FIELD_NAME"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.forms.formsets import DELETION_FIELD_NAME"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L290_C8", "label": "return", "type": "return", "loc": [290, 290], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L288_C4", "vector": [13, 2, 0.8529, 0.0029, 2, 0.3, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return AdminField(self.form, DELETION_FIELD_NAME, False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L292_C4", "label": "ordering_field", "type": "function", "loc": [292, 294], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "vector": [2, 1, 0.8618, 0.0088, 1, 0.56, 1.0, 904, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "ordering_field", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def ordering_field(self):\n from django.forms.formsets import ORDERING_FIELD_NAME\n return AdminField(self.form, ORDERING_FIELD_NAME, False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L293_C8", "label": "from django.forms.formsets import ORDERING_FIELD_NAME", "type": "import", "loc": [293, 293], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L292_C4", "vector": [1, 2, 0.8618, 0.0029, 2, 0.8, 0.0, 42, 0, 1, 0, 0, 42, 0, 0], "semantic": {"name": "django.forms.formsets", "arg_names": [], "import_names": ["ORDERING_FIELD_NAME"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.forms.formsets import ORDERING_FIELD_NAME"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L294_C8", "label": "return", "type": "return", "loc": [294, 294], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L292_C4", "vector": [13, 2, 0.8647, 0.0029, 2, 0.8, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return AdminField(self.form, ORDERING_FIELD_NAME, False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L296_C0", "label": "InlineFieldset", "type": "class", "loc": [296, 307], "level": 0, "parent": null, "vector": [3, 0, 0.8868, 0.0353, 0, 0.66, 0.8846, 619, 0, 2, 0, 0, 644, 0, 4], "semantic": {"name": "InlineFieldset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class InlineFieldset(Fieldset):\n def __init__(self, formset, *args, **kwargs):\n self.formset = formset\n super(InlineFieldset, self).__init__(*args, **kwargs)\n\n def __iter__(self):\n fk = getattr(self.formset, \"fk\", None)\n for field in self.fields:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L297_C4", "label": "__init__", "type": "function", "loc": [297, 299], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L296_C0", "vector": [2, 1, 0.8765, 0.0088, 1, 0.57, 0.0, 555, 0, 4, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "formset", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, formset, *args, **kwargs):\n self.formset = formset\n super(InlineFieldset, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L298_C8", "label": "self.formset =", "type": "assigned_variable", "loc": [298, 298], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L297_C4", "vector": [14, 2, 0.8765, 0.0029, 2, 0.26, 0.0, 991, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.formset = formset"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L299_C8", "label": "__init__()", "type": "expression", "loc": [299, 299], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L297_C4", "vector": [8, 2, 0.8794, 0.0029, 2, 0.26, 1.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(InlineFieldset, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L301_C4", "label": "__iter__", "type": "function", "loc": [301, 307], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L296_C0", "vector": [2, 1, 0.8941, 0.0206, 1, 0.57, 1.0, 891, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "__iter__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __iter__(self):\n fk = getattr(self.formset, \"fk\", None)\n for field in self.fields:\n if fk and fk.name == field:\n continue\n yield Fieldline(self.form, field, self.readonly_fields,\n model_admin=self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L302_C8", "label": "fk = getattr()", "type": "assigned_variable", "loc": [302, 302], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L301_C4", "vector": [14, 2, 0.8882, 0.0029, 2, 0.62, 0.0, 714, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "fk", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " fk = getattr(self.formset, \"fk\", None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L303_C8", "label": "for field", "type": "for", "loc": [303, 307], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L301_C4", "vector": [6, 2, 0.8971, 0.0147, 2, 0.62, 1.0, 480, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field in self.fields:\n if fk and fk.name == field:\n continue\n yield Fieldline(self.form, field, self.readonly_fields,\n model_admin=self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L304_C12", "label": "if", "type": "if", "loc": [304, 305], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L303_C8", "vector": [4, 3, 0.8956, 0.0059, 3, 0.03, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if fk and fk.name == field:\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L306_C12", "label": "expression", "type": "expression", "loc": [306, 307], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L303_C8", "vector": [8, 3, 0.9015, 0.0059, 3, 0.03, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield Fieldline(self.form, field, self.readonly_fields,\n model_admin=self.model_admin)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L309_C0", "label": "AdminErrorList", "type": "class", "loc": [309, 319], "level": 0, "parent": null, "vector": [3, 0, 0.9235, 0.0324, 0, 0.66, 0.9231, 508, 0, 1, 0, 0, 811, 0, 6], "semantic": {"name": "AdminErrorList", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminErrorList(forms.util.ErrorList):\n \"\"\"\n Stores all errors for the form/formsets in an add/change stage view.\n \"\"\"\n def __init__(self, form, inline_formsets):\n if form.is_bound:\n self.extend(form.errors.values())\n for inline_formset in inline_formsets:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L310_C4", "label": "expression", "type": "expression", "loc": [310, 312], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L309_C0", "vector": [8, 1, 0.9147, 0.0088, 1, 0.09, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Stores all errors for the form/formsets in an add/change stage view.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L313_C4", "label": "__init__", "type": "function", "loc": [313, 319], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L309_C0", "vector": [2, 1, 0.9294, 0.0206, 1, 0.09, 1.0, 555, 0, 3, 0, 0, 0, 0, 6], "semantic": {"name": "__init__", "arg_names": ["self", "form", "inline_formsets"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, form, inline_formsets):\n if form.is_bound:\n self.extend(form.errors.values())\n for inline_formset in inline_formsets:\n self.extend(inline_formset.non_form_errors())\n for errors_in_inline_form in inline_formset.errors:\n self.extend(errors_in_inline_form.values())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L314_C8", "label": "if", "type": "if", "loc": [314, 319], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L313_C4", "vector": [4, 2, 0.9309, 0.0176, 2, 0.76, 0.0, 0, 7, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.is_bound:\n self.extend(form.errors.values())\n for inline_formset in inline_formsets:\n self.extend(inline_formset.non_form_errors())\n for errors_in_inline_form in inline_formset.errors:\n self.extend(errors_in_inline_form.values())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L315_C12", "label": "extend()", "type": "expression", "loc": [315, 315], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L314_C8", "vector": [8, 3, 0.9265, 0.0029, 3, 0.58, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " self.extend(form.errors.values())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L316_C12", "label": "for inline_formset", "type": "for", "loc": [316, 319], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L314_C8", "vector": [6, 3, 0.9338, 0.0118, 3, 0.58, 1.0, 947, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "inline_formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for inline_formset in inline_formsets:\n self.extend(inline_formset.non_form_errors())\n for errors_in_inline_form in inline_formset.errors:\n self.extend(errors_in_inline_form.values())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L317_C16", "label": "extend()", "type": "expression", "loc": [317, 317], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L316_C12", "vector": [8, 4, 0.9324, 0.0029, 4, 0.0, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " self.extend(inline_formset.non_form_errors())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L318_C16", "label": "for errors_in_inline_form", "type": "for", "loc": [318, 319], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L316_C12", "vector": [6, 4, 0.9368, 0.0059, 4, 0.0, 1.0, 777, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "errors_in_inline_form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for errors_in_inline_form in inline_formset.errors:\n self.extend(errors_in_inline_form.values())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L319_C20", "label": "extend()", "type": "expression", "loc": [319, 319], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L318_C16", "vector": [8, 5, 0.9382, 0.0029, 5, 0.03, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " self.extend(errors_in_inline_form.values())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L321_C0", "label": "normalize_fieldsets", "type": "function", "loc": [321, 329], "level": 0, "parent": null, "vector": [2, 0, 0.9559, 0.0265, 0, 0.66, 0.9615, 964, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "normalize_fieldsets", "arg_names": ["fieldsets"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def normalize_fieldsets(fieldsets):\n \"\"\"\n Make sure the keys in fieldset dictionaries are strings. Returns the\n normalized data.\n \"\"\"\n result = []\n for name, options in fieldsets:\n result.append((name, normalize_dictionary(options)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L322_C4", "label": "expression", "type": "expression", "loc": [322, 325], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L321_C0", "vector": [8, 1, 0.9515, 0.0118, 1, 0.68, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Make sure the keys in fieldset dictionaries are strings. Returns the\n normalized data.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L326_C4", "label": "result =", "type": "assigned_variable", "loc": [326, 326], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L321_C0", "vector": [14, 1, 0.9588, 0.0029, 1, 0.68, 0.3333, 51, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "result", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L327_C4", "label": "for name, options", "type": "for", "loc": [327, 328], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L321_C0", "vector": [6, 1, 0.9632, 0.0059, 1, 0.68, 0.6667, 992, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "name, options", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name, options in fieldsets:\n result.append((name, normalize_dictionary(options)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L328_C8", "label": "append()", "type": "expression", "loc": [328, 328], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L327_C4", "vector": [8, 2, 0.9647, 0.0029, 2, 0.19, 0.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " result.append((name, normalize_dictionary(options)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L329_C4", "label": "return", "type": "return", "loc": [329, 329], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L321_C0", "vector": [13, 1, 0.9676, 0.0029, 1, 0.68, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return result"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L331_C0", "label": "normalize_dictionary", "type": "function", "loc": [331, 340], "level": 0, "parent": null, "vector": [2, 0, 0.9868, 0.0294, 0, 0.66, 1.0, 850, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "normalize_dictionary", "arg_names": ["data_dict"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def normalize_dictionary(data_dict):\n \"\"\"\n Converts all the keys in \"data_dict\" to strings. The keys must be\n convertible using str().\n \"\"\"\n for key, value in data_dict.items():\n if not isinstance(key, str):\n del data_dict[key]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L332_C4", "label": "expression", "type": "expression", "loc": [332, 335], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L331_C0", "vector": [8, 1, 0.9809, 0.0118, 1, 0.72, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Converts all the keys in \"data_dict\" to strings. The keys must be\n convertible using str().\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L336_C4", "label": "for key, value", "type": "for", "loc": [336, 339], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L331_C0", "vector": [6, 1, 0.9926, 0.0118, 1, 0.72, 0.5, 839, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "key, value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for key, value in data_dict.items():\n if not isinstance(key, str):\n del data_dict[key]\n data_dict[str(key)] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L337_C8", "label": "if", "type": "if", "loc": [337, 339], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L336_C4", "vector": [4, 2, 0.9941, 0.0088, 2, 0.16, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(key, str):\n del data_dict[key]\n data_dict[str(key)] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L339_C12", "label": "assign", "type": "assigned_variable", "loc": [339, 339], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L337_C8", "vector": [14, 3, 0.9971, 0.0029, 3, 0.87, 0.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data_dict[str(key)] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L340_C4", "label": "return", "type": "return", "loc": [340, 340], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L331_C0", "vector": [13, 1, 1.0, 0.0029, 1, 0.72, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return data_dict"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L25_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L33_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L34_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L25_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L38_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L39_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L25_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L47_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L48_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L49_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L49_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L50_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L51_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L54_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L55_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L54_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L57_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L25_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L61_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L62_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L25_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L64_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L76_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L79_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L81_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L83_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L83_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L84_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L85_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L88_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L90_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L91_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L90_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L93_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L95_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L96_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L99_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L100_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L101_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L101_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L102_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L101_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L105_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L107_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L107_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L108_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L110_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L111_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L112_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L110_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L117_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L118_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L119_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L118_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L120_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L118_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L122_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L123_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L123_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L124_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L125_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L126_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L127_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L116_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L130_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L132_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L136_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L137_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L136_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L139_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L145_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L146_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L147_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L148_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L149_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L130_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L151_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L152_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L153_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L153_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L154_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L155_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L157_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L130_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L162_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L162_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L162_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L164_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L162_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L165_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L162_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L166_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L167_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L166_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L169_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:Try_L166_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L171_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L171_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L172_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L171_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L173_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L173_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L174_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L173_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L176_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L173_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L177_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L177_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L178_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L171_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L180_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L180_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L181_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L180_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L182_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L182_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L183_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L182_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L185_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L162_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L186_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L189_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L193_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L194_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L195_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L197_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L197_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L198_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L192_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L199_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L201_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L201_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L202_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L202_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L203_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L201_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L206_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L206_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L207_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L201_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L210_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L214_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L214_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L215_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L214_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L216_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L216_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L217_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L216_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L219_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L219_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L220_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L219_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L228_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L230_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L230_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L231_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L230_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L232_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L232_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L233_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L230_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L234_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L188_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L235_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L238_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L243_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L244_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L245_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L246_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L246_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L247_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L248_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L249_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L252_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L252_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L253_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L253_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L254_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L257_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L257_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L258_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L258_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L259_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L257_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L261_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L261_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L262_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L262_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L263_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L257_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L264_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L266_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L268_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L269_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L272_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L274_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L276_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L278_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L278_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L279_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L281_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L281_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L282_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L281_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L283_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L283_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L284_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L283_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L286_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L288_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L288_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L289_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L288_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L290_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L237_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L292_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L292_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:ImportFrom_L293_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L292_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L294_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L296_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L297_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L297_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L298_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L297_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L299_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L296_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L301_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L301_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L302_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L301_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L303_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L303_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L304_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L303_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L306_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L309_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L310_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:ClassDef_L309_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L313_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L313_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L314_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L314_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L315_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L314_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L316_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L316_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L317_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L316_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L318_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L318_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L319_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L321_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L322_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L321_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L326_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L321_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L327_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L327_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L328_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L321_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L329_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L331_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Expr_L332_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L331_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L336_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:For_L336_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L337_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:If_L337_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Assign_L339_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98649:FunctionDef_L331_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98649:Return_L340_C4"}] |
from django import forms, template
from django.forms.formsets import all_valid
from django.forms.models import modelform_factory, modelformset_factory, inlineformset_factory
from django.forms.models import BaseInlineFormSet
from django.contrib.contenttypes.models import ContentType
from django.contrib.admin import widgets
from django.contrib.admin import helpers
from django.contrib.admin.util import unquote, flatten_fieldsets, get_deleted_objects, model_format_dict
from django.contrib import messages
from django.views.decorators.csrf import csrf_protect
from django.core.exceptions import PermissionDenied, ValidationError
from django.db import models, transaction, router
from django.db.models.fields import BLANK_CHOICE_DASH
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render_to_response
from django.utils.decorators import method_decorator
from django.utils.datastructures import SortedDict
from django.utils.functional import update_wrapper
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.functional import curry
from django.utils.text import capfirst, get_text_list
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
from django.utils.encoding import force_unicode
HORIZONTAL, VERTICAL = 1, 2
# returns the <ul> class for a given radio_admin field
get_ul_class = lambda x: 'radiolist%s' % ((x == HORIZONTAL) and ' inline' or '')
class IncorrectLookupParameters(Exception):
pass
# Defaults for formfield_overrides. ModelAdmin subclasses can change this
# by adding to ModelAdmin.formfield_overrides.
FORMFIELD_FOR_DBFIELD_DEFAULTS = {
models.DateTimeField: {
'form_class': forms.SplitDateTimeField,
'widget': widgets.AdminSplitDateTime
},
models.DateField: {'widget': widgets.AdminDateWidget},
models.TimeField: {'widget': widgets.AdminTimeWidget},
models.TextField: {'widget': widgets.AdminTextareaWidget},
models.URLField: {'widget': widgets.AdminURLFieldWidget},
models.IntegerField: {'widget': widgets.AdminIntegerFieldWidget},
models.BigIntegerField: {'widget': widgets.AdminIntegerFieldWidget},
models.CharField: {'widget': widgets.AdminTextInputWidget},
models.ImageField: {'widget': widgets.AdminFileWidget},
models.FileField: {'widget': widgets.AdminFileWidget},
}
csrf_protect_m = method_decorator(csrf_protect)
class BaseModelAdmin(object):
"""Functionality common to both ModelAdmin and InlineAdmin."""
__metaclass__ = forms.MediaDefiningClass
raw_id_fields = ()
fields = None
exclude = None
fieldsets = None
form = forms.ModelForm
filter_vertical = ()
filter_horizontal = ()
radio_fields = {}
prepopulated_fields = {}
formfield_overrides = {}
readonly_fields = ()
def __init__(self):
overrides = FORMFIELD_FOR_DBFIELD_DEFAULTS.copy()
overrides.update(self.formfield_overrides)
self.formfield_overrides = overrides
def formfield_for_dbfield(self, db_field, **kwargs):
"""
Hook for specifying the form Field instance for a given database Field
instance.
If kwargs are given, they're passed to the form Field's constructor.
"""
request = kwargs.pop("request", None)
# If the field specifies choices, we don't need to look for special
# admin widgets - we just need to use a select widget of some kind.
if db_field.choices:
return self.formfield_for_choice_field(db_field, request, **kwargs)
# ForeignKey or ManyToManyFields
if isinstance(db_field, (models.ForeignKey, models.ManyToManyField)):
# Combine the field kwargs with any options for formfield_overrides.
# Make sure the passed in **kwargs override anything in
# formfield_overrides because **kwargs is more specific, and should
# always win.
if db_field.__class__ in self.formfield_overrides:
kwargs = dict(self.formfield_overrides[db_field.__class__], **kwargs)
# Get the correct formfield.
if isinstance(db_field, models.ForeignKey):
formfield = self.formfield_for_foreignkey(db_field, request, **kwargs)
elif isinstance(db_field, models.ManyToManyField):
formfield = self.formfield_for_manytomany(db_field, request, **kwargs)
# For non-raw_id fields, wrap the widget with a wrapper that adds
# extra HTML -- the "add other" interface -- to the end of the
# rendered output. formfield can be None if it came from a
# OneToOneField with parent_link=True or a M2M intermediary.
if formfield and db_field.name not in self.raw_id_fields:
related_modeladmin = self.admin_site._registry.get(
db_field.rel.to)
can_add_related = bool(related_modeladmin and
related_modeladmin.has_add_permission(request))
formfield.widget = widgets.RelatedFieldWidgetWrapper(
formfield.widget, db_field.rel, self.admin_site,
can_add_related=can_add_related)
return formfield
# If we've got overrides for the formfield defined, use 'em. **kwargs
# passed to formfield_for_dbfield override the defaults.
for klass in db_field.__class__.mro():
if klass in self.formfield_overrides:
kwargs = dict(self.formfield_overrides[klass], **kwargs)
return db_field.formfield(**kwargs)
# For any other type of field, just call its formfield() method.
return db_field.formfield(**kwargs)
def formfield_for_choice_field(self, db_field, request=None, **kwargs):
"""
Get a form Field for a database Field that has declared choices.
"""
# If the field is named as a radio_field, use a RadioSelect
if db_field.name in self.radio_fields:
# Avoid stomping on custom widget/choices arguments.
if 'widget' not in kwargs:
kwargs['widget'] = widgets.AdminRadioSelect(attrs={
'class': get_ul_class(self.radio_fields[db_field.name]),
})
if 'choices' not in kwargs:
kwargs['choices'] = db_field.get_choices(
include_blank = db_field.blank,
blank_choice=[('', _('None'))]
)
return db_field.formfield(**kwargs)
def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
"""
Get a form Field for a ForeignKey.
"""
db = kwargs.get('using')
if db_field.name in self.raw_id_fields:
kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel, using=db)
elif db_field.name in self.radio_fields:
kwargs['widget'] = widgets.AdminRadioSelect(attrs={
'class': get_ul_class(self.radio_fields[db_field.name]),
})
kwargs['empty_label'] = db_field.blank and _('None') or None
return db_field.formfield(**kwargs)
def formfield_for_manytomany(self, db_field, request=None, **kwargs):
"""
Get a form Field for a ManyToManyField.
"""
# If it uses an intermediary model that isn't auto created, don't show
# a field in admin.
if not db_field.rel.through._meta.auto_created:
return None
db = kwargs.get('using')
if db_field.name in self.raw_id_fields:
kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel, using=db)
kwargs['help_text'] = ''
elif db_field.name in (list(self.filter_vertical) + list(self.filter_horizontal)):
kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name, (db_field.name in self.filter_vertical))
return db_field.formfield(**kwargs)
def _declared_fieldsets(self):
if self.fieldsets:
return self.fieldsets
elif self.fields:
return [(None, {'fields': self.fields})]
return None
declared_fieldsets = property(_declared_fieldsets)
def get_readonly_fields(self, request, obj=None):
return self.readonly_fields
class ModelAdmin(BaseModelAdmin):
"Encapsulates all admin options and functionality for a given model."
list_display = ('__str__',)
list_display_links = ()
list_filter = ()
list_select_related = False
list_per_page = 100
list_editable = ()
search_fields = ()
date_hierarchy = None
save_as = False
save_on_top = False
ordering = None
inlines = []
# Custom templates (designed to be over-ridden in subclasses)
add_form_template = None
change_form_template = None
change_list_template = None
delete_confirmation_template = None
delete_selected_confirmation_template = None
object_history_template = None
# Actions
actions = []
action_form = helpers.ActionForm
actions_on_top = True
actions_on_bottom = False
actions_selection_counter = True
def __init__(self, model, admin_site):
self.model = model
self.opts = model._meta
self.admin_site = admin_site
self.inline_instances = []
for inline_class in self.inlines:
inline_instance = inline_class(self.model, self.admin_site)
self.inline_instances.append(inline_instance)
if 'action_checkbox' not in self.list_display and self.actions is not None:
self.list_display = ['action_checkbox'] + list(self.list_display)
if not self.list_display_links:
for name in self.list_display:
if name != 'action_checkbox':
self.list_display_links = [name]
break
super(ModelAdmin, self).__init__()
def get_urls(self):
from django.conf.urls.defaults import patterns, url
def wrap(view):
def wrapper(*args, **kwargs):
return self.admin_site.admin_view(view)(*args, **kwargs)
return update_wrapper(wrapper, view)
info = self.model._meta.app_label, self.model._meta.module_name
urlpatterns = patterns('',
url(r'^$',
wrap(self.changelist_view),
name='%s_%s_changelist' % info),
url(r'^add/$',
wrap(self.add_view),
name='%s_%s_add' % info),
url(r'^(.+)/history/$',
wrap(self.history_view),
name='%s_%s_history' % info),
url(r'^(.+)/delete/$',
wrap(self.delete_view),
name='%s_%s_delete' % info),
url(r'^(.+)/$',
wrap(self.change_view),
name='%s_%s_change' % info),
)
return urlpatterns
def urls(self):
return self.get_urls()
urls = property(urls)
def _media(self):
from django.conf import settings
js = ['js/core.js', 'js/admin/RelatedObjectLookups.js',
'js/jquery.min.js', 'js/jquery.init.js']
if self.actions is not None:
js.extend(['js/actions.min.js'])
if self.prepopulated_fields:
js.append('js/urlify.js')
js.append('js/prepopulate.min.js')
if self.opts.get_ordered_objects():
js.extend(['js/getElementsBySelector.js', 'js/dom-drag.js' , 'js/admin/ordering.js'])
return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js])
media = property(_media)
def has_add_permission(self, request):
"Returns True if the given request has permission to add an object."
opts = self.opts
return request.user.has_perm(opts.app_label + '.' + opts.get_add_permission())
def has_change_permission(self, request, obj=None):
"""
Returns True if the given request has permission to change the given
Django model instance.
If `obj` is None, this should return True if the given request has
permission to change *any* object of the given type.
"""
opts = self.opts
return request.user.has_perm(opts.app_label + '.' + opts.get_change_permission())
def has_delete_permission(self, request, obj=None):
"""
Returns True if the given request has permission to change the given
Django model instance.
If `obj` is None, this should return True if the given request has
permission to delete *any* object of the given type.
"""
opts = self.opts
return request.user.has_perm(opts.app_label + '.' + opts.get_delete_permission())
def get_model_perms(self, request):
"""
Returns a dict of all perms for this model. This dict has the keys
``add``, ``change``, and ``delete`` mapping to the True/False for each
of those actions.
"""
return {
'add': self.has_add_permission(request),
'change': self.has_change_permission(request),
'delete': self.has_delete_permission(request),
}
def queryset(self, request):
"""
Returns a QuerySet of all model instances that can be edited by the
admin site. This is used by changelist_view.
"""
qs = self.model._default_manager.get_query_set()
# TODO: this should be handled by some parameter to the ChangeList.
ordering = self.ordering or () # otherwise we might try to *None, which is bad ;)
if ordering:
qs = qs.order_by(*ordering)
return qs
def get_fieldsets(self, request, obj=None):
"Hook for specifying fieldsets for the add form."
if self.declared_fieldsets:
return self.declared_fieldsets
form = self.get_form(request, obj)
fields = form.base_fields.keys() + list(self.get_readonly_fields(request, obj))
return [(None, {'fields': fields})]
def get_form(self, request, obj=None, **kwargs):
"""
Returns a Form class for use in the admin add view. This is used by
add_view and change_view.
"""
if self.declared_fieldsets:
fields = flatten_fieldsets(self.declared_fieldsets)
else:
fields = None
if self.exclude is None:
exclude = []
else:
exclude = list(self.exclude)
exclude.extend(kwargs.get("exclude", []))
exclude.extend(self.get_readonly_fields(request, obj))
# if exclude is an empty list we pass None to be consistant with the
# default on modelform_factory
exclude = exclude or None
defaults = {
"form": self.form,
"fields": fields,
"exclude": exclude,
"formfield_callback": curry(self.formfield_for_dbfield, request=request),
}
defaults.update(kwargs)
return modelform_factory(self.model, **defaults)
def get_changelist(self, request, **kwargs):
"""
Returns the ChangeList class for use on the changelist page.
"""
from django.contrib.admin.views.main import ChangeList
return ChangeList
def get_object(self, request, object_id):
"""
Returns an instance matching the primary key provided. ``None`` is
returned if no match is found (or the object_id failed validation
against the primary key field).
"""
queryset = self.queryset(request)
model = queryset.model
try:
object_id = model._meta.pk.to_python(object_id)
return queryset.get(pk=object_id)
except (model.DoesNotExist, ValidationError):
return None
def get_changelist_form(self, request, **kwargs):
"""
Returns a Form class for use in the Formset on the changelist page.
"""
defaults = {
"formfield_callback": curry(self.formfield_for_dbfield, request=request),
}
defaults.update(kwargs)
return modelform_factory(self.model, **defaults)
def get_changelist_formset(self, request, **kwargs):
"""
Returns a FormSet class for use on the changelist page if list_editable
is used.
"""
defaults = {
"formfield_callback": curry(self.formfield_for_dbfield, request=request),
}
defaults.update(kwargs)
return modelformset_factory(self.model,
self.get_changelist_form(request), extra=0,
fields=self.list_editable, **defaults)
def get_formsets(self, request, obj=None):
for inline in self.inline_instances:
yield inline.get_formset(request, obj)
def log_addition(self, request, object):
"""
Log that an object has been successfully added.
The default implementation creates an admin LogEntry object.
"""
from django.contrib.admin.models import LogEntry, ADDITION
LogEntry.objects.log_action(
user_id = request.user.pk,
content_type_id = ContentType.objects.get_for_model(object).pk,
object_id = object.pk,
object_repr = force_unicode(object),
action_flag = ADDITION
)
def log_change(self, request, object, message):
"""
Log that an object has been successfully changed.
The default implementation creates an admin LogEntry object.
"""
from django.contrib.admin.models import LogEntry, CHANGE
LogEntry.objects.log_action(
user_id = request.user.pk,
content_type_id = ContentType.objects.get_for_model(object).pk,
object_id = object.pk,
object_repr = force_unicode(object),
action_flag = CHANGE,
change_message = message
)
def log_deletion(self, request, object, object_repr):
"""
Log that an object will be deleted. Note that this method is called
before the deletion.
The default implementation creates an admin LogEntry object.
"""
from django.contrib.admin.models import LogEntry, DELETION
LogEntry.objects.log_action(
user_id = request.user.id,
content_type_id = ContentType.objects.get_for_model(self.model).pk,
object_id = object.pk,
object_repr = object_repr,
action_flag = DELETION
)
def action_checkbox(self, obj):
"""
A list_display column containing a checkbox widget.
"""
return helpers.checkbox.render(helpers.ACTION_CHECKBOX_NAME, force_unicode(obj.pk))
action_checkbox.short_description = mark_safe('<input type="checkbox" id="action-toggle" />')
action_checkbox.allow_tags = True
def get_actions(self, request):
"""
Return a dictionary mapping the names of all actions for this
ModelAdmin to a tuple of (callable, name, description) for each action.
"""
# If self.actions is explicitally set to None that means that we don't
# want *any* actions enabled on this page.
if self.actions is None:
return []
actions = []
# Gather actions from the admin site first
for (name, func) in self.admin_site.actions:
description = getattr(func, 'short_description', name.replace('_', ' '))
actions.append((func, name, description))
# Then gather them from the model admin and all parent classes,
# starting with self and working back up.
for klass in self.__class__.mro()[::-1]:
class_actions = getattr(klass, 'actions', [])
# Avoid trying to iterate over None
if not class_actions:
continue
actions.extend([self.get_action(action) for action in class_actions])
# get_action might have returned None, so filter any of those out.
actions = filter(None, actions)
# Convert the actions into a SortedDict keyed by name
# and sorted by description.
actions.sort(key=lambda k: k[2].lower())
actions = SortedDict([
(name, (func, name, desc))
for func, name, desc in actions
])
return actions
def get_action_choices(self, request, default_choices=BLANK_CHOICE_DASH):
"""
Return a list of choices for use in a form object. Each choice is a
tuple (name, description).
"""
choices = [] + default_choices
for func, name, description in self.get_actions(request).itervalues():
choice = (name, description % model_format_dict(self.opts))
choices.append(choice)
return choices
def get_action(self, action):
"""
Return a given action from a parameter, which can either be a callable,
or the name of a method on the ModelAdmin. Return is a tuple of
(callable, name, description).
"""
# If the action is a callable, just use it.
if callable(action):
func = action
action = action.__name__
# Next, look for a method. Grab it off self.__class__ to get an unbound
# method instead of a bound one; this ensures that the calling
# conventions are the same for functions and methods.
elif hasattr(self.__class__, action):
func = getattr(self.__class__, action)
# Finally, look for a named method on the admin site
else:
try:
func = self.admin_site.get_action(action)
except KeyError:
return None
if hasattr(func, 'short_description'):
description = func.short_description
else:
description = capfirst(action.replace('_', ' '))
return func, action, description
def construct_change_message(self, request, form, formsets):
"""
Construct a change message from a changed object.
"""
change_message = []
if form.changed_data:
change_message.append(_('Changed %s.') % get_text_list(form.changed_data, _('and')))
if formsets:
for formset in formsets:
for added_object in formset.new_objects:
change_message.append(_('Added %(name)s "%(object)s".')
% {'name': force_unicode(added_object._meta.verbose_name),
'object': force_unicode(added_object)})
for changed_object, changed_fields in formset.changed_objects:
change_message.append(_('Changed %(list)s for %(name)s "%(object)s".')
% {'list': get_text_list(changed_fields, _('and')),
'name': force_unicode(changed_object._meta.verbose_name),
'object': force_unicode(changed_object)})
for deleted_object in formset.deleted_objects:
change_message.append(_('Deleted %(name)s "%(object)s".')
% {'name': force_unicode(deleted_object._meta.verbose_name),
'object': force_unicode(deleted_object)})
change_message = ' '.join(change_message)
return change_message or _('No fields changed.')
def message_user(self, request, message):
"""
Send a message to the user. The default implementation
posts a message using the django.contrib.messages backend.
"""
messages.info(request, message)
def save_form(self, request, form, change):
"""
Given a ModelForm return an unsaved instance. ``change`` is True if
the object is being changed, and False if it's being added.
"""
return form.save(commit=False)
def save_model(self, request, obj, form, change):
"""
Given a model instance save it to the database.
"""
obj.save()
def save_formset(self, request, form, formset, change):
"""
Given an inline formset save it to the database.
"""
formset.save()
def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):
opts = self.model._meta
app_label = opts.app_label
ordered_objects = opts.get_ordered_objects()
context.update({
'add': add,
'change': change,
'has_add_permission': self.has_add_permission(request),
'has_change_permission': self.has_change_permission(request, obj),
'has_delete_permission': self.has_delete_permission(request, obj),
'has_file_field': True, # FIXME - this should check if form or formsets have a FileField,
'has_absolute_url': hasattr(self.model, 'get_absolute_url'),
'ordered_objects': ordered_objects,
'form_url': mark_safe(form_url),
'opts': opts,
'content_type_id': ContentType.objects.get_for_model(self.model).id,
'save_as': self.save_as,
'save_on_top': self.save_on_top,
'root_path': self.admin_site.root_path,
})
if add and self.add_form_template is not None:
form_template = self.add_form_template
else:
form_template = self.change_form_template
context_instance = template.RequestContext(request, current_app=self.admin_site.name)
return render_to_response(form_template or [
"admin/%s/%s/change_form.html" % (app_label, opts.object_name.lower()),
"admin/%s/change_form.html" % app_label,
"admin/change_form.html"
], context, context_instance=context_instance)
def response_add(self, request, obj, post_url_continue='../%s/'):
"""
Determines the HttpResponse for the add_view stage.
"""
opts = obj._meta
pk_value = obj._get_pk_val()
msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj)}
# Here, we distinguish between different save types by checking for
# the presence of keys in request.POST.
if "_continue" in request.POST:
self.message_user(request, msg + ' ' + _("You may edit it again below."))
if "_popup" in request.POST:
post_url_continue += "?_popup=1"
return HttpResponseRedirect(post_url_continue % pk_value)
if "_popup" in request.POST:
return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' % \
# escape() calls force_unicode.
(escape(pk_value), escape(obj)))
elif "_addanother" in request.POST:
self.message_user(request, msg + ' ' + (_("You may add another %s below.") % force_unicode(opts.verbose_name)))
return HttpResponseRedirect(request.path)
else:
self.message_user(request, msg)
# Figure out where to redirect. If the user has change permission,
# redirect to the change-list page for this object. Otherwise,
# redirect to the admin index.
if self.has_change_permission(request, None):
post_url = '../'
else:
post_url = '../../../'
return HttpResponseRedirect(post_url)
def response_change(self, request, obj):
"""
Determines the HttpResponse for the change_view stage.
"""
opts = obj._meta
pk_value = obj._get_pk_val()
msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj)}
if "_continue" in request.POST:
self.message_user(request, msg + ' ' + _("You may edit it again below."))
if "_popup" in request.REQUEST:
return HttpResponseRedirect(request.path + "?_popup=1")
else:
return HttpResponseRedirect(request.path)
elif "_saveasnew" in request.POST:
msg = _('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % {'name': force_unicode(opts.verbose_name), 'obj': obj}
self.message_user(request, msg)
return HttpResponseRedirect("../%s/" % pk_value)
elif "_addanother" in request.POST:
self.message_user(request, msg + ' ' + (_("You may add another %s below.") % force_unicode(opts.verbose_name)))
return HttpResponseRedirect("../add/")
else:
self.message_user(request, msg)
return HttpResponseRedirect("../")
def response_action(self, request, queryset):
"""
Handle an admin action. This is called if a request is POSTed to the
changelist; it returns an HttpResponse if the action was handled, and
None otherwise.
"""
# There can be multiple action forms on the page (at the top
# and bottom of the change list, for example). Get the action
# whose button was pushed.
try:
action_index = int(request.POST.get('index', 0))
except ValueError:
action_index = 0
# Construct the action form.
data = request.POST.copy()
data.pop(helpers.ACTION_CHECKBOX_NAME, None)
data.pop("index", None)
# Use the action whose button was pushed
try:
data.update({'action': data.getlist('action')[action_index]})
except IndexError:
# If we didn't get an action from the chosen form that's invalid
# POST data, so by deleting action it'll fail the validation check
# below. So no need to do anything here
pass
action_form = self.action_form(data, auto_id=None)
action_form.fields['action'].choices = self.get_action_choices(request)
# If the form's valid we can handle the action.
if action_form.is_valid():
action = action_form.cleaned_data['action']
select_across = action_form.cleaned_data['select_across']
func, name, description = self.get_actions(request)[action]
# Get the list of selected PKs. If nothing's selected, we can't
# perform an action on it, so bail. Except we want to perform
# the action explicitly on all objects.
selected = request.POST.getlist(helpers.ACTION_CHECKBOX_NAME)
if not selected and not select_across:
# Reminder that something needs to be selected or nothing will happen
msg = _("Items must be selected in order to perform "
"actions on them. No items have been changed.")
self.message_user(request, msg)
return None
if not select_across:
# Perform the action only on the selected objects
queryset = queryset.filter(pk__in=selected)
response = func(self, request, queryset)
# Actions may return an HttpResponse, which will be used as the
# response from the POST. If not, we'll be a good little HTTP
# citizen and redirect back to the changelist page.
if isinstance(response, HttpResponse):
return response
else:
return HttpResponseRedirect(request.get_full_path())
else:
msg = _("No action selected.")
self.message_user(request, msg)
return None
@csrf_protect_m
@transaction.commit_on_success
def add_view(self, request, form_url='', extra_context=None):
"The 'add' admin view for this model."
model = self.model
opts = model._meta
if not self.has_add_permission(request):
raise PermissionDenied
ModelForm = self.get_form(request)
formsets = []
if request.method == 'POST':
form = ModelForm(request.POST, request.FILES)
if form.is_valid():
new_object = self.save_form(request, form, change=False)
form_validated = True
else:
form_validated = False
new_object = self.model()
prefixes = {}
for FormSet, inline in zip(self.get_formsets(request), self.inline_instances):
prefix = FormSet.get_default_prefix()
prefixes[prefix] = prefixes.get(prefix, 0) + 1
if prefixes[prefix] != 1:
prefix = "%s-%s" % (prefix, prefixes[prefix])
formset = FormSet(data=request.POST, files=request.FILES,
instance=new_object,
save_as_new="_saveasnew" in request.POST,
prefix=prefix, queryset=inline.queryset(request))
formsets.append(formset)
if all_valid(formsets) and form_validated:
self.save_model(request, new_object, form, change=False)
form.save_m2m()
for formset in formsets:
self.save_formset(request, form, formset, change=False)
self.log_addition(request, new_object)
return self.response_add(request, new_object)
else:
# Prepare the dict of initial data from the request.
# We have to special-case M2Ms as a list of comma-separated PKs.
initial = dict(request.GET.items())
for k in initial:
try:
f = opts.get_field(k)
except models.FieldDoesNotExist:
continue
if isinstance(f, models.ManyToManyField):
initial[k] = initial[k].split(",")
form = ModelForm(initial=initial)
prefixes = {}
for FormSet, inline in zip(self.get_formsets(request),
self.inline_instances):
prefix = FormSet.get_default_prefix()
prefixes[prefix] = prefixes.get(prefix, 0) + 1
if prefixes[prefix] != 1:
prefix = "%s-%s" % (prefix, prefixes[prefix])
formset = FormSet(instance=self.model(), prefix=prefix,
queryset=inline.queryset(request))
formsets.append(formset)
adminForm = helpers.AdminForm(form, list(self.get_fieldsets(request)),
self.prepopulated_fields, self.get_readonly_fields(request),
model_admin=self)
media = self.media + adminForm.media
inline_admin_formsets = []
for inline, formset in zip(self.inline_instances, formsets):
fieldsets = list(inline.get_fieldsets(request))
readonly = list(inline.get_readonly_fields(request))
inline_admin_formset = helpers.InlineAdminFormSet(inline, formset,
fieldsets, readonly, model_admin=self)
inline_admin_formsets.append(inline_admin_formset)
media = media + inline_admin_formset.media
context = {
'title': _('Add %s') % force_unicode(opts.verbose_name),
'adminform': adminForm,
'is_popup': "_popup" in request.REQUEST,
'show_delete': False,
'media': mark_safe(media),
'inline_admin_formsets': inline_admin_formsets,
'errors': helpers.AdminErrorList(form, formsets),
'root_path': self.admin_site.root_path,
'app_label': opts.app_label,
}
context.update(extra_context or {})
return self.render_change_form(request, context, form_url=form_url, add=True)
@csrf_protect_m
@transaction.commit_on_success
def change_view(self, request, object_id, extra_context=None):
"The 'change' admin view for this model."
model = self.model
opts = model._meta
obj = self.get_object(request, unquote(object_id))
if not self.has_change_permission(request, obj):
raise PermissionDenied
if obj is None:
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_unicode(opts.verbose_name), 'key': escape(object_id)})
if request.method == 'POST' and "_saveasnew" in request.POST:
return self.add_view(request, form_url='../add/')
ModelForm = self.get_form(request, obj)
formsets = []
if request.method == 'POST':
form = ModelForm(request.POST, request.FILES, instance=obj)
if form.is_valid():
form_validated = True
new_object = self.save_form(request, form, change=True)
else:
form_validated = False
new_object = obj
prefixes = {}
for FormSet, inline in zip(self.get_formsets(request, new_object),
self.inline_instances):
prefix = FormSet.get_default_prefix()
prefixes[prefix] = prefixes.get(prefix, 0) + 1
if prefixes[prefix] != 1:
prefix = "%s-%s" % (prefix, prefixes[prefix])
formset = FormSet(request.POST, request.FILES,
instance=new_object, prefix=prefix,
queryset=inline.queryset(request))
formsets.append(formset)
if all_valid(formsets) and form_validated:
self.save_model(request, new_object, form, change=True)
form.save_m2m()
for formset in formsets:
self.save_formset(request, form, formset, change=True)
change_message = self.construct_change_message(request, form, formsets)
self.log_change(request, new_object, change_message)
return self.response_change(request, new_object)
else:
form = ModelForm(instance=obj)
prefixes = {}
for FormSet, inline in zip(self.get_formsets(request, obj), self.inline_instances):
prefix = FormSet.get_default_prefix()
prefixes[prefix] = prefixes.get(prefix, 0) + 1
if prefixes[prefix] != 1:
prefix = "%s-%s" % (prefix, prefixes[prefix])
formset = FormSet(instance=obj, prefix=prefix,
queryset=inline.queryset(request))
formsets.append(formset)
adminForm = helpers.AdminForm(form, self.get_fieldsets(request, obj),
self.prepopulated_fields, self.get_readonly_fields(request, obj),
model_admin=self)
media = self.media + adminForm.media
inline_admin_formsets = []
for inline, formset in zip(self.inline_instances, formsets):
fieldsets = list(inline.get_fieldsets(request, obj))
readonly = list(inline.get_readonly_fields(request, obj))
inline_admin_formset = helpers.InlineAdminFormSet(inline, formset,
fieldsets, readonly, model_admin=self)
inline_admin_formsets.append(inline_admin_formset)
media = media + inline_admin_formset.media
context = {
'title': _('Change %s') % force_unicode(opts.verbose_name),
'adminform': adminForm,
'object_id': object_id,
'original': obj,
'is_popup': "_popup" in request.REQUEST,
'media': mark_safe(media),
'inline_admin_formsets': inline_admin_formsets,
'errors': helpers.AdminErrorList(form, formsets),
'root_path': self.admin_site.root_path,
'app_label': opts.app_label,
}
context.update(extra_context or {})
return self.render_change_form(request, context, change=True, obj=obj)
@csrf_protect_m
def changelist_view(self, request, extra_context=None):
"The 'change list' admin view for this model."
from django.contrib.admin.views.main import ERROR_FLAG
opts = self.model._meta
app_label = opts.app_label
if not self.has_change_permission(request, None):
raise PermissionDenied
# Check actions to see if any are available on this changelist
actions = self.get_actions(request)
# Remove action checkboxes if there aren't any actions available.
list_display = list(self.list_display)
if not actions:
try:
list_display.remove('action_checkbox')
except ValueError:
pass
ChangeList = self.get_changelist(request)
try:
cl = ChangeList(request, self.model, list_display, self.list_display_links, self.list_filter,
self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self)
except IncorrectLookupParameters:
# Wacky lookup parameters were given, so redirect to the main
# changelist page, without parameters, and pass an 'invalid=1'
# parameter via the query string. If wacky parameters were given
# and the 'invalid=1' parameter was already in the query string,
# something is screwed up with the database, so display an error
# page.
if ERROR_FLAG in request.GET.keys():
return render_to_response('admin/invalid_setup.html', {'title': _('Database error')})
return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1')
# If the request was POSTed, this might be a bulk action or a bulk
# edit. Try to look up an action or confirmation first, but if this
# isn't an action the POST will fall through to the bulk edit check,
# below.
action_failed = False
selected = request.POST.getlist(helpers.ACTION_CHECKBOX_NAME)
# Actions with no confirmation
if (actions and request.method == 'POST' and
'index' in request.POST and '_save' not in request.POST):
if selected:
response = self.response_action(request, queryset=cl.get_query_set())
if response:
return response
else:
action_failed = True
else:
msg = _("Items must be selected in order to perform "
"actions on them. No items have been changed.")
self.message_user(request, msg)
action_failed = True
# Actions with confirmation
if (actions and request.method == 'POST' and
helpers.ACTION_CHECKBOX_NAME in request.POST and
'index' not in request.POST and '_save' not in request.POST):
if selected:
response = self.response_action(request, queryset=cl.get_query_set())
if response:
return response
else:
action_failed = True
# If we're allowing changelist editing, we need to construct a formset
# for the changelist given all the fields to be edited. Then we'll
# use the formset to validate/process POSTed data.
formset = cl.formset = None
# Handle POSTed bulk-edit data.
if (request.method == "POST" and self.list_editable and
'_save' in request.POST and not action_failed):
FormSet = self.get_changelist_formset(request)
formset = cl.formset = FormSet(request.POST, request.FILES, queryset=cl.result_list)
if formset.is_valid():
changecount = 0
for form in formset.forms:
if form.has_changed():
obj = self.save_form(request, form, change=True)
self.save_model(request, obj, form, change=True)
form.save_m2m()
change_msg = self.construct_change_message(request, form, None)
self.log_change(request, obj, change_msg)
changecount += 1
if changecount:
if changecount == 1:
name = force_unicode(opts.verbose_name)
else:
name = force_unicode(opts.verbose_name_plural)
msg = ungettext("%(count)s %(name)s was changed successfully.",
"%(count)s %(name)s were changed successfully.",
changecount) % {'count': changecount,
'name': name,
'obj': force_unicode(obj)}
self.message_user(request, msg)
return HttpResponseRedirect(request.get_full_path())
# Handle GET -- construct a formset for display.
elif self.list_editable:
FormSet = self.get_changelist_formset(request)
formset = cl.formset = FormSet(queryset=cl.result_list)
# Build the list of media to be used by the formset.
if formset:
media = self.media + formset.media
else:
media = self.media
# Build the action form and populate it with available actions.
if actions:
action_form = self.action_form(auto_id=None)
action_form.fields['action'].choices = self.get_action_choices(request)
else:
action_form = None
selection_note_all = ungettext('%(total_count)s selected',
'All %(total_count)s selected', cl.result_count)
context = {
'module_name': force_unicode(opts.verbose_name_plural),
'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},
'selection_note_all': selection_note_all % {'total_count': cl.result_count},
'title': cl.title,
'is_popup': cl.is_popup,
'cl': cl,
'media': media,
'has_add_permission': self.has_add_permission(request),
'root_path': self.admin_site.root_path,
'app_label': app_label,
'action_form': action_form,
'actions_on_top': self.actions_on_top,
'actions_on_bottom': self.actions_on_bottom,
'actions_selection_counter': self.actions_selection_counter,
}
context.update(extra_context or {})
context_instance = template.RequestContext(request, current_app=self.admin_site.name)
return render_to_response(self.change_list_template or [
'admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()),
'admin/%s/change_list.html' % app_label,
'admin/change_list.html'
], context, context_instance=context_instance)
@csrf_protect_m
@transaction.commit_on_success
def delete_view(self, request, object_id, extra_context=None):
"The 'delete' admin view for this model."
opts = self.model._meta
app_label = opts.app_label
obj = self.get_object(request, unquote(object_id))
if not self.has_delete_permission(request, obj):
raise PermissionDenied
if obj is None:
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_unicode(opts.verbose_name), 'key': escape(object_id)})
using = router.db_for_write(self.model)
# Populate deleted_objects, a data structure of all related objects that
# will also be deleted.
(deleted_objects, perms_needed) = get_deleted_objects(
[obj], opts, request.user, self.admin_site, using)
if request.POST: # The user has already confirmed the deletion.
if perms_needed:
raise PermissionDenied
obj_display = force_unicode(obj)
self.log_deletion(request, obj, obj_display)
obj.delete()
self.message_user(request, _('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)})
if not self.has_change_permission(request, None):
return HttpResponseRedirect("../../../../")
return HttpResponseRedirect("../../")
context = {
"title": _("Are you sure?"),
"object_name": force_unicode(opts.verbose_name),
"object": obj,
"deleted_objects": deleted_objects,
"perms_lacking": perms_needed,
"opts": opts,
"root_path": self.admin_site.root_path,
"app_label": app_label,
}
context.update(extra_context or {})
context_instance = template.RequestContext(request, current_app=self.admin_site.name)
return render_to_response(self.delete_confirmation_template or [
"admin/%s/%s/delete_confirmation.html" % (app_label, opts.object_name.lower()),
"admin/%s/delete_confirmation.html" % app_label,
"admin/delete_confirmation.html"
], context, context_instance=context_instance)
def history_view(self, request, object_id, extra_context=None):
"The 'history' admin view for this model."
from django.contrib.admin.models import LogEntry
model = self.model
opts = model._meta
app_label = opts.app_label
action_list = LogEntry.objects.filter(
object_id = object_id,
content_type__id__exact = ContentType.objects.get_for_model(model).id
).select_related().order_by('action_time')
# If no history was found, see whether this object even exists.
obj = get_object_or_404(model, pk=unquote(object_id))
context = {
'title': _('Change history: %s') % force_unicode(obj),
'action_list': action_list,
'module_name': capfirst(force_unicode(opts.verbose_name_plural)),
'object': obj,
'root_path': self.admin_site.root_path,
'app_label': app_label,
}
context.update(extra_context or {})
context_instance = template.RequestContext(request, current_app=self.admin_site.name)
return render_to_response(self.object_history_template or [
"admin/%s/%s/object_history.html" % (app_label, opts.object_name.lower()),
"admin/%s/object_history.html" % app_label,
"admin/object_history.html"
], context, context_instance=context_instance)
#
# DEPRECATED methods.
#
def __call__(self, request, url):
"""
DEPRECATED: this is the old way of URL resolution, replaced by
``get_urls()``. This only called by AdminSite.root(), which is also
deprecated.
Again, remember that the following code only exists for
backwards-compatibility. Any new URLs, changes to existing URLs, or
whatever need to be done up in get_urls(), above!
This function still exists for backwards-compatibility; it will be
removed in Django 1.3.
"""
# Delegate to the appropriate method, based on the URL.
if url is None:
return self.changelist_view(request)
elif url == "add":
return self.add_view(request)
elif url.endswith('/history'):
return self.history_view(request, unquote(url[:-8]))
elif url.endswith('/delete'):
return self.delete_view(request, unquote(url[:-7]))
else:
return self.change_view(request, unquote(url))
class InlineModelAdmin(BaseModelAdmin):
"""
Options for inline editing of ``model`` instances.
Provide ``name`` to specify the attribute name of the ``ForeignKey`` from
``model`` to its parent. This is required if ``model`` has more than one
``ForeignKey`` to its parent.
"""
model = None
fk_name = None
formset = BaseInlineFormSet
extra = 3
max_num = None
template = None
verbose_name = None
verbose_name_plural = None
can_delete = True
def __init__(self, parent_model, admin_site):
self.admin_site = admin_site
self.parent_model = parent_model
self.opts = self.model._meta
super(InlineModelAdmin, self).__init__()
if self.verbose_name is None:
self.verbose_name = self.model._meta.verbose_name
if self.verbose_name_plural is None:
self.verbose_name_plural = self.model._meta.verbose_name_plural
def _media(self):
from django.conf import settings
js = ['js/jquery.min.js', 'js/jquery.init.js', 'js/inlines.min.js']
if self.prepopulated_fields:
js.append('js/urlify.js')
js.append('js/prepopulate.min.js')
if self.filter_vertical or self.filter_horizontal:
js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js'])
return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js])
media = property(_media)
def get_formset(self, request, obj=None, **kwargs):
"""Returns a BaseInlineFormSet class for use in admin add/change views."""
if self.declared_fieldsets:
fields = flatten_fieldsets(self.declared_fieldsets)
else:
fields = None
if self.exclude is None:
exclude = []
else:
exclude = list(self.exclude)
exclude.extend(kwargs.get("exclude", []))
exclude.extend(self.get_readonly_fields(request, obj))
# if exclude is an empty list we use None, since that's the actual
# default
exclude = exclude or None
defaults = {
"form": self.form,
"formset": self.formset,
"fk_name": self.fk_name,
"fields": fields,
"exclude": exclude,
"formfield_callback": curry(self.formfield_for_dbfield, request=request),
"extra": self.extra,
"max_num": self.max_num,
"can_delete": self.can_delete,
}
defaults.update(kwargs)
return inlineformset_factory(self.parent_model, self.model, **defaults)
def get_fieldsets(self, request, obj=None):
if self.declared_fieldsets:
return self.declared_fieldsets
form = self.get_formset(request).form
fields = form.base_fields.keys() + list(self.get_readonly_fields(request, obj))
return [(None, {'fields': fields})]
def queryset(self, request):
return self.model._default_manager.all()
class StackedInline(InlineModelAdmin):
template = 'admin/edit_inline/stacked.html'
class TabularInline(InlineModelAdmin):
template = 'admin/edit_inline/tabular.html'
| ajibawa-2023/Python-Code-Large/train/row_98650 | 679 | 1,289 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L1_C0", "label": "from django import forms, template", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0008, 0.0008, 0, 0.66, 0.0, 294, 0, 2, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["forms", "template"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django import forms, template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L2_C0", "label": "from django.forms.formsets import all_valid", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0016, 0.0008, 0, 0.66, 0.0294, 42, 0, 1, 0, 0, 42, 0, 0], "semantic": {"name": "django.forms.formsets", "arg_names": [], "import_names": ["all_valid"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.forms.formsets import all_valid"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L3_C0", "label": "from django.forms.models import modelform_factory, modelformset_factory, inlineformset_factory", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0023, 0.0008, 0, 0.66, 0.0588, 625, 0, 3, 0, 0, 625, 0, 0], "semantic": {"name": "django.forms.models", "arg_names": [], "import_names": ["modelform_factory", "modelformset_factory", "inlineformset_factory"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.forms.models import modelform_factory, modelformset_factory, inlineformset_factory"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L4_C0", "label": "from django.forms.models import BaseInlineFormSet", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0031, 0.0008, 0, 0.66, 0.0882, 625, 0, 1, 0, 0, 625, 0, 0], "semantic": {"name": "django.forms.models", "arg_names": [], "import_names": ["BaseInlineFormSet"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.forms.models import BaseInlineFormSet"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L5_C0", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0039, 0.0008, 0, 0.66, 0.1176, 469, 0, 1, 0, 0, 469, 0, 0], "semantic": {"name": "django.contrib.contenttypes.models", "arg_names": [], "import_names": ["ContentType"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.contenttypes.models import ContentType"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L6_C0", "label": "from django.contrib.admin import widgets", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0047, 0.0008, 0, 0.66, 0.1471, 703, 0, 1, 0, 0, 703, 0, 0], "semantic": {"name": "django.contrib.admin", "arg_names": [], "import_names": ["widgets"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin import widgets"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L7_C0", "label": "from django.contrib.admin import helpers", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0054, 0.0008, 0, 0.66, 0.1765, 703, 0, 1, 0, 0, 703, 0, 0], "semantic": {"name": "django.contrib.admin", "arg_names": [], "import_names": ["helpers"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin import helpers"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L8_C0", "label": "from django.contrib.admin.util import unquote, flatten_fieldsets, get_deleted_objects\u2026", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0062, 0.0008, 0, 0.66, 0.2059, 69, 0, 4, 0, 0, 69, 0, 0], "semantic": {"name": "django.contrib.admin.util", "arg_names": [], "import_names": ["unquote", "flatten_fieldsets", "get_deleted_objects", "model_format_dict"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.util import unquote, flatten_fieldsets, get_deleted_objects, model_format_dict"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L9_C0", "label": "from django.contrib import messages", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.007, 0.0008, 0, 0.66, 0.2353, 302, 0, 1, 0, 0, 302, 0, 0], "semantic": {"name": "django.contrib", "arg_names": [], "import_names": ["messages"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib import messages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L10_C0", "label": "from django.views.decorators.csrf import csrf_protect", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0078, 0.0008, 0, 0.66, 0.2647, 456, 0, 1, 0, 0, 456, 0, 0], "semantic": {"name": "django.views.decorators.csrf", "arg_names": [], "import_names": ["csrf_protect"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.views.decorators.csrf import csrf_protect"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L11_C0", "label": "from django.core.exceptions import PermissionDenied, ValidationError", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0085, 0.0008, 0, 0.66, 0.2941, 160, 0, 2, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["PermissionDenied", "ValidationError"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import PermissionDenied, ValidationError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L12_C0", "label": "from django.db import models, transaction, router", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0093, 0.0008, 0, 0.66, 0.3235, 40, 0, 3, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models", "transaction", "router"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models, transaction, router"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L13_C0", "label": "from django.db.models.fields import BLANK_CHOICE_DASH", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0101, 0.0008, 0, 0.66, 0.3529, 5, 0, 1, 0, 0, 5, 0, 0], "semantic": {"name": "django.db.models.fields", "arg_names": [], "import_names": ["BLANK_CHOICE_DASH"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models.fields import BLANK_CHOICE_DASH"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L14_C0", "label": "from django.http import Http404, HttpResponse, HttpResponseRedirect", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.0109, 0.0008, 0, 0.66, 0.3824, 779, 0, 3, 0, 0, 779, 0, 0], "semantic": {"name": "django.http", "arg_names": [], "import_names": ["Http404", "HttpResponse", "HttpResponseRedirect"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.http import Http404, HttpResponse, HttpResponseRedirect"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L15_C0", "label": "from django.shortcuts import get_object_or_404, render_to_response", "type": "import", "loc": [15, 15], "level": 0, "parent": null, "vector": [1, 0, 0.0116, 0.0008, 0, 0.66, 0.4118, 852, 0, 2, 0, 0, 852, 0, 0], "semantic": {"name": "django.shortcuts", "arg_names": [], "import_names": ["get_object_or_404", "render_to_response"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.shortcuts import get_object_or_404, render_to_response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L16_C0", "label": "from django.utils.decorators import method_decorator", "type": "import", "loc": [16, 16], "level": 0, "parent": null, "vector": [1, 0, 0.0124, 0.0008, 0, 0.66, 0.4412, 532, 0, 1, 0, 0, 532, 0, 0], "semantic": {"name": "django.utils.decorators", "arg_names": [], "import_names": ["method_decorator"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.decorators import method_decorator"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L17_C0", "label": "from django.utils.datastructures import SortedDict", "type": "import", "loc": [17, 17], "level": 0, "parent": null, "vector": [1, 0, 0.0132, 0.0008, 0, 0.66, 0.4706, 757, 0, 1, 0, 0, 757, 0, 0], "semantic": {"name": "django.utils.datastructures", "arg_names": [], "import_names": ["SortedDict"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.datastructures import SortedDict"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L18_C0", "label": "from django.utils.functional import update_wrapper", "type": "import", "loc": [18, 18], "level": 0, "parent": null, "vector": [1, 0, 0.014, 0.0008, 0, 0.66, 0.5, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.functional", "arg_names": [], "import_names": ["update_wrapper"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.functional import update_wrapper"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L19_C0", "label": "from django.utils.html import escape", "type": "import", "loc": [19, 19], "level": 0, "parent": null, "vector": [1, 0, 0.0147, 0.0008, 0, 0.66, 0.5294, 535, 0, 1, 0, 0, 535, 0, 0], "semantic": {"name": "django.utils.html", "arg_names": [], "import_names": ["escape"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.html import escape"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L20_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [20, 20], "level": 0, "parent": null, "vector": [1, 0, 0.0155, 0.0008, 0, 0.66, 0.5588, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.safestring", "arg_names": [], "import_names": ["mark_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.safestring import mark_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L21_C0", "label": "from django.utils.functional import curry", "type": "import", "loc": [21, 21], "level": 0, "parent": null, "vector": [1, 0, 0.0163, 0.0008, 0, 0.66, 0.5882, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.functional", "arg_names": [], "import_names": ["curry"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.functional import curry"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L22_C0", "label": "from django.utils.text import capfirst, get_text_list", "type": "import", "loc": [22, 22], "level": 0, "parent": null, "vector": [1, 0, 0.0171, 0.0008, 0, 0.66, 0.6176, 590, 0, 2, 0, 0, 590, 0, 0], "semantic": {"name": "django.utils.text", "arg_names": [], "import_names": ["capfirst", "get_text_list"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.text import capfirst, get_text_list"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L23_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [23, 23], "level": 0, "parent": null, "vector": [1, 0, 0.0178, 0.0008, 0, 0.66, 0.6471, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L24_C0", "label": "from django.utils.translation import ungettext", "type": "import", "loc": [24, 24], "level": 0, "parent": null, "vector": [1, 0, 0.0186, 0.0008, 0, 0.66, 0.6765, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["ungettext"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ungettext"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L25_C0", "label": "from django.utils.encoding import force_unicode", "type": "import", "loc": [25, 25], "level": 0, "parent": null, "vector": [1, 0, 0.0194, 0.0008, 0, 0.66, 0.7059, 96, 0, 1, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["force_unicode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import force_unicode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L27_C0", "label": "HORIZONTAL, VERTICAL =", "type": "assigned_variable", "loc": [27, 27], "level": 0, "parent": null, "vector": [14, 0, 0.0209, 0.0008, 0, 0.66, 0.7353, 392, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "HORIZONTAL, VERTICAL", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "HORIZONTAL, VERTICAL = 1, 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L29_C0", "label": "get_ul_class =", "type": "assigned_variable", "loc": [29, 29], "level": 0, "parent": null, "vector": [14, 0, 0.0225, 0.0008, 0, 0.66, 0.7647, 720, 9, 0, 0, 0, 0, 0, 0], "semantic": {"name": "get_ul_class", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "get_ul_class = lambda x: 'radiolist%s' % ((x == HORIZONTAL) and ' inline' or '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L31_C0", "label": "IncorrectLookupParameters", "type": "class", "loc": [31, 32], "level": 0, "parent": null, "vector": [3, 0, 0.0244, 0.0016, 0, 0.66, 0.7941, 547, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "IncorrectLookupParameters", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class IncorrectLookupParameters(Exception):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L37_C0", "label": "FORMFIELD_FOR_DBFIELD_DEFAULTS =", "type": "assigned_variable", "loc": [37, 51], "level": 0, "parent": null, "vector": [14, 0, 0.0341, 0.0116, 0, 0.66, 0.8235, 940, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "FORMFIELD_FOR_DBFIELD_DEFAULTS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "FORMFIELD_FOR_DBFIELD_DEFAULTS = {\n models.DateTimeField: {\n 'form_class': forms.SplitDateTimeField,\n 'widget': widgets.AdminSplitDateTime\n },\n models.DateField: {'widget': widgets.AdminDateWidget},\n models.TimeField: {'widget': widgets.AdminTimeWidget},\n models.TextField: {'widget': widgets.AdminTextareaWidget},"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L53_C0", "label": "csrf_protect_m = method_decorator()", "type": "assigned_variable", "loc": [53, 53], "level": 0, "parent": null, "vector": [14, 0, 0.0411, 0.0008, 0, 0.66, 0.8529, 580, 3, 1, 0, 0, 421, 10, 1], "semantic": {"name": "csrf_protect_m", "arg_names": [], "import_names": [], "rhs_call_name": "method_decorator", "annotation": ""}, "snippet": "csrf_protect_m = method_decorator(csrf_protect)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "label": "BaseModelAdmin", "type": "class", "loc": [55, 190], "level": 0, "parent": null, "vector": [3, 0, 0.095, 0.1055, 0, 0.66, 0.8824, 170, 0, 7, 0, 0, 186, 0, 36], "semantic": {"name": "BaseModelAdmin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class BaseModelAdmin(object):\n \"\"\"Functionality common to both ModelAdmin and InlineAdmin.\"\"\"\n __metaclass__ = forms.MediaDefiningClass\n\n raw_id_fields = ()\n fields = None\n exclude = None\n fieldsets = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L56_C4", "label": "expression", "type": "expression", "loc": [56, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [8, 1, 0.0434, 0.0008, 1, 0.65, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Functionality common to both ModelAdmin and InlineAdmin.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L57_C4", "label": "__metaclass__ =", "type": "assigned_variable", "loc": [57, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.0442, 0.0008, 1, 0.65, 0.05, 203, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "__metaclass__", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " __metaclass__ = forms.MediaDefiningClass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L59_C4", "label": "raw_id_fields =", "type": "assigned_variable", "loc": [59, 59], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.0458, 0.0008, 1, 0.65, 0.1, 309, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "raw_id_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " raw_id_fields = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L60_C4", "label": "fields =", "type": "assigned_variable", "loc": [60, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.0465, 0.0008, 1, 0.65, 0.15, 358, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fields = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L61_C4", "label": "exclude =", "type": "assigned_variable", "loc": [61, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.0473, 0.0008, 1, 0.65, 0.2, 739, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "exclude", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " exclude = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L62_C4", "label": "fieldsets =", "type": "assigned_variable", "loc": [62, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.0481, 0.0008, 1, 0.65, 0.25, 340, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "fieldsets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fieldsets = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L63_C4", "label": "form =", "type": "assigned_variable", "loc": [63, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.0489, 0.0008, 1, 0.65, 0.3, 761, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " form = forms.ModelForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L64_C4", "label": "filter_vertical =", "type": "assigned_variable", "loc": [64, 64], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.0497, 0.0008, 1, 0.65, 0.35, 629, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "filter_vertical", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " filter_vertical = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L65_C4", "label": "filter_horizontal =", "type": "assigned_variable", "loc": [65, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.0504, 0.0008, 1, 0.65, 0.4, 258, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "filter_horizontal", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " filter_horizontal = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L66_C4", "label": "radio_fields =", "type": "assigned_variable", "loc": [66, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.0512, 0.0008, 1, 0.65, 0.45, 348, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "radio_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " radio_fields = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L67_C4", "label": "prepopulated_fields =", "type": "assigned_variable", "loc": [67, 67], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.052, 0.0008, 1, 0.65, 0.5, 127, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "prepopulated_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prepopulated_fields = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L68_C4", "label": "formfield_overrides =", "type": "assigned_variable", "loc": [68, 68], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.0528, 0.0008, 1, 0.65, 0.55, 865, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "formfield_overrides", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " formfield_overrides = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L69_C4", "label": "readonly_fields =", "type": "assigned_variable", "loc": [69, 69], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.0535, 0.0008, 1, 0.65, 0.6, 396, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "readonly_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " readonly_fields = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L71_C4", "label": "__init__", "type": "function", "loc": [71, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [2, 1, 0.0562, 0.0031, 1, 0.65, 0.65, 555, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self):\n overrides = FORMFIELD_FOR_DBFIELD_DEFAULTS.copy()\n overrides.update(self.formfield_overrides)\n self.formfield_overrides = overrides"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L72_C8", "label": "overrides = copy()", "type": "assigned_variable", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L71_C4", "vector": [14, 2, 0.0559, 0.0008, 2, 0.1, 0.0, 53, 3, 0, 0, 0, 739, 10, 1], "semantic": {"name": "overrides", "arg_names": [], "import_names": [], "rhs_call_name": "copy", "annotation": ""}, "snippet": " overrides = FORMFIELD_FOR_DBFIELD_DEFAULTS.copy()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L73_C8", "label": "update()", "type": "expression", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L71_C4", "vector": [8, 2, 0.0566, 0.0008, 2, 0.1, 0.5, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " overrides.update(self.formfield_overrides)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L74_C8", "label": "self.formfield_overrides =", "type": "assigned_variable", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L71_C4", "vector": [14, 2, 0.0574, 0.0008, 2, 0.1, 1.0, 964, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.formfield_overrides", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.formfield_overrides = overrides"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "label": "formfield_for_dbfield", "type": "function", "loc": [76, 128], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [2, 1, 0.0791, 0.0411, 1, 0.65, 0.7, 937, 0, 3, 1, 0, 0, 0, 16], "semantic": {"name": "formfield_for_dbfield", "arg_names": ["self", "db_field", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def formfield_for_dbfield(self, db_field, **kwargs):\n \"\"\"\n Hook for specifying the form Field instance for a given database Field\n instance.\n\n If kwargs are given, they're passed to the form Field's constructor.\n \"\"\"\n request = kwargs.pop(\"request\", None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L77_C8", "label": "expression", "type": "expression", "loc": [77, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "vector": [8, 2, 0.0617, 0.0047, 2, 0.94, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Hook for specifying the form Field instance for a given database Field\n instance.\n\n If kwargs are given, they're passed to the form Field's constructor.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L83_C8", "label": "request = pop()", "type": "assigned_variable", "loc": [83, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "vector": [14, 2, 0.0644, 0.0008, 2, 0.94, 0.2, 50, 3, 2, 0, 0, 969, 10, 1], "semantic": {"name": "request", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " request = kwargs.pop(\"request\", None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L87_C8", "label": "if", "type": "if", "loc": [87, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "vector": [4, 2, 0.0679, 0.0016, 2, 0.94, 0.4, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if db_field.choices:\n return self.formfield_for_choice_field(db_field, request, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L88_C12", "label": "return", "type": "return", "loc": [88, 88], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L87_C8", "vector": [13, 3, 0.0683, 0.0008, 3, 0.26, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.formfield_for_choice_field(db_field, request, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L91_C8", "label": "if", "type": "if", "loc": [91, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "vector": [4, 2, 0.0811, 0.0217, 2, 0.94, 0.6, 0, 3, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(db_field, (models.ForeignKey, models.ManyToManyField)):\n # Combine the field kwargs with any options for formfield_overrides.\n # Make sure the passed in **kwargs override anything in\n # formfield_overrides because **kwargs is more specific, and should\n # always win.\n if db_field.__class__ in self.formfield_overrides:\n kwargs = dict(self.formfield_overrides[db_field.__class__], **kwargs)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L96_C12", "label": "if", "type": "if", "loc": [96, 97], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L91_C8", "vector": [4, 3, 0.0749, 0.0016, 3, 0.54, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if db_field.__class__ in self.formfield_overrides:\n kwargs = dict(self.formfield_overrides[db_field.__class__], **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L97_C16", "label": "kwargs = dict()", "type": "assigned_variable", "loc": [97, 97], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L96_C12", "vector": [14, 4, 0.0753, 0.0008, 4, 0.94, 0.0, 987, 3, 2, 0, 0, 827, 10, 1], "semantic": {"name": "kwargs", "arg_names": [], "import_names": [], "rhs_call_name": "dict", "annotation": ""}, "snippet": " kwargs = dict(self.formfield_overrides[db_field.__class__], **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L100_C12", "label": "if", "type": "if", "loc": [100, 103], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L91_C8", "vector": [4, 3, 0.0787, 0.0031, 3, 0.54, 0.3333, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(db_field, models.ForeignKey):\n formfield = self.formfield_for_foreignkey(db_field, request, **kwargs)\n elif isinstance(db_field, models.ManyToManyField):\n formfield = self.formfield_for_manytomany(db_field, request, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L101_C16", "label": "formfield = formfield_for_foreignkey()", "type": "assigned_variable", "loc": [101, 101], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L100_C12", "vector": [14, 4, 0.0784, 0.0008, 4, 0.7, 0.0, 732, 3, 3, 0, 0, 168, 10, 1], "semantic": {"name": "formfield", "arg_names": [], "import_names": [], "rhs_call_name": "formfield_for_foreignkey", "annotation": ""}, "snippet": " formfield = self.formfield_for_foreignkey(db_field, request, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L102_C12", "label": "if", "type": "if", "loc": [102, 103], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L100_C12", "vector": [4, 4, 0.0795, 0.0016, 4, 0.7, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(db_field, models.ManyToManyField):\n formfield = self.formfield_for_manytomany(db_field, request, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L103_C16", "label": "formfield = formfield_for_manytomany()", "type": "assigned_variable", "loc": [103, 103], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L102_C12", "vector": [14, 5, 0.0799, 0.0008, 5, 0.15, 0.0, 732, 3, 3, 0, 0, 165, 10, 1], "semantic": {"name": "formfield", "arg_names": [], "import_names": [], "rhs_call_name": "formfield_for_manytomany", "annotation": ""}, "snippet": " formfield = self.formfield_for_manytomany(db_field, request, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L109_C12", "label": "if", "type": "if", "loc": [109, 116], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L91_C8", "vector": [4, 3, 0.0873, 0.0062, 3, 0.54, 0.6667, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if formfield and db_field.name not in self.raw_id_fields:\n related_modeladmin = self.admin_site._registry.get(\n db_field.rel.to)\n can_add_related = bool(related_modeladmin and\n related_modeladmin.has_add_permission(request))\n formfield.widget = widgets.RelatedFieldWidgetWrapper(\n formfield.widget, db_field.rel, self.admin_site,\n can_add_related=can_add_related)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L110_C16", "label": "related_modeladmin = get()", "type": "assigned_variable", "loc": [110, 111], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L109_C12", "vector": [14, 4, 0.0857, 0.0016, 4, 0.28, 0.0, 705, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "related_modeladmin", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " related_modeladmin = self.admin_site._registry.get(\n db_field.rel.to)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L112_C16", "label": "can_add_related = bool()", "type": "assigned_variable", "loc": [112, 113], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L109_C12", "vector": [14, 4, 0.0873, 0.0016, 4, 0.28, 0.5, 687, 3, 1, 0, 0, 337, 10, 2], "semantic": {"name": "can_add_related", "arg_names": [], "import_names": [], "rhs_call_name": "bool", "annotation": ""}, "snippet": " can_add_related = bool(related_modeladmin and\n related_modeladmin.has_add_permission(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L114_C16", "label": "formfield.widget = RelatedFieldWidgetWrapper()", "type": "assigned_variable", "loc": [114, 116], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L109_C12", "vector": [14, 4, 0.0892, 0.0023, 4, 0.28, 1.0, 463, 3, 4, 0, 0, 895, 10, 1], "semantic": {"name": "formfield.widget", "arg_names": [], "import_names": [], "rhs_call_name": "RelatedFieldWidgetWrapper", "annotation": ""}, "snippet": " formfield.widget = widgets.RelatedFieldWidgetWrapper(\n formfield.widget, db_field.rel, self.admin_site,\n can_add_related=can_add_related)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L118_C12", "label": "return", "type": "return", "loc": [118, 118], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L91_C8", "vector": [13, 3, 0.0915, 0.0008, 3, 0.54, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return formfield"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L122_C8", "label": "for klass", "type": "for", "loc": [122, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "vector": [6, 2, 0.0958, 0.0031, 2, 0.94, 0.8, 35, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "klass", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for klass in db_field.__class__.mro():\n if klass in self.formfield_overrides:\n kwargs = dict(self.formfield_overrides[klass], **kwargs)\n return db_field.formfield(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L123_C12", "label": "if", "type": "if", "loc": [123, 125], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L122_C8", "vector": [4, 3, 0.0962, 0.0023, 3, 0.46, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if klass in self.formfield_overrides:\n kwargs = dict(self.formfield_overrides[klass], **kwargs)\n return db_field.formfield(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L124_C16", "label": "kwargs = dict()", "type": "assigned_variable", "loc": [124, 124], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L123_C12", "vector": [14, 4, 0.0962, 0.0008, 4, 0.77, 0.0, 987, 3, 2, 0, 0, 827, 10, 1], "semantic": {"name": "kwargs", "arg_names": [], "import_names": [], "rhs_call_name": "dict", "annotation": ""}, "snippet": " kwargs = dict(self.formfield_overrides[klass], **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L125_C16", "label": "return", "type": "return", "loc": [125, 125], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L123_C12", "vector": [13, 4, 0.097, 0.0008, 4, 0.77, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return db_field.formfield(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L128_C8", "label": "return", "type": "return", "loc": [128, 128], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "vector": [13, 2, 0.0993, 0.0008, 2, 0.94, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return db_field.formfield(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L130_C4", "label": "formfield_for_choice_field", "type": "function", "loc": [130, 146], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [2, 1, 0.1071, 0.0132, 1, 0.65, 0.75, 1, 0, 4, 1, 0, 0, 0, 5], "semantic": {"name": "formfield_for_choice_field", "arg_names": ["self", "db_field", "request", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def formfield_for_choice_field(self, db_field, request=None, **kwargs):\n \"\"\"\n Get a form Field for a database Field that has declared choices.\n \"\"\"\n # If the field is named as a radio_field, use a RadioSelect\n if db_field.name in self.radio_fields:\n # Avoid stomping on custom widget/choices arguments.\n if 'widget' not in kwargs:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L131_C8", "label": "expression", "type": "expression", "loc": [131, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L130_C4", "vector": [8, 2, 0.1024, 0.0023, 2, 0.47, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Get a form Field for a database Field that has declared choices.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L135_C8", "label": "if", "type": "if", "loc": [135, 145], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L130_C4", "vector": [4, 2, 0.1086, 0.0085, 2, 0.47, 0.5, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if db_field.name in self.radio_fields:\n # Avoid stomping on custom widget/choices arguments.\n if 'widget' not in kwargs:\n kwargs['widget'] = widgets.AdminRadioSelect(attrs={\n 'class': get_ul_class(self.radio_fields[db_field.name]),\n })\n if 'choices' not in kwargs:\n kwargs['choices'] = db_field.get_choices("}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L137_C12", "label": "if", "type": "if", "loc": [137, 140], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L135_C8", "vector": [4, 3, 0.1074, 0.0031, 3, 0.59, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'widget' not in kwargs:\n kwargs['widget'] = widgets.AdminRadioSelect(attrs={\n 'class': get_ul_class(self.radio_fields[db_field.name]),\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L138_C16", "label": " = AdminRadioSelect()", "type": "assigned_variable", "loc": [138, 140], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L137_C12", "vector": [14, 4, 0.1078, 0.0023, 4, 0.95, 0.0, 0, 3, 1, 0, 0, 166, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "AdminRadioSelect", "annotation": ""}, "snippet": " kwargs['widget'] = widgets.AdminRadioSelect(attrs={\n 'class': get_ul_class(self.radio_fields[db_field.name]),\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L141_C12", "label": "if", "type": "if", "loc": [141, 145], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L135_C8", "vector": [4, 3, 0.1109, 0.0039, 3, 0.59, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'choices' not in kwargs:\n kwargs['choices'] = db_field.get_choices(\n include_blank = db_field.blank,\n blank_choice=[('', _('None'))]\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L142_C16", "label": " = get_choices()", "type": "assigned_variable", "loc": [142, 145], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L141_C12", "vector": [14, 4, 0.1113, 0.0031, 4, 0.63, 0.0, 0, 3, 2, 0, 0, 452, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get_choices", "annotation": ""}, "snippet": " kwargs['choices'] = db_field.get_choices(\n include_blank = db_field.blank,\n blank_choice=[('', _('None'))]\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L146_C8", "label": "return", "type": "return", "loc": [146, 146], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L130_C4", "vector": [13, 2, 0.1133, 0.0008, 2, 0.47, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return db_field.formfield(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L148_C4", "label": "formfield_for_foreignkey", "type": "function", "loc": [148, 161], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [2, 1, 0.1199, 0.0109, 1, 0.65, 0.8, 168, 0, 4, 1, 0, 0, 0, 6], "semantic": {"name": "formfield_for_foreignkey", "arg_names": ["self", "db_field", "request", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def formfield_for_foreignkey(self, db_field, request=None, **kwargs):\n \"\"\"\n Get a form Field for a ForeignKey.\n \"\"\"\n db = kwargs.get('using')\n if db_field.name in self.raw_id_fields:\n kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel, using=db)\n elif db_field.name in self.radio_fields:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L149_C8", "label": "expression", "type": "expression", "loc": [149, 151], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L148_C4", "vector": [8, 2, 0.1164, 0.0023, 2, 0.42, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Get a form Field for a ForeignKey.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L152_C8", "label": "db = get()", "type": "assigned_variable", "loc": [152, 152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L148_C4", "vector": [14, 2, 0.1179, 0.0008, 2, 0.42, 0.3333, 761, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "db", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " db = kwargs.get('using')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L153_C8", "label": "if", "type": "if", "loc": [153, 159], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L148_C4", "vector": [4, 2, 0.121, 0.0054, 2, 0.42, 0.6667, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if db_field.name in self.raw_id_fields:\n kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel, using=db)\n elif db_field.name in self.radio_fields:\n kwargs['widget'] = widgets.AdminRadioSelect(attrs={\n 'class': get_ul_class(self.radio_fields[db_field.name]),\n })\n kwargs['empty_label'] = db_field.blank and _('None') or None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L154_C12", "label": " = ForeignKeyRawIdWidget()", "type": "assigned_variable", "loc": [154, 154], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L153_C8", "vector": [14, 3, 0.1195, 0.0008, 3, 0.18, 0.0, 0, 3, 2, 0, 0, 554, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "ForeignKeyRawIdWidget", "annotation": ""}, "snippet": " kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel, using=db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L155_C8", "label": "if", "type": "if", "loc": [155, 159], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L153_C8", "vector": [4, 3, 0.1218, 0.0039, 3, 0.18, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif db_field.name in self.radio_fields:\n kwargs['widget'] = widgets.AdminRadioSelect(attrs={\n 'class': get_ul_class(self.radio_fields[db_field.name]),\n })\n kwargs['empty_label'] = db_field.blank and _('None') or None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L156_C12", "label": " = AdminRadioSelect()", "type": "assigned_variable", "loc": [156, 158], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L155_C8", "vector": [14, 4, 0.1218, 0.0023, 4, 0.25, 0.0, 0, 3, 1, 0, 0, 166, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "AdminRadioSelect", "annotation": ""}, "snippet": " kwargs['widget'] = widgets.AdminRadioSelect(attrs={\n 'class': get_ul_class(self.radio_fields[db_field.name]),\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L159_C12", "label": "assign", "type": "assigned_variable", "loc": [159, 159], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L155_C8", "vector": [14, 4, 0.1234, 0.0008, 4, 0.25, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs['empty_label'] = db_field.blank and _('None') or None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L161_C8", "label": "return", "type": "return", "loc": [161, 161], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L148_C4", "vector": [13, 2, 0.1249, 0.0008, 2, 0.42, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return db_field.formfield(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L163_C4", "label": "formfield_for_manytomany", "type": "function", "loc": [163, 179], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [2, 1, 0.1327, 0.0132, 1, 0.65, 0.85, 165, 0, 4, 1, 0, 0, 0, 6], "semantic": {"name": "formfield_for_manytomany", "arg_names": ["self", "db_field", "request", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def formfield_for_manytomany(self, db_field, request=None, **kwargs):\n \"\"\"\n Get a form Field for a ManyToManyField.\n \"\"\"\n # If it uses an intermediary model that isn't auto created, don't show\n # a field in admin.\n if not db_field.rel.through._meta.auto_created:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L164_C8", "label": "expression", "type": "expression", "loc": [164, 166], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L163_C4", "vector": [8, 2, 0.128, 0.0023, 2, 0.0, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Get a form Field for a ManyToManyField.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L169_C8", "label": "if", "type": "if", "loc": [169, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L163_C4", "vector": [4, 2, 0.1315, 0.0016, 2, 0.0, 0.25, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not db_field.rel.through._meta.auto_created:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L170_C12", "label": "return", "type": "return", "loc": [170, 170], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L169_C8", "vector": [13, 3, 0.1319, 0.0008, 3, 0.05, 0.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L171_C8", "label": "db = get()", "type": "assigned_variable", "loc": [171, 171], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L163_C4", "vector": [14, 2, 0.1327, 0.0008, 2, 0.0, 0.5, 761, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "db", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " db = kwargs.get('using')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L173_C8", "label": "if", "type": "if", "loc": [173, 177], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L163_C4", "vector": [4, 2, 0.1358, 0.0039, 2, 0.0, 0.75, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if db_field.name in self.raw_id_fields:\n kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel, using=db)\n kwargs['help_text'] = ''\n elif db_field.name in (list(self.filter_vertical) + list(self.filter_horizontal)):\n kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name, (db_field.name in self.filter_vertical))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L174_C12", "label": " = ManyToManyRawIdWidget()", "type": "assigned_variable", "loc": [174, 174], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L173_C8", "vector": [14, 3, 0.135, 0.0008, 3, 0.64, 0.0, 0, 3, 2, 0, 0, 602, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "ManyToManyRawIdWidget", "annotation": ""}, "snippet": " kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel, using=db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L175_C12", "label": "assign", "type": "assigned_variable", "loc": [175, 175], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L173_C8", "vector": [14, 3, 0.1358, 0.0008, 3, 0.64, 0.5, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs['help_text'] = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L176_C8", "label": "if", "type": "if", "loc": [176, 177], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L173_C8", "vector": [4, 3, 0.1369, 0.0016, 3, 0.64, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif db_field.name in (list(self.filter_vertical) + list(self.filter_horizontal)):\n kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name, (db_field.name in self.filter_vertical))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L177_C12", "label": " = FilteredSelectMultiple()", "type": "assigned_variable", "loc": [177, 177], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L176_C8", "vector": [14, 4, 0.1373, 0.0008, 4, 0.07, 0.0, 0, 3, 2, 0, 0, 128, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "FilteredSelectMultiple", "annotation": ""}, "snippet": " kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name, (db_field.name in self.filter_vertical))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L179_C8", "label": "return", "type": "return", "loc": [179, 179], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L163_C4", "vector": [13, 2, 0.1389, 0.0008, 2, 0.0, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return db_field.formfield(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L181_C4", "label": "_declared_fieldsets", "type": "function", "loc": [181, 186], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [2, 1, 0.1424, 0.0047, 1, 0.65, 0.9, 473, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "_declared_fieldsets", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _declared_fieldsets(self):\n if self.fieldsets:\n return self.fieldsets\n elif self.fields:\n return [(None, {'fields': self.fields})]\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L182_C8", "label": "if", "type": "if", "loc": [182, 185], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L181_C4", "vector": [4, 2, 0.1424, 0.0031, 2, 0.58, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.fieldsets:\n return self.fieldsets\n elif self.fields:\n return [(None, {'fields': self.fields})]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L183_C12", "label": "return", "type": "return", "loc": [183, 183], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L182_C8", "vector": [13, 3, 0.142, 0.0008, 3, 0.87, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.fieldsets"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L184_C8", "label": "if", "type": "if", "loc": [184, 185], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L182_C8", "vector": [4, 3, 0.1431, 0.0016, 3, 0.87, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif self.fields:\n return [(None, {'fields': self.fields})]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L185_C12", "label": "return", "type": "return", "loc": [185, 185], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L184_C8", "vector": [13, 4, 0.1435, 0.0008, 4, 0.09, 0.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [(None, {'fields': self.fields})]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L186_C8", "label": "return", "type": "return", "loc": [186, 186], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L181_C4", "vector": [13, 2, 0.1443, 0.0008, 2, 0.58, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L187_C4", "label": "declared_fieldsets = property()", "type": "assigned_variable", "loc": [187, 187], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [14, 1, 0.1451, 0.0008, 1, 0.65, 0.95, 676, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "declared_fieldsets", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " declared_fieldsets = property(_declared_fieldsets)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L189_C4", "label": "get_readonly_fields", "type": "function", "loc": [189, 190], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "vector": [2, 1, 0.147, 0.0016, 1, 0.65, 1.0, 250, 0, 3, 1, 0, 0, 0, 0], "semantic": {"name": "get_readonly_fields", "arg_names": ["self", "request", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_readonly_fields(self, request, obj=None):\n return self.readonly_fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L190_C8", "label": "return", "type": "return", "loc": [190, 190], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L189_C4", "vector": [13, 2, 0.1474, 0.0008, 2, 0.34, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.readonly_fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "label": "ModelAdmin", "type": "class", "loc": [192, 1205], "level": 0, "parent": null, "vector": [3, 0, 0.5419, 0.7867, 0, 0.66, 0.9118, 534, 0, 40, 0, 0, 170, 0, 99], "semantic": {"name": "ModelAdmin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ModelAdmin(BaseModelAdmin):\n \"Encapsulates all admin options and functionality for a given model.\"\n\n list_display = ('__str__',)\n list_display_links = ()\n list_filter = ()\n list_select_related = False\n list_per_page = 100"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L193_C4", "label": "expression", "type": "expression", "loc": [193, 193], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [8, 1, 0.1497, 0.0008, 1, 0.87, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Encapsulates all admin options and functionality for a given model.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L195_C4", "label": "list_display =", "type": "assigned_variable", "loc": [195, 195], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1513, 0.0008, 1, 0.87, 0.0154, 489, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "list_display", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_display = ('__str__',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L196_C4", "label": "list_display_links =", "type": "assigned_variable", "loc": [196, 196], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1521, 0.0008, 1, 0.87, 0.0308, 68, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "list_display_links", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_display_links = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L197_C4", "label": "list_filter =", "type": "assigned_variable", "loc": [197, 197], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1528, 0.0008, 1, 0.87, 0.0462, 851, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "list_filter", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_filter = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L198_C4", "label": "list_select_related =", "type": "assigned_variable", "loc": [198, 198], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1536, 0.0008, 1, 0.87, 0.0615, 824, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "list_select_related", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_select_related = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L199_C4", "label": "list_per_page =", "type": "assigned_variable", "loc": [199, 199], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1544, 0.0008, 1, 0.87, 0.0769, 735, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "list_per_page", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_per_page = 100"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L200_C4", "label": "list_editable =", "type": "assigned_variable", "loc": [200, 200], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1552, 0.0008, 1, 0.87, 0.0923, 36, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "list_editable", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " list_editable = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L201_C4", "label": "search_fields =", "type": "assigned_variable", "loc": [201, 201], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1559, 0.0008, 1, 0.87, 0.1077, 834, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "search_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " search_fields = ()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L202_C4", "label": "date_hierarchy =", "type": "assigned_variable", "loc": [202, 202], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1567, 0.0008, 1, 0.87, 0.1231, 317, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "date_hierarchy", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " date_hierarchy = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L203_C4", "label": "save_as =", "type": "assigned_variable", "loc": [203, 203], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1575, 0.0008, 1, 0.87, 0.1385, 755, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "save_as", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " save_as = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L204_C4", "label": "save_on_top =", "type": "assigned_variable", "loc": [204, 204], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1583, 0.0008, 1, 0.87, 0.1538, 544, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "save_on_top", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " save_on_top = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L205_C4", "label": "ordering =", "type": "assigned_variable", "loc": [205, 205], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.159, 0.0008, 1, 0.87, 0.1692, 656, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "ordering", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ordering = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L206_C4", "label": "inlines =", "type": "assigned_variable", "loc": [206, 206], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1598, 0.0008, 1, 0.87, 0.1846, 353, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "inlines", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " inlines = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L209_C4", "label": "add_form_template =", "type": "assigned_variable", "loc": [209, 209], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1621, 0.0008, 1, 0.87, 0.2, 405, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "add_form_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " add_form_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L210_C4", "label": "change_form_template =", "type": "assigned_variable", "loc": [210, 210], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1629, 0.0008, 1, 0.87, 0.2154, 759, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "change_form_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " change_form_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L211_C4", "label": "change_list_template =", "type": "assigned_variable", "loc": [211, 211], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1637, 0.0008, 1, 0.87, 0.2308, 303, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "change_list_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " change_list_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L212_C4", "label": "delete_confirmation_template =", "type": "assigned_variable", "loc": [212, 212], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1645, 0.0008, 1, 0.87, 0.2462, 789, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "delete_confirmation_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " delete_confirmation_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L213_C4", "label": "delete_selected_confirmation_template =", "type": "assigned_variable", "loc": [213, 213], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1652, 0.0008, 1, 0.87, 0.2615, 660, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "delete_selected_confirmation_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " delete_selected_confirmation_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L214_C4", "label": "object_history_template =", "type": "assigned_variable", "loc": [214, 214], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.166, 0.0008, 1, 0.87, 0.2769, 333, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "object_history_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " object_history_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L217_C4", "label": "actions =", "type": "assigned_variable", "loc": [217, 217], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1683, 0.0008, 1, 0.87, 0.2923, 317, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "actions", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " actions = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L218_C4", "label": "action_form =", "type": "assigned_variable", "loc": [218, 218], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1691, 0.0008, 1, 0.87, 0.3077, 971, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "action_form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " action_form = helpers.ActionForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L219_C4", "label": "actions_on_top =", "type": "assigned_variable", "loc": [219, 219], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1699, 0.0008, 1, 0.87, 0.3231, 858, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "actions_on_top", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " actions_on_top = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L220_C4", "label": "actions_on_bottom =", "type": "assigned_variable", "loc": [220, 220], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1707, 0.0008, 1, 0.87, 0.3385, 498, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "actions_on_bottom", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " actions_on_bottom = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L221_C4", "label": "actions_selection_counter =", "type": "assigned_variable", "loc": [221, 221], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.1715, 0.0008, 1, 0.87, 0.3538, 594, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "actions_selection_counter", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " actions_selection_counter = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "label": "__init__", "type": "function", "loc": [223, 238], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.1788, 0.0124, 1, 0.87, 0.3692, 555, 0, 3, 0, 0, 0, 0, 5], "semantic": {"name": "__init__", "arg_names": ["self", "model", "admin_site"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, model, admin_site):\n self.model = model\n self.opts = model._meta\n self.admin_site = admin_site\n self.inline_instances = []\n for inline_class in self.inlines:\n inline_instance = inline_class(self.model, self.admin_site)\n self.inline_instances.append(inline_instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L224_C8", "label": "self.model =", "type": "assigned_variable", "loc": [224, 224], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "vector": [14, 2, 0.1738, 0.0008, 2, 0.01, 0.0, 81, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model = model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L225_C8", "label": "self.opts =", "type": "assigned_variable", "loc": [225, 225], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "vector": [14, 2, 0.1746, 0.0008, 2, 0.01, 0.1429, 26, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.opts = model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L226_C8", "label": "self.admin_site =", "type": "assigned_variable", "loc": [226, 226], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "vector": [14, 2, 0.1753, 0.0008, 2, 0.01, 0.2857, 905, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.admin_site", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.admin_site = admin_site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L227_C8", "label": "self.inline_instances =", "type": "assigned_variable", "loc": [227, 227], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "vector": [14, 2, 0.1761, 0.0008, 2, 0.01, 0.4286, 871, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self.inline_instances", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.inline_instances = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L228_C8", "label": "for inline_class", "type": "for", "loc": [228, 230], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "vector": [6, 2, 0.1777, 0.0023, 2, 0.01, 0.5714, 326, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "inline_class", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for inline_class in self.inlines:\n inline_instance = inline_class(self.model, self.admin_site)\n self.inline_instances.append(inline_instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L229_C12", "label": "inline_instance = inline_class()", "type": "assigned_variable", "loc": [229, 229], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L228_C8", "vector": [14, 3, 0.1777, 0.0008, 3, 0.86, 0.0, 1, 3, 2, 0, 0, 326, 10, 1], "semantic": {"name": "inline_instance", "arg_names": [], "import_names": [], "rhs_call_name": "inline_class", "annotation": ""}, "snippet": " inline_instance = inline_class(self.model, self.admin_site)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L230_C12", "label": "append()", "type": "expression", "loc": [230, 230], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L228_C8", "vector": [8, 3, 0.1784, 0.0008, 3, 0.86, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " self.inline_instances.append(inline_instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L231_C8", "label": "if", "type": "if", "loc": [231, 232], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "vector": [4, 2, 0.1796, 0.0016, 2, 0.01, 0.7143, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'action_checkbox' not in self.list_display and self.actions is not None:\n self.list_display = ['action_checkbox'] + list(self.list_display)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L232_C12", "label": "self.list_display =", "type": "assigned_variable", "loc": [232, 232], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L231_C8", "vector": [14, 3, 0.18, 0.0008, 3, 0.19, 0.0, 341, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "self.list_display", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.list_display = ['action_checkbox'] + list(self.list_display)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L233_C8", "label": "if", "type": "if", "loc": [233, 237], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "vector": [4, 2, 0.1823, 0.0039, 2, 0.01, 0.8571, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.list_display_links:\n for name in self.list_display:\n if name != 'action_checkbox':\n self.list_display_links = [name]\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L234_C12", "label": "for name", "type": "for", "loc": [234, 237], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L233_C8", "vector": [6, 3, 0.1827, 0.0031, 3, 0.55, 0.0, 57, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name in self.list_display:\n if name != 'action_checkbox':\n self.list_display_links = [name]\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L235_C16", "label": "if", "type": "if", "loc": [235, 237], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L234_C12", "vector": [4, 4, 0.1831, 0.0023, 4, 0.88, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if name != 'action_checkbox':\n self.list_display_links = [name]\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L236_C20", "label": "self.list_display_links =", "type": "assigned_variable", "loc": [236, 236], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L235_C16", "vector": [14, 5, 0.1831, 0.0008, 5, 0.1, 0.0, 586, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self.list_display_links", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.list_display_links = [name]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L238_C8", "label": "__init__()", "type": "expression", "loc": [238, 238], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "vector": [8, 2, 0.1846, 0.0008, 2, 0.01, 1.0, 555, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(ModelAdmin, self).__init__()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L240_C4", "label": "get_urls", "type": "function", "loc": [240, 267], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.1967, 0.0217, 1, 0.87, 0.3846, 974, 0, 1, 1, 0, 0, 0, 14], "semantic": {"name": "get_urls", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_urls(self):\n from django.conf.urls.defaults import patterns, url\n\n def wrap(view):\n def wrapper(*args, **kwargs):\n return self.admin_site.admin_view(view)(*args, **kwargs)\n return update_wrapper(wrapper, view)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L241_C8", "label": "from django.conf.urls.defaults import patterns, url", "type": "import", "loc": [241, 241], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L240_C4", "vector": [1, 2, 0.187, 0.0008, 2, 0.95, 0.0, 341, 0, 2, 0, 0, 341, 0, 0], "semantic": {"name": "django.conf.urls.defaults", "arg_names": [], "import_names": ["patterns", "url"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.conf.urls.defaults import patterns, url"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L243_C8", "label": "wrap", "type": "function", "loc": [243, 246], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L240_C4", "vector": [2, 2, 0.1897, 0.0031, 2, 0.95, 0.25, 9, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "wrap", "arg_names": ["view"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def wrap(view):\n def wrapper(*args, **kwargs):\n return self.admin_site.admin_view(view)(*args, **kwargs)\n return update_wrapper(wrapper, view)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L244_C12", "label": "wrapper", "type": "function", "loc": [244, 245], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L243_C8", "vector": [2, 3, 0.1897, 0.0016, 3, 0.16, 0.0, 353, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "wrapper", "arg_names": ["args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def wrapper(*args, **kwargs):\n return self.admin_site.admin_view(view)(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L245_C16", "label": "return", "type": "return", "loc": [245, 245], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L244_C12", "vector": [13, 4, 0.1901, 0.0008, 4, 0.1, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.admin_site.admin_view(view)(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L246_C12", "label": "return", "type": "return", "loc": [246, 246], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L243_C8", "vector": [13, 3, 0.1908, 0.0008, 3, 0.16, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return update_wrapper(wrapper, view)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L248_C8", "label": "info =", "type": "assigned_variable", "loc": [248, 248], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L240_C4", "vector": [14, 2, 0.1924, 0.0008, 2, 0.95, 0.5, 730, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "info", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " info = self.model._meta.app_label, self.model._meta.module_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L250_C8", "label": "urlpatterns = patterns()", "type": "assigned_variable", "loc": [250, 266], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L240_C4", "vector": [14, 2, 0.2002, 0.0132, 2, 0.95, 0.75, 990, 3, 6, 0, 0, 75, 10, 11], "semantic": {"name": "urlpatterns", "arg_names": [], "import_names": [], "rhs_call_name": "patterns", "annotation": ""}, "snippet": " urlpatterns = patterns('',\n url(r'^$',\n wrap(self.changelist_view),\n name='%s_%s_changelist' % info),\n url(r'^add/$',\n wrap(self.add_view),\n name='%s_%s_add' % info),\n url(r'^(.+)/history/$',"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L267_C8", "label": "return", "type": "return", "loc": [267, 267], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L240_C4", "vector": [13, 2, 0.2071, 0.0008, 2, 0.95, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return urlpatterns"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L269_C4", "label": "urls", "type": "function", "loc": [269, 270], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.2091, 0.0016, 1, 0.87, 0.4, 260, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "urls", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def urls(self):\n return self.get_urls()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L270_C8", "label": "return", "type": "return", "loc": [270, 270], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L269_C4", "vector": [13, 2, 0.2095, 0.0008, 2, 0.45, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.get_urls()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L271_C4", "label": "urls = property()", "type": "assigned_variable", "loc": [271, 271], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.2102, 0.0008, 1, 0.87, 0.4154, 260, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "urls", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " urls = property(urls)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "label": "_media", "type": "function", "loc": [273, 286], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.2168, 0.0109, 1, 0.87, 0.4308, 650, 0, 1, 1, 0, 0, 0, 6], "semantic": {"name": "_media", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _media(self):\n from django.conf import settings\n\n js = ['js/core.js', 'js/admin/RelatedObjectLookups.js',\n 'js/jquery.min.js', 'js/jquery.init.js']\n if self.actions is not None:\n js.extend(['js/actions.min.js'])\n if self.prepopulated_fields:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L274_C8", "label": "from django.conf import settings", "type": "import", "loc": [274, 274], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "vector": [1, 2, 0.2126, 0.0008, 2, 0.14, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L276_C8", "label": "js =", "type": "assigned_variable", "loc": [276, 277], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "vector": [14, 2, 0.2145, 0.0016, 2, 0.14, 0.2, 62, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "js", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " js = ['js/core.js', 'js/admin/RelatedObjectLookups.js',\n 'js/jquery.min.js', 'js/jquery.init.js']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L278_C8", "label": "if", "type": "if", "loc": [278, 279], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "vector": [4, 2, 0.2161, 0.0016, 2, 0.14, 0.4, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.actions is not None:\n js.extend(['js/actions.min.js'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L279_C12", "label": "extend()", "type": "expression", "loc": [279, 279], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L278_C8", "vector": [8, 3, 0.2164, 0.0008, 3, 0.78, 0.0, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " js.extend(['js/actions.min.js'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L280_C8", "label": "if", "type": "if", "loc": [280, 282], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "vector": [4, 2, 0.218, 0.0023, 2, 0.14, 0.6, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.prepopulated_fields:\n js.append('js/urlify.js')\n js.append('js/prepopulate.min.js')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L281_C12", "label": "append()", "type": "expression", "loc": [281, 281], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L280_C8", "vector": [8, 3, 0.218, 0.0008, 3, 0.16, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " js.append('js/urlify.js')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L282_C12", "label": "append()", "type": "expression", "loc": [282, 282], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L280_C8", "vector": [8, 3, 0.2188, 0.0008, 3, 0.16, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " js.append('js/prepopulate.min.js')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L283_C8", "label": "if", "type": "if", "loc": [283, 284], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "vector": [4, 2, 0.2199, 0.0016, 2, 0.14, 0.8, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.opts.get_ordered_objects():\n js.extend(['js/getElementsBySelector.js', 'js/dom-drag.js' , 'js/admin/ordering.js'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L284_C12", "label": "extend()", "type": "expression", "loc": [284, 284], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L283_C8", "vector": [8, 3, 0.2203, 0.0008, 3, 0.35, 0.0, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " js.extend(['js/getElementsBySelector.js', 'js/dom-drag.js' , 'js/admin/ordering.js'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L286_C8", "label": "return", "type": "return", "loc": [286, 286], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "vector": [13, 2, 0.2219, 0.0008, 2, 0.14, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L287_C4", "label": "media = property()", "type": "assigned_variable", "loc": [287, 287], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.2227, 0.0008, 1, 0.87, 0.4462, 317, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " media = property(_media)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L289_C4", "label": "has_add_permission", "type": "function", "loc": [289, 292], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.2254, 0.0031, 1, 0.87, 0.4615, 981, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "has_add_permission", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_add_permission(self, request):\n \"Returns True if the given request has permission to add an object.\"\n opts = self.opts\n return request.user.has_perm(opts.app_label + '.' + opts.get_add_permission())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L290_C8", "label": "expression", "type": "expression", "loc": [290, 290], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L289_C4", "vector": [8, 2, 0.225, 0.0008, 2, 0.13, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns True if the given request has permission to add an object.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L291_C8", "label": "opts =", "type": "assigned_variable", "loc": [291, 291], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L289_C4", "vector": [14, 2, 0.2258, 0.0008, 2, 0.13, 0.5, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = self.opts"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L292_C8", "label": "return", "type": "return", "loc": [292, 292], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L289_C4", "vector": [13, 2, 0.2265, 0.0008, 2, 0.13, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return request.user.has_perm(opts.app_label + '.' + opts.get_add_permission())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L294_C4", "label": "has_change_permission", "type": "function", "loc": [294, 303], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.2316, 0.0078, 1, 0.87, 0.4769, 871, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "has_change_permission", "arg_names": ["self", "request", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_change_permission(self, request, obj=None):\n \"\"\"\n Returns True if the given request has permission to change the given\n Django model instance.\n\n If `obj` is None, this should return True if the given request has\n permission to change *any* object of the given type.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L295_C8", "label": "expression", "type": "expression", "loc": [295, 301], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L294_C4", "vector": [8, 2, 0.2312, 0.0054, 2, 0.7, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns True if the given request has permission to change the given\n Django model instance.\n\n If `obj` is None, this should return True if the given request has\n permission to change *any* object of the given type.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L302_C8", "label": "opts =", "type": "assigned_variable", "loc": [302, 302], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L294_C4", "vector": [14, 2, 0.2343, 0.0008, 2, 0.7, 0.5, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = self.opts"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L303_C8", "label": "return", "type": "return", "loc": [303, 303], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L294_C4", "vector": [13, 2, 0.2351, 0.0008, 2, 0.7, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return request.user.has_perm(opts.app_label + '.' + opts.get_change_permission())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L305_C4", "label": "has_delete_permission", "type": "function", "loc": [305, 314], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.2401, 0.0078, 1, 0.87, 0.4923, 495, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "has_delete_permission", "arg_names": ["self", "request", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_delete_permission(self, request, obj=None):\n \"\"\"\n Returns True if the given request has permission to change the given\n Django model instance.\n\n If `obj` is None, this should return True if the given request has\n permission to delete *any* object of the given type.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L306_C8", "label": "expression", "type": "expression", "loc": [306, 312], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L305_C4", "vector": [8, 2, 0.2397, 0.0054, 2, 0.01, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns True if the given request has permission to change the given\n Django model instance.\n\n If `obj` is None, this should return True if the given request has\n permission to delete *any* object of the given type.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L313_C8", "label": "opts =", "type": "assigned_variable", "loc": [313, 313], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L305_C4", "vector": [14, 2, 0.2428, 0.0008, 2, 0.01, 0.5, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = self.opts"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L314_C8", "label": "return", "type": "return", "loc": [314, 314], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L305_C4", "vector": [13, 2, 0.2436, 0.0008, 2, 0.01, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return request.user.has_perm(opts.app_label + '.' + opts.get_delete_permission())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L316_C4", "label": "get_model_perms", "type": "function", "loc": [316, 326], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.249, 0.0085, 1, 0.87, 0.5077, 319, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "get_model_perms", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_model_perms(self, request):\n \"\"\"\n Returns a dict of all perms for this model. This dict has the keys\n ``add``, ``change``, and ``delete`` mapping to the True/False for each\n of those actions.\n \"\"\"\n return {\n 'add': self.has_add_permission(request),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L317_C8", "label": "expression", "type": "expression", "loc": [317, 321], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L316_C4", "vector": [8, 2, 0.2475, 0.0039, 2, 0.19, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a dict of all perms for this model. This dict has the keys\n ``add``, ``change``, and ``delete`` mapping to the True/False for each\n of those actions.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L322_C8", "label": "return", "type": "return", "loc": [322, 326], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L316_C4", "vector": [13, 2, 0.2514, 0.0039, 2, 0.19, 1.0, 0, 0, 0, 0, 0, 0, 6, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {\n 'add': self.has_add_permission(request),\n 'change': self.has_change_permission(request),\n 'delete': self.has_delete_permission(request),\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L328_C4", "label": "queryset", "type": "function", "loc": [328, 338], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.2583, 0.0085, 1, 0.87, 0.5231, 38, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "queryset", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def queryset(self, request):\n \"\"\"\n Returns a QuerySet of all model instances that can be edited by the\n admin site. This is used by changelist_view.\n \"\"\"\n qs = self.model._default_manager.get_query_set()\n # TODO: this should be handled by some parameter to the ChangeList.\n ordering = self.ordering or () # otherwise we might try to *None, which is bad ;)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L329_C8", "label": "expression", "type": "expression", "loc": [329, 332], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L328_C4", "vector": [8, 2, 0.2564, 0.0031, 2, 0.21, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a QuerySet of all model instances that can be edited by the\n admin site. This is used by changelist_view.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L333_C8", "label": "qs = get_query_set()", "type": "assigned_variable", "loc": [333, 333], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L328_C4", "vector": [14, 2, 0.2583, 0.0008, 2, 0.21, 0.25, 251, 3, 0, 0, 0, 696, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "get_query_set", "annotation": ""}, "snippet": " qs = self.model._default_manager.get_query_set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L335_C8", "label": "ordering =", "type": "assigned_variable", "loc": [335, 335], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L328_C4", "vector": [14, 2, 0.2599, 0.0008, 2, 0.21, 0.5, 656, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "ordering", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ordering = self.ordering or () # otherwise we might try to *None, which is bad ;)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L336_C8", "label": "if", "type": "if", "loc": [336, 337], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L328_C4", "vector": [4, 2, 0.2611, 0.0016, 2, 0.21, 0.75, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ordering:\n qs = qs.order_by(*ordering)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L337_C12", "label": "qs = order_by()", "type": "assigned_variable", "loc": [337, 337], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L336_C8", "vector": [14, 3, 0.2614, 0.0008, 3, 0.42, 0.0, 251, 3, 1, 0, 0, 23, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "order_by", "annotation": ""}, "snippet": " qs = qs.order_by(*ordering)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L338_C8", "label": "return", "type": "return", "loc": [338, 338], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L328_C4", "vector": [13, 2, 0.2622, 0.0008, 2, 0.21, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return qs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L340_C4", "label": "get_fieldsets", "type": "function", "loc": [340, 346], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.2661, 0.0054, 1, 0.87, 0.5385, 273, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "get_fieldsets", "arg_names": ["self", "request", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_fieldsets(self, request, obj=None):\n \"Hook for specifying fieldsets for the add form.\"\n if self.declared_fieldsets:\n return self.declared_fieldsets\n form = self.get_form(request, obj)\n fields = form.base_fields.keys() + list(self.get_readonly_fields(request, obj))\n return [(None, {'fields': fields})]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L341_C8", "label": "expression", "type": "expression", "loc": [341, 341], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L340_C4", "vector": [8, 2, 0.2645, 0.0008, 2, 0.59, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Hook for specifying fieldsets for the add form.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L342_C8", "label": "if", "type": "if", "loc": [342, 343], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L340_C4", "vector": [4, 2, 0.2657, 0.0016, 2, 0.59, 0.25, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.declared_fieldsets:\n return self.declared_fieldsets"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L343_C12", "label": "return", "type": "return", "loc": [343, 343], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L342_C8", "vector": [13, 3, 0.2661, 0.0008, 3, 0.52, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.declared_fieldsets"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L344_C8", "label": "form = get_form()", "type": "assigned_variable", "loc": [344, 344], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L340_C4", "vector": [14, 2, 0.2669, 0.0008, 2, 0.59, 0.5, 761, 3, 2, 0, 0, 265, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "get_form", "annotation": ""}, "snippet": " form = self.get_form(request, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L345_C8", "label": "fields =", "type": "assigned_variable", "loc": [345, 345], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L340_C4", "vector": [14, 2, 0.2676, 0.0008, 2, 0.59, 0.75, 358, 4, 0, 0, 0, 0, 0, 3], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fields = form.base_fields.keys() + list(self.get_readonly_fields(request, obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L346_C8", "label": "return", "type": "return", "loc": [346, 346], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L340_C4", "vector": [13, 2, 0.2684, 0.0008, 2, 0.59, 1.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [(None, {'fields': fields})]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "label": "get_form", "type": "function", "loc": [348, 373], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.2797, 0.0202, 1, 0.87, 0.5538, 265, 0, 4, 1, 0, 0, 0, 9], "semantic": {"name": "get_form", "arg_names": ["self", "request", "obj", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_form(self, request, obj=None, **kwargs):\n \"\"\"\n Returns a Form class for use in the admin add view. This is used by\n add_view and change_view.\n \"\"\"\n if self.declared_fieldsets:\n fields = flatten_fieldsets(self.declared_fieldsets)\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L349_C8", "label": "expression", "type": "expression", "loc": [349, 352], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "vector": [8, 2, 0.2719, 0.0031, 2, 0.04, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a Form class for use in the admin add view. This is used by\n add_view and change_view.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L353_C8", "label": "if", "type": "if", "loc": [353, 356], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "vector": [4, 2, 0.275, 0.0031, 2, 0.04, 0.125, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.declared_fieldsets:\n fields = flatten_fieldsets(self.declared_fieldsets)\n else:\n fields = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L354_C12", "label": "fields = flatten_fieldsets()", "type": "assigned_variable", "loc": [354, 354], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L353_C8", "vector": [14, 3, 0.2746, 0.0008, 3, 0.01, 0.0, 358, 3, 1, 0, 0, 348, 10, 1], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "flatten_fieldsets", "annotation": ""}, "snippet": " fields = flatten_fieldsets(self.declared_fieldsets)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L356_C12", "label": "fields =", "type": "assigned_variable", "loc": [356, 356], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L353_C8", "vector": [14, 3, 0.2762, 0.0008, 3, 0.01, 1.0, 358, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fields = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L357_C8", "label": "if", "type": "if", "loc": [357, 360], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "vector": [4, 2, 0.2781, 0.0031, 2, 0.04, 0.25, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.exclude is None:\n exclude = []\n else:\n exclude = list(self.exclude)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L358_C12", "label": "exclude =", "type": "assigned_variable", "loc": [358, 358], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L357_C8", "vector": [14, 3, 0.2777, 0.0008, 3, 0.73, 0.0, 739, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "exclude", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " exclude = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L360_C12", "label": "exclude = list()", "type": "assigned_variable", "loc": [360, 360], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L357_C8", "vector": [14, 3, 0.2793, 0.0008, 3, 0.73, 1.0, 739, 3, 1, 0, 0, 430, 10, 1], "semantic": {"name": "exclude", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " exclude = list(self.exclude)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L361_C8", "label": "extend()", "type": "expression", "loc": [361, 361], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "vector": [8, 2, 0.2801, 0.0008, 2, 0.04, 0.375, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " exclude.extend(kwargs.get(\"exclude\", []))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L362_C8", "label": "extend()", "type": "expression", "loc": [362, 362], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "vector": [8, 2, 0.2808, 0.0008, 2, 0.04, 0.5, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " exclude.extend(self.get_readonly_fields(request, obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L365_C8", "label": "exclude =", "type": "assigned_variable", "loc": [365, 365], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "vector": [14, 2, 0.2832, 0.0008, 2, 0.04, 0.625, 739, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "exclude", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " exclude = exclude or None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L366_C8", "label": "defaults =", "type": "assigned_variable", "loc": [366, 371], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "vector": [14, 2, 0.2859, 0.0047, 2, 0.04, 0.75, 233, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "defaults", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults = {\n \"form\": self.form,\n \"fields\": fields,\n \"exclude\": exclude,\n \"formfield_callback\": curry(self.formfield_for_dbfield, request=request),\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L372_C8", "label": "update()", "type": "expression", "loc": [372, 372], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "vector": [8, 2, 0.2886, 0.0008, 2, 0.04, 0.875, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " defaults.update(kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L373_C8", "label": "return", "type": "return", "loc": [373, 373], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "vector": [13, 2, 0.2894, 0.0008, 2, 0.04, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return modelform_factory(self.model, **defaults)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L375_C4", "label": "get_changelist", "type": "function", "loc": [375, 380], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.2929, 0.0047, 1, 0.87, 0.5692, 202, 0, 3, 1, 0, 0, 0, 0], "semantic": {"name": "get_changelist", "arg_names": ["self", "request", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_changelist(self, request, **kwargs):\n \"\"\"\n Returns the ChangeList class for use on the changelist page.\n \"\"\"\n from django.contrib.admin.views.main import ChangeList\n return ChangeList"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L376_C8", "label": "expression", "type": "expression", "loc": [376, 378], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L375_C4", "vector": [8, 2, 0.2925, 0.0023, 2, 0.24, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns the ChangeList class for use on the changelist page.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L379_C8", "label": "from django.contrib.admin.views.main import ChangeList", "type": "import", "loc": [379, 379], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L375_C4", "vector": [1, 2, 0.294, 0.0008, 2, 0.24, 0.5, 696, 0, 1, 0, 0, 696, 0, 0], "semantic": {"name": "django.contrib.admin.views.main", "arg_names": [], "import_names": ["ChangeList"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.views.main import ChangeList"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L380_C8", "label": "return", "type": "return", "loc": [380, 380], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L375_C4", "vector": [13, 2, 0.2948, 0.0008, 2, 0.24, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ChangeList"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L382_C4", "label": "get_object", "type": "function", "loc": [382, 394], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.301, 0.0101, 1, 0.87, 0.5846, 237, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "get_object", "arg_names": ["self", "request", "object_id"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_object(self, request, object_id):\n \"\"\"\n Returns an instance matching the primary key provided. ``None`` is\n returned if no match is found (or the object_id failed validation\n against the primary key field).\n \"\"\"\n queryset = self.queryset(request)\n model = queryset.model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L383_C8", "label": "expression", "type": "expression", "loc": [383, 387], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L382_C4", "vector": [8, 2, 0.2987, 0.0039, 2, 0.49, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns an instance matching the primary key provided. ``None`` is\n returned if no match is found (or the object_id failed validation\n against the primary key field).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L388_C8", "label": "queryset = queryset()", "type": "assigned_variable", "loc": [388, 388], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L382_C4", "vector": [14, 2, 0.301, 0.0008, 2, 0.49, 0.3333, 38, 3, 1, 0, 0, 38, 10, 1], "semantic": {"name": "queryset", "arg_names": [], "import_names": [], "rhs_call_name": "queryset", "annotation": ""}, "snippet": " queryset = self.queryset(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L389_C8", "label": "model =", "type": "assigned_variable", "loc": [389, 389], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L382_C4", "vector": [14, 2, 0.3018, 0.0008, 2, 0.49, 0.6667, 722, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model = queryset.model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L390_C8", "label": "try", "type": "try", "loc": [390, 394], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L382_C4", "vector": [7, 2, 0.3041, 0.0039, 2, 0.49, 1.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n object_id = model._meta.pk.to_python(object_id)\n return queryset.get(pk=object_id)\n except (model.DoesNotExist, ValidationError):\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L391_C12", "label": "object_id = to_python()", "type": "assigned_variable", "loc": [391, 391], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L390_C8", "vector": [14, 3, 0.3033, 0.0008, 3, 0.71, 0.0, 992, 3, 1, 0, 0, 800, 10, 1], "semantic": {"name": "object_id", "arg_names": [], "import_names": [], "rhs_call_name": "to_python", "annotation": ""}, "snippet": " object_id = model._meta.pk.to_python(object_id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L392_C12", "label": "return", "type": "return", "loc": [392, 392], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L390_C8", "vector": [13, 3, 0.3041, 0.0008, 3, 0.71, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return queryset.get(pk=object_id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L394_C12", "label": "return", "type": "return", "loc": [394, 394], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L390_C8", "vector": [13, 3, 0.3057, 0.0008, 3, 0.71, 0.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L396_C4", "label": "get_changelist_form", "type": "function", "loc": [396, 404], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.3103, 0.007, 1, 0.87, 0.6, 323, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "get_changelist_form", "arg_names": ["self", "request", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_changelist_form(self, request, **kwargs):\n \"\"\"\n Returns a Form class for use in the Formset on the changelist page.\n \"\"\"\n defaults = {\n \"formfield_callback\": curry(self.formfield_for_dbfield, request=request),\n }\n defaults.update(kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L397_C8", "label": "expression", "type": "expression", "loc": [397, 399], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L396_C4", "vector": [8, 2, 0.3088, 0.0023, 2, 0.85, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a Form class for use in the Formset on the changelist page.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L400_C8", "label": "defaults =", "type": "assigned_variable", "loc": [400, 402], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L396_C4", "vector": [14, 2, 0.3111, 0.0023, 2, 0.85, 0.3333, 233, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "defaults", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults = {\n \"formfield_callback\": curry(self.formfield_for_dbfield, request=request),\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L403_C8", "label": "update()", "type": "expression", "loc": [403, 403], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L396_C4", "vector": [8, 2, 0.3126, 0.0008, 2, 0.85, 0.6667, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " defaults.update(kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L404_C8", "label": "return", "type": "return", "loc": [404, 404], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L396_C4", "vector": [13, 2, 0.3134, 0.0008, 2, 0.85, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return modelform_factory(self.model, **defaults)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L406_C4", "label": "get_changelist_formset", "type": "function", "loc": [406, 417], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.3192, 0.0093, 1, 0.87, 0.6154, 590, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "get_changelist_formset", "arg_names": ["self", "request", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_changelist_formset(self, request, **kwargs):\n \"\"\"\n Returns a FormSet class for use on the changelist page if list_editable\n is used.\n \"\"\"\n defaults = {\n \"formfield_callback\": curry(self.formfield_for_dbfield, request=request),\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L407_C8", "label": "expression", "type": "expression", "loc": [407, 410], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L406_C4", "vector": [8, 2, 0.3169, 0.0031, 2, 0.49, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a FormSet class for use on the changelist page if list_editable\n is used.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L411_C8", "label": "defaults =", "type": "assigned_variable", "loc": [411, 413], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L406_C4", "vector": [14, 2, 0.3196, 0.0023, 2, 0.49, 0.3333, 233, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "defaults", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults = {\n \"formfield_callback\": curry(self.formfield_for_dbfield, request=request),\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L414_C8", "label": "update()", "type": "expression", "loc": [414, 414], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L406_C4", "vector": [8, 2, 0.3212, 0.0008, 2, 0.49, 0.6667, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " defaults.update(kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L415_C8", "label": "return", "type": "return", "loc": [415, 417], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L406_C4", "vector": [13, 2, 0.3227, 0.0023, 2, 0.49, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return modelformset_factory(self.model,\n self.get_changelist_form(request), extra=0,\n fields=self.list_editable, **defaults)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L419_C4", "label": "get_formsets", "type": "function", "loc": [419, 421], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.3258, 0.0023, 1, 0.87, 0.6308, 869, 0, 3, 0, 0, 0, 0, 1], "semantic": {"name": "get_formsets", "arg_names": ["self", "request", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_formsets(self, request, obj=None):\n for inline in self.inline_instances:\n yield inline.get_formset(request, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L420_C8", "label": "for inline", "type": "for", "loc": [420, 421], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L419_C4", "vector": [6, 2, 0.3262, 0.0016, 2, 0.75, 0.0, 7, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "inline", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for inline in self.inline_instances:\n yield inline.get_formset(request, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L421_C12", "label": "expression", "type": "expression", "loc": [421, 421], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L420_C8", "vector": [8, 3, 0.3266, 0.0008, 3, 0.99, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield inline.get_formset(request, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L423_C4", "label": "log_addition", "type": "function", "loc": [423, 436], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.3332, 0.0109, 1, 0.87, 0.6462, 76, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "log_addition", "arg_names": ["self", "request", "object"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def log_addition(self, request, object):\n \"\"\"\n Log that an object has been successfully added.\n\n The default implementation creates an admin LogEntry object.\n \"\"\"\n from django.contrib.admin.models import LogEntry, ADDITION\n LogEntry.objects.log_action("}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L424_C8", "label": "expression", "type": "expression", "loc": [424, 428], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L423_C4", "vector": [8, 2, 0.3305, 0.0039, 2, 0.94, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Log that an object has been successfully added.\n\n The default implementation creates an admin LogEntry object.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L429_C8", "label": "from django.contrib.admin.models import LogEntry, ADDITION", "type": "import", "loc": [429, 429], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L423_C4", "vector": [1, 2, 0.3328, 0.0008, 2, 0.94, 0.5, 408, 0, 2, 0, 0, 408, 0, 0], "semantic": {"name": "django.contrib.admin.models", "arg_names": [], "import_names": ["LogEntry", "ADDITION"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.models import LogEntry, ADDITION"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L430_C8", "label": "log_action()", "type": "expression", "loc": [430, 436], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L423_C4", "vector": [8, 2, 0.3359, 0.0054, 2, 0.94, 1.0, 230, 3, 5, 0, 0, 0, 0, 3], "semantic": {"name": "log_action", "arg_names": [], "import_names": [], "rhs_call_name": "log_action", "annotation": ""}, "snippet": " LogEntry.objects.log_action(\n user_id = request.user.pk,\n content_type_id = ContentType.objects.get_for_model(object).pk,\n object_id = object.pk,\n object_repr = force_unicode(object),\n action_flag = ADDITION\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L438_C4", "label": "log_change", "type": "function", "loc": [438, 452], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.3452, 0.0116, 1, 0.87, 0.6615, 625, 0, 4, 0, 0, 0, 0, 3], "semantic": {"name": "log_change", "arg_names": ["self", "request", "object", "message"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def log_change(self, request, object, message):\n \"\"\"\n Log that an object has been successfully changed.\n\n The default implementation creates an admin LogEntry object.\n \"\"\"\n from django.contrib.admin.models import LogEntry, CHANGE\n LogEntry.objects.log_action("}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L439_C8", "label": "expression", "type": "expression", "loc": [439, 443], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L438_C4", "vector": [8, 2, 0.3421, 0.0039, 2, 0.24, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Log that an object has been successfully changed.\n\n The default implementation creates an admin LogEntry object.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L444_C8", "label": "from django.contrib.admin.models import LogEntry, CHANGE", "type": "import", "loc": [444, 444], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L438_C4", "vector": [1, 2, 0.3445, 0.0008, 2, 0.24, 0.5, 408, 0, 2, 0, 0, 408, 0, 0], "semantic": {"name": "django.contrib.admin.models", "arg_names": [], "import_names": ["LogEntry", "CHANGE"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.models import LogEntry, CHANGE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L445_C8", "label": "log_action()", "type": "expression", "loc": [445, 452], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L438_C4", "vector": [8, 2, 0.3479, 0.0062, 2, 0.24, 1.0, 230, 3, 6, 0, 0, 0, 0, 3], "semantic": {"name": "log_action", "arg_names": [], "import_names": [], "rhs_call_name": "log_action", "annotation": ""}, "snippet": " LogEntry.objects.log_action(\n user_id = request.user.pk,\n content_type_id = ContentType.objects.get_for_model(object).pk,\n object_id = object.pk,\n object_repr = force_unicode(object),\n action_flag = CHANGE,\n change_message = message\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L454_C4", "label": "log_deletion", "type": "function", "loc": [454, 468], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.3576, 0.0116, 1, 0.87, 0.6769, 271, 0, 4, 0, 0, 0, 0, 2], "semantic": {"name": "log_deletion", "arg_names": ["self", "request", "object", "object_repr"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def log_deletion(self, request, object, object_repr):\n \"\"\"\n Log that an object will be deleted. Note that this method is called\n before the deletion.\n\n The default implementation creates an admin LogEntry object.\n \"\"\"\n from django.contrib.admin.models import LogEntry, DELETION"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L455_C8", "label": "expression", "type": "expression", "loc": [455, 460], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L454_C4", "vector": [8, 2, 0.3549, 0.0047, 2, 0.91, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Log that an object will be deleted. Note that this method is called\n before the deletion.\n\n The default implementation creates an admin LogEntry object.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L461_C8", "label": "from django.contrib.admin.models import LogEntry, DELETION", "type": "import", "loc": [461, 461], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L454_C4", "vector": [1, 2, 0.3576, 0.0008, 2, 0.91, 0.5, 408, 0, 2, 0, 0, 408, 0, 0], "semantic": {"name": "django.contrib.admin.models", "arg_names": [], "import_names": ["LogEntry", "DELETION"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.models import LogEntry, DELETION"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L462_C8", "label": "log_action()", "type": "expression", "loc": [462, 468], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L454_C4", "vector": [8, 2, 0.3607, 0.0054, 2, 0.91, 1.0, 230, 3, 5, 0, 0, 0, 0, 2], "semantic": {"name": "log_action", "arg_names": [], "import_names": [], "rhs_call_name": "log_action", "annotation": ""}, "snippet": " LogEntry.objects.log_action(\n user_id = request.user.id,\n content_type_id = ContentType.objects.get_for_model(self.model).pk,\n object_id = object.pk,\n object_repr = object_repr,\n action_flag = DELETION\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L470_C4", "label": "action_checkbox", "type": "function", "loc": [470, 474], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.3662, 0.0039, 1, 0.87, 0.6923, 412, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "action_checkbox", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def action_checkbox(self, obj):\n \"\"\"\n A list_display column containing a checkbox widget.\n \"\"\"\n return helpers.checkbox.render(helpers.ACTION_CHECKBOX_NAME, force_unicode(obj.pk))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L471_C8", "label": "expression", "type": "expression", "loc": [471, 473], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L470_C4", "vector": [8, 2, 0.3662, 0.0023, 2, 0.39, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A list_display column containing a checkbox widget.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L474_C8", "label": "return", "type": "return", "loc": [474, 474], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L470_C4", "vector": [13, 2, 0.3677, 0.0008, 2, 0.39, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return helpers.checkbox.render(helpers.ACTION_CHECKBOX_NAME, force_unicode(obj.pk))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L475_C4", "label": "action_checkbox.short_description = mark_safe()", "type": "assigned_variable", "loc": [475, 475], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.3685, 0.0008, 1, 0.87, 0.7077, 671, 3, 1, 0, 0, 159, 10, 1], "semantic": {"name": "action_checkbox.short_description", "arg_names": [], "import_names": [], "rhs_call_name": "mark_safe", "annotation": ""}, "snippet": " action_checkbox.short_description = mark_safe('<input type=\"checkbox\" id=\"action-toggle\" />')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L476_C4", "label": "action_checkbox.allow_tags =", "type": "assigned_variable", "loc": [476, 476], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [14, 1, 0.3693, 0.0008, 1, 0.87, 0.7231, 105, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "action_checkbox.allow_tags", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " action_checkbox.allow_tags = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "label": "get_actions", "type": "function", "loc": [478, 515], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.3852, 0.0295, 1, 0.87, 0.7385, 315, 0, 2, 1, 0, 0, 0, 11], "semantic": {"name": "get_actions", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_actions(self, request):\n \"\"\"\n Return a dictionary mapping the names of all actions for this\n ModelAdmin to a tuple of (callable, name, description) for each action.\n \"\"\"\n # If self.actions is explicitally set to None that means that we don't\n # want *any* actions enabled on this page.\n if self.actions is None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L479_C8", "label": "expression", "type": "expression", "loc": [479, 482], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "vector": [8, 2, 0.3728, 0.0031, 2, 0.4, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Return a dictionary mapping the names of all actions for this\n ModelAdmin to a tuple of (callable, name, description) for each action.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L485_C8", "label": "if", "type": "if", "loc": [485, 486], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "vector": [4, 2, 0.3766, 0.0016, 2, 0.4, 0.125, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.actions is None:\n return []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L486_C12", "label": "return", "type": "return", "loc": [486, 486], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L485_C8", "vector": [13, 3, 0.377, 0.0008, 3, 0.68, 0.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L488_C8", "label": "actions =", "type": "assigned_variable", "loc": [488, 488], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "vector": [14, 2, 0.3786, 0.0008, 2, 0.4, 0.25, 317, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "actions", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " actions = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L491_C8", "label": "for name, func", "type": "for", "loc": [491, 493], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "vector": [6, 2, 0.3817, 0.0023, 2, 0.4, 0.375, 66, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "name, func", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for (name, func) in self.admin_site.actions:\n description = getattr(func, 'short_description', name.replace('_', ' '))\n actions.append((func, name, description))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L492_C12", "label": "description = getattr()", "type": "assigned_variable", "loc": [492, 492], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L491_C8", "vector": [14, 3, 0.3817, 0.0008, 3, 0.38, 0.0, 306, 3, 3, 0, 0, 121, 10, 2], "semantic": {"name": "description", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " description = getattr(func, 'short_description', name.replace('_', ' '))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L493_C12", "label": "append()", "type": "expression", "loc": [493, 493], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L491_C8", "vector": [8, 3, 0.3825, 0.0008, 3, 0.38, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " actions.append((func, name, description))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L497_C8", "label": "for klass", "type": "for", "loc": [497, 502], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "vector": [6, 2, 0.3875, 0.0047, 2, 0.4, 0.5, 35, 6, 0, 0, 0, 0, 0, 4], "semantic": {"name": "klass", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for klass in self.__class__.mro()[::-1]:\n class_actions = getattr(klass, 'actions', [])\n # Avoid trying to iterate over None\n if not class_actions:\n continue\n actions.extend([self.get_action(action) for action in class_actions])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L498_C12", "label": "class_actions = getattr()", "type": "assigned_variable", "loc": [498, 498], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L497_C8", "vector": [14, 3, 0.3863, 0.0008, 3, 0.05, 0.0, 158, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "class_actions", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " class_actions = getattr(klass, 'actions', [])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L500_C12", "label": "if", "type": "if", "loc": [500, 501], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L497_C8", "vector": [4, 3, 0.3883, 0.0016, 3, 0.05, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not class_actions:\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L502_C12", "label": "extend()", "type": "expression", "loc": [502, 502], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L497_C8", "vector": [8, 3, 0.3894, 0.0008, 3, 0.05, 1.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " actions.extend([self.get_action(action) for action in class_actions])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L505_C8", "label": "actions = filter()", "type": "assigned_variable", "loc": [505, 505], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "vector": [14, 2, 0.3918, 0.0008, 2, 0.4, 0.625, 317, 3, 2, 0, 0, 526, 10, 1], "semantic": {"name": "actions", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " actions = filter(None, actions)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L509_C8", "label": "sort()", "type": "expression", "loc": [509, 509], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "vector": [8, 2, 0.3949, 0.0008, 2, 0.4, 0.75, 489, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "sort", "arg_names": [], "import_names": [], "rhs_call_name": "sort", "annotation": ""}, "snippet": " actions.sort(key=lambda k: k[2].lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L510_C8", "label": "actions = SortedDict()", "type": "assigned_variable", "loc": [510, 513], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "vector": [14, 2, 0.3968, 0.0031, 2, 0.4, 0.875, 317, 3, 1, 0, 0, 525, 10, 1], "semantic": {"name": "actions", "arg_names": [], "import_names": [], "rhs_call_name": "SortedDict", "annotation": ""}, "snippet": " actions = SortedDict([\n (name, (func, name, desc))\n for func, name, desc in actions\n ])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L515_C8", "label": "return", "type": "return", "loc": [515, 515], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "vector": [13, 2, 0.3995, 0.0008, 2, 0.4, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return actions"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L517_C4", "label": "get_action_choices", "type": "function", "loc": [517, 526], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.4046, 0.0078, 1, 0.87, 0.7538, 778, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "get_action_choices", "arg_names": ["self", "request", "default_choices"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_action_choices(self, request, default_choices=BLANK_CHOICE_DASH):\n \"\"\"\n Return a list of choices for use in a form object. Each choice is a\n tuple (name, description).\n \"\"\"\n choices = [] + default_choices\n for func, name, description in self.get_actions(request).itervalues():\n choice = (name, description % model_format_dict(self.opts))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L518_C8", "label": "expression", "type": "expression", "loc": [518, 521], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L517_C4", "vector": [8, 2, 0.403, 0.0031, 2, 0.72, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Return a list of choices for use in a form object. Each choice is a\n tuple (name, description).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L522_C8", "label": "choices =", "type": "assigned_variable", "loc": [522, 522], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L517_C4", "vector": [14, 2, 0.405, 0.0008, 2, 0.72, 0.3333, 405, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "choices", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " choices = [] + default_choices"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L523_C8", "label": "for func, name, description", "type": "for", "loc": [523, 525], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L517_C4", "vector": [6, 2, 0.4065, 0.0023, 2, 0.72, 0.6667, 903, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "func, name, description", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for func, name, description in self.get_actions(request).itervalues():\n choice = (name, description % model_format_dict(self.opts))\n choices.append(choice)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L524_C12", "label": "choice =", "type": "assigned_variable", "loc": [524, 524], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L523_C8", "vector": [14, 3, 0.4065, 0.0008, 3, 0.31, 0.0, 30, 0, 0, 0, 0, 0, 8, 1], "semantic": {"name": "choice", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " choice = (name, description % model_format_dict(self.opts))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L525_C12", "label": "append()", "type": "expression", "loc": [525, 525], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L523_C8", "vector": [8, 3, 0.4073, 0.0008, 3, 0.31, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " choices.append(choice)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L526_C8", "label": "return", "type": "return", "loc": [526, 526], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L517_C4", "vector": [13, 2, 0.4081, 0.0008, 2, 0.72, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return choices"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L528_C4", "label": "get_action", "type": "function", "loc": [528, 556], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.4205, 0.0225, 1, 0.87, 0.7692, 389, 0, 2, 1, 0, 0, 0, 7], "semantic": {"name": "get_action", "arg_names": ["self", "action"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_action(self, action):\n \"\"\"\n Return a given action from a parameter, which can either be a callable,\n or the name of a method on the ModelAdmin. Return is a tuple of\n (callable, name, description).\n \"\"\"\n # If the action is a callable, just use it.\n if callable(action):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L529_C8", "label": "expression", "type": "expression", "loc": [529, 533], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L528_C4", "vector": [8, 2, 0.4119, 0.0039, 2, 0.13, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Return a given action from a parameter, which can either be a callable,\n or the name of a method on the ModelAdmin. Return is a tuple of\n (callable, name, description).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L535_C8", "label": "if", "type": "if", "loc": [535, 550], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L528_C4", "vector": [4, 2, 0.4209, 0.0124, 2, 0.13, 0.3333, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if callable(action):\n func = action\n action = action.__name__\n\n # Next, look for a method. Grab it off self.__class__ to get an unbound\n # method instead of a bound one; this ensures that the calling\n # conventions are the same for functions and methods.\n elif hasattr(self.__class__, action):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L536_C12", "label": "func =", "type": "assigned_variable", "loc": [536, 536], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L535_C8", "vector": [14, 3, 0.4158, 0.0008, 3, 0.05, 0.0, 856, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "func", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " func = action"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L537_C12", "label": "action =", "type": "assigned_variable", "loc": [537, 537], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L535_C8", "vector": [14, 3, 0.4166, 0.0008, 3, 0.05, 0.5, 422, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "action", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " action = action.__name__"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L542_C8", "label": "if", "type": "if", "loc": [542, 550], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L535_C8", "vector": [4, 3, 0.4236, 0.007, 3, 0.05, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif hasattr(self.__class__, action):\n func = getattr(self.__class__, action)\n\n # Finally, look for a named method on the admin site\n else:\n try:\n func = self.admin_site.get_action(action)\n except KeyError:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L543_C12", "label": "func = getattr()", "type": "assigned_variable", "loc": [543, 543], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L542_C8", "vector": [14, 4, 0.4213, 0.0008, 4, 0.29, 0.0, 856, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "func", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " func = getattr(self.__class__, action)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L547_C12", "label": "try", "type": "try", "loc": [547, 550], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L542_C8", "vector": [7, 4, 0.4255, 0.0031, 4, 0.29, 1.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n func = self.admin_site.get_action(action)\n except KeyError:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L548_C16", "label": "func = get_action()", "type": "assigned_variable", "loc": [548, 548], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L547_C12", "vector": [14, 5, 0.4251, 0.0008, 5, 0.23, 0.0, 856, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "func", "arg_names": [], "import_names": [], "rhs_call_name": "get_action", "annotation": ""}, "snippet": " func = self.admin_site.get_action(action)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L550_C16", "label": "return", "type": "return", "loc": [550, 550], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L547_C12", "vector": [13, 5, 0.4267, 0.0008, 5, 0.23, 0.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L552_C8", "label": "if", "type": "if", "loc": [552, 555], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L528_C4", "vector": [4, 2, 0.4294, 0.0031, 2, 0.13, 0.6667, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(func, 'short_description'):\n description = func.short_description\n else:\n description = capfirst(action.replace('_', ' '))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L553_C12", "label": "description =", "type": "assigned_variable", "loc": [553, 553], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L552_C8", "vector": [14, 3, 0.429, 0.0008, 3, 0.6, 0.0, 306, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "description", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " description = func.short_description"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L555_C12", "label": "description = capfirst()", "type": "assigned_variable", "loc": [555, 555], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L552_C8", "vector": [14, 3, 0.4306, 0.0008, 3, 0.6, 1.0, 306, 3, 1, 0, 0, 561, 10, 2], "semantic": {"name": "description", "arg_names": [], "import_names": [], "rhs_call_name": "capfirst", "annotation": ""}, "snippet": " description = capfirst(action.replace('_', ' '))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L556_C8", "label": "return", "type": "return", "loc": [556, 556], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L528_C4", "vector": [13, 2, 0.4313, 0.0008, 2, 0.13, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return func, action, description"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "label": "construct_change_message", "type": "function", "loc": [558, 582], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.4422, 0.0194, 1, 0.87, 0.7846, 314, 0, 4, 1, 0, 0, 0, 20], "semantic": {"name": "construct_change_message", "arg_names": ["self", "request", "form", "formsets"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def construct_change_message(self, request, form, formsets):\n \"\"\"\n Construct a change message from a changed object.\n \"\"\"\n change_message = []\n if form.changed_data:\n change_message.append(_('Changed %s.') % get_text_list(form.changed_data, _('and')))\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L559_C8", "label": "expression", "type": "expression", "loc": [559, 561], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "vector": [8, 2, 0.4344, 0.0023, 2, 0.19, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Construct a change message from a changed object.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L562_C8", "label": "change_message =", "type": "assigned_variable", "loc": [562, 562], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "vector": [14, 2, 0.436, 0.0008, 2, 0.19, 0.2, 306, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "change_message", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " change_message = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L563_C8", "label": "if", "type": "if", "loc": [563, 564], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "vector": [4, 2, 0.4372, 0.0016, 2, 0.19, 0.4, 0, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.changed_data:\n change_message.append(_('Changed %s.') % get_text_list(form.changed_data, _('and')))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L564_C12", "label": "append()", "type": "expression", "loc": [564, 564], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L563_C8", "vector": [8, 3, 0.4375, 0.0008, 3, 0.55, 0.0, 243, 3, 1, 0, 0, 0, 0, 4], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " change_message.append(_('Changed %s.') % get_text_list(form.changed_data, _('and')))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L566_C8", "label": "if", "type": "if", "loc": [566, 580], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "vector": [4, 2, 0.4445, 0.0116, 2, 0.19, 0.6, 0, 2, 0, 0, 0, 0, 0, 14], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if formsets:\n for formset in formsets:\n for added_object in formset.new_objects:\n change_message.append(_('Added %(name)s \"%(object)s\".')\n % {'name': force_unicode(added_object._meta.verbose_name),\n 'object': force_unicode(added_object)})\n for changed_object, changed_fields in formset.changed_objects:\n change_message.append(_('Changed %(list)s for %(name)s \"%(object)s\".')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L567_C12", "label": "for formset", "type": "for", "loc": [567, 580], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L566_C8", "vector": [6, 3, 0.4449, 0.0109, 3, 0.85, 0.0, 613, 2, 0, 0, 0, 0, 0, 14], "semantic": {"name": "formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for formset in formsets:\n for added_object in formset.new_objects:\n change_message.append(_('Added %(name)s \"%(object)s\".')\n % {'name': force_unicode(added_object._meta.verbose_name),\n 'object': force_unicode(added_object)})\n for changed_object, changed_fields in formset.changed_objects:\n change_message.append(_('Changed %(list)s for %(name)s \"%(object)s\".')\n % {'list': get_text_list(changed_fields, _('and')),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L568_C16", "label": "for added_object", "type": "for", "loc": [568, 571], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L567_C12", "vector": [6, 4, 0.4418, 0.0031, 4, 0.13, 0.0, 356, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "added_object", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for added_object in formset.new_objects:\n change_message.append(_('Added %(name)s \"%(object)s\".')\n % {'name': force_unicode(added_object._meta.verbose_name),\n 'object': force_unicode(added_object)})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L569_C20", "label": "append()", "type": "expression", "loc": [569, 571], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L568_C16", "vector": [8, 5, 0.4422, 0.0023, 5, 0.37, 0.0, 243, 3, 1, 0, 0, 0, 0, 4], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " change_message.append(_('Added %(name)s \"%(object)s\".')\n % {'name': force_unicode(added_object._meta.verbose_name),\n 'object': force_unicode(added_object)})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L572_C16", "label": "for changed_object, changed_fields", "type": "for", "loc": [572, 576], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L567_C12", "vector": [6, 4, 0.4453, 0.0039, 4, 0.13, 0.5, 518, 7, 0, 0, 0, 0, 0, 6], "semantic": {"name": "changed_object, changed_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for changed_object, changed_fields in formset.changed_objects:\n change_message.append(_('Changed %(list)s for %(name)s \"%(object)s\".')\n % {'list': get_text_list(changed_fields, _('and')),\n 'name': force_unicode(changed_object._meta.verbose_name),\n 'object': force_unicode(changed_object)})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L573_C20", "label": "append()", "type": "expression", "loc": [573, 576], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L572_C16", "vector": [8, 5, 0.4457, 0.0031, 5, 0.0, 0.0, 243, 3, 1, 0, 0, 0, 0, 6], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " change_message.append(_('Changed %(list)s for %(name)s \"%(object)s\".')\n % {'list': get_text_list(changed_fields, _('and')),\n 'name': force_unicode(changed_object._meta.verbose_name),\n 'object': force_unicode(changed_object)})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L577_C16", "label": "for deleted_object", "type": "for", "loc": [577, 580], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L567_C12", "vector": [6, 4, 0.4488, 0.0031, 4, 0.13, 1.0, 981, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "deleted_object", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for deleted_object in formset.deleted_objects:\n change_message.append(_('Deleted %(name)s \"%(object)s\".')\n % {'name': force_unicode(deleted_object._meta.verbose_name),\n 'object': force_unicode(deleted_object)})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L578_C20", "label": "append()", "type": "expression", "loc": [578, 580], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L577_C16", "vector": [8, 5, 0.4492, 0.0023, 5, 0.49, 0.0, 243, 3, 1, 0, 0, 0, 0, 4], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " change_message.append(_('Deleted %(name)s \"%(object)s\".')\n % {'name': force_unicode(deleted_object._meta.verbose_name),\n 'object': force_unicode(deleted_object)})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L581_C8", "label": "change_message = join()", "type": "assigned_variable", "loc": [581, 581], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "vector": [14, 2, 0.4507, 0.0008, 2, 0.19, 0.8, 306, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "change_message", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " change_message = ' '.join(change_message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L582_C8", "label": "return", "type": "return", "loc": [582, 582], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "vector": [13, 2, 0.4515, 0.0008, 2, 0.19, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return change_message or _('No fields changed.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L584_C4", "label": "message_user", "type": "function", "loc": [584, 589], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.455, 0.0047, 1, 0.87, 0.8, 207, 0, 3, 0, 0, 0, 0, 1], "semantic": {"name": "message_user", "arg_names": ["self", "request", "message"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def message_user(self, request, message):\n \"\"\"\n Send a message to the user. The default implementation\n posts a message using the django.contrib.messages backend.\n \"\"\"\n messages.info(request, message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L585_C8", "label": "expression", "type": "expression", "loc": [585, 588], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L584_C4", "vector": [8, 2, 0.455, 0.0031, 2, 0.0, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Send a message to the user. The default implementation\n posts a message using the django.contrib.messages backend.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L589_C8", "label": "info()", "type": "expression", "loc": [589, 589], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L584_C4", "vector": [8, 2, 0.4569, 0.0008, 2, 0.0, 1.0, 730, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "info", "arg_names": [], "import_names": [], "rhs_call_name": "info", "annotation": ""}, "snippet": " messages.info(request, message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L591_C4", "label": "save_form", "type": "function", "loc": [591, 596], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.4604, 0.0047, 1, 0.87, 0.8154, 72, 0, 4, 1, 0, 0, 0, 1], "semantic": {"name": "save_form", "arg_names": ["self", "request", "form", "change"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save_form(self, request, form, change):\n \"\"\"\n Given a ModelForm return an unsaved instance. ``change`` is True if\n the object is being changed, and False if it's being added.\n \"\"\"\n return form.save(commit=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L592_C8", "label": "expression", "type": "expression", "loc": [592, 595], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L591_C4", "vector": [8, 2, 0.4604, 0.0031, 2, 0.97, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Given a ModelForm return an unsaved instance. ``change`` is True if\n the object is being changed, and False if it's being added.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L596_C8", "label": "return", "type": "return", "loc": [596, 596], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L591_C4", "vector": [13, 2, 0.4624, 0.0008, 2, 0.97, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return form.save(commit=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L598_C4", "label": "save_model", "type": "function", "loc": [598, 602], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.4655, 0.0039, 1, 0.87, 0.8308, 231, 0, 5, 0, 0, 0, 0, 1], "semantic": {"name": "save_model", "arg_names": ["self", "request", "obj", "form", "change"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save_model(self, request, obj, form, change):\n \"\"\"\n Given a model instance save it to the database.\n \"\"\"\n obj.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L599_C8", "label": "expression", "type": "expression", "loc": [599, 601], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L598_C4", "vector": [8, 2, 0.4655, 0.0023, 2, 0.76, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Given a model instance save it to the database.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L602_C8", "label": "save()", "type": "expression", "loc": [602, 602], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L598_C4", "vector": [8, 2, 0.467, 0.0008, 2, 0.76, 1.0, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " obj.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L604_C4", "label": "save_formset", "type": "function", "loc": [604, 608], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.4701, 0.0039, 1, 0.87, 0.8462, 364, 0, 5, 0, 0, 0, 0, 1], "semantic": {"name": "save_formset", "arg_names": ["self", "request", "form", "formset", "change"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save_formset(self, request, form, formset, change):\n \"\"\"\n Given an inline formset save it to the database.\n \"\"\"\n formset.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L605_C8", "label": "expression", "type": "expression", "loc": [605, 607], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L604_C4", "vector": [8, 2, 0.4701, 0.0023, 2, 0.48, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Given an inline formset save it to the database.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L608_C8", "label": "save()", "type": "expression", "loc": [608, 608], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L604_C4", "vector": [8, 2, 0.4717, 0.0008, 2, 0.48, 1.0, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " formset.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "label": "render_change_form", "type": "function", "loc": [610, 639], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.4845, 0.0233, 1, 0.87, 0.8615, 304, 0, 7, 1, 0, 0, 0, 11], "semantic": {"name": "render_change_form", "arg_names": ["self", "request", "context", "add", "change", "form_url", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):\n opts = self.model._meta\n app_label = opts.app_label\n ordered_objects = opts.get_ordered_objects()\n context.update({\n 'add': add,\n 'change': change,\n 'has_add_permission': self.has_add_permission(request),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L611_C8", "label": "opts =", "type": "assigned_variable", "loc": [611, 611], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "vector": [14, 2, 0.474, 0.0008, 2, 0.59, 0.0, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = self.model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L612_C8", "label": "app_label =", "type": "assigned_variable", "loc": [612, 612], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "vector": [14, 2, 0.4748, 0.0008, 2, 0.59, 0.1667, 187, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "app_label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_label = opts.app_label"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L613_C8", "label": "ordered_objects = get_ordered_objects()", "type": "assigned_variable", "loc": [613, 613], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "vector": [14, 2, 0.4756, 0.0008, 2, 0.59, 0.3333, 921, 3, 0, 0, 0, 207, 10, 1], "semantic": {"name": "ordered_objects", "arg_names": [], "import_names": [], "rhs_call_name": "get_ordered_objects", "annotation": ""}, "snippet": " ordered_objects = opts.get_ordered_objects()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L614_C8", "label": "update()", "type": "expression", "loc": [614, 629], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "vector": [8, 2, 0.4822, 0.0124, 2, 0.59, 0.5, 637, 3, 1, 0, 0, 0, 0, 7], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " context.update({\n 'add': add,\n 'change': change,\n 'has_add_permission': self.has_add_permission(request),\n 'has_change_permission': self.has_change_permission(request, obj),\n 'has_delete_permission': self.has_delete_permission(request, obj),\n 'has_file_field': True, # FIXME - this should check if form or formsets have a FileField,\n 'has_absolute_url': hasattr(self.model, 'get_absolute_url'),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L630_C8", "label": "if", "type": "if", "loc": [630, 633], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "vector": [4, 2, 0.4899, 0.0031, 2, 0.59, 0.6667, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if add and self.add_form_template is not None:\n form_template = self.add_form_template\n else:\n form_template = self.change_form_template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L631_C12", "label": "form_template =", "type": "assigned_variable", "loc": [631, 631], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L630_C8", "vector": [14, 3, 0.4895, 0.0008, 3, 0.56, 0.0, 34, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "form_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " form_template = self.add_form_template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L633_C12", "label": "form_template =", "type": "assigned_variable", "loc": [633, 633], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L630_C8", "vector": [14, 3, 0.4911, 0.0008, 3, 0.56, 1.0, 34, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "form_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " form_template = self.change_form_template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L634_C8", "label": "context_instance = RequestContext()", "type": "assigned_variable", "loc": [634, 634], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "vector": [14, 2, 0.4919, 0.0008, 2, 0.59, 0.8333, 723, 3, 2, 0, 0, 47, 10, 1], "semantic": {"name": "context_instance", "arg_names": [], "import_names": [], "rhs_call_name": "RequestContext", "annotation": ""}, "snippet": " context_instance = template.RequestContext(request, current_app=self.admin_site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L635_C8", "label": "return", "type": "return", "loc": [635, 639], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "vector": [13, 2, 0.4942, 0.0039, 2, 0.59, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(form_template or [\n \"admin/%s/%s/change_form.html\" % (app_label, opts.object_name.lower()),\n \"admin/%s/change_form.html\" % app_label,\n \"admin/change_form.html\"\n ], context, context_instance=context_instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "label": "response_add", "type": "function", "loc": [641, 674], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.5101, 0.0264, 1, 0.87, 0.8769, 83, 0, 4, 1, 0, 0, 0, 17], "semantic": {"name": "response_add", "arg_names": ["self", "request", "obj", "post_url_continue"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def response_add(self, request, obj, post_url_continue='../%s/'):\n \"\"\"\n Determines the HttpResponse for the add_view stage.\n \"\"\"\n opts = obj._meta\n pk_value = obj._get_pk_val()\n\n msg = _('The %(name)s \"%(obj)s\" was added successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj)}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L642_C8", "label": "expression", "type": "expression", "loc": [642, 644], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "vector": [8, 2, 0.4988, 0.0023, 2, 0.04, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Determines the HttpResponse for the add_view stage.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L645_C8", "label": "opts =", "type": "assigned_variable", "loc": [645, 645], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "vector": [14, 2, 0.5004, 0.0008, 2, 0.04, 0.2, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = obj._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L646_C8", "label": "pk_value = _get_pk_val()", "type": "assigned_variable", "loc": [646, 646], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "vector": [14, 2, 0.5012, 0.0008, 2, 0.04, 0.4, 538, 3, 0, 0, 0, 743, 10, 1], "semantic": {"name": "pk_value", "arg_names": [], "import_names": [], "rhs_call_name": "_get_pk_val", "annotation": ""}, "snippet": " pk_value = obj._get_pk_val()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L648_C8", "label": "msg =", "type": "assigned_variable", "loc": [648, 648], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "vector": [14, 2, 0.5027, 0.0008, 2, 0.04, 0.6, 712, 4, 0, 0, 0, 0, 0, 3], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " msg = _('The %(name)s \"%(obj)s\" was added successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj)}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L651_C8", "label": "if", "type": "if", "loc": [651, 655], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "vector": [4, 2, 0.5066, 0.0039, 2, 0.04, 0.8, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if \"_continue\" in request.POST:\n self.message_user(request, msg + ' ' + _(\"You may edit it again below.\"))\n if \"_popup\" in request.POST:\n post_url_continue += \"?_popup=1\"\n return HttpResponseRedirect(post_url_continue % pk_value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L652_C12", "label": "message_user()", "type": "expression", "loc": [652, 652], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L651_C8", "vector": [8, 3, 0.5058, 0.0008, 3, 0.13, 0.0, 207, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, msg + ' ' + _(\"You may edit it again below.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L653_C12", "label": "if", "type": "if", "loc": [653, 654], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L651_C8", "vector": [4, 3, 0.507, 0.0016, 3, 0.13, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if \"_popup\" in request.POST:\n post_url_continue += \"?_popup=1\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L655_C12", "label": "return", "type": "return", "loc": [655, 655], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L651_C8", "vector": [13, 3, 0.5081, 0.0008, 3, 0.13, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(post_url_continue % pk_value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L657_C8", "label": "if", "type": "if", "loc": [657, 674], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "vector": [4, 2, 0.5163, 0.014, 2, 0.04, 1.0, 0, 0, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if \"_popup\" in request.POST:\n return HttpResponse('<script type=\"text/javascript\">opener.dismissAddAnotherPopup(window, \"%s\", \"%s\");</script>' % \\\n # escape() calls force_unicode.\n (escape(pk_value), escape(obj)))\n elif \"_addanother\" in request.POST:\n self.message_user(request, msg + ' ' + (_(\"You may add another %s below.\") % force_unicode(opts.verbose_name)))\n return HttpResponseRedirect(request.path)\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L658_C12", "label": "return", "type": "return", "loc": [658, 660], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L657_C8", "vector": [13, 3, 0.5112, 0.0023, 3, 0.75, 0.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponse('<script type=\"text/javascript\">opener.dismissAddAnotherPopup(window, \"%s\", \"%s\");</script>' % \\\n # escape() calls force_unicode.\n (escape(pk_value), escape(obj)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L661_C8", "label": "if", "type": "if", "loc": [661, 674], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L657_C8", "vector": [4, 3, 0.5178, 0.0109, 3, 0.75, 1.0, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif \"_addanother\" in request.POST:\n self.message_user(request, msg + ' ' + (_(\"You may add another %s below.\") % force_unicode(opts.verbose_name)))\n return HttpResponseRedirect(request.path)\n else:\n self.message_user(request, msg)\n\n # Figure out where to redirect. If the user has change permission,\n # redirect to the change-list page for this object. Otherwise,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L662_C12", "label": "message_user()", "type": "expression", "loc": [662, 662], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L661_C8", "vector": [8, 4, 0.5136, 0.0008, 4, 0.95, 0.0, 207, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, msg + ' ' + (_(\"You may add another %s below.\") % force_unicode(opts.verbose_name)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L663_C12", "label": "return", "type": "return", "loc": [663, 663], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L661_C8", "vector": [13, 4, 0.5144, 0.0008, 4, 0.95, 0.25, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(request.path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L665_C12", "label": "message_user()", "type": "expression", "loc": [665, 665], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L661_C8", "vector": [8, 4, 0.5159, 0.0008, 4, 0.95, 0.5, 207, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L670_C12", "label": "if", "type": "if", "loc": [670, 673], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L661_C8", "vector": [4, 4, 0.5209, 0.0031, 4, 0.95, 0.75, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.has_change_permission(request, None):\n post_url = '../'\n else:\n post_url = '../../../'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L671_C16", "label": "post_url =", "type": "assigned_variable", "loc": [671, 671], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L670_C12", "vector": [14, 5, 0.5206, 0.0008, 5, 0.12, 0.0, 293, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "post_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " post_url = '../'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L673_C16", "label": "post_url =", "type": "assigned_variable", "loc": [673, 673], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L670_C12", "vector": [14, 5, 0.5221, 0.0008, 5, 0.12, 1.0, 293, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "post_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " post_url = '../../../'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L674_C12", "label": "return", "type": "return", "loc": [674, 674], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L661_C8", "vector": [13, 4, 0.5229, 0.0008, 4, 0.95, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(post_url)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L676_C4", "label": "response_change", "type": "function", "loc": [676, 699], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.5334, 0.0186, 1, 0.87, 0.8923, 380, 0, 3, 1, 0, 0, 0, 18], "semantic": {"name": "response_change", "arg_names": ["self", "request", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def response_change(self, request, obj):\n \"\"\"\n Determines the HttpResponse for the change_view stage.\n \"\"\"\n opts = obj._meta\n pk_value = obj._get_pk_val()\n\n msg = _('The %(name)s \"%(obj)s\" was changed successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj)}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L677_C8", "label": "expression", "type": "expression", "loc": [677, 679], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L676_C4", "vector": [8, 2, 0.526, 0.0023, 2, 0.2, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Determines the HttpResponse for the change_view stage.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L680_C8", "label": "opts =", "type": "assigned_variable", "loc": [680, 680], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L676_C4", "vector": [14, 2, 0.5275, 0.0008, 2, 0.2, 0.25, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = obj._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L681_C8", "label": "pk_value = _get_pk_val()", "type": "assigned_variable", "loc": [681, 681], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L676_C4", "vector": [14, 2, 0.5283, 0.0008, 2, 0.2, 0.5, 538, 3, 0, 0, 0, 743, 10, 1], "semantic": {"name": "pk_value", "arg_names": [], "import_names": [], "rhs_call_name": "_get_pk_val", "annotation": ""}, "snippet": " pk_value = obj._get_pk_val()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L683_C8", "label": "msg =", "type": "assigned_variable", "loc": [683, 683], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L676_C4", "vector": [14, 2, 0.5299, 0.0008, 2, 0.2, 0.75, 712, 4, 0, 0, 0, 0, 0, 3], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " msg = _('The %(name)s \"%(obj)s\" was changed successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj)}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L684_C8", "label": "if", "type": "if", "loc": [684, 699], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L676_C4", "vector": [4, 2, 0.5365, 0.0124, 2, 0.2, 1.0, 0, 0, 0, 0, 0, 0, 0, 14], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if \"_continue\" in request.POST:\n self.message_user(request, msg + ' ' + _(\"You may edit it again below.\"))\n if \"_popup\" in request.REQUEST:\n return HttpResponseRedirect(request.path + \"?_popup=1\")\n else:\n return HttpResponseRedirect(request.path)\n elif \"_saveasnew\" in request.POST:\n msg = _('The %(name)s \"%(obj)s\" was added successfully. You may edit it again below.') % {'name': force_unicode(opts.verbose_name), 'obj': obj}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L685_C12", "label": "message_user()", "type": "expression", "loc": [685, 685], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L684_C8", "vector": [8, 3, 0.5314, 0.0008, 3, 0.12, 0.0, 207, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, msg + ' ' + _(\"You may edit it again below.\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L686_C12", "label": "if", "type": "if", "loc": [686, 689], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L684_C8", "vector": [4, 3, 0.5334, 0.0031, 3, 0.12, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if \"_popup\" in request.REQUEST:\n return HttpResponseRedirect(request.path + \"?_popup=1\")\n else:\n return HttpResponseRedirect(request.path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L687_C16", "label": "return", "type": "return", "loc": [687, 687], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L686_C12", "vector": [13, 4, 0.533, 0.0008, 4, 0.49, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(request.path + \"?_popup=1\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L689_C16", "label": "return", "type": "return", "loc": [689, 689], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L686_C12", "vector": [13, 4, 0.5345, 0.0008, 4, 0.49, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(request.path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L690_C8", "label": "if", "type": "if", "loc": [690, 699], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L684_C8", "vector": [4, 3, 0.5388, 0.0078, 3, 0.12, 1.0, 0, 0, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif \"_saveasnew\" in request.POST:\n msg = _('The %(name)s \"%(obj)s\" was added successfully. You may edit it again below.') % {'name': force_unicode(opts.verbose_name), 'obj': obj}\n self.message_user(request, msg)\n return HttpResponseRedirect(\"../%s/\" % pk_value)\n elif \"_addanother\" in request.POST:\n self.message_user(request, msg + ' ' + (_(\"You may add another %s below.\") % force_unicode(opts.verbose_name)))\n return HttpResponseRedirect(\"../add/\")\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L691_C12", "label": "msg =", "type": "assigned_variable", "loc": [691, 691], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L690_C8", "vector": [14, 4, 0.5361, 0.0008, 4, 0.4, 0.0, 712, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " msg = _('The %(name)s \"%(obj)s\" was added successfully. You may edit it again below.') % {'name': force_unicode(opts.verbose_name), 'obj': obj}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L692_C12", "label": "message_user()", "type": "expression", "loc": [692, 692], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L690_C8", "vector": [8, 4, 0.5369, 0.0008, 4, 0.4, 0.3333, 207, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L693_C12", "label": "return", "type": "return", "loc": [693, 693], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L690_C8", "vector": [13, 4, 0.5376, 0.0008, 4, 0.4, 0.6667, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(\"../%s/\" % pk_value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L694_C8", "label": "if", "type": "if", "loc": [694, 699], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L690_C8", "vector": [4, 4, 0.5403, 0.0047, 4, 0.4, 1.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif \"_addanother\" in request.POST:\n self.message_user(request, msg + ' ' + (_(\"You may add another %s below.\") % force_unicode(opts.verbose_name)))\n return HttpResponseRedirect(\"../add/\")\n else:\n self.message_user(request, msg)\n return HttpResponseRedirect(\"../\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L695_C12", "label": "message_user()", "type": "expression", "loc": [695, 695], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L694_C8", "vector": [8, 5, 0.5392, 0.0008, 5, 0.47, 0.0, 207, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, msg + ' ' + (_(\"You may add another %s below.\") % force_unicode(opts.verbose_name)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L696_C12", "label": "return", "type": "return", "loc": [696, 696], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L694_C8", "vector": [13, 5, 0.54, 0.0008, 5, 0.47, 0.3333, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(\"../add/\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L698_C12", "label": "message_user()", "type": "expression", "loc": [698, 698], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L694_C8", "vector": [8, 5, 0.5415, 0.0008, 5, 0.47, 0.6667, 207, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L699_C12", "label": "return", "type": "return", "loc": [699, 699], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L694_C8", "vector": [13, 5, 0.5423, 0.0008, 5, 0.47, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(\"../\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "label": "response_action", "type": "function", "loc": [701, 766], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.569, 0.0512, 1, 0.87, 0.9077, 811, 0, 3, 1, 0, 0, 0, 21], "semantic": {"name": "response_action", "arg_names": ["self", "request", "queryset"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def response_action(self, request, queryset):\n \"\"\"\n Handle an admin action. This is called if a request is POSTed to the\n changelist; it returns an HttpResponse if the action was handled, and\n None otherwise.\n \"\"\"\n\n # There can be multiple action forms on the page (at the top"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L702_C8", "label": "expression", "type": "expression", "loc": [702, 706], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "vector": [8, 2, 0.5462, 0.0039, 2, 0.57, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Handle an admin action. This is called if a request is POSTed to the\n changelist; it returns an HttpResponse if the action was handled, and\n None otherwise.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L711_C8", "label": "try", "type": "try", "loc": [711, 714], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "vector": [7, 2, 0.5528, 0.0031, 2, 0.57, 0.125, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n action_index = int(request.POST.get('index', 0))\n except ValueError:\n action_index = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L712_C12", "label": "action_index = int()", "type": "assigned_variable", "loc": [712, 712], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L711_C8", "vector": [14, 3, 0.5524, 0.0008, 3, 0.67, 0.0, 274, 3, 1, 0, 0, 901, 10, 2], "semantic": {"name": "action_index", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " action_index = int(request.POST.get('index', 0))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L714_C12", "label": "action_index =", "type": "assigned_variable", "loc": [714, 714], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L711_C8", "vector": [14, 3, 0.5539, 0.0008, 3, 0.67, 0.0, 274, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "action_index", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " action_index = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L717_C8", "label": "data = copy()", "type": "assigned_variable", "loc": [717, 717], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "vector": [14, 2, 0.5562, 0.0008, 2, 0.57, 0.25, 929, 3, 0, 0, 0, 739, 10, 1], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "copy", "annotation": ""}, "snippet": " data = request.POST.copy()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L718_C8", "label": "pop()", "type": "expression", "loc": [718, 718], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "vector": [8, 2, 0.557, 0.0008, 2, 0.57, 0.375, 969, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " data.pop(helpers.ACTION_CHECKBOX_NAME, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L719_C8", "label": "pop()", "type": "expression", "loc": [719, 719], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "vector": [8, 2, 0.5578, 0.0008, 2, 0.57, 0.5, 969, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " data.pop(\"index\", None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L722_C8", "label": "try", "type": "try", "loc": [722, 728], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "vector": [7, 2, 0.5625, 0.0054, 2, 0.57, 0.625, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n data.update({'action': data.getlist('action')[action_index]})\n except IndexError:\n # If we didn't get an action from the chosen form that's invalid\n # POST data, so by deleting action it'll fail the validation check\n # below. So no need to do anything here\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L723_C12", "label": "update()", "type": "expression", "loc": [723, 723], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L722_C8", "vector": [8, 3, 0.5609, 0.0008, 3, 0.43, 0.0, 637, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " data.update({'action': data.getlist('action')[action_index]})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L730_C8", "label": "action_form = action_form()", "type": "assigned_variable", "loc": [730, 730], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "vector": [14, 2, 0.5663, 0.0008, 2, 0.57, 0.75, 971, 3, 2, 0, 0, 971, 10, 1], "semantic": {"name": "action_form", "arg_names": [], "import_names": [], "rhs_call_name": "action_form", "annotation": ""}, "snippet": " action_form = self.action_form(data, auto_id=None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L731_C8", "label": "action_form.fields['action'].choices = get_action_choices()", "type": "assigned_variable", "loc": [731, 731], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "vector": [14, 2, 0.5671, 0.0008, 2, 0.57, 0.875, 843, 3, 1, 0, 0, 778, 10, 1], "semantic": {"name": "action_form.fields['action'].choices", "arg_names": [], "import_names": [], "rhs_call_name": "get_action_choices", "annotation": ""}, "snippet": " action_form.fields['action'].choices = self.get_action_choices(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "label": "if", "type": "if", "loc": [734, 766], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "vector": [4, 2, 0.5818, 0.0256, 2, 0.57, 1.0, 0, 3, 0, 0, 0, 0, 0, 12], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if action_form.is_valid():\n action = action_form.cleaned_data['action']\n select_across = action_form.cleaned_data['select_across']\n func, name, description = self.get_actions(request)[action]\n\n # Get the list of selected PKs. If nothing's selected, we can't\n # perform an action on it, so bail. Except we want to perform\n # the action explicitly on all objects."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L735_C12", "label": "action =", "type": "assigned_variable", "loc": [735, 735], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "vector": [14, 3, 0.5702, 0.0008, 3, 0.32, 0.0, 422, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "action", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " action = action_form.cleaned_data['action']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L736_C12", "label": "select_across =", "type": "assigned_variable", "loc": [736, 736], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "vector": [14, 3, 0.571, 0.0008, 3, 0.32, 0.1, 934, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "select_across", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " select_across = action_form.cleaned_data['select_across']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L737_C12", "label": "func, name, description =", "type": "assigned_variable", "loc": [737, 737], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "vector": [14, 3, 0.5718, 0.0008, 3, 0.32, 0.2, 903, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "func, name, description", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " func, name, description = self.get_actions(request)[action]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L742_C12", "label": "selected = getlist()", "type": "assigned_variable", "loc": [742, 742], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "vector": [14, 3, 0.5756, 0.0008, 3, 0.32, 0.3, 73, 3, 1, 0, 0, 585, 10, 1], "semantic": {"name": "selected", "arg_names": [], "import_names": [], "rhs_call_name": "getlist", "annotation": ""}, "snippet": " selected = request.POST.getlist(helpers.ACTION_CHECKBOX_NAME)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L743_C12", "label": "if", "type": "if", "loc": [743, 748], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "vector": [4, 3, 0.5784, 0.0047, 3, 0.32, 0.4, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not selected and not select_across:\n # Reminder that something needs to be selected or nothing will happen\n msg = _(\"Items must be selected in order to perform \"\n \"actions on them. No items have been changed.\")\n self.message_user(request, msg)\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L745_C16", "label": "msg = _()", "type": "assigned_variable", "loc": [745, 746], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L743_C12", "vector": [14, 4, 0.5784, 0.0016, 4, 0.17, 0.0, 712, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " msg = _(\"Items must be selected in order to perform \"\n \"actions on them. No items have been changed.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L747_C16", "label": "message_user()", "type": "expression", "loc": [747, 747], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L743_C12", "vector": [8, 4, 0.5795, 0.0008, 4, 0.17, 0.5, 207, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L748_C16", "label": "return", "type": "return", "loc": [748, 748], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L743_C12", "vector": [13, 4, 0.5803, 0.0008, 4, 0.17, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L750_C12", "label": "if", "type": "if", "loc": [750, 752], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "vector": [4, 3, 0.5826, 0.0023, 3, 0.32, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not select_across:\n # Perform the action only on the selected objects\n queryset = queryset.filter(pk__in=selected)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L752_C16", "label": "queryset = filter()", "type": "assigned_variable", "loc": [752, 752], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L750_C12", "vector": [14, 4, 0.5834, 0.0008, 4, 0.75, 0.0, 38, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "queryset", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " queryset = queryset.filter(pk__in=selected)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L754_C12", "label": "response = func()", "type": "assigned_variable", "loc": [754, 754], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "vector": [14, 3, 0.5849, 0.0008, 3, 0.32, 0.6, 511, 3, 3, 0, 0, 856, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "func", "annotation": ""}, "snippet": " response = func(self, request, queryset)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L759_C12", "label": "if", "type": "if", "loc": [759, 762], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "vector": [4, 3, 0.59, 0.0031, 3, 0.32, 0.7, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(response, HttpResponse):\n return response\n else:\n return HttpResponseRedirect(request.get_full_path())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L760_C16", "label": "return", "type": "return", "loc": [760, 760], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L759_C12", "vector": [13, 4, 0.5896, 0.0008, 4, 0.91, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L762_C16", "label": "return", "type": "return", "loc": [762, 762], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L759_C12", "vector": [13, 4, 0.5912, 0.0008, 4, 0.91, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(request.get_full_path())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L764_C12", "label": "msg = _()", "type": "assigned_variable", "loc": [764, 764], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "vector": [14, 3, 0.5927, 0.0008, 3, 0.32, 0.8, 712, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " msg = _(\"No action selected.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L765_C12", "label": "message_user()", "type": "expression", "loc": [765, 765], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "vector": [8, 3, 0.5935, 0.0008, 3, 0.32, 0.9, 207, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L766_C12", "label": "return", "type": "return", "loc": [766, 766], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "vector": [13, 3, 0.5943, 0.0008, 3, 0.32, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "label": "add_view", "type": "function", "loc": [770, 856], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.6307, 0.0675, 1, 0.87, 0.9231, 840, 0, 4, 1, 0, 0, 0, 50], "semantic": {"name": "add_view", "arg_names": ["self", "request", "form_url", "extra_context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_view(self, request, form_url='', extra_context=None):\n \"The 'add' admin view for this model.\"\n model = self.model\n opts = model._meta\n\n if not self.has_add_permission(request):\n raise PermissionDenied\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L771_C8", "label": "expression", "type": "expression", "loc": [771, 771], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [8, 2, 0.5981, 0.0008, 2, 0.23, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"The 'add' admin view for this model.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L772_C8", "label": "model =", "type": "assigned_variable", "loc": [772, 772], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [14, 2, 0.5989, 0.0008, 2, 0.23, 0.0769, 722, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model = self.model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L773_C8", "label": "opts =", "type": "assigned_variable", "loc": [773, 773], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [14, 2, 0.5997, 0.0008, 2, 0.23, 0.1538, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L775_C8", "label": "if", "type": "if", "loc": [775, 776], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [4, 2, 0.6016, 0.0016, 2, 0.23, 0.2308, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.has_add_permission(request):\n raise PermissionDenied"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L778_C8", "label": "ModelForm = get_form()", "type": "assigned_variable", "loc": [778, 778], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [14, 2, 0.6036, 0.0008, 2, 0.23, 0.3077, 118, 3, 1, 0, 0, 265, 10, 1], "semantic": {"name": "ModelForm", "arg_names": [], "import_names": [], "rhs_call_name": "get_form", "annotation": ""}, "snippet": " ModelForm = self.get_form(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L779_C8", "label": "formsets =", "type": "assigned_variable", "loc": [779, 779], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [14, 2, 0.6043, 0.0008, 2, 0.23, 0.3846, 507, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "formsets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " formsets = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "label": "if", "type": "if", "loc": [780, 828], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [4, 2, 0.6237, 0.038, 2, 0.23, 0.4615, 0, 0, 0, 0, 0, 0, 0, 31], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.method == 'POST':\n form = ModelForm(request.POST, request.FILES)\n if form.is_valid():\n new_object = self.save_form(request, form, change=False)\n form_validated = True\n else:\n form_validated = False\n new_object = self.model()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L781_C12", "label": "form = ModelForm()", "type": "assigned_variable", "loc": [781, 781], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "vector": [14, 3, 0.6059, 0.0008, 3, 0.23, 0.0, 761, 3, 2, 0, 0, 118, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "ModelForm", "annotation": ""}, "snippet": " form = ModelForm(request.POST, request.FILES)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L782_C12", "label": "if", "type": "if", "loc": [782, 787], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "vector": [4, 3, 0.6086, 0.0047, 3, 0.23, 0.1111, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.is_valid():\n new_object = self.save_form(request, form, change=False)\n form_validated = True\n else:\n form_validated = False\n new_object = self.model()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L783_C16", "label": "new_object = save_form()", "type": "assigned_variable", "loc": [783, 783], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L782_C12", "vector": [14, 4, 0.6074, 0.0008, 4, 0.25, 0.0, 131, 3, 3, 0, 0, 72, 10, 1], "semantic": {"name": "new_object", "arg_names": [], "import_names": [], "rhs_call_name": "save_form", "annotation": ""}, "snippet": " new_object = self.save_form(request, form, change=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L784_C16", "label": "form_validated =", "type": "assigned_variable", "loc": [784, 784], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L782_C12", "vector": [14, 4, 0.6082, 0.0008, 4, 0.25, 0.3333, 907, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "form_validated", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " form_validated = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L786_C16", "label": "form_validated =", "type": "assigned_variable", "loc": [786, 786], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L782_C12", "vector": [14, 4, 0.6098, 0.0008, 4, 0.25, 0.6667, 907, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "form_validated", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " form_validated = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L787_C16", "label": "new_object = model()", "type": "assigned_variable", "loc": [787, 787], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L782_C12", "vector": [14, 4, 0.6106, 0.0008, 4, 0.25, 1.0, 131, 3, 0, 0, 0, 722, 10, 1], "semantic": {"name": "new_object", "arg_names": [], "import_names": [], "rhs_call_name": "model", "annotation": ""}, "snippet": " new_object = self.model()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L788_C12", "label": "prefixes =", "type": "assigned_variable", "loc": [788, 788], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "vector": [14, 3, 0.6113, 0.0008, 3, 0.23, 0.2222, 948, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "prefixes", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prefixes = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L789_C12", "label": "for FormSet, inline", "type": "for", "loc": [789, 798], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "vector": [6, 3, 0.6156, 0.0078, 3, 0.23, 0.3333, 429, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "FormSet, inline", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for FormSet, inline in zip(self.get_formsets(request), self.inline_instances):\n prefix = FormSet.get_default_prefix()\n prefixes[prefix] = prefixes.get(prefix, 0) + 1\n if prefixes[prefix] != 1:\n prefix = \"%s-%s\" % (prefix, prefixes[prefix])\n formset = FormSet(data=request.POST, files=request.FILES,\n instance=new_object,\n save_as_new=\"_saveasnew\" in request.POST,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L790_C16", "label": "prefix = get_default_prefix()", "type": "assigned_variable", "loc": [790, 790], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L789_C12", "vector": [14, 4, 0.6129, 0.0008, 4, 0.38, 0.0, 284, 3, 0, 0, 0, 80, 10, 1], "semantic": {"name": "prefix", "arg_names": [], "import_names": [], "rhs_call_name": "get_default_prefix", "annotation": ""}, "snippet": " prefix = FormSet.get_default_prefix()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L791_C16", "label": "assign", "type": "assigned_variable", "loc": [791, 791], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L789_C12", "vector": [14, 4, 0.6137, 0.0008, 4, 0.38, 0.25, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prefixes[prefix] = prefixes.get(prefix, 0) + 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L792_C16", "label": "if", "type": "if", "loc": [792, 793], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L789_C12", "vector": [4, 4, 0.6148, 0.0016, 4, 0.38, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if prefixes[prefix] != 1:\n prefix = \"%s-%s\" % (prefix, prefixes[prefix])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L793_C20", "label": "prefix =", "type": "assigned_variable", "loc": [793, 793], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L792_C16", "vector": [14, 5, 0.6152, 0.0008, 5, 0.49, 0.0, 284, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "prefix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prefix = \"%s-%s\" % (prefix, prefixes[prefix])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L794_C16", "label": "formset = FormSet()", "type": "assigned_variable", "loc": [794, 797], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L789_C12", "vector": [14, 4, 0.6171, 0.0031, 4, 0.38, 0.75, 613, 3, 6, 0, 0, 477, 10, 2], "semantic": {"name": "formset", "arg_names": [], "import_names": [], "rhs_call_name": "FormSet", "annotation": ""}, "snippet": " formset = FormSet(data=request.POST, files=request.FILES,\n instance=new_object,\n save_as_new=\"_saveasnew\" in request.POST,\n prefix=prefix, queryset=inline.queryset(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L798_C16", "label": "append()", "type": "expression", "loc": [798, 798], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L789_C12", "vector": [8, 4, 0.6191, 0.0008, 4, 0.38, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " formsets.append(formset)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L799_C12", "label": "if", "type": "if", "loc": [799, 806], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "vector": [4, 3, 0.6226, 0.0062, 3, 0.23, 0.4444, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if all_valid(formsets) and form_validated:\n self.save_model(request, new_object, form, change=False)\n form.save_m2m()\n for formset in formsets:\n self.save_formset(request, form, formset, change=False)\n\n self.log_addition(request, new_object)\n return self.response_add(request, new_object)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L800_C16", "label": "save_model()", "type": "expression", "loc": [800, 800], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L799_C12", "vector": [8, 4, 0.6206, 0.0008, 4, 0.71, 0.0, 231, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "save_model", "arg_names": [], "import_names": [], "rhs_call_name": "save_model", "annotation": ""}, "snippet": " self.save_model(request, new_object, form, change=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L801_C16", "label": "save_m2m()", "type": "expression", "loc": [801, 801], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L799_C12", "vector": [8, 4, 0.6214, 0.0008, 4, 0.71, 0.25, 874, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save_m2m", "arg_names": [], "import_names": [], "rhs_call_name": "save_m2m", "annotation": ""}, "snippet": " form.save_m2m()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L802_C16", "label": "for formset", "type": "for", "loc": [802, 803], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L799_C12", "vector": [6, 4, 0.6226, 0.0016, 4, 0.71, 0.5, 613, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for formset in formsets:\n self.save_formset(request, form, formset, change=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L803_C20", "label": "save_formset()", "type": "expression", "loc": [803, 803], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L802_C16", "vector": [8, 5, 0.623, 0.0008, 5, 0.88, 0.0, 364, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "save_formset", "arg_names": [], "import_names": [], "rhs_call_name": "save_formset", "annotation": ""}, "snippet": " self.save_formset(request, form, formset, change=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L805_C16", "label": "log_addition()", "type": "expression", "loc": [805, 805], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L799_C12", "vector": [8, 4, 0.6245, 0.0008, 4, 0.71, 0.75, 76, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "log_addition", "arg_names": [], "import_names": [], "rhs_call_name": "log_addition", "annotation": ""}, "snippet": " self.log_addition(request, new_object)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L806_C16", "label": "return", "type": "return", "loc": [806, 806], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L799_C12", "vector": [13, 4, 0.6253, 0.0008, 4, 0.71, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.response_add(request, new_object)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L810_C12", "label": "initial = dict()", "type": "assigned_variable", "loc": [810, 810], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "vector": [14, 3, 0.6284, 0.0008, 3, 0.23, 0.5556, 838, 3, 1, 0, 0, 827, 10, 2], "semantic": {"name": "initial", "arg_names": [], "import_names": [], "rhs_call_name": "dict", "annotation": ""}, "snippet": " initial = dict(request.GET.items())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L811_C12", "label": "for k", "type": "for", "loc": [811, 817], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "vector": [6, 3, 0.6315, 0.0054, 3, 0.23, 0.6667, 954, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "k", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for k in initial:\n try:\n f = opts.get_field(k)\n except models.FieldDoesNotExist:\n continue\n if isinstance(f, models.ManyToManyField):\n initial[k] = initial[k].split(\",\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L812_C16", "label": "try", "type": "try", "loc": [812, 815], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L811_C12", "vector": [7, 4, 0.6311, 0.0031, 4, 0.52, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n f = opts.get_field(k)\n except models.FieldDoesNotExist:\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L813_C20", "label": "f = get_field()", "type": "assigned_variable", "loc": [813, 813], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L812_C16", "vector": [14, 5, 0.6307, 0.0008, 5, 0.36, 0.0, 899, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = opts.get_field(k)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L816_C16", "label": "if", "type": "if", "loc": [816, 817], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L811_C12", "vector": [4, 4, 0.6334, 0.0016, 4, 0.52, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f, models.ManyToManyField):\n initial[k] = initial[k].split(\",\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L817_C20", "label": " = split()", "type": "assigned_variable", "loc": [817, 817], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L816_C16", "vector": [14, 5, 0.6338, 0.0008, 5, 0.56, 0.0, 0, 3, 1, 0, 0, 908, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " initial[k] = initial[k].split(\",\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L818_C12", "label": "form = ModelForm()", "type": "assigned_variable", "loc": [818, 818], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "vector": [14, 3, 0.6346, 0.0008, 3, 0.23, 0.7778, 761, 3, 1, 0, 0, 118, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "ModelForm", "annotation": ""}, "snippet": " form = ModelForm(initial=initial)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L819_C12", "label": "prefixes =", "type": "assigned_variable", "loc": [819, 819], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "vector": [14, 3, 0.6354, 0.0008, 3, 0.23, 0.8889, 948, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "prefixes", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prefixes = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L820_C12", "label": "for FormSet, inline", "type": "for", "loc": [820, 828], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "vector": [6, 3, 0.6393, 0.007, 3, 0.23, 1.0, 429, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "FormSet, inline", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for FormSet, inline in zip(self.get_formsets(request),\n self.inline_instances):\n prefix = FormSet.get_default_prefix()\n prefixes[prefix] = prefixes.get(prefix, 0) + 1\n if prefixes[prefix] != 1:\n prefix = \"%s-%s\" % (prefix, prefixes[prefix])\n formset = FormSet(instance=self.model(), prefix=prefix,\n queryset=inline.queryset(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L822_C16", "label": "prefix = get_default_prefix()", "type": "assigned_variable", "loc": [822, 822], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L820_C12", "vector": [14, 4, 0.6377, 0.0008, 4, 0.25, 0.0, 284, 3, 0, 0, 0, 80, 10, 1], "semantic": {"name": "prefix", "arg_names": [], "import_names": [], "rhs_call_name": "get_default_prefix", "annotation": ""}, "snippet": " prefix = FormSet.get_default_prefix()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L823_C16", "label": "assign", "type": "assigned_variable", "loc": [823, 823], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L820_C12", "vector": [14, 4, 0.6385, 0.0008, 4, 0.25, 0.25, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prefixes[prefix] = prefixes.get(prefix, 0) + 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L824_C16", "label": "if", "type": "if", "loc": [824, 825], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L820_C12", "vector": [4, 4, 0.6396, 0.0016, 4, 0.25, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if prefixes[prefix] != 1:\n prefix = \"%s-%s\" % (prefix, prefixes[prefix])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L825_C20", "label": "prefix =", "type": "assigned_variable", "loc": [825, 825], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L824_C16", "vector": [14, 5, 0.64, 0.0008, 5, 0.5, 0.0, 284, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "prefix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prefix = \"%s-%s\" % (prefix, prefixes[prefix])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L826_C16", "label": "formset = FormSet()", "type": "assigned_variable", "loc": [826, 827], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L820_C12", "vector": [14, 4, 0.6412, 0.0016, 4, 0.25, 0.75, 613, 3, 3, 0, 0, 477, 10, 3], "semantic": {"name": "formset", "arg_names": [], "import_names": [], "rhs_call_name": "FormSet", "annotation": ""}, "snippet": " formset = FormSet(instance=self.model(), prefix=prefix,\n queryset=inline.queryset(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L828_C16", "label": "append()", "type": "expression", "loc": [828, 828], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L820_C12", "vector": [8, 4, 0.6424, 0.0008, 4, 0.25, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " formsets.append(formset)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L830_C8", "label": "adminForm = AdminForm()", "type": "assigned_variable", "loc": [830, 832], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [14, 2, 0.6447, 0.0023, 2, 0.23, 0.5385, 130, 3, 5, 0, 0, 529, 10, 4], "semantic": {"name": "adminForm", "arg_names": [], "import_names": [], "rhs_call_name": "AdminForm", "annotation": ""}, "snippet": " adminForm = helpers.AdminForm(form, list(self.get_fieldsets(request)),\n self.prepopulated_fields, self.get_readonly_fields(request),\n model_admin=self)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L833_C8", "label": "media =", "type": "assigned_variable", "loc": [833, 833], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [14, 2, 0.6462, 0.0008, 2, 0.23, 0.6154, 317, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " media = self.media + adminForm.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L835_C8", "label": "inline_admin_formsets =", "type": "assigned_variable", "loc": [835, 835], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [14, 2, 0.6478, 0.0008, 2, 0.23, 0.6923, 945, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "inline_admin_formsets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " inline_admin_formsets = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L836_C8", "label": "for inline, formset", "type": "for", "loc": [836, 842], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [6, 2, 0.6509, 0.0054, 2, 0.23, 0.7692, 535, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "inline, formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for inline, formset in zip(self.inline_instances, formsets):\n fieldsets = list(inline.get_fieldsets(request))\n readonly = list(inline.get_readonly_fields(request))\n inline_admin_formset = helpers.InlineAdminFormSet(inline, formset,\n fieldsets, readonly, model_admin=self)\n inline_admin_formsets.append(inline_admin_formset)\n media = media + inline_admin_formset.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L837_C12", "label": "fieldsets = list()", "type": "assigned_variable", "loc": [837, 837], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L836_C8", "vector": [14, 3, 0.6493, 0.0008, 3, 0.82, 0.0, 340, 3, 1, 0, 0, 430, 10, 2], "semantic": {"name": "fieldsets", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " fieldsets = list(inline.get_fieldsets(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L838_C12", "label": "readonly = list()", "type": "assigned_variable", "loc": [838, 838], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L836_C8", "vector": [14, 3, 0.6501, 0.0008, 3, 0.82, 0.25, 176, 3, 1, 0, 0, 430, 10, 2], "semantic": {"name": "readonly", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " readonly = list(inline.get_readonly_fields(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L839_C12", "label": "inline_admin_formset = InlineAdminFormSet()", "type": "assigned_variable", "loc": [839, 840], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L836_C8", "vector": [14, 3, 0.6513, 0.0016, 3, 0.82, 0.5, 318, 3, 5, 0, 0, 185, 10, 1], "semantic": {"name": "inline_admin_formset", "arg_names": [], "import_names": [], "rhs_call_name": "InlineAdminFormSet", "annotation": ""}, "snippet": " inline_admin_formset = helpers.InlineAdminFormSet(inline, formset,\n fieldsets, readonly, model_admin=self)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L841_C12", "label": "append()", "type": "expression", "loc": [841, 841], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L836_C8", "vector": [8, 3, 0.6524, 0.0008, 3, 0.82, 0.75, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " inline_admin_formsets.append(inline_admin_formset)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L842_C12", "label": "media =", "type": "assigned_variable", "loc": [842, 842], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L836_C8", "vector": [14, 3, 0.6532, 0.0008, 3, 0.82, 1.0, 317, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " media = media + inline_admin_formset.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L844_C8", "label": "context =", "type": "assigned_variable", "loc": [844, 854], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [14, 2, 0.6587, 0.0085, 2, 0.23, 0.8462, 954, 0, 0, 0, 0, 0, 6, 4], "semantic": {"name": "context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context = {\n 'title': _('Add %s') % force_unicode(opts.verbose_name),\n 'adminform': adminForm,\n 'is_popup': \"_popup\" in request.REQUEST,\n 'show_delete': False,\n 'media': mark_safe(media),\n 'inline_admin_formsets': inline_admin_formsets,\n 'errors': helpers.AdminErrorList(form, formsets),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L855_C8", "label": "update()", "type": "expression", "loc": [855, 855], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [8, 2, 0.6633, 0.0008, 2, 0.23, 0.9231, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " context.update(extra_context or {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L856_C8", "label": "return", "type": "return", "loc": [856, 856], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "vector": [13, 2, 0.6641, 0.0008, 2, 0.23, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.render_change_form(request, context, form_url=form_url, add=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "label": "change_view", "type": "function", "loc": [860, 948], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.7013, 0.069, 1, 0.87, 0.9385, 542, 0, 4, 1, 0, 0, 0, 50], "semantic": {"name": "change_view", "arg_names": ["self", "request", "object_id", "extra_context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def change_view(self, request, object_id, extra_context=None):\n \"The 'change' admin view for this model.\"\n model = self.model\n opts = model._meta\n\n obj = self.get_object(request, unquote(object_id))\n\n if not self.has_change_permission(request, obj):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L861_C8", "label": "expression", "type": "expression", "loc": [861, 861], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [8, 2, 0.668, 0.0008, 2, 0.25, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"The 'change' admin view for this model.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L862_C8", "label": "model =", "type": "assigned_variable", "loc": [862, 862], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [14, 2, 0.6687, 0.0008, 2, 0.25, 0.0625, 722, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model = self.model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L863_C8", "label": "opts =", "type": "assigned_variable", "loc": [863, 863], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [14, 2, 0.6695, 0.0008, 2, 0.25, 0.125, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L865_C8", "label": "obj = get_object()", "type": "assigned_variable", "loc": [865, 865], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [14, 2, 0.6711, 0.0008, 2, 0.25, 0.1875, 505, 3, 2, 0, 0, 237, 10, 2], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "get_object", "annotation": ""}, "snippet": " obj = self.get_object(request, unquote(object_id))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L867_C8", "label": "if", "type": "if", "loc": [867, 868], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [4, 2, 0.673, 0.0016, 2, 0.25, 0.25, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.has_change_permission(request, obj):\n raise PermissionDenied"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L870_C8", "label": "if", "type": "if", "loc": [870, 871], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [4, 2, 0.6753, 0.0016, 2, 0.25, 0.3125, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if obj is None:\n raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_unicode(opts.verbose_name), 'key': escape(object_id)})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L873_C8", "label": "if", "type": "if", "loc": [873, 874], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [4, 2, 0.6777, 0.0016, 2, 0.25, 0.375, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.method == 'POST' and \"_saveasnew\" in request.POST:\n return self.add_view(request, form_url='../add/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L874_C12", "label": "return", "type": "return", "loc": [874, 874], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L873_C8", "vector": [13, 3, 0.678, 0.0008, 3, 0.88, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.add_view(request, form_url='../add/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L876_C8", "label": "ModelForm = get_form()", "type": "assigned_variable", "loc": [876, 876], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [14, 2, 0.6796, 0.0008, 2, 0.25, 0.4375, 118, 3, 2, 0, 0, 265, 10, 1], "semantic": {"name": "ModelForm", "arg_names": [], "import_names": [], "rhs_call_name": "get_form", "annotation": ""}, "snippet": " ModelForm = self.get_form(request, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L877_C8", "label": "formsets =", "type": "assigned_variable", "loc": [877, 877], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [14, 2, 0.6804, 0.0008, 2, 0.25, 0.5, 507, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "formsets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " formsets = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "label": "if", "type": "if", "loc": [878, 919], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [4, 2, 0.6971, 0.0326, 2, 0.25, 0.5625, 0, 0, 0, 0, 0, 0, 0, 25], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.method == 'POST':\n form = ModelForm(request.POST, request.FILES, instance=obj)\n if form.is_valid():\n form_validated = True\n new_object = self.save_form(request, form, change=True)\n else:\n form_validated = False\n new_object = obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L879_C12", "label": "form = ModelForm()", "type": "assigned_variable", "loc": [879, 879], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "vector": [14, 3, 0.6819, 0.0008, 3, 0.8, 0.0, 761, 3, 3, 0, 0, 118, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "ModelForm", "annotation": ""}, "snippet": " form = ModelForm(request.POST, request.FILES, instance=obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L880_C12", "label": "if", "type": "if", "loc": [880, 885], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "vector": [4, 3, 0.6846, 0.0047, 3, 0.8, 0.1429, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.is_valid():\n form_validated = True\n new_object = self.save_form(request, form, change=True)\n else:\n form_validated = False\n new_object = obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L881_C16", "label": "form_validated =", "type": "assigned_variable", "loc": [881, 881], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L880_C12", "vector": [14, 4, 0.6835, 0.0008, 4, 0.78, 0.0, 907, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "form_validated", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " form_validated = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L882_C16", "label": "new_object = save_form()", "type": "assigned_variable", "loc": [882, 882], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L880_C12", "vector": [14, 4, 0.6843, 0.0008, 4, 0.78, 0.3333, 131, 3, 3, 0, 0, 72, 10, 1], "semantic": {"name": "new_object", "arg_names": [], "import_names": [], "rhs_call_name": "save_form", "annotation": ""}, "snippet": " new_object = self.save_form(request, form, change=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L884_C16", "label": "form_validated =", "type": "assigned_variable", "loc": [884, 884], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L880_C12", "vector": [14, 4, 0.6858, 0.0008, 4, 0.78, 0.6667, 907, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "form_validated", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " form_validated = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L885_C16", "label": "new_object =", "type": "assigned_variable", "loc": [885, 885], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L880_C12", "vector": [14, 4, 0.6866, 0.0008, 4, 0.78, 1.0, 131, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "new_object", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " new_object = obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L886_C12", "label": "prefixes =", "type": "assigned_variable", "loc": [886, 886], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "vector": [14, 3, 0.6874, 0.0008, 3, 0.8, 0.2857, 948, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "prefixes", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prefixes = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L887_C12", "label": "for FormSet, inline", "type": "for", "loc": [887, 897], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "vector": [6, 3, 0.692, 0.0085, 3, 0.8, 0.4286, 429, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "FormSet, inline", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for FormSet, inline in zip(self.get_formsets(request, new_object),\n self.inline_instances):\n prefix = FormSet.get_default_prefix()\n prefixes[prefix] = prefixes.get(prefix, 0) + 1\n if prefixes[prefix] != 1:\n prefix = \"%s-%s\" % (prefix, prefixes[prefix])\n formset = FormSet(request.POST, request.FILES,\n instance=new_object, prefix=prefix,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L889_C16", "label": "prefix = get_default_prefix()", "type": "assigned_variable", "loc": [889, 889], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L887_C12", "vector": [14, 4, 0.6897, 0.0008, 4, 0.99, 0.0, 284, 3, 0, 0, 0, 80, 10, 1], "semantic": {"name": "prefix", "arg_names": [], "import_names": [], "rhs_call_name": "get_default_prefix", "annotation": ""}, "snippet": " prefix = FormSet.get_default_prefix()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L890_C16", "label": "assign", "type": "assigned_variable", "loc": [890, 890], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L887_C12", "vector": [14, 4, 0.6905, 0.0008, 4, 0.99, 0.25, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prefixes[prefix] = prefixes.get(prefix, 0) + 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L891_C16", "label": "if", "type": "if", "loc": [891, 892], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L887_C12", "vector": [4, 4, 0.6916, 0.0016, 4, 0.99, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if prefixes[prefix] != 1:\n prefix = \"%s-%s\" % (prefix, prefixes[prefix])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L892_C20", "label": "prefix =", "type": "assigned_variable", "loc": [892, 892], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L891_C16", "vector": [14, 5, 0.692, 0.0008, 5, 0.98, 0.0, 284, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "prefix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prefix = \"%s-%s\" % (prefix, prefixes[prefix])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L893_C16", "label": "formset = FormSet()", "type": "assigned_variable", "loc": [893, 895], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L887_C12", "vector": [14, 4, 0.6936, 0.0023, 4, 0.99, 0.75, 613, 3, 5, 0, 0, 477, 10, 2], "semantic": {"name": "formset", "arg_names": [], "import_names": [], "rhs_call_name": "FormSet", "annotation": ""}, "snippet": " formset = FormSet(request.POST, request.FILES,\n instance=new_object, prefix=prefix,\n queryset=inline.queryset(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L897_C16", "label": "append()", "type": "expression", "loc": [897, 897], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L887_C12", "vector": [8, 4, 0.6959, 0.0008, 4, 0.99, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " formsets.append(formset)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "label": "if", "type": "if", "loc": [899, 907], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "vector": [4, 3, 0.7005, 0.007, 3, 0.8, 0.5714, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if all_valid(formsets) and form_validated:\n self.save_model(request, new_object, form, change=True)\n form.save_m2m()\n for formset in formsets:\n self.save_formset(request, form, formset, change=True)\n\n change_message = self.construct_change_message(request, form, formsets)\n self.log_change(request, new_object, change_message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L900_C16", "label": "save_model()", "type": "expression", "loc": [900, 900], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "vector": [8, 4, 0.6982, 0.0008, 4, 0.55, 0.0, 231, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "save_model", "arg_names": [], "import_names": [], "rhs_call_name": "save_model", "annotation": ""}, "snippet": " self.save_model(request, new_object, form, change=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L901_C16", "label": "save_m2m()", "type": "expression", "loc": [901, 901], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "vector": [8, 4, 0.699, 0.0008, 4, 0.55, 0.2, 874, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save_m2m", "arg_names": [], "import_names": [], "rhs_call_name": "save_m2m", "annotation": ""}, "snippet": " form.save_m2m()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L902_C16", "label": "for formset", "type": "for", "loc": [902, 903], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "vector": [6, 4, 0.7002, 0.0016, 4, 0.55, 0.4, 613, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for formset in formsets:\n self.save_formset(request, form, formset, change=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L903_C20", "label": "save_formset()", "type": "expression", "loc": [903, 903], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L902_C16", "vector": [8, 5, 0.7005, 0.0008, 5, 0.66, 0.0, 364, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "save_formset", "arg_names": [], "import_names": [], "rhs_call_name": "save_formset", "annotation": ""}, "snippet": " self.save_formset(request, form, formset, change=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L905_C16", "label": "change_message = construct_change_message()", "type": "assigned_variable", "loc": [905, 905], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "vector": [14, 4, 0.7021, 0.0008, 4, 0.55, 0.6, 306, 3, 3, 0, 0, 314, 10, 1], "semantic": {"name": "change_message", "arg_names": [], "import_names": [], "rhs_call_name": "construct_change_message", "annotation": ""}, "snippet": " change_message = self.construct_change_message(request, form, formsets)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L906_C16", "label": "log_change()", "type": "expression", "loc": [906, 906], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "vector": [8, 4, 0.7029, 0.0008, 4, 0.55, 0.8, 625, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "log_change", "arg_names": [], "import_names": [], "rhs_call_name": "log_change", "annotation": ""}, "snippet": " self.log_change(request, new_object, change_message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L907_C16", "label": "return", "type": "return", "loc": [907, 907], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "vector": [13, 4, 0.7036, 0.0008, 4, 0.55, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.response_change(request, new_object)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L910_C12", "label": "form = ModelForm()", "type": "assigned_variable", "loc": [910, 910], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "vector": [14, 3, 0.706, 0.0008, 3, 0.8, 0.7143, 761, 3, 1, 0, 0, 118, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "ModelForm", "annotation": ""}, "snippet": " form = ModelForm(instance=obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L911_C12", "label": "prefixes =", "type": "assigned_variable", "loc": [911, 911], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "vector": [14, 3, 0.7067, 0.0008, 3, 0.8, 0.8571, 948, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "prefixes", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prefixes = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L912_C12", "label": "for FormSet, inline", "type": "for", "loc": [912, 919], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "vector": [6, 3, 0.7102, 0.0062, 3, 0.8, 1.0, 429, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "FormSet, inline", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for FormSet, inline in zip(self.get_formsets(request, obj), self.inline_instances):\n prefix = FormSet.get_default_prefix()\n prefixes[prefix] = prefixes.get(prefix, 0) + 1\n if prefixes[prefix] != 1:\n prefix = \"%s-%s\" % (prefix, prefixes[prefix])\n formset = FormSet(instance=obj, prefix=prefix,\n queryset=inline.queryset(request))\n formsets.append(formset)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L913_C16", "label": "prefix = get_default_prefix()", "type": "assigned_variable", "loc": [913, 913], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L912_C12", "vector": [14, 4, 0.7083, 0.0008, 4, 0.16, 0.0, 284, 3, 0, 0, 0, 80, 10, 1], "semantic": {"name": "prefix", "arg_names": [], "import_names": [], "rhs_call_name": "get_default_prefix", "annotation": ""}, "snippet": " prefix = FormSet.get_default_prefix()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L914_C16", "label": "assign", "type": "assigned_variable", "loc": [914, 914], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L912_C12", "vector": [14, 4, 0.7091, 0.0008, 4, 0.16, 0.25, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prefixes[prefix] = prefixes.get(prefix, 0) + 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L915_C16", "label": "if", "type": "if", "loc": [915, 916], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L912_C12", "vector": [4, 4, 0.7102, 0.0016, 4, 0.16, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if prefixes[prefix] != 1:\n prefix = \"%s-%s\" % (prefix, prefixes[prefix])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L916_C20", "label": "prefix =", "type": "assigned_variable", "loc": [916, 916], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L915_C16", "vector": [14, 5, 0.7106, 0.0008, 5, 0.15, 0.0, 284, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "prefix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prefix = \"%s-%s\" % (prefix, prefixes[prefix])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L917_C16", "label": "formset = FormSet()", "type": "assigned_variable", "loc": [917, 918], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L912_C12", "vector": [14, 4, 0.7118, 0.0016, 4, 0.16, 0.75, 613, 3, 3, 0, 0, 477, 10, 2], "semantic": {"name": "formset", "arg_names": [], "import_names": [], "rhs_call_name": "FormSet", "annotation": ""}, "snippet": " formset = FormSet(instance=obj, prefix=prefix,\n queryset=inline.queryset(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L919_C16", "label": "append()", "type": "expression", "loc": [919, 919], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L912_C12", "vector": [8, 4, 0.713, 0.0008, 4, 0.16, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " formsets.append(formset)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L921_C8", "label": "adminForm = AdminForm()", "type": "assigned_variable", "loc": [921, 923], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [14, 2, 0.7153, 0.0023, 2, 0.25, 0.625, 130, 3, 5, 0, 0, 529, 10, 3], "semantic": {"name": "adminForm", "arg_names": [], "import_names": [], "rhs_call_name": "AdminForm", "annotation": ""}, "snippet": " adminForm = helpers.AdminForm(form, self.get_fieldsets(request, obj),\n self.prepopulated_fields, self.get_readonly_fields(request, obj),\n model_admin=self)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L924_C8", "label": "media =", "type": "assigned_variable", "loc": [924, 924], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [14, 2, 0.7168, 0.0008, 2, 0.25, 0.6875, 317, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " media = self.media + adminForm.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L926_C8", "label": "inline_admin_formsets =", "type": "assigned_variable", "loc": [926, 926], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [14, 2, 0.7184, 0.0008, 2, 0.25, 0.75, 945, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "inline_admin_formsets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " inline_admin_formsets = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L927_C8", "label": "for inline, formset", "type": "for", "loc": [927, 933], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [6, 2, 0.7215, 0.0054, 2, 0.25, 0.8125, 535, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "inline, formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for inline, formset in zip(self.inline_instances, formsets):\n fieldsets = list(inline.get_fieldsets(request, obj))\n readonly = list(inline.get_readonly_fields(request, obj))\n inline_admin_formset = helpers.InlineAdminFormSet(inline, formset,\n fieldsets, readonly, model_admin=self)\n inline_admin_formsets.append(inline_admin_formset)\n media = media + inline_admin_formset.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L928_C12", "label": "fieldsets = list()", "type": "assigned_variable", "loc": [928, 928], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L927_C8", "vector": [14, 3, 0.7199, 0.0008, 3, 0.65, 0.0, 340, 3, 1, 0, 0, 430, 10, 2], "semantic": {"name": "fieldsets", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " fieldsets = list(inline.get_fieldsets(request, obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L929_C12", "label": "readonly = list()", "type": "assigned_variable", "loc": [929, 929], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L927_C8", "vector": [14, 3, 0.7207, 0.0008, 3, 0.65, 0.25, 176, 3, 1, 0, 0, 430, 10, 2], "semantic": {"name": "readonly", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " readonly = list(inline.get_readonly_fields(request, obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L930_C12", "label": "inline_admin_formset = InlineAdminFormSet()", "type": "assigned_variable", "loc": [930, 931], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L927_C8", "vector": [14, 3, 0.7219, 0.0016, 3, 0.65, 0.5, 318, 3, 5, 0, 0, 185, 10, 1], "semantic": {"name": "inline_admin_formset", "arg_names": [], "import_names": [], "rhs_call_name": "InlineAdminFormSet", "annotation": ""}, "snippet": " inline_admin_formset = helpers.InlineAdminFormSet(inline, formset,\n fieldsets, readonly, model_admin=self)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L932_C12", "label": "append()", "type": "expression", "loc": [932, 932], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L927_C8", "vector": [8, 3, 0.723, 0.0008, 3, 0.65, 0.75, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " inline_admin_formsets.append(inline_admin_formset)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L933_C12", "label": "media =", "type": "assigned_variable", "loc": [933, 933], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L927_C8", "vector": [14, 3, 0.7238, 0.0008, 3, 0.65, 1.0, 317, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " media = media + inline_admin_formset.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L935_C8", "label": "context =", "type": "assigned_variable", "loc": [935, 946], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [14, 2, 0.7296, 0.0093, 2, 0.25, 0.875, 954, 0, 0, 0, 0, 0, 6, 4], "semantic": {"name": "context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context = {\n 'title': _('Change %s') % force_unicode(opts.verbose_name),\n 'adminform': adminForm,\n 'object_id': object_id,\n 'original': obj,\n 'is_popup': \"_popup\" in request.REQUEST,\n 'media': mark_safe(media),\n 'inline_admin_formsets': inline_admin_formsets,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L947_C8", "label": "update()", "type": "expression", "loc": [947, 947], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [8, 2, 0.7347, 0.0008, 2, 0.25, 0.9375, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " context.update(extra_context or {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L948_C8", "label": "return", "type": "return", "loc": [948, 948], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "vector": [13, 2, 0.7355, 0.0008, 2, 0.25, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.render_change_form(request, context, change=True, obj=obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "label": "changelist_view", "type": "function", "loc": [951, 1096], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.794, 0.1133, 1, 0.87, 0.9538, 368, 0, 3, 1, 0, 0, 0, 46], "semantic": {"name": "changelist_view", "arg_names": ["self", "request", "extra_context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def changelist_view(self, request, extra_context=None):\n \"The 'change list' admin view for this model.\"\n from django.contrib.admin.views.main import ERROR_FLAG\n opts = self.model._meta\n app_label = opts.app_label\n if not self.has_change_permission(request, None):\n raise PermissionDenied\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L952_C8", "label": "expression", "type": "expression", "loc": [952, 952], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [8, 2, 0.7386, 0.0008, 2, 0.11, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"The 'change list' admin view for this model.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L953_C8", "label": "from django.contrib.admin.views.main import ERROR_FLAG", "type": "import", "loc": [953, 953], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [1, 2, 0.7393, 0.0008, 2, 0.11, 0.0455, 696, 0, 1, 0, 0, 696, 0, 0], "semantic": {"name": "django.contrib.admin.views.main", "arg_names": [], "import_names": ["ERROR_FLAG"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.views.main import ERROR_FLAG"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L954_C8", "label": "opts =", "type": "assigned_variable", "loc": [954, 954], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [14, 2, 0.7401, 0.0008, 2, 0.11, 0.0909, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = self.model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L955_C8", "label": "app_label =", "type": "assigned_variable", "loc": [955, 955], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [14, 2, 0.7409, 0.0008, 2, 0.11, 0.1364, 187, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "app_label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_label = opts.app_label"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L956_C8", "label": "if", "type": "if", "loc": [956, 957], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [4, 2, 0.742, 0.0016, 2, 0.11, 0.1818, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.has_change_permission(request, None):\n raise PermissionDenied"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L960_C8", "label": "actions = get_actions()", "type": "assigned_variable", "loc": [960, 960], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [14, 2, 0.7448, 0.0008, 2, 0.11, 0.2273, 317, 3, 1, 0, 0, 315, 10, 1], "semantic": {"name": "actions", "arg_names": [], "import_names": [], "rhs_call_name": "get_actions", "annotation": ""}, "snippet": " actions = self.get_actions(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L963_C8", "label": "list_display = list()", "type": "assigned_variable", "loc": [963, 963], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [14, 2, 0.7471, 0.0008, 2, 0.11, 0.2727, 489, 3, 1, 0, 0, 430, 10, 1], "semantic": {"name": "list_display", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " list_display = list(self.list_display)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L964_C8", "label": "if", "type": "if", "loc": [964, 968], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [4, 2, 0.7494, 0.0039, 2, 0.11, 0.3182, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not actions:\n try:\n list_display.remove('action_checkbox')\n except ValueError:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L965_C12", "label": "try", "type": "try", "loc": [965, 968], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L964_C8", "vector": [7, 3, 0.7498, 0.0031, 3, 0.21, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n list_display.remove('action_checkbox')\n except ValueError:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L966_C16", "label": "remove()", "type": "expression", "loc": [966, 966], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L965_C12", "vector": [8, 4, 0.7494, 0.0008, 4, 0.67, 0.0, 185, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "remove", "arg_names": [], "import_names": [], "rhs_call_name": "remove", "annotation": ""}, "snippet": " list_display.remove('action_checkbox')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L970_C8", "label": "ChangeList = get_changelist()", "type": "assigned_variable", "loc": [970, 970], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [14, 2, 0.7525, 0.0008, 2, 0.11, 0.3636, 574, 3, 1, 0, 0, 202, 10, 1], "semantic": {"name": "ChangeList", "arg_names": [], "import_names": [], "rhs_call_name": "get_changelist", "annotation": ""}, "snippet": " ChangeList = self.get_changelist(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L971_C8", "label": "try", "type": "try", "loc": [971, 983], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [7, 2, 0.758, 0.0101, 2, 0.11, 0.4091, 0, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n cl = ChangeList(request, self.model, list_display, self.list_display_links, self.list_filter,\n self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self)\n except IncorrectLookupParameters:\n # Wacky lookup parameters were given, so redirect to the main\n # changelist page, without parameters, and pass an 'invalid=1'\n # parameter via the query string. If wacky parameters were given\n # and the 'invalid=1' parameter was already in the query string,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L972_C12", "label": "cl = ChangeList()", "type": "assigned_variable", "loc": [972, 973], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L971_C8", "vector": [14, 3, 0.7545, 0.0016, 3, 0.43, 0.0, 649, 3, 11, 0, 0, 574, 10, 1], "semantic": {"name": "cl", "arg_names": [], "import_names": [], "rhs_call_name": "ChangeList", "annotation": ""}, "snippet": " cl = ChangeList(request, self.model, list_display, self.list_display_links, self.list_filter,\n self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L981_C12", "label": "if", "type": "if", "loc": [981, 982], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L971_C8", "vector": [4, 3, 0.7614, 0.0016, 3, 0.43, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ERROR_FLAG in request.GET.keys():\n return render_to_response('admin/invalid_setup.html', {'title': _('Database error')})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L982_C16", "label": "return", "type": "return", "loc": [982, 982], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L981_C12", "vector": [13, 4, 0.7618, 0.0008, 4, 0.21, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response('admin/invalid_setup.html', {'title': _('Database error')})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L983_C12", "label": "return", "type": "return", "loc": [983, 983], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L971_C8", "vector": [13, 3, 0.7626, 0.0008, 3, 0.43, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L989_C8", "label": "action_failed =", "type": "assigned_variable", "loc": [989, 989], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [14, 2, 0.7673, 0.0008, 2, 0.11, 0.4545, 838, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "action_failed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " action_failed = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L990_C8", "label": "selected = getlist()", "type": "assigned_variable", "loc": [990, 990], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [14, 2, 0.768, 0.0008, 2, 0.11, 0.5, 73, 3, 1, 0, 0, 585, 10, 1], "semantic": {"name": "selected", "arg_names": [], "import_names": [], "rhs_call_name": "getlist", "annotation": ""}, "snippet": " selected = request.POST.getlist(helpers.ACTION_CHECKBOX_NAME)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L993_C8", "label": "if", "type": "if", "loc": [993, 1005], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [4, 2, 0.775, 0.0101, 2, 0.11, 0.5455, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if (actions and request.method == 'POST' and\n 'index' in request.POST and '_save' not in request.POST):\n if selected:\n response = self.response_action(request, queryset=cl.get_query_set())\n if response:\n return response\n else:\n action_failed = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L995_C12", "label": "if", "type": "if", "loc": [995, 1005], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L993_C8", "vector": [4, 3, 0.7758, 0.0085, 3, 0.23, 0.0, 0, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if selected:\n response = self.response_action(request, queryset=cl.get_query_set())\n if response:\n return response\n else:\n action_failed = True\n else:\n msg = _(\"Items must be selected in order to perform \""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L996_C16", "label": "response = response_action()", "type": "assigned_variable", "loc": [996, 996], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L995_C12", "vector": [14, 4, 0.7727, 0.0008, 4, 0.29, 0.0, 511, 3, 2, 0, 0, 811, 10, 2], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "response_action", "annotation": ""}, "snippet": " response = self.response_action(request, queryset=cl.get_query_set())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L997_C16", "label": "if", "type": "if", "loc": [997, 1000], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L995_C12", "vector": [4, 4, 0.7746, 0.0031, 4, 0.29, 0.25, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response:\n return response\n else:\n action_failed = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L998_C20", "label": "return", "type": "return", "loc": [998, 998], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L997_C16", "vector": [13, 5, 0.7742, 0.0008, 5, 0.85, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1000_C20", "label": "action_failed =", "type": "assigned_variable", "loc": [1000, 1000], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L997_C16", "vector": [14, 5, 0.7758, 0.0008, 5, 0.85, 1.0, 838, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "action_failed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " action_failed = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1002_C16", "label": "msg = _()", "type": "assigned_variable", "loc": [1002, 1003], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L995_C12", "vector": [14, 4, 0.7777, 0.0016, 4, 0.29, 0.5, 712, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " msg = _(\"Items must be selected in order to perform \"\n \"actions on them. No items have been changed.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1004_C16", "label": "message_user()", "type": "expression", "loc": [1004, 1004], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L995_C12", "vector": [8, 4, 0.7789, 0.0008, 4, 0.29, 0.75, 207, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1005_C16", "label": "action_failed =", "type": "assigned_variable", "loc": [1005, 1005], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L995_C12", "vector": [14, 4, 0.7797, 0.0008, 4, 0.29, 1.0, 838, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "action_failed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " action_failed = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1008_C8", "label": "if", "type": "if", "loc": [1008, 1016], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [4, 2, 0.7851, 0.007, 2, 0.11, 0.5909, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if (actions and request.method == 'POST' and\n helpers.ACTION_CHECKBOX_NAME in request.POST and\n 'index' not in request.POST and '_save' not in request.POST):\n if selected:\n response = self.response_action(request, queryset=cl.get_query_set())\n if response:\n return response\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1011_C12", "label": "if", "type": "if", "loc": [1011, 1016], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1008_C8", "vector": [4, 3, 0.7863, 0.0047, 3, 0.31, 0.0, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if selected:\n response = self.response_action(request, queryset=cl.get_query_set())\n if response:\n return response\n else:\n action_failed = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1012_C16", "label": "response = response_action()", "type": "assigned_variable", "loc": [1012, 1012], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1011_C12", "vector": [14, 4, 0.7851, 0.0008, 4, 0.67, 0.0, 511, 3, 2, 0, 0, 811, 10, 2], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "response_action", "annotation": ""}, "snippet": " response = self.response_action(request, queryset=cl.get_query_set())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1013_C16", "label": "if", "type": "if", "loc": [1013, 1016], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1011_C12", "vector": [4, 4, 0.787, 0.0031, 4, 0.67, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response:\n return response\n else:\n action_failed = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1014_C20", "label": "return", "type": "return", "loc": [1014, 1014], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1013_C16", "vector": [13, 5, 0.7867, 0.0008, 5, 0.4, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1016_C20", "label": "action_failed =", "type": "assigned_variable", "loc": [1016, 1016], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1013_C16", "vector": [14, 5, 0.7882, 0.0008, 5, 0.4, 1.0, 838, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "action_failed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " action_failed = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1021_C8", "label": "formset =", "type": "assigned_variable", "loc": [1021, 1021], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [14, 2, 0.7921, 0.0008, 2, 0.11, 0.6364, 613, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " formset = cl.formset = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1024_C8", "label": "if", "type": "if", "loc": [1024, 1056], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [4, 2, 0.8068, 0.0256, 2, 0.11, 0.6818, 0, 0, 0, 0, 0, 0, 0, 18], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if (request.method == \"POST\" and self.list_editable and\n '_save' in request.POST and not action_failed):\n FormSet = self.get_changelist_formset(request)\n formset = cl.formset = FormSet(request.POST, request.FILES, queryset=cl.result_list)\n if formset.is_valid():\n changecount = 0\n for form in formset.forms:\n if form.has_changed():"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1026_C12", "label": "FormSet = get_changelist_formset()", "type": "assigned_variable", "loc": [1026, 1026], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1024_C8", "vector": [14, 3, 0.796, 0.0008, 3, 0.42, 0.0, 477, 3, 1, 0, 0, 590, 10, 1], "semantic": {"name": "FormSet", "arg_names": [], "import_names": [], "rhs_call_name": "get_changelist_formset", "annotation": ""}, "snippet": " FormSet = self.get_changelist_formset(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1027_C12", "label": "formset = FormSet()", "type": "assigned_variable", "loc": [1027, 1027], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1024_C8", "vector": [14, 3, 0.7967, 0.0008, 3, 0.42, 0.3333, 613, 3, 3, 0, 0, 477, 10, 1], "semantic": {"name": "formset", "arg_names": [], "import_names": [], "rhs_call_name": "FormSet", "annotation": ""}, "snippet": " formset = cl.formset = FormSet(request.POST, request.FILES, queryset=cl.result_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1028_C12", "label": "if", "type": "if", "loc": [1028, 1051], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1024_C8", "vector": [4, 3, 0.8064, 0.0186, 3, 0.42, 0.6667, 0, 3, 0, 0, 0, 0, 0, 14], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if formset.is_valid():\n changecount = 0\n for form in formset.forms:\n if form.has_changed():\n obj = self.save_form(request, form, change=True)\n self.save_model(request, obj, form, change=True)\n form.save_m2m()\n change_msg = self.construct_change_message(request, form, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1029_C16", "label": "changecount =", "type": "assigned_variable", "loc": [1029, 1029], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1028_C12", "vector": [14, 4, 0.7983, 0.0008, 4, 0.25, 0.0, 895, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "changecount", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " changecount = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L1030_C16", "label": "for form", "type": "for", "loc": [1030, 1037], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1028_C12", "vector": [6, 4, 0.8018, 0.0062, 4, 0.25, 0.3333, 761, 7, 0, 0, 0, 0, 0, 6], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for form in formset.forms:\n if form.has_changed():\n obj = self.save_form(request, form, change=True)\n self.save_model(request, obj, form, change=True)\n form.save_m2m()\n change_msg = self.construct_change_message(request, form, None)\n self.log_change(request, obj, change_msg)\n changecount += 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1031_C20", "label": "if", "type": "if", "loc": [1031, 1037], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L1030_C16", "vector": [4, 5, 0.8022, 0.0054, 5, 0.07, 0.0, 0, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.has_changed():\n obj = self.save_form(request, form, change=True)\n self.save_model(request, obj, form, change=True)\n form.save_m2m()\n change_msg = self.construct_change_message(request, form, None)\n self.log_change(request, obj, change_msg)\n changecount += 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1032_C24", "label": "obj = save_form()", "type": "assigned_variable", "loc": [1032, 1032], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1031_C20", "vector": [14, 6, 0.8006, 0.0008, 6, 0.87, 0.0, 505, 3, 3, 0, 0, 72, 10, 1], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "save_form", "annotation": ""}, "snippet": " obj = self.save_form(request, form, change=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1033_C24", "label": "save_model()", "type": "expression", "loc": [1033, 1033], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1031_C20", "vector": [8, 6, 0.8014, 0.0008, 6, 0.87, 0.25, 231, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "save_model", "arg_names": [], "import_names": [], "rhs_call_name": "save_model", "annotation": ""}, "snippet": " self.save_model(request, obj, form, change=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1034_C24", "label": "save_m2m()", "type": "expression", "loc": [1034, 1034], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1031_C20", "vector": [8, 6, 0.8022, 0.0008, 6, 0.87, 0.5, 874, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save_m2m", "arg_names": [], "import_names": [], "rhs_call_name": "save_m2m", "annotation": ""}, "snippet": " form.save_m2m()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1035_C24", "label": "change_msg = construct_change_message()", "type": "assigned_variable", "loc": [1035, 1035], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1031_C20", "vector": [14, 6, 0.8029, 0.0008, 6, 0.87, 0.75, 57, 3, 3, 0, 0, 314, 10, 1], "semantic": {"name": "change_msg", "arg_names": [], "import_names": [], "rhs_call_name": "construct_change_message", "annotation": ""}, "snippet": " change_msg = self.construct_change_message(request, form, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1036_C24", "label": "log_change()", "type": "expression", "loc": [1036, 1036], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1031_C20", "vector": [8, 6, 0.8037, 0.0008, 6, 0.87, 1.0, 625, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "log_change", "arg_names": [], "import_names": [], "rhs_call_name": "log_change", "annotation": ""}, "snippet": " self.log_change(request, obj, change_msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1039_C16", "label": "if", "type": "if", "loc": [1039, 1049], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1028_C12", "vector": [4, 4, 0.8099, 0.0085, 4, 0.25, 0.6667, 0, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if changecount:\n if changecount == 1:\n name = force_unicode(opts.verbose_name)\n else:\n name = force_unicode(opts.verbose_name_plural)\n msg = ungettext(\"%(count)s %(name)s was changed successfully.\",\n \"%(count)s %(name)s were changed successfully.\",\n changecount) % {'count': changecount,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1040_C20", "label": "if", "type": "if", "loc": [1040, 1043], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1039_C16", "vector": [4, 5, 0.808, 0.0031, 5, 0.54, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if changecount == 1:\n name = force_unicode(opts.verbose_name)\n else:\n name = force_unicode(opts.verbose_name_plural)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1041_C24", "label": "name = force_unicode()", "type": "assigned_variable", "loc": [1041, 1041], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1040_C20", "vector": [14, 6, 0.8076, 0.0008, 6, 0.82, 0.0, 57, 3, 1, 0, 0, 870, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "force_unicode", "annotation": ""}, "snippet": " name = force_unicode(opts.verbose_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1043_C24", "label": "name = force_unicode()", "type": "assigned_variable", "loc": [1043, 1043], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1040_C20", "vector": [14, 6, 0.8092, 0.0008, 6, 0.82, 1.0, 57, 3, 1, 0, 0, 870, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "force_unicode", "annotation": ""}, "snippet": " name = force_unicode(opts.verbose_name_plural)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1044_C20", "label": "msg =", "type": "assigned_variable", "loc": [1044, 1048], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1039_C16", "vector": [14, 5, 0.8115, 0.0039, 5, 0.54, 0.5, 712, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " msg = ungettext(\"%(count)s %(name)s was changed successfully.\",\n \"%(count)s %(name)s were changed successfully.\",\n changecount) % {'count': changecount,\n 'name': name,\n 'obj': force_unicode(obj)}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1049_C20", "label": "message_user()", "type": "expression", "loc": [1049, 1049], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1039_C16", "vector": [8, 5, 0.8138, 0.0008, 5, 0.54, 1.0, 207, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1051_C16", "label": "return", "type": "return", "loc": [1051, 1051], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1028_C12", "vector": [13, 4, 0.8154, 0.0008, 4, 0.25, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(request.get_full_path())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1054_C8", "label": "if", "type": "if", "loc": [1054, 1056], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1024_C8", "vector": [4, 3, 0.8185, 0.0023, 3, 0.42, 1.0, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif self.list_editable:\n FormSet = self.get_changelist_formset(request)\n formset = cl.formset = FormSet(queryset=cl.result_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1055_C12", "label": "FormSet = get_changelist_formset()", "type": "assigned_variable", "loc": [1055, 1055], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1054_C8", "vector": [14, 4, 0.8185, 0.0008, 4, 0.95, 0.0, 477, 3, 1, 0, 0, 590, 10, 1], "semantic": {"name": "FormSet", "arg_names": [], "import_names": [], "rhs_call_name": "get_changelist_formset", "annotation": ""}, "snippet": " FormSet = self.get_changelist_formset(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1056_C12", "label": "formset = FormSet()", "type": "assigned_variable", "loc": [1056, 1056], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1054_C8", "vector": [14, 4, 0.8192, 0.0008, 4, 0.95, 1.0, 613, 3, 1, 0, 0, 477, 10, 1], "semantic": {"name": "formset", "arg_names": [], "import_names": [], "rhs_call_name": "FormSet", "annotation": ""}, "snippet": " formset = cl.formset = FormSet(queryset=cl.result_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1059_C8", "label": "if", "type": "if", "loc": [1059, 1062], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [4, 2, 0.8227, 0.0031, 2, 0.11, 0.7273, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if formset:\n media = self.media + formset.media\n else:\n media = self.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1060_C12", "label": "media =", "type": "assigned_variable", "loc": [1060, 1060], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1059_C8", "vector": [14, 3, 0.8223, 0.0008, 3, 0.85, 0.0, 317, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " media = self.media + formset.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1062_C12", "label": "media =", "type": "assigned_variable", "loc": [1062, 1062], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1059_C8", "vector": [14, 3, 0.8239, 0.0008, 3, 0.85, 1.0, 317, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " media = self.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1065_C8", "label": "if", "type": "if", "loc": [1065, 1069], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [4, 2, 0.8278, 0.0039, 2, 0.11, 0.7727, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if actions:\n action_form = self.action_form(auto_id=None)\n action_form.fields['action'].choices = self.get_action_choices(request)\n else:\n action_form = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1066_C12", "label": "action_form = action_form()", "type": "assigned_variable", "loc": [1066, 1066], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1065_C8", "vector": [14, 3, 0.827, 0.0008, 3, 0.92, 0.0, 971, 3, 1, 0, 0, 971, 10, 1], "semantic": {"name": "action_form", "arg_names": [], "import_names": [], "rhs_call_name": "action_form", "annotation": ""}, "snippet": " action_form = self.action_form(auto_id=None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1067_C12", "label": "action_form.fields['action'].choices = get_action_choices()", "type": "assigned_variable", "loc": [1067, 1067], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1065_C8", "vector": [14, 3, 0.8278, 0.0008, 3, 0.92, 0.5, 843, 3, 1, 0, 0, 778, 10, 1], "semantic": {"name": "action_form.fields['action'].choices", "arg_names": [], "import_names": [], "rhs_call_name": "get_action_choices", "annotation": ""}, "snippet": " action_form.fields['action'].choices = self.get_action_choices(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1069_C12", "label": "action_form =", "type": "assigned_variable", "loc": [1069, 1069], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1065_C8", "vector": [14, 3, 0.8293, 0.0008, 3, 0.92, 1.0, 971, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "action_form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " action_form = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1071_C8", "label": "selection_note_all = ungettext()", "type": "assigned_variable", "loc": [1071, 1072], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [14, 2, 0.8313, 0.0016, 2, 0.11, 0.8182, 849, 3, 3, 0, 0, 950, 10, 1], "semantic": {"name": "selection_note_all", "arg_names": [], "import_names": [], "rhs_call_name": "ungettext", "annotation": ""}, "snippet": " selection_note_all = ungettext('%(total_count)s selected',\n 'All %(total_count)s selected', cl.result_count)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1074_C8", "label": "context =", "type": "assigned_variable", "loc": [1074, 1089], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [14, 2, 0.839, 0.0124, 2, 0.11, 0.8636, 954, 0, 0, 0, 0, 0, 6, 4], "semantic": {"name": "context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context = {\n 'module_name': force_unicode(opts.verbose_name_plural),\n 'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},\n 'selection_note_all': selection_note_all % {'total_count': cl.result_count},\n 'title': cl.title,\n 'is_popup': cl.is_popup,\n 'cl': cl,\n 'media': media,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1090_C8", "label": "update()", "type": "expression", "loc": [1090, 1090], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [8, 2, 0.8456, 0.0008, 2, 0.11, 0.9091, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " context.update(extra_context or {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1091_C8", "label": "context_instance = RequestContext()", "type": "assigned_variable", "loc": [1091, 1091], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [14, 2, 0.8464, 0.0008, 2, 0.11, 0.9545, 723, 3, 2, 0, 0, 47, 10, 1], "semantic": {"name": "context_instance", "arg_names": [], "import_names": [], "rhs_call_name": "RequestContext", "annotation": ""}, "snippet": " context_instance = template.RequestContext(request, current_app=self.admin_site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1092_C8", "label": "return", "type": "return", "loc": [1092, 1096], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "vector": [13, 2, 0.8487, 0.0039, 2, 0.11, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(self.change_list_template or [\n 'admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()),\n 'admin/%s/change_list.html' % app_label,\n 'admin/change_list.html'\n ], context, context_instance=context_instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "label": "delete_view", "type": "function", "loc": [1100, 1149], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.8724, 0.0388, 1, 0.87, 0.9692, 800, 0, 4, 1, 0, 0, 0, 25], "semantic": {"name": "delete_view", "arg_names": ["self", "request", "object_id", "extra_context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def delete_view(self, request, object_id, extra_context=None):\n \"The 'delete' admin view for this model.\"\n opts = self.model._meta\n app_label = opts.app_label\n\n obj = self.get_object(request, unquote(object_id))\n\n if not self.has_delete_permission(request, obj):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1101_C8", "label": "expression", "type": "expression", "loc": [1101, 1101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [8, 2, 0.8542, 0.0008, 2, 0.09, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"The 'delete' admin view for this model.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1102_C8", "label": "opts =", "type": "assigned_variable", "loc": [1102, 1102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [14, 2, 0.8549, 0.0008, 2, 0.09, 0.0833, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = self.model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1103_C8", "label": "app_label =", "type": "assigned_variable", "loc": [1103, 1103], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [14, 2, 0.8557, 0.0008, 2, 0.09, 0.1667, 187, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "app_label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_label = opts.app_label"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1105_C8", "label": "obj = get_object()", "type": "assigned_variable", "loc": [1105, 1105], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [14, 2, 0.8573, 0.0008, 2, 0.09, 0.25, 505, 3, 2, 0, 0, 237, 10, 2], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "get_object", "annotation": ""}, "snippet": " obj = self.get_object(request, unquote(object_id))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1107_C8", "label": "if", "type": "if", "loc": [1107, 1108], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [4, 2, 0.8592, 0.0016, 2, 0.09, 0.3333, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.has_delete_permission(request, obj):\n raise PermissionDenied"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1110_C8", "label": "if", "type": "if", "loc": [1110, 1111], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [4, 2, 0.8615, 0.0016, 2, 0.09, 0.4167, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if obj is None:\n raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_unicode(opts.verbose_name), 'key': escape(object_id)})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1113_C8", "label": "using = db_for_write()", "type": "assigned_variable", "loc": [1113, 1113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [14, 2, 0.8635, 0.0008, 2, 0.09, 0.5, 699, 3, 1, 0, 0, 395, 10, 1], "semantic": {"name": "using", "arg_names": [], "import_names": [], "rhs_call_name": "db_for_write", "annotation": ""}, "snippet": " using = router.db_for_write(self.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1117_C8", "label": "deleted_objects, perms_needed = get_deleted_objects()", "type": "assigned_variable", "loc": [1117, 1118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [14, 2, 0.867, 0.0016, 2, 0.09, 0.5833, 607, 3, 5, 0, 0, 624, 10, 1], "semantic": {"name": "deleted_objects, perms_needed", "arg_names": [], "import_names": [], "rhs_call_name": "get_deleted_objects", "annotation": ""}, "snippet": " (deleted_objects, perms_needed) = get_deleted_objects(\n [obj], opts, request.user, self.admin_site, using)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "label": "if", "type": "if", "loc": [1120, 1131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [4, 2, 0.8732, 0.0093, 2, 0.09, 0.6667, 0, 7, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.POST: # The user has already confirmed the deletion.\n if perms_needed:\n raise PermissionDenied\n obj_display = force_unicode(obj)\n self.log_deletion(request, obj, obj_display)\n obj.delete()\n\n self.message_user(request, _('The %(name)s \"%(obj)s\" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1121_C12", "label": "if", "type": "if", "loc": [1121, 1122], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "vector": [4, 3, 0.8701, 0.0016, 3, 0.49, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if perms_needed:\n raise PermissionDenied"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1123_C12", "label": "obj_display = force_unicode()", "type": "assigned_variable", "loc": [1123, 1123], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "vector": [14, 3, 0.8712, 0.0008, 3, 0.49, 0.1667, 628, 3, 1, 0, 0, 870, 10, 1], "semantic": {"name": "obj_display", "arg_names": [], "import_names": [], "rhs_call_name": "force_unicode", "annotation": ""}, "snippet": " obj_display = force_unicode(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1124_C12", "label": "log_deletion()", "type": "expression", "loc": [1124, 1124], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "vector": [8, 3, 0.872, 0.0008, 3, 0.49, 0.3333, 271, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "log_deletion", "arg_names": [], "import_names": [], "rhs_call_name": "log_deletion", "annotation": ""}, "snippet": " self.log_deletion(request, obj, obj_display)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1125_C12", "label": "delete()", "type": "expression", "loc": [1125, 1125], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "vector": [8, 3, 0.8728, 0.0008, 3, 0.49, 0.5, 266, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " obj.delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1127_C12", "label": "message_user()", "type": "expression", "loc": [1127, 1127], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "vector": [8, 3, 0.8743, 0.0008, 3, 0.49, 0.6667, 207, 3, 2, 0, 0, 0, 0, 4], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " self.message_user(request, _('The %(name)s \"%(obj)s\" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1129_C12", "label": "if", "type": "if", "loc": [1129, 1130], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "vector": [4, 3, 0.8763, 0.0016, 3, 0.49, 0.8333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.has_change_permission(request, None):\n return HttpResponseRedirect(\"../../../../\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1130_C16", "label": "return", "type": "return", "loc": [1130, 1130], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1129_C12", "vector": [13, 4, 0.8766, 0.0008, 4, 0.32, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(\"../../../../\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1131_C12", "label": "return", "type": "return", "loc": [1131, 1131], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "vector": [13, 3, 0.8774, 0.0008, 3, 0.49, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponseRedirect(\"../../\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1133_C8", "label": "context =", "type": "assigned_variable", "loc": [1133, 1142], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [14, 2, 0.8825, 0.0078, 2, 0.09, 0.75, 954, 0, 0, 0, 0, 0, 6, 2], "semantic": {"name": "context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context = {\n \"title\": _(\"Are you sure?\"),\n \"object_name\": force_unicode(opts.verbose_name),\n \"object\": obj,\n \"deleted_objects\": deleted_objects,\n \"perms_lacking\": perms_needed,\n \"opts\": opts,\n \"root_path\": self.admin_site.root_path,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1143_C8", "label": "update()", "type": "expression", "loc": [1143, 1143], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [8, 2, 0.8867, 0.0008, 2, 0.09, 0.8333, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " context.update(extra_context or {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1144_C8", "label": "context_instance = RequestContext()", "type": "assigned_variable", "loc": [1144, 1144], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [14, 2, 0.8875, 0.0008, 2, 0.09, 0.9167, 723, 3, 2, 0, 0, 47, 10, 1], "semantic": {"name": "context_instance", "arg_names": [], "import_names": [], "rhs_call_name": "RequestContext", "annotation": ""}, "snippet": " context_instance = template.RequestContext(request, current_app=self.admin_site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1145_C8", "label": "return", "type": "return", "loc": [1145, 1149], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "vector": [13, 2, 0.8898, 0.0039, 2, 0.09, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(self.delete_confirmation_template or [\n \"admin/%s/%s/delete_confirmation.html\" % (app_label, opts.object_name.lower()),\n \"admin/%s/delete_confirmation.html\" % app_label,\n \"admin/delete_confirmation.html\"\n ], context, context_instance=context_instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "label": "history_view", "type": "function", "loc": [1151, 1177], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.903, 0.0209, 1, 0.87, 0.9846, 751, 0, 4, 1, 0, 0, 0, 14], "semantic": {"name": "history_view", "arg_names": ["self", "request", "object_id", "extra_context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def history_view(self, request, object_id, extra_context=None):\n \"The 'history' admin view for this model.\"\n from django.contrib.admin.models import LogEntry\n model = self.model\n opts = model._meta\n app_label = opts.app_label\n action_list = LogEntry.objects.filter(\n object_id = object_id,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1152_C8", "label": "expression", "type": "expression", "loc": [1152, 1152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "vector": [8, 2, 0.8937, 0.0008, 2, 0.51, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"The 'history' admin view for this model.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L1153_C8", "label": "from django.contrib.admin.models import LogEntry", "type": "import", "loc": [1153, 1153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "vector": [1, 2, 0.8945, 0.0008, 2, 0.51, 0.1, 408, 0, 1, 0, 0, 408, 0, 0], "semantic": {"name": "django.contrib.admin.models", "arg_names": [], "import_names": ["LogEntry"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.models import LogEntry"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1154_C8", "label": "model =", "type": "assigned_variable", "loc": [1154, 1154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "vector": [14, 2, 0.8953, 0.0008, 2, 0.51, 0.2, 722, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model = self.model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1155_C8", "label": "opts =", "type": "assigned_variable", "loc": [1155, 1155], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "vector": [14, 2, 0.896, 0.0008, 2, 0.51, 0.3, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1156_C8", "label": "app_label =", "type": "assigned_variable", "loc": [1156, 1156], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "vector": [14, 2, 0.8968, 0.0008, 2, 0.51, 0.4, 187, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "app_label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_label = opts.app_label"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1157_C8", "label": "action_list = order_by()", "type": "assigned_variable", "loc": [1157, 1160], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "vector": [14, 2, 0.8988, 0.0031, 2, 0.51, 0.5, 965, 3, 1, 0, 0, 23, 10, 4], "semantic": {"name": "action_list", "arg_names": [], "import_names": [], "rhs_call_name": "order_by", "annotation": ""}, "snippet": " action_list = LogEntry.objects.filter(\n object_id = object_id,\n content_type__id__exact = ContentType.objects.get_for_model(model).id\n ).select_related().order_by('action_time')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1162_C8", "label": "obj = get_object_or_404()", "type": "assigned_variable", "loc": [1162, 1162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "vector": [14, 2, 0.9015, 0.0008, 2, 0.51, 0.6, 505, 3, 2, 0, 0, 611, 10, 2], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "get_object_or_404", "annotation": ""}, "snippet": " obj = get_object_or_404(model, pk=unquote(object_id))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1163_C8", "label": "context =", "type": "assigned_variable", "loc": [1163, 1170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "vector": [14, 2, 0.905, 0.0062, 2, 0.51, 0.7, 954, 0, 0, 0, 0, 0, 6, 4], "semantic": {"name": "context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context = {\n 'title': _('Change history: %s') % force_unicode(obj),\n 'action_list': action_list,\n 'module_name': capfirst(force_unicode(opts.verbose_name_plural)),\n 'object': obj,\n 'root_path': self.admin_site.root_path,\n 'app_label': app_label,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1171_C8", "label": "update()", "type": "expression", "loc": [1171, 1171], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "vector": [8, 2, 0.9085, 0.0008, 2, 0.51, 0.8, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " context.update(extra_context or {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1172_C8", "label": "context_instance = RequestContext()", "type": "assigned_variable", "loc": [1172, 1172], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "vector": [14, 2, 0.9092, 0.0008, 2, 0.51, 0.9, 723, 3, 2, 0, 0, 47, 10, 1], "semantic": {"name": "context_instance", "arg_names": [], "import_names": [], "rhs_call_name": "RequestContext", "annotation": ""}, "snippet": " context_instance = template.RequestContext(request, current_app=self.admin_site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1173_C8", "label": "return", "type": "return", "loc": [1173, 1177], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "vector": [13, 2, 0.9116, 0.0039, 2, 0.51, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(self.object_history_template or [\n \"admin/%s/%s/object_history.html\" % (app_label, opts.object_name.lower()),\n \"admin/%s/object_history.html\" % app_label,\n \"admin/object_history.html\"\n ], context, context_instance=context_instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1182_C4", "label": "__call__", "type": "function", "loc": [1182, 1205], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "vector": [2, 1, 0.9259, 0.0186, 1, 0.87, 1.0, 319, 0, 3, 1, 0, 0, 0, 10], "semantic": {"name": "__call__", "arg_names": ["self", "request", "url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __call__(self, request, url):\n \"\"\"\n DEPRECATED: this is the old way of URL resolution, replaced by\n ``get_urls()``. This only called by AdminSite.root(), which is also\n deprecated.\n\n Again, remember that the following code only exists for\n backwards-compatibility. Any new URLs, changes to existing URLs, or"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1183_C8", "label": "expression", "type": "expression", "loc": [1183, 1194], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1182_C4", "vector": [8, 2, 0.922, 0.0093, 2, 0.26, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n DEPRECATED: this is the old way of URL resolution, replaced by\n ``get_urls()``. This only called by AdminSite.root(), which is also\n deprecated.\n\n Again, remember that the following code only exists for\n backwards-compatibility. Any new URLs, changes to existing URLs, or\n whatever need to be done up in get_urls(), above!"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1196_C8", "label": "if", "type": "if", "loc": [1196, 1205], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1182_C4", "vector": [4, 2, 0.9313, 0.0078, 2, 0.26, 1.0, 0, 0, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if url is None:\n return self.changelist_view(request)\n elif url == \"add\":\n return self.add_view(request)\n elif url.endswith('/history'):\n return self.history_view(request, unquote(url[:-8]))\n elif url.endswith('/delete'):\n return self.delete_view(request, unquote(url[:-7]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1197_C12", "label": "return", "type": "return", "loc": [1197, 1197], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1196_C8", "vector": [13, 3, 0.9286, 0.0008, 3, 0.0, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.changelist_view(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1198_C8", "label": "if", "type": "if", "loc": [1198, 1205], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1196_C8", "vector": [4, 3, 0.9321, 0.0062, 3, 0.0, 1.0, 0, 0, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif url == \"add\":\n return self.add_view(request)\n elif url.endswith('/history'):\n return self.history_view(request, unquote(url[:-8]))\n elif url.endswith('/delete'):\n return self.delete_view(request, unquote(url[:-7]))\n else:\n return self.change_view(request, unquote(url))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1199_C12", "label": "return", "type": "return", "loc": [1199, 1199], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1198_C8", "vector": [13, 4, 0.9302, 0.0008, 4, 0.74, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.add_view(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1200_C8", "label": "if", "type": "if", "loc": [1200, 1205], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1198_C8", "vector": [4, 4, 0.9329, 0.0047, 4, 0.74, 1.0, 0, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif url.endswith('/history'):\n return self.history_view(request, unquote(url[:-8]))\n elif url.endswith('/delete'):\n return self.delete_view(request, unquote(url[:-7]))\n else:\n return self.change_view(request, unquote(url))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1201_C12", "label": "return", "type": "return", "loc": [1201, 1201], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1200_C8", "vector": [13, 5, 0.9317, 0.0008, 5, 0.24, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.history_view(request, unquote(url[:-8]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1202_C8", "label": "if", "type": "if", "loc": [1202, 1205], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1200_C8", "vector": [4, 5, 0.9337, 0.0031, 5, 0.24, 1.0, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif url.endswith('/delete'):\n return self.delete_view(request, unquote(url[:-7]))\n else:\n return self.change_view(request, unquote(url))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1203_C12", "label": "return", "type": "return", "loc": [1203, 1203], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1202_C8", "vector": [13, 6, 0.9333, 0.0008, 6, 0.75, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.delete_view(request, unquote(url[:-7]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1205_C12", "label": "return", "type": "return", "loc": [1205, 1205], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1202_C8", "vector": [13, 6, 0.9348, 0.0008, 6, 0.75, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.change_view(request, unquote(url))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "label": "InlineModelAdmin", "type": "class", "loc": [1207, 1283], "level": 0, "parent": null, "vector": [3, 0, 0.9659, 0.0597, 0, 0.66, 0.9412, 289, 0, 5, 0, 0, 170, 0, 21], "semantic": {"name": "InlineModelAdmin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class InlineModelAdmin(BaseModelAdmin):\n \"\"\"\n Options for inline editing of ``model`` instances.\n\n Provide ``name`` to specify the attribute name of the ``ForeignKey`` from\n ``model`` to its parent. This is required if ``model`` has more than one\n ``ForeignKey`` to its parent.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1208_C4", "label": "expression", "type": "expression", "loc": [1208, 1214], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [8, 1, 0.9395, 0.0054, 1, 0.2, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Options for inline editing of ``model`` instances.\n\n Provide ``name`` to specify the attribute name of the ``ForeignKey`` from\n ``model`` to its parent. This is required if ``model`` has more than one\n ``ForeignKey`` to its parent.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1215_C4", "label": "model =", "type": "assigned_variable", "loc": [1215, 1215], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [14, 1, 0.9426, 0.0008, 1, 0.2, 0.0667, 722, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1216_C4", "label": "fk_name =", "type": "assigned_variable", "loc": [1216, 1216], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [14, 1, 0.9434, 0.0008, 1, 0.2, 0.1333, 297, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "fk_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fk_name = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1217_C4", "label": "formset =", "type": "assigned_variable", "loc": [1217, 1217], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [14, 1, 0.9441, 0.0008, 1, 0.2, 0.2, 613, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " formset = BaseInlineFormSet"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1218_C4", "label": "extra =", "type": "assigned_variable", "loc": [1218, 1218], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [14, 1, 0.9449, 0.0008, 1, 0.2, 0.2667, 980, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "extra", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " extra = 3"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1219_C4", "label": "max_num =", "type": "assigned_variable", "loc": [1219, 1219], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [14, 1, 0.9457, 0.0008, 1, 0.2, 0.3333, 607, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "max_num", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " max_num = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1220_C4", "label": "template =", "type": "assigned_variable", "loc": [1220, 1220], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [14, 1, 0.9465, 0.0008, 1, 0.2, 0.4, 549, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1221_C4", "label": "verbose_name =", "type": "assigned_variable", "loc": [1221, 1221], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [14, 1, 0.9472, 0.0008, 1, 0.2, 0.4667, 616, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "verbose_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " verbose_name = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1222_C4", "label": "verbose_name_plural =", "type": "assigned_variable", "loc": [1222, 1222], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [14, 1, 0.948, 0.0008, 1, 0.2, 0.5333, 329, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "verbose_name_plural", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " verbose_name_plural = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1223_C4", "label": "can_delete =", "type": "assigned_variable", "loc": [1223, 1223], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [14, 1, 0.9488, 0.0008, 1, 0.2, 0.6, 721, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "can_delete", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " can_delete = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "label": "__init__", "type": "function", "loc": [1225, 1233], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [2, 1, 0.9535, 0.007, 1, 0.2, 0.6667, 555, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "parent_model", "admin_site"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, parent_model, admin_site):\n self.admin_site = admin_site\n self.parent_model = parent_model\n self.opts = self.model._meta\n super(InlineModelAdmin, self).__init__()\n if self.verbose_name is None:\n self.verbose_name = self.model._meta.verbose_name\n if self.verbose_name_plural is None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1226_C8", "label": "self.admin_site =", "type": "assigned_variable", "loc": [1226, 1226], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "vector": [14, 2, 0.9511, 0.0008, 2, 0.29, 0.0, 905, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.admin_site", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.admin_site = admin_site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1227_C8", "label": "self.parent_model =", "type": "assigned_variable", "loc": [1227, 1227], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "vector": [14, 2, 0.9519, 0.0008, 2, 0.29, 0.2, 372, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.parent_model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.parent_model = parent_model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1228_C8", "label": "self.opts =", "type": "assigned_variable", "loc": [1228, 1228], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "vector": [14, 2, 0.9527, 0.0008, 2, 0.29, 0.4, 26, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.opts = self.model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1229_C8", "label": "__init__()", "type": "expression", "loc": [1229, 1229], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "vector": [8, 2, 0.9535, 0.0008, 2, 0.29, 0.6, 555, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(InlineModelAdmin, self).__init__()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1230_C8", "label": "if", "type": "if", "loc": [1230, 1231], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "vector": [4, 2, 0.9546, 0.0016, 2, 0.29, 0.8, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.verbose_name is None:\n self.verbose_name = self.model._meta.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1231_C12", "label": "self.verbose_name =", "type": "assigned_variable", "loc": [1231, 1231], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1230_C8", "vector": [14, 3, 0.955, 0.0008, 3, 0.91, 0.0, 45, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.verbose_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.verbose_name = self.model._meta.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1232_C8", "label": "if", "type": "if", "loc": [1232, 1233], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "vector": [4, 2, 0.9562, 0.0016, 2, 0.29, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.verbose_name_plural is None:\n self.verbose_name_plural = self.model._meta.verbose_name_plural"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1233_C12", "label": "self.verbose_name_plural =", "type": "assigned_variable", "loc": [1233, 1233], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1232_C8", "vector": [14, 3, 0.9566, 0.0008, 3, 0.2, 0.0, 966, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.verbose_name_plural", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.verbose_name_plural = self.model._meta.verbose_name_plural"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1235_C4", "label": "_media", "type": "function", "loc": [1235, 1243], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [2, 1, 0.9612, 0.007, 1, 0.2, 0.7333, 650, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "_media", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _media(self):\n from django.conf import settings\n js = ['js/jquery.min.js', 'js/jquery.init.js', 'js/inlines.min.js']\n if self.prepopulated_fields:\n js.append('js/urlify.js')\n js.append('js/prepopulate.min.js')\n if self.filter_vertical or self.filter_horizontal:\n js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L1236_C8", "label": "from django.conf import settings", "type": "import", "loc": [1236, 1236], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1235_C4", "vector": [1, 2, 0.9589, 0.0008, 2, 0.31, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1237_C8", "label": "js =", "type": "assigned_variable", "loc": [1237, 1237], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1235_C4", "vector": [14, 2, 0.9597, 0.0008, 2, 0.31, 0.25, 62, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "js", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " js = ['js/jquery.min.js', 'js/jquery.init.js', 'js/inlines.min.js']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1238_C8", "label": "if", "type": "if", "loc": [1238, 1240], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1235_C4", "vector": [4, 2, 0.9612, 0.0023, 2, 0.31, 0.5, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.prepopulated_fields:\n js.append('js/urlify.js')\n js.append('js/prepopulate.min.js')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1239_C12", "label": "append()", "type": "expression", "loc": [1239, 1239], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1238_C8", "vector": [8, 3, 0.9612, 0.0008, 3, 0.67, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " js.append('js/urlify.js')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1240_C12", "label": "append()", "type": "expression", "loc": [1240, 1240], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1238_C8", "vector": [8, 3, 0.962, 0.0008, 3, 0.67, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " js.append('js/prepopulate.min.js')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1241_C8", "label": "if", "type": "if", "loc": [1241, 1242], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1235_C4", "vector": [4, 2, 0.9631, 0.0016, 2, 0.31, 0.75, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.filter_vertical or self.filter_horizontal:\n js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1242_C12", "label": "extend()", "type": "expression", "loc": [1242, 1242], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1241_C8", "vector": [8, 3, 0.9635, 0.0008, 3, 0.73, 0.0, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1243_C8", "label": "return", "type": "return", "loc": [1243, 1243], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1235_C4", "vector": [13, 2, 0.9643, 0.0008, 2, 0.31, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1244_C4", "label": "media = property()", "type": "assigned_variable", "loc": [1244, 1244], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [14, 1, 0.9651, 0.0008, 1, 0.2, 0.8, 317, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " media = property(_media)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "label": "get_formset", "type": "function", "loc": [1246, 1273], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [2, 1, 0.9771, 0.0217, 1, 0.2, 0.8667, 405, 0, 4, 1, 0, 0, 0, 9], "semantic": {"name": "get_formset", "arg_names": ["self", "request", "obj", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_formset(self, request, obj=None, **kwargs):\n \"\"\"Returns a BaseInlineFormSet class for use in admin add/change views.\"\"\"\n if self.declared_fieldsets:\n fields = flatten_fieldsets(self.declared_fieldsets)\n else:\n fields = None\n if self.exclude is None:\n exclude = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1247_C8", "label": "expression", "type": "expression", "loc": [1247, 1247], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "vector": [8, 2, 0.9674, 0.0008, 2, 0.74, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Returns a BaseInlineFormSet class for use in admin add/change views.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1248_C8", "label": "if", "type": "if", "loc": [1248, 1251], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "vector": [4, 2, 0.9694, 0.0031, 2, 0.74, 0.125, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.declared_fieldsets:\n fields = flatten_fieldsets(self.declared_fieldsets)\n else:\n fields = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1249_C12", "label": "fields = flatten_fieldsets()", "type": "assigned_variable", "loc": [1249, 1249], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1248_C8", "vector": [14, 3, 0.969, 0.0008, 3, 0.36, 0.0, 358, 3, 1, 0, 0, 348, 10, 1], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "flatten_fieldsets", "annotation": ""}, "snippet": " fields = flatten_fieldsets(self.declared_fieldsets)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1251_C12", "label": "fields =", "type": "assigned_variable", "loc": [1251, 1251], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1248_C8", "vector": [14, 3, 0.9705, 0.0008, 3, 0.36, 1.0, 358, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fields = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1252_C8", "label": "if", "type": "if", "loc": [1252, 1255], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "vector": [4, 2, 0.9725, 0.0031, 2, 0.74, 0.25, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.exclude is None:\n exclude = []\n else:\n exclude = list(self.exclude)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1253_C12", "label": "exclude =", "type": "assigned_variable", "loc": [1253, 1253], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1252_C8", "vector": [14, 3, 0.9721, 0.0008, 3, 0.72, 0.0, 739, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "exclude", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " exclude = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1255_C12", "label": "exclude = list()", "type": "assigned_variable", "loc": [1255, 1255], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1252_C8", "vector": [14, 3, 0.9736, 0.0008, 3, 0.72, 1.0, 739, 3, 1, 0, 0, 430, 10, 1], "semantic": {"name": "exclude", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " exclude = list(self.exclude)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1256_C8", "label": "extend()", "type": "expression", "loc": [1256, 1256], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "vector": [8, 2, 0.9744, 0.0008, 2, 0.74, 0.375, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " exclude.extend(kwargs.get(\"exclude\", []))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1257_C8", "label": "extend()", "type": "expression", "loc": [1257, 1257], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "vector": [8, 2, 0.9752, 0.0008, 2, 0.74, 0.5, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " exclude.extend(self.get_readonly_fields(request, obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1260_C8", "label": "exclude =", "type": "assigned_variable", "loc": [1260, 1260], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "vector": [14, 2, 0.9775, 0.0008, 2, 0.74, 0.625, 739, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "exclude", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " exclude = exclude or None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1261_C8", "label": "defaults =", "type": "assigned_variable", "loc": [1261, 1271], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "vector": [14, 2, 0.9822, 0.0085, 2, 0.74, 0.75, 233, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "defaults", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults = {\n \"form\": self.form,\n \"formset\": self.formset,\n \"fk_name\": self.fk_name,\n \"fields\": fields,\n \"exclude\": exclude,\n \"formfield_callback\": curry(self.formfield_for_dbfield, request=request),\n \"extra\": self.extra,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1272_C8", "label": "update()", "type": "expression", "loc": [1272, 1272], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "vector": [8, 2, 0.9868, 0.0008, 2, 0.74, 0.875, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " defaults.update(kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1273_C8", "label": "return", "type": "return", "loc": [1273, 1273], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "vector": [13, 2, 0.9876, 0.0008, 2, 0.74, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return inlineformset_factory(self.parent_model, self.model, **defaults)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1275_C4", "label": "get_fieldsets", "type": "function", "loc": [1275, 1280], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [2, 1, 0.9911, 0.0047, 1, 0.2, 0.9333, 273, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "get_fieldsets", "arg_names": ["self", "request", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_fieldsets(self, request, obj=None):\n if self.declared_fieldsets:\n return self.declared_fieldsets\n form = self.get_formset(request).form\n fields = form.base_fields.keys() + list(self.get_readonly_fields(request, obj))\n return [(None, {'fields': fields})]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1276_C8", "label": "if", "type": "if", "loc": [1276, 1277], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1275_C4", "vector": [4, 2, 0.9903, 0.0016, 2, 0.56, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.declared_fieldsets:\n return self.declared_fieldsets"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1277_C12", "label": "return", "type": "return", "loc": [1277, 1277], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1276_C8", "vector": [13, 3, 0.9907, 0.0008, 3, 0.5, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.declared_fieldsets"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1278_C8", "label": "form =", "type": "assigned_variable", "loc": [1278, 1278], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1275_C4", "vector": [14, 2, 0.9915, 0.0008, 2, 0.56, 0.3333, 761, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " form = self.get_formset(request).form"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1279_C8", "label": "fields =", "type": "assigned_variable", "loc": [1279, 1279], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1275_C4", "vector": [14, 2, 0.9922, 0.0008, 2, 0.56, 0.6667, 358, 4, 0, 0, 0, 0, 0, 3], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fields = form.base_fields.keys() + list(self.get_readonly_fields(request, obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1280_C8", "label": "return", "type": "return", "loc": [1280, 1280], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1275_C4", "vector": [13, 2, 0.993, 0.0008, 2, 0.56, 1.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [(None, {'fields': fields})]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1282_C4", "label": "queryset", "type": "function", "loc": [1282, 1283], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "vector": [2, 1, 0.995, 0.0016, 1, 0.2, 1.0, 38, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "queryset", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def queryset(self, request):\n return self.model._default_manager.all()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1283_C8", "label": "return", "type": "return", "loc": [1283, 1283], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1282_C4", "vector": [13, 2, 0.9953, 0.0008, 2, 0.47, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.model._default_manager.all()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1285_C0", "label": "StackedInline", "type": "class", "loc": [1285, 1286], "level": 0, "parent": null, "vector": [3, 0, 0.9973, 0.0016, 0, 0.66, 0.9706, 763, 0, 0, 0, 0, 289, 0, 0], "semantic": {"name": "StackedInline", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class StackedInline(InlineModelAdmin):\n template = 'admin/edit_inline/stacked.html'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1286_C4", "label": "template =", "type": "assigned_variable", "loc": [1286, 1286], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1285_C0", "vector": [14, 1, 0.9977, 0.0008, 1, 0.24, 0.0, 549, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " template = 'admin/edit_inline/stacked.html'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1288_C0", "label": "TabularInline", "type": "class", "loc": [1288, 1289], "level": 0, "parent": null, "vector": [3, 0, 0.9996, 0.0016, 0, 0.66, 1.0, 837, 0, 0, 0, 0, 289, 0, 0], "semantic": {"name": "TabularInline", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TabularInline(InlineModelAdmin):\n template = 'admin/edit_inline/tabular.html'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1289_C4", "label": "template =", "type": "assigned_variable", "loc": [1289, 1289], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1288_C0", "vector": [14, 1, 1.0, 0.0008, 1, 0.23, 0.0, 549, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " template = 'admin/edit_inline/tabular.html'"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L57_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L60_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L61_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L62_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L64_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L65_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L66_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L68_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L71_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L83_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L87_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L88_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L91_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L96_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L96_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L97_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L91_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L100_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L100_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L101_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L100_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L102_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L102_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L103_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L91_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L109_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L109_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L110_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L109_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L112_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L109_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L114_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L91_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L118_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L122_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L122_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L123_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L123_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L124_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L123_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L125_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L130_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L130_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L130_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L135_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L135_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L137_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L137_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L138_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L135_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L141_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L142_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L130_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L146_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L148_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L148_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L149_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L148_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L152_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L148_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L153_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L153_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L154_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L153_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L155_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L155_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L156_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L155_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L159_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L148_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L161_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L163_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L163_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L164_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L163_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L169_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L169_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L170_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L163_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L171_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L163_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L173_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L173_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L174_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L173_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L175_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L173_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L176_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L176_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L177_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L163_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L179_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L181_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L181_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L182_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L182_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L183_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L182_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L184_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L184_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L185_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L181_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L186_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L187_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L189_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L189_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L190_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L193_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L195_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L196_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L197_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L198_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L199_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L200_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L201_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L202_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L203_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L204_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L205_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L206_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L209_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L210_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L211_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L212_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L213_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L214_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L217_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L218_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L219_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L220_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L221_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L224_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L225_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L226_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L227_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L228_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L228_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L229_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L228_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L230_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L231_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L231_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L232_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L233_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L233_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L234_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L234_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L235_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L235_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L236_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L238_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L240_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L240_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L241_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L240_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L243_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L243_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L244_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L244_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L245_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L243_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L246_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L240_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L248_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L240_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L250_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L240_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L267_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L269_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L269_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L270_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L271_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L274_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L276_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L278_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L278_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L279_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L280_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L280_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L281_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L280_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L282_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L283_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L283_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L284_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L286_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L287_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L289_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L289_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L290_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L289_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L291_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L289_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L292_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L294_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L294_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L295_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L294_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L302_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L294_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L303_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L305_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L305_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L306_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L305_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L313_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L305_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L314_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L316_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L316_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L317_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L316_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L322_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L328_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L328_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L329_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L328_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L333_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L328_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L335_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L328_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L336_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L336_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L337_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L328_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L338_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L340_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L340_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L341_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L340_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L342_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L342_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L343_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L340_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L344_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L340_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L345_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L340_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L346_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L349_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L353_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L353_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L354_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L353_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L356_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L357_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L357_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L358_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L357_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L360_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L361_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L362_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L365_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L366_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L372_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L348_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L373_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L375_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L375_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L376_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L375_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L379_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L375_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L380_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L382_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L383_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L388_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L389_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L390_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L390_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L391_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L390_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L392_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L390_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L394_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L396_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L396_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L397_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L396_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L400_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L396_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L403_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L396_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L404_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L406_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L406_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L407_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L406_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L411_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L406_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L414_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L406_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L415_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L419_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L419_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L420_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L420_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L421_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L423_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L423_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L424_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L423_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L429_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L423_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L430_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L438_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L438_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L439_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L438_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L444_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L438_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L445_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L454_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L454_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L455_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L454_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L461_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L454_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L462_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L470_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L470_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L471_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L470_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L474_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L475_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L476_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L479_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L485_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L485_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L486_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L488_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L491_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L491_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L492_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L491_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L493_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L497_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L497_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L498_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L497_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L500_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L497_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L502_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L505_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L509_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L510_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L478_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L515_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L517_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L517_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L518_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L517_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L522_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L517_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L523_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L523_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L524_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L523_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L525_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L517_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L526_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L528_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L528_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L529_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L528_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L535_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L535_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L536_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L535_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L537_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L535_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L542_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L542_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L543_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L542_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L547_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L547_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L548_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L547_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L550_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L528_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L552_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L552_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L553_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L552_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L555_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L528_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L556_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L559_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L562_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L563_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L563_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L564_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L566_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L566_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L567_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L567_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L568_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L568_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L569_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L567_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L572_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L572_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L573_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L567_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L577_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L577_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L578_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L581_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L558_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L582_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L584_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L584_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L585_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L584_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L589_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L591_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L591_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L592_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L591_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L596_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L598_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L598_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L599_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L598_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L602_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L604_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L604_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L605_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L604_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L608_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L611_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L612_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L613_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L614_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L630_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L630_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L631_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L630_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L633_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L634_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L610_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L635_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L642_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L645_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L646_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L648_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L651_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L651_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L652_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L651_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L653_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L651_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L655_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L641_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L657_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L657_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L658_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L657_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L661_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L661_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L662_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L661_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L663_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L661_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L665_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L661_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L670_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L670_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L671_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L670_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L673_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L661_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L674_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L676_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L676_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L677_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L676_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L680_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L676_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L681_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L676_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L683_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L676_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L684_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L684_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L685_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L684_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L686_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L686_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L687_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L686_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L689_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L684_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L690_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L690_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L691_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L690_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L692_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L690_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L693_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L690_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L694_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L694_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L695_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L694_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L696_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L694_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L698_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L694_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L699_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L702_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L711_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L711_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L712_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L711_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L714_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L717_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L718_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L719_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L722_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L722_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L723_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L730_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L731_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L701_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L735_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L736_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L737_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L742_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L743_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L743_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L745_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L743_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L747_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L743_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L748_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L750_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L750_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L752_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L754_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L759_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L759_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L760_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L759_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L762_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L764_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L765_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L734_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L766_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L771_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L772_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L773_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L775_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L778_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L779_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L781_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L782_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L782_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L783_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L782_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L784_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L782_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L786_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L782_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L787_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L788_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L789_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L789_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L790_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L789_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L791_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L789_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L792_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L792_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L793_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L789_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L794_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L789_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L798_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L799_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L799_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L800_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L799_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L801_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L799_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L802_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L802_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L803_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L799_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L805_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L799_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L806_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L810_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L811_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L811_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L812_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L812_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L813_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L811_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L816_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L816_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L817_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L818_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L819_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L780_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L820_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L820_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L822_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L820_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L823_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L820_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L824_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L824_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L825_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L820_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L826_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L820_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L828_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L830_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L833_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L835_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L836_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L836_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L837_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L836_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L838_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L836_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L839_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L836_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L841_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L836_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L842_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L844_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L855_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L770_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L856_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L861_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L862_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L863_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L865_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L867_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L870_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L873_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L873_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L874_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L876_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L877_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L879_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L880_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L880_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L881_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L880_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L882_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L880_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L884_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L880_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L885_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L886_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L887_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L887_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L889_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L887_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L890_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L887_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L891_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L891_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L892_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L887_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L893_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L887_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L897_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L900_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L901_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L902_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L902_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L903_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L905_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L906_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L899_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L907_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L910_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L911_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L878_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L912_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L912_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L913_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L912_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L914_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L912_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L915_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L915_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L916_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L912_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L917_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L912_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L919_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L921_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L924_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L926_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L927_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L927_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L928_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L927_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L929_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L927_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L930_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L927_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L932_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L927_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L933_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L935_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L947_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L860_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L948_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L952_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L953_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L954_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L955_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L956_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L960_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L963_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L964_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L964_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L965_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L965_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L966_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L970_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L971_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L971_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L972_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L971_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L981_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L981_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L982_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:Try_L971_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L983_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L989_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L990_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L993_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L993_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L995_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L995_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L996_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L995_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L997_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L997_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L998_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L997_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1000_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L995_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1002_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L995_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1004_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L995_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1005_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1008_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1008_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1011_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1011_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1012_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1011_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1013_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1013_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1014_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1013_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1016_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1021_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1024_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1024_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1026_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1024_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1027_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1024_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1028_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1028_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1029_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1028_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L1030_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:For_L1030_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1031_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1031_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1032_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1031_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1033_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1031_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1034_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1031_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1035_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1031_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1036_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1028_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1039_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1039_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1040_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1040_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1041_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1040_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1043_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1039_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1044_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1039_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1049_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1028_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1051_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1024_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1054_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1054_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1055_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1054_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1056_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1059_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1059_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1060_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1059_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1062_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1065_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1065_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1066_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1065_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1067_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1065_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1069_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1071_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1074_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1090_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1091_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L951_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1092_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1102_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1103_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1105_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1117_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1121_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1123_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1124_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1125_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1127_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1129_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1129_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1130_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1120_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1131_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1143_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1144_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1145_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1152_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L1153_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1155_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1157_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1171_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1172_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1173_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L192_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1182_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1182_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1183_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1182_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1197_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1198_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1198_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1199_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1198_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1200_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1200_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1201_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1200_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1202_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1202_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1203_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1202_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1205_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1208_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1215_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1216_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1217_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1218_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1219_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1220_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1221_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1222_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1223_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1226_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1227_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1228_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1229_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1230_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1230_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1231_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1225_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1232_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1232_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1233_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1235_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1235_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:ImportFrom_L1236_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1235_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1237_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1235_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1238_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1238_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1239_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1238_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1240_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1235_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1241_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1241_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1242_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1235_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1243_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1244_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1247_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1248_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1248_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1249_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1248_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1251_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1252_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1252_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1253_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1252_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1255_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1256_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1257_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1260_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1261_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Expr_L1272_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1273_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1275_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1275_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1276_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:If_L1276_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1277_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1275_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1278_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1275_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1279_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1275_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1280_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1282_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:FunctionDef_L1282_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Return_L1283_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1285_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1286_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98650:ClassDef_L1288_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98650:Assign_L1289_C4"}] |
import re
from django import http, template
from django.contrib.admin import ModelAdmin
from django.contrib.admin import actions
from django.contrib.auth import authenticate, login
from django.views.decorators.csrf import csrf_protect
from django.db.models.base import ModelBase
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django.shortcuts import render_to_response
from django.utils.functional import update_wrapper
from django.utils.safestring import mark_safe
from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy, ugettext as _
from django.views.decorators.cache import never_cache
from django.conf import settings
ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.")
LOGIN_FORM_KEY = 'this_is_the_login_form'
class AlreadyRegistered(Exception):
pass
class NotRegistered(Exception):
pass
class AdminSite(object):
"""
An AdminSite object encapsulates an instance of the Django admin application, ready
to be hooked in to your URLconf. Models are registered with the AdminSite using the
register() method, and the get_urls() method can then be used to access Django view
functions that present a full admin interface for the collection of registered
models.
"""
index_template = None
app_index_template = None
login_template = None
logout_template = None
password_change_template = None
password_change_done_template = None
def __init__(self, name=None, app_name='admin'):
self._registry = {} # model_class class -> admin_class instance
self.root_path = None
if name is None:
self.name = 'admin'
else:
self.name = name
self.app_name = app_name
self._actions = {'delete_selected': actions.delete_selected}
self._global_actions = self._actions.copy()
def register(self, model_or_iterable, admin_class=None, **options):
"""
Registers the given model(s) with the given admin class.
The model(s) should be Model classes, not instances.
If an admin class isn't given, it will use ModelAdmin (the default
admin options). If keyword arguments are given -- e.g., list_display --
they'll be applied as options to the admin class.
If a model is already registered, this will raise AlreadyRegistered.
"""
if not admin_class:
admin_class = ModelAdmin
# Don't import the humongous validation code unless required
if admin_class and settings.DEBUG:
from django.contrib.admin.validation import validate
else:
validate = lambda model, adminclass: None
if isinstance(model_or_iterable, ModelBase):
model_or_iterable = [model_or_iterable]
for model in model_or_iterable:
if model in self._registry:
raise AlreadyRegistered('The model %s is already registered' % model.__name__)
# If we got **options then dynamically construct a subclass of
# admin_class with those **options.
if options:
# For reasons I don't quite understand, without a __module__
# the created class appears to "live" in the wrong place,
# which causes issues later on.
options['__module__'] = __name__
admin_class = type("%sAdmin" % model.__name__, (admin_class,), options)
# Validate (which might be a no-op)
validate(admin_class, model)
# Instantiate the admin class to save in the registry
self._registry[model] = admin_class(model, self)
def unregister(self, model_or_iterable):
"""
Unregisters the given model(s).
If a model isn't already registered, this will raise NotRegistered.
"""
if isinstance(model_or_iterable, ModelBase):
model_or_iterable = [model_or_iterable]
for model in model_or_iterable:
if model not in self._registry:
raise NotRegistered('The model %s is not registered' % model.__name__)
del self._registry[model]
def add_action(self, action, name=None):
"""
Register an action to be available globally.
"""
name = name or action.__name__
self._actions[name] = action
self._global_actions[name] = action
def disable_action(self, name):
"""
Disable a globally-registered action. Raises KeyError for invalid names.
"""
del self._actions[name]
def get_action(self, name):
"""
Explicitally get a registered global action wheather it's enabled or
not. Raises KeyError for invalid names.
"""
return self._global_actions[name]
def actions(self):
"""
Get all the enabled actions as an iterable of (name, func).
"""
return self._actions.iteritems()
actions = property(actions)
def has_permission(self, request):
"""
Returns True if the given HttpRequest has permission to view
*at least one* page in the admin site.
"""
return request.user.is_active and request.user.is_staff
def check_dependencies(self):
"""
Check that all things needed to run the admin have been correctly installed.
The default implementation checks that LogEntry, ContentType and the
auth context processor are installed.
"""
from django.contrib.admin.models import LogEntry
from django.contrib.contenttypes.models import ContentType
if not LogEntry._meta.installed:
raise ImproperlyConfigured("Put 'django.contrib.admin' in your "
"INSTALLED_APPS setting in order to use the admin application.")
if not ContentType._meta.installed:
raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in "
"your INSTALLED_APPS setting in order to use the admin application.")
if not ('django.contrib.auth.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS or
'django.core.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS):
raise ImproperlyConfigured("Put 'django.contrib.auth.context_processors.auth' "
"in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.")
def admin_view(self, view, cacheable=False):
"""
Decorator to create an admin view attached to this ``AdminSite``. This
wraps the view and provides permission checking by calling
``self.has_permission``.
You'll want to use this from within ``AdminSite.get_urls()``:
class MyAdminSite(AdminSite):
def get_urls(self):
from django.conf.urls.defaults import patterns, url
urls = super(MyAdminSite, self).get_urls()
urls += patterns('',
url(r'^my_view/$', self.admin_view(some_view))
)
return urls
By default, admin_views are marked non-cacheable using the
``never_cache`` decorator. If the view can be safely cached, set
cacheable=True.
"""
def inner(request, *args, **kwargs):
if not self.has_permission(request):
return self.login(request)
return view(request, *args, **kwargs)
if not cacheable:
inner = never_cache(inner)
# We add csrf_protect here so this function can be used as a utility
# function for any view, without having to repeat 'csrf_protect'.
if not getattr(view, 'csrf_exempt', False):
inner = csrf_protect(inner)
return update_wrapper(inner, view)
def get_urls(self):
from django.conf.urls.defaults import patterns, url, include
if settings.DEBUG:
self.check_dependencies()
def wrap(view, cacheable=False):
def wrapper(*args, **kwargs):
return self.admin_view(view, cacheable)(*args, **kwargs)
return update_wrapper(wrapper, view)
# Admin-site-wide views.
urlpatterns = patterns('',
url(r'^$',
wrap(self.index),
name='index'),
url(r'^logout/$',
wrap(self.logout),
name='logout'),
url(r'^password_change/$',
wrap(self.password_change, cacheable=True),
name='password_change'),
url(r'^password_change/done/$',
wrap(self.password_change_done, cacheable=True),
name='password_change_done'),
url(r'^jsi18n/$',
wrap(self.i18n_javascript, cacheable=True),
name='jsi18n'),
url(r'^r/(?P<content_type_id>\d+)/(?P<object_id>.+)/$',
'django.views.defaults.shortcut'),
url(r'^(?P<app_label>\w+)/$',
wrap(self.app_index),
name='app_list')
)
# Add in each model's views.
for model, model_admin in self._registry.iteritems():
urlpatterns += patterns('',
url(r'^%s/%s/' % (model._meta.app_label, model._meta.module_name),
include(model_admin.urls))
)
return urlpatterns
def urls(self):
return self.get_urls(), self.app_name, self.name
urls = property(urls)
def password_change(self, request):
"""
Handles the "change password" task -- both form display and validation.
"""
from django.contrib.auth.views import password_change
if self.root_path is not None:
url = '%spassword_change/done/' % self.root_path
else:
url = reverse('admin:password_change_done', current_app=self.name)
defaults = {
'post_change_redirect': url
}
if self.password_change_template is not None:
defaults['template_name'] = self.password_change_template
return password_change(request, **defaults)
def password_change_done(self, request):
"""
Displays the "success" page after a password change.
"""
from django.contrib.auth.views import password_change_done
defaults = {}
if self.password_change_done_template is not None:
defaults['template_name'] = self.password_change_done_template
return password_change_done(request, **defaults)
def i18n_javascript(self, request):
"""
Displays the i18n JavaScript that the Django admin requires.
This takes into account the USE_I18N setting. If it's set to False, the
generated JavaScript will be leaner and faster.
"""
if settings.USE_I18N:
from django.views.i18n import javascript_catalog
else:
from django.views.i18n import null_javascript_catalog as javascript_catalog
return javascript_catalog(request, packages='django.conf')
def logout(self, request):
"""
Logs out the user for the given HttpRequest.
This should *not* assume the user is already logged in.
"""
from django.contrib.auth.views import logout
defaults = {}
if self.logout_template is not None:
defaults['template_name'] = self.logout_template
return logout(request, **defaults)
logout = never_cache(logout)
def login(self, request):
"""
Displays the login form for the given HttpRequest.
"""
from django.contrib.auth.models import User
# If this isn't already the login page, display it.
if LOGIN_FORM_KEY not in request.POST:
if request.POST:
message = _("Please log in again, because your session has expired.")
else:
message = ""
return self.display_login_form(request, message)
# Check that the user accepts cookies.
if not request.session.test_cookie_worked():
message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.")
return self.display_login_form(request, message)
else:
request.session.delete_test_cookie()
# Check the password.
username = request.POST.get('username', None)
password = request.POST.get('password', None)
user = authenticate(username=username, password=password)
if user is None:
message = ERROR_MESSAGE
if username is not None and u'@' in username:
# Mistakenly entered e-mail address instead of username? Look it up.
try:
user = User.objects.get(email=username)
except (User.DoesNotExist, User.MultipleObjectsReturned):
message = _("Usernames cannot contain the '@' character.")
else:
if user.check_password(password):
message = _("Your e-mail address is not your username."
" Try '%s' instead.") % user.username
else:
message = _("Usernames cannot contain the '@' character.")
return self.display_login_form(request, message)
# The user data is correct; log in the user in and continue.
else:
if user.is_active and user.is_staff:
login(request, user)
return http.HttpResponseRedirect(request.get_full_path())
else:
return self.display_login_form(request, ERROR_MESSAGE)
login = never_cache(login)
def index(self, request, extra_context=None):
"""
Displays the main admin index page, which lists all of the installed
apps that have been registered in this site.
"""
app_dict = {}
user = request.user
for model, model_admin in self._registry.items():
app_label = model._meta.app_label
has_module_perms = user.has_module_perms(app_label)
if has_module_perms:
perms = model_admin.get_model_perms(request)
# Check whether user has any perm for this module.
# If so, add the module to the model_list.
if True in perms.values():
model_dict = {
'name': capfirst(model._meta.verbose_name_plural),
'admin_url': mark_safe('%s/%s/' % (app_label, model.__name__.lower())),
'perms': perms,
}
if app_label in app_dict:
app_dict[app_label]['models'].append(model_dict)
else:
app_dict[app_label] = {
'name': app_label.title(),
'app_url': app_label + '/',
'has_module_perms': has_module_perms,
'models': [model_dict],
}
# Sort the apps alphabetically.
app_list = app_dict.values()
app_list.sort(key=lambda x: x['name'])
# Sort the models alphabetically within each app.
for app in app_list:
app['models'].sort(key=lambda x: x['name'])
context = {
'title': _('Site administration'),
'app_list': app_list,
'root_path': self.root_path,
}
context.update(extra_context or {})
context_instance = template.RequestContext(request, current_app=self.name)
return render_to_response(self.index_template or 'admin/index.html', context,
context_instance=context_instance
)
index = never_cache(index)
def display_login_form(self, request, error_message='', extra_context=None):
request.session.set_test_cookie()
context = {
'title': _('Log in'),
'app_path': request.get_full_path(),
'error_message': error_message,
'root_path': self.root_path,
}
context.update(extra_context or {})
context_instance = template.RequestContext(request, current_app=self.name)
return render_to_response(self.login_template or 'admin/login.html', context,
context_instance=context_instance
)
def app_index(self, request, app_label, extra_context=None):
user = request.user
has_module_perms = user.has_module_perms(app_label)
app_dict = {}
for model, model_admin in self._registry.items():
if app_label == model._meta.app_label:
if has_module_perms:
perms = model_admin.get_model_perms(request)
# Check whether user has any perm for this module.
# If so, add the module to the model_list.
if True in perms.values():
model_dict = {
'name': capfirst(model._meta.verbose_name_plural),
'admin_url': '%s/' % model.__name__.lower(),
'perms': perms,
}
if app_dict:
app_dict['models'].append(model_dict),
else:
# First time around, now that we know there's
# something to display, add in the necessary meta
# information.
app_dict = {
'name': app_label.title(),
'app_url': '',
'has_module_perms': has_module_perms,
'models': [model_dict],
}
if not app_dict:
raise http.Http404('The requested admin page does not exist.')
# Sort the models alphabetically within each app.
app_dict['models'].sort(key=lambda x: x['name'])
context = {
'title': _('%s administration') % capfirst(app_label),
'app_list': [app_dict],
'root_path': self.root_path,
}
context.update(extra_context or {})
context_instance = template.RequestContext(request, current_app=self.name)
return render_to_response(self.app_index_template or ('admin/%s/app_index.html' % app_label,
'admin/app_index.html'), context,
context_instance=context_instance
)
# This global object represents the default admin site, for the common case.
# You can instantiate AdminSite in your own code to create a custom admin site.
site = AdminSite()
| ajibawa-2023/Python-Code-Large/train/row_98651 | 218 | 462 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Import_L1_C0", "label": "re import re", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0022, 0.0022, 0, 0.66, 0.0, 540, 0, 1, 0, 0, 540, 0, 0], "semantic": {"name": "re", "arg_names": [], "import_names": ["re"], "rhs_call_name": "", "annotation": ""}, "snippet": "import re"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L2_C0", "label": "from django import http, template", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0043, 0.0022, 0, 0.66, 0.0476, 294, 0, 2, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["http", "template"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django import http, template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L3_C0", "label": "from django.contrib.admin import ModelAdmin", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0065, 0.0022, 0, 0.66, 0.0952, 703, 0, 1, 0, 0, 703, 0, 0], "semantic": {"name": "django.contrib.admin", "arg_names": [], "import_names": ["ModelAdmin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin import ModelAdmin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L4_C0", "label": "from django.contrib.admin import actions", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0087, 0.0022, 0, 0.66, 0.1429, 703, 0, 1, 0, 0, 703, 0, 0], "semantic": {"name": "django.contrib.admin", "arg_names": [], "import_names": ["actions"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin import actions"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L5_C0", "label": "from django.contrib.auth import authenticate, login", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0108, 0.0022, 0, 0.66, 0.1905, 895, 0, 2, 0, 0, 895, 0, 0], "semantic": {"name": "django.contrib.auth", "arg_names": [], "import_names": ["authenticate", "login"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.auth import authenticate, login"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L6_C0", "label": "from django.views.decorators.csrf import csrf_protect", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.013, 0.0022, 0, 0.66, 0.2381, 456, 0, 1, 0, 0, 456, 0, 0], "semantic": {"name": "django.views.decorators.csrf", "arg_names": [], "import_names": ["csrf_protect"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.views.decorators.csrf import csrf_protect"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L7_C0", "label": "from django.db.models.base import ModelBase", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0152, 0.0022, 0, 0.66, 0.2857, 465, 0, 1, 0, 0, 465, 0, 0], "semantic": {"name": "django.db.models.base", "arg_names": [], "import_names": ["ModelBase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models.base import ModelBase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L8_C0", "label": "from django.core.exceptions import ImproperlyConfigured", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0173, 0.0022, 0, 0.66, 0.3333, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["ImproperlyConfigured"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import ImproperlyConfigured"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L9_C0", "label": "from django.core.urlresolvers import reverse", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0195, 0.0022, 0, 0.66, 0.381, 749, 0, 1, 0, 0, 749, 0, 0], "semantic": {"name": "django.core.urlresolvers", "arg_names": [], "import_names": ["reverse"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.urlresolvers import reverse"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L10_C0", "label": "from django.shortcuts import render_to_response", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0216, 0.0022, 0, 0.66, 0.4286, 852, 0, 1, 0, 0, 852, 0, 0], "semantic": {"name": "django.shortcuts", "arg_names": [], "import_names": ["render_to_response"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.shortcuts import render_to_response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L11_C0", "label": "from django.utils.functional import update_wrapper", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0238, 0.0022, 0, 0.66, 0.4762, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.functional", "arg_names": [], "import_names": ["update_wrapper"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.functional import update_wrapper"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L12_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.026, 0.0022, 0, 0.66, 0.5238, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.safestring", "arg_names": [], "import_names": ["mark_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.safestring import mark_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L13_C0", "label": "from django.utils.text import capfirst", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0281, 0.0022, 0, 0.66, 0.5714, 590, 0, 1, 0, 0, 590, 0, 0], "semantic": {"name": "django.utils.text", "arg_names": [], "import_names": ["capfirst"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.text import capfirst"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L14_C0", "label": "from django.utils.translation import ugettext_lazy, _", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.0303, 0.0022, 0, 0.66, 0.619, 389, 0, 2, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["ugettext_lazy", "_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext_lazy, ugettext as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L15_C0", "label": "from django.views.decorators.cache import never_cache", "type": "import", "loc": [15, 15], "level": 0, "parent": null, "vector": [1, 0, 0.0325, 0.0022, 0, 0.66, 0.6667, 305, 0, 1, 0, 0, 305, 0, 0], "semantic": {"name": "django.views.decorators.cache", "arg_names": [], "import_names": ["never_cache"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.views.decorators.cache import never_cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L16_C0", "label": "from django.conf import settings", "type": "import", "loc": [16, 16], "level": 0, "parent": null, "vector": [1, 0, 0.0346, 0.0022, 0, 0.66, 0.7143, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L18_C0", "label": "ERROR_MESSAGE = ugettext_lazy()", "type": "assigned_variable", "loc": [18, 18], "level": 0, "parent": null, "vector": [14, 0, 0.039, 0.0022, 0, 0.66, 0.7619, 310, 3, 1, 0, 0, 532, 10, 1], "semantic": {"name": "ERROR_MESSAGE", "arg_names": [], "import_names": [], "rhs_call_name": "ugettext_lazy", "annotation": ""}, "snippet": "ERROR_MESSAGE = ugettext_lazy(\"Please enter a correct username and password. Note that both fields are case-sensitive.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L19_C0", "label": "LOGIN_FORM_KEY =", "type": "assigned_variable", "loc": [19, 19], "level": 0, "parent": null, "vector": [14, 0, 0.0411, 0.0022, 0, 0.66, 0.8095, 993, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "LOGIN_FORM_KEY", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "LOGIN_FORM_KEY = 'this_is_the_login_form'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L21_C0", "label": "AlreadyRegistered", "type": "class", "loc": [21, 22], "level": 0, "parent": null, "vector": [3, 0, 0.0465, 0.0043, 0, 0.66, 0.8571, 602, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "AlreadyRegistered", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AlreadyRegistered(Exception):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L24_C0", "label": "NotRegistered", "type": "class", "loc": [24, 25], "level": 0, "parent": null, "vector": [3, 0, 0.053, 0.0043, 0, 0.66, 0.9048, 943, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "NotRegistered", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class NotRegistered(Exception):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "label": "AdminSite", "type": "class", "loc": [27, 458], "level": 0, "parent": null, "vector": [3, 0, 0.5249, 0.9351, 0, 0.66, 0.9524, 938, 0, 23, 0, 0, 186, 0, 99], "semantic": {"name": "AdminSite", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminSite(object):\n \"\"\"\n An AdminSite object encapsulates an instance of the Django admin application, ready\n to be hooked in to your URLconf. Models are registered with the AdminSite using the\n register() method, and the get_urls() method can then be used to access Django view\n functions that present a full admin interface for the collection of registered\n models.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L28_C4", "label": "expression", "type": "expression", "loc": [28, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [8, 1, 0.0671, 0.0152, 1, 0.89, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n An AdminSite object encapsulates an instance of the Django admin application, ready\n to be hooked in to your URLconf. Models are registered with the AdminSite using the\n register() method, and the get_urls() method can then be used to access Django view\n functions that present a full admin interface for the collection of registered\n models.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L36_C4", "label": "index_template =", "type": "assigned_variable", "loc": [36, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [14, 1, 0.0779, 0.0022, 1, 0.89, 0.0323, 189, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "index_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " index_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L37_C4", "label": "app_index_template =", "type": "assigned_variable", "loc": [37, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [14, 1, 0.0801, 0.0022, 1, 0.89, 0.0645, 883, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "app_index_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_index_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L38_C4", "label": "login_template =", "type": "assigned_variable", "loc": [38, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [14, 1, 0.0823, 0.0022, 1, 0.89, 0.0968, 847, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "login_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " login_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L39_C4", "label": "logout_template =", "type": "assigned_variable", "loc": [39, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [14, 1, 0.0844, 0.0022, 1, 0.89, 0.129, 727, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "logout_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " logout_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L40_C4", "label": "password_change_template =", "type": "assigned_variable", "loc": [40, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [14, 1, 0.0866, 0.0022, 1, 0.89, 0.1613, 8, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "password_change_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " password_change_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L41_C4", "label": "password_change_done_template =", "type": "assigned_variable", "loc": [41, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [14, 1, 0.0887, 0.0022, 1, 0.89, 0.1935, 267, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "password_change_done_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " password_change_done_template = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "label": "__init__", "type": "function", "loc": [43, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.1028, 0.0216, 1, 0.89, 0.2258, 555, 0, 3, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "name", "app_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, name=None, app_name='admin'):\n self._registry = {} # model_class class -> admin_class instance\n self.root_path = None\n if name is None:\n self.name = 'admin'\n else:\n self.name = name\n self.app_name = app_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L44_C8", "label": "self._registry =", "type": "assigned_variable", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "vector": [14, 2, 0.0952, 0.0022, 2, 0.04, 0.0, 394, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "self._registry", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._registry = {} # model_class class -> admin_class instance"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L45_C8", "label": "self.root_path =", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "vector": [14, 2, 0.0974, 0.0022, 2, 0.04, 0.2, 427, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "self.root_path", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.root_path = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L46_C8", "label": "if", "type": "if", "loc": [46, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "vector": [4, 2, 0.1028, 0.0087, 2, 0.04, 0.4, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if name is None:\n self.name = 'admin'\n else:\n self.name = name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L47_C12", "label": "self.name =", "type": "assigned_variable", "loc": [47, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L46_C8", "vector": [14, 3, 0.1017, 0.0022, 3, 0.32, 0.0, 689, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "self.name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.name = 'admin'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L49_C12", "label": "self.name =", "type": "assigned_variable", "loc": [49, 49], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L46_C8", "vector": [14, 3, 0.1061, 0.0022, 3, 0.32, 1.0, 689, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.name = name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L50_C8", "label": "self.app_name =", "type": "assigned_variable", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "vector": [14, 2, 0.1082, 0.0022, 2, 0.04, 0.6, 911, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.app_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.app_name = app_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L51_C8", "label": "self._actions =", "type": "assigned_variable", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "vector": [14, 2, 0.1104, 0.0022, 2, 0.04, 0.8, 868, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "self._actions", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._actions = {'delete_selected': actions.delete_selected}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L52_C8", "label": "self._global_actions = copy()", "type": "assigned_variable", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "vector": [14, 2, 0.1126, 0.0022, 2, 0.04, 1.0, 727, 3, 0, 0, 0, 739, 10, 1], "semantic": {"name": "self._global_actions", "arg_names": [], "import_names": [], "rhs_call_name": "copy", "annotation": ""}, "snippet": " self._global_actions = self._actions.copy()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L54_C4", "label": "register", "type": "function", "loc": [54, 94], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.1602, 0.0887, 1, 0.89, 0.2581, 276, 0, 4, 0, 0, 0, 0, 5], "semantic": {"name": "register", "arg_names": ["self", "model_or_iterable", "admin_class", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def register(self, model_or_iterable, admin_class=None, **options):\n \"\"\"\n Registers the given model(s) with the given admin class.\n\n The model(s) should be Model classes, not instances.\n\n If an admin class isn't given, it will use ModelAdmin (the default\n admin options). If keyword arguments are given -- e.g., list_display --"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L55_C8", "label": "expression", "type": "expression", "loc": [55, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L54_C4", "vector": [8, 2, 0.1299, 0.0238, 2, 0.41, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Registers the given model(s) with the given admin class.\n\n The model(s) should be Model classes, not instances.\n\n If an admin class isn't given, it will use ModelAdmin (the default\n admin options). If keyword arguments are given -- e.g., list_display --\n they'll be applied as options to the admin class."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L66_C8", "label": "if", "type": "if", "loc": [66, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L54_C4", "vector": [4, 2, 0.1439, 0.0043, 2, 0.41, 0.25, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not admin_class:\n admin_class = ModelAdmin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L67_C12", "label": "admin_class =", "type": "assigned_variable", "loc": [67, 67], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L66_C8", "vector": [14, 3, 0.145, 0.0022, 3, 0.02, 0.0, 237, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "admin_class", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " admin_class = ModelAdmin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L70_C8", "label": "if", "type": "if", "loc": [70, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L54_C4", "vector": [4, 2, 0.1548, 0.0087, 2, 0.41, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if admin_class and settings.DEBUG:\n from django.contrib.admin.validation import validate\n else:\n validate = lambda model, adminclass: None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L71_C12", "label": "from django.contrib.admin.validation import validate", "type": "import", "loc": [71, 71], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L70_C8", "vector": [1, 3, 0.1537, 0.0022, 3, 0.88, 0.0, 139, 0, 1, 0, 0, 139, 0, 0], "semantic": {"name": "django.contrib.admin.validation", "arg_names": [], "import_names": ["validate"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.validation import validate"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L73_C12", "label": "validate =", "type": "assigned_variable", "loc": [73, 73], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L70_C8", "vector": [14, 3, 0.158, 0.0022, 3, 0.88, 1.0, 628, 9, 0, 0, 0, 0, 0, 0], "semantic": {"name": "validate", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " validate = lambda model, adminclass: None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L75_C8", "label": "if", "type": "if", "loc": [75, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L54_C4", "vector": [4, 2, 0.1634, 0.0043, 2, 0.41, 0.75, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(model_or_iterable, ModelBase):\n model_or_iterable = [model_or_iterable]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L76_C12", "label": "model_or_iterable =", "type": "assigned_variable", "loc": [76, 76], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L75_C8", "vector": [14, 3, 0.1645, 0.0022, 3, 0.22, 0.0, 624, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "model_or_iterable", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model_or_iterable = [model_or_iterable]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L77_C8", "label": "for model", "type": "for", "loc": [77, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L54_C4", "vector": [6, 2, 0.1851, 0.039, 2, 0.41, 1.0, 722, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model in model_or_iterable:\n if model in self._registry:\n raise AlreadyRegistered('The model %s is already registered' % model.__name__)\n\n # If we got **options then dynamically construct a subclass of\n # admin_class with those **options.\n if options:\n # For reasons I don't quite understand, without a __module__"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L78_C12", "label": "if", "type": "if", "loc": [78, 79], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L77_C8", "vector": [4, 3, 0.1699, 0.0043, 3, 0.6, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if model in self._registry:\n raise AlreadyRegistered('The model %s is already registered' % model.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L83_C12", "label": "if", "type": "if", "loc": [83, 88], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L77_C8", "vector": [4, 3, 0.1851, 0.013, 3, 0.6, 0.3333, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if options:\n # For reasons I don't quite understand, without a __module__\n # the created class appears to \"live\" in the wrong place,\n # which causes issues later on.\n options['__module__'] = __name__\n admin_class = type(\"%sAdmin\" % model.__name__, (admin_class,), options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L87_C16", "label": "assign", "type": "assigned_variable", "loc": [87, 87], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L83_C12", "vector": [14, 4, 0.1883, 0.0022, 4, 0.57, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " options['__module__'] = __name__"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L88_C16", "label": "admin_class = type()", "type": "assigned_variable", "loc": [88, 88], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L83_C12", "vector": [14, 4, 0.1905, 0.0022, 4, 0.57, 1.0, 237, 3, 3, 0, 0, 801, 10, 1], "semantic": {"name": "admin_class", "arg_names": [], "import_names": [], "rhs_call_name": "type", "annotation": ""}, "snippet": " admin_class = type(\"%sAdmin\" % model.__name__, (admin_class,), options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L91_C12", "label": "validate()", "type": "expression", "loc": [91, 91], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L77_C8", "vector": [8, 3, 0.197, 0.0022, 3, 0.6, 0.6667, 628, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "validate", "arg_names": [], "import_names": [], "rhs_call_name": "validate", "annotation": ""}, "snippet": " validate(admin_class, model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L94_C12", "label": " = admin_class()", "type": "assigned_variable", "loc": [94, 94], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L77_C8", "vector": [14, 3, 0.2035, 0.0022, 3, 0.6, 1.0, 0, 3, 2, 0, 0, 237, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "admin_class", "annotation": ""}, "snippet": " self._registry[model] = admin_class(model, self)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L96_C4", "label": "unregister", "type": "function", "loc": [96, 107], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.2197, 0.026, 1, 0.89, 0.2903, 614, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "unregister", "arg_names": ["self", "model_or_iterable"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def unregister(self, model_or_iterable):\n \"\"\"\n Unregisters the given model(s).\n\n If a model isn't already registered, this will raise NotRegistered.\n \"\"\"\n if isinstance(model_or_iterable, ModelBase):\n model_or_iterable = [model_or_iterable]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L97_C8", "label": "expression", "type": "expression", "loc": [97, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L96_C4", "vector": [8, 2, 0.2143, 0.0108, 2, 0.17, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Unregisters the given model(s).\n\n If a model isn't already registered, this will raise NotRegistered.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L102_C8", "label": "if", "type": "if", "loc": [102, 103], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L96_C4", "vector": [4, 2, 0.2219, 0.0043, 2, 0.17, 0.5, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(model_or_iterable, ModelBase):\n model_or_iterable = [model_or_iterable]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L103_C12", "label": "model_or_iterable =", "type": "assigned_variable", "loc": [103, 103], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L102_C8", "vector": [14, 3, 0.2229, 0.0022, 3, 0.12, 0.0, 624, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "model_or_iterable", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model_or_iterable = [model_or_iterable]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L104_C8", "label": "for model", "type": "for", "loc": [104, 107], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L96_C4", "vector": [6, 2, 0.2284, 0.0087, 2, 0.17, 1.0, 722, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model in model_or_iterable:\n if model not in self._registry:\n raise NotRegistered('The model %s is not registered' % model.__name__)\n del self._registry[model]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L105_C12", "label": "if", "type": "if", "loc": [105, 106], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L104_C8", "vector": [4, 3, 0.2284, 0.0043, 3, 0.88, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if model not in self._registry:\n raise NotRegistered('The model %s is not registered' % model.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L109_C4", "label": "add_action", "type": "function", "loc": [109, 115], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.2424, 0.0152, 1, 0.89, 0.3226, 818, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "add_action", "arg_names": ["self", "action", "name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_action(self, action, name=None):\n \"\"\"\n Register an action to be available globally.\n \"\"\"\n name = name or action.__name__\n self._actions[name] = action\n self._global_actions[name] = action"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L110_C8", "label": "expression", "type": "expression", "loc": [110, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L109_C4", "vector": [8, 2, 0.2403, 0.0065, 2, 0.31, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Register an action to be available globally.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L113_C8", "label": "name =", "type": "assigned_variable", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L109_C4", "vector": [14, 2, 0.2446, 0.0022, 2, 0.31, 0.3333, 57, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " name = name or action.__name__"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L114_C8", "label": "assign", "type": "assigned_variable", "loc": [114, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L109_C4", "vector": [14, 2, 0.2468, 0.0022, 2, 0.31, 0.6667, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._actions[name] = action"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L115_C8", "label": "assign", "type": "assigned_variable", "loc": [115, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L109_C4", "vector": [14, 2, 0.2489, 0.0022, 2, 0.31, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._global_actions[name] = action"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L117_C4", "label": "disable_action", "type": "function", "loc": [117, 121], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.2576, 0.0108, 1, 0.89, 0.3548, 171, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "disable_action", "arg_names": ["self", "name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def disable_action(self, name):\n \"\"\"\n Disable a globally-registered action. Raises KeyError for invalid names.\n \"\"\"\n del self._actions[name]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L118_C8", "label": "expression", "type": "expression", "loc": [118, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L117_C4", "vector": [8, 2, 0.2576, 0.0065, 2, 0.06, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Disable a globally-registered action. Raises KeyError for invalid names.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L123_C4", "label": "get_action", "type": "function", "loc": [123, 128], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.2716, 0.013, 1, 0.89, 0.3871, 389, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "get_action", "arg_names": ["self", "name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_action(self, name):\n \"\"\"\n Explicitally get a registered global action wheather it's enabled or\n not. Raises KeyError for invalid names.\n \"\"\"\n return self._global_actions[name]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L124_C8", "label": "expression", "type": "expression", "loc": [124, 127], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L123_C4", "vector": [8, 2, 0.2716, 0.0087, 2, 0.3, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Explicitally get a registered global action wheather it's enabled or\n not. Raises KeyError for invalid names.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L128_C8", "label": "return", "type": "return", "loc": [128, 128], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L123_C4", "vector": [13, 2, 0.2771, 0.0022, 2, 0.3, 1.0, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._global_actions[name]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L130_C4", "label": "actions", "type": "function", "loc": [130, 134], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.2857, 0.0108, 1, 0.89, 0.4194, 317, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "actions", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def actions(self):\n \"\"\"\n Get all the enabled actions as an iterable of (name, func).\n \"\"\"\n return self._actions.iteritems()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L131_C8", "label": "expression", "type": "expression", "loc": [131, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L130_C4", "vector": [8, 2, 0.2857, 0.0065, 2, 0.7, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Get all the enabled actions as an iterable of (name, func).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L134_C8", "label": "return", "type": "return", "loc": [134, 134], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L130_C4", "vector": [13, 2, 0.29, 0.0022, 2, 0.7, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._actions.iteritems()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L135_C4", "label": "actions = property()", "type": "assigned_variable", "loc": [135, 135], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [14, 1, 0.2922, 0.0022, 1, 0.89, 0.4516, 317, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "actions", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " actions = property(actions)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L137_C4", "label": "has_permission", "type": "function", "loc": [137, 142], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.3019, 0.013, 1, 0.89, 0.4839, 521, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "has_permission", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_permission(self, request):\n \"\"\"\n Returns True if the given HttpRequest has permission to view\n *at least one* page in the admin site.\n \"\"\"\n return request.user.is_active and request.user.is_staff"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L138_C8", "label": "expression", "type": "expression", "loc": [138, 141], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L137_C4", "vector": [8, 2, 0.3019, 0.0087, 2, 0.56, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns True if the given HttpRequest has permission to view\n *at least one* page in the admin site.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L142_C8", "label": "return", "type": "return", "loc": [142, 142], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L137_C4", "vector": [13, 2, 0.3074, 0.0022, 2, 0.56, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return request.user.is_active and request.user.is_staff"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "label": "check_dependencies", "type": "function", "loc": [144, 163], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.3323, 0.0433, 1, 0.89, 0.5161, 547, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "check_dependencies", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def check_dependencies(self):\n \"\"\"\n Check that all things needed to run the admin have been correctly installed.\n\n The default implementation checks that LogEntry, ContentType and the\n auth context processor are installed.\n \"\"\"\n from django.contrib.admin.models import LogEntry"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L145_C8", "label": "expression", "type": "expression", "loc": [145, 150], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "vector": [8, 2, 0.3193, 0.013, 2, 0.85, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Check that all things needed to run the admin have been correctly installed.\n\n The default implementation checks that LogEntry, ContentType and the\n auth context processor are installed.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L151_C8", "label": "from django.contrib.admin.models import LogEntry", "type": "import", "loc": [151, 151], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "vector": [1, 2, 0.3268, 0.0022, 2, 0.85, 0.2, 408, 0, 1, 0, 0, 408, 0, 0], "semantic": {"name": "django.contrib.admin.models", "arg_names": [], "import_names": ["LogEntry"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.models import LogEntry"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L152_C8", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [152, 152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "vector": [1, 2, 0.329, 0.0022, 2, 0.85, 0.4, 469, 0, 1, 0, 0, 469, 0, 0], "semantic": {"name": "django.contrib.contenttypes.models", "arg_names": [], "import_names": ["ContentType"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.contenttypes.models import ContentType"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L154_C8", "label": "if", "type": "if", "loc": [154, 156], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "vector": [4, 2, 0.3355, 0.0065, 2, 0.85, 0.6, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not LogEntry._meta.installed:\n raise ImproperlyConfigured(\"Put 'django.contrib.admin' in your \"\n \"INSTALLED_APPS setting in order to use the admin application.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L157_C8", "label": "if", "type": "if", "loc": [157, 159], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "vector": [4, 2, 0.342, 0.0065, 2, 0.85, 0.8, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not ContentType._meta.installed:\n raise ImproperlyConfigured(\"Put 'django.contrib.contenttypes' in \"\n \"your INSTALLED_APPS setting in order to use the admin application.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L160_C8", "label": "if", "type": "if", "loc": [160, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "vector": [4, 2, 0.3496, 0.0087, 2, 0.85, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not ('django.contrib.auth.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS or\n 'django.core.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS):\n raise ImproperlyConfigured(\"Put 'django.contrib.auth.context_processors.auth' \"\n \"in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L165_C4", "label": "admin_view", "type": "function", "loc": [165, 198], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.3929, 0.0736, 1, 0.89, 0.5484, 296, 0, 3, 1, 0, 0, 0, 7], "semantic": {"name": "admin_view", "arg_names": ["self", "view", "cacheable"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def admin_view(self, view, cacheable=False):\n \"\"\"\n Decorator to create an admin view attached to this ``AdminSite``. This\n wraps the view and provides permission checking by calling\n ``self.has_permission``.\n\n You'll want to use this from within ``AdminSite.get_urls()``:\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L166_C8", "label": "expression", "type": "expression", "loc": [166, 187], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L165_C4", "vector": [8, 2, 0.382, 0.0476, 2, 0.69, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Decorator to create an admin view attached to this ``AdminSite``. This\n wraps the view and provides permission checking by calling\n ``self.has_permission``.\n\n You'll want to use this from within ``AdminSite.get_urls()``:\n\n class MyAdminSite(AdminSite):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L188_C8", "label": "inner", "type": "function", "loc": [188, 191], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L165_C4", "vector": [2, 2, 0.4102, 0.0087, 2, 0.69, 0.25, 763, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "inner", "arg_names": ["request", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def inner(request, *args, **kwargs):\n if not self.has_permission(request):\n return self.login(request)\n return view(request, *args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L189_C12", "label": "if", "type": "if", "loc": [189, 190], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L188_C8", "vector": [4, 3, 0.4102, 0.0043, 3, 0.82, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.has_permission(request):\n return self.login(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L190_C16", "label": "return", "type": "return", "loc": [190, 190], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L189_C12", "vector": [13, 4, 0.4113, 0.0022, 4, 0.95, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.login(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L191_C12", "label": "return", "type": "return", "loc": [191, 191], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L188_C8", "vector": [13, 3, 0.4134, 0.0022, 3, 0.82, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return view(request, *args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L192_C8", "label": "if", "type": "if", "loc": [192, 193], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L165_C4", "vector": [4, 2, 0.4167, 0.0043, 2, 0.69, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not cacheable:\n inner = never_cache(inner)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L193_C12", "label": "inner = never_cache()", "type": "assigned_variable", "loc": [193, 193], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L192_C8", "vector": [14, 3, 0.4177, 0.0022, 3, 0.58, 0.0, 763, 3, 1, 0, 0, 21, 10, 1], "semantic": {"name": "inner", "arg_names": [], "import_names": [], "rhs_call_name": "never_cache", "annotation": ""}, "snippet": " inner = never_cache(inner)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L196_C8", "label": "if", "type": "if", "loc": [196, 197], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L165_C4", "vector": [4, 2, 0.4253, 0.0043, 2, 0.69, 0.75, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not getattr(view, 'csrf_exempt', False):\n inner = csrf_protect(inner)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L197_C12", "label": "inner = csrf_protect()", "type": "assigned_variable", "loc": [197, 197], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L196_C8", "vector": [14, 3, 0.4264, 0.0022, 3, 0.55, 0.0, 763, 3, 1, 0, 0, 967, 10, 1], "semantic": {"name": "inner", "arg_names": [], "import_names": [], "rhs_call_name": "csrf_protect", "annotation": ""}, "snippet": " inner = csrf_protect(inner)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L198_C8", "label": "return", "type": "return", "loc": [198, 198], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L165_C4", "vector": [13, 2, 0.4286, 0.0022, 2, 0.69, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return update_wrapper(inner, view)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "label": "get_urls", "type": "function", "loc": [200, 241], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.4773, 0.0909, 1, 0.89, 0.5806, 974, 0, 1, 1, 0, 0, 0, 22], "semantic": {"name": "get_urls", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_urls(self):\n from django.conf.urls.defaults import patterns, url, include\n\n if settings.DEBUG:\n self.check_dependencies()\n\n def wrap(view, cacheable=False):\n def wrapper(*args, **kwargs):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L201_C8", "label": "from django.conf.urls.defaults import patterns, url, include", "type": "import", "loc": [201, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "vector": [1, 2, 0.4351, 0.0022, 2, 0.51, 0.0, 341, 0, 3, 0, 0, 341, 0, 0], "semantic": {"name": "django.conf.urls.defaults", "arg_names": [], "import_names": ["patterns", "url", "include"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.conf.urls.defaults import patterns, url, include"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L203_C8", "label": "if", "type": "if", "loc": [203, 204], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "vector": [4, 2, 0.4405, 0.0043, 2, 0.51, 0.2, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if settings.DEBUG:\n self.check_dependencies()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L204_C12", "label": "check_dependencies()", "type": "expression", "loc": [204, 204], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L203_C8", "vector": [8, 3, 0.4416, 0.0022, 3, 0.11, 0.0, 547, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "check_dependencies", "arg_names": [], "import_names": [], "rhs_call_name": "check_dependencies", "annotation": ""}, "snippet": " self.check_dependencies()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L206_C8", "label": "wrap", "type": "function", "loc": [206, 209], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "vector": [2, 2, 0.4491, 0.0087, 2, 0.51, 0.4, 9, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "wrap", "arg_names": ["view", "cacheable"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def wrap(view, cacheable=False):\n def wrapper(*args, **kwargs):\n return self.admin_view(view, cacheable)(*args, **kwargs)\n return update_wrapper(wrapper, view)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L207_C12", "label": "wrapper", "type": "function", "loc": [207, 208], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L206_C8", "vector": [2, 3, 0.4491, 0.0043, 3, 0.15, 0.0, 353, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "wrapper", "arg_names": ["args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def wrapper(*args, **kwargs):\n return self.admin_view(view, cacheable)(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L208_C16", "label": "return", "type": "return", "loc": [208, 208], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L207_C12", "vector": [13, 4, 0.4502, 0.0022, 4, 0.21, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.admin_view(view, cacheable)(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L209_C12", "label": "return", "type": "return", "loc": [209, 209], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L206_C8", "vector": [13, 3, 0.4524, 0.0022, 3, 0.15, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return update_wrapper(wrapper, view)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L212_C8", "label": "urlpatterns = patterns()", "type": "assigned_variable", "loc": [212, 233], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "vector": [14, 2, 0.4816, 0.0476, 2, 0.51, 0.6, 990, 3, 8, 0, 0, 75, 10, 14], "semantic": {"name": "urlpatterns", "arg_names": [], "import_names": [], "rhs_call_name": "patterns", "annotation": ""}, "snippet": " urlpatterns = patterns('',\n url(r'^$',\n wrap(self.index),\n name='index'),\n url(r'^logout/$',\n wrap(self.logout),\n name='logout'),\n url(r'^password_change/$',"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L236_C8", "label": "for model, model_admin", "type": "for", "loc": [236, 240], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "vector": [6, 2, 0.5152, 0.0108, 2, 0.51, 0.8, 169, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "model, model_admin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model, model_admin in self._registry.iteritems():\n urlpatterns += patterns('',\n url(r'^%s/%s/' % (model._meta.app_label, model._meta.module_name),\n include(model_admin.urls))\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L241_C8", "label": "return", "type": "return", "loc": [241, 241], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "vector": [13, 2, 0.5216, 0.0022, 2, 0.51, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return urlpatterns"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L243_C4", "label": "urls", "type": "function", "loc": [243, 244], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.5271, 0.0043, 1, 0.89, 0.6129, 260, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "urls", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def urls(self):\n return self.get_urls(), self.app_name, self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L244_C8", "label": "return", "type": "return", "loc": [244, 244], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L243_C4", "vector": [13, 2, 0.5281, 0.0022, 2, 0.69, 0.0, 0, 0, 0, 0, 0, 0, 8, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.get_urls(), self.app_name, self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L245_C4", "label": "urls = property()", "type": "assigned_variable", "loc": [245, 245], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [14, 1, 0.5303, 0.0022, 1, 0.89, 0.6452, 260, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "urls", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " urls = property(urls)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "label": "password_change", "type": "function", "loc": [247, 261], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.5498, 0.0325, 1, 0.89, 0.6774, 272, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "password_change", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def password_change(self, request):\n \"\"\"\n Handles the \"change password\" task -- both form display and validation.\n \"\"\"\n from django.contrib.auth.views import password_change\n if self.root_path is not None:\n url = '%spassword_change/done/' % self.root_path\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L248_C8", "label": "expression", "type": "expression", "loc": [248, 250], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "vector": [8, 2, 0.539, 0.0065, 2, 0.45, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Handles the \"change password\" task -- both form display and validation.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L251_C8", "label": "from django.contrib.auth.views import password_change", "type": "import", "loc": [251, 251], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "vector": [1, 2, 0.5433, 0.0022, 2, 0.45, 0.2, 745, 0, 1, 0, 0, 745, 0, 0], "semantic": {"name": "django.contrib.auth.views", "arg_names": [], "import_names": ["password_change"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.auth.views import password_change"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L252_C8", "label": "if", "type": "if", "loc": [252, 255], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "vector": [4, 2, 0.5487, 0.0087, 2, 0.45, 0.4, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.root_path is not None:\n url = '%spassword_change/done/' % self.root_path\n else:\n url = reverse('admin:password_change_done', current_app=self.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L253_C12", "label": "url =", "type": "assigned_variable", "loc": [253, 253], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L252_C8", "vector": [14, 3, 0.5476, 0.0022, 3, 0.37, 0.0, 789, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " url = '%spassword_change/done/' % self.root_path"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L255_C12", "label": "url = reverse()", "type": "assigned_variable", "loc": [255, 255], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L252_C8", "vector": [14, 3, 0.5519, 0.0022, 3, 0.37, 1.0, 789, 3, 2, 0, 0, 109, 10, 1], "semantic": {"name": "url", "arg_names": [], "import_names": [], "rhs_call_name": "reverse", "annotation": ""}, "snippet": " url = reverse('admin:password_change_done', current_app=self.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L256_C8", "label": "defaults =", "type": "assigned_variable", "loc": [256, 258], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "vector": [14, 2, 0.5563, 0.0065, 2, 0.45, 0.6, 233, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "defaults", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults = {\n 'post_change_redirect': url\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L259_C8", "label": "if", "type": "if", "loc": [259, 260], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "vector": [4, 2, 0.5617, 0.0043, 2, 0.45, 0.8, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.password_change_template is not None:\n defaults['template_name'] = self.password_change_template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L260_C12", "label": "assign", "type": "assigned_variable", "loc": [260, 260], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L259_C8", "vector": [14, 3, 0.5628, 0.0022, 3, 0.54, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults['template_name'] = self.password_change_template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L261_C8", "label": "return", "type": "return", "loc": [261, 261], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "vector": [13, 2, 0.5649, 0.0022, 2, 0.45, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return password_change(request, **defaults)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L263_C4", "label": "password_change_done", "type": "function", "loc": [263, 271], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.5779, 0.0195, 1, 0.89, 0.7097, 29, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "password_change_done", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def password_change_done(self, request):\n \"\"\"\n Displays the \"success\" page after a password change.\n \"\"\"\n from django.contrib.auth.views import password_change_done\n defaults = {}\n if self.password_change_done_template is not None:\n defaults['template_name'] = self.password_change_done_template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L264_C8", "label": "expression", "type": "expression", "loc": [264, 266], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L263_C4", "vector": [8, 2, 0.5736, 0.0065, 2, 0.09, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Displays the \"success\" page after a password change.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L267_C8", "label": "from django.contrib.auth.views import password_change_done", "type": "import", "loc": [267, 267], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L263_C4", "vector": [1, 2, 0.5779, 0.0022, 2, 0.09, 0.25, 745, 0, 1, 0, 0, 745, 0, 0], "semantic": {"name": "django.contrib.auth.views", "arg_names": [], "import_names": ["password_change_done"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.auth.views import password_change_done"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L268_C8", "label": "defaults =", "type": "assigned_variable", "loc": [268, 268], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L263_C4", "vector": [14, 2, 0.5801, 0.0022, 2, 0.09, 0.5, 233, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "defaults", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L269_C8", "label": "if", "type": "if", "loc": [269, 270], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L263_C4", "vector": [4, 2, 0.5833, 0.0043, 2, 0.09, 0.75, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.password_change_done_template is not None:\n defaults['template_name'] = self.password_change_done_template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L270_C12", "label": "assign", "type": "assigned_variable", "loc": [270, 270], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L269_C8", "vector": [14, 3, 0.5844, 0.0022, 3, 0.43, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults['template_name'] = self.password_change_done_template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L271_C8", "label": "return", "type": "return", "loc": [271, 271], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L263_C4", "vector": [13, 2, 0.5866, 0.0022, 2, 0.09, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return password_change_done(request, **defaults)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L273_C4", "label": "i18n_javascript", "type": "function", "loc": [273, 284], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.6028, 0.026, 1, 0.89, 0.7419, 573, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "i18n_javascript", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def i18n_javascript(self, request):\n \"\"\"\n Displays the i18n JavaScript that the Django admin requires.\n\n This takes into account the USE_I18N setting. If it's set to False, the\n generated JavaScript will be leaner and faster.\n \"\"\"\n if settings.USE_I18N:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L274_C8", "label": "expression", "type": "expression", "loc": [274, 279], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L273_C4", "vector": [8, 2, 0.5985, 0.013, 2, 0.65, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Displays the i18n JavaScript that the Django admin requires.\n\n This takes into account the USE_I18N setting. If it's set to False, the\n generated JavaScript will be leaner and faster.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L280_C8", "label": "if", "type": "if", "loc": [280, 283], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L273_C4", "vector": [4, 2, 0.6093, 0.0087, 2, 0.65, 0.5, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if settings.USE_I18N:\n from django.views.i18n import javascript_catalog\n else:\n from django.views.i18n import null_javascript_catalog as javascript_catalog"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L281_C12", "label": "from django.views.i18n import javascript_catalog", "type": "import", "loc": [281, 281], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L280_C8", "vector": [1, 3, 0.6082, 0.0022, 3, 0.94, 0.0, 122, 0, 1, 0, 0, 122, 0, 0], "semantic": {"name": "django.views.i18n", "arg_names": [], "import_names": ["javascript_catalog"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.views.i18n import javascript_catalog"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L283_C12", "label": "from django.views.i18n import javascript_catalog", "type": "import", "loc": [283, 283], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L280_C8", "vector": [1, 3, 0.6126, 0.0022, 3, 0.94, 1.0, 122, 0, 1, 0, 0, 122, 0, 0], "semantic": {"name": "django.views.i18n", "arg_names": [], "import_names": ["javascript_catalog"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.views.i18n import null_javascript_catalog as javascript_catalog"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L284_C8", "label": "return", "type": "return", "loc": [284, 284], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L273_C4", "vector": [13, 2, 0.6147, 0.0022, 2, 0.65, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return javascript_catalog(request, packages='django.conf')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L286_C4", "label": "logout", "type": "function", "loc": [286, 296], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.6299, 0.0238, 1, 0.89, 0.7742, 525, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "logout", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def logout(self, request):\n \"\"\"\n Logs out the user for the given HttpRequest.\n\n This should *not* assume the user is already logged in.\n \"\"\"\n from django.contrib.auth.views import logout\n defaults = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L287_C8", "label": "expression", "type": "expression", "loc": [287, 291], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L286_C4", "vector": [8, 2, 0.6255, 0.0108, 2, 0.28, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Logs out the user for the given HttpRequest.\n\n This should *not* assume the user is already logged in.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L292_C8", "label": "from django.contrib.auth.views import logout", "type": "import", "loc": [292, 292], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L286_C4", "vector": [1, 2, 0.632, 0.0022, 2, 0.28, 0.25, 745, 0, 1, 0, 0, 745, 0, 0], "semantic": {"name": "django.contrib.auth.views", "arg_names": [], "import_names": ["logout"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.auth.views import logout"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L293_C8", "label": "defaults =", "type": "assigned_variable", "loc": [293, 293], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L286_C4", "vector": [14, 2, 0.6342, 0.0022, 2, 0.28, 0.5, 233, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "defaults", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L294_C8", "label": "if", "type": "if", "loc": [294, 295], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L286_C4", "vector": [4, 2, 0.6374, 0.0043, 2, 0.28, 0.75, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.logout_template is not None:\n defaults['template_name'] = self.logout_template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L295_C12", "label": "assign", "type": "assigned_variable", "loc": [295, 295], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L294_C8", "vector": [14, 3, 0.6385, 0.0022, 3, 0.48, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults['template_name'] = self.logout_template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L296_C8", "label": "return", "type": "return", "loc": [296, 296], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L286_C4", "vector": [13, 2, 0.6407, 0.0022, 2, 0.28, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return logout(request, **defaults)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L297_C4", "label": "logout = never_cache()", "type": "assigned_variable", "loc": [297, 297], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [14, 1, 0.6429, 0.0022, 1, 0.89, 0.8065, 525, 3, 1, 0, 0, 21, 10, 1], "semantic": {"name": "logout", "arg_names": [], "import_names": [], "rhs_call_name": "never_cache", "annotation": ""}, "snippet": " logout = never_cache(logout)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "label": "login", "type": "function", "loc": [299, 346], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.6981, 0.1039, 1, 0.89, 0.8387, 724, 0, 2, 1, 0, 0, 0, 19], "semantic": {"name": "login", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def login(self, request):\n \"\"\"\n Displays the login form for the given HttpRequest.\n \"\"\"\n from django.contrib.auth.models import User\n\n # If this isn't already the login page, display it.\n if LOGIN_FORM_KEY not in request.POST:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L300_C8", "label": "expression", "type": "expression", "loc": [300, 302], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "vector": [8, 2, 0.6515, 0.0065, 2, 0.44, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Displays the login form for the given HttpRequest.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L303_C8", "label": "from django.contrib.auth.models import User", "type": "import", "loc": [303, 303], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "vector": [1, 2, 0.6558, 0.0022, 2, 0.44, 0.1429, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "django.contrib.auth.models", "arg_names": [], "import_names": ["User"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.auth.models import User"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L306_C8", "label": "if", "type": "if", "loc": [306, 311], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "vector": [4, 2, 0.6677, 0.013, 2, 0.44, 0.2857, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if LOGIN_FORM_KEY not in request.POST:\n if request.POST:\n message = _(\"Please log in again, because your session has expired.\")\n else:\n message = \"\"\n return self.display_login_form(request, message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L307_C12", "label": "if", "type": "if", "loc": [307, 310], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L306_C8", "vector": [4, 3, 0.6677, 0.0087, 3, 0.63, 0.0, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.POST:\n message = _(\"Please log in again, because your session has expired.\")\n else:\n message = \"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L308_C16", "label": "message = _()", "type": "assigned_variable", "loc": [308, 308], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L307_C12", "vector": [14, 4, 0.6667, 0.0022, 4, 0.8, 0.0, 635, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " message = _(\"Please log in again, because your session has expired.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L310_C16", "label": "message =", "type": "assigned_variable", "loc": [310, 310], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L307_C12", "vector": [14, 4, 0.671, 0.0022, 4, 0.8, 1.0, 635, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " message = \"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L311_C12", "label": "return", "type": "return", "loc": [311, 311], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L306_C8", "vector": [13, 3, 0.6732, 0.0022, 3, 0.63, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.display_login_form(request, message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L314_C8", "label": "if", "type": "if", "loc": [314, 318], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "vector": [4, 2, 0.684, 0.0108, 2, 0.44, 0.4286, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not request.session.test_cookie_worked():\n message = _(\"Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.\")\n return self.display_login_form(request, message)\n else:\n request.session.delete_test_cookie()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L315_C12", "label": "message = _()", "type": "assigned_variable", "loc": [315, 315], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L314_C8", "vector": [14, 3, 0.6818, 0.0022, 3, 0.65, 0.0, 635, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " message = _(\"Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L316_C12", "label": "return", "type": "return", "loc": [316, 316], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L314_C8", "vector": [13, 3, 0.684, 0.0022, 3, 0.65, 0.5, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.display_login_form(request, message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L318_C12", "label": "delete_test_cookie()", "type": "expression", "loc": [318, 318], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L314_C8", "vector": [8, 3, 0.6883, 0.0022, 3, 0.65, 1.0, 358, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete_test_cookie", "arg_names": [], "import_names": [], "rhs_call_name": "delete_test_cookie", "annotation": ""}, "snippet": " request.session.delete_test_cookie()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L321_C8", "label": "username = get()", "type": "assigned_variable", "loc": [321, 321], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "vector": [14, 2, 0.6948, 0.0022, 2, 0.44, 0.5714, 718, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "username", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " username = request.POST.get('username', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L322_C8", "label": "password = get()", "type": "assigned_variable", "loc": [322, 322], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "vector": [14, 2, 0.697, 0.0022, 2, 0.44, 0.7143, 489, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "password", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " password = request.POST.get('password', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L323_C8", "label": "user = authenticate()", "type": "assigned_variable", "loc": [323, 323], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "vector": [14, 2, 0.6991, 0.0022, 2, 0.44, 0.8571, 503, 3, 2, 0, 0, 751, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "authenticate", "annotation": ""}, "snippet": " user = authenticate(username=username, password=password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L324_C8", "label": "if", "type": "if", "loc": [324, 346], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "vector": [4, 2, 0.7251, 0.0498, 2, 0.44, 1.0, 0, 0, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user is None:\n message = ERROR_MESSAGE\n if username is not None and u'@' in username:\n # Mistakenly entered e-mail address instead of username? Look it up.\n try:\n user = User.objects.get(email=username)\n except (User.DoesNotExist, User.MultipleObjectsReturned):\n message = _(\"Usernames cannot contain the '@' character.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L325_C12", "label": "message =", "type": "assigned_variable", "loc": [325, 325], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L324_C8", "vector": [14, 3, 0.7035, 0.0022, 3, 0.53, 0.0, 635, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " message = ERROR_MESSAGE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L326_C12", "label": "if", "type": "if", "loc": [326, 337], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L324_C8", "vector": [4, 3, 0.7175, 0.026, 3, 0.53, 0.3333, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if username is not None and u'@' in username:\n # Mistakenly entered e-mail address instead of username? Look it up.\n try:\n user = User.objects.get(email=username)\n except (User.DoesNotExist, User.MultipleObjectsReturned):\n message = _(\"Usernames cannot contain the '@' character.\")\n else:\n if user.check_password(password):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Try_L328_C16", "label": "try", "type": "try", "loc": [328, 337], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L326_C12", "vector": [7, 4, 0.7197, 0.0216, 4, 0.05, 0.0, 0, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n user = User.objects.get(email=username)\n except (User.DoesNotExist, User.MultipleObjectsReturned):\n message = _(\"Usernames cannot contain the '@' character.\")\n else:\n if user.check_password(password):\n message = _(\"Your e-mail address is not your username.\"\n \" Try '%s' instead.\") % user.username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L329_C20", "label": "user = get()", "type": "assigned_variable", "loc": [329, 329], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:Try_L328_C16", "vector": [14, 5, 0.7121, 0.0022, 5, 0.19, 0.0, 503, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " user = User.objects.get(email=username)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L331_C20", "label": "message = _()", "type": "assigned_variable", "loc": [331, 331], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:Try_L328_C16", "vector": [14, 5, 0.7165, 0.0022, 5, 0.19, 0.0, 635, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " message = _(\"Usernames cannot contain the '@' character.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L333_C20", "label": "if", "type": "if", "loc": [333, 337], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:Try_L328_C16", "vector": [4, 5, 0.7251, 0.0108, 5, 0.19, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user.check_password(password):\n message = _(\"Your e-mail address is not your username.\"\n \" Try '%s' instead.\") % user.username\n else:\n message = _(\"Usernames cannot contain the '@' character.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L334_C24", "label": "message =", "type": "assigned_variable", "loc": [334, 335], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L333_C20", "vector": [14, 6, 0.724, 0.0043, 6, 0.05, 0.0, 635, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " message = _(\"Your e-mail address is not your username.\"\n \" Try '%s' instead.\") % user.username"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L337_C24", "label": "message = _()", "type": "assigned_variable", "loc": [337, 337], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L333_C20", "vector": [14, 6, 0.7294, 0.0022, 6, 0.05, 1.0, 635, 3, 1, 0, 0, 660, 10, 1], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "_", "annotation": ""}, "snippet": " message = _(\"Usernames cannot contain the '@' character.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L338_C12", "label": "return", "type": "return", "loc": [338, 338], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L324_C8", "vector": [13, 3, 0.7316, 0.0022, 3, 0.53, 0.6667, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.display_login_form(request, message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L342_C12", "label": "if", "type": "if", "loc": [342, 346], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L324_C8", "vector": [4, 3, 0.7446, 0.0108, 3, 0.53, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if user.is_active and user.is_staff:\n login(request, user)\n return http.HttpResponseRedirect(request.get_full_path())\n else:\n return self.display_login_form(request, ERROR_MESSAGE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L343_C16", "label": "login()", "type": "expression", "loc": [343, 343], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L342_C12", "vector": [8, 4, 0.7424, 0.0022, 4, 0.88, 0.0, 724, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " login(request, user)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L344_C16", "label": "return", "type": "return", "loc": [344, 344], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L342_C12", "vector": [13, 4, 0.7446, 0.0022, 4, 0.88, 0.5, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return http.HttpResponseRedirect(request.get_full_path())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L346_C16", "label": "return", "type": "return", "loc": [346, 346], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L342_C12", "vector": [13, 4, 0.7489, 0.0022, 4, 0.88, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.display_login_form(request, ERROR_MESSAGE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L347_C4", "label": "login = never_cache()", "type": "assigned_variable", "loc": [347, 347], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [14, 1, 0.7511, 0.0022, 1, 0.89, 0.871, 724, 3, 1, 0, 0, 21, 10, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "never_cache", "annotation": ""}, "snippet": " login = never_cache(login)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "label": "index", "type": "function", "loc": [349, 398], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.8084, 0.1082, 1, 0.89, 0.9032, 780, 0, 3, 1, 0, 0, 0, 16], "semantic": {"name": "index", "arg_names": ["self", "request", "extra_context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def index(self, request, extra_context=None):\n \"\"\"\n Displays the main admin index page, which lists all of the installed\n apps that have been registered in this site.\n \"\"\"\n app_dict = {}\n user = request.user\n for model, model_admin in self._registry.items():"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L350_C8", "label": "expression", "type": "expression", "loc": [350, 353], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "vector": [8, 2, 0.7608, 0.0087, 2, 0.04, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Displays the main admin index page, which lists all of the installed\n apps that have been registered in this site.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L354_C8", "label": "app_dict =", "type": "assigned_variable", "loc": [354, 354], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "vector": [14, 2, 0.7662, 0.0022, 2, 0.04, 0.1, 255, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "app_dict", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_dict = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L355_C8", "label": "user =", "type": "assigned_variable", "loc": [355, 355], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "vector": [14, 2, 0.7684, 0.0022, 2, 0.04, 0.2, 503, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user = request.user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L356_C8", "label": "for model, model_admin", "type": "for", "loc": [356, 379], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "vector": [6, 2, 0.7955, 0.0519, 2, 0.04, 0.3, 169, 3, 0, 0, 0, 0, 0, 9], "semantic": {"name": "model, model_admin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model, model_admin in self._registry.items():\n app_label = model._meta.app_label\n has_module_perms = user.has_module_perms(app_label)\n\n if has_module_perms:\n perms = model_admin.get_model_perms(request)\n\n # Check whether user has any perm for this module."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L357_C12", "label": "app_label =", "type": "assigned_variable", "loc": [357, 357], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L356_C8", "vector": [14, 3, 0.7727, 0.0022, 3, 0.09, 0.0, 187, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "app_label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_label = model._meta.app_label"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L358_C12", "label": "has_module_perms = has_module_perms()", "type": "assigned_variable", "loc": [358, 358], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L356_C8", "vector": [14, 3, 0.7749, 0.0022, 3, 0.09, 0.5, 249, 3, 1, 0, 0, 249, 10, 1], "semantic": {"name": "has_module_perms", "arg_names": [], "import_names": [], "rhs_call_name": "has_module_perms", "annotation": ""}, "snippet": " has_module_perms = user.has_module_perms(app_label)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L360_C12", "label": "if", "type": "if", "loc": [360, 379], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L356_C8", "vector": [4, 3, 0.7998, 0.0433, 3, 0.09, 1.0, 0, 2, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if has_module_perms:\n perms = model_admin.get_model_perms(request)\n\n # Check whether user has any perm for this module.\n # If so, add the module to the model_list.\n if True in perms.values():\n model_dict = {\n 'name': capfirst(model._meta.verbose_name_plural),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L361_C16", "label": "perms = get_model_perms()", "type": "assigned_variable", "loc": [361, 361], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L360_C12", "vector": [14, 4, 0.7814, 0.0022, 4, 0.55, 0.0, 840, 3, 1, 0, 0, 319, 10, 1], "semantic": {"name": "perms", "arg_names": [], "import_names": [], "rhs_call_name": "get_model_perms", "annotation": ""}, "snippet": " perms = model_admin.get_model_perms(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L365_C16", "label": "if", "type": "if", "loc": [365, 379], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L360_C12", "vector": [4, 4, 0.8052, 0.0325, 4, 0.55, 1.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if True in perms.values():\n model_dict = {\n 'name': capfirst(model._meta.verbose_name_plural),\n 'admin_url': mark_safe('%s/%s/' % (app_label, model.__name__.lower())),\n 'perms': perms,\n }\n if app_label in app_dict:\n app_dict[app_label]['models'].append(model_dict)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L366_C20", "label": "model_dict =", "type": "assigned_variable", "loc": [366, 370], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L365_C16", "vector": [14, 5, 0.7965, 0.0108, 5, 0.43, 0.0, 553, 0, 0, 0, 0, 0, 6, 3], "semantic": {"name": "model_dict", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model_dict = {\n 'name': capfirst(model._meta.verbose_name_plural),\n 'admin_url': mark_safe('%s/%s/' % (app_label, model.__name__.lower())),\n 'perms': perms,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L371_C20", "label": "if", "type": "if", "loc": [371, 379], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L365_C16", "vector": [4, 5, 0.8117, 0.0195, 5, 0.43, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if app_label in app_dict:\n app_dict[app_label]['models'].append(model_dict)\n else:\n app_dict[app_label] = {\n 'name': app_label.title(),\n 'app_url': app_label + '/',\n 'has_module_perms': has_module_perms,\n 'models': [model_dict],"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L372_C24", "label": "append()", "type": "expression", "loc": [372, 372], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L371_C20", "vector": [8, 6, 0.8052, 0.0022, 6, 0.59, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " app_dict[app_label]['models'].append(model_dict)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L374_C24", "label": "assign", "type": "assigned_variable", "loc": [374, 379], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L371_C20", "vector": [14, 6, 0.8149, 0.013, 6, 0.59, 1.0, 0, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_dict[app_label] = {\n 'name': app_label.title(),\n 'app_url': app_label + '/',\n 'has_module_perms': has_module_perms,\n 'models': [model_dict],\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L382_C8", "label": "app_list = values()", "type": "assigned_variable", "loc": [382, 382], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "vector": [14, 2, 0.8268, 0.0022, 2, 0.04, 0.4, 975, 3, 0, 0, 0, 721, 10, 1], "semantic": {"name": "app_list", "arg_names": [], "import_names": [], "rhs_call_name": "values", "annotation": ""}, "snippet": " app_list = app_dict.values()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L383_C8", "label": "sort()", "type": "expression", "loc": [383, 383], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "vector": [8, 2, 0.829, 0.0022, 2, 0.04, 0.5, 489, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "sort", "arg_names": [], "import_names": [], "rhs_call_name": "sort", "annotation": ""}, "snippet": " app_list.sort(key=lambda x: x['name'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L386_C8", "label": "for app", "type": "for", "loc": [386, 387], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "vector": [6, 2, 0.8366, 0.0043, 2, 0.04, 0.6, 494, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "app", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for app in app_list:\n app['models'].sort(key=lambda x: x['name'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L387_C12", "label": "sort()", "type": "expression", "loc": [387, 387], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L386_C8", "vector": [8, 3, 0.8377, 0.0022, 3, 0.53, 0.0, 489, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "sort", "arg_names": [], "import_names": [], "rhs_call_name": "sort", "annotation": ""}, "snippet": " app['models'].sort(key=lambda x: x['name'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L389_C8", "label": "context =", "type": "assigned_variable", "loc": [389, 393], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "vector": [14, 2, 0.8463, 0.0108, 2, 0.04, 0.7, 954, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context = {\n 'title': _('Site administration'),\n 'app_list': app_list,\n 'root_path': self.root_path,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L394_C8", "label": "update()", "type": "expression", "loc": [394, 394], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "vector": [8, 2, 0.8528, 0.0022, 2, 0.04, 0.8, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " context.update(extra_context or {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L395_C8", "label": "context_instance = RequestContext()", "type": "assigned_variable", "loc": [395, 395], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "vector": [14, 2, 0.855, 0.0022, 2, 0.04, 0.9, 723, 3, 2, 0, 0, 47, 10, 1], "semantic": {"name": "context_instance", "arg_names": [], "import_names": [], "rhs_call_name": "RequestContext", "annotation": ""}, "snippet": " context_instance = template.RequestContext(request, current_app=self.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L396_C8", "label": "return", "type": "return", "loc": [396, 398], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "vector": [13, 2, 0.8593, 0.0065, 2, 0.04, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(self.index_template or 'admin/index.html', context,\n context_instance=context_instance\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L399_C4", "label": "index = never_cache()", "type": "assigned_variable", "loc": [399, 399], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [14, 1, 0.8636, 0.0022, 1, 0.89, 0.9355, 780, 3, 1, 0, 0, 21, 10, 1], "semantic": {"name": "index", "arg_names": [], "import_names": [], "rhs_call_name": "never_cache", "annotation": ""}, "snippet": " index = never_cache(index)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L401_C4", "label": "display_login_form", "type": "function", "loc": [401, 413], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.881, 0.0281, 1, 0.89, 0.9677, 38, 0, 4, 1, 0, 0, 0, 6], "semantic": {"name": "display_login_form", "arg_names": ["self", "request", "error_message", "extra_context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def display_login_form(self, request, error_message='', extra_context=None):\n request.session.set_test_cookie()\n context = {\n 'title': _('Log in'),\n 'app_path': request.get_full_path(),\n 'error_message': error_message,\n 'root_path': self.root_path,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L402_C8", "label": "set_test_cookie()", "type": "expression", "loc": [402, 402], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L401_C4", "vector": [8, 2, 0.8701, 0.0022, 2, 0.01, 0.0, 915, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "set_test_cookie", "arg_names": [], "import_names": [], "rhs_call_name": "set_test_cookie", "annotation": ""}, "snippet": " request.session.set_test_cookie()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L403_C8", "label": "context =", "type": "assigned_variable", "loc": [403, 408], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L401_C4", "vector": [14, 2, 0.8777, 0.013, 2, 0.01, 0.25, 954, 0, 0, 0, 0, 0, 6, 2], "semantic": {"name": "context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context = {\n 'title': _('Log in'),\n 'app_path': request.get_full_path(),\n 'error_message': error_message,\n 'root_path': self.root_path,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L409_C8", "label": "update()", "type": "expression", "loc": [409, 409], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L401_C4", "vector": [8, 2, 0.8853, 0.0022, 2, 0.01, 0.5, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " context.update(extra_context or {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L410_C8", "label": "context_instance = RequestContext()", "type": "assigned_variable", "loc": [410, 410], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L401_C4", "vector": [14, 2, 0.8874, 0.0022, 2, 0.01, 0.75, 723, 3, 2, 0, 0, 47, 10, 1], "semantic": {"name": "context_instance", "arg_names": [], "import_names": [], "rhs_call_name": "RequestContext", "annotation": ""}, "snippet": " context_instance = template.RequestContext(request, current_app=self.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L411_C8", "label": "return", "type": "return", "loc": [411, 413], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L401_C4", "vector": [13, 2, 0.8918, 0.0065, 2, 0.01, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(self.login_template or 'admin/login.html', context,\n context_instance=context_instance\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "label": "app_index", "type": "function", "loc": [415, 458], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "vector": [2, 1, 0.9448, 0.0952, 1, 0.89, 1.0, 745, 0, 4, 1, 0, 0, 0, 15], "semantic": {"name": "app_index", "arg_names": ["self", "request", "app_label", "extra_context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def app_index(self, request, app_label, extra_context=None):\n user = request.user\n has_module_perms = user.has_module_perms(app_label)\n app_dict = {}\n for model, model_admin in self._registry.items():\n if app_label == model._meta.app_label:\n if has_module_perms:\n perms = model_admin.get_model_perms(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L416_C8", "label": "user =", "type": "assigned_variable", "loc": [416, 416], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "vector": [14, 2, 0.9004, 0.0022, 2, 0.74, 0.0, 503, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "user", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " user = request.user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L417_C8", "label": "has_module_perms = has_module_perms()", "type": "assigned_variable", "loc": [417, 417], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "vector": [14, 2, 0.9026, 0.0022, 2, 0.74, 0.1111, 249, 3, 1, 0, 0, 249, 10, 1], "semantic": {"name": "has_module_perms", "arg_names": [], "import_names": [], "rhs_call_name": "has_module_perms", "annotation": ""}, "snippet": " has_module_perms = user.has_module_perms(app_label)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L418_C8", "label": "app_dict =", "type": "assigned_variable", "loc": [418, 418], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "vector": [14, 2, 0.9048, 0.0022, 2, 0.74, 0.2222, 255, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "app_dict", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_dict = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L419_C8", "label": "for model, model_admin", "type": "for", "loc": [419, 443], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "vector": [6, 2, 0.9329, 0.0541, 2, 0.74, 0.3333, 169, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "model, model_admin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model, model_admin in self._registry.items():\n if app_label == model._meta.app_label:\n if has_module_perms:\n perms = model_admin.get_model_perms(request)\n\n # Check whether user has any perm for this module.\n # If so, add the module to the model_list.\n if True in perms.values():"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L420_C12", "label": "if", "type": "if", "loc": [420, 443], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L419_C8", "vector": [4, 3, 0.934, 0.0519, 3, 0.62, 0.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if app_label == model._meta.app_label:\n if has_module_perms:\n perms = model_admin.get_model_perms(request)\n\n # Check whether user has any perm for this module.\n # If so, add the module to the model_list.\n if True in perms.values():\n model_dict = {"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L421_C16", "label": "if", "type": "if", "loc": [421, 443], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L420_C12", "vector": [4, 4, 0.9351, 0.0498, 4, 0.6, 0.0, 0, 2, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if has_module_perms:\n perms = model_admin.get_model_perms(request)\n\n # Check whether user has any perm for this module.\n # If so, add the module to the model_list.\n if True in perms.values():\n model_dict = {\n 'name': capfirst(model._meta.verbose_name_plural),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L422_C20", "label": "perms = get_model_perms()", "type": "assigned_variable", "loc": [422, 422], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L421_C16", "vector": [14, 5, 0.9134, 0.0022, 5, 0.53, 0.0, 840, 3, 1, 0, 0, 319, 10, 1], "semantic": {"name": "perms", "arg_names": [], "import_names": [], "rhs_call_name": "get_model_perms", "annotation": ""}, "snippet": " perms = model_admin.get_model_perms(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L426_C20", "label": "if", "type": "if", "loc": [426, 443], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L421_C16", "vector": [4, 5, 0.9405, 0.039, 5, 0.53, 1.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if True in perms.values():\n model_dict = {\n 'name': capfirst(model._meta.verbose_name_plural),\n 'admin_url': '%s/' % model.__name__.lower(),\n 'perms': perms,\n }\n if app_dict:\n app_dict['models'].append(model_dict),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L427_C24", "label": "model_dict =", "type": "assigned_variable", "loc": [427, 431], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L426_C20", "vector": [14, 6, 0.9286, 0.0108, 6, 0.94, 0.0, 553, 0, 0, 0, 0, 0, 6, 2], "semantic": {"name": "model_dict", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model_dict = {\n 'name': capfirst(model._meta.verbose_name_plural),\n 'admin_url': '%s/' % model.__name__.lower(),\n 'perms': perms,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L432_C24", "label": "if", "type": "if", "loc": [432, 443], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L426_C20", "vector": [4, 6, 0.947, 0.026, 6, 0.94, 1.0, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if app_dict:\n app_dict['models'].append(model_dict),\n else:\n # First time around, now that we know there's\n # something to display, add in the necessary meta\n # information.\n app_dict = {\n 'name': app_label.title(),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L433_C28", "label": "expression", "type": "expression", "loc": [433, 433], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L432_C24", "vector": [8, 7, 0.9372, 0.0022, 7, 0.79, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_dict['models'].append(model_dict),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L438_C28", "label": "app_dict =", "type": "assigned_variable", "loc": [438, 443], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L432_C24", "vector": [14, 7, 0.9535, 0.013, 7, 0.79, 1.0, 255, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "app_dict", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_dict = {\n 'name': app_label.title(),\n 'app_url': '',\n 'has_module_perms': has_module_perms,\n 'models': [model_dict],\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L444_C8", "label": "if", "type": "if", "loc": [444, 445], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "vector": [4, 2, 0.9621, 0.0043, 2, 0.74, 0.4444, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not app_dict:\n raise http.Http404('The requested admin page does not exist.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L447_C8", "label": "sort()", "type": "expression", "loc": [447, 447], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "vector": [8, 2, 0.9675, 0.0022, 2, 0.74, 0.5556, 489, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "sort", "arg_names": [], "import_names": [], "rhs_call_name": "sort", "annotation": ""}, "snippet": " app_dict['models'].sort(key=lambda x: x['name'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L448_C8", "label": "context =", "type": "assigned_variable", "loc": [448, 452], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "vector": [14, 2, 0.974, 0.0108, 2, 0.74, 0.6667, 954, 0, 0, 0, 0, 0, 6, 2], "semantic": {"name": "context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context = {\n 'title': _('%s administration') % capfirst(app_label),\n 'app_list': [app_dict],\n 'root_path': self.root_path,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L453_C8", "label": "update()", "type": "expression", "loc": [453, 453], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "vector": [8, 2, 0.9805, 0.0022, 2, 0.74, 0.7778, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " context.update(extra_context or {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L454_C8", "label": "context_instance = RequestContext()", "type": "assigned_variable", "loc": [454, 454], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "vector": [14, 2, 0.9827, 0.0022, 2, 0.74, 0.8889, 723, 3, 2, 0, 0, 47, 10, 1], "semantic": {"name": "context_instance", "arg_names": [], "import_names": [], "rhs_call_name": "RequestContext", "annotation": ""}, "snippet": " context_instance = template.RequestContext(request, current_app=self.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L455_C8", "label": "return", "type": "return", "loc": [455, 458], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "vector": [13, 2, 0.9881, 0.0087, 2, 0.74, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(self.app_index_template or ('admin/%s/app_index.html' % app_label,\n 'admin/app_index.html'), context,\n context_instance=context_instance\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L462_C0", "label": "site = AdminSite()", "type": "assigned_variable", "loc": [462, 462], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0022, 0, 0.66, 1.0, 681, 3, 0, 0, 0, 938, 10, 1], "semantic": {"name": "site", "arg_names": [], "import_names": [], "rhs_call_name": "AdminSite", "annotation": ""}, "snippet": "site = AdminSite()"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L47_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L49_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L66_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L67_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L70_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L71_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L70_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L73_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L75_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L76_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L83_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L83_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L87_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L83_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L88_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L91_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L94_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L96_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L96_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L96_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L102_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L102_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L103_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L96_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L104_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L104_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L105_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L109_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L115_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L117_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L123_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L123_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L124_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L123_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L130_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L130_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L130_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L134_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L135_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L137_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L137_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L138_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L137_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L142_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L145_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L151_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L152_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L157_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L160_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L165_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L188_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L188_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L189_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L189_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L190_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L188_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L191_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L192_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L192_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L193_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L197_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L198_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L201_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L203_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L203_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L204_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L206_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L206_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L207_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L207_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L208_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L206_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L209_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L212_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L236_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L241_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L243_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L243_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L244_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L245_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L248_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L251_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L252_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L252_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L253_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L252_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L255_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L256_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L259_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L259_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L260_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L247_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L261_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L263_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L264_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L267_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L268_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L269_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L269_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L270_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L271_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L273_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L274_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L280_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L280_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L281_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L280_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L283_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L273_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L284_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L286_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L286_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L287_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L286_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L292_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L286_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L293_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L286_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L294_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L294_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L295_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L286_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L296_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L297_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L300_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:ImportFrom_L303_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L306_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L306_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L307_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L307_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L308_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L307_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L310_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L306_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L311_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L314_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L314_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L315_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L314_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L316_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L314_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L318_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L321_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L322_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L323_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L299_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L324_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L324_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L325_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L324_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L326_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L326_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Try_L328_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:Try_L328_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L329_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:Try_L328_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L331_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:Try_L328_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L333_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L333_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L334_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L333_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L337_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L324_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L338_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L324_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L342_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L342_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L343_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L342_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L344_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L342_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L346_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L347_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L350_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L354_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L355_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L356_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L356_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L357_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L356_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L358_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L356_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L360_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L360_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L361_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L360_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L365_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L365_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L366_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L365_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L371_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L371_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L372_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L371_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L374_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L382_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L383_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L386_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L386_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L387_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L389_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L394_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L395_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L396_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L399_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L401_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L401_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L402_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L401_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L403_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L401_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L409_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L401_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L410_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L401_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L411_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L416_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L417_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L418_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L419_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:For_L419_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L420_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L420_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L421_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L421_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L422_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L421_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L426_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L426_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L427_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L426_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L432_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L432_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L433_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L432_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L438_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:If_L444_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L447_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L448_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Expr_L453_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Assign_L454_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98651:FunctionDef_L415_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98651:Return_L455_C8"}] |
"""
Form Widget classes specific to the Django admin site.
"""
import django.utils.copycompat as copy
from django import forms
from django.forms.widgets import RadioFieldRenderer
from django.forms.util import flatatt
from django.utils.html import escape
from django.utils.text import truncate_words
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from django.utils.encoding import force_unicode
from django.conf import settings
from django.core.urlresolvers import reverse, NoReverseMatch
class FilteredSelectMultiple(forms.SelectMultiple):
"""
A SelectMultiple with a JavaScript filter interface.
Note that the resulting JavaScript assumes that the jsi18n
catalog has been loaded in the page
"""
class Media:
js = (settings.ADMIN_MEDIA_PREFIX + "js/core.js",
settings.ADMIN_MEDIA_PREFIX + "js/SelectBox.js",
settings.ADMIN_MEDIA_PREFIX + "js/SelectFilter2.js")
def __init__(self, verbose_name, is_stacked, attrs=None, choices=()):
self.verbose_name = verbose_name
self.is_stacked = is_stacked
super(FilteredSelectMultiple, self).__init__(attrs, choices)
def render(self, name, value, attrs=None, choices=()):
if attrs is None: attrs = {}
attrs['class'] = 'selectfilter'
if self.is_stacked: attrs['class'] += 'stacked'
output = [super(FilteredSelectMultiple, self).render(name, value, attrs, choices)]
output.append(u'<script type="text/javascript">addEvent(window, "load", function(e) {')
# TODO: "id_" is hard-coded here. This should instead use the correct
# API to determine the ID dynamically.
output.append(u'SelectFilter.init("id_%s", "%s", %s, "%s"); });</script>\n' % \
(name, self.verbose_name.replace('"', '\\"'), int(self.is_stacked), settings.ADMIN_MEDIA_PREFIX))
return mark_safe(u''.join(output))
class AdminDateWidget(forms.DateInput):
class Media:
js = (settings.ADMIN_MEDIA_PREFIX + "js/calendar.js",
settings.ADMIN_MEDIA_PREFIX + "js/admin/DateTimeShortcuts.js")
def __init__(self, attrs={}, format=None):
super(AdminDateWidget, self).__init__(attrs={'class': 'vDateField', 'size': '10'}, format=format)
class AdminTimeWidget(forms.TimeInput):
class Media:
js = (settings.ADMIN_MEDIA_PREFIX + "js/calendar.js",
settings.ADMIN_MEDIA_PREFIX + "js/admin/DateTimeShortcuts.js")
def __init__(self, attrs={}, format=None):
super(AdminTimeWidget, self).__init__(attrs={'class': 'vTimeField', 'size': '8'}, format=format)
class AdminSplitDateTime(forms.SplitDateTimeWidget):
"""
A SplitDateTime Widget that has some admin-specific styling.
"""
def __init__(self, attrs=None):
widgets = [AdminDateWidget, AdminTimeWidget]
# Note that we're calling MultiWidget, not SplitDateTimeWidget, because
# we want to define widgets.
forms.MultiWidget.__init__(self, widgets, attrs)
def format_output(self, rendered_widgets):
return mark_safe(u'<p class="datetime">%s %s<br />%s %s</p>' % \
(_('Date:'), rendered_widgets[0], _('Time:'), rendered_widgets[1]))
class AdminRadioFieldRenderer(RadioFieldRenderer):
def render(self):
"""Outputs a <ul> for this set of radio fields."""
return mark_safe(u'<ul%s>\n%s\n</ul>' % (
flatatt(self.attrs),
u'\n'.join([u'<li>%s</li>' % force_unicode(w) for w in self]))
)
class AdminRadioSelect(forms.RadioSelect):
renderer = AdminRadioFieldRenderer
class AdminFileWidget(forms.ClearableFileInput):
template_with_initial = (u'<p class="file-upload">%s</p>'
% forms.ClearableFileInput.template_with_initial)
template_with_clear = (u'<span class="clearable-file-input">%s</span>'
% forms.ClearableFileInput.template_with_clear)
class ForeignKeyRawIdWidget(forms.TextInput):
"""
A Widget for displaying ForeignKeys in the "raw_id" interface rather than
in a <select> box.
"""
def __init__(self, rel, attrs=None, using=None):
self.rel = rel
self.db = using
super(ForeignKeyRawIdWidget, self).__init__(attrs)
def render(self, name, value, attrs=None):
if attrs is None:
attrs = {}
related_url = '../../../%s/%s/' % (self.rel.to._meta.app_label, self.rel.to._meta.object_name.lower())
params = self.url_parameters()
if params:
url = '?' + '&'.join(['%s=%s' % (k, v) for k, v in params.items()])
else:
url = ''
if "class" not in attrs:
attrs['class'] = 'vForeignKeyRawIdAdminField' # The JavaScript looks for this hook.
output = [super(ForeignKeyRawIdWidget, self).render(name, value, attrs)]
# TODO: "id_" is hard-coded here. This should instead use the correct
# API to determine the ID dynamically.
output.append('<a href="%s%s" class="related-lookup" id="lookup_id_%s" onclick="return showRelatedObjectLookupPopup(this);"> ' % \
(related_url, url, name))
output.append('<img src="%simg/admin/selector-search.gif" width="16" height="16" alt="%s" /></a>' % (settings.ADMIN_MEDIA_PREFIX, _('Lookup')))
if value:
output.append(self.label_for_value(value))
return mark_safe(u''.join(output))
def base_url_parameters(self):
params = {}
if self.rel.limit_choices_to and hasattr(self.rel.limit_choices_to, 'items'):
items = []
for k, v in self.rel.limit_choices_to.items():
if isinstance(v, list):
v = ','.join([str(x) for x in v])
else:
v = str(v)
items.append((k, v))
params.update(dict(items))
return params
def url_parameters(self):
from django.contrib.admin.views.main import TO_FIELD_VAR
params = self.base_url_parameters()
params.update({TO_FIELD_VAR: self.rel.get_related_field().name})
return params
def label_for_value(self, value):
key = self.rel.get_related_field().name
try:
obj = self.rel.to._default_manager.using(self.db).get(**{key: value})
return ' <strong>%s</strong>' % escape(truncate_words(obj, 14))
except (ValueError, self.rel.to.DoesNotExist):
return ''
class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
"""
A Widget for displaying ManyToMany ids in the "raw_id" interface rather than
in a <select multiple> box.
"""
def render(self, name, value, attrs=None):
if attrs is None:
attrs = {}
attrs['class'] = 'vManyToManyRawIdAdminField'
if value:
value = ','.join([force_unicode(v) for v in value])
else:
value = ''
return super(ManyToManyRawIdWidget, self).render(name, value, attrs)
def url_parameters(self):
return self.base_url_parameters()
def label_for_value(self, value):
return ''
def value_from_datadict(self, data, files, name):
value = data.get(name)
if value:
return value.split(',')
def _has_changed(self, initial, data):
if initial is None:
initial = []
if data is None:
data = []
if len(initial) != len(data):
return True
for pk1, pk2 in zip(initial, data):
if force_unicode(pk1) != force_unicode(pk2):
return True
return False
class RelatedFieldWidgetWrapper(forms.Widget):
"""
This class is a wrapper to a given widget to add the add icon for the
admin interface.
"""
def __init__(self, widget, rel, admin_site, can_add_related=None):
self.is_hidden = widget.is_hidden
self.needs_multipart_form = widget.needs_multipart_form
self.attrs = widget.attrs
self.choices = widget.choices
self.widget = widget
self.rel = rel
# Backwards compatible check for whether a user can add related
# objects.
if can_add_related is None:
can_add_related = rel_to in self.admin_site._registry
self.can_add_related = can_add_related
# so we can check if the related object is registered with this AdminSite
self.admin_site = admin_site
def __deepcopy__(self, memo):
obj = copy.copy(self)
obj.widget = copy.deepcopy(self.widget, memo)
obj.attrs = self.widget.attrs
memo[id(self)] = obj
return obj
def _media(self):
return self.widget.media
media = property(_media)
def render(self, name, value, *args, **kwargs):
rel_to = self.rel.to
info = (rel_to._meta.app_label, rel_to._meta.object_name.lower())
try:
related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name)
except NoReverseMatch:
info = (self.admin_site.root_path, rel_to._meta.app_label, rel_to._meta.object_name.lower())
related_url = '%s%s/%s/add/' % info
self.widget.choices = self.choices
output = [self.widget.render(name, value, *args, **kwargs)]
if self.can_add_related:
# TODO: "id_" is hard-coded here. This should instead use the correct
# API to determine the ID dynamically.
output.append(u'<a href="%s" class="add-another" id="add_id_%s" onclick="return showAddAnotherPopup(this);"> ' % \
(related_url, name))
output.append(u'<img src="%simg/admin/icon_addlink.gif" width="10" height="10" alt="%s"/></a>' % (settings.ADMIN_MEDIA_PREFIX, _('Add Another')))
return mark_safe(u''.join(output))
def build_attrs(self, extra_attrs=None, **kwargs):
"Helper function for building an attribute dictionary."
self.attrs = self.widget.build_attrs(extra_attrs=None, **kwargs)
return self.attrs
def value_from_datadict(self, data, files, name):
return self.widget.value_from_datadict(data, files, name)
def _has_changed(self, initial, data):
return self.widget._has_changed(initial, data)
def id_for_label(self, id_):
return self.widget.id_for_label(id_)
class AdminTextareaWidget(forms.Textarea):
def __init__(self, attrs=None):
final_attrs = {'class': 'vLargeTextField'}
if attrs is not None:
final_attrs.update(attrs)
super(AdminTextareaWidget, self).__init__(attrs=final_attrs)
class AdminTextInputWidget(forms.TextInput):
def __init__(self, attrs=None):
final_attrs = {'class': 'vTextField'}
if attrs is not None:
final_attrs.update(attrs)
super(AdminTextInputWidget, self).__init__(attrs=final_attrs)
class AdminURLFieldWidget(forms.TextInput):
def __init__(self, attrs=None):
final_attrs = {'class': 'vURLField'}
if attrs is not None:
final_attrs.update(attrs)
super(AdminURLFieldWidget, self).__init__(attrs=final_attrs)
class AdminIntegerFieldWidget(forms.TextInput):
def __init__(self, attrs=None):
final_attrs = {'class': 'vIntegerField'}
if attrs is not None:
final_attrs.update(attrs)
super(AdminIntegerFieldWidget, self).__init__(attrs=final_attrs)
class AdminCommaSeparatedIntegerFieldWidget(forms.TextInput):
def __init__(self, attrs=None):
final_attrs = {'class': 'vCommaSeparatedIntegerField'}
if attrs is not None:
final_attrs.update(attrs)
super(AdminCommaSeparatedIntegerFieldWidget, self).__init__(attrs=final_attrs)
| ajibawa-2023/Python-Code-Large/train/row_98652 | 203 | 287 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.007, 0.0105, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nForm Widget classes specific to the Django admin site.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Import_L5_C0", "label": "django.utils.copycompat import copy", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0174, 0.0035, 0, 0.66, 0.0385, 125, 0, 1, 0, 0, 125, 0, 0], "semantic": {"name": "django.utils.copycompat", "arg_names": [], "import_names": ["copy"], "rhs_call_name": "", "annotation": ""}, "snippet": "import django.utils.copycompat as copy"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ImportFrom_L7_C0", "label": "from django import forms", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0244, 0.0035, 0, 0.66, 0.0769, 294, 0, 1, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["forms"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django import forms"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ImportFrom_L8_C0", "label": "from django.forms.widgets import RadioFieldRenderer", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0279, 0.0035, 0, 0.66, 0.1154, 260, 0, 1, 0, 0, 260, 0, 0], "semantic": {"name": "django.forms.widgets", "arg_names": [], "import_names": ["RadioFieldRenderer"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.forms.widgets import RadioFieldRenderer"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ImportFrom_L9_C0", "label": "from django.forms.util import flatatt", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0314, 0.0035, 0, 0.66, 0.1538, 332, 0, 1, 0, 0, 332, 0, 0], "semantic": {"name": "django.forms.util", "arg_names": [], "import_names": ["flatatt"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.forms.util import flatatt"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ImportFrom_L10_C0", "label": "from django.utils.html import escape", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0348, 0.0035, 0, 0.66, 0.1923, 535, 0, 1, 0, 0, 535, 0, 0], "semantic": {"name": "django.utils.html", "arg_names": [], "import_names": ["escape"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.html import escape"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ImportFrom_L11_C0", "label": "from django.utils.text import truncate_words", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0383, 0.0035, 0, 0.66, 0.2308, 590, 0, 1, 0, 0, 590, 0, 0], "semantic": {"name": "django.utils.text", "arg_names": [], "import_names": ["truncate_words"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.text import truncate_words"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ImportFrom_L12_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0418, 0.0035, 0, 0.66, 0.2692, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ImportFrom_L13_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0453, 0.0035, 0, 0.66, 0.3077, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.safestring", "arg_names": [], "import_names": ["mark_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.safestring import mark_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ImportFrom_L14_C0", "label": "from django.utils.encoding import force_unicode", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.0488, 0.0035, 0, 0.66, 0.3462, 96, 0, 1, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["force_unicode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import force_unicode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ImportFrom_L15_C0", "label": "from django.conf import settings", "type": "import", "loc": [15, 15], "level": 0, "parent": null, "vector": [1, 0, 0.0523, 0.0035, 0, 0.66, 0.3846, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ImportFrom_L16_C0", "label": "from django.core.urlresolvers import reverse, NoReverseMatch", "type": "import", "loc": [16, 16], "level": 0, "parent": null, "vector": [1, 0, 0.0557, 0.0035, 0, 0.66, 0.4231, 749, 0, 2, 0, 0, 749, 0, 0], "semantic": {"name": "django.core.urlresolvers", "arg_names": [], "import_names": ["reverse", "NoReverseMatch"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.urlresolvers import reverse, NoReverseMatch"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L18_C0", "label": "FilteredSelectMultiple", "type": "class", "loc": [18, 45], "level": 0, "parent": null, "vector": [3, 0, 0.1098, 0.0976, 0, 0.66, 0.4615, 128, 0, 2, 0, 0, 7, 0, 10], "semantic": {"name": "FilteredSelectMultiple", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class FilteredSelectMultiple(forms.SelectMultiple):\n \"\"\"\n A SelectMultiple with a JavaScript filter interface.\n\n Note that the resulting JavaScript assumes that the jsi18n\n catalog has been loaded in the page\n \"\"\"\n class Media:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L19_C4", "label": "expression", "type": "expression", "loc": [19, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L18_C0", "vector": [8, 1, 0.0749, 0.0209, 1, 0.34, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A SelectMultiple with a JavaScript filter interface.\n\n Note that the resulting JavaScript assumes that the jsi18n\n catalog has been loaded in the page\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L25_C4", "label": "Media", "type": "class", "loc": [25, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L18_C0", "vector": [3, 1, 0.0923, 0.0139, 1, 0.34, 0.3333, 185, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "Media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Media:\n js = (settings.ADMIN_MEDIA_PREFIX + \"js/core.js\",\n settings.ADMIN_MEDIA_PREFIX + \"js/SelectBox.js\",\n settings.ADMIN_MEDIA_PREFIX + \"js/SelectFilter2.js\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L26_C8", "label": "js =", "type": "assigned_variable", "loc": [26, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L25_C4", "vector": [14, 2, 0.0941, 0.0105, 2, 0.83, 0.0, 62, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "js", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " js = (settings.ADMIN_MEDIA_PREFIX + \"js/core.js\",\n settings.ADMIN_MEDIA_PREFIX + \"js/SelectBox.js\",\n settings.ADMIN_MEDIA_PREFIX + \"js/SelectFilter2.js\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L30_C4", "label": "__init__", "type": "function", "loc": [30, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L18_C0", "vector": [2, 1, 0.1098, 0.0139, 1, 0.34, 0.6667, 555, 0, 5, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "verbose_name", "is_stacked", "attrs", "choices"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, verbose_name, is_stacked, attrs=None, choices=()):\n self.verbose_name = verbose_name\n self.is_stacked = is_stacked\n super(FilteredSelectMultiple, self).__init__(attrs, choices)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L31_C8", "label": "self.verbose_name =", "type": "assigned_variable", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L30_C4", "vector": [14, 2, 0.108, 0.0035, 2, 0.17, 0.0, 45, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.verbose_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.verbose_name = verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L32_C8", "label": "self.is_stacked =", "type": "assigned_variable", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L30_C4", "vector": [14, 2, 0.1115, 0.0035, 2, 0.17, 0.5, 758, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.is_stacked", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.is_stacked = is_stacked"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L33_C8", "label": "__init__()", "type": "expression", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L30_C4", "vector": [8, 2, 0.115, 0.0035, 2, 0.17, 1.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(FilteredSelectMultiple, self).__init__(attrs, choices)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "label": "render", "type": "function", "loc": [35, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L18_C0", "vector": [2, 1, 0.1394, 0.0383, 1, 0.34, 1.0, 24, 0, 5, 1, 0, 0, 0, 8], "semantic": {"name": "render", "arg_names": ["self", "name", "value", "attrs", "choices"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self, name, value, attrs=None, choices=()):\n if attrs is None: attrs = {}\n attrs['class'] = 'selectfilter'\n if self.is_stacked: attrs['class'] += 'stacked'\n output = [super(FilteredSelectMultiple, self).render(name, value, attrs, choices)]\n output.append(u'<script type=\"text/javascript\">addEvent(window, \"load\", function(e) {')\n # TODO: \"id_\" is hard-coded here. This should instead use the correct\n # API to determine the ID dynamically."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L36_C8", "label": "if", "type": "if", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "vector": [4, 2, 0.1254, 0.0035, 2, 0.33, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if attrs is None: attrs = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L36_C26", "label": "attrs =", "type": "assigned_variable", "loc": [36, 36], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L36_C8", "vector": [14, 3, 0.1254, 0.0035, 3, 0.29, 0.0, 251, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if attrs is None: attrs = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L37_C8", "label": "assign", "type": "assigned_variable", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "vector": [14, 2, 0.1289, 0.0035, 2, 0.33, 0.1667, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs['class'] = 'selectfilter'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L38_C8", "label": "if", "type": "if", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "vector": [4, 2, 0.1324, 0.0035, 2, 0.33, 0.3333, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.is_stacked: attrs['class'] += 'stacked'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L39_C8", "label": "output =", "type": "assigned_variable", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "vector": [14, 2, 0.1359, 0.0035, 2, 0.33, 0.5, 886, 0, 0, 0, 0, 0, 5, 2], "semantic": {"name": "output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output = [super(FilteredSelectMultiple, self).render(name, value, attrs, choices)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L40_C8", "label": "append()", "type": "expression", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "vector": [8, 2, 0.1394, 0.0035, 2, 0.33, 0.6667, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " output.append(u'<script type=\"text/javascript\">addEvent(window, \"load\", function(e) {')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L43_C8", "label": "append()", "type": "expression", "loc": [43, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "vector": [8, 2, 0.1516, 0.007, 2, 0.33, 0.8333, 243, 3, 1, 0, 0, 0, 0, 3], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " output.append(u'SelectFilter.init(\"id_%s\", \"%s\", %s, \"%s\"); });</script>\\n' % \\\n (name, self.verbose_name.replace('\"', '\\\\\"'), int(self.is_stacked), settings.ADMIN_MEDIA_PREFIX))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L45_C8", "label": "return", "type": "return", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "vector": [13, 2, 0.1568, 0.0035, 2, 0.33, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u''.join(output))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L47_C0", "label": "AdminDateWidget", "type": "class", "loc": [47, 53], "level": 0, "parent": null, "vector": [3, 0, 0.1742, 0.0244, 0, 0.66, 0.5, 413, 0, 1, 0, 0, 956, 0, 2], "semantic": {"name": "AdminDateWidget", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminDateWidget(forms.DateInput):\n class Media:\n js = (settings.ADMIN_MEDIA_PREFIX + \"js/calendar.js\",\n settings.ADMIN_MEDIA_PREFIX + \"js/admin/DateTimeShortcuts.js\")\n\n def __init__(self, attrs={}, format=None):\n super(AdminDateWidget, self).__init__(attrs={'class': 'vDateField', 'size': '10'}, format=format)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L48_C4", "label": "Media", "type": "class", "loc": [48, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L47_C0", "vector": [3, 1, 0.1707, 0.0105, 1, 0.44, 0.0, 185, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "Media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Media:\n js = (settings.ADMIN_MEDIA_PREFIX + \"js/calendar.js\",\n settings.ADMIN_MEDIA_PREFIX + \"js/admin/DateTimeShortcuts.js\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L49_C8", "label": "js =", "type": "assigned_variable", "loc": [49, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L48_C4", "vector": [14, 2, 0.1725, 0.007, 2, 0.28, 0.0, 62, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "js", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " js = (settings.ADMIN_MEDIA_PREFIX + \"js/calendar.js\",\n settings.ADMIN_MEDIA_PREFIX + \"js/admin/DateTimeShortcuts.js\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L52_C4", "label": "__init__", "type": "function", "loc": [52, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L47_C0", "vector": [2, 1, 0.1829, 0.007, 1, 0.44, 1.0, 555, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "attrs", "format"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, attrs={}, format=None):\n super(AdminDateWidget, self).__init__(attrs={'class': 'vDateField', 'size': '10'}, format=format)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L53_C8", "label": "__init__()", "type": "expression", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L52_C4", "vector": [8, 2, 0.1847, 0.0035, 2, 0.31, 0.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(AdminDateWidget, self).__init__(attrs={'class': 'vDateField', 'size': '10'}, format=format)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L55_C0", "label": "AdminTimeWidget", "type": "class", "loc": [55, 61], "level": 0, "parent": null, "vector": [3, 0, 0.2021, 0.0244, 0, 0.66, 0.5385, 462, 0, 1, 0, 0, 164, 0, 2], "semantic": {"name": "AdminTimeWidget", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminTimeWidget(forms.TimeInput):\n class Media:\n js = (settings.ADMIN_MEDIA_PREFIX + \"js/calendar.js\",\n settings.ADMIN_MEDIA_PREFIX + \"js/admin/DateTimeShortcuts.js\")\n\n def __init__(self, attrs={}, format=None):\n super(AdminTimeWidget, self).__init__(attrs={'class': 'vTimeField', 'size': '8'}, format=format)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L56_C4", "label": "Media", "type": "class", "loc": [56, 58], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L55_C0", "vector": [3, 1, 0.1986, 0.0105, 1, 0.33, 0.0, 185, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "Media", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Media:\n js = (settings.ADMIN_MEDIA_PREFIX + \"js/calendar.js\",\n settings.ADMIN_MEDIA_PREFIX + \"js/admin/DateTimeShortcuts.js\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L57_C8", "label": "js =", "type": "assigned_variable", "loc": [57, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L56_C4", "vector": [14, 2, 0.2003, 0.007, 2, 0.28, 0.0, 62, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "js", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " js = (settings.ADMIN_MEDIA_PREFIX + \"js/calendar.js\",\n settings.ADMIN_MEDIA_PREFIX + \"js/admin/DateTimeShortcuts.js\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L60_C4", "label": "__init__", "type": "function", "loc": [60, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L55_C0", "vector": [2, 1, 0.2108, 0.007, 1, 0.33, 1.0, 555, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "attrs", "format"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, attrs={}, format=None):\n super(AdminTimeWidget, self).__init__(attrs={'class': 'vTimeField', 'size': '8'}, format=format)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L61_C8", "label": "__init__()", "type": "expression", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L60_C4", "vector": [8, 2, 0.2125, 0.0035, 2, 0.74, 0.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(AdminTimeWidget, self).__init__(attrs={'class': 'vTimeField', 'size': '8'}, format=format)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L63_C0", "label": "AdminSplitDateTime", "type": "class", "loc": [63, 75], "level": 0, "parent": null, "vector": [3, 0, 0.2404, 0.0453, 0, 0.66, 0.5769, 416, 0, 2, 0, 0, 708, 0, 4], "semantic": {"name": "AdminSplitDateTime", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminSplitDateTime(forms.SplitDateTimeWidget):\n \"\"\"\n A SplitDateTime Widget that has some admin-specific styling.\n \"\"\"\n def __init__(self, attrs=None):\n widgets = [AdminDateWidget, AdminTimeWidget]\n # Note that we're calling MultiWidget, not SplitDateTimeWidget, because\n # we want to define widgets."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L64_C4", "label": "expression", "type": "expression", "loc": [64, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L63_C0", "vector": [8, 1, 0.2265, 0.0105, 1, 0.93, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A SplitDateTime Widget that has some admin-specific styling.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L67_C4", "label": "__init__", "type": "function", "loc": [67, 71], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L63_C0", "vector": [2, 1, 0.2404, 0.0174, 1, 0.93, 0.5, 555, 0, 2, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "attrs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, attrs=None):\n widgets = [AdminDateWidget, AdminTimeWidget]\n # Note that we're calling MultiWidget, not SplitDateTimeWidget, because\n # we want to define widgets.\n forms.MultiWidget.__init__(self, widgets, attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L68_C8", "label": "widgets =", "type": "assigned_variable", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L67_C4", "vector": [14, 2, 0.2369, 0.0035, 2, 0.35, 0.0, 178, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "widgets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " widgets = [AdminDateWidget, AdminTimeWidget]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L71_C8", "label": "__init__()", "type": "expression", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L67_C4", "vector": [8, 2, 0.2474, 0.0035, 2, 0.35, 1.0, 555, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " forms.MultiWidget.__init__(self, widgets, attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L73_C4", "label": "format_output", "type": "function", "loc": [73, 75], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L63_C0", "vector": [2, 1, 0.2578, 0.0105, 1, 0.93, 1.0, 417, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "format_output", "arg_names": ["self", "rendered_widgets"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def format_output(self, rendered_widgets):\n return mark_safe(u'<p class=\"datetime\">%s %s<br />%s %s</p>' % \\\n (_('Date:'), rendered_widgets[0], _('Time:'), rendered_widgets[1]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L74_C8", "label": "return", "type": "return", "loc": [74, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L73_C4", "vector": [13, 2, 0.2596, 0.007, 2, 0.54, 0.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u'<p class=\"datetime\">%s %s<br />%s %s</p>' % \\\n (_('Date:'), rendered_widgets[0], _('Time:'), rendered_widgets[1]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L77_C0", "label": "AdminRadioFieldRenderer", "type": "class", "loc": [77, 83], "level": 0, "parent": null, "vector": [3, 0, 0.2787, 0.0244, 0, 0.66, 0.6154, 872, 0, 1, 0, 0, 556, 0, 4], "semantic": {"name": "AdminRadioFieldRenderer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminRadioFieldRenderer(RadioFieldRenderer):\n def render(self):\n \"\"\"Outputs a <ul> for this set of radio fields.\"\"\"\n return mark_safe(u'<ul%s>\\n%s\\n</ul>' % (\n flatatt(self.attrs),\n u'\\n'.join([u'<li>%s</li>' % force_unicode(w) for w in self]))\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L78_C4", "label": "render", "type": "function", "loc": [78, 83], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L77_C0", "vector": [2, 1, 0.2805, 0.0209, 1, 0.59, 0.0, 24, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "render", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self):\n \"\"\"Outputs a <ul> for this set of radio fields.\"\"\"\n return mark_safe(u'<ul%s>\\n%s\\n</ul>' % (\n flatatt(self.attrs),\n u'\\n'.join([u'<li>%s</li>' % force_unicode(w) for w in self]))\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L79_C8", "label": "expression", "type": "expression", "loc": [79, 79], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L78_C4", "vector": [8, 2, 0.2753, 0.0035, 2, 0.29, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Outputs a <ul> for this set of radio fields.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L80_C8", "label": "return", "type": "return", "loc": [80, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L78_C4", "vector": [13, 2, 0.284, 0.0139, 2, 0.29, 1.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u'<ul%s>\\n%s\\n</ul>' % (\n flatatt(self.attrs),\n u'\\n'.join([u'<li>%s</li>' % force_unicode(w) for w in self]))\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L85_C0", "label": "AdminRadioSelect", "type": "class", "loc": [85, 86], "level": 0, "parent": null, "vector": [3, 0, 0.2979, 0.007, 0, 0.66, 0.6538, 166, 0, 0, 0, 0, 540, 0, 0], "semantic": {"name": "AdminRadioSelect", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminRadioSelect(forms.RadioSelect):\n renderer = AdminRadioFieldRenderer"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L86_C4", "label": "renderer =", "type": "assigned_variable", "loc": [86, 86], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L85_C0", "vector": [14, 1, 0.2997, 0.0035, 1, 0.31, 0.0, 428, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "renderer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " renderer = AdminRadioFieldRenderer"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L88_C0", "label": "AdminFileWidget", "type": "class", "loc": [88, 92], "level": 0, "parent": null, "vector": [3, 0, 0.3136, 0.0174, 0, 0.66, 0.6923, 26, 0, 0, 0, 0, 105, 0, 0], "semantic": {"name": "AdminFileWidget", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminFileWidget(forms.ClearableFileInput):\n template_with_initial = (u'<p class=\"file-upload\">%s</p>'\n % forms.ClearableFileInput.template_with_initial)\n template_with_clear = (u'<span class=\"clearable-file-input\">%s</span>'\n % forms.ClearableFileInput.template_with_clear)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L89_C4", "label": "template_with_initial =", "type": "assigned_variable", "loc": [89, 90], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L88_C0", "vector": [14, 1, 0.3118, 0.007, 1, 0.95, 0.0, 407, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "template_with_initial", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " template_with_initial = (u'<p class=\"file-upload\">%s</p>'\n % forms.ClearableFileInput.template_with_initial)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L91_C4", "label": "template_with_clear =", "type": "assigned_variable", "loc": [91, 92], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L88_C0", "vector": [14, 1, 0.3188, 0.007, 1, 0.95, 1.0, 704, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "template_with_clear", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " template_with_clear = (u'<span class=\"clearable-file-input\">%s</span>'\n % forms.ClearableFileInput.template_with_clear)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "label": "ForeignKeyRawIdWidget", "type": "class", "loc": [95, 151], "level": 0, "parent": null, "vector": [3, 0, 0.4286, 0.1986, 0, 0.66, 0.7308, 554, 0, 5, 0, 0, 151, 0, 32], "semantic": {"name": "ForeignKeyRawIdWidget", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ForeignKeyRawIdWidget(forms.TextInput):\n \"\"\"\n A Widget for displaying ForeignKeys in the \"raw_id\" interface rather than\n in a <select> box.\n \"\"\"\n def __init__(self, rel, attrs=None, using=None):\n self.rel = rel\n self.db = using"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L96_C4", "label": "expression", "type": "expression", "loc": [96, 99], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "vector": [8, 1, 0.3397, 0.0139, 1, 0.54, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A Widget for displaying ForeignKeys in the \"raw_id\" interface rather than\n in a <select> box.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L100_C4", "label": "__init__", "type": "function", "loc": [100, 103], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "vector": [2, 1, 0.3537, 0.0139, 1, 0.54, 0.2, 555, 0, 4, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "rel", "attrs", "using"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, rel, attrs=None, using=None):\n self.rel = rel\n self.db = using\n super(ForeignKeyRawIdWidget, self).__init__(attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L101_C8", "label": "self.rel =", "type": "assigned_variable", "loc": [101, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L100_C4", "vector": [14, 2, 0.3519, 0.0035, 2, 0.32, 0.0, 793, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.rel", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.rel = rel"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L102_C8", "label": "self.db =", "type": "assigned_variable", "loc": [102, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L100_C4", "vector": [14, 2, 0.3554, 0.0035, 2, 0.32, 0.5, 990, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.db", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.db = using"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L103_C8", "label": "__init__()", "type": "expression", "loc": [103, 103], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L100_C4", "vector": [8, 2, 0.3589, 0.0035, 2, 0.32, 1.0, 555, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(ForeignKeyRawIdWidget, self).__init__(attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "label": "render", "type": "function", "loc": [105, 124], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "vector": [2, 1, 0.399, 0.0697, 1, 0.54, 0.4, 24, 0, 4, 1, 0, 0, 0, 13], "semantic": {"name": "render", "arg_names": ["self", "name", "value", "attrs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self, name, value, attrs=None):\n if attrs is None:\n attrs = {}\n related_url = '../../../%s/%s/' % (self.rel.to._meta.app_label, self.rel.to._meta.object_name.lower())\n params = self.url_parameters()\n if params:\n url = '?' + '&'.join(['%s=%s' % (k, v) for k, v in params.items()])\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L106_C8", "label": "if", "type": "if", "loc": [106, 107], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "vector": [4, 2, 0.3711, 0.007, 2, 0.61, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if attrs is None:\n attrs = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L107_C12", "label": "attrs =", "type": "assigned_variable", "loc": [107, 107], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L106_C8", "vector": [14, 3, 0.3728, 0.0035, 3, 0.26, 0.0, 251, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L108_C8", "label": "related_url =", "type": "assigned_variable", "loc": [108, 108], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "vector": [14, 2, 0.3763, 0.0035, 2, 0.61, 0.1111, 258, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "related_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " related_url = '../../../%s/%s/' % (self.rel.to._meta.app_label, self.rel.to._meta.object_name.lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L109_C8", "label": "params = url_parameters()", "type": "assigned_variable", "loc": [109, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "vector": [14, 2, 0.3798, 0.0035, 2, 0.61, 0.2222, 206, 3, 0, 0, 0, 207, 10, 1], "semantic": {"name": "params", "arg_names": [], "import_names": [], "rhs_call_name": "url_parameters", "annotation": ""}, "snippet": " params = self.url_parameters()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L110_C8", "label": "if", "type": "if", "loc": [110, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "vector": [4, 2, 0.3885, 0.0139, 2, 0.61, 0.3333, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if params:\n url = '?' + '&'.join(['%s=%s' % (k, v) for k, v in params.items()])\n else:\n url = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L111_C12", "label": "url =", "type": "assigned_variable", "loc": [111, 111], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L110_C8", "vector": [14, 3, 0.3868, 0.0035, 3, 0.57, 0.0, 789, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " url = '?' + '&'.join(['%s=%s' % (k, v) for k, v in params.items()])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L113_C12", "label": "url =", "type": "assigned_variable", "loc": [113, 113], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L110_C8", "vector": [14, 3, 0.3937, 0.0035, 3, 0.57, 1.0, 789, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " url = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L114_C8", "label": "if", "type": "if", "loc": [114, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "vector": [4, 2, 0.399, 0.007, 2, 0.61, 0.4444, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if \"class\" not in attrs:\n attrs['class'] = 'vForeignKeyRawIdAdminField' # The JavaScript looks for this hook."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L115_C12", "label": "assign", "type": "assigned_variable", "loc": [115, 115], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L114_C8", "vector": [14, 3, 0.4007, 0.0035, 3, 0.05, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs['class'] = 'vForeignKeyRawIdAdminField' # The JavaScript looks for this hook."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L116_C8", "label": "output =", "type": "assigned_variable", "loc": [116, 116], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "vector": [14, 2, 0.4042, 0.0035, 2, 0.61, 0.5556, 886, 0, 0, 0, 0, 0, 5, 2], "semantic": {"name": "output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output = [super(ForeignKeyRawIdWidget, self).render(name, value, attrs)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L119_C8", "label": "append()", "type": "expression", "loc": [119, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "vector": [8, 2, 0.4164, 0.007, 2, 0.61, 0.6667, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " output.append('<a href=\"%s%s\" class=\"related-lookup\" id=\"lookup_id_%s\" onclick=\"return showRelatedObjectLookupPopup(this);\"> ' % \\\n (related_url, url, name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L121_C8", "label": "append()", "type": "expression", "loc": [121, 121], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "vector": [8, 2, 0.4216, 0.0035, 2, 0.61, 0.7778, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " output.append('<img src=\"%simg/admin/selector-search.gif\" width=\"16\" height=\"16\" alt=\"%s\" /></a>' % (settings.ADMIN_MEDIA_PREFIX, _('Lookup')))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L122_C8", "label": "if", "type": "if", "loc": [122, 123], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "vector": [4, 2, 0.4268, 0.007, 2, 0.61, 0.8889, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value:\n output.append(self.label_for_value(value))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L123_C12", "label": "append()", "type": "expression", "loc": [123, 123], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L122_C8", "vector": [8, 3, 0.4286, 0.0035, 3, 0.32, 0.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " output.append(self.label_for_value(value))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L124_C8", "label": "return", "type": "return", "loc": [124, 124], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "vector": [13, 2, 0.4321, 0.0035, 2, 0.61, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u''.join(output))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L126_C4", "label": "base_url_parameters", "type": "function", "loc": [126, 137], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "vector": [2, 1, 0.4582, 0.0418, 1, 0.54, 0.6, 523, 0, 1, 1, 0, 0, 0, 9], "semantic": {"name": "base_url_parameters", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def base_url_parameters(self):\n params = {}\n if self.rel.limit_choices_to and hasattr(self.rel.limit_choices_to, 'items'):\n items = []\n for k, v in self.rel.limit_choices_to.items():\n if isinstance(v, list):\n v = ','.join([str(x) for x in v])\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L127_C8", "label": "params =", "type": "assigned_variable", "loc": [127, 127], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L126_C4", "vector": [14, 2, 0.4425, 0.0035, 2, 0.65, 0.0, 206, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "params", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " params = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L128_C8", "label": "if", "type": "if", "loc": [128, 136], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L126_C4", "vector": [4, 2, 0.4599, 0.0314, 2, 0.65, 0.5, 0, 0, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.rel.limit_choices_to and hasattr(self.rel.limit_choices_to, 'items'):\n items = []\n for k, v in self.rel.limit_choices_to.items():\n if isinstance(v, list):\n v = ','.join([str(x) for x in v])\n else:\n v = str(v)\n items.append((k, v))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L129_C12", "label": "items =", "type": "assigned_variable", "loc": [129, 129], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L128_C8", "vector": [14, 3, 0.4495, 0.0035, 3, 0.76, 0.0, 339, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "items", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " items = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:For_L130_C12", "label": "for k, v", "type": "for", "loc": [130, 135], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L128_C8", "vector": [6, 3, 0.4617, 0.0209, 3, 0.76, 0.5, 867, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "k, v", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for k, v in self.rel.limit_choices_to.items():\n if isinstance(v, list):\n v = ','.join([str(x) for x in v])\n else:\n v = str(v)\n items.append((k, v))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L131_C16", "label": "if", "type": "if", "loc": [131, 134], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:For_L130_C12", "vector": [4, 4, 0.4617, 0.0139, 4, 0.01, 0.0, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(v, list):\n v = ','.join([str(x) for x in v])\n else:\n v = str(v)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L132_C20", "label": "v = join()", "type": "assigned_variable", "loc": [132, 132], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L131_C16", "vector": [14, 5, 0.4599, 0.0035, 5, 0.87, 0.0, 553, 3, 1, 0, 0, 933, 10, 2], "semantic": {"name": "v", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " v = ','.join([str(x) for x in v])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L134_C20", "label": "v = str()", "type": "assigned_variable", "loc": [134, 134], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L131_C16", "vector": [14, 5, 0.4669, 0.0035, 5, 0.87, 1.0, 553, 3, 1, 0, 0, 52, 10, 1], "semantic": {"name": "v", "arg_names": [], "import_names": [], "rhs_call_name": "str", "annotation": ""}, "snippet": " v = str(v)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L135_C16", "label": "append()", "type": "expression", "loc": [135, 135], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:For_L130_C12", "vector": [8, 4, 0.4704, 0.0035, 4, 0.01, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " items.append((k, v))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L136_C12", "label": "update()", "type": "expression", "loc": [136, 136], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L128_C8", "vector": [8, 3, 0.4739, 0.0035, 3, 0.76, 1.0, 637, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " params.update(dict(items))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L137_C8", "label": "return", "type": "return", "loc": [137, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L126_C4", "vector": [13, 2, 0.4774, 0.0035, 2, 0.65, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return params"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L139_C4", "label": "url_parameters", "type": "function", "loc": [139, 143], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "vector": [2, 1, 0.4913, 0.0174, 1, 0.54, 0.8, 207, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "url_parameters", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def url_parameters(self):\n from django.contrib.admin.views.main import TO_FIELD_VAR\n params = self.base_url_parameters()\n params.update({TO_FIELD_VAR: self.rel.get_related_field().name})\n return params"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ImportFrom_L140_C8", "label": "from django.contrib.admin.views.main import TO_FIELD_VAR", "type": "import", "loc": [140, 140], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L139_C4", "vector": [1, 2, 0.4878, 0.0035, 2, 0.61, 0.0, 696, 0, 1, 0, 0, 696, 0, 0], "semantic": {"name": "django.contrib.admin.views.main", "arg_names": [], "import_names": ["TO_FIELD_VAR"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.admin.views.main import TO_FIELD_VAR"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L141_C8", "label": "params = base_url_parameters()", "type": "assigned_variable", "loc": [141, 141], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L139_C4", "vector": [14, 2, 0.4913, 0.0035, 2, 0.61, 0.3333, 206, 3, 0, 0, 0, 523, 10, 1], "semantic": {"name": "params", "arg_names": [], "import_names": [], "rhs_call_name": "base_url_parameters", "annotation": ""}, "snippet": " params = self.base_url_parameters()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L142_C8", "label": "update()", "type": "expression", "loc": [142, 142], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L139_C4", "vector": [8, 2, 0.4948, 0.0035, 2, 0.61, 0.6667, 637, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " params.update({TO_FIELD_VAR: self.rel.get_related_field().name})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L143_C8", "label": "return", "type": "return", "loc": [143, 143], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L139_C4", "vector": [13, 2, 0.4983, 0.0035, 2, 0.61, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return params"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L145_C4", "label": "label_for_value", "type": "function", "loc": [145, 151], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "vector": [2, 1, 0.5157, 0.0244, 1, 0.54, 1.0, 205, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "label_for_value", "arg_names": ["self", "value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def label_for_value(self, value):\n key = self.rel.get_related_field().name\n try:\n obj = self.rel.to._default_manager.using(self.db).get(**{key: value})\n return ' <strong>%s</strong>' % escape(truncate_words(obj, 14))\n except (ValueError, self.rel.to.DoesNotExist):\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L146_C8", "label": "key =", "type": "assigned_variable", "loc": [146, 146], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L145_C4", "vector": [14, 2, 0.5087, 0.0035, 2, 0.24, 0.0, 230, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "key", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " key = self.rel.get_related_field().name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L147_C8", "label": "try", "type": "try", "loc": [147, 151], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L145_C4", "vector": [7, 2, 0.5192, 0.0174, 2, 0.24, 1.0, 0, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n obj = self.rel.to._default_manager.using(self.db).get(**{key: value})\n return ' <strong>%s</strong>' % escape(truncate_words(obj, 14))\n except (ValueError, self.rel.to.DoesNotExist):\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L148_C12", "label": "obj = get()", "type": "assigned_variable", "loc": [148, 148], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L147_C8", "vector": [14, 3, 0.5157, 0.0035, 3, 0.39, 0.0, 505, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " obj = self.rel.to._default_manager.using(self.db).get(**{key: value})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L149_C12", "label": "return", "type": "return", "loc": [149, 149], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L147_C8", "vector": [13, 3, 0.5192, 0.0035, 3, 0.39, 1.0, 0, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ' <strong>%s</strong>' % escape(truncate_words(obj, 14))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L151_C12", "label": "return", "type": "return", "loc": [151, 151], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L147_C8", "vector": [13, 3, 0.5261, 0.0035, 3, 0.39, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "label": "ManyToManyRawIdWidget", "type": "class", "loc": [153, 189], "level": 0, "parent": null, "vector": [3, 0, 0.5958, 0.1289, 0, 0.66, 0.7692, 602, 0, 5, 0, 0, 554, 0, 12], "semantic": {"name": "ManyToManyRawIdWidget", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):\n \"\"\"\n A Widget for displaying ManyToMany ids in the \"raw_id\" interface rather than\n in a <select multiple> box.\n \"\"\"\n def render(self, name, value, attrs=None):\n if attrs is None:\n attrs = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L154_C4", "label": "expression", "type": "expression", "loc": [154, 157], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "vector": [8, 1, 0.5418, 0.0139, 1, 0.6, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A Widget for displaying ManyToMany ids in the \"raw_id\" interface rather than\n in a <select multiple> box.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L158_C4", "label": "render", "type": "function", "loc": [158, 166], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "vector": [2, 1, 0.5645, 0.0314, 1, 0.6, 0.2, 24, 0, 4, 1, 0, 0, 0, 4], "semantic": {"name": "render", "arg_names": ["self", "name", "value", "attrs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self, name, value, attrs=None):\n if attrs is None:\n attrs = {}\n attrs['class'] = 'vManyToManyRawIdAdminField'\n if value:\n value = ','.join([force_unicode(v) for v in value])\n else:\n value = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L159_C8", "label": "if", "type": "if", "loc": [159, 160], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L158_C4", "vector": [4, 2, 0.5557, 0.007, 2, 0.26, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if attrs is None:\n attrs = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L160_C12", "label": "attrs =", "type": "assigned_variable", "loc": [160, 160], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L159_C8", "vector": [14, 3, 0.5575, 0.0035, 3, 0.08, 0.0, 251, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L161_C8", "label": "assign", "type": "assigned_variable", "loc": [161, 161], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L158_C4", "vector": [14, 2, 0.561, 0.0035, 2, 0.26, 0.3333, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs['class'] = 'vManyToManyRawIdAdminField'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L162_C8", "label": "if", "type": "if", "loc": [162, 165], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L158_C4", "vector": [4, 2, 0.5697, 0.0139, 2, 0.26, 0.6667, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value:\n value = ','.join([force_unicode(v) for v in value])\n else:\n value = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L163_C12", "label": "value = join()", "type": "assigned_variable", "loc": [163, 163], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L162_C8", "vector": [14, 3, 0.5679, 0.0035, 3, 0.86, 0.0, 441, 3, 1, 0, 0, 933, 10, 2], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " value = ','.join([force_unicode(v) for v in value])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L165_C12", "label": "value =", "type": "assigned_variable", "loc": [165, 165], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L162_C8", "vector": [14, 3, 0.5749, 0.0035, 3, 0.86, 1.0, 441, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " value = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L166_C8", "label": "return", "type": "return", "loc": [166, 166], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L158_C4", "vector": [13, 2, 0.5784, 0.0035, 2, 0.26, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return super(ManyToManyRawIdWidget, self).render(name, value, attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L168_C4", "label": "url_parameters", "type": "function", "loc": [168, 169], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "vector": [2, 1, 0.5871, 0.007, 1, 0.6, 0.4, 207, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "url_parameters", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def url_parameters(self):\n return self.base_url_parameters()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L169_C8", "label": "return", "type": "return", "loc": [169, 169], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L168_C4", "vector": [13, 2, 0.5889, 0.0035, 2, 0.32, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.base_url_parameters()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L171_C4", "label": "label_for_value", "type": "function", "loc": [171, 172], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "vector": [2, 1, 0.5976, 0.007, 1, 0.6, 0.6, 205, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "label_for_value", "arg_names": ["self", "value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def label_for_value(self, value):\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L172_C8", "label": "return", "type": "return", "loc": [172, 172], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L171_C4", "vector": [13, 2, 0.5993, 0.0035, 2, 0.15, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L174_C4", "label": "value_from_datadict", "type": "function", "loc": [174, 177], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "vector": [2, 1, 0.6115, 0.0139, 1, 0.6, 0.8, 272, 0, 4, 1, 0, 0, 0, 2], "semantic": {"name": "value_from_datadict", "arg_names": ["self", "data", "files", "name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def value_from_datadict(self, data, files, name):\n value = data.get(name)\n if value:\n return value.split(',')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L175_C8", "label": "value = get()", "type": "assigned_variable", "loc": [175, 175], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L174_C4", "vector": [14, 2, 0.6098, 0.0035, 2, 0.03, 0.0, 441, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " value = data.get(name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L176_C8", "label": "if", "type": "if", "loc": [176, 177], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L174_C4", "vector": [4, 2, 0.615, 0.007, 2, 0.03, 1.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value:\n return value.split(',')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L177_C12", "label": "return", "type": "return", "loc": [177, 177], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L176_C8", "vector": [13, 3, 0.6167, 0.0035, 3, 0.17, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return value.split(',')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L179_C4", "label": "_has_changed", "type": "function", "loc": [179, 189], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "vector": [2, 1, 0.6411, 0.0383, 1, 0.6, 1.0, 719, 0, 3, 1, 0, 0, 0, 5], "semantic": {"name": "_has_changed", "arg_names": ["self", "initial", "data"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _has_changed(self, initial, data):\n if initial is None:\n initial = []\n if data is None:\n data = []\n if len(initial) != len(data):\n return True\n for pk1, pk2 in zip(initial, data):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L180_C8", "label": "if", "type": "if", "loc": [180, 181], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L179_C4", "vector": [4, 2, 0.6289, 0.007, 2, 0.28, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if initial is None:\n initial = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L181_C12", "label": "initial =", "type": "assigned_variable", "loc": [181, 181], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L180_C8", "vector": [14, 3, 0.6307, 0.0035, 3, 0.26, 0.0, 838, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "initial", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " initial = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L182_C8", "label": "if", "type": "if", "loc": [182, 183], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L179_C4", "vector": [4, 2, 0.6359, 0.007, 2, 0.28, 0.25, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if data is None:\n data = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L183_C12", "label": "data =", "type": "assigned_variable", "loc": [183, 183], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L182_C8", "vector": [14, 3, 0.6376, 0.0035, 3, 0.98, 0.0, 929, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L184_C8", "label": "if", "type": "if", "loc": [184, 185], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L179_C4", "vector": [4, 2, 0.6429, 0.007, 2, 0.28, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(initial) != len(data):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L185_C12", "label": "return", "type": "return", "loc": [185, 185], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L184_C8", "vector": [13, 3, 0.6446, 0.0035, 3, 0.42, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:For_L186_C8", "label": "for pk1, pk2", "type": "for", "loc": [186, 188], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L179_C4", "vector": [6, 2, 0.6516, 0.0105, 2, 0.28, 0.75, 295, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "pk1, pk2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for pk1, pk2 in zip(initial, data):\n if force_unicode(pk1) != force_unicode(pk2):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L187_C12", "label": "if", "type": "if", "loc": [187, 188], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:For_L186_C8", "vector": [4, 3, 0.6533, 0.007, 3, 0.68, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if force_unicode(pk1) != force_unicode(pk2):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L188_C16", "label": "return", "type": "return", "loc": [188, 188], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L187_C12", "vector": [13, 4, 0.6551, 0.0035, 4, 0.87, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L189_C8", "label": "return", "type": "return", "loc": [189, 189], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L179_C4", "vector": [13, 2, 0.6585, 0.0035, 2, 0.28, 1.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "label": "RelatedFieldWidgetWrapper", "type": "class", "loc": [191, 252], "level": 0, "parent": null, "vector": [3, 0, 0.7718, 0.216, 0, 0.66, 0.8077, 895, 0, 8, 0, 0, 866, 0, 17], "semantic": {"name": "RelatedFieldWidgetWrapper", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class RelatedFieldWidgetWrapper(forms.Widget):\n \"\"\"\n This class is a wrapper to a given widget to add the add icon for the\n admin interface.\n \"\"\"\n def __init__(self, widget, rel, admin_site, can_add_related=None):\n self.is_hidden = widget.is_hidden\n self.needs_multipart_form = widget.needs_multipart_form"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L192_C4", "label": "expression", "type": "expression", "loc": [192, 195], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "vector": [8, 1, 0.6742, 0.0139, 1, 0.25, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This class is a wrapper to a given widget to add the add icon for the\n admin interface.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "label": "__init__", "type": "function", "loc": [196, 209], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "vector": [2, 1, 0.7056, 0.0488, 1, 0.25, 0.1111, 555, 0, 5, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "widget", "rel", "admin_site", "can_add_related"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, widget, rel, admin_site, can_add_related=None):\n self.is_hidden = widget.is_hidden\n self.needs_multipart_form = widget.needs_multipart_form\n self.attrs = widget.attrs\n self.choices = widget.choices\n self.widget = widget\n self.rel = rel\n # Backwards compatible check for whether a user can add related"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L197_C8", "label": "self.is_hidden =", "type": "assigned_variable", "loc": [197, 197], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "vector": [14, 2, 0.6864, 0.0035, 2, 0.01, 0.0, 738, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.is_hidden", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.is_hidden = widget.is_hidden"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L198_C8", "label": "self.needs_multipart_form =", "type": "assigned_variable", "loc": [198, 198], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "vector": [14, 2, 0.6899, 0.0035, 2, 0.01, 0.125, 467, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.needs_multipart_form", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.needs_multipart_form = widget.needs_multipart_form"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L199_C8", "label": "self.attrs =", "type": "assigned_variable", "loc": [199, 199], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "vector": [14, 2, 0.6934, 0.0035, 2, 0.01, 0.25, 793, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.attrs = widget.attrs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L200_C8", "label": "self.choices =", "type": "assigned_variable", "loc": [200, 200], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "vector": [14, 2, 0.6969, 0.0035, 2, 0.01, 0.375, 259, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.choices", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.choices = widget.choices"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L201_C8", "label": "self.widget =", "type": "assigned_variable", "loc": [201, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "vector": [14, 2, 0.7003, 0.0035, 2, 0.01, 0.5, 102, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.widget", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.widget = widget"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L202_C8", "label": "self.rel =", "type": "assigned_variable", "loc": [202, 202], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "vector": [14, 2, 0.7038, 0.0035, 2, 0.01, 0.625, 793, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.rel", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.rel = rel"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L205_C8", "label": "if", "type": "if", "loc": [205, 206], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "vector": [4, 2, 0.716, 0.007, 2, 0.01, 0.75, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if can_add_related is None:\n can_add_related = rel_to in self.admin_site._registry"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L206_C12", "label": "can_add_related =", "type": "assigned_variable", "loc": [206, 206], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L205_C8", "vector": [14, 3, 0.7178, 0.0035, 3, 0.95, 0.0, 687, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "can_add_related", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " can_add_related = rel_to in self.admin_site._registry"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L207_C8", "label": "self.can_add_related =", "type": "assigned_variable", "loc": [207, 207], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "vector": [14, 2, 0.7213, 0.0035, 2, 0.01, 0.875, 253, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.can_add_related", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.can_add_related = can_add_related"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L209_C8", "label": "self.admin_site =", "type": "assigned_variable", "loc": [209, 209], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "vector": [14, 2, 0.7282, 0.0035, 2, 0.01, 1.0, 905, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.admin_site", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.admin_site = admin_site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L211_C4", "label": "__deepcopy__", "type": "function", "loc": [211, 216], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "vector": [2, 1, 0.7439, 0.0209, 1, 0.25, 0.2222, 652, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "__deepcopy__", "arg_names": ["self", "memo"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __deepcopy__(self, memo):\n obj = copy.copy(self)\n obj.widget = copy.deepcopy(self.widget, memo)\n obj.attrs = self.widget.attrs\n memo[id(self)] = obj\n return obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L212_C8", "label": "obj = copy()", "type": "assigned_variable", "loc": [212, 212], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L211_C4", "vector": [14, 2, 0.7387, 0.0035, 2, 0.58, 0.0, 505, 3, 1, 0, 0, 739, 10, 1], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "copy", "annotation": ""}, "snippet": " obj = copy.copy(self)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L213_C8", "label": "obj.widget = deepcopy()", "type": "assigned_variable", "loc": [213, 213], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L211_C4", "vector": [14, 2, 0.7422, 0.0035, 2, 0.58, 0.25, 125, 3, 2, 0, 0, 44, 10, 1], "semantic": {"name": "obj.widget", "arg_names": [], "import_names": [], "rhs_call_name": "deepcopy", "annotation": ""}, "snippet": " obj.widget = copy.deepcopy(self.widget, memo)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L214_C8", "label": "obj.attrs =", "type": "assigned_variable", "loc": [214, 214], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L211_C4", "vector": [14, 2, 0.7456, 0.0035, 2, 0.58, 0.5, 968, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "obj.attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " obj.attrs = self.widget.attrs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L215_C8", "label": "assign", "type": "assigned_variable", "loc": [215, 215], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L211_C4", "vector": [14, 2, 0.7491, 0.0035, 2, 0.58, 0.75, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " memo[id(self)] = obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L216_C8", "label": "return", "type": "return", "loc": [216, 216], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L211_C4", "vector": [13, 2, 0.7526, 0.0035, 2, 0.58, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L218_C4", "label": "_media", "type": "function", "loc": [218, 219], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "vector": [2, 1, 0.7613, 0.007, 1, 0.25, 0.3333, 650, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "_media", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _media(self):\n return self.widget.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L219_C8", "label": "return", "type": "return", "loc": [219, 219], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L218_C4", "vector": [13, 2, 0.7631, 0.0035, 2, 0.62, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.widget.media"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L220_C4", "label": "media = property()", "type": "assigned_variable", "loc": [220, 220], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "vector": [14, 1, 0.7666, 0.0035, 1, 0.25, 0.4444, 317, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "media", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " media = property(_media)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "label": "render", "type": "function", "loc": [222, 238], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "vector": [2, 1, 0.8014, 0.0592, 1, 0.25, 0.5556, 24, 0, 5, 1, 0, 0, 0, 9], "semantic": {"name": "render", "arg_names": ["self", "name", "value", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self, name, value, *args, **kwargs):\n rel_to = self.rel.to\n info = (rel_to._meta.app_label, rel_to._meta.object_name.lower())\n try:\n related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name)\n except NoReverseMatch:\n info = (self.admin_site.root_path, rel_to._meta.app_label, rel_to._meta.object_name.lower())\n related_url = '%s%s/%s/add/' % info"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L223_C8", "label": "rel_to =", "type": "assigned_variable", "loc": [223, 223], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "vector": [14, 2, 0.777, 0.0035, 2, 0.62, 0.0, 213, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "rel_to", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " rel_to = self.rel.to"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L224_C8", "label": "info =", "type": "assigned_variable", "loc": [224, 224], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "vector": [14, 2, 0.7805, 0.0035, 2, 0.62, 0.1667, 730, 0, 0, 0, 0, 0, 8, 1], "semantic": {"name": "info", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " info = (rel_to._meta.app_label, rel_to._meta.object_name.lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L225_C8", "label": "try", "type": "try", "loc": [225, 229], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "vector": [7, 2, 0.7909, 0.0174, 2, 0.62, 0.3333, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name)\n except NoReverseMatch:\n info = (self.admin_site.root_path, rel_to._meta.app_label, rel_to._meta.object_name.lower())\n related_url = '%s%s/%s/add/' % info"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L226_C12", "label": "related_url = reverse()", "type": "assigned_variable", "loc": [226, 226], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L225_C8", "vector": [14, 3, 0.7875, 0.0035, 3, 0.92, 0.0, 258, 3, 2, 0, 0, 109, 10, 1], "semantic": {"name": "related_url", "arg_names": [], "import_names": [], "rhs_call_name": "reverse", "annotation": ""}, "snippet": " related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L228_C12", "label": "info =", "type": "assigned_variable", "loc": [228, 228], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L225_C8", "vector": [14, 3, 0.7944, 0.0035, 3, 0.92, 0.0, 730, 0, 0, 0, 0, 0, 8, 1], "semantic": {"name": "info", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " info = (self.admin_site.root_path, rel_to._meta.app_label, rel_to._meta.object_name.lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L229_C12", "label": "related_url =", "type": "assigned_variable", "loc": [229, 229], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L225_C8", "vector": [14, 3, 0.7979, 0.0035, 3, 0.92, 1.0, 258, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "related_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " related_url = '%s%s/%s/add/' % info"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L230_C8", "label": "self.widget.choices =", "type": "assigned_variable", "loc": [230, 230], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "vector": [14, 2, 0.8014, 0.0035, 2, 0.62, 0.5, 130, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.widget.choices", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.widget.choices = self.choices"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L231_C8", "label": "output =", "type": "assigned_variable", "loc": [231, 231], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "vector": [14, 2, 0.8049, 0.0035, 2, 0.62, 0.6667, 886, 0, 0, 0, 0, 0, 5, 1], "semantic": {"name": "output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output = [self.widget.render(name, value, *args, **kwargs)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L232_C8", "label": "if", "type": "if", "loc": [232, 237], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "vector": [4, 2, 0.8171, 0.0209, 2, 0.62, 0.8333, 0, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.can_add_related:\n # TODO: \"id_\" is hard-coded here. This should instead use the correct\n # API to determine the ID dynamically.\n output.append(u'<a href=\"%s\" class=\"add-another\" id=\"add_id_%s\" onclick=\"return showAddAnotherPopup(this);\"> ' % \\\n (related_url, name))\n output.append(u'<img src=\"%simg/admin/icon_addlink.gif\" width=\"10\" height=\"10\" alt=\"%s\"/></a>' % (settings.ADMIN_MEDIA_PREFIX, _('Add Another')))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L235_C12", "label": "append()", "type": "expression", "loc": [235, 236], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L232_C8", "vector": [8, 3, 0.8206, 0.007, 3, 0.89, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " output.append(u'<a href=\"%s\" class=\"add-another\" id=\"add_id_%s\" onclick=\"return showAddAnotherPopup(this);\"> ' % \\\n (related_url, name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L237_C12", "label": "append()", "type": "expression", "loc": [237, 237], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L232_C8", "vector": [8, 3, 0.8258, 0.0035, 3, 0.89, 1.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " output.append(u'<img src=\"%simg/admin/icon_addlink.gif\" width=\"10\" height=\"10\" alt=\"%s\"/></a>' % (settings.ADMIN_MEDIA_PREFIX, _('Add Another')))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L238_C8", "label": "return", "type": "return", "loc": [238, 238], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "vector": [13, 2, 0.8293, 0.0035, 2, 0.62, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u''.join(output))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L240_C4", "label": "build_attrs", "type": "function", "loc": [240, 243], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "vector": [2, 1, 0.8415, 0.0139, 1, 0.25, 0.6667, 588, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "build_attrs", "arg_names": ["self", "extra_attrs", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def build_attrs(self, extra_attrs=None, **kwargs):\n \"Helper function for building an attribute dictionary.\"\n self.attrs = self.widget.build_attrs(extra_attrs=None, **kwargs)\n return self.attrs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L241_C8", "label": "expression", "type": "expression", "loc": [241, 241], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L240_C4", "vector": [8, 2, 0.8397, 0.0035, 2, 0.01, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Helper function for building an attribute dictionary.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L242_C8", "label": "self.attrs = build_attrs()", "type": "assigned_variable", "loc": [242, 242], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L240_C4", "vector": [14, 2, 0.8432, 0.0035, 2, 0.01, 0.5, 793, 3, 2, 0, 0, 588, 10, 1], "semantic": {"name": "self.attrs", "arg_names": [], "import_names": [], "rhs_call_name": "build_attrs", "annotation": ""}, "snippet": " self.attrs = self.widget.build_attrs(extra_attrs=None, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L243_C8", "label": "return", "type": "return", "loc": [243, 243], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L240_C4", "vector": [13, 2, 0.8467, 0.0035, 2, 0.01, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.attrs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L245_C4", "label": "value_from_datadict", "type": "function", "loc": [245, 246], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "vector": [2, 1, 0.8554, 0.007, 1, 0.25, 0.7778, 272, 0, 4, 1, 0, 0, 0, 1], "semantic": {"name": "value_from_datadict", "arg_names": ["self", "data", "files", "name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def value_from_datadict(self, data, files, name):\n return self.widget.value_from_datadict(data, files, name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L246_C8", "label": "return", "type": "return", "loc": [246, 246], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L245_C4", "vector": [13, 2, 0.8571, 0.0035, 2, 0.3, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.widget.value_from_datadict(data, files, name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L248_C4", "label": "_has_changed", "type": "function", "loc": [248, 249], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "vector": [2, 1, 0.8659, 0.007, 1, 0.25, 0.8889, 719, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "_has_changed", "arg_names": ["self", "initial", "data"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _has_changed(self, initial, data):\n return self.widget._has_changed(initial, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L249_C8", "label": "return", "type": "return", "loc": [249, 249], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L248_C4", "vector": [13, 2, 0.8676, 0.0035, 2, 0.48, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.widget._has_changed(initial, data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L251_C4", "label": "id_for_label", "type": "function", "loc": [251, 252], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "vector": [2, 1, 0.8763, 0.007, 1, 0.25, 1.0, 952, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "id_for_label", "arg_names": ["self", "id_"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def id_for_label(self, id_):\n return self.widget.id_for_label(id_)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L252_C8", "label": "return", "type": "return", "loc": [252, 252], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L251_C4", "vector": [13, 2, 0.878, 0.0035, 2, 0.71, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.widget.id_for_label(id_)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L254_C0", "label": "AdminTextareaWidget", "type": "class", "loc": [254, 259], "level": 0, "parent": null, "vector": [3, 0, 0.8937, 0.0209, 0, 0.66, 0.8462, 824, 0, 1, 0, 0, 420, 0, 3], "semantic": {"name": "AdminTextareaWidget", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminTextareaWidget(forms.Textarea):\n def __init__(self, attrs=None):\n final_attrs = {'class': 'vLargeTextField'}\n if attrs is not None:\n final_attrs.update(attrs)\n super(AdminTextareaWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L255_C4", "label": "__init__", "type": "function", "loc": [255, 259], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L254_C0", "vector": [2, 1, 0.8955, 0.0174, 1, 0.3, 0.0, 555, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "__init__", "arg_names": ["self", "attrs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, attrs=None):\n final_attrs = {'class': 'vLargeTextField'}\n if attrs is not None:\n final_attrs.update(attrs)\n super(AdminTextareaWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L256_C8", "label": "final_attrs =", "type": "assigned_variable", "loc": [256, 256], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L255_C4", "vector": [14, 2, 0.892, 0.0035, 2, 0.4, 0.0, 750, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "final_attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " final_attrs = {'class': 'vLargeTextField'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L257_C8", "label": "if", "type": "if", "loc": [257, 258], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L255_C4", "vector": [4, 2, 0.8972, 0.007, 2, 0.4, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if attrs is not None:\n final_attrs.update(attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L258_C12", "label": "update()", "type": "expression", "loc": [258, 258], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L257_C8", "vector": [8, 3, 0.899, 0.0035, 3, 0.86, 0.0, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " final_attrs.update(attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L259_C8", "label": "__init__()", "type": "expression", "loc": [259, 259], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L255_C4", "vector": [8, 2, 0.9024, 0.0035, 2, 0.4, 1.0, 555, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(AdminTextareaWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L261_C0", "label": "AdminTextInputWidget", "type": "class", "loc": [261, 266], "level": 0, "parent": null, "vector": [3, 0, 0.9181, 0.0209, 0, 0.66, 0.8846, 486, 0, 1, 0, 0, 151, 0, 3], "semantic": {"name": "AdminTextInputWidget", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminTextInputWidget(forms.TextInput):\n def __init__(self, attrs=None):\n final_attrs = {'class': 'vTextField'}\n if attrs is not None:\n final_attrs.update(attrs)\n super(AdminTextInputWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L262_C4", "label": "__init__", "type": "function", "loc": [262, 266], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L261_C0", "vector": [2, 1, 0.9199, 0.0174, 1, 0.64, 0.0, 555, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "__init__", "arg_names": ["self", "attrs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, attrs=None):\n final_attrs = {'class': 'vTextField'}\n if attrs is not None:\n final_attrs.update(attrs)\n super(AdminTextInputWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L263_C8", "label": "final_attrs =", "type": "assigned_variable", "loc": [263, 263], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L262_C4", "vector": [14, 2, 0.9164, 0.0035, 2, 0.43, 0.0, 750, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "final_attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " final_attrs = {'class': 'vTextField'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L264_C8", "label": "if", "type": "if", "loc": [264, 265], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L262_C4", "vector": [4, 2, 0.9216, 0.007, 2, 0.43, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if attrs is not None:\n final_attrs.update(attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L265_C12", "label": "update()", "type": "expression", "loc": [265, 265], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L264_C8", "vector": [8, 3, 0.9233, 0.0035, 3, 0.86, 0.0, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " final_attrs.update(attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L266_C8", "label": "__init__()", "type": "expression", "loc": [266, 266], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L262_C4", "vector": [8, 2, 0.9268, 0.0035, 2, 0.43, 1.0, 555, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(AdminTextInputWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L268_C0", "label": "AdminURLFieldWidget", "type": "class", "loc": [268, 273], "level": 0, "parent": null, "vector": [3, 0, 0.9425, 0.0209, 0, 0.66, 0.9231, 664, 0, 1, 0, 0, 151, 0, 3], "semantic": {"name": "AdminURLFieldWidget", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminURLFieldWidget(forms.TextInput):\n def __init__(self, attrs=None):\n final_attrs = {'class': 'vURLField'}\n if attrs is not None:\n final_attrs.update(attrs)\n super(AdminURLFieldWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L269_C4", "label": "__init__", "type": "function", "loc": [269, 273], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L268_C0", "vector": [2, 1, 0.9443, 0.0174, 1, 0.01, 0.0, 555, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "__init__", "arg_names": ["self", "attrs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, attrs=None):\n final_attrs = {'class': 'vURLField'}\n if attrs is not None:\n final_attrs.update(attrs)\n super(AdminURLFieldWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L270_C8", "label": "final_attrs =", "type": "assigned_variable", "loc": [270, 270], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L269_C4", "vector": [14, 2, 0.9408, 0.0035, 2, 0.27, 0.0, 750, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "final_attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " final_attrs = {'class': 'vURLField'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L271_C8", "label": "if", "type": "if", "loc": [271, 272], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L269_C4", "vector": [4, 2, 0.946, 0.007, 2, 0.27, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if attrs is not None:\n final_attrs.update(attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L272_C12", "label": "update()", "type": "expression", "loc": [272, 272], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L271_C8", "vector": [8, 3, 0.9477, 0.0035, 3, 0.23, 0.0, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " final_attrs.update(attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L273_C8", "label": "__init__()", "type": "expression", "loc": [273, 273], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L269_C4", "vector": [8, 2, 0.9512, 0.0035, 2, 0.27, 1.0, 555, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(AdminURLFieldWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L275_C0", "label": "AdminIntegerFieldWidget", "type": "class", "loc": [275, 280], "level": 0, "parent": null, "vector": [3, 0, 0.9669, 0.0209, 0, 0.66, 0.9615, 763, 0, 1, 0, 0, 151, 0, 3], "semantic": {"name": "AdminIntegerFieldWidget", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminIntegerFieldWidget(forms.TextInput):\n def __init__(self, attrs=None):\n final_attrs = {'class': 'vIntegerField'}\n if attrs is not None:\n final_attrs.update(attrs)\n super(AdminIntegerFieldWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L276_C4", "label": "__init__", "type": "function", "loc": [276, 280], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L275_C0", "vector": [2, 1, 0.9686, 0.0174, 1, 0.93, 0.0, 555, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "__init__", "arg_names": ["self", "attrs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, attrs=None):\n final_attrs = {'class': 'vIntegerField'}\n if attrs is not None:\n final_attrs.update(attrs)\n super(AdminIntegerFieldWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L277_C8", "label": "final_attrs =", "type": "assigned_variable", "loc": [277, 277], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L276_C4", "vector": [14, 2, 0.9652, 0.0035, 2, 0.48, 0.0, 750, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "final_attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " final_attrs = {'class': 'vIntegerField'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L278_C8", "label": "if", "type": "if", "loc": [278, 279], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L276_C4", "vector": [4, 2, 0.9704, 0.007, 2, 0.48, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if attrs is not None:\n final_attrs.update(attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L279_C12", "label": "update()", "type": "expression", "loc": [279, 279], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L278_C8", "vector": [8, 3, 0.9721, 0.0035, 3, 0.1, 0.0, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " final_attrs.update(attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L280_C8", "label": "__init__()", "type": "expression", "loc": [280, 280], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L276_C4", "vector": [8, 2, 0.9756, 0.0035, 2, 0.48, 1.0, 555, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(AdminIntegerFieldWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L282_C0", "label": "AdminCommaSeparatedIntegerFieldWidget", "type": "class", "loc": [282, 287], "level": 0, "parent": null, "vector": [3, 0, 0.9913, 0.0209, 0, 0.66, 1.0, 672, 0, 1, 0, 0, 151, 0, 3], "semantic": {"name": "AdminCommaSeparatedIntegerFieldWidget", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AdminCommaSeparatedIntegerFieldWidget(forms.TextInput):\n def __init__(self, attrs=None):\n final_attrs = {'class': 'vCommaSeparatedIntegerField'}\n if attrs is not None:\n final_attrs.update(attrs)\n super(AdminCommaSeparatedIntegerFieldWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L283_C4", "label": "__init__", "type": "function", "loc": [283, 287], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L282_C0", "vector": [2, 1, 0.993, 0.0174, 1, 0.87, 0.0, 555, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "__init__", "arg_names": ["self", "attrs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, attrs=None):\n final_attrs = {'class': 'vCommaSeparatedIntegerField'}\n if attrs is not None:\n final_attrs.update(attrs)\n super(AdminCommaSeparatedIntegerFieldWidget, self).__init__(attrs=final_attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L284_C8", "label": "final_attrs =", "type": "assigned_variable", "loc": [284, 284], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L283_C4", "vector": [14, 2, 0.9895, 0.0035, 2, 0.88, 0.0, 750, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "final_attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " final_attrs = {'class': 'vCommaSeparatedIntegerField'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L285_C8", "label": "if", "type": "if", "loc": [285, 286], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L283_C4", "vector": [4, 2, 0.9948, 0.007, 2, 0.88, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if attrs is not None:\n final_attrs.update(attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L286_C12", "label": "update()", "type": "expression", "loc": [286, 286], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L285_C8", "vector": [8, 3, 0.9965, 0.0035, 3, 0.77, 0.0, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " final_attrs.update(attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L287_C8", "label": "__init__()", "type": "expression", "loc": [287, 287], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L283_C4", "vector": [8, 2, 1.0, 0.0035, 2, 0.88, 1.0, 555, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(AdminCommaSeparatedIntegerFieldWidget, self).__init__(attrs=final_attrs)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L36_C26"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L60_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L60_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L64_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L73_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L73_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L77_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L78_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L78_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L79_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L78_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L85_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L86_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L88_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L89_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L88_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L91_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L96_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L100_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L102_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L103_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L106_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L106_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L107_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L108_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L110_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L111_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L110_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L113_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L114_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L115_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L116_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L121_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L122_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L122_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L123_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L124_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L126_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L126_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L127_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L126_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L128_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L129_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L128_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:For_L130_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:For_L130_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L131_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L131_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L132_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L131_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L134_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:For_L130_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L135_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L128_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L136_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L126_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L137_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L139_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:ImportFrom_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L141_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L142_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L143_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L95_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L145_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L145_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L146_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L145_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L147_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L147_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L148_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L147_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L149_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L147_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L151_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L154_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L158_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L158_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L159_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L159_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L160_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L158_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L161_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L158_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L162_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L163_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L162_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L165_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L158_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L168_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L168_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L169_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L171_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L171_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L172_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L174_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L174_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L175_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L174_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L176_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L176_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L177_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L153_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L179_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L180_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L180_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L181_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L182_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L182_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L183_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L184_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L184_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L185_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:For_L186_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:For_L186_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L187_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L187_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L188_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L179_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L189_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L192_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L197_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L198_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L199_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L200_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L201_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L202_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L205_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L205_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L206_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L207_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L209_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L211_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L211_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L212_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L211_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L213_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L211_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L214_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L211_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L215_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L211_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L216_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L218_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L218_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L219_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L220_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L223_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L224_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L225_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L225_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L226_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L225_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L228_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:Try_L225_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L229_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L230_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L231_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L232_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L232_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L235_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L232_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L237_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L238_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L240_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L240_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L241_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L240_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L242_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L240_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L243_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L245_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L245_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L246_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L248_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L248_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L249_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L191_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L251_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L251_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Return_L252_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L254_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L255_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L255_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L256_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L255_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L257_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L257_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L258_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L255_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L259_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L261_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L262_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L262_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L263_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L262_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L264_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L264_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L265_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L262_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L266_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L268_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L269_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L269_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L270_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L269_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L271_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L271_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L272_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L269_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L273_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L275_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L276_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L276_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L277_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L276_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L278_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L278_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L279_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L276_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L280_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:ClassDef_L282_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L283_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L283_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Assign_L284_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L283_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L285_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:If_L285_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L286_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98652:FunctionDef_L283_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98652:Expr_L287_C8"}] |
# ACTION_CHECKBOX_NAME is unused, but should stay since its import from here
# has been referenced in documentation.
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL
from django.contrib.admin.options import StackedInline, TabularInline
from django.contrib.admin.sites import AdminSite, site
def autodiscover():
"""
Auto-discover INSTALLED_APPS admin.py modules and fail silently when
not present. This forces an import on them to register any admin bits they
may want.
"""
import copy
from django.conf import settings
from django.utils.importlib import import_module
from django.utils.module_loading import module_has_submodule
for app in settings.INSTALLED_APPS:
mod = import_module(app)
# Attempt to import the app's admin module.
try:
before_import_registry = copy.copy(site._registry)
import_module('%s.admin' % app)
except:
# Reset the model registry to the state before the last import as
# this import will have to reoccur on the next request and this
# could raise NotRegistered and AlreadyRegistered exceptions
# (see #8245).
site._registry = before_import_registry
# Decide whether to bubble up this error. If the app just
# doesn't have an admin module, we can ignore the error
# attempting to import it, otherwise we want it to bubble up.
if module_has_submodule(mod, 'admin'):
raise
| ajibawa-2023/Python-Code-Large/train/row_98653 | 17 | 38 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98653:ImportFrom_L3_C0", "label": "from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0789, 0.0263, 0, 0.66, 0.0, 140, 0, 1, 0, 0, 140, 0, 0], "semantic": {"name": "django.contrib.admin.helpers", "arg_names": [], "import_names": ["ACTION_CHECKBOX_NAME"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:ImportFrom_L4_C0", "label": "from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.1053, 0.0263, 0, 0.66, 0.25, 84, 0, 3, 0, 0, 84, 0, 0], "semantic": {"name": "django.contrib.admin.options", "arg_names": [], "import_names": ["ModelAdmin", "HORIZONTAL", "VERTICAL"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:ImportFrom_L5_C0", "label": "from django.contrib.admin.options import StackedInline, TabularInline", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.1316, 0.0263, 0, 0.66, 0.5, 84, 0, 2, 0, 0, 84, 0, 0], "semantic": {"name": "django.contrib.admin.options", "arg_names": [], "import_names": ["StackedInline", "TabularInline"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.options import StackedInline, TabularInline"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:ImportFrom_L6_C0", "label": "from django.contrib.admin.sites import AdminSite, site", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.1579, 0.0263, 0, 0.66, 0.75, 687, 0, 2, 0, 0, 687, 0, 0], "semantic": {"name": "django.contrib.admin.sites", "arg_names": [], "import_names": ["AdminSite", "site"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.sites import AdminSite, site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "label": "autodiscover", "type": "function", "loc": [9, 38], "level": 0, "parent": null, "vector": [2, 0, 0.6184, 0.7895, 0, 0.66, 1.0, 798, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "autodiscover", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def autodiscover():\n \"\"\"\n Auto-discover INSTALLED_APPS admin.py modules and fail silently when\n not present. This forces an import on them to register any admin bits they\n may want.\n \"\"\"\n\n import copy"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:Expr_L10_C4", "label": "expression", "type": "expression", "loc": [10, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "vector": [8, 1, 0.3158, 0.1316, 1, 0.24, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Auto-discover INSTALLED_APPS admin.py modules and fail silently when\n not present. This forces an import on them to register any admin bits they\n may want.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:Import_L16_C4", "label": "copy import copy", "type": "import", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "vector": [1, 1, 0.4211, 0.0263, 1, 0.24, 0.2, 739, 0, 1, 0, 0, 739, 0, 0], "semantic": {"name": "copy", "arg_names": [], "import_names": ["copy"], "rhs_call_name": "", "annotation": ""}, "snippet": " import copy"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:ImportFrom_L17_C4", "label": "from django.conf import settings", "type": "import", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "vector": [1, 1, 0.4474, 0.0263, 1, 0.24, 0.4, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:ImportFrom_L18_C4", "label": "from django.utils.importlib import import_module", "type": "import", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "vector": [1, 1, 0.4737, 0.0263, 1, 0.24, 0.6, 118, 0, 1, 0, 0, 118, 0, 0], "semantic": {"name": "django.utils.importlib", "arg_names": [], "import_names": ["import_module"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.utils.importlib import import_module"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:ImportFrom_L19_C4", "label": "from django.utils.module_loading import module_has_submodule", "type": "import", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "vector": [1, 1, 0.5, 0.0263, 1, 0.24, 0.8, 689, 0, 1, 0, 0, 689, 0, 0], "semantic": {"name": "django.utils.module_loading", "arg_names": [], "import_names": ["module_has_submodule"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.utils.module_loading import module_has_submodule"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:For_L21_C4", "label": "for app", "type": "for", "loc": [21, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "vector": [6, 1, 0.7763, 0.4737, 1, 0.24, 1.0, 494, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "app", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for app in settings.INSTALLED_APPS:\n mod = import_module(app)\n # Attempt to import the app's admin module.\n try:\n before_import_registry = copy.copy(site._registry)\n import_module('%s.admin' % app)\n except:\n # Reset the model registry to the state before the last import as"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:Assign_L22_C8", "label": "mod = import_module()", "type": "assigned_variable", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98653:For_L21_C4", "vector": [14, 2, 0.5789, 0.0263, 2, 0.71, 0.0, 25, 3, 1, 0, 0, 637, 10, 1], "semantic": {"name": "mod", "arg_names": [], "import_names": [], "rhs_call_name": "import_module", "annotation": ""}, "snippet": " mod = import_module(app)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:Try_L24_C8", "label": "try", "type": "try", "loc": [24, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98653:For_L21_C4", "vector": [7, 2, 0.8158, 0.3947, 2, 0.71, 1.0, 0, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n before_import_registry = copy.copy(site._registry)\n import_module('%s.admin' % app)\n except:\n # Reset the model registry to the state before the last import as\n # this import will have to reoccur on the next request and this\n # could raise NotRegistered and AlreadyRegistered exceptions\n # (see #8245)."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:Assign_L25_C12", "label": "before_import_registry = copy()", "type": "assigned_variable", "loc": [25, 25], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98653:Try_L24_C8", "vector": [14, 3, 0.6579, 0.0263, 3, 0.37, 0.0, 484, 3, 1, 0, 0, 739, 10, 1], "semantic": {"name": "before_import_registry", "arg_names": [], "import_names": [], "rhs_call_name": "copy", "annotation": ""}, "snippet": " before_import_registry = copy.copy(site._registry)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:Expr_L26_C12", "label": "import_module()", "type": "expression", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98653:Try_L24_C8", "vector": [8, 3, 0.6842, 0.0263, 3, 0.37, 1.0, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "import_module", "arg_names": [], "import_names": [], "rhs_call_name": "import_module", "annotation": ""}, "snippet": " import_module('%s.admin' % app)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:Assign_L32_C12", "label": "site._registry =", "type": "assigned_variable", "loc": [32, 32], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98653:Try_L24_C8", "vector": [14, 3, 0.8421, 0.0263, 3, 0.37, 0.0, 273, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "site._registry", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " site._registry = before_import_registry"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98653:If_L37_C12", "label": "if", "type": "if", "loc": [37, 38], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98653:Try_L24_C8", "vector": [4, 3, 0.9868, 0.0526, 3, 0.37, 1.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if module_has_submodule(mod, 'admin'):\n raise"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98653:Expr_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98653:Import_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98653:ImportFrom_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98653:ImportFrom_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98653:ImportFrom_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98653:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98653:For_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98653:For_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98653:Assign_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98653:For_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98653:Try_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98653:Try_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98653:Assign_L25_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98653:Try_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98653:Expr_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98653:Try_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98653:Assign_L32_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98653:Try_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98653:If_L37_C12"}] |
"""
Built-in, globally-available admin actions.
"""
from django import template
from django.core.exceptions import PermissionDenied
from django.contrib.admin import helpers
from django.contrib.admin.util import get_deleted_objects, model_ngettext
from django.db import router
from django.shortcuts import render_to_response
from django.utils.encoding import force_unicode
from django.utils.translation import ugettext_lazy, ugettext as _
def delete_selected(modeladmin, request, queryset):
"""
Default action which deletes the selected objects.
This action first displays a confirmation page whichs shows all the
deleteable objects, or, if the user has no permission one of the related
childs (foreignkeys), a "permission denied" message.
Next, it delets all selected objects and redirects back to the change list.
"""
opts = modeladmin.model._meta
app_label = opts.app_label
# Check that the user has delete permission for the actual model
if not modeladmin.has_delete_permission(request):
raise PermissionDenied
using = router.db_for_write(modeladmin.model)
# Populate deletable_objects, a data structure of all related objects that
# will also be deleted.
deletable_objects, perms_needed = get_deleted_objects(
queryset, opts, request.user, modeladmin.admin_site, using)
# The user has already confirmed the deletion.
# Do the deletion and return a None to display the change list view again.
if request.POST.get('post'):
if perms_needed:
raise PermissionDenied
n = queryset.count()
if n:
for obj in queryset:
obj_display = force_unicode(obj)
modeladmin.log_deletion(request, obj, obj_display)
queryset.delete()
modeladmin.message_user(request, _("Successfully deleted %(count)d %(items)s.") % {
"count": n, "items": model_ngettext(modeladmin.opts, n)
})
# Return None to display the change list page again.
return None
context = {
"title": _("Are you sure?"),
"object_name": force_unicode(opts.verbose_name),
"deletable_objects": [deletable_objects],
'queryset': queryset,
"perms_lacking": perms_needed,
"opts": opts,
"root_path": modeladmin.admin_site.root_path,
"app_label": app_label,
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
}
# Display the confirmation page
return render_to_response(modeladmin.delete_selected_confirmation_template or [
"admin/%s/%s/delete_selected_confirmation.html" % (app_label, opts.object_name.lower()),
"admin/%s/delete_selected_confirmation.html" % app_label,
"admin/delete_selected_confirmation.html"
], context, context_instance=template.RequestContext(request))
delete_selected.short_description = ugettext_lazy("Delete selected %(verbose_name_plural)s")
| ajibawa-2023/Python-Code-Large/train/row_98654 | 29 | 74 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.027, 0.0405, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nBuilt-in, globally-available admin actions.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:ImportFrom_L5_C0", "label": "from django import template", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0676, 0.0135, 0, 0.66, 0.1, 294, 0, 1, 0, 0, 294, 0, 0], "semantic": {"name": "django", "arg_names": [], "import_names": ["template"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django import template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:ImportFrom_L6_C0", "label": "from django.core.exceptions import PermissionDenied", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0811, 0.0135, 0, 0.66, 0.2, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["PermissionDenied"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import PermissionDenied"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:ImportFrom_L7_C0", "label": "from django.contrib.admin import helpers", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0946, 0.0135, 0, 0.66, 0.3, 703, 0, 1, 0, 0, 703, 0, 0], "semantic": {"name": "django.contrib.admin", "arg_names": [], "import_names": ["helpers"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin import helpers"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:ImportFrom_L8_C0", "label": "from django.contrib.admin.util import get_deleted_objects, model_ngettext", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.1081, 0.0135, 0, 0.66, 0.4, 69, 0, 2, 0, 0, 69, 0, 0], "semantic": {"name": "django.contrib.admin.util", "arg_names": [], "import_names": ["get_deleted_objects", "model_ngettext"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.util import get_deleted_objects, model_ngettext"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:ImportFrom_L9_C0", "label": "from django.db import router", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.1216, 0.0135, 0, 0.66, 0.5, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["router"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import router"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:ImportFrom_L10_C0", "label": "from django.shortcuts import render_to_response", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.1351, 0.0135, 0, 0.66, 0.6, 852, 0, 1, 0, 0, 852, 0, 0], "semantic": {"name": "django.shortcuts", "arg_names": [], "import_names": ["render_to_response"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.shortcuts import render_to_response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:ImportFrom_L11_C0", "label": "from django.utils.encoding import force_unicode", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.1486, 0.0135, 0, 0.66, 0.7, 96, 0, 1, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["force_unicode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import force_unicode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:ImportFrom_L12_C0", "label": "from django.utils.translation import ugettext_lazy, _", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.1622, 0.0135, 0, 0.66, 0.8, 389, 0, 2, 0, 0, 389, 0, 0], "semantic": {"name": "django.utils.translation", "arg_names": [], "import_names": ["ugettext_lazy", "_"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.translation import ugettext_lazy, ugettext as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "label": "delete_selected", "type": "function", "loc": [14, 72], "level": 0, "parent": null, "vector": [2, 0, 0.5811, 0.7973, 0, 0.66, 0.9, 678, 0, 3, 1, 0, 0, 0, 16], "semantic": {"name": "delete_selected", "arg_names": ["modeladmin", "request", "queryset"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def delete_selected(modeladmin, request, queryset):\n \"\"\"\n Default action which deletes the selected objects.\n\n This action first displays a confirmation page whichs shows all the\n deleteable objects, or, if the user has no permission one of the related\n childs (foreignkeys), a \"permission denied\" message.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Expr_L15_C4", "label": "expression", "type": "expression", "loc": [15, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "vector": [8, 1, 0.2568, 0.1216, 1, 0.84, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Default action which deletes the selected objects.\n\n This action first displays a confirmation page whichs shows all the\n deleteable objects, or, if the user has no permission one of the related\n childs (foreignkeys), a \"permission denied\" message.\n\n Next, it delets all selected objects and redirects back to the change list."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L24_C4", "label": "opts =", "type": "assigned_variable", "loc": [24, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "vector": [14, 1, 0.3243, 0.0135, 1, 0.84, 0.125, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = modeladmin.model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L25_C4", "label": "app_label =", "type": "assigned_variable", "loc": [25, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "vector": [14, 1, 0.3378, 0.0135, 1, 0.84, 0.25, 187, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "app_label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_label = opts.app_label"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L28_C4", "label": "if", "type": "if", "loc": [28, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "vector": [4, 1, 0.3851, 0.027, 1, 0.84, 0.375, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not modeladmin.has_delete_permission(request):\n raise PermissionDenied"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L31_C4", "label": "using = db_for_write()", "type": "assigned_variable", "loc": [31, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "vector": [14, 1, 0.4189, 0.0135, 1, 0.84, 0.5, 699, 3, 1, 0, 0, 395, 10, 1], "semantic": {"name": "using", "arg_names": [], "import_names": [], "rhs_call_name": "db_for_write", "annotation": ""}, "snippet": " using = router.db_for_write(modeladmin.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L35_C4", "label": "deletable_objects, perms_needed = get_deleted_objects()", "type": "assigned_variable", "loc": [35, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "vector": [14, 1, 0.4797, 0.027, 1, 0.84, 0.625, 558, 3, 5, 0, 0, 624, 10, 1], "semantic": {"name": "deletable_objects, perms_needed", "arg_names": [], "import_names": [], "rhs_call_name": "get_deleted_objects", "annotation": ""}, "snippet": " deletable_objects, perms_needed = get_deleted_objects(\n queryset, opts, request.user, modeladmin.admin_site, using)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L40_C4", "label": "if", "type": "if", "loc": [40, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "vector": [4, 1, 0.6284, 0.1892, 1, 0.84, 0.75, 0, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.POST.get('post'):\n if perms_needed:\n raise PermissionDenied\n n = queryset.count()\n if n:\n for obj in queryset:\n obj_display = force_unicode(obj)\n modeladmin.log_deletion(request, obj, obj_display)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L41_C8", "label": "if", "type": "if", "loc": [41, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L40_C4", "vector": [4, 2, 0.5608, 0.027, 2, 0.2, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if perms_needed:\n raise PermissionDenied"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L43_C8", "label": "n = count()", "type": "assigned_variable", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L40_C4", "vector": [14, 2, 0.5811, 0.0135, 2, 0.2, 0.3333, 773, 3, 0, 0, 0, 778, 10, 1], "semantic": {"name": "n", "arg_names": [], "import_names": [], "rhs_call_name": "count", "annotation": ""}, "snippet": " n = queryset.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L44_C8", "label": "if", "type": "if", "loc": [44, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L40_C4", "vector": [4, 2, 0.6419, 0.1081, 2, 0.2, 0.6667, 0, 2, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if n:\n for obj in queryset:\n obj_display = force_unicode(obj)\n modeladmin.log_deletion(request, obj, obj_display)\n queryset.delete()\n modeladmin.message_user(request, _(\"Successfully deleted %(count)d %(items)s.\") % {\n \"count\": n, \"items\": model_ngettext(modeladmin.opts, n)\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:For_L45_C12", "label": "for obj", "type": "for", "loc": [45, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L44_C8", "vector": [6, 3, 0.6216, 0.0405, 3, 0.21, 0.0, 505, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for obj in queryset:\n obj_display = force_unicode(obj)\n modeladmin.log_deletion(request, obj, obj_display)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L46_C16", "label": "obj_display = force_unicode()", "type": "assigned_variable", "loc": [46, 46], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:For_L45_C12", "vector": [14, 4, 0.6216, 0.0135, 4, 0.37, 0.0, 628, 3, 1, 0, 0, 870, 10, 1], "semantic": {"name": "obj_display", "arg_names": [], "import_names": [], "rhs_call_name": "force_unicode", "annotation": ""}, "snippet": " obj_display = force_unicode(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Expr_L47_C16", "label": "log_deletion()", "type": "expression", "loc": [47, 47], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:For_L45_C12", "vector": [8, 4, 0.6351, 0.0135, 4, 0.37, 1.0, 271, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "log_deletion", "arg_names": [], "import_names": [], "rhs_call_name": "log_deletion", "annotation": ""}, "snippet": " modeladmin.log_deletion(request, obj, obj_display)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Expr_L48_C12", "label": "delete()", "type": "expression", "loc": [48, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L44_C8", "vector": [8, 3, 0.6486, 0.0135, 3, 0.21, 0.5, 266, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " queryset.delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Expr_L49_C12", "label": "message_user()", "type": "expression", "loc": [49, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L44_C8", "vector": [8, 3, 0.6757, 0.0405, 3, 0.21, 1.0, 207, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "message_user", "arg_names": [], "import_names": [], "rhs_call_name": "message_user", "annotation": ""}, "snippet": " modeladmin.message_user(request, _(\"Successfully deleted %(count)d %(items)s.\") % {\n \"count\": n, \"items\": model_ngettext(modeladmin.opts, n)\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Return_L53_C8", "label": "return", "type": "return", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L40_C4", "vector": [13, 2, 0.7162, 0.0135, 2, 0.2, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L55_C4", "label": "context =", "type": "assigned_variable", "loc": [55, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "vector": [14, 1, 0.8108, 0.1486, 1, 0.84, 0.875, 954, 0, 0, 0, 0, 0, 6, 2], "semantic": {"name": "context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context = {\n \"title\": _(\"Are you sure?\"),\n \"object_name\": force_unicode(opts.verbose_name),\n \"deletable_objects\": [deletable_objects],\n 'queryset': queryset,\n \"perms_lacking\": perms_needed,\n \"opts\": opts,\n \"root_path\": modeladmin.admin_site.root_path,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Return_L68_C4", "label": "return", "type": "return", "loc": [68, 72], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "vector": [13, 1, 0.9459, 0.0676, 1, 0.84, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(modeladmin.delete_selected_confirmation_template or [\n \"admin/%s/%s/delete_selected_confirmation.html\" % (app_label, opts.object_name.lower()),\n \"admin/%s/delete_selected_confirmation.html\" % app_label,\n \"admin/delete_selected_confirmation.html\"\n ], context, context_instance=template.RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L74_C0", "label": "delete_selected.short_description = ugettext_lazy()", "type": "assigned_variable", "loc": [74, 74], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0135, 0, 0.66, 1.0, 26, 3, 1, 0, 0, 532, 10, 1], "semantic": {"name": "delete_selected.short_description", "arg_names": [], "import_names": [], "rhs_call_name": "ugettext_lazy", "annotation": ""}, "snippet": "delete_selected.short_description = ugettext_lazy(\"Delete selected %(verbose_name_plural)s\")"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Expr_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L31_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L35_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:For_L45_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:For_L45_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L46_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:For_L45_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Expr_L47_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Expr_L48_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Expr_L49_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:If_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Return_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Assign_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98654:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98654:Return_L68_C4"}] |
import cStringIO, zipfile
from django.conf import settings
from django.http import HttpResponse
from django.template import loader
def compress_kml(kml):
"Returns compressed KMZ from the given KML string."
kmz = cStringIO.StringIO()
zf = zipfile.ZipFile(kmz, 'a', zipfile.ZIP_DEFLATED)
zf.writestr('doc.kml', kml.encode(settings.DEFAULT_CHARSET))
zf.close()
kmz.seek(0)
return kmz.read()
def render_to_kml(*args, **kwargs):
"Renders the response as KML (using the correct MIME type)."
return HttpResponse(loader.render_to_string(*args, **kwargs),
mimetype='application/vnd.google-earth.kml+xml')
def render_to_kmz(*args, **kwargs):
"""
Compresses the KML content and returns as KMZ (using the correct
MIME type).
"""
return HttpResponse(compress_kml(loader.render_to_string(*args, **kwargs)),
mimetype='application/vnd.google-earth.kmz')
def render_to_text(*args, **kwargs):
"Renders the response using the MIME type for plain text."
return HttpResponse(loader.render_to_string(*args, **kwargs),
mimetype='text/plain')
| ajibawa-2023/Python-Code-Large/train/row_98655 | 21 | 32 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Import_L1_C0", "label": "cStringIO import cStringIO, zipfile", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0312, 0.0312, 0, 0.66, 0.0, 764, 0, 2, 0, 0, 764, 0, 0], "semantic": {"name": "cStringIO", "arg_names": [], "import_names": ["cStringIO", "zipfile"], "rhs_call_name": "", "annotation": ""}, "snippet": "import cStringIO, zipfile"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:ImportFrom_L2_C0", "label": "from django.conf import settings", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0625, 0.0312, 0, 0.66, 0.1429, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:ImportFrom_L3_C0", "label": "from django.http import HttpResponse", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0938, 0.0312, 0, 0.66, 0.2857, 779, 0, 1, 0, 0, 779, 0, 0], "semantic": {"name": "django.http", "arg_names": [], "import_names": ["HttpResponse"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.http import HttpResponse"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:ImportFrom_L4_C0", "label": "from django.template import loader", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.125, 0.0312, 0, 0.66, 0.4286, 213, 0, 1, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["loader"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import loader"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "label": "compress_kml", "type": "function", "loc": [6, 13], "level": 0, "parent": null, "vector": [2, 0, 0.2969, 0.25, 0, 0.66, 0.5714, 523, 0, 1, 1, 0, 0, 0, 7], "semantic": {"name": "compress_kml", "arg_names": ["kml"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def compress_kml(kml):\n \"Returns compressed KMZ from the given KML string.\"\n kmz = cStringIO.StringIO()\n zf = zipfile.ZipFile(kmz, 'a', zipfile.ZIP_DEFLATED)\n zf.writestr('doc.kml', kml.encode(settings.DEFAULT_CHARSET))\n zf.close()\n kmz.seek(0)\n return kmz.read()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L7_C4", "label": "expression", "type": "expression", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "vector": [8, 1, 0.2188, 0.0312, 1, 0.85, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns compressed KMZ from the given KML string.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Assign_L8_C4", "label": "kmz = StringIO()", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "vector": [14, 1, 0.25, 0.0312, 1, 0.85, 0.1667, 670, 3, 0, 0, 0, 609, 10, 1], "semantic": {"name": "kmz", "arg_names": [], "import_names": [], "rhs_call_name": "StringIO", "annotation": ""}, "snippet": " kmz = cStringIO.StringIO()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Assign_L9_C4", "label": "zf = ZipFile()", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "vector": [14, 1, 0.2812, 0.0312, 1, 0.85, 0.3333, 134, 3, 3, 0, 0, 299, 10, 1], "semantic": {"name": "zf", "arg_names": [], "import_names": [], "rhs_call_name": "ZipFile", "annotation": ""}, "snippet": " zf = zipfile.ZipFile(kmz, 'a', zipfile.ZIP_DEFLATED)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L10_C4", "label": "writestr()", "type": "expression", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "vector": [8, 1, 0.3125, 0.0312, 1, 0.85, 0.5, 641, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "writestr", "arg_names": [], "import_names": [], "rhs_call_name": "writestr", "annotation": ""}, "snippet": " zf.writestr('doc.kml', kml.encode(settings.DEFAULT_CHARSET))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L11_C4", "label": "close()", "type": "expression", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "vector": [8, 1, 0.3438, 0.0312, 1, 0.85, 0.6667, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " zf.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L12_C4", "label": "seek()", "type": "expression", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "vector": [8, 1, 0.375, 0.0312, 1, 0.85, 0.8333, 66, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "seek", "arg_names": [], "import_names": [], "rhs_call_name": "seek", "annotation": ""}, "snippet": " kmz.seek(0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Return_L13_C4", "label": "return", "type": "return", "loc": [13, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "vector": [13, 1, 0.4062, 0.0312, 1, 0.85, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return kmz.read()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L15_C0", "label": "render_to_kml", "type": "function", "loc": [15, 18], "level": 0, "parent": null, "vector": [2, 0, 0.5156, 0.125, 0, 0.66, 0.7143, 629, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "render_to_kml", "arg_names": ["args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def render_to_kml(*args, **kwargs):\n \"Renders the response as KML (using the correct MIME type).\"\n return HttpResponse(loader.render_to_string(*args, **kwargs),\n mimetype='application/vnd.google-earth.kml+xml')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L16_C4", "label": "expression", "type": "expression", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L15_C0", "vector": [8, 1, 0.5, 0.0312, 1, 0.08, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Renders the response as KML (using the correct MIME type).\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Return_L17_C4", "label": "return", "type": "return", "loc": [17, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L15_C0", "vector": [13, 1, 0.5469, 0.0625, 1, 0.08, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponse(loader.render_to_string(*args, **kwargs),\n mimetype='application/vnd.google-earth.kml+xml')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L20_C0", "label": "render_to_kmz", "type": "function", "loc": [20, 26], "level": 0, "parent": null, "vector": [2, 0, 0.7188, 0.2188, 0, 0.66, 0.8571, 120, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "render_to_kmz", "arg_names": ["args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def render_to_kmz(*args, **kwargs):\n \"\"\"\n Compresses the KML content and returns as KMZ (using the correct \n MIME type).\n \"\"\"\n return HttpResponse(compress_kml(loader.render_to_string(*args, **kwargs)),\n mimetype='application/vnd.google-earth.kmz')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L21_C4", "label": "expression", "type": "expression", "loc": [21, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L20_C0", "vector": [8, 1, 0.7031, 0.125, 1, 0.93, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Compresses the KML content and returns as KMZ (using the correct \n MIME type).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Return_L25_C4", "label": "return", "type": "return", "loc": [25, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L20_C0", "vector": [13, 1, 0.7969, 0.0625, 1, 0.93, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponse(compress_kml(loader.render_to_string(*args, **kwargs)),\n mimetype='application/vnd.google-earth.kmz')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L29_C0", "label": "render_to_text", "type": "function", "loc": [29, 32], "level": 0, "parent": null, "vector": [2, 0, 0.9531, 0.125, 0, 0.66, 1.0, 552, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "render_to_text", "arg_names": ["args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def render_to_text(*args, **kwargs):\n \"Renders the response using the MIME type for plain text.\"\n return HttpResponse(loader.render_to_string(*args, **kwargs),\n mimetype='text/plain')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L30_C4", "label": "expression", "type": "expression", "loc": [30, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L29_C0", "vector": [8, 1, 0.9375, 0.0312, 1, 0.4, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Renders the response using the MIME type for plain text.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98655:Return_L31_C4", "label": "return", "type": "return", "loc": [31, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L29_C0", "vector": [13, 1, 0.9844, 0.0625, 1, 0.4, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponse(loader.render_to_string(*args, **kwargs),\n mimetype='text/plain')"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Return_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Return_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Return_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L29_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Expr_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98655:FunctionDef_L29_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98655:Return_L31_C4"}] |
from django.db import connection
if (hasattr(connection.ops, 'spatial_version') and
not connection.ops.mysql):
# Getting the `SpatialRefSys` and `GeometryColumns`
# models for the default spatial backend. These
# aliases are provided for backwards-compatibility.
SpatialRefSys = connection.ops.spatial_ref_sys()
GeometryColumns = connection.ops.geometry_columns()
| ajibawa-2023/Python-Code-Large/train/row_98656 | 4 | 9 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98656:ImportFrom_L1_C0", "label": "from django.db import connection", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.1111, 0.1111, 0, 0.66, 0.0, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["connection"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import connection"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98656:If_L3_C0", "label": "if", "type": "if", "loc": [3, 9], "level": 0, "parent": null, "vector": [4, 0, 0.6667, 0.7778, 0, 0.66, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if (hasattr(connection.ops, 'spatial_version') and\n not connection.ops.mysql):\n # Getting the `SpatialRefSys` and `GeometryColumns`\n # models for the default spatial backend. These\n # aliases are provided for backwards-compatibility.\n SpatialRefSys = connection.ops.spatial_ref_sys()\n GeometryColumns = connection.ops.geometry_columns()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98656:Assign_L8_C4", "label": "SpatialRefSys = spatial_ref_sys()", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98656:If_L3_C0", "vector": [14, 1, 0.8889, 0.1111, 1, 0.92, 0.0, 219, 3, 0, 0, 0, 318, 10, 1], "semantic": {"name": "SpatialRefSys", "arg_names": [], "import_names": [], "rhs_call_name": "spatial_ref_sys", "annotation": ""}, "snippet": " SpatialRefSys = connection.ops.spatial_ref_sys()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98656:Assign_L9_C4", "label": "GeometryColumns = geometry_columns()", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98656:If_L3_C0", "vector": [14, 1, 1.0, 0.1111, 1, 0.92, 1.0, 250, 3, 0, 0, 0, 291, 10, 1], "semantic": {"name": "GeometryColumns", "arg_names": [], "import_names": [], "rhs_call_name": "geometry_columns", "annotation": ""}, "snippet": " GeometryColumns = connection.ops.geometry_columns()"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98656:If_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98656:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98656:If_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98656:Assign_L9_C4"}] |
from django.core import urlresolvers
from django.contrib.sitemaps import Sitemap
class GeoRSSSitemap(Sitemap):
"""
A minimal hook to produce sitemaps for GeoRSS feeds.
"""
def __init__(self, feed_dict, slug_dict=None):
"""
This sitemap object initializes on a feed dictionary (as would be passed
to `django.contrib.syndication.views.feed`) and a slug dictionary.
If the slug dictionary is not defined, then it's assumed the keys provide
the URL parameter to the feed. However, if you have a complex feed (e.g.,
you override `get_object`, then you'll need to provide a slug dictionary.
The slug dictionary should have the same keys as the feed dictionary, but
each value in the slug dictionary should be a sequence of slugs that may
be used for valid feeds. For example, let's say we have a feed that
returns objects for a specific ZIP code in our feed dictionary:
feed_dict = {'zipcode' : ZipFeed}
Then we would use a slug dictionary with a list of the zip code slugs
corresponding to feeds you want listed in the sitemap:
slug_dict = {'zipcode' : ['77002', '77054']}
"""
# Setting up.
self.feed_dict = feed_dict
self.locations = []
if slug_dict is None: slug_dict = {}
# Getting the feed locations.
for section in feed_dict.keys():
if slug_dict.get(section, False):
for slug in slug_dict[section]:
self.locations.append('%s/%s' % (section, slug))
else:
self.locations.append(section)
def get_urls(self, page=1, site=None):
"""
This method is overrridden so the appropriate `geo_format` attribute
is placed on each URL element.
"""
urls = Sitemap.get_urls(self, page=page, site=site)
for url in urls: url['geo_format'] = 'georss'
return urls
def items(self):
return self.locations
def location(self, obj):
return urlresolvers.reverse('django.contrib.syndication.views.feed', args=(obj,))
| ajibawa-2023/Python-Code-Large/train/row_98657 | 25 | 53 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98657:ImportFrom_L1_C0", "label": "from django.core import urlresolvers", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0189, 0.0189, 0, 0.66, 0.0, 913, 0, 1, 0, 0, 913, 0, 0], "semantic": {"name": "django.core", "arg_names": [], "import_names": ["urlresolvers"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core import urlresolvers"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:ImportFrom_L2_C0", "label": "from django.contrib.sitemaps import Sitemap", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0377, 0.0189, 0, 0.66, 0.5, 890, 0, 1, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sitemaps", "arg_names": [], "import_names": ["Sitemap"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sitemaps import Sitemap"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:ClassDef_L4_C0", "label": "GeoRSSSitemap", "type": "class", "loc": [4, 52], "level": 0, "parent": null, "vector": [3, 0, 0.5283, 0.9245, 0, 0.66, 1.0, 587, 0, 4, 0, 0, 771, 0, 6], "semantic": {"name": "GeoRSSSitemap", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GeoRSSSitemap(Sitemap):\n \"\"\"\n A minimal hook to produce sitemaps for GeoRSS feeds.\n \"\"\"\n def __init__(self, feed_dict, slug_dict=None):\n \"\"\"\n This sitemap object initializes on a feed dictionary (as would be passed\n to `django.contrib.syndication.views.feed`) and a slug dictionary. "}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Expr_L5_C4", "label": "expression", "type": "expression", "loc": [5, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:ClassDef_L4_C0", "vector": [8, 1, 0.1132, 0.0566, 1, 0.61, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A minimal hook to produce sitemaps for GeoRSS feeds.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L8_C4", "label": "__init__", "type": "function", "loc": [8, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:ClassDef_L4_C0", "vector": [2, 1, 0.4245, 0.566, 1, 0.61, 0.25, 555, 0, 3, 0, 0, 0, 0, 4], "semantic": {"name": "__init__", "arg_names": ["self", "feed_dict", "slug_dict"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, feed_dict, slug_dict=None):\n \"\"\"\n This sitemap object initializes on a feed dictionary (as would be passed\n to `django.contrib.syndication.views.feed`) and a slug dictionary. \n If the slug dictionary is not defined, then it's assumed the keys provide\n the URL parameter to the feed. However, if you have a complex feed (e.g.,\n you override `get_object`, then you'll need to provide a slug dictionary.\n The slug dictionary should have the same keys as the feed dictionary, but "}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Expr_L9_C8", "label": "expression", "type": "expression", "loc": [9, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L8_C4", "vector": [8, 2, 0.3302, 0.3396, 2, 0.96, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This sitemap object initializes on a feed dictionary (as would be passed\n to `django.contrib.syndication.views.feed`) and a slug dictionary. \n If the slug dictionary is not defined, then it's assumed the keys provide\n the URL parameter to the feed. However, if you have a complex feed (e.g.,\n you override `get_object`, then you'll need to provide a slug dictionary.\n The slug dictionary should have the same keys as the feed dictionary, but \n each value in the slug dictionary should be a sequence of slugs that may "}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Assign_L28_C8", "label": "self.feed_dict =", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L8_C4", "vector": [14, 2, 0.5283, 0.0189, 2, 0.96, 0.25, 341, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.feed_dict", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.feed_dict = feed_dict"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Assign_L29_C8", "label": "self.locations =", "type": "assigned_variable", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L8_C4", "vector": [14, 2, 0.5472, 0.0189, 2, 0.96, 0.5, 453, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self.locations", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.locations = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:If_L30_C8", "label": "if", "type": "if", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L8_C4", "vector": [4, 2, 0.566, 0.0189, 2, 0.96, 0.75, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if slug_dict is None: slug_dict = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Assign_L30_C30", "label": "slug_dict =", "type": "assigned_variable", "loc": [30, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:If_L30_C8", "vector": [14, 3, 0.566, 0.0189, 3, 0.48, 0.0, 792, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "slug_dict", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if slug_dict is None: slug_dict = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:For_L32_C8", "label": "for section", "type": "for", "loc": [32, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L8_C4", "vector": [6, 2, 0.6509, 0.1132, 2, 0.96, 1.0, 806, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "section", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for section in feed_dict.keys():\n if slug_dict.get(section, False):\n for slug in slug_dict[section]:\n self.locations.append('%s/%s' % (section, slug))\n else:\n self.locations.append(section)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:If_L33_C12", "label": "if", "type": "if", "loc": [33, 37], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:For_L32_C8", "vector": [4, 3, 0.6604, 0.0943, 3, 0.82, 0.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if slug_dict.get(section, False):\n for slug in slug_dict[section]:\n self.locations.append('%s/%s' % (section, slug))\n else:\n self.locations.append(section)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:For_L34_C16", "label": "for slug", "type": "for", "loc": [34, 35], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:If_L33_C12", "vector": [6, 4, 0.6509, 0.0377, 4, 0.71, 0.0, 797, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "slug", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for slug in slug_dict[section]:\n self.locations.append('%s/%s' % (section, slug))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Expr_L35_C20", "label": "append()", "type": "expression", "loc": [35, 35], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:For_L34_C16", "vector": [8, 5, 0.6604, 0.0189, 5, 0.6, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " self.locations.append('%s/%s' % (section, slug))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Expr_L37_C16", "label": "append()", "type": "expression", "loc": [37, 37], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:If_L33_C12", "vector": [8, 4, 0.6981, 0.0189, 4, 0.71, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " self.locations.append(section)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L39_C4", "label": "get_urls", "type": "function", "loc": [39, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:ClassDef_L4_C0", "vector": [2, 1, 0.8019, 0.1509, 1, 0.61, 0.5, 974, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "get_urls", "arg_names": ["self", "page", "site"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_urls(self, page=1, site=None):\n \"\"\"\n This method is overrridden so the appropriate `geo_format` attribute\n is placed on each URL element.\n \"\"\"\n urls = Sitemap.get_urls(self, page=page, site=site)\n for url in urls: url['geo_format'] = 'georss'\n return urls"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Expr_L40_C8", "label": "expression", "type": "expression", "loc": [40, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L39_C4", "vector": [8, 2, 0.783, 0.0755, 2, 0.58, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This method is overrridden so the appropriate `geo_format` attribute\n is placed on each URL element.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Assign_L44_C8", "label": "urls = get_urls()", "type": "assigned_variable", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L39_C4", "vector": [14, 2, 0.8302, 0.0189, 2, 0.58, 0.3333, 260, 3, 3, 0, 0, 974, 10, 1], "semantic": {"name": "urls", "arg_names": [], "import_names": [], "rhs_call_name": "get_urls", "annotation": ""}, "snippet": " urls = Sitemap.get_urls(self, page=page, site=site)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:For_L45_C8", "label": "for url", "type": "for", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L39_C4", "vector": [6, 2, 0.8491, 0.0189, 2, 0.58, 0.6667, 789, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for url in urls: url['geo_format'] = 'georss'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Assign_L45_C25", "label": "assign", "type": "assigned_variable", "loc": [45, 45], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:For_L45_C8", "vector": [14, 3, 0.8491, 0.0189, 3, 0.18, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for url in urls: url['geo_format'] = 'georss'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Return_L46_C8", "label": "return", "type": "return", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L39_C4", "vector": [13, 2, 0.8679, 0.0189, 2, 0.58, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return urls"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L48_C4", "label": "items", "type": "function", "loc": [48, 49], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:ClassDef_L4_C0", "vector": [2, 1, 0.9151, 0.0377, 1, 0.61, 0.75, 339, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "items", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def items(self):\n return self.locations"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Return_L49_C8", "label": "return", "type": "return", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L48_C4", "vector": [13, 2, 0.9245, 0.0189, 2, 0.21, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.locations"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L51_C4", "label": "location", "type": "function", "loc": [51, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:ClassDef_L4_C0", "vector": [2, 1, 0.9717, 0.0377, 1, 0.61, 1.0, 771, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "location", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def location(self, obj):\n return urlresolvers.reverse('django.contrib.syndication.views.feed', args=(obj,))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98657:Return_L52_C8", "label": "return", "type": "return", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L51_C4", "vector": [13, 2, 0.9811, 0.0189, 2, 0.29, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return urlresolvers.reverse('django.contrib.syndication.views.feed', args=(obj,))"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98657:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Expr_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Expr_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Assign_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:If_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:If_L30_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Assign_L30_C30"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:For_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:For_L32_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:If_L33_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:If_L33_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:For_L34_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:For_L34_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Expr_L35_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:If_L33_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Expr_L37_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Expr_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Assign_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:For_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:For_L45_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Assign_L45_C25"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Return_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Return_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L51_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98657:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98657:Return_L52_C8"}] |
from django.core import urlresolvers
from django.contrib.sitemaps import Sitemap
from django.contrib.gis.db.models.fields import GeometryField
from django.db import models
class KMLSitemap(Sitemap):
"""
A minimal hook to produce KML sitemaps.
"""
geo_format = 'kml'
def __init__(self, locations=None):
# If no locations specified, then we try to build for
# every model in installed applications.
self.locations = self._build_kml_sources(locations)
def _build_kml_sources(self, sources):
"""
Goes through the given sources and returns a 3-tuple of
the application label, module name, and field name of every
GeometryField encountered in the sources.
If no sources are provided, then all models.
"""
kml_sources = []
if sources is None:
sources = models.get_models()
for source in sources:
if isinstance(source, models.base.ModelBase):
for field in source._meta.fields:
if isinstance(field, GeometryField):
kml_sources.append((source._meta.app_label,
source._meta.module_name,
field.name))
elif isinstance(source, (list, tuple)):
if len(source) != 3:
raise ValueError('Must specify a 3-tuple of (app_label, module_name, field_name).')
kml_sources.append(source)
else:
raise TypeError('KML Sources must be a model or a 3-tuple.')
return kml_sources
def get_urls(self, page=1, site=None):
"""
This method is overrridden so the appropriate `geo_format` attribute
is placed on each URL element.
"""
urls = Sitemap.get_urls(self, page=page, site=site)
for url in urls: url['geo_format'] = self.geo_format
return urls
def items(self):
return self.locations
def location(self, obj):
return urlresolvers.reverse('django.contrib.gis.sitemaps.views.%s' % self.geo_format,
kwargs={'label' : obj[0],
'model' : obj[1],
'field_name': obj[2],
}
)
class KMZSitemap(KMLSitemap):
geo_format = 'kmz'
| ajibawa-2023/Python-Code-Large/train/row_98658 | 35 | 63 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98658:ImportFrom_L1_C0", "label": "from django.core import urlresolvers", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0159, 0.0159, 0, 0.66, 0.0, 913, 0, 1, 0, 0, 913, 0, 0], "semantic": {"name": "django.core", "arg_names": [], "import_names": ["urlresolvers"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core import urlresolvers"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:ImportFrom_L2_C0", "label": "from django.contrib.sitemaps import Sitemap", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0317, 0.0159, 0, 0.66, 0.2, 890, 0, 1, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sitemaps", "arg_names": [], "import_names": ["Sitemap"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sitemaps import Sitemap"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:ImportFrom_L3_C0", "label": "from django.contrib.gis.db.models.fields import GeometryField", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0476, 0.0159, 0, 0.66, 0.4, 708, 0, 1, 0, 0, 708, 0, 0], "semantic": {"name": "django.contrib.gis.db.models.fields", "arg_names": [], "import_names": ["GeometryField"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.db.models.fields import GeometryField"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:ImportFrom_L4_C0", "label": "from django.db import models", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0635, 0.0159, 0, 0.66, 0.6, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "label": "KMLSitemap", "type": "class", "loc": [6, 61], "level": 0, "parent": null, "vector": [3, 0, 0.5317, 0.8889, 0, 0.66, 0.8, 604, 0, 5, 0, 0, 771, 0, 12], "semantic": {"name": "KMLSitemap", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class KMLSitemap(Sitemap):\n \"\"\"\n A minimal hook to produce KML sitemaps.\n \"\"\"\n geo_format = 'kml'\n\n def __init__(self, locations=None):\n # If no locations specified, then we try to build for"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Expr_L7_C4", "label": "expression", "type": "expression", "loc": [7, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "vector": [8, 1, 0.127, 0.0476, 1, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A minimal hook to produce KML sitemaps.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L10_C4", "label": "geo_format =", "type": "assigned_variable", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "vector": [14, 1, 0.1587, 0.0159, 1, 0.66, 0.1667, 698, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "geo_format", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " geo_format = 'kml'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L12_C4", "label": "__init__", "type": "function", "loc": [12, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "vector": [2, 1, 0.2143, 0.0635, 1, 0.66, 0.3333, 555, 0, 2, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "locations"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, locations=None):\n # If no locations specified, then we try to build for\n # every model in installed applications.\n self.locations = self._build_kml_sources(locations)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L15_C8", "label": "self.locations = _build_kml_sources()", "type": "assigned_variable", "loc": [15, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L12_C4", "vector": [14, 2, 0.2381, 0.0159, 2, 0.19, 0.0, 453, 3, 1, 0, 0, 563, 10, 1], "semantic": {"name": "self.locations", "arg_names": [], "import_names": [], "rhs_call_name": "_build_kml_sources", "annotation": ""}, "snippet": " self.locations = self._build_kml_sources(locations)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L17_C4", "label": "_build_kml_sources", "type": "function", "loc": [17, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "vector": [2, 1, 0.4603, 0.3968, 1, 0.66, 0.5, 563, 0, 2, 1, 0, 0, 0, 9], "semantic": {"name": "_build_kml_sources", "arg_names": ["self", "sources"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _build_kml_sources(self, sources):\n \"\"\"\n Goes through the given sources and returns a 3-tuple of\n the application label, module name, and field name of every\n GeometryField encountered in the sources.\n\n If no sources are provided, then all models.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Expr_L18_C8", "label": "expression", "type": "expression", "loc": [18, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L17_C4", "vector": [8, 2, 0.3333, 0.1111, 2, 0.84, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Goes through the given sources and returns a 3-tuple of\n the application label, module name, and field name of every\n GeometryField encountered in the sources.\n\n If no sources are provided, then all models.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L25_C8", "label": "kml_sources =", "type": "assigned_variable", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L17_C4", "vector": [14, 2, 0.3968, 0.0159, 2, 0.84, 0.25, 117, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "kml_sources", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kml_sources = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L26_C8", "label": "if", "type": "if", "loc": [26, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L17_C4", "vector": [4, 2, 0.4206, 0.0317, 2, 0.84, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if sources is None:\n sources = models.get_models()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L27_C12", "label": "sources = get_models()", "type": "assigned_variable", "loc": [27, 27], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L26_C8", "vector": [14, 3, 0.4286, 0.0159, 3, 0.36, 0.0, 648, 3, 0, 0, 0, 404, 10, 1], "semantic": {"name": "sources", "arg_names": [], "import_names": [], "rhs_call_name": "get_models", "annotation": ""}, "snippet": " sources = models.get_models()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:For_L28_C8", "label": "for source", "type": "for", "loc": [28, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L17_C4", "vector": [6, 2, 0.5397, 0.2063, 2, 0.84, 0.75, 703, 2, 0, 0, 0, 0, 0, 8], "semantic": {"name": "source", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for source in sources:\n if isinstance(source, models.base.ModelBase):\n for field in source._meta.fields:\n if isinstance(field, GeometryField):\n kml_sources.append((source._meta.app_label,\n source._meta.module_name,\n field.name))\n elif isinstance(source, (list, tuple)):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L29_C12", "label": "if", "type": "if", "loc": [29, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:For_L28_C8", "vector": [4, 3, 0.5476, 0.1905, 3, 0.56, 0.0, 0, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(source, models.base.ModelBase):\n for field in source._meta.fields:\n if isinstance(field, GeometryField):\n kml_sources.append((source._meta.app_label,\n source._meta.module_name,\n field.name))\n elif isinstance(source, (list, tuple)):\n if len(source) != 3: "}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:For_L30_C16", "label": "for field", "type": "for", "loc": [30, 34], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L29_C12", "vector": [6, 4, 0.5079, 0.0794, 4, 0.36, 0.0, 480, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field in source._meta.fields:\n if isinstance(field, GeometryField):\n kml_sources.append((source._meta.app_label,\n source._meta.module_name,\n field.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L31_C20", "label": "if", "type": "if", "loc": [31, 34], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:For_L30_C16", "vector": [4, 5, 0.5159, 0.0635, 5, 0.15, 0.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(field, GeometryField):\n kml_sources.append((source._meta.app_label,\n source._meta.module_name,\n field.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Expr_L32_C24", "label": "append()", "type": "expression", "loc": [32, 34], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L31_C20", "vector": [8, 6, 0.5238, 0.0476, 6, 0.52, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " kml_sources.append((source._meta.app_label,\n source._meta.module_name,\n field.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L35_C12", "label": "if", "type": "if", "loc": [35, 40], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L29_C12", "vector": [4, 4, 0.5952, 0.0952, 4, 0.36, 1.0, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(source, (list, tuple)):\n if len(source) != 3: \n raise ValueError('Must specify a 3-tuple of (app_label, module_name, field_name).')\n kml_sources.append(source)\n else:\n raise TypeError('KML Sources must be a model or a 3-tuple.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L36_C16", "label": "if", "type": "if", "loc": [36, 37], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L35_C12", "vector": [4, 5, 0.5794, 0.0317, 5, 0.94, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(source) != 3: \n raise ValueError('Must specify a 3-tuple of (app_label, module_name, field_name).')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Expr_L38_C16", "label": "append()", "type": "expression", "loc": [38, 38], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L35_C12", "vector": [8, 5, 0.6032, 0.0159, 5, 0.94, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " kml_sources.append(source)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Return_L41_C8", "label": "return", "type": "return", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L17_C4", "vector": [13, 2, 0.6508, 0.0159, 2, 0.84, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return kml_sources"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L43_C4", "label": "get_urls", "type": "function", "loc": [43, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "vector": [2, 1, 0.7381, 0.127, 1, 0.66, 0.6667, 974, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "get_urls", "arg_names": ["self", "page", "site"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_urls(self, page=1, site=None):\n \"\"\"\n This method is overrridden so the appropriate `geo_format` attribute\n is placed on each URL element.\n \"\"\"\n urls = Sitemap.get_urls(self, page=page, site=site)\n for url in urls: url['geo_format'] = self.geo_format\n return urls"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Expr_L44_C8", "label": "expression", "type": "expression", "loc": [44, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L43_C4", "vector": [8, 2, 0.7222, 0.0635, 2, 0.11, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This method is overrridden so the appropriate `geo_format` attribute\n is placed on each URL element.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L48_C8", "label": "urls = get_urls()", "type": "assigned_variable", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L43_C4", "vector": [14, 2, 0.7619, 0.0159, 2, 0.11, 0.3333, 260, 3, 3, 0, 0, 974, 10, 1], "semantic": {"name": "urls", "arg_names": [], "import_names": [], "rhs_call_name": "get_urls", "annotation": ""}, "snippet": " urls = Sitemap.get_urls(self, page=page, site=site)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:For_L49_C8", "label": "for url", "type": "for", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L43_C4", "vector": [6, 2, 0.7778, 0.0159, 2, 0.11, 0.6667, 789, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for url in urls: url['geo_format'] = self.geo_format"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L49_C25", "label": "assign", "type": "assigned_variable", "loc": [49, 49], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:For_L49_C8", "vector": [14, 3, 0.7778, 0.0159, 3, 0.52, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for url in urls: url['geo_format'] = self.geo_format"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Return_L50_C8", "label": "return", "type": "return", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L43_C4", "vector": [13, 2, 0.7937, 0.0159, 2, 0.11, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return urls"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L52_C4", "label": "items", "type": "function", "loc": [52, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "vector": [2, 1, 0.8333, 0.0317, 1, 0.66, 0.8333, 339, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "items", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def items(self):\n return self.locations"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Return_L53_C8", "label": "return", "type": "return", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L52_C4", "vector": [13, 2, 0.8413, 0.0159, 2, 0.23, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.locations"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L55_C4", "label": "location", "type": "function", "loc": [55, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "vector": [2, 1, 0.9206, 0.1111, 1, 0.66, 1.0, 771, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "location", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def location(self, obj):\n return urlresolvers.reverse('django.contrib.gis.sitemaps.views.%s' % self.geo_format,\n kwargs={'label' : obj[0], \n 'model' : obj[1],\n 'field_name': obj[2],\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Return_L56_C8", "label": "return", "type": "return", "loc": [56, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L55_C4", "vector": [13, 2, 0.9286, 0.0952, 2, 0.39, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return urlresolvers.reverse('django.contrib.gis.sitemaps.views.%s' % self.geo_format,\n kwargs={'label' : obj[0], \n 'model' : obj[1],\n 'field_name': obj[2],\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L62_C0", "label": "KMZSitemap", "type": "class", "loc": [62, 63], "level": 0, "parent": null, "vector": [3, 0, 0.9921, 0.0317, 0, 0.66, 1.0, 440, 0, 0, 0, 0, 604, 0, 0], "semantic": {"name": "KMZSitemap", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class KMZSitemap(KMLSitemap):\n geo_format = 'kmz'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L63_C4", "label": "geo_format =", "type": "assigned_variable", "loc": [63, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L62_C0", "vector": [14, 1, 1.0, 0.0159, 1, 0.55, 0.0, 698, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "geo_format", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " geo_format = 'kmz'"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Expr_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Expr_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L26_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L27_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:For_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:For_L28_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L29_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L29_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:For_L30_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:For_L30_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L31_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L31_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Expr_L32_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L29_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L35_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L35_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L36_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:If_L35_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Expr_L38_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Return_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Expr_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:For_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:For_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L49_C25"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Return_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Return_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:FunctionDef_L55_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Return_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98658:ClassDef_L62_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98658:Assign_L63_C4"}] |
from django.http import HttpResponse, Http404
from django.template import loader
from django.contrib.sites.models import get_current_site
from django.core import urlresolvers
from django.core.paginator import EmptyPage, PageNotAnInteger
from django.contrib.gis.db.models.fields import GeometryField
from django.db import connections, DEFAULT_DB_ALIAS
from django.db.models import get_model
from django.utils.encoding import smart_str
from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz
def index(request, sitemaps):
"""
This view generates a sitemap index that uses the proper view
for resolving geographic section sitemap URLs.
"""
current_site = get_current_site(request)
sites = []
protocol = request.is_secure() and 'https' or 'http'
for section, site in sitemaps.items():
if callable(site):
pages = site().paginator.num_pages
else:
pages = site.paginator.num_pages
sitemap_url = urlresolvers.reverse('django.contrib.gis.sitemaps.views.sitemap', kwargs={'section': section})
sites.append('%s://%s%s' % (protocol, current_site.domain, sitemap_url))
if pages > 1:
for page in range(2, pages+1):
sites.append('%s://%s%s?p=%s' % (protocol, current_site.domain, sitemap_url, page))
xml = loader.render_to_string('sitemap_index.xml', {'sitemaps': sites})
return HttpResponse(xml, mimetype='application/xml')
def sitemap(request, sitemaps, section=None):
"""
This view generates a sitemap with additional geographic
elements defined by Google.
"""
maps, urls = [], []
if section is not None:
if section not in sitemaps:
raise Http404("No sitemap available for section: %r" % section)
maps.append(sitemaps[section])
else:
maps = sitemaps.values()
page = request.GET.get("p", 1)
current_site = get_current_site(request)
for site in maps:
try:
if callable(site):
urls.extend(site().get_urls(page=page, site=current_site))
else:
urls.extend(site.get_urls(page=page, site=current_site))
except EmptyPage:
raise Http404("Page %s empty" % page)
except PageNotAnInteger:
raise Http404("No page '%s'" % page)
xml = smart_str(loader.render_to_string('gis/sitemaps/geo_sitemap.xml', {'urlset': urls}))
return HttpResponse(xml, mimetype='application/xml')
def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS):
"""
This view generates KML for the given app label, model, and field name.
The model's default manager must be GeoManager, and the field name
must be that of a geographic field.
"""
placemarks = []
klass = get_model(label, model)
if not klass:
raise Http404('You must supply a valid app label and module name. Got "%s.%s"' % (label, model))
if field_name:
try:
info = klass._meta.get_field_by_name(field_name)
if not isinstance(info[0], GeometryField):
raise Exception
except:
raise Http404('Invalid geometry field.')
connection = connections[using]
if connection.ops.postgis:
# PostGIS will take care of transformation.
placemarks = klass._default_manager.using(using).kml(field_name=field_name)
else:
# There's no KML method on Oracle or MySQL, so we use the `kml`
# attribute of the lazy geometry instead.
placemarks = []
if connection.ops.oracle:
qs = klass._default_manager.using(using).transform(4326, field_name=field_name)
else:
qs = klass._default_manager.using(using).all()
for mod in qs:
mod.kml = getattr(mod, field_name).kml
placemarks.append(mod)
# Getting the render function and rendering to the correct.
if compress:
render = render_to_kmz
else:
render = render_to_kml
return render('gis/kml/placemarks.kml', {'places' : placemarks})
def kmz(request, label, model, field_name=None, using=DEFAULT_DB_ALIAS):
"""
This view returns KMZ for the given app label, model, and field name.
"""
return kml(request, label, model, field_name, compress=True, using=using)
| ajibawa-2023/Python-Code-Large/train/row_98659 | 68 | 111 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98659:ImportFrom_L1_C0", "label": "from django.http import HttpResponse, Http404", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.009, 0.009, 0, 0.66, 0.0, 779, 0, 2, 0, 0, 779, 0, 0], "semantic": {"name": "django.http", "arg_names": [], "import_names": ["HttpResponse", "Http404"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.http import HttpResponse, Http404"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:ImportFrom_L2_C0", "label": "from django.template import loader", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.018, 0.009, 0, 0.66, 0.0769, 213, 0, 1, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["loader"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import loader"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:ImportFrom_L3_C0", "label": "from django.contrib.sites.models import get_current_site", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.027, 0.009, 0, 0.66, 0.1538, 890, 0, 1, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sites.models", "arg_names": [], "import_names": ["get_current_site"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sites.models import get_current_site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:ImportFrom_L4_C0", "label": "from django.core import urlresolvers", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.036, 0.009, 0, 0.66, 0.2308, 913, 0, 1, 0, 0, 913, 0, 0], "semantic": {"name": "django.core", "arg_names": [], "import_names": ["urlresolvers"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core import urlresolvers"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:ImportFrom_L5_C0", "label": "from django.core.paginator import EmptyPage, PageNotAnInteger", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.045, 0.009, 0, 0.66, 0.3077, 831, 0, 2, 0, 0, 831, 0, 0], "semantic": {"name": "django.core.paginator", "arg_names": [], "import_names": ["EmptyPage", "PageNotAnInteger"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.paginator import EmptyPage, PageNotAnInteger"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:ImportFrom_L6_C0", "label": "from django.contrib.gis.db.models.fields import GeometryField", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0541, 0.009, 0, 0.66, 0.3846, 708, 0, 1, 0, 0, 708, 0, 0], "semantic": {"name": "django.contrib.gis.db.models.fields", "arg_names": [], "import_names": ["GeometryField"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.db.models.fields import GeometryField"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:ImportFrom_L7_C0", "label": "from django.db import connections, DEFAULT_DB_ALIAS", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0631, 0.009, 0, 0.66, 0.4615, 40, 0, 2, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["connections", "DEFAULT_DB_ALIAS"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import connections, DEFAULT_DB_ALIAS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:ImportFrom_L8_C0", "label": "from django.db.models import get_model", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0721, 0.009, 0, 0.66, 0.5385, 680, 0, 1, 0, 0, 680, 0, 0], "semantic": {"name": "django.db.models", "arg_names": [], "import_names": ["get_model"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models import get_model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:ImportFrom_L9_C0", "label": "from django.utils.encoding import smart_str", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0811, 0.009, 0, 0.66, 0.6154, 96, 0, 1, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_str"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_str"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:ImportFrom_L11_C0", "label": "from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0991, 0.009, 0, 0.66, 0.6923, 833, 0, 2, 0, 0, 833, 0, 0], "semantic": {"name": "django.contrib.gis.shortcuts", "arg_names": [], "import_names": ["render_to_kml", "render_to_kmz"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "label": "index", "type": "function", "loc": [13, 33], "level": 0, "parent": null, "vector": [2, 0, 0.2072, 0.1892, 0, 0.66, 0.7692, 780, 0, 2, 1, 0, 0, 0, 11], "semantic": {"name": "index", "arg_names": ["request", "sitemaps"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def index(request, sitemaps):\n \"\"\"\n This view generates a sitemap index that uses the proper view\n for resolving geographic section sitemap URLs.\n \"\"\"\n current_site = get_current_site(request)\n sites = []\n protocol = request.is_secure() and 'https' or 'http'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L14_C4", "label": "expression", "type": "expression", "loc": [14, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "vector": [8, 1, 0.1396, 0.036, 1, 0.28, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This view generates a sitemap index that uses the proper view\n for resolving geographic section sitemap URLs.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L18_C4", "label": "current_site = get_current_site()", "type": "assigned_variable", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "vector": [14, 1, 0.1622, 0.009, 1, 0.28, 0.1667, 725, 3, 1, 0, 0, 760, 10, 1], "semantic": {"name": "current_site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current_site", "annotation": ""}, "snippet": " current_site = get_current_site(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L19_C4", "label": "sites =", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "vector": [14, 1, 0.1712, 0.009, 1, 0.28, 0.3333, 321, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "sites", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " sites = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L20_C4", "label": "protocol =", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "vector": [14, 1, 0.1802, 0.009, 1, 0.28, 0.5, 393, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "protocol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " protocol = request.is_secure() and 'https' or 'http'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L21_C4", "label": "for section, site", "type": "for", "loc": [21, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "vector": [6, 1, 0.2342, 0.0991, 1, 0.28, 0.6667, 300, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "section, site", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for section, site in sitemaps.items():\n if callable(site):\n pages = site().paginator.num_pages\n else:\n pages = site.paginator.num_pages\n sitemap_url = urlresolvers.reverse('django.contrib.gis.sitemaps.views.sitemap', kwargs={'section': section})\n sites.append('%s://%s%s' % (protocol, current_site.domain, sitemap_url))\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L22_C8", "label": "if", "type": "if", "loc": [22, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L21_C4", "vector": [4, 2, 0.2117, 0.036, 2, 0.67, 0.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if callable(site):\n pages = site().paginator.num_pages\n else:\n pages = site.paginator.num_pages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L23_C12", "label": "pages =", "type": "assigned_variable", "loc": [23, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L22_C8", "vector": [14, 3, 0.2072, 0.009, 3, 0.02, 0.0, 125, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "pages", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pages = site().paginator.num_pages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L25_C12", "label": "pages =", "type": "assigned_variable", "loc": [25, 25], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L22_C8", "vector": [14, 3, 0.2252, 0.009, 3, 0.02, 1.0, 125, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "pages", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pages = site.paginator.num_pages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L26_C8", "label": "sitemap_url = reverse()", "type": "assigned_variable", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L21_C4", "vector": [14, 2, 0.2342, 0.009, 2, 0.67, 0.3333, 538, 3, 2, 0, 0, 109, 10, 1], "semantic": {"name": "sitemap_url", "arg_names": [], "import_names": [], "rhs_call_name": "reverse", "annotation": ""}, "snippet": " sitemap_url = urlresolvers.reverse('django.contrib.gis.sitemaps.views.sitemap', kwargs={'section': section})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L27_C8", "label": "append()", "type": "expression", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L21_C4", "vector": [8, 2, 0.2432, 0.009, 2, 0.67, 0.6667, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " sites.append('%s://%s%s' % (protocol, current_site.domain, sitemap_url))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L29_C8", "label": "if", "type": "if", "loc": [29, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L21_C4", "vector": [4, 2, 0.2703, 0.027, 2, 0.67, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if pages > 1:\n for page in range(2, pages+1):\n sites.append('%s://%s%s?p=%s' % (protocol, current_site.domain, sitemap_url, page))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L30_C12", "label": "for page", "type": "for", "loc": [30, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L29_C8", "vector": [6, 3, 0.2748, 0.018, 3, 0.3, 0.0, 623, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "page", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for page in range(2, pages+1):\n sites.append('%s://%s%s?p=%s' % (protocol, current_site.domain, sitemap_url, page))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L31_C16", "label": "append()", "type": "expression", "loc": [31, 31], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L30_C12", "vector": [8, 4, 0.2793, 0.009, 4, 0.79, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " sites.append('%s://%s%s?p=%s' % (protocol, current_site.domain, sitemap_url, page))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L32_C4", "label": "xml = render_to_string()", "type": "assigned_variable", "loc": [32, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "vector": [14, 1, 0.2883, 0.009, 1, 0.28, 0.8333, 324, 3, 2, 0, 0, 851, 10, 1], "semantic": {"name": "xml", "arg_names": [], "import_names": [], "rhs_call_name": "render_to_string", "annotation": ""}, "snippet": " xml = loader.render_to_string('sitemap_index.xml', {'sitemaps': sites})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Return_L33_C4", "label": "return", "type": "return", "loc": [33, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "vector": [13, 1, 0.2973, 0.009, 1, 0.28, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponse(xml, mimetype='application/xml')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "label": "sitemap", "type": "function", "loc": [35, 61], "level": 0, "parent": null, "vector": [2, 0, 0.4324, 0.2432, 0, 0.66, 0.8462, 628, 0, 3, 1, 0, 0, 0, 16], "semantic": {"name": "sitemap", "arg_names": ["request", "sitemaps", "section"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def sitemap(request, sitemaps, section=None):\n \"\"\"\n This view generates a sitemap with additional geographic\n elements defined by Google.\n \"\"\"\n maps, urls = [], []\n if section is not None:\n if section not in sitemaps:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L36_C4", "label": "expression", "type": "expression", "loc": [36, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "vector": [8, 1, 0.3378, 0.036, 1, 0.16, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This view generates a sitemap with additional geographic\n elements defined by Google.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L40_C4", "label": "maps, urls =", "type": "assigned_variable", "loc": [40, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "vector": [14, 1, 0.3604, 0.009, 1, 0.16, 0.1429, 418, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "maps, urls", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " maps, urls = [], []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L41_C4", "label": "if", "type": "if", "loc": [41, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "vector": [4, 1, 0.3919, 0.0541, 1, 0.16, 0.2857, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if section is not None:\n if section not in sitemaps:\n raise Http404(\"No sitemap available for section: %r\" % section)\n maps.append(sitemaps[section])\n else:\n maps = sitemaps.values()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L42_C8", "label": "if", "type": "if", "loc": [42, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L41_C4", "vector": [4, 2, 0.3829, 0.018, 2, 0.7, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if section not in sitemaps:\n raise Http404(\"No sitemap available for section: %r\" % section)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L44_C8", "label": "append()", "type": "expression", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L41_C4", "vector": [8, 2, 0.3964, 0.009, 2, 0.7, 0.5, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " maps.append(sitemaps[section])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L46_C8", "label": "maps = values()", "type": "assigned_variable", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L41_C4", "vector": [14, 2, 0.4144, 0.009, 2, 0.7, 1.0, 262, 3, 0, 0, 0, 721, 10, 1], "semantic": {"name": "maps", "arg_names": [], "import_names": [], "rhs_call_name": "values", "annotation": ""}, "snippet": " maps = sitemaps.values()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L48_C4", "label": "page = get()", "type": "assigned_variable", "loc": [48, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "vector": [14, 1, 0.4324, 0.009, 1, 0.16, 0.4286, 623, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "page", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " page = request.GET.get(\"p\", 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L49_C4", "label": "current_site = get_current_site()", "type": "assigned_variable", "loc": [49, 49], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "vector": [14, 1, 0.4414, 0.009, 1, 0.16, 0.5714, 725, 3, 1, 0, 0, 760, 10, 1], "semantic": {"name": "current_site", "arg_names": [], "import_names": [], "rhs_call_name": "get_current_site", "annotation": ""}, "snippet": " current_site = get_current_site(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L50_C4", "label": "for site", "type": "for", "loc": [50, 59], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "vector": [6, 1, 0.491, 0.0901, 1, 0.16, 0.7143, 681, 2, 0, 0, 0, 0, 0, 8], "semantic": {"name": "site", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for site in maps:\n try:\n if callable(site):\n urls.extend(site().get_urls(page=page, site=current_site))\n else:\n urls.extend(site.get_urls(page=page, site=current_site))\n except EmptyPage:\n raise Http404(\"Page %s empty\" % page)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Try_L51_C8", "label": "try", "type": "try", "loc": [51, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L50_C4", "vector": [7, 2, 0.4955, 0.0811, 2, 0.73, 0.0, 0, 0, 2, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n if callable(site):\n urls.extend(site().get_urls(page=page, site=current_site))\n else:\n urls.extend(site.get_urls(page=page, site=current_site))\n except EmptyPage:\n raise Http404(\"Page %s empty\" % page)\n except PageNotAnInteger:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L52_C12", "label": "if", "type": "if", "loc": [52, 55], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:Try_L51_C8", "vector": [4, 3, 0.482, 0.036, 3, 0.07, 0.0, 0, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if callable(site):\n urls.extend(site().get_urls(page=page, site=current_site))\n else:\n urls.extend(site.get_urls(page=page, site=current_site))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L53_C16", "label": "extend()", "type": "expression", "loc": [53, 53], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L52_C12", "vector": [8, 4, 0.4775, 0.009, 4, 0.1, 0.0, 660, 3, 1, 0, 0, 0, 0, 3], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " urls.extend(site().get_urls(page=page, site=current_site))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L55_C16", "label": "extend()", "type": "expression", "loc": [55, 55], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L52_C12", "vector": [8, 4, 0.4955, 0.009, 4, 0.1, 1.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " urls.extend(site.get_urls(page=page, site=current_site))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L60_C4", "label": "xml = smart_str()", "type": "assigned_variable", "loc": [60, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "vector": [14, 1, 0.5405, 0.009, 1, 0.16, 0.8571, 324, 3, 1, 0, 0, 820, 10, 2], "semantic": {"name": "xml", "arg_names": [], "import_names": [], "rhs_call_name": "smart_str", "annotation": ""}, "snippet": " xml = smart_str(loader.render_to_string('gis/sitemaps/geo_sitemap.xml', {'urlset': urls}))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Return_L61_C4", "label": "return", "type": "return", "loc": [61, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "vector": [13, 1, 0.5495, 0.009, 1, 0.16, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return HttpResponse(xml, mimetype='application/xml')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "label": "kml", "type": "function", "loc": [63, 105], "level": 0, "parent": null, "vector": [2, 0, 0.7568, 0.3874, 0, 0.66, 0.9231, 168, 0, 6, 1, 0, 0, 0, 14], "semantic": {"name": "kml", "arg_names": ["request", "label", "model", "field_name", "compress", "using"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS):\n \"\"\"\n This view generates KML for the given app label, model, and field name.\n\n The model's default manager must be GeoManager, and the field name\n must be that of a geographic field.\n \"\"\"\n placemarks = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L64_C4", "label": "expression", "type": "expression", "loc": [64, 69], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "vector": [8, 1, 0.5991, 0.0541, 1, 0.72, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This view generates KML for the given app label, model, and field name.\n\n The model's default manager must be GeoManager, and the field name\n must be that of a geographic field.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L70_C4", "label": "placemarks =", "type": "assigned_variable", "loc": [70, 70], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "vector": [14, 1, 0.6306, 0.009, 1, 0.72, 0.125, 192, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "placemarks", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " placemarks = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L71_C4", "label": "klass = get_model()", "type": "assigned_variable", "loc": [71, 71], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "vector": [14, 1, 0.6396, 0.009, 1, 0.72, 0.25, 35, 3, 2, 0, 0, 115, 10, 1], "semantic": {"name": "klass", "arg_names": [], "import_names": [], "rhs_call_name": "get_model", "annotation": ""}, "snippet": " klass = get_model(label, model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L72_C4", "label": "if", "type": "if", "loc": [72, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "vector": [4, 1, 0.6532, 0.018, 1, 0.72, 0.375, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not klass:\n raise Http404('You must supply a valid app label and module name. Got \"%s.%s\"' % (label, model))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L75_C4", "label": "if", "type": "if", "loc": [75, 81], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "vector": [4, 1, 0.7027, 0.0631, 1, 0.72, 0.5, 0, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_name:\n try:\n info = klass._meta.get_field_by_name(field_name)\n if not isinstance(info[0], GeometryField):\n raise Exception\n except:\n raise Http404('Invalid geometry field.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Try_L76_C8", "label": "try", "type": "try", "loc": [76, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L75_C4", "vector": [7, 2, 0.7072, 0.0541, 2, 0.37, 0.0, 0, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n info = klass._meta.get_field_by_name(field_name)\n if not isinstance(info[0], GeometryField):\n raise Exception\n except:\n raise Http404('Invalid geometry field.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L77_C12", "label": "info = get_field_by_name()", "type": "assigned_variable", "loc": [77, 77], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:Try_L76_C8", "vector": [14, 3, 0.6937, 0.009, 3, 0.25, 0.0, 730, 3, 1, 0, 0, 779, 10, 1], "semantic": {"name": "info", "arg_names": [], "import_names": [], "rhs_call_name": "get_field_by_name", "annotation": ""}, "snippet": " info = klass._meta.get_field_by_name(field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L78_C12", "label": "if", "type": "if", "loc": [78, 79], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:Try_L76_C8", "vector": [4, 3, 0.7072, 0.018, 3, 0.25, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(info[0], GeometryField):\n raise Exception"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L83_C4", "label": "connection =", "type": "assigned_variable", "loc": [83, 83], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "vector": [14, 1, 0.7477, 0.009, 1, 0.72, 0.625, 351, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "connection", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " connection = connections[using]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L85_C4", "label": "if", "type": "if", "loc": [85, 98], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "vector": [4, 1, 0.8243, 0.1261, 1, 0.72, 0.75, 0, 7, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if connection.ops.postgis:\n # PostGIS will take care of transformation.\n placemarks = klass._default_manager.using(using).kml(field_name=field_name)\n else:\n # There's no KML method on Oracle or MySQL, so we use the `kml`\n # attribute of the lazy geometry instead.\n placemarks = []\n if connection.ops.oracle:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L87_C8", "label": "placemarks = kml()", "type": "assigned_variable", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L85_C4", "vector": [14, 2, 0.7838, 0.009, 2, 0.75, 0.0, 192, 3, 1, 0, 0, 168, 10, 2], "semantic": {"name": "placemarks", "arg_names": [], "import_names": [], "rhs_call_name": "kml", "annotation": ""}, "snippet": " placemarks = klass._default_manager.using(using).kml(field_name=field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L91_C8", "label": "placemarks =", "type": "assigned_variable", "loc": [91, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L85_C4", "vector": [14, 2, 0.8198, 0.009, 2, 0.75, 0.3333, 192, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "placemarks", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " placemarks = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L92_C8", "label": "if", "type": "if", "loc": [92, 95], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L85_C4", "vector": [4, 2, 0.8423, 0.036, 2, 0.75, 0.6667, 0, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if connection.ops.oracle:\n qs = klass._default_manager.using(using).transform(4326, field_name=field_name)\n else:\n qs = klass._default_manager.using(using).all()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L93_C12", "label": "qs = transform()", "type": "assigned_variable", "loc": [93, 93], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L92_C8", "vector": [14, 3, 0.8378, 0.009, 3, 0.37, 0.0, 251, 3, 2, 0, 0, 48, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "transform", "annotation": ""}, "snippet": " qs = klass._default_manager.using(using).transform(4326, field_name=field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L95_C12", "label": "qs = all()", "type": "assigned_variable", "loc": [95, 95], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L92_C8", "vector": [14, 3, 0.8559, 0.009, 3, 0.37, 1.0, 251, 3, 0, 0, 0, 895, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "all", "annotation": ""}, "snippet": " qs = klass._default_manager.using(using).all()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L96_C8", "label": "for mod", "type": "for", "loc": [96, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L85_C4", "vector": [6, 2, 0.8739, 0.027, 2, 0.75, 1.0, 25, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "mod", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for mod in qs:\n mod.kml = getattr(mod, field_name).kml\n placemarks.append(mod)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L97_C12", "label": "mod.kml =", "type": "assigned_variable", "loc": [97, 97], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L96_C8", "vector": [14, 3, 0.8739, 0.009, 3, 0.12, 0.0, 804, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "mod.kml", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " mod.kml = getattr(mod, field_name).kml"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L98_C12", "label": "append()", "type": "expression", "loc": [98, 98], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L96_C8", "vector": [8, 3, 0.8829, 0.009, 3, 0.12, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " placemarks.append(mod)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L101_C4", "label": "if", "type": "if", "loc": [101, 104], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "vector": [4, 1, 0.9234, 0.036, 1, 0.72, 0.875, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if compress:\n render = render_to_kmz\n else:\n render = render_to_kml"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L102_C8", "label": "render =", "type": "assigned_variable", "loc": [102, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L101_C4", "vector": [14, 2, 0.9189, 0.009, 2, 0.11, 0.0, 24, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "render", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " render = render_to_kmz"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L104_C8", "label": "render =", "type": "assigned_variable", "loc": [104, 104], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L101_C4", "vector": [14, 2, 0.9369, 0.009, 2, 0.11, 1.0, 24, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "render", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " render = render_to_kml"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Return_L105_C4", "label": "return", "type": "return", "loc": [105, 105], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "vector": [13, 1, 0.9459, 0.009, 1, 0.72, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render('gis/kml/placemarks.kml', {'places' : placemarks})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L107_C0", "label": "kmz", "type": "function", "loc": [107, 111], "level": 0, "parent": null, "vector": [2, 0, 0.982, 0.045, 0, 0.66, 1.0, 670, 0, 5, 1, 0, 0, 0, 1], "semantic": {"name": "kmz", "arg_names": ["request", "label", "model", "field_name", "using"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def kmz(request, label, model, field_name=None, using=DEFAULT_DB_ALIAS):\n \"\"\"\n This view returns KMZ for the given app label, model, and field name.\n \"\"\"\n return kml(request, label, model, field_name, compress=True, using=using)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L108_C4", "label": "expression", "type": "expression", "loc": [108, 110], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L107_C0", "vector": [8, 1, 0.982, 0.027, 1, 0.34, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This view returns KMZ for the given app label, model, and field name.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98659:Return_L111_C4", "label": "return", "type": "return", "loc": [111, 111], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L107_C0", "vector": [13, 1, 1.0, 0.009, 1, 0.34, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return kml(request, label, model, field_name, compress=True, using=using)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L23_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L25_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L30_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L31_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L32_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Return_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Try_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:Try_L51_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L52_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L52_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L53_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L52_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L55_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L60_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Return_L61_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L64_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L70_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L71_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L72_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L75_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Try_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:Try_L76_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L77_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:Try_L76_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L83_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L85_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L92_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L92_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L93_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L92_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L95_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L96_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L97_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:For_L96_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L98_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L101_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L101_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L102_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:If_L101_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Assign_L104_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Return_L105_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L107_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Expr_L108_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98659:FunctionDef_L107_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98659:Return_L111_C4"}] |
# Geo-enabled Sitemap classes.
from django.contrib.gis.sitemaps.georss import GeoRSSSitemap
from django.contrib.gis.sitemaps.kml import KMLSitemap, KMZSitemap
| ajibawa-2023/Python-Code-Large/train/row_98660 | 2 | 4 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98660:ImportFrom_L2_C0", "label": "from django.contrib.gis.sitemaps.georss import GeoRSSSitemap", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.5, 0.25, 0, 0.66, 0.0, 81, 0, 1, 0, 0, 81, 0, 0], "semantic": {"name": "django.contrib.gis.sitemaps.georss", "arg_names": [], "import_names": ["GeoRSSSitemap"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.sitemaps.georss import GeoRSSSitemap"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98660:ImportFrom_L3_C0", "label": "from django.contrib.gis.sitemaps.kml import KMLSitemap, KMZSitemap", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.75, 0.25, 0, 0.66, 1.0, 933, 0, 2, 0, 0, 933, 0, 0], "semantic": {"name": "django.contrib.gis.sitemaps.kml", "arg_names": [], "import_names": ["KMLSitemap", "KMZSitemap"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.sitemaps.kml import KMLSitemap, KMZSitemap"}] | [] |
from django.contrib.gis.geos import \
GEOSGeometry as Geometry, \
GEOSException as GeometryException
| ajibawa-2023/Python-Code-Large/train/row_98661 | 1 | 3 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98661:ImportFrom_L1_C0", "label": "from django.contrib.gis.geos import Geometry, GeometryException", "type": "import", "loc": [1, 3], "level": 0, "parent": null, "vector": [1, 0, 0.6667, 1.0, 0, 0.66, 0.0, 886, 0, 2, 0, 0, 886, 0, 0], "semantic": {"name": "django.contrib.gis.geos", "arg_names": [], "import_names": ["Geometry", "GeometryException"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.geos import \\\n GEOSGeometry as Geometry, \\\n GEOSException as GeometryException"}] | [] |
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.importlib import import_module
geom_backend = getattr(settings, 'GEOMETRY_BACKEND', 'geos')
try:
module = import_module('.%s' % geom_backend, 'django.contrib.gis.geometry.backend')
except ImportError, e:
try:
module = import_module(geom_backend)
except ImportError, e_user:
raise ImproperlyConfigured('Could not import user-defined GEOMETRY_BACKEND '
'"%s".' % geom_backend)
try:
Geometry = module.Geometry
GeometryException = module.GeometryException
except AttributeError:
raise ImproperlyConfigured('Cannot import Geometry from the "%s" '
'geometry backend.' % geom_backend)
| ajibawa-2023/Python-Code-Large/train/row_98662 | 3 | 4 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98662:ImportFrom_L1_C0", "label": "from django.conf import settings", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.25, 0.25, 0, 0.66, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98662:ImportFrom_L2_C0", "label": "from django.core.exceptions import ImproperlyConfigured", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.5, 0.25, 0, 0.66, 0.5, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["ImproperlyConfigured"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import ImproperlyConfigured"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98662:ImportFrom_L3_C0", "label": "from django.utils.importlib import import_module", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.75, 0.25, 0, 0.66, 1.0, 118, 0, 1, 0, 0, 118, 0, 0], "semantic": {"name": "django.utils.importlib", "arg_names": [], "import_names": ["import_module"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.importlib import import_module"}] | [] |
import re
# Regular expression for recognizing HEXEWKB and WKT. A prophylactic measure
# to prevent potentially malicious input from reaching the underlying C
# library. Not a substitute for good Web security programming practices.
hex_regex = re.compile(r'^[0-9A-F]+$', re.I)
wkt_regex = re.compile(r'^(SRID=(?P<srid>\d+);)?'
r'(?P<wkt>'
r'(?P<type>POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)'
r'[ACEGIMLONPSRUTYZ\d,\.\-\(\) ]+)$',
re.I)
json_regex = re.compile(r'^(\s+)?\{[\s\w,\[\]\{\}\-\."\':]+\}(\s+)?$')
| ajibawa-2023/Python-Code-Large/train/row_98663 | 4 | 12 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98663:Import_L1_C0", "label": "re import re", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0833, 0.0833, 0, 0.66, 0.0, 540, 0, 1, 0, 0, 540, 0, 0], "semantic": {"name": "re", "arg_names": [], "import_names": ["re"], "rhs_call_name": "", "annotation": ""}, "snippet": "import re"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98663:Assign_L6_C0", "label": "hex_regex = compile()", "type": "assigned_variable", "loc": [6, 6], "level": 0, "parent": null, "vector": [14, 0, 0.5, 0.0833, 0, 0.66, 0.3333, 439, 3, 2, 0, 0, 821, 10, 1], "semantic": {"name": "hex_regex", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": "hex_regex = re.compile(r'^[0-9A-F]+$', re.I)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98663:Assign_L7_C0", "label": "wkt_regex = compile()", "type": "assigned_variable", "loc": [7, 11], "level": 0, "parent": null, "vector": [14, 0, 0.75, 0.4167, 0, 0.66, 0.6667, 665, 3, 2, 0, 0, 821, 10, 1], "semantic": {"name": "wkt_regex", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": "wkt_regex = re.compile(r'^(SRID=(?P<srid>\\d+);)?'\n r'(?P<wkt>'\n r'(?P<type>POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)'\n r'[ACEGIMLONPSRUTYZ\\d,\\.\\-\\(\\) ]+)$',\n re.I)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98663:Assign_L12_C0", "label": "json_regex = compile()", "type": "assigned_variable", "loc": [12, 12], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0833, 0, 0.66, 1.0, 970, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "json_regex", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": "json_regex = re.compile(r'^(\\s+)?\\{[\\s\\w,\\[\\]\\{\\}\\-\\.\"\\':]+\\}(\\s+)?$')"}] | [] |
from django.contrib.gis.geos import GEOSGeometry, LinearRing, Polygon, Point
from django.contrib.gis.maps.google.gmap import GoogleMapException
from math import pi, sin, cos, log, exp, atan
# Constants used for degree to radian conversion, and vice-versa.
DTOR = pi / 180.
RTOD = 180. / pi
class GoogleZoom(object):
"""
GoogleZoom is a utility for performing operations related to the zoom
levels on Google Maps.
This class is inspired by the OpenStreetMap Mapnik tile generation routine
`generate_tiles.py`, and the article "How Big Is the World" (Hack #16) in
"Google Maps Hacks" by Rich Gibson and Schuyler Erle.
`generate_tiles.py` may be found at:
http://trac.openstreetmap.org/browser/applications/rendering/mapnik/generate_tiles.py
"Google Maps Hacks" may be found at http://safari.oreilly.com/0596101619
"""
def __init__(self, num_zoom=19, tilesize=256):
"Initializes the Google Zoom object."
# Google's tilesize is 256x256, square tiles are assumed.
self._tilesize = tilesize
# The number of zoom levels
self._nzoom = num_zoom
# Initializing arrays to hold the parameters for each one of the
# zoom levels.
self._degpp = [] # Degrees per pixel
self._radpp = [] # Radians per pixel
self._npix = [] # 1/2 the number of pixels for a tile at the given zoom level
# Incrementing through the zoom levels and populating the parameter arrays.
z = tilesize # The number of pixels per zoom level.
for i in xrange(num_zoom):
# Getting the degrees and radians per pixel, and the 1/2 the number of
# for every zoom level.
self._degpp.append(z / 360.) # degrees per pixel
self._radpp.append(z / (2 * pi)) # radians per pixl
self._npix.append(z / 2) # number of pixels to center of tile
# Multiplying `z` by 2 for the next iteration.
z *= 2
def __len__(self):
"Returns the number of zoom levels."
return self._nzoom
def get_lon_lat(self, lonlat):
"Unpacks longitude, latitude from GEOS Points and 2-tuples."
if isinstance(lonlat, Point):
lon, lat = lonlat.coords
else:
lon, lat = lonlat
return lon, lat
def lonlat_to_pixel(self, lonlat, zoom):
"Converts a longitude, latitude coordinate pair for the given zoom level."
# Setting up, unpacking the longitude, latitude values and getting the
# number of pixels for the given zoom level.
lon, lat = self.get_lon_lat(lonlat)
npix = self._npix[zoom]
# Calculating the pixel x coordinate by multiplying the longitude value
# with with the number of degrees/pixel at the given zoom level.
px_x = round(npix + (lon * self._degpp[zoom]))
# Creating the factor, and ensuring that 1 or -1 is not passed in as the
# base to the logarithm. Here's why:
# if fac = -1, we'll get log(0) which is undefined;
# if fac = 1, our logarithm base will be divided by 0, also undefined.
fac = min(max(sin(DTOR * lat), -0.9999), 0.9999)
# Calculating the pixel y coordinate.
px_y = round(npix + (0.5 * log((1 + fac)/(1 - fac)) * (-1.0 * self._radpp[zoom])))
# Returning the pixel x, y to the caller of the function.
return (px_x, px_y)
def pixel_to_lonlat(self, px, zoom):
"Converts a pixel to a longitude, latitude pair at the given zoom level."
if len(px) != 2:
raise TypeError('Pixel should be a sequence of two elements.')
# Getting the number of pixels for the given zoom level.
npix = self._npix[zoom]
# Calculating the longitude value, using the degrees per pixel.
lon = (px[0] - npix) / self._degpp[zoom]
# Calculating the latitude value.
lat = RTOD * ( 2 * atan(exp((px[1] - npix)/ (-1.0 * self._radpp[zoom]))) - 0.5 * pi)
# Returning the longitude, latitude coordinate pair.
return (lon, lat)
def tile(self, lonlat, zoom):
"""
Returns a Polygon corresponding to the region represented by a fictional
Google Tile for the given longitude/latitude pair and zoom level. This
tile is used to determine the size of a tile at the given point.
"""
# The given lonlat is the center of the tile.
delta = self._tilesize / 2
# Getting the pixel coordinates corresponding to the
# the longitude/latitude.
px = self.lonlat_to_pixel(lonlat, zoom)
# Getting the lower-left and upper-right lat/lon coordinates
# for the bounding box of the tile.
ll = self.pixel_to_lonlat((px[0]-delta, px[1]-delta), zoom)
ur = self.pixel_to_lonlat((px[0]+delta, px[1]+delta), zoom)
# Constructing the Polygon, representing the tile and returning.
return Polygon(LinearRing(ll, (ll[0], ur[1]), ur, (ur[0], ll[1]), ll), srid=4326)
def get_zoom(self, geom):
"Returns the optimal Zoom level for the given geometry."
# Checking the input type.
if not isinstance(geom, GEOSGeometry) or geom.srid != 4326:
raise TypeError('get_zoom() expects a GEOS Geometry with an SRID of 4326.')
# Getting the envelope for the geometry, and its associated width, height
# and centroid.
env = geom.envelope
env_w, env_h = self.get_width_height(env.extent)
center = env.centroid
for z in xrange(self._nzoom):
# Getting the tile at the zoom level.
tile_w, tile_h = self.get_width_height(self.tile(center, z).extent)
# When we span more than one tile, this is an approximately good
# zoom level.
if (env_w > tile_w) or (env_h > tile_h):
if z == 0:
raise GoogleMapException('Geometry width and height should not exceed that of the Earth.')
return z-1
# Otherwise, we've zoomed in to the max.
return self._nzoom-1
def get_width_height(self, extent):
"""
Returns the width and height for the given extent.
"""
# Getting the lower-left, upper-left, and upper-right
# coordinates from the extent.
ll = Point(extent[:2])
ul = Point(extent[0], extent[3])
ur = Point(extent[2:])
# Calculating the width and height.
height = ll.distance(ul)
width = ul.distance(ur)
return width, height
| ajibawa-2023/Python-Code-Large/train/row_98664 | 70 | 161 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98664:ImportFrom_L1_C0", "label": "from django.contrib.gis.geos import GEOSGeometry, LinearRing, Polygon\u2026", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0062, 0.0062, 0, 0.66, 0.0, 886, 0, 4, 0, 0, 886, 0, 0], "semantic": {"name": "django.contrib.gis.geos", "arg_names": [], "import_names": ["GEOSGeometry", "LinearRing", "Polygon", "Point"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.geos import GEOSGeometry, LinearRing, Polygon, Point"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:ImportFrom_L2_C0", "label": "from django.contrib.gis.maps.google.gmap import GoogleMapException", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0124, 0.0062, 0, 0.66, 0.2, 633, 0, 1, 0, 0, 633, 0, 0], "semantic": {"name": "django.contrib.gis.maps.google.gmap", "arg_names": [], "import_names": ["GoogleMapException"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.maps.google.gmap import GoogleMapException"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:ImportFrom_L3_C0", "label": "from math import pi, sin, cos\u2026", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0186, 0.0062, 0, 0.66, 0.4, 526, 0, 6, 0, 0, 526, 0, 0], "semantic": {"name": "math", "arg_names": [], "import_names": ["pi", "sin", "cos", "log", "exp", "atan"], "rhs_call_name": "", "annotation": ""}, "snippet": "from math import pi, sin, cos, log, exp, atan"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L6_C0", "label": "DTOR =", "type": "assigned_variable", "loc": [6, 6], "level": 0, "parent": null, "vector": [14, 0, 0.0373, 0.0062, 0, 0.66, 0.6, 731, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "DTOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DTOR = pi / 180."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L7_C0", "label": "RTOD =", "type": "assigned_variable", "loc": [7, 7], "level": 0, "parent": null, "vector": [14, 0, 0.0435, 0.0062, 0, 0.66, 0.8, 754, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "RTOD", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "RTOD = 180. / pi"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "label": "GoogleZoom", "type": "class", "loc": [9, 161], "level": 0, "parent": null, "vector": [3, 0, 0.528, 0.9503, 0, 0.66, 1.0, 157, 0, 8, 0, 0, 186, 0, 33], "semantic": {"name": "GoogleZoom", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GoogleZoom(object):\n \"\"\"\n GoogleZoom is a utility for performing operations related to the zoom\n levels on Google Maps.\n\n This class is inspired by the OpenStreetMap Mapnik tile generation routine\n `generate_tiles.py`, and the article \"How Big Is the World\" (Hack #16) in\n \"Google Maps Hacks\" by Rich Gibson and Schuyler Erle."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L10_C4", "label": "expression", "type": "expression", "loc": [10, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "vector": [8, 1, 0.0994, 0.0807, 1, 0.09, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n GoogleZoom is a utility for performing operations related to the zoom\n levels on Google Maps.\n\n This class is inspired by the OpenStreetMap Mapnik tile generation routine\n `generate_tiles.py`, and the article \"How Big Is the World\" (Hack #16) in\n \"Google Maps Hacks\" by Rich Gibson and Schuyler Erle.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "label": "__init__", "type": "function", "loc": [24, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "vector": [2, 1, 0.2236, 0.1553, 1, 0.09, 0.125, 555, 0, 3, 0, 0, 0, 0, 4], "semantic": {"name": "__init__", "arg_names": ["self", "num_zoom", "tilesize"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, num_zoom=19, tilesize=256):\n \"Initializes the Google Zoom object.\"\n # Google's tilesize is 256x256, square tiles are assumed.\n self._tilesize = tilesize\n \n # The number of zoom levels\n self._nzoom = num_zoom\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L25_C8", "label": "expression", "type": "expression", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "vector": [8, 2, 0.1553, 0.0062, 2, 0.71, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Initializes the Google Zoom object.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L27_C8", "label": "self._tilesize =", "type": "assigned_variable", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "vector": [14, 2, 0.1677, 0.0062, 2, 0.71, 0.1429, 378, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._tilesize", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._tilesize = tilesize"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L30_C8", "label": "self._nzoom =", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "vector": [14, 2, 0.1863, 0.0062, 2, 0.71, 0.2857, 945, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._nzoom", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._nzoom = num_zoom"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L34_C8", "label": "self._degpp =", "type": "assigned_variable", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "vector": [14, 2, 0.2112, 0.0062, 2, 0.71, 0.4286, 807, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self._degpp", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._degpp = [] # Degrees per pixel"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L35_C8", "label": "self._radpp =", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "vector": [14, 2, 0.2174, 0.0062, 2, 0.71, 0.5714, 494, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self._radpp", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._radpp = [] # Radians per pixel"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L36_C8", "label": "self._npix =", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "vector": [14, 2, 0.2236, 0.0062, 2, 0.71, 0.7143, 333, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self._npix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._npix = [] # 1/2 the number of pixels for a tile at the given zoom level"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L39_C8", "label": "z =", "type": "assigned_variable", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "vector": [14, 2, 0.2422, 0.0062, 2, 0.71, 0.8571, 859, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "z", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " z = tilesize # The number of pixels per zoom level."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L40_C8", "label": "for i", "type": "for", "loc": [40, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "vector": [6, 2, 0.2733, 0.0559, 2, 0.71, 1.0, 826, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "i", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i in xrange(num_zoom):\n # Getting the degrees and radians per pixel, and the 1/2 the number of\n # for every zoom level.\n self._degpp.append(z / 360.) # degrees per pixel\n self._radpp.append(z / (2 * pi)) # radians per pixl\n self._npix.append(z / 2) # number of pixels to center of tile\n\n # Multiplying `z` by 2 for the next iteration."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L43_C12", "label": "append()", "type": "expression", "loc": [43, 43], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L40_C8", "vector": [8, 3, 0.2671, 0.0062, 3, 0.38, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " self._degpp.append(z / 360.) # degrees per pixel"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L44_C12", "label": "append()", "type": "expression", "loc": [44, 44], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L40_C8", "vector": [8, 3, 0.2733, 0.0062, 3, 0.38, 0.5, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " self._radpp.append(z / (2 * pi)) # radians per pixl"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L45_C12", "label": "append()", "type": "expression", "loc": [45, 45], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L40_C8", "vector": [8, 3, 0.2795, 0.0062, 3, 0.38, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " self._npix.append(z / 2) # number of pixels to center of tile"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L50_C4", "label": "__len__", "type": "function", "loc": [50, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "vector": [2, 1, 0.3168, 0.0186, 1, 0.09, 0.25, 76, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__len__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __len__(self):\n \"Returns the number of zoom levels.\"\n return self._nzoom"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L51_C8", "label": "expression", "type": "expression", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L50_C4", "vector": [8, 2, 0.3168, 0.0062, 2, 0.72, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the number of zoom levels.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L52_C8", "label": "return", "type": "return", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L50_C4", "vector": [13, 2, 0.323, 0.0062, 2, 0.72, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._nzoom"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L54_C4", "label": "get_lon_lat", "type": "function", "loc": [54, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "vector": [2, 1, 0.354, 0.0435, 1, 0.09, 0.375, 613, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "get_lon_lat", "arg_names": ["self", "lonlat"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_lon_lat(self, lonlat):\n \"Unpacks longitude, latitude from GEOS Points and 2-tuples.\"\n if isinstance(lonlat, Point):\n lon, lat = lonlat.coords\n else:\n lon, lat = lonlat\n return lon, lat"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L55_C8", "label": "expression", "type": "expression", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L54_C4", "vector": [8, 2, 0.3416, 0.0062, 2, 0.06, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Unpacks longitude, latitude from GEOS Points and 2-tuples.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L56_C8", "label": "if", "type": "if", "loc": [56, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L54_C4", "vector": [4, 2, 0.3571, 0.0248, 2, 0.06, 0.5, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(lonlat, Point):\n lon, lat = lonlat.coords\n else:\n lon, lat = lonlat"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L57_C12", "label": "lon, lat =", "type": "assigned_variable", "loc": [57, 57], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L56_C8", "vector": [14, 3, 0.354, 0.0062, 3, 0.14, 0.0, 949, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "lon, lat", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lon, lat = lonlat.coords"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L59_C12", "label": "lon, lat =", "type": "assigned_variable", "loc": [59, 59], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L56_C8", "vector": [14, 3, 0.3665, 0.0062, 3, 0.14, 1.0, 949, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "lon, lat", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lon, lat = lonlat"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L60_C8", "label": "return", "type": "return", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L54_C4", "vector": [13, 2, 0.3727, 0.0062, 2, 0.06, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return lon, lat"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "label": "lonlat_to_pixel", "type": "function", "loc": [62, 83], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "vector": [2, 1, 0.4503, 0.1366, 1, 0.09, 0.5, 70, 0, 3, 1, 0, 0, 0, 7], "semantic": {"name": "lonlat_to_pixel", "arg_names": ["self", "lonlat", "zoom"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def lonlat_to_pixel(self, lonlat, zoom):\n \"Converts a longitude, latitude coordinate pair for the given zoom level.\"\n # Setting up, unpacking the longitude, latitude values and getting the\n # number of pixels for the given zoom level.\n lon, lat = self.get_lon_lat(lonlat)\n npix = self._npix[zoom]\n\n # Calculating the pixel x coordinate by multiplying the longitude value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L63_C8", "label": "expression", "type": "expression", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "vector": [8, 2, 0.3913, 0.0062, 2, 0.86, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Converts a longitude, latitude coordinate pair for the given zoom level.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L66_C8", "label": "lon, lat = get_lon_lat()", "type": "assigned_variable", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "vector": [14, 2, 0.4099, 0.0062, 2, 0.86, 0.1667, 949, 3, 1, 0, 0, 613, 10, 1], "semantic": {"name": "lon, lat", "arg_names": [], "import_names": [], "rhs_call_name": "get_lon_lat", "annotation": ""}, "snippet": " lon, lat = self.get_lon_lat(lonlat)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L67_C8", "label": "npix =", "type": "assigned_variable", "loc": [67, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "vector": [14, 2, 0.4161, 0.0062, 2, 0.86, 0.3333, 674, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "npix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " npix = self._npix[zoom]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L71_C8", "label": "px_x = round()", "type": "assigned_variable", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "vector": [14, 2, 0.441, 0.0062, 2, 0.86, 0.5, 305, 3, 1, 0, 0, 19, 10, 1], "semantic": {"name": "px_x", "arg_names": [], "import_names": [], "rhs_call_name": "round", "annotation": ""}, "snippet": " px_x = round(npix + (lon * self._degpp[zoom]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L77_C8", "label": "fac = min()", "type": "assigned_variable", "loc": [77, 77], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "vector": [14, 2, 0.4783, 0.0062, 2, 0.86, 0.6667, 672, 3, 2, 0, 0, 867, 10, 3], "semantic": {"name": "fac", "arg_names": [], "import_names": [], "rhs_call_name": "min", "annotation": ""}, "snippet": " fac = min(max(sin(DTOR * lat), -0.9999), 0.9999)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L80_C8", "label": "px_y = round()", "type": "assigned_variable", "loc": [80, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "vector": [14, 2, 0.4969, 0.0062, 2, 0.86, 0.8333, 214, 3, 1, 0, 0, 19, 10, 2], "semantic": {"name": "px_y", "arg_names": [], "import_names": [], "rhs_call_name": "round", "annotation": ""}, "snippet": " px_y = round(npix + (0.5 * log((1 + fac)/(1 - fac)) * (-1.0 * self._radpp[zoom])))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L83_C8", "label": "return", "type": "return", "loc": [83, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "vector": [13, 2, 0.5155, 0.0062, 2, 0.86, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return (px_x, px_y)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "label": "pixel_to_lonlat", "type": "function", "loc": [85, 100], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "vector": [2, 1, 0.5745, 0.0994, 1, 0.09, 0.625, 990, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "pixel_to_lonlat", "arg_names": ["self", "px", "zoom"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def pixel_to_lonlat(self, px, zoom):\n \"Converts a pixel to a longitude, latitude pair at the given zoom level.\"\n if len(px) != 2:\n raise TypeError('Pixel should be a sequence of two elements.')\n\n # Getting the number of pixels for the given zoom level.\n npix = self._npix[zoom]\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L86_C8", "label": "expression", "type": "expression", "loc": [86, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "vector": [8, 2, 0.5342, 0.0062, 2, 0.83, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Converts a pixel to a longitude, latitude pair at the given zoom level.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L87_C8", "label": "if", "type": "if", "loc": [87, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "vector": [4, 2, 0.5435, 0.0124, 2, 0.83, 0.2, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(px) != 2:\n raise TypeError('Pixel should be a sequence of two elements.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L91_C8", "label": "npix =", "type": "assigned_variable", "loc": [91, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "vector": [14, 2, 0.5652, 0.0062, 2, 0.83, 0.4, 674, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "npix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " npix = self._npix[zoom]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L94_C8", "label": "lon =", "type": "assigned_variable", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "vector": [14, 2, 0.5839, 0.0062, 2, 0.83, 0.6, 646, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "lon", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lon = (px[0] - npix) / self._degpp[zoom]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L97_C8", "label": "lat =", "type": "assigned_variable", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "vector": [14, 2, 0.6025, 0.0062, 2, 0.83, 0.8, 833, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "lat", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lat = RTOD * ( 2 * atan(exp((px[1] - npix)/ (-1.0 * self._radpp[zoom]))) - 0.5 * pi)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L100_C8", "label": "return", "type": "return", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "vector": [13, 2, 0.6211, 0.0062, 2, 0.83, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return (lon, lat)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "label": "tile", "type": "function", "loc": [102, 121], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "vector": [2, 1, 0.6925, 0.1242, 1, 0.09, 0.75, 319, 0, 3, 1, 0, 0, 0, 5], "semantic": {"name": "tile", "arg_names": ["self", "lonlat", "zoom"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def tile(self, lonlat, zoom):\n \"\"\"\n Returns a Polygon corresponding to the region represented by a fictional\n Google Tile for the given longitude/latitude pair and zoom level. This\n tile is used to determine the size of a tile at the given point.\n \"\"\"\n # The given lonlat is the center of the tile.\n delta = self._tilesize / 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L103_C8", "label": "expression", "type": "expression", "loc": [103, 107], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "vector": [8, 2, 0.6522, 0.0311, 2, 0.99, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a Polygon corresponding to the region represented by a fictional\n Google Tile for the given longitude/latitude pair and zoom level. This\n tile is used to determine the size of a tile at the given point.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L109_C8", "label": "delta =", "type": "assigned_variable", "loc": [109, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "vector": [14, 2, 0.677, 0.0062, 2, 0.99, 0.2, 593, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "delta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " delta = self._tilesize / 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L113_C8", "label": "px = lonlat_to_pixel()", "type": "assigned_variable", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "vector": [14, 2, 0.7019, 0.0062, 2, 0.99, 0.4, 422, 3, 2, 0, 0, 70, 10, 1], "semantic": {"name": "px", "arg_names": [], "import_names": [], "rhs_call_name": "lonlat_to_pixel", "annotation": ""}, "snippet": " px = self.lonlat_to_pixel(lonlat, zoom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L117_C8", "label": "ll = pixel_to_lonlat()", "type": "assigned_variable", "loc": [117, 117], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "vector": [14, 2, 0.7267, 0.0062, 2, 0.99, 0.6, 929, 3, 2, 0, 0, 990, 10, 1], "semantic": {"name": "ll", "arg_names": [], "import_names": [], "rhs_call_name": "pixel_to_lonlat", "annotation": ""}, "snippet": " ll = self.pixel_to_lonlat((px[0]-delta, px[1]-delta), zoom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L118_C8", "label": "ur = pixel_to_lonlat()", "type": "assigned_variable", "loc": [118, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "vector": [14, 2, 0.7329, 0.0062, 2, 0.99, 0.8, 611, 3, 2, 0, 0, 990, 10, 1], "semantic": {"name": "ur", "arg_names": [], "import_names": [], "rhs_call_name": "pixel_to_lonlat", "annotation": ""}, "snippet": " ur = self.pixel_to_lonlat((px[0]+delta, px[1]+delta), zoom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L121_C8", "label": "return", "type": "return", "loc": [121, 121], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "vector": [13, 2, 0.7516, 0.0062, 2, 0.99, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return Polygon(LinearRing(ll, (ll[0], ur[1]), ur, (ur[0], ll[1]), ll), srid=4326)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "label": "get_zoom", "type": "function", "loc": [123, 147], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "vector": [2, 1, 0.8385, 0.1553, 1, 0.09, 0.875, 219, 0, 2, 1, 0, 0, 0, 7], "semantic": {"name": "get_zoom", "arg_names": ["self", "geom"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_zoom(self, geom):\n \"Returns the optimal Zoom level for the given geometry.\"\n # Checking the input type.\n if not isinstance(geom, GEOSGeometry) or geom.srid != 4326:\n raise TypeError('get_zoom() expects a GEOS Geometry with an SRID of 4326.')\n\n # Getting the envelope for the geometry, and its associated width, height\n # and centroid."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L124_C8", "label": "expression", "type": "expression", "loc": [124, 124], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "vector": [8, 2, 0.7702, 0.0062, 2, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the optimal Zoom level for the given geometry.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L126_C8", "label": "if", "type": "if", "loc": [126, 127], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "vector": [4, 2, 0.7857, 0.0124, 2, 0.66, 0.1667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(geom, GEOSGeometry) or geom.srid != 4326:\n raise TypeError('get_zoom() expects a GEOS Geometry with an SRID of 4326.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L131_C8", "label": "env =", "type": "assigned_variable", "loc": [131, 131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "vector": [14, 2, 0.8137, 0.0062, 2, 0.66, 0.3333, 803, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "env", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " env = geom.envelope"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L132_C8", "label": "env_w, env_h = get_width_height()", "type": "assigned_variable", "loc": [132, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "vector": [14, 2, 0.8199, 0.0062, 2, 0.66, 0.5, 759, 3, 1, 0, 0, 540, 10, 1], "semantic": {"name": "env_w, env_h", "arg_names": [], "import_names": [], "rhs_call_name": "get_width_height", "annotation": ""}, "snippet": " env_w, env_h = self.get_width_height(env.extent)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L133_C8", "label": "center =", "type": "assigned_variable", "loc": [133, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "vector": [14, 2, 0.8261, 0.0062, 2, 0.66, 0.6667, 546, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "center", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " center = env.centroid"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L135_C8", "label": "for z", "type": "for", "loc": [135, 144], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "vector": [6, 2, 0.8665, 0.0621, 2, 0.66, 0.8333, 859, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "z", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for z in xrange(self._nzoom):\n # Getting the tile at the zoom level.\n tile_w, tile_h = self.get_width_height(self.tile(center, z).extent)\n\n # When we span more than one tile, this is an approximately good\n # zoom level.\n if (env_w > tile_w) or (env_h > tile_h):\n if z == 0: "}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L137_C12", "label": "tile_w, tile_h = get_width_height()", "type": "assigned_variable", "loc": [137, 137], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L135_C8", "vector": [14, 3, 0.8509, 0.0062, 3, 0.94, 0.0, 646, 3, 1, 0, 0, 540, 10, 2], "semantic": {"name": "tile_w, tile_h", "arg_names": [], "import_names": [], "rhs_call_name": "get_width_height", "annotation": ""}, "snippet": " tile_w, tile_h = self.get_width_height(self.tile(center, z).extent)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L141_C12", "label": "if", "type": "if", "loc": [141, 144], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L135_C8", "vector": [4, 3, 0.8851, 0.0248, 3, 0.94, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if (env_w > tile_w) or (env_h > tile_h):\n if z == 0: \n raise GoogleMapException('Geometry width and height should not exceed that of the Earth.')\n return z-1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L142_C16", "label": "if", "type": "if", "loc": [142, 143], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L141_C12", "vector": [4, 4, 0.8851, 0.0124, 4, 0.22, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if z == 0: \n raise GoogleMapException('Geometry width and height should not exceed that of the Earth.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L144_C16", "label": "return", "type": "return", "loc": [144, 144], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L141_C12", "vector": [13, 4, 0.8944, 0.0062, 4, 0.22, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return z-1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L147_C8", "label": "return", "type": "return", "loc": [147, 147], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "vector": [13, 2, 0.913, 0.0062, 2, 0.66, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._nzoom-1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "label": "get_width_height", "type": "function", "loc": [149, 161], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "vector": [2, 1, 0.9627, 0.0807, 1, 0.09, 1.0, 540, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "get_width_height", "arg_names": ["self", "extent"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_width_height(self, extent):\n \"\"\"\n Returns the width and height for the given extent.\n \"\"\"\n # Getting the lower-left, upper-left, and upper-right\n # coordinates from the extent.\n ll = Point(extent[:2])\n ul = Point(extent[0], extent[3])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L150_C8", "label": "expression", "type": "expression", "loc": [150, 152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "vector": [8, 2, 0.9379, 0.0186, 2, 0.0, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns the width and height for the given extent.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L155_C8", "label": "ll = Point()", "type": "assigned_variable", "loc": [155, 155], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "vector": [14, 2, 0.9627, 0.0062, 2, 0.0, 0.1667, 929, 3, 1, 0, 0, 652, 10, 1], "semantic": {"name": "ll", "arg_names": [], "import_names": [], "rhs_call_name": "Point", "annotation": ""}, "snippet": " ll = Point(extent[:2])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L156_C8", "label": "ul = Point()", "type": "assigned_variable", "loc": [156, 156], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "vector": [14, 2, 0.9689, 0.0062, 2, 0.0, 0.3333, 608, 3, 2, 0, 0, 652, 10, 1], "semantic": {"name": "ul", "arg_names": [], "import_names": [], "rhs_call_name": "Point", "annotation": ""}, "snippet": " ul = Point(extent[0], extent[3])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L157_C8", "label": "ur = Point()", "type": "assigned_variable", "loc": [157, 157], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "vector": [14, 2, 0.9752, 0.0062, 2, 0.0, 0.5, 611, 3, 1, 0, 0, 652, 10, 1], "semantic": {"name": "ur", "arg_names": [], "import_names": [], "rhs_call_name": "Point", "annotation": ""}, "snippet": " ur = Point(extent[2:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L159_C8", "label": "height = distance()", "type": "assigned_variable", "loc": [159, 159], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "vector": [14, 2, 0.9876, 0.0062, 2, 0.0, 0.6667, 751, 3, 1, 0, 0, 145, 10, 1], "semantic": {"name": "height", "arg_names": [], "import_names": [], "rhs_call_name": "distance", "annotation": ""}, "snippet": " height = ll.distance(ul)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L160_C8", "label": "width = distance()", "type": "assigned_variable", "loc": [160, 160], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "vector": [14, 2, 0.9938, 0.0062, 2, 0.0, 0.8333, 989, 3, 1, 0, 0, 145, 10, 1], "semantic": {"name": "width", "arg_names": [], "import_names": [], "rhs_call_name": "distance", "annotation": ""}, "snippet": " width = ul.distance(ur)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L161_C8", "label": "return", "type": "return", "loc": [161, 161], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "vector": [13, 2, 1.0, 0.0062, 2, 0.0, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return width, height"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L40_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L43_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L40_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L44_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L40_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L45_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L56_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L57_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L56_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L59_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L83_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L103_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L117_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L121_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L124_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L132_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L135_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L135_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L137_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:For_L135_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L141_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L142_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:If_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L144_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L123_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L147_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Expr_L150_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L155_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L157_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L159_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Assign_L160_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98664:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98664:Return_L161_C8"}] |
from django.utils.safestring import mark_safe
from django.contrib.gis.geos import fromstr, Point, LineString, LinearRing, Polygon
class GEvent(object):
"""
A Python wrapper for the Google GEvent object.
Events can be attached to any object derived from GOverlayBase with the
add_event() call.
For more information please see the Google Maps API Reference:
http://code.google.com/apis/maps/documentation/reference.html#GEvent
Example:
from django.shortcuts import render_to_response
from django.contrib.gis.maps.google import GoogleMap, GEvent, GPolyline
def sample_request(request):
polyline = GPolyline('LINESTRING(101 26, 112 26, 102 31)')
event = GEvent('click',
'function() { location.href = "http://www.google.com"}')
polyline.add_event(event)
return render_to_response('mytemplate.html',
{'google' : GoogleMap(polylines=[polyline])})
"""
def __init__(self, event, action):
"""
Initializes a GEvent object.
Parameters:
event:
string for the event, such as 'click'. The event must be a valid
event for the object in the Google Maps API.
There is no validation of the event type within Django.
action:
string containing a Javascript function, such as
'function() { location.href = "newurl";}'
The string must be a valid Javascript function. Again there is no
validation fo the function within Django.
"""
self.event = event
self.action = action
def __unicode__(self):
"Returns the parameter part of a GEvent."
return mark_safe('"%s", %s' %(self.event, self.action))
class GOverlayBase(object):
def __init__(self):
self.events = []
def latlng_from_coords(self, coords):
"Generates a JavaScript array of GLatLng objects for the given coordinates."
return '[%s]' % ','.join(['new GLatLng(%s,%s)' % (y, x) for x, y in coords])
def add_event(self, event):
"Attaches a GEvent to the overlay object."
self.events.append(event)
def __unicode__(self):
"The string representation is the JavaScript API call."
return mark_safe('%s(%s)' % (self.__class__.__name__, self.js_params))
class GPolygon(GOverlayBase):
"""
A Python wrapper for the Google GPolygon object. For more information
please see the Google Maps API Reference:
http://code.google.com/apis/maps/documentation/reference.html#GPolygon
"""
def __init__(self, poly,
stroke_color='#0000ff', stroke_weight=2, stroke_opacity=1,
fill_color='#0000ff', fill_opacity=0.4):
"""
The GPolygon object initializes on a GEOS Polygon or a parameter that
may be instantiated into GEOS Polygon. Please note that this will not
depict a Polygon's internal rings.
Keyword Options:
stroke_color:
The color of the polygon outline. Defaults to '#0000ff' (blue).
stroke_weight:
The width of the polygon outline, in pixels. Defaults to 2.
stroke_opacity:
The opacity of the polygon outline, between 0 and 1. Defaults to 1.
fill_color:
The color of the polygon fill. Defaults to '#0000ff' (blue).
fill_opacity:
The opacity of the polygon fill. Defaults to 0.4.
"""
if isinstance(poly, basestring): poly = fromstr(poly)
if isinstance(poly, (tuple, list)): poly = Polygon(poly)
if not isinstance(poly, Polygon):
raise TypeError('GPolygon may only initialize on GEOS Polygons.')
# Getting the envelope of the input polygon (used for automatically
# determining the zoom level).
self.envelope = poly.envelope
# Translating the coordinates into a JavaScript array of
# Google `GLatLng` objects.
self.points = self.latlng_from_coords(poly.shell.coords)
# Stroke settings.
self.stroke_color, self.stroke_opacity, self.stroke_weight = stroke_color, stroke_opacity, stroke_weight
# Fill settings.
self.fill_color, self.fill_opacity = fill_color, fill_opacity
super(GPolygon, self).__init__()
@property
def js_params(self):
return '%s, "%s", %s, %s, "%s", %s' % (self.points, self.stroke_color, self.stroke_weight, self.stroke_opacity,
self.fill_color, self.fill_opacity)
class GPolyline(GOverlayBase):
"""
A Python wrapper for the Google GPolyline object. For more information
please see the Google Maps API Reference:
http://code.google.com/apis/maps/documentation/reference.html#GPolyline
"""
def __init__(self, geom, color='#0000ff', weight=2, opacity=1):
"""
The GPolyline object may be initialized on GEOS LineStirng, LinearRing,
and Polygon objects (internal rings not supported) or a parameter that
may instantiated into one of the above geometries.
Keyword Options:
color:
The color to use for the polyline. Defaults to '#0000ff' (blue).
weight:
The width of the polyline, in pixels. Defaults to 2.
opacity:
The opacity of the polyline, between 0 and 1. Defaults to 1.
"""
# If a GEOS geometry isn't passed in, try to contsruct one.
if isinstance(geom, basestring): geom = fromstr(geom)
if isinstance(geom, (tuple, list)): geom = Polygon(geom)
# Generating the lat/lng coordinate pairs.
if isinstance(geom, (LineString, LinearRing)):
self.latlngs = self.latlng_from_coords(geom.coords)
elif isinstance(geom, Polygon):
self.latlngs = self.latlng_from_coords(geom.shell.coords)
else:
raise TypeError('GPolyline may only initialize on GEOS LineString, LinearRing, and/or Polygon geometries.')
# Getting the envelope for automatic zoom determination.
self.envelope = geom.envelope
self.color, self.weight, self.opacity = color, weight, opacity
super(GPolyline, self).__init__()
@property
def js_params(self):
return '%s, "%s", %s, %s' % (self.latlngs, self.color, self.weight, self.opacity)
class GIcon(object):
"""
Creates a GIcon object to pass into a Gmarker object.
The keyword arguments map to instance attributes of the same name. These,
in turn, correspond to a subset of the attributes of the official GIcon
javascript object:
http://code.google.com/apis/maps/documentation/reference.html#GIcon
Because a Google map often uses several different icons, a name field has
been added to the required arguments.
Required Arguments:
varname:
A string which will become the basis for the js variable name of
the marker, for this reason, your code should assign a unique
name for each GIcon you instantiate, otherwise there will be
name space collisions in your javascript.
Keyword Options:
image:
The url of the image to be used as the icon on the map defaults
to 'G_DEFAULT_ICON'
iconsize:
a tuple representing the pixel size of the foreground (not the
shadow) image of the icon, in the format: (width, height) ex.:
GIcon('fast_food',
image="/media/icon/star.png",
iconsize=(15,10))
Would indicate your custom icon was 15px wide and 10px height.
shadow:
the url of the image of the icon's shadow
shadowsize:
a tuple representing the pixel size of the shadow image, format is
the same as ``iconsize``
iconanchor:
a tuple representing the pixel coordinate relative to the top left
corner of the icon image at which this icon is anchored to the map.
In (x, y) format. x increases to the right in the Google Maps
coordinate system and y increases downwards in the Google Maps
coordinate system.)
infowindowanchor:
The pixel coordinate relative to the top left corner of the icon
image at which the info window is anchored to this icon.
"""
def __init__(self, varname, image=None, iconsize=None,
shadow=None, shadowsize=None, iconanchor=None,
infowindowanchor=None):
self.varname = varname
self.image = image
self.iconsize = iconsize
self.shadow = shadow
self.shadowsize = shadowsize
self.iconanchor = iconanchor
self.infowindowanchor = infowindowanchor
def __cmp__(self, other):
return cmp(self.varname, other.varname)
def __hash__(self):
# XOR with hash of GIcon type so that hash('varname') won't
# equal hash(GIcon('varname')).
return hash(self.__class__) ^ hash(self.varname)
class GMarker(GOverlayBase):
"""
A Python wrapper for the Google GMarker object. For more information
please see the Google Maps API Reference:
http://code.google.com/apis/maps/documentation/reference.html#GMarker
Example:
from django.shortcuts import render_to_response
from django.contrib.gis.maps.google.overlays import GMarker, GEvent
def sample_request(request):
marker = GMarker('POINT(101 26)')
event = GEvent('click',
'function() { location.href = "http://www.google.com"}')
marker.add_event(event)
return render_to_response('mytemplate.html',
{'google' : GoogleMap(markers=[marker])})
"""
def __init__(self, geom, title=None, draggable=False, icon=None):
"""
The GMarker object may initialize on GEOS Points or a parameter
that may be instantiated into a GEOS point. Keyword options map to
GMarkerOptions -- so far only the title option is supported.
Keyword Options:
title:
Title option for GMarker, will be displayed as a tooltip.
draggable:
Draggable option for GMarker, disabled by default.
"""
# If a GEOS geometry isn't passed in, try to construct one.
if isinstance(geom, basestring): geom = fromstr(geom)
if isinstance(geom, (tuple, list)): geom = Point(geom)
if isinstance(geom, Point):
self.latlng = self.latlng_from_coords(geom.coords)
else:
raise TypeError('GMarker may only initialize on GEOS Point geometry.')
# Getting the envelope for automatic zoom determination.
self.envelope = geom.envelope
# TODO: Add support for more GMarkerOptions
self.title = title
self.draggable = draggable
self.icon = icon
super(GMarker, self).__init__()
def latlng_from_coords(self, coords):
return 'new GLatLng(%s,%s)' %(coords[1], coords[0])
def options(self):
result = []
if self.title: result.append('title: "%s"' % self.title)
if self.icon: result.append('icon: %s' % self.icon.varname)
if self.draggable: result.append('draggable: true')
return '{%s}' % ','.join(result)
@property
def js_params(self):
return '%s, %s' % (self.latlng, self.options())
| ajibawa-2023/Python-Code-Large/train/row_98665 | 98 | 301 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98665:ImportFrom_L1_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0033, 0.0033, 0, 0.66, 0.0, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.safestring", "arg_names": [], "import_names": ["mark_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.safestring import mark_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:ImportFrom_L2_C0", "label": "from django.contrib.gis.geos import fromstr, Point, LineString\u2026", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0066, 0.0033, 0, 0.66, 0.1429, 886, 0, 5, 0, 0, 886, 0, 0], "semantic": {"name": "django.contrib.gis.geos", "arg_names": [], "import_names": ["fromstr", "Point", "LineString", "LinearRing", "Polygon"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.geos import fromstr, Point, LineString, LinearRing, Polygon"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L4_C0", "label": "GEvent", "type": "class", "loc": [4, 50], "level": 0, "parent": null, "vector": [3, 0, 0.0897, 0.1561, 0, 0.66, 0.2857, 661, 0, 2, 0, 0, 186, 0, 1], "semantic": {"name": "GEvent", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GEvent(object):\n \"\"\"\n A Python wrapper for the Google GEvent object.\n\n Events can be attached to any object derived from GOverlayBase with the\n add_event() call.\n\n For more information please see the Google Maps API Reference:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L5_C4", "label": "expression", "type": "expression", "loc": [5, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L4_C0", "vector": [8, 1, 0.0515, 0.0731, 1, 0.48, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A Python wrapper for the Google GEvent object.\n\n Events can be attached to any object derived from GOverlayBase with the\n add_event() call.\n\n For more information please see the Google Maps API Reference:\n http://code.google.com/apis/maps/documentation/reference.html#GEvent"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L28_C4", "label": "__init__", "type": "function", "loc": [28, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L4_C0", "vector": [2, 1, 0.1229, 0.0631, 1, 0.48, 0.5, 555, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "event", "action"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, event, action):\n \"\"\"\n Initializes a GEvent object.\n\n Parameters:\n\n event:\n string for the event, such as 'click'. The event must be a valid"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L29_C8", "label": "expression", "type": "expression", "loc": [29, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L28_C4", "vector": [8, 2, 0.1213, 0.0532, 2, 0.65, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Initializes a GEvent object.\n\n Parameters:\n\n event:\n string for the event, such as 'click'. The event must be a valid\n event for the object in the Google Maps API."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L45_C8", "label": "self.event =", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L28_C4", "vector": [14, 2, 0.1495, 0.0033, 2, 0.65, 0.5, 752, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.event", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.event = event"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L46_C8", "label": "self.action =", "type": "assigned_variable", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L28_C4", "vector": [14, 2, 0.1528, 0.0033, 2, 0.65, 1.0, 222, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.action", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.action = action"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L48_C4", "label": "__unicode__", "type": "function", "loc": [48, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L4_C0", "vector": [2, 1, 0.1628, 0.01, 1, 0.48, 1.0, 318, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n \"Returns the parameter part of a GEvent.\"\n return mark_safe('\"%s\", %s' %(self.event, self.action))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L49_C8", "label": "expression", "type": "expression", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L48_C4", "vector": [8, 2, 0.1628, 0.0033, 2, 0.88, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the parameter part of a GEvent.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L50_C8", "label": "return", "type": "return", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L48_C4", "vector": [13, 2, 0.1661, 0.0033, 2, 0.88, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe('\"%s\", %s' %(self.event, self.action))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L52_C0", "label": "GOverlayBase", "type": "class", "loc": [52, 66], "level": 0, "parent": null, "vector": [3, 0, 0.196, 0.0498, 0, 0.66, 0.4286, 76, 0, 4, 0, 0, 186, 0, 3], "semantic": {"name": "GOverlayBase", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GOverlayBase(object):\n def __init__(self):\n self.events = []\n\n def latlng_from_coords(self, coords):\n \"Generates a JavaScript array of GLatLng objects for the given coordinates.\"\n return '[%s]' % ','.join(['new GLatLng(%s,%s)' % (y, x) for x, y in coords])\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L53_C4", "label": "__init__", "type": "function", "loc": [53, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L52_C0", "vector": [2, 1, 0.1777, 0.0066, 1, 0.7, 0.0, 555, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self):\n self.events = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L54_C8", "label": "self.events =", "type": "assigned_variable", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L53_C4", "vector": [14, 2, 0.1794, 0.0033, 2, 0.29, 0.0, 87, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self.events", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.events = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L56_C4", "label": "latlng_from_coords", "type": "function", "loc": [56, 58], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L52_C0", "vector": [2, 1, 0.1894, 0.01, 1, 0.7, 0.3333, 466, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "latlng_from_coords", "arg_names": ["self", "coords"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def latlng_from_coords(self, coords):\n \"Generates a JavaScript array of GLatLng objects for the given coordinates.\"\n return '[%s]' % ','.join(['new GLatLng(%s,%s)' % (y, x) for x, y in coords])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L57_C8", "label": "expression", "type": "expression", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L56_C4", "vector": [8, 2, 0.1894, 0.0033, 2, 0.32, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Generates a JavaScript array of GLatLng objects for the given coordinates.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L58_C8", "label": "return", "type": "return", "loc": [58, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L56_C4", "vector": [13, 2, 0.1927, 0.0033, 2, 0.32, 1.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '[%s]' % ','.join(['new GLatLng(%s,%s)' % (y, x) for x, y in coords])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L60_C4", "label": "add_event", "type": "function", "loc": [60, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L52_C0", "vector": [2, 1, 0.2027, 0.01, 1, 0.7, 0.6667, 17, 0, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add_event", "arg_names": ["self", "event"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_event(self, event):\n \"Attaches a GEvent to the overlay object.\"\n self.events.append(event)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L61_C8", "label": "expression", "type": "expression", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L60_C4", "vector": [8, 2, 0.2027, 0.0033, 2, 0.3, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Attaches a GEvent to the overlay object.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L62_C8", "label": "append()", "type": "expression", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L60_C4", "vector": [8, 2, 0.206, 0.0033, 2, 0.3, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " self.events.append(event)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L64_C4", "label": "__unicode__", "type": "function", "loc": [64, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L52_C0", "vector": [2, 1, 0.2159, 0.01, 1, 0.7, 1.0, 318, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n \"The string representation is the JavaScript API call.\"\n return mark_safe('%s(%s)' % (self.__class__.__name__, self.js_params))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L65_C8", "label": "expression", "type": "expression", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L64_C4", "vector": [8, 2, 0.2159, 0.0033, 2, 0.86, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"The string representation is the JavaScript API call.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L66_C8", "label": "return", "type": "return", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L64_C4", "vector": [13, 2, 0.2193, 0.0033, 2, 0.86, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe('%s(%s)' % (self.__class__.__name__, self.js_params))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L68_C0", "label": "GPolygon", "type": "class", "loc": [68, 123], "level": 0, "parent": null, "vector": [3, 0, 0.3173, 0.186, 0, 0.66, 0.5714, 461, 0, 2, 0, 0, 76, 0, 9], "semantic": {"name": "GPolygon", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GPolygon(GOverlayBase):\n \"\"\"\n A Python wrapper for the Google GPolygon object. For more information\n please see the Google Maps API Reference:\n http://code.google.com/apis/maps/documentation/reference.html#GPolygon\n \"\"\"\n def __init__(self, poly,\n stroke_color='#0000ff', stroke_weight=2, stroke_opacity=1,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L69_C4", "label": "expression", "type": "expression", "loc": [69, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L68_C0", "vector": [8, 1, 0.2359, 0.0166, 1, 0.63, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A Python wrapper for the Google GPolygon object. For more information\n please see the Google Maps API Reference:\n http://code.google.com/apis/maps/documentation/reference.html#GPolygon\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "label": "__init__", "type": "function", "loc": [74, 118], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L68_C0", "vector": [2, 1, 0.3189, 0.1495, 1, 0.63, 0.5, 555, 0, 7, 0, 0, 0, 0, 9], "semantic": {"name": "__init__", "arg_names": ["self", "poly", "stroke_color", "stroke_weight", "stroke_opacity", "fill_color", "fill_opacity"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, poly,\n stroke_color='#0000ff', stroke_weight=2, stroke_opacity=1,\n fill_color='#0000ff', fill_opacity=0.4):\n \"\"\"\n The GPolygon object initializes on a GEOS Polygon or a parameter that\n may be instantiated into GEOS Polygon. Please note that this will not\n depict a Polygon's internal rings.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L77_C8", "label": "expression", "type": "expression", "loc": [77, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "vector": [8, 2, 0.2907, 0.0731, 2, 0.96, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n The GPolygon object initializes on a GEOS Polygon or a parameter that\n may be instantiated into GEOS Polygon. Please note that this will not\n depict a Polygon's internal rings.\n\n Keyword Options:\n\n stroke_color:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L99_C8", "label": "if", "type": "if", "loc": [99, 99], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "vector": [4, 2, 0.3289, 0.0033, 2, 0.96, 0.125, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(poly, basestring): poly = fromstr(poly)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L99_C41", "label": "poly = fromstr()", "type": "assigned_variable", "loc": [99, 99], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L99_C8", "vector": [14, 3, 0.3289, 0.0033, 3, 0.64, 0.0, 365, 3, 1, 0, 0, 946, 10, 1], "semantic": {"name": "poly", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " if isinstance(poly, basestring): poly = fromstr(poly)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L100_C8", "label": "if", "type": "if", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "vector": [4, 2, 0.3322, 0.0033, 2, 0.96, 0.25, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(poly, (tuple, list)): poly = Polygon(poly)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L100_C44", "label": "poly = Polygon()", "type": "assigned_variable", "loc": [100, 100], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L100_C8", "vector": [14, 3, 0.3322, 0.0033, 3, 0.56, 0.0, 365, 3, 1, 0, 0, 818, 10, 1], "semantic": {"name": "poly", "arg_names": [], "import_names": [], "rhs_call_name": "Polygon", "annotation": ""}, "snippet": " if isinstance(poly, (tuple, list)): poly = Polygon(poly)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L101_C8", "label": "if", "type": "if", "loc": [101, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "vector": [4, 2, 0.3372, 0.0066, 2, 0.96, 0.375, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(poly, Polygon):\n raise TypeError('GPolygon may only initialize on GEOS Polygons.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L106_C8", "label": "self.envelope =", "type": "assigned_variable", "loc": [106, 106], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "vector": [14, 2, 0.3522, 0.0033, 2, 0.96, 0.5, 113, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.envelope", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.envelope = poly.envelope"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L110_C8", "label": "self.points = latlng_from_coords()", "type": "assigned_variable", "loc": [110, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "vector": [14, 2, 0.3654, 0.0033, 2, 0.96, 0.625, 831, 3, 1, 0, 0, 466, 10, 1], "semantic": {"name": "self.points", "arg_names": [], "import_names": [], "rhs_call_name": "latlng_from_coords", "annotation": ""}, "snippet": " self.points = self.latlng_from_coords(poly.shell.coords)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L113_C8", "label": "assign", "type": "assigned_variable", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "vector": [14, 2, 0.3754, 0.0033, 2, 0.96, 0.75, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.stroke_color, self.stroke_opacity, self.stroke_weight = stroke_color, stroke_opacity, stroke_weight"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L116_C8", "label": "assign", "type": "assigned_variable", "loc": [116, 116], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "vector": [14, 2, 0.3854, 0.0033, 2, 0.96, 0.875, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.fill_color, self.fill_opacity = fill_color, fill_opacity"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L118_C8", "label": "__init__()", "type": "expression", "loc": [118, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "vector": [8, 2, 0.392, 0.0033, 2, 0.96, 1.0, 555, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(GPolygon, self).__init__()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L121_C4", "label": "js_params", "type": "function", "loc": [121, 123], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L68_C0", "vector": [2, 1, 0.4053, 0.01, 1, 0.63, 1.0, 596, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "js_params", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def js_params(self):\n return '%s, \"%s\", %s, %s, \"%s\", %s' % (self.points, self.stroke_color, self.stroke_weight, self.stroke_opacity,\n self.fill_color, self.fill_opacity)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L122_C8", "label": "return", "type": "return", "loc": [122, 123], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L121_C4", "vector": [13, 2, 0.407, 0.0066, 2, 0.54, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '%s, \"%s\", %s, %s, \"%s\", %s' % (self.points, self.stroke_color, self.stroke_weight, self.stroke_opacity,\n self.fill_color, self.fill_opacity)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L125_C0", "label": "GPolyline", "type": "class", "loc": [125, 166], "level": 0, "parent": null, "vector": [3, 0, 0.4834, 0.1395, 0, 0.66, 0.7143, 498, 0, 2, 0, 0, 76, 0, 11], "semantic": {"name": "GPolyline", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GPolyline(GOverlayBase):\n \"\"\"\n A Python wrapper for the Google GPolyline object. For more information\n please see the Google Maps API Reference:\n http://code.google.com/apis/maps/documentation/reference.html#GPolyline\n \"\"\"\n def __init__(self, geom, color='#0000ff', weight=2, opacity=1):\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L126_C4", "label": "expression", "type": "expression", "loc": [126, 130], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L125_C0", "vector": [8, 1, 0.4252, 0.0166, 1, 0.48, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A Python wrapper for the Google GPolyline object. For more information\n please see the Google Maps API Reference:\n http://code.google.com/apis/maps/documentation/reference.html#GPolyline\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "label": "__init__", "type": "function", "loc": [131, 162], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L125_C0", "vector": [2, 1, 0.4867, 0.1063, 1, 0.48, 0.5, 555, 0, 5, 0, 0, 0, 0, 11], "semantic": {"name": "__init__", "arg_names": ["self", "geom", "color", "weight", "opacity"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, geom, color='#0000ff', weight=2, opacity=1):\n \"\"\"\n The GPolyline object may be initialized on GEOS LineStirng, LinearRing,\n and Polygon objects (internal rings not supported) or a parameter that\n may instantiated into one of the above geometries.\n\n Keyword Options:\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L132_C8", "label": "expression", "type": "expression", "loc": [132, 147], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "vector": [8, 2, 0.4635, 0.0532, 2, 0.54, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n The GPolyline object may be initialized on GEOS LineStirng, LinearRing,\n and Polygon objects (internal rings not supported) or a parameter that\n may instantiated into one of the above geometries.\n\n Keyword Options:\n\n color:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L149_C8", "label": "if", "type": "if", "loc": [149, 149], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "vector": [4, 2, 0.495, 0.0033, 2, 0.54, 0.1667, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(geom, basestring): geom = fromstr(geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L149_C41", "label": "geom = fromstr()", "type": "assigned_variable", "loc": [149, 149], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L149_C8", "vector": [14, 3, 0.495, 0.0033, 3, 0.14, 0.0, 5, 3, 1, 0, 0, 946, 10, 1], "semantic": {"name": "geom", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " if isinstance(geom, basestring): geom = fromstr(geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L150_C8", "label": "if", "type": "if", "loc": [150, 150], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "vector": [4, 2, 0.4983, 0.0033, 2, 0.54, 0.3333, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(geom, (tuple, list)): geom = Polygon(geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L150_C44", "label": "geom = Polygon()", "type": "assigned_variable", "loc": [150, 150], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L150_C8", "vector": [14, 3, 0.4983, 0.0033, 3, 0.04, 0.0, 5, 3, 1, 0, 0, 818, 10, 1], "semantic": {"name": "geom", "arg_names": [], "import_names": [], "rhs_call_name": "Polygon", "annotation": ""}, "snippet": " if isinstance(geom, (tuple, list)): geom = Polygon(geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L152_C8", "label": "if", "type": "if", "loc": [152, 157], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "vector": [4, 2, 0.5133, 0.0199, 2, 0.54, 0.5, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(geom, (LineString, LinearRing)):\n self.latlngs = self.latlng_from_coords(geom.coords)\n elif isinstance(geom, Polygon):\n self.latlngs = self.latlng_from_coords(geom.shell.coords)\n else:\n raise TypeError('GPolyline may only initialize on GEOS LineString, LinearRing, and/or Polygon geometries.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L153_C12", "label": "self.latlngs = latlng_from_coords()", "type": "assigned_variable", "loc": [153, 153], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L152_C8", "vector": [14, 3, 0.5083, 0.0033, 3, 0.94, 0.0, 273, 3, 1, 0, 0, 466, 10, 1], "semantic": {"name": "self.latlngs", "arg_names": [], "import_names": [], "rhs_call_name": "latlng_from_coords", "annotation": ""}, "snippet": " self.latlngs = self.latlng_from_coords(geom.coords)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L154_C8", "label": "if", "type": "if", "loc": [154, 157], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L152_C8", "vector": [4, 3, 0.5166, 0.0133, 3, 0.94, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(geom, Polygon):\n self.latlngs = self.latlng_from_coords(geom.shell.coords)\n else:\n raise TypeError('GPolyline may only initialize on GEOS LineString, LinearRing, and/or Polygon geometries.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L155_C12", "label": "self.latlngs = latlng_from_coords()", "type": "assigned_variable", "loc": [155, 155], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L154_C8", "vector": [14, 4, 0.515, 0.0033, 4, 0.92, 0.0, 273, 3, 1, 0, 0, 466, 10, 1], "semantic": {"name": "self.latlngs", "arg_names": [], "import_names": [], "rhs_call_name": "latlng_from_coords", "annotation": ""}, "snippet": " self.latlngs = self.latlng_from_coords(geom.shell.coords)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L160_C8", "label": "self.envelope =", "type": "assigned_variable", "loc": [160, 160], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "vector": [14, 2, 0.5316, 0.0033, 2, 0.54, 0.6667, 113, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.envelope", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.envelope = geom.envelope"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L161_C8", "label": "assign", "type": "assigned_variable", "loc": [161, 161], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "vector": [14, 2, 0.5349, 0.0033, 2, 0.54, 0.8333, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.color, self.weight, self.opacity = color, weight, opacity"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L162_C8", "label": "__init__()", "type": "expression", "loc": [162, 162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "vector": [8, 2, 0.5382, 0.0033, 2, 0.54, 1.0, 555, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(GPolyline, self).__init__()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L165_C4", "label": "js_params", "type": "function", "loc": [165, 166], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L125_C0", "vector": [2, 1, 0.5498, 0.0066, 1, 0.48, 1.0, 596, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "js_params", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def js_params(self):\n return '%s, \"%s\", %s, %s' % (self.latlngs, self.color, self.weight, self.opacity)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L166_C8", "label": "return", "type": "return", "loc": [166, 166], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L165_C4", "vector": [13, 2, 0.5515, 0.0033, 2, 0.72, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '%s, \"%s\", %s, %s' % (self.latlngs, self.color, self.weight, self.opacity)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L169_C0", "label": "GIcon", "type": "class", "loc": [169, 240], "level": 0, "parent": null, "vector": [3, 0, 0.6794, 0.2392, 0, 0.66, 0.8571, 23, 0, 3, 0, 0, 186, 0, 3], "semantic": {"name": "GIcon", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GIcon(object):\n \"\"\"\n Creates a GIcon object to pass into a Gmarker object.\n\n The keyword arguments map to instance attributes of the same name. These,\n in turn, correspond to a subset of the attributes of the official GIcon\n javascript object:\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L170_C4", "label": "expression", "type": "expression", "loc": [170, 222], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L169_C0", "vector": [8, 1, 0.6512, 0.1761, 1, 0.97, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Creates a GIcon object to pass into a Gmarker object.\n\n The keyword arguments map to instance attributes of the same name. These,\n in turn, correspond to a subset of the attributes of the official GIcon\n javascript object:\n\n http://code.google.com/apis/maps/documentation/reference.html#GIcon"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "label": "__init__", "type": "function", "loc": [223, 232], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L169_C0", "vector": [2, 1, 0.7558, 0.0332, 1, 0.97, 0.3333, 555, 0, 8, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "varname", "image", "iconsize", "shadow", "shadowsize", "iconanchor", "infowindowanchor"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, varname, image=None, iconsize=None,\n shadow=None, shadowsize=None, iconanchor=None,\n infowindowanchor=None):\n self.varname = varname\n self.image = image\n self.iconsize = iconsize\n self.shadow = shadow\n self.shadowsize = shadowsize"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L226_C8", "label": "self.varname =", "type": "assigned_variable", "loc": [226, 226], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "vector": [14, 2, 0.7508, 0.0033, 2, 0.65, 0.0, 29, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.varname", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.varname = varname"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L227_C8", "label": "self.image =", "type": "assigned_variable", "loc": [227, 227], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "vector": [14, 2, 0.7542, 0.0033, 2, 0.65, 0.1667, 219, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.image", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.image = image"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L228_C8", "label": "self.iconsize =", "type": "assigned_variable", "loc": [228, 228], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "vector": [14, 2, 0.7575, 0.0033, 2, 0.65, 0.3333, 621, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.iconsize", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.iconsize = iconsize"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L229_C8", "label": "self.shadow =", "type": "assigned_variable", "loc": [229, 229], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "vector": [14, 2, 0.7608, 0.0033, 2, 0.65, 0.5, 371, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.shadow", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.shadow = shadow"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L230_C8", "label": "self.shadowsize =", "type": "assigned_variable", "loc": [230, 230], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "vector": [14, 2, 0.7641, 0.0033, 2, 0.65, 0.6667, 394, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.shadowsize", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.shadowsize = shadowsize"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L231_C8", "label": "self.iconanchor =", "type": "assigned_variable", "loc": [231, 231], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "vector": [14, 2, 0.7674, 0.0033, 2, 0.65, 0.8333, 106, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.iconanchor", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.iconanchor = iconanchor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L232_C8", "label": "self.infowindowanchor =", "type": "assigned_variable", "loc": [232, 232], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "vector": [14, 2, 0.7708, 0.0033, 2, 0.65, 1.0, 134, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.infowindowanchor", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.infowindowanchor = infowindowanchor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L234_C4", "label": "__cmp__", "type": "function", "loc": [234, 235], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L169_C0", "vector": [2, 1, 0.7791, 0.0066, 1, 0.97, 0.6667, 271, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "__cmp__", "arg_names": ["self", "other"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __cmp__(self, other):\n return cmp(self.varname, other.varname)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L235_C8", "label": "return", "type": "return", "loc": [235, 235], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L234_C4", "vector": [13, 2, 0.7807, 0.0033, 2, 0.0, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return cmp(self.varname, other.varname)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L237_C4", "label": "__hash__", "type": "function", "loc": [237, 240], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L169_C0", "vector": [2, 1, 0.7924, 0.0133, 1, 0.97, 1.0, 49, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "__hash__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __hash__(self):\n # XOR with hash of GIcon type so that hash('varname') won't \n # equal hash(GIcon('varname')).\n return hash(self.__class__) ^ hash(self.varname)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L240_C8", "label": "return", "type": "return", "loc": [240, 240], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L237_C4", "vector": [13, 2, 0.7973, 0.0033, 2, 0.22, 0.0, 0, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return hash(self.__class__) ^ hash(self.varname)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L242_C0", "label": "GMarker", "type": "class", "loc": [242, 301], "level": 0, "parent": null, "vector": [3, 0, 0.902, 0.1993, 0, 0.66, 1.0, 316, 0, 4, 0, 0, 76, 0, 14], "semantic": {"name": "GMarker", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GMarker(GOverlayBase):\n \"\"\"\n A Python wrapper for the Google GMarker object. For more information\n please see the Google Maps API Reference:\n http://code.google.com/apis/maps/documentation/reference.html#GMarker\n\n Example:\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L243_C4", "label": "expression", "type": "expression", "loc": [243, 260], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L242_C0", "vector": [8, 1, 0.8355, 0.0598, 1, 0.71, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A Python wrapper for the Google GMarker object. For more information\n please see the Google Maps API Reference:\n http://code.google.com/apis/maps/documentation/reference.html#GMarker\n\n Example:\n\n from django.shortcuts import render_to_response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "label": "__init__", "type": "function", "loc": [261, 287], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L242_C0", "vector": [2, 1, 0.9103, 0.0897, 1, 0.71, 0.25, 555, 0, 5, 0, 0, 0, 0, 9], "semantic": {"name": "__init__", "arg_names": ["self", "geom", "title", "draggable", "icon"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, geom, title=None, draggable=False, icon=None):\n \"\"\"\n The GMarker object may initialize on GEOS Points or a parameter\n that may be instantiated into a GEOS point. Keyword options map to\n GMarkerOptions -- so far only the title option is supported.\n\n Keyword Options:\n title:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L262_C8", "label": "expression", "type": "expression", "loc": [262, 273], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "vector": [8, 2, 0.8887, 0.0399, 2, 0.11, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n The GMarker object may initialize on GEOS Points or a parameter\n that may be instantiated into a GEOS point. Keyword options map to\n GMarkerOptions -- so far only the title option is supported.\n\n Keyword Options:\n title:\n Title option for GMarker, will be displayed as a tooltip."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L275_C8", "label": "if", "type": "if", "loc": [275, 275], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "vector": [4, 2, 0.9136, 0.0033, 2, 0.11, 0.125, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(geom, basestring): geom = fromstr(geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L275_C41", "label": "geom = fromstr()", "type": "assigned_variable", "loc": [275, 275], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L275_C8", "vector": [14, 3, 0.9136, 0.0033, 3, 0.84, 0.0, 5, 3, 1, 0, 0, 946, 10, 1], "semantic": {"name": "geom", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " if isinstance(geom, basestring): geom = fromstr(geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L276_C8", "label": "if", "type": "if", "loc": [276, 276], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "vector": [4, 2, 0.9169, 0.0033, 2, 0.11, 0.25, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(geom, (tuple, list)): geom = Point(geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L276_C44", "label": "geom = Point()", "type": "assigned_variable", "loc": [276, 276], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L276_C8", "vector": [14, 3, 0.9169, 0.0033, 3, 0.33, 0.0, 5, 3, 1, 0, 0, 652, 10, 1], "semantic": {"name": "geom", "arg_names": [], "import_names": [], "rhs_call_name": "Point", "annotation": ""}, "snippet": " if isinstance(geom, (tuple, list)): geom = Point(geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L277_C8", "label": "if", "type": "if", "loc": [277, 280], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "vector": [4, 2, 0.9252, 0.0133, 2, 0.11, 0.375, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(geom, Point):\n self.latlng = self.latlng_from_coords(geom.coords)\n else:\n raise TypeError('GMarker may only initialize on GEOS Point geometry.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L278_C12", "label": "self.latlng = latlng_from_coords()", "type": "assigned_variable", "loc": [278, 278], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L277_C8", "vector": [14, 3, 0.9236, 0.0033, 3, 0.27, 0.0, 602, 3, 1, 0, 0, 466, 10, 1], "semantic": {"name": "self.latlng", "arg_names": [], "import_names": [], "rhs_call_name": "latlng_from_coords", "annotation": ""}, "snippet": " self.latlng = self.latlng_from_coords(geom.coords)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L282_C8", "label": "self.envelope =", "type": "assigned_variable", "loc": [282, 282], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "vector": [14, 2, 0.9369, 0.0033, 2, 0.11, 0.5, 113, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.envelope", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.envelope = geom.envelope"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L284_C8", "label": "self.title =", "type": "assigned_variable", "loc": [284, 284], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "vector": [14, 2, 0.9435, 0.0033, 2, 0.11, 0.625, 629, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.title", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.title = title"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L285_C8", "label": "self.draggable =", "type": "assigned_variable", "loc": [285, 285], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "vector": [14, 2, 0.9468, 0.0033, 2, 0.11, 0.75, 413, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.draggable", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.draggable = draggable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L286_C8", "label": "self.icon =", "type": "assigned_variable", "loc": [286, 286], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "vector": [14, 2, 0.9502, 0.0033, 2, 0.11, 0.875, 217, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.icon", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.icon = icon"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L287_C8", "label": "__init__()", "type": "expression", "loc": [287, 287], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "vector": [8, 2, 0.9535, 0.0033, 2, 0.11, 1.0, 555, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(GMarker, self).__init__()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L289_C4", "label": "latlng_from_coords", "type": "function", "loc": [289, 290], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L242_C0", "vector": [2, 1, 0.9618, 0.0066, 1, 0.71, 0.5, 466, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "latlng_from_coords", "arg_names": ["self", "coords"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def latlng_from_coords(self, coords):\n return 'new GLatLng(%s,%s)' %(coords[1], coords[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L290_C8", "label": "return", "type": "return", "loc": [290, 290], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L289_C4", "vector": [13, 2, 0.9635, 0.0033, 2, 0.12, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 'new GLatLng(%s,%s)' %(coords[1], coords[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L292_C4", "label": "options", "type": "function", "loc": [292, 297], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L242_C0", "vector": [2, 1, 0.9784, 0.0199, 1, 0.71, 0.75, 707, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "options", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def options(self):\n result = []\n if self.title: result.append('title: \"%s\"' % self.title)\n if self.icon: result.append('icon: %s' % self.icon.varname)\n if self.draggable: result.append('draggable: true')\n return '{%s}' % ','.join(result)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L293_C8", "label": "result =", "type": "assigned_variable", "loc": [293, 293], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L292_C4", "vector": [14, 2, 0.9734, 0.0033, 2, 0.14, 0.0, 51, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "result", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L294_C8", "label": "if", "type": "if", "loc": [294, 294], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L292_C4", "vector": [4, 2, 0.9767, 0.0033, 2, 0.14, 0.25, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.title: result.append('title: \"%s\"' % self.title)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L294_C23", "label": "append()", "type": "expression", "loc": [294, 294], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L294_C8", "vector": [8, 3, 0.9767, 0.0033, 3, 0.35, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " if self.title: result.append('title: \"%s\"' % self.title)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L295_C8", "label": "if", "type": "if", "loc": [295, 295], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L292_C4", "vector": [4, 2, 0.9801, 0.0033, 2, 0.14, 0.5, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.icon: result.append('icon: %s' % self.icon.varname)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L295_C22", "label": "append()", "type": "expression", "loc": [295, 295], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L295_C8", "vector": [8, 3, 0.9801, 0.0033, 3, 0.11, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " if self.icon: result.append('icon: %s' % self.icon.varname)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L296_C8", "label": "if", "type": "if", "loc": [296, 296], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L292_C4", "vector": [4, 2, 0.9834, 0.0033, 2, 0.14, 0.75, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.draggable: result.append('draggable: true')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L296_C27", "label": "append()", "type": "expression", "loc": [296, 296], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L296_C8", "vector": [8, 3, 0.9834, 0.0033, 3, 0.94, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " if self.draggable: result.append('draggable: true')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L297_C8", "label": "return", "type": "return", "loc": [297, 297], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L292_C4", "vector": [13, 2, 0.9867, 0.0033, 2, 0.14, 1.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '{%s}' % ','.join(result)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L300_C4", "label": "js_params", "type": "function", "loc": [300, 301], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L242_C0", "vector": [2, 1, 0.9983, 0.0066, 1, 0.71, 1.0, 596, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "js_params", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def js_params(self):\n return '%s, %s' % (self.latlng, self.options())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L301_C8", "label": "return", "type": "return", "loc": [301, 301], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L300_C4", "vector": [13, 2, 1.0, 0.0033, 2, 0.8, 0.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '%s, %s' % (self.latlng, self.options())"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L53_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L60_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L60_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L60_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L64_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L64_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L64_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L68_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L68_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L99_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L99_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L99_C41"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L100_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L100_C44"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L106_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L116_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L68_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L121_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L121_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L122_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L125_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L126_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L125_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L132_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L149_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L149_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L149_C41"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L150_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L150_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L150_C44"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L152_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L152_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L153_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L152_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L154_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L155_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L160_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L161_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L125_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L165_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L165_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L169_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L170_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L169_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L226_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L227_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L228_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L229_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L230_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L231_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L232_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L169_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L234_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L234_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L235_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L169_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L237_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L237_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L240_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L242_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L243_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L242_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L262_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L275_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L275_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L275_C41"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L276_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L276_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L276_C44"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L277_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L277_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L278_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L282_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L284_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L285_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L286_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L261_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L287_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L242_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L289_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L289_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L290_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L242_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L292_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L292_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Assign_L293_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L292_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L294_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L294_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L294_C23"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L292_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L295_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L295_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L295_C22"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L292_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L296_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:If_L296_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Expr_L296_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L292_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L297_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:ClassDef_L242_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L300_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98665:FunctionDef_L300_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98665:Return_L301_C8"}] |
"""
This module houses the GoogleMap object, used for generating
the needed javascript to embed Google Maps in a Web page.
Google(R) is a registered trademark of Google, Inc. of Mountain View, California.
Example:
* In the view:
return render_to_response('template.html', {'google' : GoogleMap(key="abcdefg")})
* In the template:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{{ google.xhtml }}
<head>
<title>Google Maps via GeoDjango</title>
{{ google.style }}
{{ google.scripts }}
</head>
{{ google.body }}
<div id="{{ google.dom_id }}" style="width:600px;height:400px;"></div>
</body>
</html>
Note: If you want to be more explicit in your templates, the following are
equivalent:
{{ google.body }} => "<body {{ google.onload }} {{ google.onunload }}>"
{{ google.xhtml }} => "<html xmlns="http://www.w3.org/1999/xhtml" {{ google.xmlns }}>"
{{ google.style }} => "<style>{{ google.vml_css }}</style>"
Explanation:
- The `xhtml` property provides the correct XML namespace needed for
Google Maps to operate in IE using XHTML. Google Maps on IE uses
VML to draw polylines. Returns, by default:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
- The `style` property provides the correct style tag for the CSS
properties required by Google Maps on IE:
<style type="text/css">v\:* {behavior:url(#default#VML);}</style>
- The `scripts` property provides the necessary <script> tags for
including the Google Maps javascript, as well as including the
generated javascript.
- The `body` property provides the correct attributes for the
body tag to load the generated javascript. By default, returns:
<body onload="gmap_load()" onunload="GUnload()">
- The `dom_id` property returns the DOM id for the map. Defaults to "map".
The following attributes may be set or customized in your local settings:
* GOOGLE_MAPS_API_KEY: String of your Google Maps API key. These are tied to
to a domain. May be obtained from http://www.google.com/apis/maps/
* GOOGLE_MAPS_API_VERSION (optional): Defaults to using "2.x"
* GOOGLE_MAPS_URL (optional): Must have a substitution ('%s') for the API
version.
"""
from django.contrib.gis.maps.google.gmap import GoogleMap, GoogleMapSet
from django.contrib.gis.maps.google.overlays import GEvent, GIcon, GMarker, GPolygon, GPolyline
from django.contrib.gis.maps.google.zoom import GoogleZoom
| ajibawa-2023/Python-Code-Large/train/row_98666 | 4 | 61 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98666:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 58], "level": 0, "parent": null, "vector": [8, 0, 0.4836, 0.9508, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\n This module houses the GoogleMap object, used for generating\n the needed javascript to embed Google Maps in a Web page.\n\n Google(R) is a registered trademark of Google, Inc. of Mountain View, California.\n\n Example:\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98666:ImportFrom_L59_C0", "label": "from django.contrib.gis.maps.google.gmap import GoogleMap, GoogleMapSet", "type": "import", "loc": [59, 59], "level": 0, "parent": null, "vector": [1, 0, 0.9672, 0.0164, 0, 0.66, 0.3333, 633, 0, 2, 0, 0, 633, 0, 0], "semantic": {"name": "django.contrib.gis.maps.google.gmap", "arg_names": [], "import_names": ["GoogleMap", "GoogleMapSet"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.maps.google.gmap import GoogleMap, GoogleMapSet"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98666:ImportFrom_L60_C0", "label": "from django.contrib.gis.maps.google.overlays import GEvent, GIcon, GMarker\u2026", "type": "import", "loc": [60, 60], "level": 0, "parent": null, "vector": [1, 0, 0.9836, 0.0164, 0, 0.66, 0.6667, 995, 0, 5, 0, 0, 995, 0, 0], "semantic": {"name": "django.contrib.gis.maps.google.overlays", "arg_names": [], "import_names": ["GEvent", "GIcon", "GMarker", "GPolygon", "GPolyline"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.maps.google.overlays import GEvent, GIcon, GMarker, GPolygon, GPolyline"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98666:ImportFrom_L61_C0", "label": "from django.contrib.gis.maps.google.zoom import GoogleZoom", "type": "import", "loc": [61, 61], "level": 0, "parent": null, "vector": [1, 0, 1.0, 0.0164, 0, 0.66, 1.0, 934, 0, 1, 0, 0, 934, 0, 0], "semantic": {"name": "django.contrib.gis.maps.google.zoom", "arg_names": [], "import_names": ["GoogleZoom"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.maps.google.zoom import GoogleZoom"}] | [] |
from django.conf import settings
from django.contrib.gis import geos
from django.template.loader import render_to_string
from django.utils.safestring import mark_safe
class GoogleMapException(Exception): pass
from django.contrib.gis.maps.google.overlays import GPolygon, GPolyline, GMarker, GIcon
# The default Google Maps URL (for the API javascript)
# TODO: Internationalize for Japan, UK, etc.
GOOGLE_MAPS_URL='http://maps.google.com/maps?file=api&v=%s&key='
class GoogleMap(object):
"A class for generating Google Maps JavaScript."
# String constants
onunload = mark_safe('onunload="GUnload()"') # Cleans up after Google Maps
vml_css = mark_safe('v\:* {behavior:url(#default#VML);}') # CSS for IE VML
xmlns = mark_safe('xmlns:v="urn:schemas-microsoft-com:vml"') # XML Namespace (for IE VML).
def __init__(self, key=None, api_url=None, version=None,
center=None, zoom=None, dom_id='map',
kml_urls=[], polylines=None, polygons=None, markers=None,
template='gis/google/google-map.js',
js_module='geodjango',
extra_context={}):
# The Google Maps API Key defined in the settings will be used
# if not passed in as a parameter. The use of an API key is
# _required_.
if not key:
try:
self.key = settings.GOOGLE_MAPS_API_KEY
except AttributeError:
raise GoogleMapException('Google Maps API Key not found (try adding GOOGLE_MAPS_API_KEY to your settings).')
else:
self.key = key
# Getting the Google Maps API version, defaults to using the latest ("2.x"),
# this is not necessarily the most stable.
if not version:
self.version = getattr(settings, 'GOOGLE_MAPS_API_VERSION', '2.x')
else:
self.version = version
# Can specify the API URL in the `api_url` keyword.
if not api_url:
self.api_url = mark_safe(getattr(settings, 'GOOGLE_MAPS_URL', GOOGLE_MAPS_URL) % self.version)
else:
self.api_url = api_url
# Setting the DOM id of the map, the load function, the JavaScript
# template, and the KML URLs array.
self.dom_id = dom_id
self.extra_context = extra_context
self.js_module = js_module
self.template = template
self.kml_urls = kml_urls
# Does the user want any GMarker, GPolygon, and/or GPolyline overlays?
overlay_info = [[GMarker, markers, 'markers'],
[GPolygon, polygons, 'polygons'],
[GPolyline, polylines, 'polylines']]
for overlay_class, overlay_list, varname in overlay_info:
setattr(self, varname, [])
if overlay_list:
for overlay in overlay_list:
if isinstance(overlay, overlay_class):
getattr(self, varname).append(overlay)
else:
getattr(self, varname).append(overlay_class(overlay))
# If GMarker, GPolygons, and/or GPolylines are used the zoom will be
# automatically calculated via the Google Maps API. If both a zoom
# level and a center coordinate are provided with polygons/polylines,
# no automatic determination will occur.
self.calc_zoom = False
if self.polygons or self.polylines or self.markers:
if center is None or zoom is None:
self.calc_zoom = True
# Defaults for the zoom level and center coordinates if the zoom
# is not automatically calculated.
if zoom is None: zoom = 4
self.zoom = zoom
if center is None: center = (0, 0)
self.center = center
def render(self):
"""
Generates the JavaScript necessary for displaying this Google Map.
"""
params = {'calc_zoom' : self.calc_zoom,
'center' : self.center,
'dom_id' : self.dom_id,
'js_module' : self.js_module,
'kml_urls' : self.kml_urls,
'zoom' : self.zoom,
'polygons' : self.polygons,
'polylines' : self.polylines,
'icons': self.icons,
'markers' : self.markers,
}
params.update(self.extra_context)
return render_to_string(self.template, params)
@property
def body(self):
"Returns HTML body tag for loading and unloading Google Maps javascript."
return mark_safe('<body %s %s>' % (self.onload, self.onunload))
@property
def onload(self):
"Returns the `onload` HTML <body> attribute."
return mark_safe('onload="%s.%s_load()"' % (self.js_module, self.dom_id))
@property
def api_script(self):
"Returns the <script> tag for the Google Maps API javascript."
return mark_safe('<script src="%s%s" type="text/javascript"></script>' % (self.api_url, self.key))
@property
def js(self):
"Returns only the generated Google Maps JavaScript (no <script> tags)."
return self.render()
@property
def scripts(self):
"Returns all <script></script> tags required with Google Maps JavaScript."
return mark_safe('%s\n <script type="text/javascript">\n//<![CDATA[\n%s//]]>\n </script>' % (self.api_script, self.js))
@property
def style(self):
"Returns additional CSS styling needed for Google Maps on IE."
return mark_safe('<style type="text/css">%s</style>' % self.vml_css)
@property
def xhtml(self):
"Returns XHTML information needed for IE VML overlays."
return mark_safe('<html xmlns="http://www.w3.org/1999/xhtml" %s>' % self.xmlns)
@property
def icons(self):
"Returns a sequence of GIcon objects in this map."
return set([marker.icon for marker in self.markers if marker.icon])
class GoogleMapSet(GoogleMap):
def __init__(self, *args, **kwargs):
"""
A class for generating sets of Google Maps that will be shown on the
same page together.
Example:
gmapset = GoogleMapSet( GoogleMap( ... ), GoogleMap( ... ) )
gmapset = GoogleMapSet( [ gmap1, gmap2] )
"""
# The `google-multi.js` template is used instead of `google-single.js`
# by default.
template = kwargs.pop('template', 'gis/google/google-multi.js')
# This is the template used to generate the GMap load JavaScript for
# each map in the set.
self.map_template = kwargs.pop('map_template', 'gis/google/google-single.js')
# Running GoogleMap.__init__(), and resetting the template
# value with default obtained above.
super(GoogleMapSet, self).__init__(**kwargs)
self.template = template
# If a tuple/list passed in as first element of args, then assume
if isinstance(args[0], (tuple, list)):
self.maps = args[0]
else:
self.maps = args
# Generating DOM ids for each of the maps in the set.
self.dom_ids = ['map%d' % i for i in xrange(len(self.maps))]
def load_map_js(self):
"""
Returns JavaScript containing all of the loading routines for each
map in this set.
"""
result = []
for dom_id, gmap in zip(self.dom_ids, self.maps):
# Backup copies the GoogleMap DOM id and template attributes.
# They are overridden on each GoogleMap instance in the set so
# that only the loading JavaScript (and not the header variables)
# is used with the generated DOM ids.
tmp = (gmap.template, gmap.dom_id)
gmap.template = self.map_template
gmap.dom_id = dom_id
result.append(gmap.js)
# Restoring the backup values.
gmap.template, gmap.dom_id = tmp
return mark_safe(''.join(result))
def render(self):
"""
Generates the JavaScript for the collection of Google Maps in
this set.
"""
params = {'js_module' : self.js_module,
'dom_ids' : self.dom_ids,
'load_map_js' : self.load_map_js(),
'icons' : self.icons,
}
params.update(self.extra_context)
return render_to_string(self.template, params)
@property
def onload(self):
"Returns the `onload` HTML <body> attribute."
# Overloaded to use the `load` function defined in the
# `google-multi.js`, which calls the load routines for
# each one of the individual maps in the set.
return mark_safe('onload="%s.load()"' % self.js_module)
@property
def icons(self):
"Returns a sequence of all icons in each map of the set."
icons = set()
for map in self.maps: icons |= map.icons
return icons
| ajibawa-2023/Python-Code-Large/train/row_98667 | 109 | 226 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98667:ImportFrom_L1_C0", "label": "from django.conf import settings", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0044, 0.0044, 0, 0.66, 0.0, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:ImportFrom_L2_C0", "label": "from django.contrib.gis import geos", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0088, 0.0044, 0, 0.66, 0.125, 735, 0, 1, 0, 0, 735, 0, 0], "semantic": {"name": "django.contrib.gis", "arg_names": [], "import_names": ["geos"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis import geos"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:ImportFrom_L3_C0", "label": "from django.template.loader import render_to_string", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0133, 0.0044, 0, 0.66, 0.25, 970, 0, 1, 0, 0, 970, 0, 0], "semantic": {"name": "django.template.loader", "arg_names": [], "import_names": ["render_to_string"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template.loader import render_to_string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:ImportFrom_L4_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0177, 0.0044, 0, 0.66, 0.375, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.safestring", "arg_names": [], "import_names": ["mark_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.safestring import mark_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L6_C0", "label": "GoogleMapException", "type": "class", "loc": [6, 6], "level": 0, "parent": null, "vector": [3, 0, 0.0265, 0.0044, 0, 0.66, 0.5, 422, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "GoogleMapException", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GoogleMapException(Exception): pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:ImportFrom_L7_C0", "label": "from django.contrib.gis.maps.google.overlays import GPolygon, GPolyline, GMarker\u2026", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.031, 0.0044, 0, 0.66, 0.625, 995, 0, 4, 0, 0, 995, 0, 0], "semantic": {"name": "django.contrib.gis.maps.google.overlays", "arg_names": [], "import_names": ["GPolygon", "GPolyline", "GMarker", "GIcon"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.maps.google.overlays import GPolygon, GPolyline, GMarker, GIcon"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L11_C0", "label": "GOOGLE_MAPS_URL =", "type": "assigned_variable", "loc": [11, 11], "level": 0, "parent": null, "vector": [14, 0, 0.0487, 0.0044, 0, 0.66, 0.75, 546, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "GOOGLE_MAPS_URL", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "GOOGLE_MAPS_URL='http://maps.google.com/maps?file=api&v=%s&key='"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "label": "GoogleMap", "type": "class", "loc": [13, 146], "level": 0, "parent": null, "vector": [3, 0, 0.3518, 0.5929, 0, 0.66, 0.875, 586, 0, 10, 0, 0, 186, 0, 24], "semantic": {"name": "GoogleMap", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GoogleMap(object):\n \"A class for generating Google Maps JavaScript.\"\n\n # String constants\n onunload = mark_safe('onunload=\"GUnload()\"') # Cleans up after Google Maps\n vml_css = mark_safe('v\\:* {behavior:url(#default#VML);}') # CSS for IE VML\n xmlns = mark_safe('xmlns:v=\"urn:schemas-microsoft-com:vml\"') # XML Namespace (for IE VML).\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L14_C4", "label": "expression", "type": "expression", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [8, 1, 0.0619, 0.0044, 1, 0.17, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"A class for generating Google Maps JavaScript.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L17_C4", "label": "onunload = mark_safe()", "type": "assigned_variable", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [14, 1, 0.0752, 0.0044, 1, 0.17, 0.0769, 363, 3, 1, 0, 0, 159, 10, 1], "semantic": {"name": "onunload", "arg_names": [], "import_names": [], "rhs_call_name": "mark_safe", "annotation": ""}, "snippet": " onunload = mark_safe('onunload=\"GUnload()\"') # Cleans up after Google Maps"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L18_C4", "label": "vml_css = mark_safe()", "type": "assigned_variable", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [14, 1, 0.0796, 0.0044, 1, 0.17, 0.1538, 683, 3, 1, 0, 0, 159, 10, 1], "semantic": {"name": "vml_css", "arg_names": [], "import_names": [], "rhs_call_name": "mark_safe", "annotation": ""}, "snippet": " vml_css = mark_safe('v\\:* {behavior:url(#default#VML);}') # CSS for IE VML"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L19_C4", "label": "xmlns = mark_safe()", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [14, 1, 0.0841, 0.0044, 1, 0.17, 0.2308, 311, 3, 1, 0, 0, 159, 10, 1], "semantic": {"name": "xmlns", "arg_names": [], "import_names": [], "rhs_call_name": "mark_safe", "annotation": ""}, "snippet": " xmlns = mark_safe('xmlns:v=\"urn:schemas-microsoft-com:vml\"') # XML Namespace (for IE VML)."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "label": "__init__", "type": "function", "loc": [21, 88], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [2, 1, 0.2412, 0.3009, 1, 0.17, 0.3077, 555, 0, 14, 0, 0, 0, 0, 11], "semantic": {"name": "__init__", "arg_names": ["self", "key", "api_url", "version", "center", "zoom", "dom_id", "kml_urls", "polylines", "polygons", "markers", "template", "js_module", "extra_context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, key=None, api_url=None, version=None,\n center=None, zoom=None, dom_id='map',\n kml_urls=[], polylines=None, polygons=None, markers=None,\n template='gis/google/google-map.js',\n js_module='geodjango',\n extra_context={}):\n\n # The Google Maps API Key defined in the settings will be used"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L31_C8", "label": "if", "type": "if", "loc": [31, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [4, 2, 0.1504, 0.031, 2, 0.65, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not key:\n try:\n self.key = settings.GOOGLE_MAPS_API_KEY\n except AttributeError:\n raise GoogleMapException('Google Maps API Key not found (try adding GOOGLE_MAPS_API_KEY to your settings).')\n else:\n self.key = key"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Try_L32_C12", "label": "try", "type": "try", "loc": [32, 35], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L31_C8", "vector": [7, 3, 0.1482, 0.0177, 3, 0.6, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n self.key = settings.GOOGLE_MAPS_API_KEY\n except AttributeError:\n raise GoogleMapException('Google Maps API Key not found (try adding GOOGLE_MAPS_API_KEY to your settings).')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L33_C16", "label": "self.key =", "type": "assigned_variable", "loc": [33, 33], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:Try_L32_C12", "vector": [14, 4, 0.146, 0.0044, 4, 0.43, 0.0, 605, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.key", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.key = settings.GOOGLE_MAPS_API_KEY"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L37_C12", "label": "self.key =", "type": "assigned_variable", "loc": [37, 37], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L31_C8", "vector": [14, 3, 0.1637, 0.0044, 3, 0.6, 1.0, 605, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.key", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.key = key"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L41_C8", "label": "if", "type": "if", "loc": [41, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [4, 2, 0.1881, 0.0177, 2, 0.65, 0.0667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not version:\n self.version = getattr(settings, 'GOOGLE_MAPS_API_VERSION', '2.x')\n else:\n self.version = version"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L42_C12", "label": "self.version = getattr()", "type": "assigned_variable", "loc": [42, 42], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L41_C8", "vector": [14, 3, 0.1858, 0.0044, 3, 0.23, 0.0, 686, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "self.version", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " self.version = getattr(settings, 'GOOGLE_MAPS_API_VERSION', '2.x')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L44_C12", "label": "self.version =", "type": "assigned_variable", "loc": [44, 44], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L41_C8", "vector": [14, 3, 0.1947, 0.0044, 3, 0.23, 1.0, 686, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.version", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.version = version"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L47_C8", "label": "if", "type": "if", "loc": [47, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [4, 2, 0.2146, 0.0177, 2, 0.65, 0.1333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not api_url:\n self.api_url = mark_safe(getattr(settings, 'GOOGLE_MAPS_URL', GOOGLE_MAPS_URL) % self.version)\n else:\n self.api_url = api_url"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L48_C12", "label": "self.api_url = mark_safe()", "type": "assigned_variable", "loc": [48, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L47_C8", "vector": [14, 3, 0.2124, 0.0044, 3, 0.95, 0.0, 168, 3, 1, 0, 0, 159, 10, 2], "semantic": {"name": "self.api_url", "arg_names": [], "import_names": [], "rhs_call_name": "mark_safe", "annotation": ""}, "snippet": " self.api_url = mark_safe(getattr(settings, 'GOOGLE_MAPS_URL', GOOGLE_MAPS_URL) % self.version)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L50_C12", "label": "self.api_url =", "type": "assigned_variable", "loc": [50, 50], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L47_C8", "vector": [14, 3, 0.2212, 0.0044, 3, 0.95, 1.0, 168, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.api_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.api_url = api_url"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L54_C8", "label": "self.dom_id =", "type": "assigned_variable", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [14, 2, 0.2389, 0.0044, 2, 0.65, 0.2, 316, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.dom_id", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.dom_id = dom_id"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L55_C8", "label": "self.extra_context =", "type": "assigned_variable", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [14, 2, 0.2434, 0.0044, 2, 0.65, 0.2667, 195, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.extra_context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.extra_context = extra_context"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L56_C8", "label": "self.js_module =", "type": "assigned_variable", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [14, 2, 0.2478, 0.0044, 2, 0.65, 0.3333, 723, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.js_module", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.js_module = js_module"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L57_C8", "label": "self.template =", "type": "assigned_variable", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [14, 2, 0.2522, 0.0044, 2, 0.65, 0.4, 479, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.template = template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L58_C8", "label": "self.kml_urls =", "type": "assigned_variable", "loc": [58, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [14, 2, 0.2566, 0.0044, 2, 0.65, 0.4667, 865, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.kml_urls", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.kml_urls = kml_urls"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L61_C8", "label": "overlay_info =", "type": "assigned_variable", "loc": [61, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [14, 2, 0.2743, 0.0133, 2, 0.65, 0.5333, 84, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "overlay_info", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " overlay_info = [[GMarker, markers, 'markers'],\n [GPolygon, polygons, 'polygons'],\n [GPolyline, polylines, 'polylines']]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L65_C8", "label": "for overlay_class, overlay_list, varname", "type": "for", "loc": [65, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [6, 2, 0.3031, 0.0354, 2, 0.65, 0.6, 836, 2, 0, 0, 0, 0, 0, 7], "semantic": {"name": "overlay_class, overlay_list, varname", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for overlay_class, overlay_list, varname in overlay_info:\n setattr(self, varname, [])\n if overlay_list:\n for overlay in overlay_list:\n if isinstance(overlay, overlay_class):\n getattr(self, varname).append(overlay)\n else:\n getattr(self, varname).append(overlay_class(overlay))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L66_C12", "label": "setattr()", "type": "expression", "loc": [66, 66], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L65_C8", "vector": [8, 3, 0.292, 0.0044, 3, 0.1, 0.0, 501, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "setattr", "arg_names": [], "import_names": [], "rhs_call_name": "setattr", "annotation": ""}, "snippet": " setattr(self, varname, [])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L67_C12", "label": "if", "type": "if", "loc": [67, 72], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L65_C8", "vector": [4, 3, 0.3075, 0.0265, 3, 0.1, 1.0, 0, 2, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if overlay_list:\n for overlay in overlay_list:\n if isinstance(overlay, overlay_class):\n getattr(self, varname).append(overlay)\n else:\n getattr(self, varname).append(overlay_class(overlay))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L68_C16", "label": "for overlay", "type": "for", "loc": [68, 72], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L67_C12", "vector": [6, 4, 0.3097, 0.0221, 4, 0.12, 0.0, 229, 2, 0, 0, 0, 0, 0, 6], "semantic": {"name": "overlay", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for overlay in overlay_list:\n if isinstance(overlay, overlay_class):\n getattr(self, varname).append(overlay)\n else:\n getattr(self, varname).append(overlay_class(overlay))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L69_C20", "label": "if", "type": "if", "loc": [69, 72], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L68_C16", "vector": [4, 5, 0.3119, 0.0177, 5, 0.64, 0.0, 0, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(overlay, overlay_class):\n getattr(self, varname).append(overlay)\n else:\n getattr(self, varname).append(overlay_class(overlay))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L70_C24", "label": "append()", "type": "expression", "loc": [70, 70], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L69_C20", "vector": [8, 6, 0.3097, 0.0044, 6, 0.46, 0.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " getattr(self, varname).append(overlay)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L72_C24", "label": "append()", "type": "expression", "loc": [72, 72], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L69_C20", "vector": [8, 6, 0.3186, 0.0044, 6, 0.46, 1.0, 243, 3, 1, 0, 0, 0, 0, 3], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " getattr(self, varname).append(overlay_class(overlay))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L78_C8", "label": "self.calc_zoom =", "type": "assigned_variable", "loc": [78, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [14, 2, 0.3451, 0.0044, 2, 0.65, 0.6667, 258, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self.calc_zoom", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.calc_zoom = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L79_C8", "label": "if", "type": "if", "loc": [79, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [4, 2, 0.354, 0.0133, 2, 0.65, 0.7333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.polygons or self.polylines or self.markers:\n if center is None or zoom is None:\n self.calc_zoom = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L80_C12", "label": "if", "type": "if", "loc": [80, 81], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L79_C8", "vector": [4, 3, 0.3562, 0.0088, 3, 0.61, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if center is None or zoom is None:\n self.calc_zoom = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L81_C16", "label": "self.calc_zoom =", "type": "assigned_variable", "loc": [81, 81], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L80_C12", "vector": [14, 4, 0.3584, 0.0044, 4, 0.18, 0.0, 258, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self.calc_zoom", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.calc_zoom = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L85_C8", "label": "if", "type": "if", "loc": [85, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [4, 2, 0.3761, 0.0044, 2, 0.65, 0.8, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if zoom is None: zoom = 4"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L85_C25", "label": "zoom =", "type": "assigned_variable", "loc": [85, 85], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L85_C8", "vector": [14, 3, 0.3761, 0.0044, 3, 0.21, 0.0, 707, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "zoom", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if zoom is None: zoom = 4"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L86_C8", "label": "self.zoom =", "type": "assigned_variable", "loc": [86, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [14, 2, 0.3805, 0.0044, 2, 0.65, 0.8667, 774, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.zoom", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.zoom = zoom"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L87_C8", "label": "if", "type": "if", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [4, 2, 0.385, 0.0044, 2, 0.65, 0.9333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if center is None: center = (0, 0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L87_C27", "label": "center =", "type": "assigned_variable", "loc": [87, 87], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L87_C8", "vector": [14, 3, 0.385, 0.0044, 3, 0.97, 0.0, 546, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "center", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if center is None: center = (0, 0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L88_C8", "label": "self.center =", "type": "assigned_variable", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "vector": [14, 2, 0.3894, 0.0044, 2, 0.65, 1.0, 46, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.center", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.center = center"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L90_C4", "label": "render", "type": "function", "loc": [90, 106], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [2, 1, 0.4336, 0.0752, 1, 0.17, 0.3846, 24, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "render", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self):\n \"\"\"\n Generates the JavaScript necessary for displaying this Google Map.\n \"\"\"\n params = {'calc_zoom' : self.calc_zoom,\n 'center' : self.center,\n 'dom_id' : self.dom_id,\n 'js_module' : self.js_module,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L91_C8", "label": "expression", "type": "expression", "loc": [91, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L90_C4", "vector": [8, 2, 0.4071, 0.0133, 2, 0.82, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Generates the JavaScript necessary for displaying this Google Map.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L94_C8", "label": "params =", "type": "assigned_variable", "loc": [94, 104], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L90_C4", "vector": [14, 2, 0.4381, 0.0487, 2, 0.82, 0.3333, 206, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "params", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " params = {'calc_zoom' : self.calc_zoom,\n 'center' : self.center,\n 'dom_id' : self.dom_id,\n 'js_module' : self.js_module,\n 'kml_urls' : self.kml_urls,\n 'zoom' : self.zoom,\n 'polygons' : self.polygons,\n 'polylines' : self.polylines,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L105_C8", "label": "update()", "type": "expression", "loc": [105, 105], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L90_C4", "vector": [8, 2, 0.4646, 0.0044, 2, 0.82, 0.6667, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " params.update(self.extra_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L106_C8", "label": "return", "type": "return", "loc": [106, 106], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L90_C4", "vector": [13, 2, 0.469, 0.0044, 2, 0.82, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_string(self.template, params)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L109_C4", "label": "body", "type": "function", "loc": [109, 111], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [2, 1, 0.4867, 0.0133, 1, 0.17, 0.4615, 477, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "body", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def body(self):\n \"Returns HTML body tag for loading and unloading Google Maps javascript.\"\n return mark_safe('<body %s %s>' % (self.onload, self.onunload))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L110_C8", "label": "expression", "type": "expression", "loc": [110, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L109_C4", "vector": [8, 2, 0.4867, 0.0044, 2, 0.04, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns HTML body tag for loading and unloading Google Maps javascript.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L111_C8", "label": "return", "type": "return", "loc": [111, 111], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L109_C4", "vector": [13, 2, 0.4912, 0.0044, 2, 0.04, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe('<body %s %s>' % (self.onload, self.onunload))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L114_C4", "label": "onload", "type": "function", "loc": [114, 116], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [2, 1, 0.5088, 0.0133, 1, 0.17, 0.5385, 181, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "onload", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def onload(self):\n \"Returns the `onload` HTML <body> attribute.\"\n return mark_safe('onload=\"%s.%s_load()\"' % (self.js_module, self.dom_id))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L115_C8", "label": "expression", "type": "expression", "loc": [115, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L114_C4", "vector": [8, 2, 0.5088, 0.0044, 2, 0.93, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the `onload` HTML <body> attribute.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L116_C8", "label": "return", "type": "return", "loc": [116, 116], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L114_C4", "vector": [13, 2, 0.5133, 0.0044, 2, 0.93, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe('onload=\"%s.%s_load()\"' % (self.js_module, self.dom_id))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L119_C4", "label": "api_script", "type": "function", "loc": [119, 121], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [2, 1, 0.531, 0.0133, 1, 0.17, 0.6154, 837, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "api_script", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def api_script(self):\n \"Returns the <script> tag for the Google Maps API javascript.\"\n return mark_safe('<script src=\"%s%s\" type=\"text/javascript\"></script>' % (self.api_url, self.key))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L120_C8", "label": "expression", "type": "expression", "loc": [120, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L119_C4", "vector": [8, 2, 0.531, 0.0044, 2, 0.81, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the <script> tag for the Google Maps API javascript.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L121_C8", "label": "return", "type": "return", "loc": [121, 121], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L119_C4", "vector": [13, 2, 0.5354, 0.0044, 2, 0.81, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe('<script src=\"%s%s\" type=\"text/javascript\"></script>' % (self.api_url, self.key))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L124_C4", "label": "js", "type": "function", "loc": [124, 126], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [2, 1, 0.5531, 0.0133, 1, 0.17, 0.6923, 62, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "js", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def js(self):\n \"Returns only the generated Google Maps JavaScript (no <script> tags).\"\n return self.render()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L125_C8", "label": "expression", "type": "expression", "loc": [125, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L124_C4", "vector": [8, 2, 0.5531, 0.0044, 2, 0.4, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns only the generated Google Maps JavaScript (no <script> tags).\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L126_C8", "label": "return", "type": "return", "loc": [126, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L124_C4", "vector": [13, 2, 0.5575, 0.0044, 2, 0.4, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.render()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L129_C4", "label": "scripts", "type": "function", "loc": [129, 131], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [2, 1, 0.5752, 0.0133, 1, 0.17, 0.7692, 738, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "scripts", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def scripts(self):\n \"Returns all <script></script> tags required with Google Maps JavaScript.\"\n return mark_safe('%s\\n <script type=\"text/javascript\">\\n//<![CDATA[\\n%s//]]>\\n </script>' % (self.api_script, self.js))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L130_C8", "label": "expression", "type": "expression", "loc": [130, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L129_C4", "vector": [8, 2, 0.5752, 0.0044, 2, 0.48, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns all <script></script> tags required with Google Maps JavaScript.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L131_C8", "label": "return", "type": "return", "loc": [131, 131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L129_C4", "vector": [13, 2, 0.5796, 0.0044, 2, 0.48, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe('%s\\n <script type=\"text/javascript\">\\n//<![CDATA[\\n%s//]]>\\n </script>' % (self.api_script, self.js))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L134_C4", "label": "style", "type": "function", "loc": [134, 136], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [2, 1, 0.5973, 0.0133, 1, 0.17, 0.8462, 3, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "style", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def style(self):\n \"Returns additional CSS styling needed for Google Maps on IE.\"\n return mark_safe('<style type=\"text/css\">%s</style>' % self.vml_css)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L135_C8", "label": "expression", "type": "expression", "loc": [135, 135], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L134_C4", "vector": [8, 2, 0.5973, 0.0044, 2, 0.78, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns additional CSS styling needed for Google Maps on IE.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L136_C8", "label": "return", "type": "return", "loc": [136, 136], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L134_C4", "vector": [13, 2, 0.6018, 0.0044, 2, 0.78, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe('<style type=\"text/css\">%s</style>' % self.vml_css)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L139_C4", "label": "xhtml", "type": "function", "loc": [139, 141], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [2, 1, 0.6195, 0.0133, 1, 0.17, 0.9231, 973, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "xhtml", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def xhtml(self):\n \"Returns XHTML information needed for IE VML overlays.\"\n return mark_safe('<html xmlns=\"http://www.w3.org/1999/xhtml\" %s>' % self.xmlns)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L140_C8", "label": "expression", "type": "expression", "loc": [140, 140], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L139_C4", "vector": [8, 2, 0.6195, 0.0044, 2, 0.94, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns XHTML information needed for IE VML overlays.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L141_C8", "label": "return", "type": "return", "loc": [141, 141], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L139_C4", "vector": [13, 2, 0.6239, 0.0044, 2, 0.94, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe('<html xmlns=\"http://www.w3.org/1999/xhtml\" %s>' % self.xmlns)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L144_C4", "label": "icons", "type": "function", "loc": [144, 146], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "vector": [2, 1, 0.6416, 0.0133, 1, 0.17, 1.0, 351, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "icons", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def icons(self):\n \"Returns a sequence of GIcon objects in this map.\"\n return set([marker.icon for marker in self.markers if marker.icon])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L145_C8", "label": "expression", "type": "expression", "loc": [145, 145], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L144_C4", "vector": [8, 2, 0.6416, 0.0044, 2, 0.26, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns a sequence of GIcon objects in this map.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L146_C8", "label": "return", "type": "return", "loc": [146, 146], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L144_C4", "vector": [13, 2, 0.646, 0.0044, 2, 0.26, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return set([marker.icon for marker in self.markers if marker.icon])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L148_C0", "label": "GoogleMapSet", "type": "class", "loc": [148, 226], "level": 0, "parent": null, "vector": [3, 0, 0.8274, 0.3496, 0, 0.66, 1.0, 457, 0, 5, 0, 0, 586, 0, 16], "semantic": {"name": "GoogleMapSet", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GoogleMapSet(GoogleMap):\n\n def __init__(self, *args, **kwargs):\n \"\"\"\n A class for generating sets of Google Maps that will be shown on the\n same page together.\n\n Example:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "label": "__init__", "type": "function", "loc": [150, 179], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L148_C0", "vector": [2, 1, 0.7279, 0.1327, 1, 0.99, 0.0, 555, 0, 3, 0, 0, 0, 0, 7], "semantic": {"name": "__init__", "arg_names": ["self", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, *args, **kwargs):\n \"\"\"\n A class for generating sets of Google Maps that will be shown on the\n same page together.\n\n Example:\n gmapset = GoogleMapSet( GoogleMap( ... ), GoogleMap( ... ) )\n gmapset = GoogleMapSet( [ gmap1, gmap2] )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L151_C8", "label": "expression", "type": "expression", "loc": [151, 158], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "vector": [8, 2, 0.6836, 0.0354, 2, 0.12, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A class for generating sets of Google Maps that will be shown on the\n same page together.\n\n Example:\n gmapset = GoogleMapSet( GoogleMap( ... ), GoogleMap( ... ) )\n gmapset = GoogleMapSet( [ gmap1, gmap2] )\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L161_C8", "label": "template = pop()", "type": "assigned_variable", "loc": [161, 161], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "vector": [14, 2, 0.7124, 0.0044, 2, 0.12, 0.1667, 549, 3, 2, 0, 0, 969, 10, 1], "semantic": {"name": "template", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " template = kwargs.pop('template', 'gis/google/google-multi.js')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L165_C8", "label": "self.map_template = pop()", "type": "assigned_variable", "loc": [165, 165], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "vector": [14, 2, 0.7301, 0.0044, 2, 0.12, 0.3333, 967, 3, 2, 0, 0, 969, 10, 1], "semantic": {"name": "self.map_template", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " self.map_template = kwargs.pop('map_template', 'gis/google/google-single.js')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L169_C8", "label": "__init__()", "type": "expression", "loc": [169, 169], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "vector": [8, 2, 0.7478, 0.0044, 2, 0.12, 0.5, 555, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(GoogleMapSet, self).__init__(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L170_C8", "label": "self.template =", "type": "assigned_variable", "loc": [170, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "vector": [14, 2, 0.7522, 0.0044, 2, 0.12, 0.6667, 479, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.template = template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L173_C8", "label": "if", "type": "if", "loc": [173, 176], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "vector": [4, 2, 0.7721, 0.0177, 2, 0.12, 0.8333, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(args[0], (tuple, list)):\n self.maps = args[0]\n else:\n self.maps = args"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L174_C12", "label": "self.maps =", "type": "assigned_variable", "loc": [174, 174], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L173_C8", "vector": [14, 3, 0.7699, 0.0044, 3, 0.65, 0.0, 801, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.maps", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.maps = args[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L176_C12", "label": "self.maps =", "type": "assigned_variable", "loc": [176, 176], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L173_C8", "vector": [14, 3, 0.7788, 0.0044, 3, 0.65, 1.0, 801, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.maps", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.maps = args"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L179_C8", "label": "self.dom_ids =", "type": "assigned_variable", "loc": [179, 179], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "vector": [14, 2, 0.792, 0.0044, 2, 0.12, 1.0, 517, 5, 0, 0, 0, 0, 0, 2], "semantic": {"name": "self.dom_ids", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.dom_ids = ['map%d' % i for i in xrange(len(self.maps))]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L181_C4", "label": "load_map_js", "type": "function", "loc": [181, 198], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L148_C0", "vector": [2, 1, 0.8385, 0.0796, 1, 0.99, 0.25, 593, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "load_map_js", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def load_map_js(self):\n \"\"\"\n Returns JavaScript containing all of the loading routines for each\n map in this set.\n \"\"\"\n result = []\n for dom_id, gmap in zip(self.dom_ids, self.maps):\n # Backup copies the GoogleMap DOM id and template attributes."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L182_C8", "label": "expression", "type": "expression", "loc": [182, 185], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L181_C4", "vector": [8, 2, 0.8119, 0.0177, 2, 0.69, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns JavaScript containing all of the loading routines for each\n map in this set.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L186_C8", "label": "result =", "type": "assigned_variable", "loc": [186, 186], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L181_C4", "vector": [14, 2, 0.823, 0.0044, 2, 0.69, 0.3333, 51, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "result", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L187_C8", "label": "for dom_id, gmap", "type": "for", "loc": [187, 197], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L181_C4", "vector": [6, 2, 0.8496, 0.0487, 2, 0.69, 0.6667, 979, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "dom_id, gmap", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for dom_id, gmap in zip(self.dom_ids, self.maps):\n # Backup copies the GoogleMap DOM id and template attributes.\n # They are overridden on each GoogleMap instance in the set so\n # that only the loading JavaScript (and not the header variables)\n # is used with the generated DOM ids.\n tmp = (gmap.template, gmap.dom_id)\n gmap.template = self.map_template\n gmap.dom_id = dom_id"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L192_C12", "label": "tmp =", "type": "assigned_variable", "loc": [192, 192], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L187_C8", "vector": [14, 3, 0.8496, 0.0044, 3, 0.93, 0.0, 517, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "tmp", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tmp = (gmap.template, gmap.dom_id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L193_C12", "label": "gmap.template =", "type": "assigned_variable", "loc": [193, 193], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L187_C8", "vector": [14, 3, 0.854, 0.0044, 3, 0.93, 0.25, 370, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "gmap.template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " gmap.template = self.map_template"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L194_C12", "label": "gmap.dom_id =", "type": "assigned_variable", "loc": [194, 194], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L187_C8", "vector": [14, 3, 0.8584, 0.0044, 3, 0.93, 0.5, 334, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "gmap.dom_id", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " gmap.dom_id = dom_id"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L195_C12", "label": "append()", "type": "expression", "loc": [195, 195], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L187_C8", "vector": [8, 3, 0.8628, 0.0044, 3, 0.93, 0.75, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " result.append(gmap.js)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L197_C12", "label": "assign", "type": "assigned_variable", "loc": [197, 197], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L187_C8", "vector": [14, 3, 0.8717, 0.0044, 3, 0.93, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " gmap.template, gmap.dom_id = tmp"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L198_C8", "label": "return", "type": "return", "loc": [198, 198], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L181_C4", "vector": [13, 2, 0.8761, 0.0044, 2, 0.69, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(''.join(result))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L200_C4", "label": "render", "type": "function", "loc": [200, 211], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L148_C0", "vector": [2, 1, 0.9093, 0.0531, 1, 0.99, 0.5, 24, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "render", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self):\n \"\"\"\n Generates the JavaScript for the collection of Google Maps in\n this set.\n \"\"\"\n params = {'js_module' : self.js_module,\n 'dom_ids' : self.dom_ids,\n 'load_map_js' : self.load_map_js(),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L201_C8", "label": "expression", "type": "expression", "loc": [201, 204], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L200_C4", "vector": [8, 2, 0.896, 0.0177, 2, 0.31, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Generates the JavaScript for the collection of Google Maps in\n this set.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L205_C8", "label": "params =", "type": "assigned_variable", "loc": [205, 209], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L200_C4", "vector": [14, 2, 0.9159, 0.0221, 2, 0.31, 0.3333, 206, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "params", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " params = {'js_module' : self.js_module,\n 'dom_ids' : self.dom_ids,\n 'load_map_js' : self.load_map_js(),\n 'icons' : self.icons,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L210_C8", "label": "update()", "type": "expression", "loc": [210, 210], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L200_C4", "vector": [8, 2, 0.9292, 0.0044, 2, 0.31, 0.6667, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " params.update(self.extra_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L211_C8", "label": "return", "type": "return", "loc": [211, 211], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L200_C4", "vector": [13, 2, 0.9336, 0.0044, 2, 0.31, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_string(self.template, params)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L214_C4", "label": "onload", "type": "function", "loc": [214, 219], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L148_C0", "vector": [2, 1, 0.958, 0.0265, 1, 0.99, 0.75, 181, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "onload", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def onload(self):\n \"Returns the `onload` HTML <body> attribute.\"\n # Overloaded to use the `load` function defined in the\n # `google-multi.js`, which calls the load routines for\n # each one of the individual maps in the set.\n return mark_safe('onload=\"%s.load()\"' % self.js_module)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L215_C8", "label": "expression", "type": "expression", "loc": [215, 215], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L214_C4", "vector": [8, 2, 0.9513, 0.0044, 2, 0.06, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the `onload` HTML <body> attribute.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L219_C8", "label": "return", "type": "return", "loc": [219, 219], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L214_C4", "vector": [13, 2, 0.969, 0.0044, 2, 0.06, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe('onload=\"%s.load()\"' % self.js_module)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L222_C4", "label": "icons", "type": "function", "loc": [222, 226], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L148_C0", "vector": [2, 1, 0.9912, 0.0221, 1, 0.99, 1.0, 351, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "icons", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def icons(self):\n \"Returns a sequence of all icons in each map of the set.\"\n icons = set()\n for map in self.maps: icons |= map.icons\n return icons"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L223_C8", "label": "expression", "type": "expression", "loc": [223, 223], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L222_C4", "vector": [8, 2, 0.9867, 0.0044, 2, 0.42, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns a sequence of all icons in each map of the set.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L224_C8", "label": "icons = set()", "type": "assigned_variable", "loc": [224, 224], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L222_C4", "vector": [14, 2, 0.9912, 0.0044, 2, 0.42, 0.3333, 351, 3, 0, 0, 0, 21, 10, 1], "semantic": {"name": "icons", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " icons = set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L225_C8", "label": "for map", "type": "for", "loc": [225, 225], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L222_C4", "vector": [6, 2, 0.9956, 0.0044, 2, 0.42, 0.6667, 53, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "map", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for map in self.maps: icons |= map.icons"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L226_C8", "label": "return", "type": "return", "loc": [226, 226], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L222_C4", "vector": [13, 2, 1.0, 0.0044, 2, 0.42, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return icons"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L31_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Try_L32_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:Try_L32_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L33_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L31_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L41_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L42_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L41_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L44_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L47_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L48_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L47_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L65_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L66_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L65_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L67_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L67_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L68_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L68_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L69_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L69_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L70_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L69_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L72_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L79_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L79_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L80_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L80_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L81_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L85_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L85_C25"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L87_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L87_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L90_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L90_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L90_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L90_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L105_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L90_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L106_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L109_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L111_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L114_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L114_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L115_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L114_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L116_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L119_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L120_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L121_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L124_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L124_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L124_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L129_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L129_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L130_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L129_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L134_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L135_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L139_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L141_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L144_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L145_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L144_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L146_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L148_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L151_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L161_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L165_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L169_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L170_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L173_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L173_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L174_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:If_L173_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L176_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L150_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L179_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L148_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L181_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L181_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L182_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L181_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L186_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L181_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L187_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L187_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L192_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L187_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L193_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L187_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L194_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L187_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L195_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L187_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L197_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L181_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L198_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L148_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L200_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L201_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L205_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L210_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L211_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L148_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L214_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L214_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L215_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L214_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L219_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:ClassDef_L148_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L222_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Expr_L223_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Assign_L224_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:For_L225_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98667:FunctionDef_L222_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98667:Return_L226_C8"}] |
from django.contrib.syndication.feeds import Feed as BaseFeed, FeedDoesNotExist
from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed
class GeoFeedMixin(object):
"""
This mixin provides the necessary routines for SyndicationFeed subclasses
to produce simple GeoRSS or W3C Geo elements.
"""
def georss_coords(self, coords):
"""
In GeoRSS coordinate pairs are ordered by lat/lon and separated by
a single white space. Given a tuple of coordinates, this will return
a unicode GeoRSS representation.
"""
return u' '.join([u'%f %f' % (coord[1], coord[0]) for coord in coords])
def add_georss_point(self, handler, coords, w3c_geo=False):
"""
Adds a GeoRSS point with the given coords using the given handler.
Handles the differences between simple GeoRSS and the more pouplar
W3C Geo specification.
"""
if w3c_geo:
lon, lat = coords[:2]
handler.addQuickElement(u'geo:lat', u'%f' % lat)
handler.addQuickElement(u'geo:lon', u'%f' % lon)
else:
handler.addQuickElement(u'georss:point', self.georss_coords((coords,)))
def add_georss_element(self, handler, item, w3c_geo=False):
"""
This routine adds a GeoRSS XML element using the given item and handler.
"""
# Getting the Geometry object.
geom = item.get('geometry', None)
if not geom is None:
if isinstance(geom, (list, tuple)):
# Special case if a tuple/list was passed in. The tuple may be
# a point or a box
box_coords = None
if isinstance(geom[0], (list, tuple)):
# Box: ( (X0, Y0), (X1, Y1) )
if len(geom) == 2:
box_coords = geom
else:
raise ValueError('Only should be two sets of coordinates.')
else:
if len(geom) == 2:
# Point: (X, Y)
self.add_georss_point(handler, geom, w3c_geo=w3c_geo)
elif len(geom) == 4:
# Box: (X0, Y0, X1, Y1)
box_coords = (geom[:2], geom[2:])
else:
raise ValueError('Only should be 2 or 4 numeric elements.')
# If a GeoRSS box was given via tuple.
if not box_coords is None:
if w3c_geo: raise ValueError('Cannot use simple GeoRSS box in W3C Geo feeds.')
handler.addQuickElement(u'georss:box', self.georss_coords(box_coords))
else:
# Getting the lower-case geometry type.
gtype = str(geom.geom_type).lower()
if gtype == 'point':
self.add_georss_point(handler, geom.coords, w3c_geo=w3c_geo)
else:
if w3c_geo: raise ValueError('W3C Geo only supports Point geometries.')
# For formatting consistent w/the GeoRSS simple standard:
# http://georss.org/1.0#simple
if gtype in ('linestring', 'linearring'):
handler.addQuickElement(u'georss:line', self.georss_coords(geom.coords))
elif gtype in ('polygon',):
# Only support the exterior ring.
handler.addQuickElement(u'georss:polygon', self.georss_coords(geom[0].coords))
else:
raise ValueError('Geometry type "%s" not supported.' % geom.geom_type)
### SyndicationFeed subclasses ###
class GeoRSSFeed(Rss201rev2Feed, GeoFeedMixin):
def rss_attributes(self):
attrs = super(GeoRSSFeed, self).rss_attributes()
attrs[u'xmlns:georss'] = u'http://www.georss.org/georss'
return attrs
def add_item_elements(self, handler, item):
super(GeoRSSFeed, self).add_item_elements(handler, item)
self.add_georss_element(handler, item)
def add_root_elements(self, handler):
super(GeoRSSFeed, self).add_root_elements(handler)
self.add_georss_element(handler, self.feed)
class GeoAtom1Feed(Atom1Feed, GeoFeedMixin):
def root_attributes(self):
attrs = super(GeoAtom1Feed, self).root_attributes()
attrs[u'xmlns:georss'] = u'http://www.georss.org/georss'
return attrs
def add_item_elements(self, handler, item):
super(GeoAtom1Feed, self).add_item_elements(handler, item)
self.add_georss_element(handler, item)
def add_root_elements(self, handler):
super(GeoAtom1Feed, self).add_root_elements(handler)
self.add_georss_element(handler, self.feed)
class W3CGeoFeed(Rss201rev2Feed, GeoFeedMixin):
def rss_attributes(self):
attrs = super(W3CGeoFeed, self).rss_attributes()
attrs[u'xmlns:geo'] = u'http://www.w3.org/2003/01/geo/wgs84_pos#'
return attrs
def add_item_elements(self, handler, item):
super(W3CGeoFeed, self).add_item_elements(handler, item)
self.add_georss_element(handler, item, w3c_geo=True)
def add_root_elements(self, handler):
super(W3CGeoFeed, self).add_root_elements(handler)
self.add_georss_element(handler, self.feed, w3c_geo=True)
### Feed subclass ###
class Feed(BaseFeed):
"""
This is a subclass of the `Feed` from `django.contrib.syndication`.
This allows users to define a `geometry(obj)` and/or `item_geometry(item)`
methods on their own subclasses so that geo-referenced information may
placed in the feed.
"""
feed_type = GeoRSSFeed
def feed_extra_kwargs(self, obj):
return {'geometry' : self.__get_dynamic_attr('geometry', obj)}
def item_extra_kwargs(self, item):
return {'geometry' : self.__get_dynamic_attr('item_geometry', item)}
| ajibawa-2023/Python-Code-Large/train/row_98668 | 78 | 135 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98668:ImportFrom_L1_C0", "label": "from django.contrib.syndication.feeds import BaseFeed, FeedDoesNotExist", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0074, 0.0074, 0, 0.66, 0.0, 211, 0, 2, 0, 0, 211, 0, 0], "semantic": {"name": "django.contrib.syndication.feeds", "arg_names": [], "import_names": ["BaseFeed", "FeedDoesNotExist"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.syndication.feeds import Feed as BaseFeed, FeedDoesNotExist"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:ImportFrom_L2_C0", "label": "from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0148, 0.0074, 0, 0.66, 0.1667, 366, 0, 2, 0, 0, 366, 0, 0], "semantic": {"name": "django.utils.feedgenerator", "arg_names": [], "import_names": ["Atom1Feed", "Rss201rev2Feed"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L4_C0", "label": "GeoFeedMixin", "type": "class", "loc": [4, 76], "level": 0, "parent": null, "vector": [3, 0, 0.2963, 0.5407, 0, 0.66, 0.3333, 804, 0, 3, 0, 0, 186, 0, 26], "semantic": {"name": "GeoFeedMixin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GeoFeedMixin(object):\n \"\"\"\n This mixin provides the necessary routines for SyndicationFeed subclasses\n to produce simple GeoRSS or W3C Geo elements.\n \"\"\"\n\n def georss_coords(self, coords):\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L5_C4", "label": "expression", "type": "expression", "loc": [5, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L4_C0", "vector": [8, 1, 0.0481, 0.0296, 1, 0.78, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This mixin provides the necessary routines for SyndicationFeed subclasses\n to produce simple GeoRSS or W3C Geo elements.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L10_C4", "label": "georss_coords", "type": "function", "loc": [10, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L4_C0", "vector": [2, 1, 0.0963, 0.0519, 1, 0.78, 0.3333, 249, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "georss_coords", "arg_names": ["self", "coords"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def georss_coords(self, coords):\n \"\"\"\n In GeoRSS coordinate pairs are ordered by lat/lon and separated by\n a single white space. Given a tuple of coordinates, this will return\n a unicode GeoRSS representation.\n \"\"\"\n return u' '.join([u'%f %f' % (coord[1], coord[0]) for coord in coords])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L11_C8", "label": "expression", "type": "expression", "loc": [11, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L10_C4", "vector": [8, 2, 0.0963, 0.037, 2, 0.17, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n In GeoRSS coordinate pairs are ordered by lat/lon and separated by\n a single white space. Given a tuple of coordinates, this will return\n a unicode GeoRSS representation.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Return_L16_C8", "label": "return", "type": "return", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L10_C4", "vector": [13, 2, 0.1185, 0.0074, 2, 0.17, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u' '.join([u'%f %f' % (coord[1], coord[0]) for coord in coords])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L18_C4", "label": "add_georss_point", "type": "function", "loc": [18, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L4_C0", "vector": [2, 1, 0.1741, 0.0889, 1, 0.78, 0.6667, 402, 0, 4, 0, 0, 0, 0, 4], "semantic": {"name": "add_georss_point", "arg_names": ["self", "handler", "coords", "w3c_geo"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_georss_point(self, handler, coords, w3c_geo=False):\n \"\"\"\n Adds a GeoRSS point with the given coords using the given handler.\n Handles the differences between simple GeoRSS and the more pouplar\n W3C Geo specification.\n \"\"\"\n if w3c_geo:\n lon, lat = coords[:2]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L19_C8", "label": "expression", "type": "expression", "loc": [19, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L18_C4", "vector": [8, 2, 0.1556, 0.037, 2, 0.69, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Adds a GeoRSS point with the given coords using the given handler.\n Handles the differences between simple GeoRSS and the more pouplar\n W3C Geo specification.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L24_C8", "label": "if", "type": "if", "loc": [24, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L18_C4", "vector": [4, 2, 0.1963, 0.0444, 2, 0.69, 1.0, 0, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if w3c_geo:\n lon, lat = coords[:2]\n handler.addQuickElement(u'geo:lat', u'%f' % lat)\n handler.addQuickElement(u'geo:lon', u'%f' % lon)\n else:\n handler.addQuickElement(u'georss:point', self.georss_coords((coords,)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L25_C12", "label": "lon, lat =", "type": "assigned_variable", "loc": [25, 25], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L24_C8", "vector": [14, 3, 0.1852, 0.0074, 3, 0.04, 0.0, 949, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "lon, lat", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lon, lat = coords[:2]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L26_C12", "label": "addQuickElement()", "type": "expression", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L24_C8", "vector": [8, 3, 0.1926, 0.0074, 3, 0.04, 0.3333, 928, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "addQuickElement", "arg_names": [], "import_names": [], "rhs_call_name": "addQuickElement", "annotation": ""}, "snippet": " handler.addQuickElement(u'geo:lat', u'%f' % lat)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L27_C12", "label": "addQuickElement()", "type": "expression", "loc": [27, 27], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L24_C8", "vector": [8, 3, 0.2, 0.0074, 3, 0.04, 0.6667, 928, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "addQuickElement", "arg_names": [], "import_names": [], "rhs_call_name": "addQuickElement", "annotation": ""}, "snippet": " handler.addQuickElement(u'geo:lon', u'%f' % lon)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L29_C12", "label": "addQuickElement()", "type": "expression", "loc": [29, 29], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L24_C8", "vector": [8, 3, 0.2148, 0.0074, 3, 0.04, 1.0, 928, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "addQuickElement", "arg_names": [], "import_names": [], "rhs_call_name": "addQuickElement", "annotation": ""}, "snippet": " handler.addQuickElement(u'georss:point', self.georss_coords((coords,)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L31_C4", "label": "add_georss_element", "type": "function", "loc": [31, 76], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L4_C0", "vector": [2, 1, 0.3963, 0.3407, 1, 0.78, 1.0, 583, 0, 4, 0, 0, 0, 0, 21], "semantic": {"name": "add_georss_element", "arg_names": ["self", "handler", "item", "w3c_geo"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_georss_element(self, handler, item, w3c_geo=False):\n \"\"\"\n This routine adds a GeoRSS XML element using the given item and handler.\n \"\"\"\n # Getting the Geometry object.\n geom = item.get('geometry', None)\n if not geom is None:\n if isinstance(geom, (list, tuple)):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L32_C8", "label": "expression", "type": "expression", "loc": [32, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L31_C4", "vector": [8, 2, 0.2444, 0.0222, 2, 0.78, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This routine adds a GeoRSS XML element using the given item and handler.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L36_C8", "label": "geom = get()", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L31_C4", "vector": [14, 2, 0.2667, 0.0074, 2, 0.78, 0.5, 5, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "geom", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " geom = item.get('geometry', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L37_C8", "label": "if", "type": "if", "loc": [37, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L31_C4", "vector": [4, 2, 0.4185, 0.2963, 2, 0.78, 1.0, 0, 0, 0, 0, 0, 0, 0, 20], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not geom is None:\n if isinstance(geom, (list, tuple)):\n # Special case if a tuple/list was passed in. The tuple may be\n # a point or a box\n box_coords = None\n if isinstance(geom[0], (list, tuple)):\n # Box: ( (X0, Y0), (X1, Y1) )\n if len(geom) == 2:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L38_C12", "label": "if", "type": "if", "loc": [38, 76], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L37_C8", "vector": [4, 3, 0.4222, 0.2889, 3, 0.37, 0.0, 0, 3, 0, 0, 0, 0, 0, 20], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(geom, (list, tuple)):\n # Special case if a tuple/list was passed in. The tuple may be\n # a point or a box\n box_coords = None\n if isinstance(geom[0], (list, tuple)):\n # Box: ( (X0, Y0), (X1, Y1) )\n if len(geom) == 2:\n box_coords = geom"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L41_C16", "label": "box_coords =", "type": "assigned_variable", "loc": [41, 41], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L38_C12", "vector": [14, 4, 0.3037, 0.0074, 4, 0.33, 0.0, 49, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "box_coords", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " box_coords = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L42_C16", "label": "if", "type": "if", "loc": [42, 56], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L38_C12", "vector": [4, 4, 0.363, 0.1111, 4, 0.33, 0.25, 0, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(geom[0], (list, tuple)):\n # Box: ( (X0, Y0), (X1, Y1) )\n if len(geom) == 2:\n box_coords = geom\n else:\n raise ValueError('Only should be two sets of coordinates.')\n else:\n if len(geom) == 2:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L44_C20", "label": "if", "type": "if", "loc": [44, 47], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L42_C16", "vector": [4, 5, 0.337, 0.0296, 5, 0.74, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(geom) == 2:\n box_coords = geom\n else:\n raise ValueError('Only should be two sets of coordinates.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L45_C24", "label": "box_coords =", "type": "assigned_variable", "loc": [45, 45], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L44_C20", "vector": [14, 6, 0.3333, 0.0074, 6, 0.25, 0.0, 49, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "box_coords", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " box_coords = geom"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L49_C20", "label": "if", "type": "if", "loc": [49, 56], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L42_C16", "vector": [4, 5, 0.3889, 0.0593, 5, 0.74, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(geom) == 2:\n # Point: (X, Y)\n self.add_georss_point(handler, geom, w3c_geo=w3c_geo)\n elif len(geom) == 4:\n # Box: (X0, Y0, X1, Y1)\n box_coords = (geom[:2], geom[2:])\n else:\n raise ValueError('Only should be 2 or 4 numeric elements.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L51_C24", "label": "add_georss_point()", "type": "expression", "loc": [51, 51], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L49_C20", "vector": [8, 6, 0.3778, 0.0074, 6, 0.64, 0.0, 402, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "add_georss_point", "arg_names": [], "import_names": [], "rhs_call_name": "add_georss_point", "annotation": ""}, "snippet": " self.add_georss_point(handler, geom, w3c_geo=w3c_geo)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L52_C20", "label": "if", "type": "if", "loc": [52, 56], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L49_C20", "vector": [4, 6, 0.4, 0.037, 6, 0.64, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif len(geom) == 4:\n # Box: (X0, Y0, X1, Y1)\n box_coords = (geom[:2], geom[2:])\n else:\n raise ValueError('Only should be 2 or 4 numeric elements.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L54_C24", "label": "box_coords =", "type": "assigned_variable", "loc": [54, 54], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L52_C20", "vector": [14, 7, 0.4, 0.0074, 7, 0.67, 0.0, 49, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "box_coords", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " box_coords = (geom[:2], geom[2:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L58_C16", "label": "if", "type": "if", "loc": [58, 60], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L38_C12", "vector": [4, 4, 0.437, 0.0222, 4, 0.33, 0.5, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not box_coords is None:\n if w3c_geo: raise ValueError('Cannot use simple GeoRSS box in W3C Geo feeds.')\n handler.addQuickElement(u'georss:box', self.georss_coords(box_coords))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L59_C20", "label": "if", "type": "if", "loc": [59, 59], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L58_C16", "vector": [4, 5, 0.437, 0.0074, 5, 0.42, 0.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if w3c_geo: raise ValueError('Cannot use simple GeoRSS box in W3C Geo feeds.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L60_C20", "label": "addQuickElement()", "type": "expression", "loc": [60, 60], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L58_C16", "vector": [8, 5, 0.4444, 0.0074, 5, 0.42, 1.0, 928, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "addQuickElement", "arg_names": [], "import_names": [], "rhs_call_name": "addQuickElement", "annotation": ""}, "snippet": " handler.addQuickElement(u'georss:box', self.georss_coords(box_coords))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L63_C16", "label": "gtype = lower()", "type": "assigned_variable", "loc": [63, 63], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L38_C12", "vector": [14, 4, 0.4667, 0.0074, 4, 0.33, 0.75, 377, 3, 0, 0, 0, 432, 10, 2], "semantic": {"name": "gtype", "arg_names": [], "import_names": [], "rhs_call_name": "lower", "annotation": ""}, "snippet": " gtype = str(geom.geom_type).lower()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L64_C16", "label": "if", "type": "if", "loc": [64, 76], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L38_C12", "vector": [4, 4, 0.5185, 0.0963, 4, 0.33, 1.0, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if gtype == 'point':\n self.add_georss_point(handler, geom.coords, w3c_geo=w3c_geo) \n else:\n if w3c_geo: raise ValueError('W3C Geo only supports Point geometries.')\n # For formatting consistent w/the GeoRSS simple standard:\n # http://georss.org/1.0#simple\n if gtype in ('linestring', 'linearring'):\n handler.addQuickElement(u'georss:line', self.georss_coords(geom.coords))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L65_C20", "label": "add_georss_point()", "type": "expression", "loc": [65, 65], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L64_C16", "vector": [8, 5, 0.4815, 0.0074, 5, 0.41, 0.0, 402, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "add_georss_point", "arg_names": [], "import_names": [], "rhs_call_name": "add_georss_point", "annotation": ""}, "snippet": " self.add_georss_point(handler, geom.coords, w3c_geo=w3c_geo) "}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L67_C20", "label": "if", "type": "if", "loc": [67, 67], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L64_C16", "vector": [4, 5, 0.4963, 0.0074, 5, 0.41, 0.5, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if w3c_geo: raise ValueError('W3C Geo only supports Point geometries.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L70_C20", "label": "if", "type": "if", "loc": [70, 76], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L64_C16", "vector": [4, 5, 0.5407, 0.0519, 5, 0.41, 1.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if gtype in ('linestring', 'linearring'):\n handler.addQuickElement(u'georss:line', self.georss_coords(geom.coords))\n elif gtype in ('polygon',):\n # Only support the exterior ring.\n handler.addQuickElement(u'georss:polygon', self.georss_coords(geom[0].coords))\n else:\n raise ValueError('Geometry type \"%s\" not supported.' % geom.geom_type)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L71_C24", "label": "addQuickElement()", "type": "expression", "loc": [71, 71], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L70_C20", "vector": [8, 6, 0.5259, 0.0074, 6, 0.45, 0.0, 928, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "addQuickElement", "arg_names": [], "import_names": [], "rhs_call_name": "addQuickElement", "annotation": ""}, "snippet": " handler.addQuickElement(u'georss:line', self.georss_coords(geom.coords))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L72_C20", "label": "if", "type": "if", "loc": [72, 76], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L70_C20", "vector": [4, 6, 0.5481, 0.037, 6, 0.45, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif gtype in ('polygon',):\n # Only support the exterior ring.\n handler.addQuickElement(u'georss:polygon', self.georss_coords(geom[0].coords))\n else:\n raise ValueError('Geometry type \"%s\" not supported.' % geom.geom_type)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L74_C24", "label": "addQuickElement()", "type": "expression", "loc": [74, 74], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L72_C20", "vector": [8, 7, 0.5481, 0.0074, 7, 0.28, 0.0, 928, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "addQuickElement", "arg_names": [], "import_names": [], "rhs_call_name": "addQuickElement", "annotation": ""}, "snippet": " handler.addQuickElement(u'georss:polygon', self.georss_coords(geom[0].coords))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L79_C0", "label": "GeoRSSFeed", "type": "class", "loc": [79, 91], "level": 0, "parent": null, "vector": [3, 0, 0.6296, 0.0963, 0, 0.66, 0.5, 295, 0, 3, 0, 0, 447, 0, 8], "semantic": {"name": "GeoRSSFeed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GeoRSSFeed(Rss201rev2Feed, GeoFeedMixin):\n def rss_attributes(self):\n attrs = super(GeoRSSFeed, self).rss_attributes()\n attrs[u'xmlns:georss'] = u'http://www.georss.org/georss'\n return attrs\n\n def add_item_elements(self, handler, item):\n super(GeoRSSFeed, self).add_item_elements(handler, item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L80_C4", "label": "rss_attributes", "type": "function", "loc": [80, 83], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L79_C0", "vector": [2, 1, 0.6037, 0.0296, 1, 0.61, 0.0, 807, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "rss_attributes", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def rss_attributes(self):\n attrs = super(GeoRSSFeed, self).rss_attributes()\n attrs[u'xmlns:georss'] = u'http://www.georss.org/georss'\n return attrs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L81_C8", "label": "attrs = rss_attributes()", "type": "assigned_variable", "loc": [81, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L80_C4", "vector": [14, 2, 0.6, 0.0074, 2, 0.35, 0.0, 251, 3, 0, 0, 0, 807, 10, 2], "semantic": {"name": "attrs", "arg_names": [], "import_names": [], "rhs_call_name": "rss_attributes", "annotation": ""}, "snippet": " attrs = super(GeoRSSFeed, self).rss_attributes()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L82_C8", "label": "assign", "type": "assigned_variable", "loc": [82, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L80_C4", "vector": [14, 2, 0.6074, 0.0074, 2, 0.35, 0.5, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs[u'xmlns:georss'] = u'http://www.georss.org/georss'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Return_L83_C8", "label": "return", "type": "return", "loc": [83, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L80_C4", "vector": [13, 2, 0.6148, 0.0074, 2, 0.35, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return attrs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L85_C4", "label": "add_item_elements", "type": "function", "loc": [85, 87], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L79_C0", "vector": [2, 1, 0.637, 0.0222, 1, 0.61, 0.5, 977, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "add_item_elements", "arg_names": ["self", "handler", "item"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_item_elements(self, handler, item):\n super(GeoRSSFeed, self).add_item_elements(handler, item)\n self.add_georss_element(handler, item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L86_C8", "label": "add_item_elements()", "type": "expression", "loc": [86, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L85_C4", "vector": [8, 2, 0.637, 0.0074, 2, 0.33, 0.0, 977, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add_item_elements", "arg_names": [], "import_names": [], "rhs_call_name": "add_item_elements", "annotation": ""}, "snippet": " super(GeoRSSFeed, self).add_item_elements(handler, item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L87_C8", "label": "add_georss_element()", "type": "expression", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L85_C4", "vector": [8, 2, 0.6444, 0.0074, 2, 0.33, 1.0, 583, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add_georss_element", "arg_names": [], "import_names": [], "rhs_call_name": "add_georss_element", "annotation": ""}, "snippet": " self.add_georss_element(handler, item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L89_C4", "label": "add_root_elements", "type": "function", "loc": [89, 91], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L79_C0", "vector": [2, 1, 0.6667, 0.0222, 1, 0.61, 1.0, 964, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "add_root_elements", "arg_names": ["self", "handler"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_root_elements(self, handler):\n super(GeoRSSFeed, self).add_root_elements(handler)\n self.add_georss_element(handler, self.feed)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L90_C8", "label": "add_root_elements()", "type": "expression", "loc": [90, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L89_C4", "vector": [8, 2, 0.6667, 0.0074, 2, 0.12, 0.0, 964, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "add_root_elements", "arg_names": [], "import_names": [], "rhs_call_name": "add_root_elements", "annotation": ""}, "snippet": " super(GeoRSSFeed, self).add_root_elements(handler)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L91_C8", "label": "add_georss_element()", "type": "expression", "loc": [91, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L89_C4", "vector": [8, 2, 0.6741, 0.0074, 2, 0.12, 1.0, 583, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add_georss_element", "arg_names": [], "import_names": [], "rhs_call_name": "add_georss_element", "annotation": ""}, "snippet": " self.add_georss_element(handler, self.feed)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L93_C0", "label": "GeoAtom1Feed", "type": "class", "loc": [93, 105], "level": 0, "parent": null, "vector": [3, 0, 0.7333, 0.0963, 0, 0.66, 0.6667, 838, 0, 3, 0, 0, 558, 0, 8], "semantic": {"name": "GeoAtom1Feed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GeoAtom1Feed(Atom1Feed, GeoFeedMixin):\n def root_attributes(self):\n attrs = super(GeoAtom1Feed, self).root_attributes()\n attrs[u'xmlns:georss'] = u'http://www.georss.org/georss'\n return attrs\n\n def add_item_elements(self, handler, item):\n super(GeoAtom1Feed, self).add_item_elements(handler, item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L94_C4", "label": "root_attributes", "type": "function", "loc": [94, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L93_C0", "vector": [2, 1, 0.7074, 0.0296, 1, 0.83, 0.0, 926, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "root_attributes", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def root_attributes(self):\n attrs = super(GeoAtom1Feed, self).root_attributes()\n attrs[u'xmlns:georss'] = u'http://www.georss.org/georss'\n return attrs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L95_C8", "label": "attrs = root_attributes()", "type": "assigned_variable", "loc": [95, 95], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L94_C4", "vector": [14, 2, 0.7037, 0.0074, 2, 0.14, 0.0, 251, 3, 0, 0, 0, 926, 10, 2], "semantic": {"name": "attrs", "arg_names": [], "import_names": [], "rhs_call_name": "root_attributes", "annotation": ""}, "snippet": " attrs = super(GeoAtom1Feed, self).root_attributes()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L96_C8", "label": "assign", "type": "assigned_variable", "loc": [96, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L94_C4", "vector": [14, 2, 0.7111, 0.0074, 2, 0.14, 0.5, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs[u'xmlns:georss'] = u'http://www.georss.org/georss'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Return_L97_C8", "label": "return", "type": "return", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L94_C4", "vector": [13, 2, 0.7185, 0.0074, 2, 0.14, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return attrs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L99_C4", "label": "add_item_elements", "type": "function", "loc": [99, 101], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L93_C0", "vector": [2, 1, 0.7407, 0.0222, 1, 0.83, 0.5, 977, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "add_item_elements", "arg_names": ["self", "handler", "item"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_item_elements(self, handler, item):\n super(GeoAtom1Feed, self).add_item_elements(handler, item)\n self.add_georss_element(handler, item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L100_C8", "label": "add_item_elements()", "type": "expression", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L99_C4", "vector": [8, 2, 0.7407, 0.0074, 2, 0.89, 0.0, 977, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add_item_elements", "arg_names": [], "import_names": [], "rhs_call_name": "add_item_elements", "annotation": ""}, "snippet": " super(GeoAtom1Feed, self).add_item_elements(handler, item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L101_C8", "label": "add_georss_element()", "type": "expression", "loc": [101, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L99_C4", "vector": [8, 2, 0.7481, 0.0074, 2, 0.89, 1.0, 583, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add_georss_element", "arg_names": [], "import_names": [], "rhs_call_name": "add_georss_element", "annotation": ""}, "snippet": " self.add_georss_element(handler, item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L103_C4", "label": "add_root_elements", "type": "function", "loc": [103, 105], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L93_C0", "vector": [2, 1, 0.7704, 0.0222, 1, 0.83, 1.0, 964, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "add_root_elements", "arg_names": ["self", "handler"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_root_elements(self, handler):\n super(GeoAtom1Feed, self).add_root_elements(handler)\n self.add_georss_element(handler, self.feed)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L104_C8", "label": "add_root_elements()", "type": "expression", "loc": [104, 104], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L103_C4", "vector": [8, 2, 0.7704, 0.0074, 2, 0.9, 0.0, 964, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "add_root_elements", "arg_names": [], "import_names": [], "rhs_call_name": "add_root_elements", "annotation": ""}, "snippet": " super(GeoAtom1Feed, self).add_root_elements(handler)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L105_C8", "label": "add_georss_element()", "type": "expression", "loc": [105, 105], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L103_C4", "vector": [8, 2, 0.7778, 0.0074, 2, 0.9, 1.0, 583, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add_georss_element", "arg_names": [], "import_names": [], "rhs_call_name": "add_georss_element", "annotation": ""}, "snippet": " self.add_georss_element(handler, self.feed)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L107_C0", "label": "W3CGeoFeed", "type": "class", "loc": [107, 119], "level": 0, "parent": null, "vector": [3, 0, 0.837, 0.0963, 0, 0.66, 0.8333, 413, 0, 3, 0, 0, 447, 0, 8], "semantic": {"name": "W3CGeoFeed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class W3CGeoFeed(Rss201rev2Feed, GeoFeedMixin):\n def rss_attributes(self):\n attrs = super(W3CGeoFeed, self).rss_attributes()\n attrs[u'xmlns:geo'] = u'http://www.w3.org/2003/01/geo/wgs84_pos#'\n return attrs\n\n def add_item_elements(self, handler, item):\n super(W3CGeoFeed, self).add_item_elements(handler, item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L108_C4", "label": "rss_attributes", "type": "function", "loc": [108, 111], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L107_C0", "vector": [2, 1, 0.8111, 0.0296, 1, 0.3, 0.0, 807, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "rss_attributes", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def rss_attributes(self):\n attrs = super(W3CGeoFeed, self).rss_attributes()\n attrs[u'xmlns:geo'] = u'http://www.w3.org/2003/01/geo/wgs84_pos#'\n return attrs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L109_C8", "label": "attrs = rss_attributes()", "type": "assigned_variable", "loc": [109, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L108_C4", "vector": [14, 2, 0.8074, 0.0074, 2, 0.11, 0.0, 251, 3, 0, 0, 0, 807, 10, 2], "semantic": {"name": "attrs", "arg_names": [], "import_names": [], "rhs_call_name": "rss_attributes", "annotation": ""}, "snippet": " attrs = super(W3CGeoFeed, self).rss_attributes()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L110_C8", "label": "assign", "type": "assigned_variable", "loc": [110, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L108_C4", "vector": [14, 2, 0.8148, 0.0074, 2, 0.11, 0.5, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs[u'xmlns:geo'] = u'http://www.w3.org/2003/01/geo/wgs84_pos#'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Return_L111_C8", "label": "return", "type": "return", "loc": [111, 111], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L108_C4", "vector": [13, 2, 0.8222, 0.0074, 2, 0.11, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return attrs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L113_C4", "label": "add_item_elements", "type": "function", "loc": [113, 115], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L107_C0", "vector": [2, 1, 0.8444, 0.0222, 1, 0.3, 0.5, 977, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "add_item_elements", "arg_names": ["self", "handler", "item"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_item_elements(self, handler, item):\n super(W3CGeoFeed, self).add_item_elements(handler, item)\n self.add_georss_element(handler, item, w3c_geo=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L114_C8", "label": "add_item_elements()", "type": "expression", "loc": [114, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L113_C4", "vector": [8, 2, 0.8444, 0.0074, 2, 0.17, 0.0, 977, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add_item_elements", "arg_names": [], "import_names": [], "rhs_call_name": "add_item_elements", "annotation": ""}, "snippet": " super(W3CGeoFeed, self).add_item_elements(handler, item)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L115_C8", "label": "add_georss_element()", "type": "expression", "loc": [115, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L113_C4", "vector": [8, 2, 0.8519, 0.0074, 2, 0.17, 1.0, 583, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "add_georss_element", "arg_names": [], "import_names": [], "rhs_call_name": "add_georss_element", "annotation": ""}, "snippet": " self.add_georss_element(handler, item, w3c_geo=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L117_C4", "label": "add_root_elements", "type": "function", "loc": [117, 119], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L107_C0", "vector": [2, 1, 0.8741, 0.0222, 1, 0.3, 1.0, 964, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "add_root_elements", "arg_names": ["self", "handler"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_root_elements(self, handler):\n super(W3CGeoFeed, self).add_root_elements(handler)\n self.add_georss_element(handler, self.feed, w3c_geo=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L118_C8", "label": "add_root_elements()", "type": "expression", "loc": [118, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L117_C4", "vector": [8, 2, 0.8741, 0.0074, 2, 0.27, 0.0, 964, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "add_root_elements", "arg_names": [], "import_names": [], "rhs_call_name": "add_root_elements", "annotation": ""}, "snippet": " super(W3CGeoFeed, self).add_root_elements(handler)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L119_C8", "label": "add_georss_element()", "type": "expression", "loc": [119, 119], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L117_C4", "vector": [8, 2, 0.8815, 0.0074, 2, 0.27, 1.0, 583, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "add_georss_element", "arg_names": [], "import_names": [], "rhs_call_name": "add_georss_element", "annotation": ""}, "snippet": " self.add_georss_element(handler, self.feed, w3c_geo=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L122_C0", "label": "Feed", "type": "class", "loc": [122, 135], "level": 0, "parent": null, "vector": [3, 0, 0.9519, 0.1037, 0, 0.66, 1.0, 571, 0, 2, 0, 0, 346, 0, 2], "semantic": {"name": "Feed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Feed(BaseFeed):\n \"\"\"\n This is a subclass of the `Feed` from `django.contrib.syndication`.\n This allows users to define a `geometry(obj)` and/or `item_geometry(item)`\n methods on their own subclasses so that geo-referenced information may\n placed in the feed.\n \"\"\"\n feed_type = GeoRSSFeed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L123_C4", "label": "expression", "type": "expression", "loc": [123, 128], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L122_C0", "vector": [8, 1, 0.9296, 0.0444, 1, 0.71, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This is a subclass of the `Feed` from `django.contrib.syndication`.\n This allows users to define a `geometry(obj)` and/or `item_geometry(item)`\n methods on their own subclasses so that geo-referenced information may\n placed in the feed.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L129_C4", "label": "feed_type =", "type": "assigned_variable", "loc": [129, 129], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L122_C0", "vector": [14, 1, 0.9556, 0.0074, 1, 0.71, 0.3333, 55, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "feed_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " feed_type = GeoRSSFeed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L131_C4", "label": "feed_extra_kwargs", "type": "function", "loc": [131, 132], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L122_C0", "vector": [2, 1, 0.9741, 0.0148, 1, 0.71, 0.6667, 325, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "feed_extra_kwargs", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def feed_extra_kwargs(self, obj):\n return {'geometry' : self.__get_dynamic_attr('geometry', obj)}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Return_L132_C8", "label": "return", "type": "return", "loc": [132, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L131_C4", "vector": [13, 2, 0.9778, 0.0074, 2, 0.81, 0.0, 0, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {'geometry' : self.__get_dynamic_attr('geometry', obj)}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L134_C4", "label": "item_extra_kwargs", "type": "function", "loc": [134, 135], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L122_C0", "vector": [2, 1, 0.9963, 0.0148, 1, 0.71, 1.0, 993, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "item_extra_kwargs", "arg_names": ["self", "item"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def item_extra_kwargs(self, item):\n return {'geometry' : self.__get_dynamic_attr('item_geometry', item)}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98668:Return_L135_C8", "label": "return", "type": "return", "loc": [135, 135], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L134_C4", "vector": [13, 2, 1.0, 0.0074, 2, 0.25, 0.0, 0, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {'geometry' : self.__get_dynamic_attr('item_geometry', item)}"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Return_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L25_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L27_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L29_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L31_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L31_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L31_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L31_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L38_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L41_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L42_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L42_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L44_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L44_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L45_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L42_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L49_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L49_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L51_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L49_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L52_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L52_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L54_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L58_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L58_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L59_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L58_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L60_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L63_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L64_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L64_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L65_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L64_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L67_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L64_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L70_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L70_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L71_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L70_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L72_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:If_L72_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L74_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L79_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L80_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L81_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Return_L83_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L79_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L85_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L79_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L89_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L89_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L89_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L93_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L94_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Return_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L93_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L99_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L93_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L103_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L103_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L104_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L103_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L105_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L107_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L108_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L108_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L108_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L108_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Return_L111_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L107_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L113_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L113_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L113_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L115_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L107_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L117_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L122_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Expr_L123_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L122_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Assign_L129_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L122_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L131_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L131_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Return_L132_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:ClassDef_L122_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L134_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98668:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98668:Return_L135_C8"}] |
"""
Utilities for manipulating Geometry WKT.
"""
def precision_wkt(geom, prec):
"""
Returns WKT text of the geometry according to the given precision (an
integer or a string). If the precision is an integer, then the decimal
places of coordinates WKT will be truncated to that number:
>>> pnt = Point(5, 23)
>>> pnt.wkt
'POINT (5.0000000000000000 23.0000000000000000)'
>>> precision(geom, 1)
'POINT (5.0 23.0)'
If the precision is a string, it must be valid Python format string
(e.g., '%20.7f') -- thus, you should know what you're doing.
"""
if isinstance(prec, int):
num_fmt = '%%.%df' % prec
elif isinstance(prec, basestring):
num_fmt = prec
else:
raise TypeError
# TODO: Support 3D geometries.
coord_fmt = ' '.join([num_fmt, num_fmt])
def formatted_coords(coords):
return ','.join([coord_fmt % c[:2] for c in coords])
def formatted_poly(poly):
return ','.join(['(%s)' % formatted_coords(r) for r in poly])
def formatted_geom(g):
gtype = str(g.geom_type).upper()
yield '%s(' % gtype
if gtype == 'POINT':
yield formatted_coords((g.coords,))
elif gtype in ('LINESTRING', 'LINEARRING'):
yield formatted_coords(g.coords)
elif gtype in ('POLYGON', 'MULTILINESTRING'):
yield formatted_poly(g)
elif gtype == 'MULTIPOINT':
yield formatted_coords(g.coords)
elif gtype == 'MULTIPOLYGON':
yield ','.join(['(%s)' % formatted_poly(p) for p in g])
elif gtype == 'GEOMETRYCOLLECTION':
yield ','.join([''.join([wkt for wkt in formatted_geom(child)]) for child in g])
else:
raise TypeError
yield ')'
return ''.join([wkt for wkt in formatted_geom(geom)])
| ajibawa-2023/Python-Code-Large/train/row_98669 | 29 | 55 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.0364, 0.0545, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\n Utilities for manipulating Geometry WKT.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "label": "precision_wkt", "type": "function", "loc": [5, 55], "level": 0, "parent": null, "vector": [2, 0, 0.5455, 0.9273, 0, 0.66, 1.0, 39, 0, 2, 1, 0, 0, 0, 19], "semantic": {"name": "precision_wkt", "arg_names": ["geom", "prec"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def precision_wkt(geom, prec):\n \"\"\"\n Returns WKT text of the geometry according to the given precision (an \n integer or a string). If the precision is an integer, then the decimal\n places of coordinates WKT will be truncated to that number:\n\n >>> pnt = Point(5, 23)\n >>> pnt.wkt"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L6_C4", "label": "expression", "type": "expression", "loc": [6, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "vector": [8, 1, 0.2273, 0.2545, 1, 0.51, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns WKT text of the geometry according to the given precision (an \n integer or a string). If the precision is an integer, then the decimal\n places of coordinates WKT will be truncated to that number:\n\n >>> pnt = Point(5, 23)\n >>> pnt.wkt\n 'POINT (5.0000000000000000 23.0000000000000000)'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L20_C4", "label": "if", "type": "if", "loc": [20, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "vector": [4, 1, 0.4091, 0.1091, 1, 0.51, 0.1667, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(prec, int):\n num_fmt = '%%.%df' % prec\n elif isinstance(prec, basestring):\n num_fmt = prec\n else:\n raise TypeError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Assign_L21_C8", "label": "num_fmt =", "type": "assigned_variable", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L20_C4", "vector": [14, 2, 0.3818, 0.0182, 2, 0.83, 0.0, 252, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "num_fmt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " num_fmt = '%%.%df' % prec"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L22_C4", "label": "if", "type": "if", "loc": [22, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L20_C4", "vector": [4, 2, 0.4273, 0.0727, 2, 0.83, 1.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(prec, basestring):\n num_fmt = prec\n else:\n raise TypeError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Assign_L23_C8", "label": "num_fmt =", "type": "assigned_variable", "loc": [23, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L22_C4", "vector": [14, 3, 0.4182, 0.0182, 3, 0.02, 0.0, 252, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "num_fmt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " num_fmt = prec"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Assign_L28_C4", "label": "coord_fmt = join()", "type": "assigned_variable", "loc": [28, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "vector": [14, 1, 0.5091, 0.0182, 1, 0.51, 0.3333, 728, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "coord_fmt", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " coord_fmt = ' '.join([num_fmt, num_fmt])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L30_C4", "label": "formatted_coords", "type": "function", "loc": [30, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "vector": [2, 1, 0.5545, 0.0364, 1, 0.51, 0.5, 638, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "formatted_coords", "arg_names": ["coords"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def formatted_coords(coords):\n return ','.join([coord_fmt % c[:2] for c in coords])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Return_L31_C8", "label": "return", "type": "return", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L30_C4", "vector": [13, 2, 0.5636, 0.0182, 2, 0.91, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ','.join([coord_fmt % c[:2] for c in coords])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L33_C4", "label": "formatted_poly", "type": "function", "loc": [33, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "vector": [2, 1, 0.6091, 0.0364, 1, 0.51, 0.6667, 183, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "formatted_poly", "arg_names": ["poly"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def formatted_poly(poly):\n return ','.join(['(%s)' % formatted_coords(r) for r in poly])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Return_L34_C8", "label": "return", "type": "return", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L33_C4", "vector": [13, 2, 0.6182, 0.0182, 2, 0.97, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ','.join(['(%s)' % formatted_coords(r) for r in poly])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L36_C4", "label": "formatted_geom", "type": "function", "loc": [36, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "vector": [2, 1, 0.8091, 0.3273, 1, 0.51, 0.8333, 699, 0, 1, 0, 0, 0, 0, 11], "semantic": {"name": "formatted_geom", "arg_names": ["g"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def formatted_geom(g):\n gtype = str(g.geom_type).upper()\n yield '%s(' % gtype\n if gtype == 'POINT':\n yield formatted_coords((g.coords,))\n elif gtype in ('LINESTRING', 'LINEARRING'):\n yield formatted_coords(g.coords)\n elif gtype in ('POLYGON', 'MULTILINESTRING'):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Assign_L37_C8", "label": "gtype = upper()", "type": "assigned_variable", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L36_C4", "vector": [14, 2, 0.6727, 0.0182, 2, 0.91, 0.0, 377, 3, 0, 0, 0, 347, 10, 2], "semantic": {"name": "gtype", "arg_names": [], "import_names": [], "rhs_call_name": "upper", "annotation": ""}, "snippet": " gtype = str(g.geom_type).upper()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L38_C8", "label": "expression", "type": "expression", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L36_C4", "vector": [8, 2, 0.6909, 0.0182, 2, 0.91, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield '%s(' % gtype"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L39_C8", "label": "if", "type": "if", "loc": [39, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L36_C4", "vector": [4, 2, 0.8273, 0.2545, 2, 0.91, 0.6667, 0, 0, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if gtype == 'POINT':\n yield formatted_coords((g.coords,))\n elif gtype in ('LINESTRING', 'LINEARRING'):\n yield formatted_coords(g.coords)\n elif gtype in ('POLYGON', 'MULTILINESTRING'):\n yield formatted_poly(g)\n elif gtype == 'MULTIPOINT':\n yield formatted_coords(g.coords)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L40_C12", "label": "expression", "type": "expression", "loc": [40, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L39_C8", "vector": [8, 3, 0.7273, 0.0182, 3, 0.24, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield formatted_coords((g.coords,))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L41_C8", "label": "if", "type": "if", "loc": [41, 52], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L39_C8", "vector": [4, 3, 0.8455, 0.2182, 3, 0.24, 1.0, 0, 0, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif gtype in ('LINESTRING', 'LINEARRING'):\n yield formatted_coords(g.coords)\n elif gtype in ('POLYGON', 'MULTILINESTRING'):\n yield formatted_poly(g)\n elif gtype == 'MULTIPOINT':\n yield formatted_coords(g.coords)\n elif gtype == 'MULTIPOLYGON':\n yield ','.join(['(%s)' % formatted_poly(p) for p in g])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L42_C12", "label": "expression", "type": "expression", "loc": [42, 42], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L41_C8", "vector": [8, 4, 0.7636, 0.0182, 4, 0.12, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield formatted_coords(g.coords)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L43_C8", "label": "if", "type": "if", "loc": [43, 52], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L41_C8", "vector": [4, 4, 0.8636, 0.1818, 4, 0.12, 1.0, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif gtype in ('POLYGON', 'MULTILINESTRING'):\n yield formatted_poly(g)\n elif gtype == 'MULTIPOINT':\n yield formatted_coords(g.coords)\n elif gtype == 'MULTIPOLYGON':\n yield ','.join(['(%s)' % formatted_poly(p) for p in g])\n elif gtype == 'GEOMETRYCOLLECTION':\n yield ','.join([''.join([wkt for wkt in formatted_geom(child)]) for child in g])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L44_C12", "label": "expression", "type": "expression", "loc": [44, 44], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L43_C8", "vector": [8, 5, 0.8, 0.0182, 5, 0.86, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield formatted_poly(g)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L45_C8", "label": "if", "type": "if", "loc": [45, 52], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L43_C8", "vector": [4, 5, 0.8818, 0.1455, 5, 0.86, 1.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif gtype == 'MULTIPOINT':\n yield formatted_coords(g.coords)\n elif gtype == 'MULTIPOLYGON':\n yield ','.join(['(%s)' % formatted_poly(p) for p in g])\n elif gtype == 'GEOMETRYCOLLECTION':\n yield ','.join([''.join([wkt for wkt in formatted_geom(child)]) for child in g])\n else:\n raise TypeError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L46_C12", "label": "expression", "type": "expression", "loc": [46, 46], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L45_C8", "vector": [8, 6, 0.8364, 0.0182, 6, 0.4, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield formatted_coords(g.coords)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L47_C8", "label": "if", "type": "if", "loc": [47, 52], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L45_C8", "vector": [4, 6, 0.9, 0.1091, 6, 0.4, 1.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif gtype == 'MULTIPOLYGON':\n yield ','.join(['(%s)' % formatted_poly(p) for p in g])\n elif gtype == 'GEOMETRYCOLLECTION':\n yield ','.join([''.join([wkt for wkt in formatted_geom(child)]) for child in g])\n else:\n raise TypeError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L48_C12", "label": "expression", "type": "expression", "loc": [48, 48], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L47_C8", "vector": [8, 7, 0.8727, 0.0182, 7, 0.61, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ','.join(['(%s)' % formatted_poly(p) for p in g])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L49_C8", "label": "if", "type": "if", "loc": [49, 52], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L47_C8", "vector": [4, 7, 0.9182, 0.0727, 7, 0.61, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif gtype == 'GEOMETRYCOLLECTION':\n yield ','.join([''.join([wkt for wkt in formatted_geom(child)]) for child in g])\n else:\n raise TypeError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L50_C12", "label": "expression", "type": "expression", "loc": [50, 50], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L49_C8", "vector": [8, 8, 0.9091, 0.0182, 8, 0.4, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ','.join([''.join([wkt for wkt in formatted_geom(child)]) for child in g])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L53_C8", "label": "expression", "type": "expression", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L36_C4", "vector": [8, 2, 0.9636, 0.0182, 2, 0.91, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ')'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98669:Return_L55_C4", "label": "return", "type": "return", "loc": [55, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "vector": [13, 1, 1.0, 0.0182, 1, 0.51, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''.join([wkt for wkt in formatted_geom(geom)])"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Assign_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Assign_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Assign_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Return_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Return_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Assign_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L40_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L41_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L42_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L41_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L43_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L44_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L43_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L45_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L46_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L45_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L47_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L48_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L47_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:If_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Expr_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98669:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98669:Return_L55_C4"}] |
"""
This module houses the GeoIP object, a ctypes wrapper for the MaxMind GeoIP(R)
C API (http://www.maxmind.com/app/c). This is an alternative to the GPL
licensed Python GeoIP interface provided by MaxMind.
GeoIP(R) is a registered trademark of MaxMind, LLC of Boston, Massachusetts.
For IP-based geolocation, this module requires the GeoLite Country and City
datasets, in binary format (CSV will not work!). The datasets may be
downloaded from MaxMind at http://www.maxmind.com/download/geoip/database/.
Grab GeoIP.dat.gz and GeoLiteCity.dat.gz, and unzip them in the directory
corresponding to settings.GEOIP_PATH. See the GeoIP docstring and examples
below for more details.
TODO: Verify compatibility with Windows.
Example:
>>> from django.contrib.gis.utils import GeoIP
>>> g = GeoIP()
>>> g.country('google.com')
{'country_code': 'US', 'country_name': 'United States'}
>>> g.city('72.14.207.99')
{'area_code': 650,
'city': 'Mountain View',
'country_code': 'US',
'country_code3': 'USA',
'country_name': 'United States',
'dma_code': 807,
'latitude': 37.419200897216797,
'longitude': -122.05740356445312,
'postal_code': '94043',
'region': 'CA'}
>>> g.lat_lon('salon.com')
(37.789798736572266, -122.39420318603516)
>>> g.lon_lat('uh.edu')
(-95.415199279785156, 29.77549934387207)
>>> g.geos('24.124.1.80').wkt
'POINT (-95.2087020874023438 39.0392990112304688)'
"""
import os, re
from ctypes import c_char_p, c_float, c_int, Structure, CDLL, POINTER
from ctypes.util import find_library
from django.conf import settings
if not settings.configured: settings.configure()
# Creating the settings dictionary with any settings, if needed.
GEOIP_SETTINGS = dict((key, getattr(settings, key))
for key in ('GEOIP_PATH', 'GEOIP_LIBRARY_PATH', 'GEOIP_COUNTRY', 'GEOIP_CITY')
if hasattr(settings, key))
lib_path = GEOIP_SETTINGS.get('GEOIP_LIBRARY_PATH', None)
# GeoIP Exception class.
class GeoIPException(Exception): pass
# The shared library for the GeoIP C API. May be downloaded
# from http://www.maxmind.com/download/geoip/api/c/
if lib_path:
lib_name = None
else:
# TODO: Is this really the library name for Windows?
lib_name = 'GeoIP'
# Getting the path to the GeoIP library.
if lib_name: lib_path = find_library(lib_name)
if lib_path is None: raise GeoIPException('Could not find the GeoIP library (tried "%s"). '
'Try setting GEOIP_LIBRARY_PATH in your settings.' % lib_name)
lgeoip = CDLL(lib_path)
# Regular expressions for recognizing IP addresses and the GeoIP
# free database editions.
ipregex = re.compile(r'^(?P<w>\d\d?\d?)\.(?P<x>\d\d?\d?)\.(?P<y>\d\d?\d?)\.(?P<z>\d\d?\d?)$')
free_regex = re.compile(r'^GEO-\d{3}FREE')
lite_regex = re.compile(r'^GEO-\d{3}LITE')
#### GeoIP C Structure definitions ####
class GeoIPRecord(Structure):
_fields_ = [('country_code', c_char_p),
('country_code3', c_char_p),
('country_name', c_char_p),
('region', c_char_p),
('city', c_char_p),
('postal_code', c_char_p),
('latitude', c_float),
('longitude', c_float),
# TODO: In 1.4.6 this changed from `int dma_code;` to
# `union {int metro_code; int dma_code;};`. Change
# to a `ctypes.Union` in to accomodate in future when
# pre-1.4.6 versions are no longer distributed.
('dma_code', c_int),
('area_code', c_int),
# TODO: The following structure fields were added in 1.4.3 --
# uncomment these fields when sure previous versions are no
# longer distributed by package maintainers.
#('charset', c_int),
#('continent_code', c_char_p),
]
class GeoIPTag(Structure): pass
#### ctypes function prototypes ####
RECTYPE = POINTER(GeoIPRecord)
DBTYPE = POINTER(GeoIPTag)
# For retrieving records by name or address.
def record_output(func):
func.restype = RECTYPE
return func
rec_by_addr = record_output(lgeoip.GeoIP_record_by_addr)
rec_by_name = record_output(lgeoip.GeoIP_record_by_name)
# For opening & closing GeoIP database files.
geoip_open = lgeoip.GeoIP_open
geoip_open.restype = DBTYPE
geoip_close = lgeoip.GeoIP_delete
geoip_close.argtypes = [DBTYPE]
geoip_close.restype = None
# String output routines.
def string_output(func):
func.restype = c_char_p
return func
geoip_dbinfo = string_output(lgeoip.GeoIP_database_info)
cntry_code_by_addr = string_output(lgeoip.GeoIP_country_code_by_addr)
cntry_code_by_name = string_output(lgeoip.GeoIP_country_code_by_name)
cntry_name_by_addr = string_output(lgeoip.GeoIP_country_name_by_addr)
cntry_name_by_name = string_output(lgeoip.GeoIP_country_name_by_name)
#### GeoIP class ####
class GeoIP(object):
# The flags for GeoIP memory caching.
# GEOIP_STANDARD - read database from filesystem, uses least memory.
#
# GEOIP_MEMORY_CACHE - load database into memory, faster performance
# but uses more memory
#
# GEOIP_CHECK_CACHE - check for updated database. If database has been updated,
# reload filehandle and/or memory cache.
#
# GEOIP_INDEX_CACHE - just cache
# the most frequently accessed index portion of the database, resulting
# in faster lookups than GEOIP_STANDARD, but less memory usage than
# GEOIP_MEMORY_CACHE - useful for larger databases such as
# GeoIP Organization and GeoIP City. Note, for GeoIP Country, Region
# and Netspeed databases, GEOIP_INDEX_CACHE is equivalent to GEOIP_MEMORY_CACHE
#
GEOIP_STANDARD = 0
GEOIP_MEMORY_CACHE = 1
GEOIP_CHECK_CACHE = 2
GEOIP_INDEX_CACHE = 4
cache_options = dict((opt, None) for opt in (0, 1, 2, 4))
_city_file = ''
_country_file = ''
# Initially, pointers to GeoIP file references are NULL.
_city = None
_country = None
def __init__(self, path=None, cache=0, country=None, city=None):
"""
Initializes the GeoIP object, no parameters are required to use default
settings. Keyword arguments may be passed in to customize the locations
of the GeoIP data sets.
* path: Base directory to where GeoIP data is located or the full path
to where the city or country data files (*.dat) are located.
Assumes that both the city and country data sets are located in
this directory; overrides the GEOIP_PATH settings attribute.
* cache: The cache settings when opening up the GeoIP datasets,
and may be an integer in (0, 1, 2, 4) corresponding to
the GEOIP_STANDARD, GEOIP_MEMORY_CACHE, GEOIP_CHECK_CACHE,
and GEOIP_INDEX_CACHE `GeoIPOptions` C API settings,
respectively. Defaults to 0, meaning that the data is read
from the disk.
* country: The name of the GeoIP country data file. Defaults to
'GeoIP.dat'; overrides the GEOIP_COUNTRY settings attribute.
* city: The name of the GeoIP city data file. Defaults to
'GeoLiteCity.dat'; overrides the GEOIP_CITY settings attribute.
"""
# Checking the given cache option.
if cache in self.cache_options:
self._cache = self.cache_options[cache]
else:
raise GeoIPException('Invalid caching option: %s' % cache)
# Getting the GeoIP data path.
if not path:
path = GEOIP_SETTINGS.get('GEOIP_PATH', None)
if not path: raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
if not isinstance(path, basestring):
raise TypeError('Invalid path type: %s' % type(path).__name__)
if os.path.isdir(path):
# Constructing the GeoIP database filenames using the settings
# dictionary. If the database files for the GeoLite country
# and/or city datasets exist, then try and open them.
country_db = os.path.join(path, country or GEOIP_SETTINGS.get('GEOIP_COUNTRY', 'GeoIP.dat'))
if os.path.isfile(country_db):
self._country = geoip_open(country_db, cache)
self._country_file = country_db
city_db = os.path.join(path, city or GEOIP_SETTINGS.get('GEOIP_CITY', 'GeoLiteCity.dat'))
if os.path.isfile(city_db):
self._city = geoip_open(city_db, cache)
self._city_file = city_db
elif os.path.isfile(path):
# Otherwise, some detective work will be needed to figure
# out whether the given database path is for the GeoIP country
# or city databases.
ptr = geoip_open(path, cache)
info = geoip_dbinfo(ptr)
if lite_regex.match(info):
# GeoLite City database detected.
self._city = ptr
self._city_file = path
elif free_regex.match(info):
# GeoIP Country database detected.
self._country = ptr
self._country_file = path
else:
raise GeoIPException('Unable to recognize database edition: %s' % info)
else:
raise GeoIPException('GeoIP path must be a valid file or directory.')
def __del__(self):
# Cleaning any GeoIP file handles lying around.
if self._country: geoip_close(self._country)
if self._city: geoip_close(self._city)
def _check_query(self, query, country=False, city=False, city_or_country=False):
"Helper routine for checking the query and database availability."
# Making sure a string was passed in for the query.
if not isinstance(query, basestring):
raise TypeError('GeoIP query must be a string, not type %s' % type(query).__name__)
# Extra checks for the existence of country and city databases.
if city_or_country and not (self._country or self._city):
raise GeoIPException('Invalid GeoIP country and city data files.')
elif country and not self._country:
raise GeoIPException('Invalid GeoIP country data file: %s' % self._country_file)
elif city and not self._city:
raise GeoIPException('Invalid GeoIP city data file: %s' % self._city_file)
def city(self, query):
"""
Returns a dictionary of city information for the given IP address or
Fully Qualified Domain Name (FQDN). Some information in the dictionary
may be undefined (None).
"""
self._check_query(query, city=True)
if ipregex.match(query):
# If an IP address was passed in
ptr = rec_by_addr(self._city, c_char_p(query))
else:
# If a FQDN was passed in.
ptr = rec_by_name(self._city, c_char_p(query))
# Checking the pointer to the C structure, if valid pull out elements
# into a dicionary and return.
if bool(ptr):
record = ptr.contents
return dict((tup[0], getattr(record, tup[0])) for tup in record._fields_)
else:
return None
def country_code(self, query):
"Returns the country code for the given IP Address or FQDN."
self._check_query(query, city_or_country=True)
if self._country:
if ipregex.match(query): return cntry_code_by_addr(self._country, query)
else: return cntry_code_by_name(self._country, query)
else:
return self.city(query)['country_code']
def country_name(self, query):
"Returns the country name for the given IP Address or FQDN."
self._check_query(query, city_or_country=True)
if self._country:
if ipregex.match(query): return cntry_name_by_addr(self._country, query)
else: return cntry_name_by_name(self._country, query)
else:
return self.city(query)['country_name']
def country(self, query):
"""
Returns a dictonary with with the country code and name when given an
IP address or a Fully Qualified Domain Name (FQDN). For example, both
'24.124.1.80' and 'djangoproject.com' are valid parameters.
"""
# Returning the country code and name
return {'country_code' : self.country_code(query),
'country_name' : self.country_name(query),
}
#### Coordinate retrieval routines ####
def coords(self, query, ordering=('longitude', 'latitude')):
cdict = self.city(query)
if cdict is None: return None
else: return tuple(cdict[o] for o in ordering)
def lon_lat(self, query):
"Returns a tuple of the (longitude, latitude) for the given query."
return self.coords(query)
def lat_lon(self, query):
"Returns a tuple of the (latitude, longitude) for the given query."
return self.coords(query, ('latitude', 'longitude'))
def geos(self, query):
"Returns a GEOS Point object for the given query."
ll = self.lon_lat(query)
if ll:
from django.contrib.gis.geos import Point
return Point(ll, srid=4326)
else:
return None
#### GeoIP Database Information Routines ####
def country_info(self):
"Returns information about the GeoIP country database."
if self._country is None:
ci = 'No GeoIP Country data in "%s"' % self._country_file
else:
ci = geoip_dbinfo(self._country)
return ci
country_info = property(country_info)
def city_info(self):
"Retuns information about the GeoIP city database."
if self._city is None:
ci = 'No GeoIP City data in "%s"' % self._city_file
else:
ci = geoip_dbinfo(self._city)
return ci
city_info = property(city_info)
def info(self):
"Returns information about all GeoIP databases in use."
return 'Country:\n\t%s\nCity:\n\t%s' % (self.country_info, self.city_info)
info = property(info)
#### Methods for compatibility w/the GeoIP-Python API. ####
@classmethod
def open(cls, full_path, cache):
return GeoIP(full_path, cache)
def _rec_by_arg(self, arg):
if self._city:
return self.city(arg)
else:
return self.country(arg)
region_by_addr = city
region_by_name = city
record_by_addr = _rec_by_arg
record_by_name = _rec_by_arg
country_code_by_addr = country_code
country_code_by_name = country_code
country_name_by_addr = country_name
country_name_by_name = country_name
| ajibawa-2023/Python-Code-Large/train/row_98670 | 169 | 361 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 40], "level": 0, "parent": null, "vector": [8, 0, 0.0568, 0.1108, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\n This module houses the GeoIP object, a ctypes wrapper for the MaxMind GeoIP(R)\n C API (http://www.maxmind.com/app/c). This is an alternative to the GPL\n licensed Python GeoIP interface provided by MaxMind.\n\n GeoIP(R) is a registered trademark of MaxMind, LLC of Boston, Massachusetts.\n\n For IP-based geolocation, this module requires the GeoLite Country and City"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Import_L41_C0", "label": "os import os, re", "type": "import", "loc": [41, 41], "level": 0, "parent": null, "vector": [1, 0, 0.1136, 0.0028, 0, 0.66, 0.0294, 688, 0, 2, 0, 0, 688, 0, 0], "semantic": {"name": "os", "arg_names": [], "import_names": ["os", "re"], "rhs_call_name": "", "annotation": ""}, "snippet": "import os, re"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:ImportFrom_L42_C0", "label": "from ctypes import c_char_p, c_float, c_int\u2026", "type": "import", "loc": [42, 42], "level": 0, "parent": null, "vector": [1, 0, 0.1163, 0.0028, 0, 0.66, 0.0588, 182, 0, 6, 0, 0, 182, 0, 0], "semantic": {"name": "ctypes", "arg_names": [], "import_names": ["c_char_p", "c_float", "c_int", "Structure", "CDLL", "POINTER"], "rhs_call_name": "", "annotation": ""}, "snippet": "from ctypes import c_char_p, c_float, c_int, Structure, CDLL, POINTER"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:ImportFrom_L43_C0", "label": "from ctypes.util import find_library", "type": "import", "loc": [43, 43], "level": 0, "parent": null, "vector": [1, 0, 0.1191, 0.0028, 0, 0.66, 0.0882, 426, 0, 1, 0, 0, 426, 0, 0], "semantic": {"name": "ctypes.util", "arg_names": [], "import_names": ["find_library"], "rhs_call_name": "", "annotation": ""}, "snippet": "from ctypes.util import find_library"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:ImportFrom_L44_C0", "label": "from django.conf import settings", "type": "import", "loc": [44, 44], "level": 0, "parent": null, "vector": [1, 0, 0.1219, 0.0028, 0, 0.66, 0.1176, 128, 0, 1, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L45_C0", "label": "if", "type": "if", "loc": [45, 45], "level": 0, "parent": null, "vector": [4, 0, 0.1247, 0.0028, 0, 0.66, 0.1471, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if not settings.configured: settings.configure()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L45_C28", "label": "configure()", "type": "expression", "loc": [45, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L45_C0", "vector": [8, 1, 0.1247, 0.0028, 1, 0.18, 0.0, 765, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "configure", "arg_names": [], "import_names": [], "rhs_call_name": "configure", "annotation": ""}, "snippet": "if not settings.configured: settings.configure()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L48_C0", "label": "GEOIP_SETTINGS = dict()", "type": "assigned_variable", "loc": [48, 50], "level": 0, "parent": null, "vector": [14, 0, 0.1357, 0.0083, 0, 0.66, 0.1765, 573, 3, 1, 0, 0, 827, 10, 3], "semantic": {"name": "GEOIP_SETTINGS", "arg_names": [], "import_names": [], "rhs_call_name": "dict", "annotation": ""}, "snippet": "GEOIP_SETTINGS = dict((key, getattr(settings, key))\n for key in ('GEOIP_PATH', 'GEOIP_LIBRARY_PATH', 'GEOIP_COUNTRY', 'GEOIP_CITY')\n if hasattr(settings, key))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L51_C0", "label": "lib_path = get()", "type": "assigned_variable", "loc": [51, 51], "level": 0, "parent": null, "vector": [14, 0, 0.1413, 0.0028, 0, 0.66, 0.2059, 563, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "lib_path", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": "lib_path = GEOIP_SETTINGS.get('GEOIP_LIBRARY_PATH', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L54_C0", "label": "GeoIPException", "type": "class", "loc": [54, 54], "level": 0, "parent": null, "vector": [3, 0, 0.1496, 0.0028, 0, 0.66, 0.2353, 863, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "GeoIPException", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GeoIPException(Exception): pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L58_C0", "label": "if", "type": "if", "loc": [58, 62], "level": 0, "parent": null, "vector": [4, 0, 0.1662, 0.0139, 0, 0.66, 0.2647, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if lib_path:\n lib_name = None\nelse:\n # TODO: Is this really the library name for Windows?\n lib_name = 'GeoIP'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L59_C4", "label": "lib_name =", "type": "assigned_variable", "loc": [59, 59], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L58_C0", "vector": [14, 1, 0.1634, 0.0028, 1, 0.84, 0.0, 613, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "lib_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lib_name = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L62_C4", "label": "lib_name =", "type": "assigned_variable", "loc": [62, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L58_C0", "vector": [14, 1, 0.1717, 0.0028, 1, 0.84, 1.0, 613, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "lib_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lib_name = 'GeoIP'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L65_C0", "label": "if", "type": "if", "loc": [65, 65], "level": 0, "parent": null, "vector": [4, 0, 0.1801, 0.0028, 0, 0.66, 0.2941, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if lib_name: lib_path = find_library(lib_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L65_C13", "label": "lib_path = find_library()", "type": "assigned_variable", "loc": [65, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L65_C0", "vector": [14, 1, 0.1801, 0.0028, 1, 0.01, 0.0, 563, 3, 1, 0, 0, 80, 10, 1], "semantic": {"name": "lib_path", "arg_names": [], "import_names": [], "rhs_call_name": "find_library", "annotation": ""}, "snippet": "if lib_name: lib_path = find_library(lib_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L66_C0", "label": "if", "type": "if", "loc": [66, 67], "level": 0, "parent": null, "vector": [4, 0, 0.1842, 0.0055, 0, 0.66, 0.3235, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if lib_path is None: raise GeoIPException('Could not find the GeoIP library (tried \"%s\"). '\n 'Try setting GEOIP_LIBRARY_PATH in your settings.' % lib_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L68_C0", "label": "lgeoip = CDLL()", "type": "assigned_variable", "loc": [68, 68], "level": 0, "parent": null, "vector": [14, 0, 0.1884, 0.0028, 0, 0.66, 0.3529, 505, 3, 1, 0, 0, 453, 10, 1], "semantic": {"name": "lgeoip", "arg_names": [], "import_names": [], "rhs_call_name": "CDLL", "annotation": ""}, "snippet": "lgeoip = CDLL(lib_path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L72_C0", "label": "ipregex = compile()", "type": "assigned_variable", "loc": [72, 72], "level": 0, "parent": null, "vector": [14, 0, 0.1994, 0.0028, 0, 0.66, 0.3824, 563, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "ipregex", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": "ipregex = re.compile(r'^(?P<w>\\d\\d?\\d?)\\.(?P<x>\\d\\d?\\d?)\\.(?P<y>\\d\\d?\\d?)\\.(?P<z>\\d\\d?\\d?)$')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L73_C0", "label": "free_regex = compile()", "type": "assigned_variable", "loc": [73, 73], "level": 0, "parent": null, "vector": [14, 0, 0.2022, 0.0028, 0, 0.66, 0.4118, 587, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "free_regex", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": "free_regex = re.compile(r'^GEO-\\d{3}FREE')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L74_C0", "label": "lite_regex = compile()", "type": "assigned_variable", "loc": [74, 74], "level": 0, "parent": null, "vector": [14, 0, 0.205, 0.0028, 0, 0.66, 0.4412, 439, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "lite_regex", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": "lite_regex = re.compile(r'^GEO-\\d{3}LITE')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L77_C0", "label": "GeoIPRecord", "type": "class", "loc": [77, 97], "level": 0, "parent": null, "vector": [3, 0, 0.241, 0.0582, 0, 0.66, 0.4706, 650, 0, 0, 0, 0, 183, 0, 0], "semantic": {"name": "GeoIPRecord", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GeoIPRecord(Structure):\n _fields_ = [('country_code', c_char_p),\n ('country_code3', c_char_p),\n ('country_name', c_char_p),\n ('region', c_char_p),\n ('city', c_char_p),\n ('postal_code', c_char_p),\n ('latitude', c_float),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L78_C4", "label": "_fields_ =", "type": "assigned_variable", "loc": [78, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L77_C0", "vector": [14, 1, 0.2424, 0.0554, 1, 0.67, 0.0, 283, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "_fields_", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " _fields_ = [('country_code', c_char_p),\n ('country_code3', c_char_p),\n ('country_name', c_char_p),\n ('region', c_char_p),\n ('city', c_char_p),\n ('postal_code', c_char_p),\n ('latitude', c_float),\n ('longitude', c_float),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L98_C0", "label": "GeoIPTag", "type": "class", "loc": [98, 98], "level": 0, "parent": null, "vector": [3, 0, 0.2715, 0.0028, 0, 0.66, 0.5, 251, 0, 0, 0, 0, 183, 0, 0], "semantic": {"name": "GeoIPTag", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GeoIPTag(Structure): pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L101_C0", "label": "RECTYPE = POINTER()", "type": "assigned_variable", "loc": [101, 101], "level": 0, "parent": null, "vector": [14, 0, 0.2798, 0.0028, 0, 0.66, 0.5294, 204, 3, 1, 0, 0, 785, 10, 1], "semantic": {"name": "RECTYPE", "arg_names": [], "import_names": [], "rhs_call_name": "POINTER", "annotation": ""}, "snippet": "RECTYPE = POINTER(GeoIPRecord)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L102_C0", "label": "DBTYPE = POINTER()", "type": "assigned_variable", "loc": [102, 102], "level": 0, "parent": null, "vector": [14, 0, 0.2825, 0.0028, 0, 0.66, 0.5588, 159, 3, 1, 0, 0, 785, 10, 1], "semantic": {"name": "DBTYPE", "arg_names": [], "import_names": [], "rhs_call_name": "POINTER", "annotation": ""}, "snippet": "DBTYPE = POINTER(GeoIPTag)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L105_C0", "label": "record_output", "type": "function", "loc": [105, 107], "level": 0, "parent": null, "vector": [2, 0, 0.2936, 0.0083, 0, 0.66, 0.5882, 597, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "record_output", "arg_names": ["func"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def record_output(func):\n func.restype = RECTYPE\n return func"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L106_C4", "label": "func.restype =", "type": "assigned_variable", "loc": [106, 106], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L105_C0", "vector": [14, 1, 0.2936, 0.0028, 1, 0.52, 0.0, 634, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "func.restype", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " func.restype = RECTYPE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L107_C4", "label": "return", "type": "return", "loc": [107, 107], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L105_C0", "vector": [13, 1, 0.2964, 0.0028, 1, 0.52, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return func"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L108_C0", "label": "rec_by_addr = record_output()", "type": "assigned_variable", "loc": [108, 108], "level": 0, "parent": null, "vector": [14, 0, 0.2992, 0.0028, 0, 0.66, 0.6176, 919, 3, 1, 0, 0, 597, 10, 1], "semantic": {"name": "rec_by_addr", "arg_names": [], "import_names": [], "rhs_call_name": "record_output", "annotation": ""}, "snippet": "rec_by_addr = record_output(lgeoip.GeoIP_record_by_addr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L109_C0", "label": "rec_by_name = record_output()", "type": "assigned_variable", "loc": [109, 109], "level": 0, "parent": null, "vector": [14, 0, 0.3019, 0.0028, 0, 0.66, 0.6471, 200, 3, 1, 0, 0, 597, 10, 1], "semantic": {"name": "rec_by_name", "arg_names": [], "import_names": [], "rhs_call_name": "record_output", "annotation": ""}, "snippet": "rec_by_name = record_output(lgeoip.GeoIP_record_by_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L112_C0", "label": "geoip_open =", "type": "assigned_variable", "loc": [112, 112], "level": 0, "parent": null, "vector": [14, 0, 0.3102, 0.0028, 0, 0.66, 0.6765, 995, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "geoip_open", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "geoip_open = lgeoip.GeoIP_open"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L113_C0", "label": "geoip_open.restype =", "type": "assigned_variable", "loc": [113, 113], "level": 0, "parent": null, "vector": [14, 0, 0.313, 0.0028, 0, 0.66, 0.7059, 134, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "geoip_open.restype", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "geoip_open.restype = DBTYPE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L114_C0", "label": "geoip_close =", "type": "assigned_variable", "loc": [114, 114], "level": 0, "parent": null, "vector": [14, 0, 0.3158, 0.0028, 0, 0.66, 0.7353, 434, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "geoip_close", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "geoip_close = lgeoip.GeoIP_delete"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L115_C0", "label": "geoip_close.argtypes =", "type": "assigned_variable", "loc": [115, 115], "level": 0, "parent": null, "vector": [14, 0, 0.3186, 0.0028, 0, 0.66, 0.7647, 562, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "geoip_close.argtypes", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "geoip_close.argtypes = [DBTYPE]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L116_C0", "label": "geoip_close.restype =", "type": "assigned_variable", "loc": [116, 116], "level": 0, "parent": null, "vector": [14, 0, 0.3213, 0.0028, 0, 0.66, 0.7941, 972, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "geoip_close.restype", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "geoip_close.restype = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L119_C0", "label": "string_output", "type": "function", "loc": [119, 121], "level": 0, "parent": null, "vector": [2, 0, 0.3324, 0.0083, 0, 0.66, 0.8235, 345, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "string_output", "arg_names": ["func"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def string_output(func):\n func.restype = c_char_p\n return func"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L120_C4", "label": "func.restype =", "type": "assigned_variable", "loc": [120, 120], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L119_C0", "vector": [14, 1, 0.3324, 0.0028, 1, 0.13, 0.0, 634, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "func.restype", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " func.restype = c_char_p"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L121_C4", "label": "return", "type": "return", "loc": [121, 121], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L119_C0", "vector": [13, 1, 0.3352, 0.0028, 1, 0.13, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return func"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L122_C0", "label": "geoip_dbinfo = string_output()", "type": "assigned_variable", "loc": [122, 122], "level": 0, "parent": null, "vector": [14, 0, 0.338, 0.0028, 0, 0.66, 0.8529, 629, 3, 1, 0, 0, 345, 10, 1], "semantic": {"name": "geoip_dbinfo", "arg_names": [], "import_names": [], "rhs_call_name": "string_output", "annotation": ""}, "snippet": "geoip_dbinfo = string_output(lgeoip.GeoIP_database_info)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L123_C0", "label": "cntry_code_by_addr = string_output()", "type": "assigned_variable", "loc": [123, 123], "level": 0, "parent": null, "vector": [14, 0, 0.3407, 0.0028, 0, 0.66, 0.8824, 180, 3, 1, 0, 0, 345, 10, 1], "semantic": {"name": "cntry_code_by_addr", "arg_names": [], "import_names": [], "rhs_call_name": "string_output", "annotation": ""}, "snippet": "cntry_code_by_addr = string_output(lgeoip.GeoIP_country_code_by_addr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L124_C0", "label": "cntry_code_by_name = string_output()", "type": "assigned_variable", "loc": [124, 124], "level": 0, "parent": null, "vector": [14, 0, 0.3435, 0.0028, 0, 0.66, 0.9118, 580, 3, 1, 0, 0, 345, 10, 1], "semantic": {"name": "cntry_code_by_name", "arg_names": [], "import_names": [], "rhs_call_name": "string_output", "annotation": ""}, "snippet": "cntry_code_by_name = string_output(lgeoip.GeoIP_country_code_by_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L125_C0", "label": "cntry_name_by_addr = string_output()", "type": "assigned_variable", "loc": [125, 125], "level": 0, "parent": null, "vector": [14, 0, 0.3463, 0.0028, 0, 0.66, 0.9412, 993, 3, 1, 0, 0, 345, 10, 1], "semantic": {"name": "cntry_name_by_addr", "arg_names": [], "import_names": [], "rhs_call_name": "string_output", "annotation": ""}, "snippet": "cntry_name_by_addr = string_output(lgeoip.GeoIP_country_name_by_addr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L126_C0", "label": "cntry_name_by_name = string_output()", "type": "assigned_variable", "loc": [126, 126], "level": 0, "parent": null, "vector": [14, 0, 0.349, 0.0028, 0, 0.66, 0.9706, 909, 3, 1, 0, 0, 345, 10, 1], "semantic": {"name": "cntry_name_by_name", "arg_names": [], "import_names": [], "rhs_call_name": "string_output", "annotation": ""}, "snippet": "cntry_name_by_name = string_output(lgeoip.GeoIP_country_name_by_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "label": "GeoIP", "type": "class", "loc": [129, 361], "level": 0, "parent": null, "vector": [3, 0, 0.6787, 0.6454, 0, 0.66, 1.0, 388, 0, 16, 0, 0, 186, 0, 66], "semantic": {"name": "GeoIP", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GeoIP(object):\n # The flags for GeoIP memory caching.\n # GEOIP_STANDARD - read database from filesystem, uses least memory.\n #\n # GEOIP_MEMORY_CACHE - load database into memory, faster performance\n # but uses more memory\n #\n # GEOIP_CHECK_CACHE - check for updated database. If database has been updated,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L146_C4", "label": "GEOIP_STANDARD =", "type": "assigned_variable", "loc": [146, 146], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.4044, 0.0028, 1, 0.73, 0.0, 299, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "GEOIP_STANDARD", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " GEOIP_STANDARD = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L147_C4", "label": "GEOIP_MEMORY_CACHE =", "type": "assigned_variable", "loc": [147, 147], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.4072, 0.0028, 1, 0.73, 0.0286, 774, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "GEOIP_MEMORY_CACHE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " GEOIP_MEMORY_CACHE = 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L148_C4", "label": "GEOIP_CHECK_CACHE =", "type": "assigned_variable", "loc": [148, 148], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.41, 0.0028, 1, 0.73, 0.0571, 608, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "GEOIP_CHECK_CACHE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " GEOIP_CHECK_CACHE = 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L149_C4", "label": "GEOIP_INDEX_CACHE =", "type": "assigned_variable", "loc": [149, 149], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.4127, 0.0028, 1, 0.73, 0.0857, 566, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "GEOIP_INDEX_CACHE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " GEOIP_INDEX_CACHE = 4"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L150_C4", "label": "cache_options = dict()", "type": "assigned_variable", "loc": [150, 150], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.4155, 0.0028, 1, 0.73, 0.1143, 832, 3, 1, 0, 0, 827, 10, 1], "semantic": {"name": "cache_options", "arg_names": [], "import_names": [], "rhs_call_name": "dict", "annotation": ""}, "snippet": " cache_options = dict((opt, None) for opt in (0, 1, 2, 4))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L151_C4", "label": "_city_file =", "type": "assigned_variable", "loc": [151, 151], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.4183, 0.0028, 1, 0.73, 0.1429, 536, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "_city_file", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " _city_file = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L152_C4", "label": "_country_file =", "type": "assigned_variable", "loc": [152, 152], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.4211, 0.0028, 1, 0.73, 0.1714, 990, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "_country_file", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " _country_file = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L155_C4", "label": "_city =", "type": "assigned_variable", "loc": [155, 155], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.4294, 0.0028, 1, 0.73, 0.2, 688, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "_city", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " _city = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L156_C4", "label": "_country =", "type": "assigned_variable", "loc": [156, 156], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.4321, 0.0028, 1, 0.73, 0.2286, 673, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "_country", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " _country = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L158_C4", "label": "__init__", "type": "function", "loc": [158, 225], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.5305, 0.1884, 1, 0.73, 0.2571, 555, 0, 5, 0, 0, 0, 0, 22], "semantic": {"name": "__init__", "arg_names": ["self", "path", "cache", "country", "city"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, path=None, cache=0, country=None, city=None):\n \"\"\"\n Initializes the GeoIP object, no parameters are required to use default\n settings. Keyword arguments may be passed in to customize the locations\n of the GeoIP data sets.\n\n * path: Base directory to where GeoIP data is located or the full path\n to where the city or country data files (*.dat) are located."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L159_C8", "label": "expression", "type": "expression", "loc": [159, 181], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L158_C4", "vector": [8, 2, 0.4709, 0.0637, 2, 0.86, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Initializes the GeoIP object, no parameters are required to use default\n settings. Keyword arguments may be passed in to customize the locations\n of the GeoIP data sets.\n\n * path: Base directory to where GeoIP data is located or the full path\n to where the city or country data files (*.dat) are located.\n Assumes that both the city and country data sets are located in"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L183_C8", "label": "if", "type": "if", "loc": [183, 186], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L158_C4", "vector": [4, 2, 0.5111, 0.0111, 2, 0.86, 0.25, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cache in self.cache_options:\n self._cache = self.cache_options[cache]\n else:\n raise GeoIPException('Invalid caching option: %s' % cache)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L184_C12", "label": "self._cache =", "type": "assigned_variable", "loc": [184, 184], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L183_C8", "vector": [14, 3, 0.5097, 0.0028, 3, 0.0, 0.0, 723, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._cache", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._cache = self.cache_options[cache]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L189_C8", "label": "if", "type": "if", "loc": [189, 191], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L158_C4", "vector": [4, 2, 0.5263, 0.0083, 2, 0.86, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not path:\n path = GEOIP_SETTINGS.get('GEOIP_PATH', None)\n if not path: raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L190_C12", "label": "path = get()", "type": "assigned_variable", "loc": [190, 190], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L189_C8", "vector": [14, 3, 0.5263, 0.0028, 3, 0.71, 0.0, 358, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "path", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " path = GEOIP_SETTINGS.get('GEOIP_PATH', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L191_C12", "label": "if", "type": "if", "loc": [191, 191], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L189_C8", "vector": [4, 3, 0.5291, 0.0028, 3, 0.71, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not path: raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L192_C8", "label": "if", "type": "if", "loc": [192, 193], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L158_C4", "vector": [4, 2, 0.5332, 0.0055, 2, 0.86, 0.75, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(path, basestring):\n raise TypeError('Invalid path type: %s' % type(path).__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L195_C8", "label": "if", "type": "if", "loc": [195, 225], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L158_C4", "vector": [4, 2, 0.5817, 0.0859, 2, 0.86, 1.0, 0, 3, 0, 0, 0, 0, 0, 16], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if os.path.isdir(path):\n # Constructing the GeoIP database filenames using the settings\n # dictionary. If the database files for the GeoLite country\n # and/or city datasets exist, then try and open them.\n country_db = os.path.join(path, country or GEOIP_SETTINGS.get('GEOIP_COUNTRY', 'GeoIP.dat'))\n if os.path.isfile(country_db):\n self._country = geoip_open(country_db, cache)\n self._country_file = country_db"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L199_C12", "label": "country_db = join()", "type": "assigned_variable", "loc": [199, 199], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L195_C8", "vector": [14, 3, 0.5512, 0.0028, 3, 0.86, 0.0, 665, 3, 2, 0, 0, 933, 10, 2], "semantic": {"name": "country_db", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " country_db = os.path.join(path, country or GEOIP_SETTINGS.get('GEOIP_COUNTRY', 'GeoIP.dat'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L200_C12", "label": "if", "type": "if", "loc": [200, 202], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L195_C8", "vector": [4, 3, 0.5568, 0.0083, 3, 0.86, 0.25, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if os.path.isfile(country_db):\n self._country = geoip_open(country_db, cache)\n self._country_file = country_db"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L201_C16", "label": "self._country = geoip_open()", "type": "assigned_variable", "loc": [201, 201], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L200_C12", "vector": [14, 4, 0.5568, 0.0028, 4, 0.01, 0.0, 675, 3, 2, 0, 0, 995, 10, 1], "semantic": {"name": "self._country", "arg_names": [], "import_names": [], "rhs_call_name": "geoip_open", "annotation": ""}, "snippet": " self._country = geoip_open(country_db, cache)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L202_C16", "label": "self._country_file =", "type": "assigned_variable", "loc": [202, 202], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L200_C12", "vector": [14, 4, 0.5596, 0.0028, 4, 0.01, 1.0, 456, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._country_file", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._country_file = country_db"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L204_C12", "label": "city_db = join()", "type": "assigned_variable", "loc": [204, 204], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L195_C8", "vector": [14, 3, 0.5651, 0.0028, 3, 0.86, 0.5, 140, 3, 2, 0, 0, 933, 10, 2], "semantic": {"name": "city_db", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " city_db = os.path.join(path, city or GEOIP_SETTINGS.get('GEOIP_CITY', 'GeoLiteCity.dat'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L205_C12", "label": "if", "type": "if", "loc": [205, 207], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L195_C8", "vector": [4, 3, 0.5706, 0.0083, 3, 0.86, 0.75, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if os.path.isfile(city_db):\n self._city = geoip_open(city_db, cache)\n self._city_file = city_db"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L206_C16", "label": "self._city = geoip_open()", "type": "assigned_variable", "loc": [206, 206], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L205_C12", "vector": [14, 4, 0.5706, 0.0028, 4, 0.7, 0.0, 606, 3, 2, 0, 0, 995, 10, 1], "semantic": {"name": "self._city", "arg_names": [], "import_names": [], "rhs_call_name": "geoip_open", "annotation": ""}, "snippet": " self._city = geoip_open(city_db, cache)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L207_C16", "label": "self._city_file =", "type": "assigned_variable", "loc": [207, 207], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L205_C12", "vector": [14, 4, 0.5734, 0.0028, 4, 0.7, 1.0, 292, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._city_file", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._city_file = city_db"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L208_C8", "label": "if", "type": "if", "loc": [208, 225], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L195_C8", "vector": [4, 3, 0.5997, 0.0499, 3, 0.86, 1.0, 0, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif os.path.isfile(path):\n # Otherwise, some detective work will be needed to figure\n # out whether the given database path is for the GeoIP country\n # or city databases.\n ptr = geoip_open(path, cache)\n info = geoip_dbinfo(ptr)\n if lite_regex.match(info):\n # GeoLite City database detected."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L212_C12", "label": "ptr = geoip_open()", "type": "assigned_variable", "loc": [212, 212], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L208_C8", "vector": [14, 4, 0.5873, 0.0028, 4, 0.41, 0.0, 676, 3, 2, 0, 0, 995, 10, 1], "semantic": {"name": "ptr", "arg_names": [], "import_names": [], "rhs_call_name": "geoip_open", "annotation": ""}, "snippet": " ptr = geoip_open(path, cache)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L213_C12", "label": "info = geoip_dbinfo()", "type": "assigned_variable", "loc": [213, 213], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L208_C8", "vector": [14, 4, 0.59, 0.0028, 4, 0.41, 0.5, 730, 3, 1, 0, 0, 629, 10, 1], "semantic": {"name": "info", "arg_names": [], "import_names": [], "rhs_call_name": "geoip_dbinfo", "annotation": ""}, "snippet": " info = geoip_dbinfo(ptr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L214_C12", "label": "if", "type": "if", "loc": [214, 223], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L208_C8", "vector": [4, 4, 0.6053, 0.0277, 4, 0.41, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if lite_regex.match(info):\n # GeoLite City database detected.\n self._city = ptr\n self._city_file = path\n elif free_regex.match(info):\n # GeoIP Country database detected.\n self._country = ptr\n self._country_file = path"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L216_C16", "label": "self._city =", "type": "assigned_variable", "loc": [216, 216], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L214_C12", "vector": [14, 5, 0.5983, 0.0028, 5, 0.64, 0.0, 606, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._city", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._city = ptr"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L217_C16", "label": "self._city_file =", "type": "assigned_variable", "loc": [217, 217], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L214_C12", "vector": [14, 5, 0.6011, 0.0028, 5, 0.64, 0.5, 292, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._city_file", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._city_file = path"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L218_C12", "label": "if", "type": "if", "loc": [218, 223], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L214_C12", "vector": [4, 5, 0.6108, 0.0166, 5, 0.64, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif free_regex.match(info):\n # GeoIP Country database detected.\n self._country = ptr\n self._country_file = path\n else:\n raise GeoIPException('Unable to recognize database edition: %s' % info)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L220_C16", "label": "self._country =", "type": "assigned_variable", "loc": [220, 220], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L218_C12", "vector": [14, 6, 0.6094, 0.0028, 6, 0.32, 0.0, 675, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._country", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._country = ptr"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L221_C16", "label": "self._country_file =", "type": "assigned_variable", "loc": [221, 221], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L218_C12", "vector": [14, 6, 0.6122, 0.0028, 6, 0.32, 1.0, 456, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._country_file", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._country_file = path"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L227_C4", "label": "__del__", "type": "function", "loc": [227, 230], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.633, 0.0111, 1, 0.73, 0.2857, 258, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "__del__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __del__(self):\n # Cleaning any GeoIP file handles lying around.\n if self._country: geoip_close(self._country)\n if self._city: geoip_close(self._city)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L229_C8", "label": "if", "type": "if", "loc": [229, 229], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L227_C4", "vector": [4, 2, 0.6343, 0.0028, 2, 0.2, 0.0, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._country: geoip_close(self._country)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L229_C26", "label": "geoip_close()", "type": "expression", "loc": [229, 229], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L229_C8", "vector": [8, 3, 0.6343, 0.0028, 3, 0.44, 0.0, 434, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "geoip_close", "arg_names": [], "import_names": [], "rhs_call_name": "geoip_close", "annotation": ""}, "snippet": " if self._country: geoip_close(self._country)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L230_C8", "label": "if", "type": "if", "loc": [230, 230], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L227_C4", "vector": [4, 2, 0.6371, 0.0028, 2, 0.2, 1.0, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._city: geoip_close(self._city)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L230_C23", "label": "geoip_close()", "type": "expression", "loc": [230, 230], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L230_C8", "vector": [8, 3, 0.6371, 0.0028, 3, 0.99, 0.0, 434, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "geoip_close", "arg_names": [], "import_names": [], "rhs_call_name": "geoip_close", "annotation": ""}, "snippet": " if self._city: geoip_close(self._city)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L232_C4", "label": "_check_query", "type": "function", "loc": [232, 244], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.6593, 0.036, 1, 0.73, 0.3143, 712, 0, 5, 0, 0, 0, 0, 6], "semantic": {"name": "_check_query", "arg_names": ["self", "query", "country", "city", "city_or_country"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _check_query(self, query, country=False, city=False, city_or_country=False):\n \"Helper routine for checking the query and database availability.\"\n # Making sure a string was passed in for the query.\n if not isinstance(query, basestring):\n raise TypeError('GeoIP query must be a string, not type %s' % type(query).__name__)\n\n # Extra checks for the existence of country and city databases.\n if city_or_country and not (self._country or self._city):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L233_C8", "label": "expression", "type": "expression", "loc": [233, 233], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L232_C4", "vector": [8, 2, 0.6454, 0.0028, 2, 0.21, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Helper routine for checking the query and database availability.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L235_C8", "label": "if", "type": "if", "loc": [235, 236], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L232_C4", "vector": [4, 2, 0.6524, 0.0055, 2, 0.21, 0.5, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(query, basestring):\n raise TypeError('GeoIP query must be a string, not type %s' % type(query).__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L239_C8", "label": "if", "type": "if", "loc": [239, 244], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L232_C4", "vector": [4, 2, 0.669, 0.0166, 2, 0.21, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if city_or_country and not (self._country or self._city):\n raise GeoIPException('Invalid GeoIP country and city data files.')\n elif country and not self._country:\n raise GeoIPException('Invalid GeoIP country data file: %s' % self._country_file)\n elif city and not self._city:\n raise GeoIPException('Invalid GeoIP city data file: %s' % self._city_file)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L241_C8", "label": "if", "type": "if", "loc": [241, 244], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L239_C8", "vector": [4, 3, 0.6717, 0.0111, 3, 0.99, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif country and not self._country:\n raise GeoIPException('Invalid GeoIP country data file: %s' % self._country_file)\n elif city and not self._city:\n raise GeoIPException('Invalid GeoIP city data file: %s' % self._city_file)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L243_C8", "label": "if", "type": "if", "loc": [243, 244], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L241_C8", "vector": [4, 4, 0.6745, 0.0055, 4, 0.34, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif city and not self._city:\n raise GeoIPException('Invalid GeoIP city data file: %s' % self._city_file)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L246_C4", "label": "city", "type": "function", "loc": [246, 266], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.7091, 0.0582, 1, 0.73, 0.3429, 825, 0, 2, 1, 0, 0, 0, 9], "semantic": {"name": "city", "arg_names": ["self", "query"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def city(self, query):\n \"\"\"\n Returns a dictionary of city information for the given IP address or\n Fully Qualified Domain Name (FQDN). Some information in the dictionary\n may be undefined (None).\n \"\"\"\n self._check_query(query, city=True)\n if ipregex.match(query):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L247_C8", "label": "expression", "type": "expression", "loc": [247, 251], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L246_C4", "vector": [8, 2, 0.6898, 0.0139, 2, 0.8, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a dictionary of city information for the given IP address or\n Fully Qualified Domain Name (FQDN). Some information in the dictionary\n may be undefined (None).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L252_C8", "label": "_check_query()", "type": "expression", "loc": [252, 252], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L246_C4", "vector": [8, 2, 0.6981, 0.0028, 2, 0.8, 0.3333, 712, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "_check_query", "arg_names": [], "import_names": [], "rhs_call_name": "_check_query", "annotation": ""}, "snippet": " self._check_query(query, city=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L253_C8", "label": "if", "type": "if", "loc": [253, 258], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L246_C4", "vector": [4, 2, 0.7078, 0.0166, 2, 0.8, 0.6667, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ipregex.match(query):\n # If an IP address was passed in\n ptr = rec_by_addr(self._city, c_char_p(query))\n else:\n # If a FQDN was passed in.\n ptr = rec_by_name(self._city, c_char_p(query))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L255_C12", "label": "ptr = rec_by_addr()", "type": "assigned_variable", "loc": [255, 255], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L253_C8", "vector": [14, 3, 0.7064, 0.0028, 3, 0.05, 0.0, 676, 3, 2, 0, 0, 919, 10, 2], "semantic": {"name": "ptr", "arg_names": [], "import_names": [], "rhs_call_name": "rec_by_addr", "annotation": ""}, "snippet": " ptr = rec_by_addr(self._city, c_char_p(query))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L258_C12", "label": "ptr = rec_by_name()", "type": "assigned_variable", "loc": [258, 258], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L253_C8", "vector": [14, 3, 0.7147, 0.0028, 3, 0.05, 1.0, 676, 3, 2, 0, 0, 200, 10, 2], "semantic": {"name": "ptr", "arg_names": [], "import_names": [], "rhs_call_name": "rec_by_name", "annotation": ""}, "snippet": " ptr = rec_by_name(self._city, c_char_p(query))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L262_C8", "label": "if", "type": "if", "loc": [262, 266], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L246_C4", "vector": [4, 2, 0.7313, 0.0139, 2, 0.8, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if bool(ptr):\n record = ptr.contents\n return dict((tup[0], getattr(record, tup[0])) for tup in record._fields_)\n else:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L263_C12", "label": "record =", "type": "assigned_variable", "loc": [263, 263], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L262_C8", "vector": [14, 3, 0.7285, 0.0028, 3, 0.7, 0.0, 667, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "record", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " record = ptr.contents"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L264_C12", "label": "return", "type": "return", "loc": [264, 264], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L262_C8", "vector": [13, 3, 0.7313, 0.0028, 3, 0.7, 0.5, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return dict((tup[0], getattr(record, tup[0])) for tup in record._fields_)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L266_C12", "label": "return", "type": "return", "loc": [266, 266], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L262_C8", "vector": [13, 3, 0.7368, 0.0028, 3, 0.7, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L268_C4", "label": "country_code", "type": "function", "loc": [268, 275], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.7521, 0.0222, 1, 0.73, 0.3714, 781, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "country_code", "arg_names": ["self", "query"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def country_code(self, query):\n \"Returns the country code for the given IP Address or FQDN.\"\n self._check_query(query, city_or_country=True)\n if self._country:\n if ipregex.match(query): return cntry_code_by_addr(self._country, query)\n else: return cntry_code_by_name(self._country, query)\n else:\n return self.city(query)['country_code']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L269_C8", "label": "expression", "type": "expression", "loc": [269, 269], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L268_C4", "vector": [8, 2, 0.7452, 0.0028, 2, 0.38, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the country code for the given IP Address or FQDN.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L270_C8", "label": "_check_query()", "type": "expression", "loc": [270, 270], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L268_C4", "vector": [8, 2, 0.7479, 0.0028, 2, 0.38, 0.5, 712, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "_check_query", "arg_names": [], "import_names": [], "rhs_call_name": "_check_query", "annotation": ""}, "snippet": " self._check_query(query, city_or_country=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L271_C8", "label": "if", "type": "if", "loc": [271, 275], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L268_C4", "vector": [4, 2, 0.7562, 0.0139, 2, 0.38, 1.0, 0, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._country:\n if ipregex.match(query): return cntry_code_by_addr(self._country, query)\n else: return cntry_code_by_name(self._country, query)\n else:\n return self.city(query)['country_code']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L272_C12", "label": "if", "type": "if", "loc": [272, 273], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L271_C8", "vector": [4, 3, 0.7548, 0.0055, 3, 0.13, 0.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ipregex.match(query): return cntry_code_by_addr(self._country, query)\n else: return cntry_code_by_name(self._country, query)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L272_C37", "label": "return", "type": "return", "loc": [272, 272], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L272_C12", "vector": [13, 4, 0.7535, 0.0028, 4, 0.02, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ipregex.match(query): return cntry_code_by_addr(self._country, query)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L273_C18", "label": "return", "type": "return", "loc": [273, 273], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L272_C12", "vector": [13, 4, 0.7562, 0.0028, 4, 0.02, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " else: return cntry_code_by_name(self._country, query)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L275_C12", "label": "return", "type": "return", "loc": [275, 275], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L271_C8", "vector": [13, 3, 0.7618, 0.0028, 3, 0.13, 1.0, 0, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.city(query)['country_code']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L277_C4", "label": "country_name", "type": "function", "loc": [277, 284], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.777, 0.0222, 1, 0.73, 0.4, 7, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "country_name", "arg_names": ["self", "query"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def country_name(self, query):\n \"Returns the country name for the given IP Address or FQDN.\"\n self._check_query(query, city_or_country=True)\n if self._country:\n if ipregex.match(query): return cntry_name_by_addr(self._country, query)\n else: return cntry_name_by_name(self._country, query)\n else:\n return self.city(query)['country_name']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L278_C8", "label": "expression", "type": "expression", "loc": [278, 278], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L277_C4", "vector": [8, 2, 0.7701, 0.0028, 2, 0.79, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the country name for the given IP Address or FQDN.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L279_C8", "label": "_check_query()", "type": "expression", "loc": [279, 279], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L277_C4", "vector": [8, 2, 0.7729, 0.0028, 2, 0.79, 0.5, 712, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "_check_query", "arg_names": [], "import_names": [], "rhs_call_name": "_check_query", "annotation": ""}, "snippet": " self._check_query(query, city_or_country=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L280_C8", "label": "if", "type": "if", "loc": [280, 284], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L277_C4", "vector": [4, 2, 0.7812, 0.0139, 2, 0.79, 1.0, 0, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._country:\n if ipregex.match(query): return cntry_name_by_addr(self._country, query)\n else: return cntry_name_by_name(self._country, query)\n else:\n return self.city(query)['country_name']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L281_C12", "label": "if", "type": "if", "loc": [281, 282], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L280_C8", "vector": [4, 3, 0.7798, 0.0055, 3, 0.14, 0.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ipregex.match(query): return cntry_name_by_addr(self._country, query)\n else: return cntry_name_by_name(self._country, query)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L281_C37", "label": "return", "type": "return", "loc": [281, 281], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L281_C12", "vector": [13, 4, 0.7784, 0.0028, 4, 0.56, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ipregex.match(query): return cntry_name_by_addr(self._country, query)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L282_C18", "label": "return", "type": "return", "loc": [282, 282], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L281_C12", "vector": [13, 4, 0.7812, 0.0028, 4, 0.56, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " else: return cntry_name_by_name(self._country, query)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L284_C12", "label": "return", "type": "return", "loc": [284, 284], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L280_C8", "vector": [13, 3, 0.7867, 0.0028, 3, 0.14, 1.0, 0, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.city(query)['country_name']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L286_C4", "label": "country", "type": "function", "loc": [286, 295], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.8047, 0.0277, 1, 0.73, 0.4286, 261, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "country", "arg_names": ["self", "query"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def country(self, query):\n \"\"\"\n Returns a dictonary with with the country code and name when given an\n IP address or a Fully Qualified Domain Name (FQDN). For example, both\n '24.124.1.80' and 'djangoproject.com' are valid parameters.\n \"\"\"\n # Returning the country code and name\n return {'country_code' : self.country_code(query),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L287_C8", "label": "expression", "type": "expression", "loc": [287, 291], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L286_C4", "vector": [8, 2, 0.8006, 0.0139, 2, 0.76, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a dictonary with with the country code and name when given an\n IP address or a Fully Qualified Domain Name (FQDN). For example, both\n '24.124.1.80' and 'djangoproject.com' are valid parameters.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L293_C8", "label": "return", "type": "return", "loc": [293, 295], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L286_C4", "vector": [13, 2, 0.8144, 0.0083, 2, 0.76, 1.0, 0, 0, 0, 0, 0, 0, 6, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {'country_code' : self.country_code(query),\n 'country_name' : self.country_name(query),\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L298_C4", "label": "coords", "type": "function", "loc": [298, 301], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.8296, 0.0111, 1, 0.73, 0.4571, 216, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "coords", "arg_names": ["self", "query", "ordering"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def coords(self, query, ordering=('longitude', 'latitude')):\n cdict = self.city(query)\n if cdict is None: return None\n else: return tuple(cdict[o] for o in ordering)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L299_C8", "label": "cdict = city()", "type": "assigned_variable", "loc": [299, 299], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L298_C4", "vector": [14, 2, 0.8283, 0.0028, 2, 0.54, 0.0, 140, 3, 1, 0, 0, 825, 10, 1], "semantic": {"name": "cdict", "arg_names": [], "import_names": [], "rhs_call_name": "city", "annotation": ""}, "snippet": " cdict = self.city(query)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L300_C8", "label": "if", "type": "if", "loc": [300, 301], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L298_C4", "vector": [4, 2, 0.8324, 0.0055, 2, 0.54, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cdict is None: return None\n else: return tuple(cdict[o] for o in ordering)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L300_C26", "label": "return", "type": "return", "loc": [300, 300], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L300_C8", "vector": [13, 3, 0.831, 0.0028, 3, 0.75, 0.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cdict is None: return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L301_C14", "label": "return", "type": "return", "loc": [301, 301], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L300_C8", "vector": [13, 3, 0.8338, 0.0028, 3, 0.75, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " else: return tuple(cdict[o] for o in ordering)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L303_C4", "label": "lon_lat", "type": "function", "loc": [303, 305], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.8421, 0.0083, 1, 0.73, 0.4857, 970, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "lon_lat", "arg_names": ["self", "query"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def lon_lat(self, query):\n \"Returns a tuple of the (longitude, latitude) for the given query.\"\n return self.coords(query)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L304_C8", "label": "expression", "type": "expression", "loc": [304, 304], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L303_C4", "vector": [8, 2, 0.8421, 0.0028, 2, 0.07, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns a tuple of the (longitude, latitude) for the given query.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L305_C8", "label": "return", "type": "return", "loc": [305, 305], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L303_C4", "vector": [13, 2, 0.8449, 0.0028, 2, 0.07, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.coords(query)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L307_C4", "label": "lat_lon", "type": "function", "loc": [307, 309], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.8532, 0.0083, 1, 0.73, 0.5143, 990, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "lat_lon", "arg_names": ["self", "query"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def lat_lon(self, query):\n \"Returns a tuple of the (latitude, longitude) for the given query.\"\n return self.coords(query, ('latitude', 'longitude'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L308_C8", "label": "expression", "type": "expression", "loc": [308, 308], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L307_C4", "vector": [8, 2, 0.8532, 0.0028, 2, 0.88, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns a tuple of the (latitude, longitude) for the given query.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L309_C8", "label": "return", "type": "return", "loc": [309, 309], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L307_C4", "vector": [13, 2, 0.856, 0.0028, 2, 0.88, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.coords(query, ('latitude', 'longitude'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L311_C4", "label": "geos", "type": "function", "loc": [311, 318], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.8712, 0.0222, 1, 0.73, 0.5429, 437, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "geos", "arg_names": ["self", "query"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def geos(self, query):\n \"Returns a GEOS Point object for the given query.\"\n ll = self.lon_lat(query)\n if ll:\n from django.contrib.gis.geos import Point\n return Point(ll, srid=4326)\n else:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L312_C8", "label": "expression", "type": "expression", "loc": [312, 312], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L311_C4", "vector": [8, 2, 0.8643, 0.0028, 2, 0.9, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns a GEOS Point object for the given query.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L313_C8", "label": "ll = lon_lat()", "type": "assigned_variable", "loc": [313, 313], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L311_C4", "vector": [14, 2, 0.867, 0.0028, 2, 0.9, 0.5, 929, 3, 1, 0, 0, 970, 10, 1], "semantic": {"name": "ll", "arg_names": [], "import_names": [], "rhs_call_name": "lon_lat", "annotation": ""}, "snippet": " ll = self.lon_lat(query)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L314_C8", "label": "if", "type": "if", "loc": [314, 318], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L311_C4", "vector": [4, 2, 0.8753, 0.0139, 2, 0.9, 1.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ll:\n from django.contrib.gis.geos import Point\n return Point(ll, srid=4326)\n else:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:ImportFrom_L315_C12", "label": "from django.contrib.gis.geos import Point", "type": "import", "loc": [315, 315], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L314_C8", "vector": [1, 3, 0.8726, 0.0028, 3, 0.47, 0.0, 886, 0, 1, 0, 0, 886, 0, 0], "semantic": {"name": "django.contrib.gis.geos", "arg_names": [], "import_names": ["Point"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.gis.geos import Point"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L316_C12", "label": "return", "type": "return", "loc": [316, 316], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L314_C8", "vector": [13, 3, 0.8753, 0.0028, 3, 0.47, 0.5, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return Point(ll, srid=4326)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L318_C12", "label": "return", "type": "return", "loc": [318, 318], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L314_C8", "vector": [13, 3, 0.8809, 0.0028, 3, 0.47, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L321_C4", "label": "country_info", "type": "function", "loc": [321, 327], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.8975, 0.0194, 1, 0.73, 0.5714, 362, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "country_info", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def country_info(self):\n \"Returns information about the GeoIP country database.\"\n if self._country is None:\n ci = 'No GeoIP Country data in \"%s\"' % self._country_file\n else:\n ci = geoip_dbinfo(self._country)\n return ci"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L322_C8", "label": "expression", "type": "expression", "loc": [322, 322], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L321_C4", "vector": [8, 2, 0.892, 0.0028, 2, 0.9, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns information about the GeoIP country database.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L323_C8", "label": "if", "type": "if", "loc": [323, 326], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L321_C4", "vector": [4, 2, 0.8989, 0.0111, 2, 0.9, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._country is None:\n ci = 'No GeoIP Country data in \"%s\"' % self._country_file\n else:\n ci = geoip_dbinfo(self._country)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L324_C12", "label": "ci =", "type": "assigned_variable", "loc": [324, 324], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L323_C8", "vector": [14, 3, 0.8975, 0.0028, 3, 0.61, 0.0, 916, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "ci", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ci = 'No GeoIP Country data in \"%s\"' % self._country_file"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L326_C12", "label": "ci = geoip_dbinfo()", "type": "assigned_variable", "loc": [326, 326], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L323_C8", "vector": [14, 3, 0.903, 0.0028, 3, 0.61, 1.0, 916, 3, 1, 0, 0, 629, 10, 1], "semantic": {"name": "ci", "arg_names": [], "import_names": [], "rhs_call_name": "geoip_dbinfo", "annotation": ""}, "snippet": " ci = geoip_dbinfo(self._country)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L327_C8", "label": "return", "type": "return", "loc": [327, 327], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L321_C4", "vector": [13, 2, 0.9058, 0.0028, 2, 0.9, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ci"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L328_C4", "label": "country_info = property()", "type": "assigned_variable", "loc": [328, 328], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.9086, 0.0028, 1, 0.73, 0.6, 362, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "country_info", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " country_info = property(country_info)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L330_C4", "label": "city_info", "type": "function", "loc": [330, 336], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.9224, 0.0194, 1, 0.73, 0.6286, 174, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "city_info", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def city_info(self):\n \"Retuns information about the GeoIP city database.\"\n if self._city is None:\n ci = 'No GeoIP City data in \"%s\"' % self._city_file\n else:\n ci = geoip_dbinfo(self._city)\n return ci"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L331_C8", "label": "expression", "type": "expression", "loc": [331, 331], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L330_C4", "vector": [8, 2, 0.9169, 0.0028, 2, 0.45, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Retuns information about the GeoIP city database.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L332_C8", "label": "if", "type": "if", "loc": [332, 335], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L330_C4", "vector": [4, 2, 0.9238, 0.0111, 2, 0.45, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._city is None:\n ci = 'No GeoIP City data in \"%s\"' % self._city_file\n else:\n ci = geoip_dbinfo(self._city)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L333_C12", "label": "ci =", "type": "assigned_variable", "loc": [333, 333], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L332_C8", "vector": [14, 3, 0.9224, 0.0028, 3, 0.38, 0.0, 916, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "ci", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ci = 'No GeoIP City data in \"%s\"' % self._city_file"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L335_C12", "label": "ci = geoip_dbinfo()", "type": "assigned_variable", "loc": [335, 335], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L332_C8", "vector": [14, 3, 0.928, 0.0028, 3, 0.38, 1.0, 916, 3, 1, 0, 0, 629, 10, 1], "semantic": {"name": "ci", "arg_names": [], "import_names": [], "rhs_call_name": "geoip_dbinfo", "annotation": ""}, "snippet": " ci = geoip_dbinfo(self._city)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L336_C8", "label": "return", "type": "return", "loc": [336, 336], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L330_C4", "vector": [13, 2, 0.9307, 0.0028, 2, 0.45, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ci"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L337_C4", "label": "city_info = property()", "type": "assigned_variable", "loc": [337, 337], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.9335, 0.0028, 1, 0.73, 0.6571, 174, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "city_info", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " city_info = property(city_info)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L339_C4", "label": "info", "type": "function", "loc": [339, 341], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.9418, 0.0083, 1, 0.73, 0.6857, 730, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "info", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def info(self):\n \"Returns information about all GeoIP databases in use.\"\n return 'Country:\\n\\t%s\\nCity:\\n\\t%s' % (self.country_info, self.city_info)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L340_C8", "label": "expression", "type": "expression", "loc": [340, 340], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L339_C4", "vector": [8, 2, 0.9418, 0.0028, 2, 0.16, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns information about all GeoIP databases in use.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L341_C8", "label": "return", "type": "return", "loc": [341, 341], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L339_C4", "vector": [13, 2, 0.9446, 0.0028, 2, 0.16, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 'Country:\\n\\t%s\\nCity:\\n\\t%s' % (self.country_info, self.city_info)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L342_C4", "label": "info = property()", "type": "assigned_variable", "loc": [342, 342], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.9474, 0.0028, 1, 0.73, 0.7143, 730, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "info", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " info = property(info)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L346_C4", "label": "open", "type": "function", "loc": [346, 347], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.9598, 0.0055, 1, 0.73, 0.7429, 693, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "open", "arg_names": ["cls", "full_path", "cache"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def open(cls, full_path, cache):\n return GeoIP(full_path, cache)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L347_C8", "label": "return", "type": "return", "loc": [347, 347], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L346_C4", "vector": [13, 2, 0.9612, 0.0028, 2, 0.33, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return GeoIP(full_path, cache)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L349_C4", "label": "_rec_by_arg", "type": "function", "loc": [349, 353], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [2, 1, 0.9723, 0.0139, 1, 0.73, 0.7714, 78, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "_rec_by_arg", "arg_names": ["self", "arg"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _rec_by_arg(self, arg):\n if self._city:\n return self.city(arg)\n else:\n return self.country(arg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L350_C8", "label": "if", "type": "if", "loc": [350, 353], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L349_C4", "vector": [4, 2, 0.9737, 0.0111, 2, 0.73, 0.0, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._city:\n return self.city(arg)\n else:\n return self.country(arg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L351_C12", "label": "return", "type": "return", "loc": [351, 351], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L350_C8", "vector": [13, 3, 0.9723, 0.0028, 3, 0.63, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.city(arg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L353_C12", "label": "return", "type": "return", "loc": [353, 353], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L350_C8", "vector": [13, 3, 0.9778, 0.0028, 3, 0.63, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.country(arg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L354_C4", "label": "region_by_addr =", "type": "assigned_variable", "loc": [354, 354], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.9806, 0.0028, 1, 0.73, 0.8, 110, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "region_by_addr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " region_by_addr = city"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L355_C4", "label": "region_by_name =", "type": "assigned_variable", "loc": [355, 355], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.9834, 0.0028, 1, 0.73, 0.8286, 426, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "region_by_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " region_by_name = city"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L356_C4", "label": "record_by_addr =", "type": "assigned_variable", "loc": [356, 356], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.9861, 0.0028, 1, 0.73, 0.8571, 887, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "record_by_addr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " record_by_addr = _rec_by_arg"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L357_C4", "label": "record_by_name =", "type": "assigned_variable", "loc": [357, 357], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.9889, 0.0028, 1, 0.73, 0.8857, 334, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "record_by_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " record_by_name = _rec_by_arg"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L358_C4", "label": "country_code_by_addr =", "type": "assigned_variable", "loc": [358, 358], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.9917, 0.0028, 1, 0.73, 0.9143, 63, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "country_code_by_addr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " country_code_by_addr = country_code"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L359_C4", "label": "country_code_by_name =", "type": "assigned_variable", "loc": [359, 359], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.9945, 0.0028, 1, 0.73, 0.9429, 958, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "country_code_by_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " country_code_by_name = country_code"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L360_C4", "label": "country_name_by_addr =", "type": "assigned_variable", "loc": [360, 360], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 0.9972, 0.0028, 1, 0.73, 0.9714, 543, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "country_name_by_addr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " country_name_by_addr = country_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L361_C4", "label": "country_name_by_name =", "type": "assigned_variable", "loc": [361, 361], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "vector": [14, 1, 1.0, 0.0028, 1, 0.73, 1.0, 79, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "country_name_by_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " country_name_by_name = country_name"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L45_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L58_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L58_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L62_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L65_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L65_C13"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L77_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L78_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L105_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L106_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L105_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L107_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L120_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L121_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L146_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L147_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L148_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L149_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L150_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L151_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L152_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L155_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L156_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L158_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L158_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L159_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L158_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L183_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L183_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L184_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L158_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L189_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L189_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L190_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L189_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L191_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L158_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L192_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L158_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L195_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L195_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L199_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L195_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L200_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L200_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L201_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L200_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L202_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L195_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L204_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L195_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L205_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L205_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L206_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L205_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L207_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L195_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L208_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L208_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L212_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L208_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L213_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L208_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L214_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L214_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L216_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L214_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L217_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L214_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L218_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L218_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L220_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L218_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L221_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L227_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L227_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L229_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L229_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L229_C26"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L227_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L230_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L230_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L230_C23"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L232_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L232_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L233_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L232_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L235_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L232_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L239_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L239_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L241_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L241_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L243_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L246_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L247_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L252_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L253_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L253_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L255_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L253_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L258_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L262_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L262_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L263_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L262_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L264_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L262_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L266_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L268_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L268_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L269_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L268_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L270_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L268_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L271_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L271_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L272_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L272_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L272_C37"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L272_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L273_C18"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L271_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L275_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L277_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L277_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L278_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L277_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L279_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L277_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L280_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L280_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L281_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L281_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L281_C37"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L281_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L282_C18"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L280_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L284_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L286_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L286_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L287_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L286_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L293_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L298_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L298_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L299_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L298_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L300_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L300_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L300_C26"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L300_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L301_C14"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L303_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L303_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L304_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L303_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L305_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L307_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L307_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L308_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L307_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L309_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L311_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L311_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L312_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L311_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L313_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L311_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L314_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L314_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:ImportFrom_L315_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L314_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L316_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L314_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L318_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L321_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L321_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L322_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L321_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L323_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L323_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L324_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L323_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L326_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L321_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L327_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L328_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L330_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L330_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L331_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L330_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L332_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L332_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L333_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L332_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L335_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L330_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L336_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L337_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L339_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L339_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Expr_L340_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L339_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L341_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L342_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L346_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L346_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L347_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L349_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L350_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L350_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L351_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:If_L350_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Return_L353_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L354_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L355_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L356_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L357_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L358_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L359_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L360_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98670:ClassDef_L129_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98670:Assign_L361_C4"}] |
"""
This module is for inspecting OGR data sources and generating either
models for GeoDjango and/or mapping dictionaries for use with the
`LayerMapping` utility.
Author: Travis Pinney, Dane Springmeyer, & Justin Bronn
"""
from itertools import izip
# Requires GDAL to use.
from django.contrib.gis.gdal import DataSource
from django.contrib.gis.gdal.field import OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime
def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False):
"""
Given a DataSource, generates a dictionary that may be used
for invoking the LayerMapping utility.
Keyword Arguments:
`geom_name` => The name of the geometry field to use for the model.
`layer_key` => The key for specifying which layer in the DataSource to use;
defaults to 0 (the first layer). May be an integer index or a string
identifier for the layer.
`multi_geom` => Boolean (default: False) - specify as multigeometry.
"""
if isinstance(data_source, basestring):
# Instantiating the DataSource from the string.
data_source = DataSource(data_source)
elif isinstance(data_source, DataSource):
pass
else:
raise TypeError('Data source parameter must be a string or a DataSource object.')
# Creating the dictionary.
_mapping = {}
# Generating the field name for each field in the layer.
for field in data_source[layer_key].fields:
mfield = field.lower()
if mfield[-1:] == '_': mfield += 'field'
_mapping[mfield] = field
gtype = data_source[layer_key].geom_type
if multi_geom and gtype.num in (1, 2, 3): prefix = 'MULTI'
else: prefix = ''
_mapping[geom_name] = prefix + str(gtype).upper()
return _mapping
def ogrinspect(*args, **kwargs):
"""
Given a data source (either a string or a DataSource object) and a string
model name this function will generate a GeoDjango model.
Usage:
>>> from django.contrib.gis.utils import ogrinspect
>>> ogrinspect('/path/to/shapefile.shp','NewModel')
...will print model definition to stout
or put this in a python script and use to redirect the output to a new
model like:
$ python generate_model.py > myapp/models.py
# generate_model.py
from django.contrib.gis.utils import ogrinspect
shp_file = 'data/mapping_hacks/world_borders.shp'
model_name = 'WorldBorders'
print ogrinspect(shp_file, model_name, multi_geom=True, srid=4326,
geom_name='shapes', blank=True)
Required Arguments
`datasource` => string or DataSource object to file pointer
`model name` => string of name of new model class to create
Optional Keyword Arguments
`geom_name` => For specifying the model name for the Geometry Field.
Otherwise will default to `geom`
`layer_key` => The key for specifying which layer in the DataSource to use;
defaults to 0 (the first layer). May be an integer index or a string
identifier for the layer.
`srid` => The SRID to use for the Geometry Field. If it can be determined,
the SRID of the datasource is used.
`multi_geom` => Boolean (default: False) - specify as multigeometry.
`name_field` => String - specifies a field name to return for the
`__unicode__` function (which will be generated if specified).
`imports` => Boolean (default: True) - set to False to omit the
`from django.contrib.gis.db import models` code from the
autogenerated models thus avoiding duplicated imports when building
more than one model by batching ogrinspect()
`decimal` => Boolean or sequence (default: False). When set to True
all generated model fields corresponding to the `OFTReal` type will
be `DecimalField` instead of `FloatField`. A sequence of specific
field names to generate as `DecimalField` may also be used.
`blank` => Boolean or sequence (default: False). When set to True all
generated model fields will have `blank=True`. If the user wants to
give specific fields to have blank, then a list/tuple of OGR field
names may be used.
`null` => Boolean (default: False) - When set to True all generated
model fields will have `null=True`. If the user wants to specify
give specific fields to have null, then a list/tuple of OGR field
names may be used.
Note: This routine calls the _ogrinspect() helper to do the heavy lifting.
"""
return '\n'.join(s for s in _ogrinspect(*args, **kwargs))
def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=None,
multi_geom=False, name_field=None, imports=True,
decimal=False, blank=False, null=False):
"""
Helper routine for `ogrinspect` that generates GeoDjango models corresponding
to the given data source. See the `ogrinspect` docstring for more details.
"""
# Getting the DataSource
if isinstance(data_source, str):
data_source = DataSource(data_source)
elif isinstance(data_source, DataSource):
pass
else:
raise TypeError('Data source parameter must be a string or a DataSource object.')
# Getting the layer corresponding to the layer key and getting
# a string listing of all OGR fields in the Layer.
layer = data_source[layer_key]
ogr_fields = layer.fields
# Creating lists from the `null`, `blank`, and `decimal`
# keyword arguments.
def process_kwarg(kwarg):
if isinstance(kwarg, (list, tuple)):
return [s.lower() for s in kwarg]
elif kwarg:
return [s.lower() for s in ogr_fields]
else:
return []
null_fields = process_kwarg(null)
blank_fields = process_kwarg(blank)
decimal_fields = process_kwarg(decimal)
# Gets the `null` and `blank` keywords for the given field name.
def get_kwargs_str(field_name):
kwlist = []
if field_name.lower() in null_fields: kwlist.append('null=True')
if field_name.lower() in blank_fields: kwlist.append('blank=True')
if kwlist: return ', ' + ', '.join(kwlist)
else: return ''
# For those wishing to disable the imports.
if imports:
yield '# This is an auto-generated Django model module created by ogrinspect.'
yield 'from django.contrib.gis.db import models'
yield ''
yield 'class %s(models.Model):' % model_name
for field_name, width, precision, field_type in izip(ogr_fields, layer.field_widths, layer.field_precisions, layer.field_types):
# The model field name.
mfield = field_name.lower()
if mfield[-1:] == '_': mfield += 'field'
# Getting the keyword args string.
kwargs_str = get_kwargs_str(field_name)
if field_type is OFTReal:
# By default OFTReals are mapped to `FloatField`, however, they
# may also be mapped to `DecimalField` if specified in the
# `decimal` keyword.
if field_name.lower() in decimal_fields:
yield ' %s = models.DecimalField(max_digits=%d, decimal_places=%d%s)' % (mfield, width, precision, kwargs_str)
else:
yield ' %s = models.FloatField(%s)' % (mfield, kwargs_str[2:])
elif field_type is OFTInteger:
yield ' %s = models.IntegerField(%s)' % (mfield, kwargs_str[2:])
elif field_type is OFTString:
yield ' %s = models.CharField(max_length=%s%s)' % (mfield, width, kwargs_str)
elif field_type is OFTDate:
yield ' %s = models.DateField(%s)' % (mfield, kwargs_str[2:])
elif field_type is OFTDateTime:
yield ' %s = models.DateTimeField(%s)' % (mfield, kwargs_str[2:])
elif field_type is OFTDate:
yield ' %s = models.TimeField(%s)' % (mfield, kwargs_str[2:])
else:
raise TypeError('Unknown field type %s in %s' % (field_type, mfield))
# TODO: Autodetection of multigeometry types (see #7218).
gtype = layer.geom_type
if multi_geom and gtype.num in (1, 2, 3):
geom_field = 'Multi%s' % gtype.django
else:
geom_field = gtype.django
# Setting up the SRID keyword string.
if srid is None:
if layer.srs is None:
srid_str = 'srid=-1'
else:
srid = layer.srs.srid
if srid is None:
srid_str = 'srid=-1'
elif srid == 4326:
# WGS84 is already the default.
srid_str = ''
else:
srid_str = 'srid=%s' % srid
else:
srid_str = 'srid=%s' % srid
yield ' %s = models.%s(%s)' % (geom_name, geom_field, srid_str)
yield ' objects = models.GeoManager()'
if name_field:
yield ''
yield ' def __unicode__(self): return self.%s' % name_field
| ajibawa-2023/Python-Code-Large/train/row_98671 | 90 | 225 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 7], "level": 0, "parent": null, "vector": [8, 0, 0.0178, 0.0311, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nThis module is for inspecting OGR data sources and generating either\nmodels for GeoDjango and/or mapping dictionaries for use with the\n`LayerMapping` utility.\n\nAuthor: Travis Pinney, Dane Springmeyer, & Justin Bronn\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:ImportFrom_L8_C0", "label": "from itertools import izip", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0356, 0.0044, 0, 0.66, 0.1667, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "itertools", "arg_names": [], "import_names": ["izip"], "rhs_call_name": "", "annotation": ""}, "snippet": "from itertools import izip"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:ImportFrom_L10_C0", "label": "from django.contrib.gis.gdal import DataSource", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0444, 0.0044, 0, 0.66, 0.3333, 793, 0, 1, 0, 0, 793, 0, 0], "semantic": {"name": "django.contrib.gis.gdal", "arg_names": [], "import_names": ["DataSource"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.gdal import DataSource"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:ImportFrom_L11_C0", "label": "from django.contrib.gis.gdal.field import OFTDate, OFTDateTime, OFTInteger\u2026", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0489, 0.0044, 0, 0.66, 0.5, 367, 0, 6, 0, 0, 367, 0, 0], "semantic": {"name": "django.contrib.gis.gdal.field", "arg_names": [], "import_names": ["OFTDate", "OFTDateTime", "OFTInteger", "OFTReal", "OFTString", "OFTTime"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.gdal.field import OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "label": "mapping", "type": "function", "loc": [13, 47], "level": 0, "parent": null, "vector": [2, 0, 0.1333, 0.1556, 0, 0.66, 0.6667, 351, 0, 4, 1, 0, 0, 0, 7], "semantic": {"name": "mapping", "arg_names": ["data_source", "geom_name", "layer_key", "multi_geom"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False):\n \"\"\"\n Given a DataSource, generates a dictionary that may be used\n for invoking the LayerMapping utility.\n\n Keyword Arguments:\n `geom_name` => The name of the geometry field to use for the model.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L14_C4", "label": "expression", "type": "expression", "loc": [14, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "vector": [8, 1, 0.0889, 0.0578, 1, 0.01, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Given a DataSource, generates a dictionary that may be used\n for invoking the LayerMapping utility.\n\n Keyword Arguments:\n `geom_name` => The name of the geometry field to use for the model.\n\n `layer_key` => The key for specifying which layer in the DataSource to use;"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L27_C4", "label": "if", "type": "if", "loc": [27, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "vector": [4, 1, 0.1333, 0.0311, 1, 0.01, 0.1429, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(data_source, basestring):\n # Instantiating the DataSource from the string.\n data_source = DataSource(data_source)\n elif isinstance(data_source, DataSource):\n pass\n else:\n raise TypeError('Data source parameter must be a string or a DataSource object.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L29_C8", "label": "data_source = DataSource()", "type": "assigned_variable", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L27_C4", "vector": [14, 2, 0.1289, 0.0044, 2, 0.79, 0.0, 357, 3, 1, 0, 0, 717, 10, 1], "semantic": {"name": "data_source", "arg_names": [], "import_names": [], "rhs_call_name": "DataSource", "annotation": ""}, "snippet": " data_source = DataSource(data_source)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L30_C4", "label": "if", "type": "if", "loc": [30, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L27_C4", "vector": [4, 2, 0.14, 0.0178, 2, 0.79, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(data_source, DataSource):\n pass\n else:\n raise TypeError('Data source parameter must be a string or a DataSource object.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L36_C4", "label": "_mapping =", "type": "assigned_variable", "loc": [36, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "vector": [14, 1, 0.16, 0.0044, 1, 0.01, 0.2857, 329, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "_mapping", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " _mapping = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L39_C4", "label": "for field", "type": "for", "loc": [39, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "vector": [6, 1, 0.18, 0.0178, 1, 0.01, 0.4286, 480, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field in data_source[layer_key].fields:\n mfield = field.lower()\n if mfield[-1:] == '_': mfield += 'field'\n _mapping[mfield] = field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L40_C8", "label": "mfield = lower()", "type": "assigned_variable", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L39_C4", "vector": [14, 2, 0.1778, 0.0044, 2, 0.82, 0.0, 921, 3, 0, 0, 0, 432, 10, 1], "semantic": {"name": "mfield", "arg_names": [], "import_names": [], "rhs_call_name": "lower", "annotation": ""}, "snippet": " mfield = field.lower()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L41_C8", "label": "if", "type": "if", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L39_C4", "vector": [4, 2, 0.1822, 0.0044, 2, 0.82, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if mfield[-1:] == '_': mfield += 'field'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L42_C8", "label": "assign", "type": "assigned_variable", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L39_C4", "vector": [14, 2, 0.1867, 0.0044, 2, 0.82, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " _mapping[mfield] = field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L43_C4", "label": "gtype =", "type": "assigned_variable", "loc": [43, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "vector": [14, 1, 0.1911, 0.0044, 1, 0.01, 0.5714, 377, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "gtype", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " gtype = data_source[layer_key].geom_type"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L44_C4", "label": "if", "type": "if", "loc": [44, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "vector": [4, 1, 0.1978, 0.0089, 1, 0.01, 0.7143, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if multi_geom and gtype.num in (1, 2, 3): prefix = 'MULTI'\n else: prefix = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L44_C46", "label": "prefix =", "type": "assigned_variable", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L44_C4", "vector": [14, 2, 0.1956, 0.0044, 2, 0.29, 0.0, 284, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "prefix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if multi_geom and gtype.num in (1, 2, 3): prefix = 'MULTI'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L45_C10", "label": "prefix =", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L44_C4", "vector": [14, 2, 0.2, 0.0044, 2, 0.29, 1.0, 284, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "prefix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " else: prefix = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L46_C4", "label": "assign", "type": "assigned_variable", "loc": [46, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "vector": [14, 1, 0.2044, 0.0044, 1, 0.01, 0.8571, 0, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " _mapping[geom_name] = prefix + str(gtype).upper()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L47_C4", "label": "return", "type": "return", "loc": [47, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "vector": [13, 1, 0.2089, 0.0044, 1, 0.01, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _mapping"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L49_C0", "label": "ogrinspect", "type": "function", "loc": [49, 117], "level": 0, "parent": null, "vector": [2, 0, 0.3689, 0.3067, 0, 0.66, 0.8333, 658, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "ogrinspect", "arg_names": ["args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def ogrinspect(*args, **kwargs):\n \"\"\"\n Given a data source (either a string or a DataSource object) and a string\n model name this function will generate a GeoDjango model.\n\n Usage:\n\n >>> from django.contrib.gis.utils import ogrinspect"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L50_C4", "label": "expression", "type": "expression", "loc": [50, 116], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L49_C0", "vector": [8, 1, 0.3689, 0.2978, 1, 0.19, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Given a data source (either a string or a DataSource object) and a string\n model name this function will generate a GeoDjango model.\n\n Usage:\n\n >>> from django.contrib.gis.utils import ogrinspect\n >>> ogrinspect('/path/to/shapefile.shp','NewModel')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L117_C4", "label": "return", "type": "return", "loc": [117, 117], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L49_C0", "vector": [13, 1, 0.52, 0.0044, 1, 0.19, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '\\n'.join(s for s in _ogrinspect(*args, **kwargs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "label": "_ogrinspect", "type": "function", "loc": [119, 225], "level": 0, "parent": null, "vector": [2, 0, 0.7644, 0.4756, 0, 0.66, 1.0, 218, 0, 11, 1, 0, 0, 0, 20], "semantic": {"name": "_ogrinspect", "arg_names": ["data_source", "model_name", "geom_name", "layer_key", "srid", "multi_geom", "name_field", "imports", "decimal", "blank", "null"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=None,\n multi_geom=False, name_field=None, imports=True,\n decimal=False, blank=False, null=False):\n \"\"\"\n Helper routine for `ogrinspect` that generates GeoDjango models corresponding\n to the given data source. See the `ogrinspect` docstring for more details.\n \"\"\"\n # Getting the DataSource"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L122_C4", "label": "expression", "type": "expression", "loc": [122, 125], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [8, 1, 0.5489, 0.0178, 1, 0.72, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Helper routine for `ogrinspect` that generates GeoDjango models corresponding\n to the given data source. See the `ogrinspect` docstring for more details.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L127_C4", "label": "if", "type": "if", "loc": [127, 132], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [4, 1, 0.5756, 0.0267, 1, 0.72, 0.0588, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(data_source, str):\n data_source = DataSource(data_source)\n elif isinstance(data_source, DataSource):\n pass\n else:\n raise TypeError('Data source parameter must be a string or a DataSource object.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L128_C8", "label": "data_source = DataSource()", "type": "assigned_variable", "loc": [128, 128], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L127_C4", "vector": [14, 2, 0.5689, 0.0044, 2, 0.59, 0.0, 357, 3, 1, 0, 0, 717, 10, 1], "semantic": {"name": "data_source", "arg_names": [], "import_names": [], "rhs_call_name": "DataSource", "annotation": ""}, "snippet": " data_source = DataSource(data_source)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L129_C4", "label": "if", "type": "if", "loc": [129, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L127_C4", "vector": [4, 2, 0.58, 0.0178, 2, 0.59, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(data_source, DataSource):\n pass\n else:\n raise TypeError('Data source parameter must be a string or a DataSource object.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L136_C4", "label": "layer =", "type": "assigned_variable", "loc": [136, 136], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [14, 1, 0.6044, 0.0044, 1, 0.72, 0.1176, 556, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "layer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " layer = data_source[layer_key]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L137_C4", "label": "ogr_fields =", "type": "assigned_variable", "loc": [137, 137], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [14, 1, 0.6089, 0.0044, 1, 0.72, 0.1765, 752, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "ogr_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ogr_fields = layer.fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L141_C4", "label": "process_kwarg", "type": "function", "loc": [141, 147], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [2, 1, 0.64, 0.0311, 1, 0.72, 0.2353, 243, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "process_kwarg", "arg_names": ["kwarg"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_kwarg(kwarg):\n if isinstance(kwarg, (list, tuple)):\n return [s.lower() for s in kwarg]\n elif kwarg:\n return [s.lower() for s in ogr_fields]\n else:\n return []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L142_C8", "label": "if", "type": "if", "loc": [142, 147], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L141_C4", "vector": [4, 2, 0.6422, 0.0267, 2, 0.71, 0.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(kwarg, (list, tuple)):\n return [s.lower() for s in kwarg]\n elif kwarg:\n return [s.lower() for s in ogr_fields]\n else:\n return []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L143_C12", "label": "return", "type": "return", "loc": [143, 143], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L142_C8", "vector": [13, 3, 0.6356, 0.0044, 3, 0.39, 0.0, 0, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [s.lower() for s in kwarg]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L144_C8", "label": "if", "type": "if", "loc": [144, 147], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L142_C8", "vector": [4, 3, 0.6467, 0.0178, 3, 0.39, 1.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif kwarg:\n return [s.lower() for s in ogr_fields]\n else:\n return []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L145_C12", "label": "return", "type": "return", "loc": [145, 145], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L144_C8", "vector": [13, 4, 0.6444, 0.0044, 4, 0.01, 0.0, 0, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [s.lower() for s in ogr_fields]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L147_C12", "label": "return", "type": "return", "loc": [147, 147], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L144_C8", "vector": [13, 4, 0.6533, 0.0044, 4, 0.01, 1.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L148_C4", "label": "null_fields = process_kwarg()", "type": "assigned_variable", "loc": [148, 148], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [14, 1, 0.6578, 0.0044, 1, 0.72, 0.2941, 482, 3, 1, 0, 0, 243, 10, 1], "semantic": {"name": "null_fields", "arg_names": [], "import_names": [], "rhs_call_name": "process_kwarg", "annotation": ""}, "snippet": " null_fields = process_kwarg(null)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L149_C4", "label": "blank_fields = process_kwarg()", "type": "assigned_variable", "loc": [149, 149], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [14, 1, 0.6622, 0.0044, 1, 0.72, 0.3529, 618, 3, 1, 0, 0, 243, 10, 1], "semantic": {"name": "blank_fields", "arg_names": [], "import_names": [], "rhs_call_name": "process_kwarg", "annotation": ""}, "snippet": " blank_fields = process_kwarg(blank)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L150_C4", "label": "decimal_fields = process_kwarg()", "type": "assigned_variable", "loc": [150, 150], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [14, 1, 0.6667, 0.0044, 1, 0.72, 0.4118, 840, 3, 1, 0, 0, 243, 10, 1], "semantic": {"name": "decimal_fields", "arg_names": [], "import_names": [], "rhs_call_name": "process_kwarg", "annotation": ""}, "snippet": " decimal_fields = process_kwarg(decimal)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L153_C4", "label": "get_kwargs_str", "type": "function", "loc": [153, 158], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [2, 1, 0.6911, 0.0267, 1, 0.72, 0.4706, 291, 0, 1, 1, 0, 0, 0, 5], "semantic": {"name": "get_kwargs_str", "arg_names": ["field_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_kwargs_str(field_name):\n kwlist = []\n if field_name.lower() in null_fields: kwlist.append('null=True')\n if field_name.lower() in blank_fields: kwlist.append('blank=True')\n if kwlist: return ', ' + ', '.join(kwlist)\n else: return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L154_C8", "label": "kwlist =", "type": "assigned_variable", "loc": [154, 154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L153_C4", "vector": [14, 2, 0.6844, 0.0044, 2, 0.28, 0.0, 548, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "kwlist", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwlist = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L155_C8", "label": "if", "type": "if", "loc": [155, 155], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L153_C4", "vector": [4, 2, 0.6889, 0.0044, 2, 0.28, 0.3333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_name.lower() in null_fields: kwlist.append('null=True')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L155_C46", "label": "append()", "type": "expression", "loc": [155, 155], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L155_C8", "vector": [8, 3, 0.6889, 0.0044, 3, 0.28, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " if field_name.lower() in null_fields: kwlist.append('null=True')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L156_C8", "label": "if", "type": "if", "loc": [156, 156], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L153_C4", "vector": [4, 2, 0.6933, 0.0044, 2, 0.28, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_name.lower() in blank_fields: kwlist.append('blank=True')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L156_C47", "label": "append()", "type": "expression", "loc": [156, 156], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L156_C8", "vector": [8, 3, 0.6933, 0.0044, 3, 0.38, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " if field_name.lower() in blank_fields: kwlist.append('blank=True')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L157_C8", "label": "if", "type": "if", "loc": [157, 158], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L153_C4", "vector": [4, 2, 0.7, 0.0089, 2, 0.28, 1.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if kwlist: return ', ' + ', '.join(kwlist)\n else: return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L157_C19", "label": "return", "type": "return", "loc": [157, 157], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L157_C8", "vector": [13, 3, 0.6978, 0.0044, 3, 0.0, 0.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if kwlist: return ', ' + ', '.join(kwlist)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L158_C14", "label": "return", "type": "return", "loc": [158, 158], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L157_C8", "vector": [13, 3, 0.7022, 0.0044, 3, 0.0, 1.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " else: return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L161_C4", "label": "if", "type": "if", "loc": [161, 164], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [4, 1, 0.7222, 0.0178, 1, 0.72, 0.5294, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if imports:\n yield '# This is an auto-generated Django model module created by ogrinspect.'\n yield 'from django.contrib.gis.db import models'\n yield ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L162_C8", "label": "expression", "type": "expression", "loc": [162, 162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L161_C4", "vector": [8, 2, 0.72, 0.0044, 2, 0.05, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield '# This is an auto-generated Django model module created by ogrinspect.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L163_C8", "label": "expression", "type": "expression", "loc": [163, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L161_C4", "vector": [8, 2, 0.7244, 0.0044, 2, 0.05, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield 'from django.contrib.gis.db import models'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L164_C8", "label": "expression", "type": "expression", "loc": [164, 164], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L161_C4", "vector": [8, 2, 0.7289, 0.0044, 2, 0.05, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L166_C4", "label": "expression", "type": "expression", "loc": [166, 166], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [8, 1, 0.7378, 0.0044, 1, 0.72, 0.5882, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield 'class %s(models.Model):' % model_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L168_C4", "label": "for field_name, width, precision, field_type", "type": "for", "loc": [168, 195], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [6, 1, 0.8067, 0.1244, 1, 0.72, 0.6471, 263, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "field_name, width, precision, field_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field_name, width, precision, field_type in izip(ogr_fields, layer.field_widths, layer.field_precisions, layer.field_types):\n # The model field name.\n mfield = field_name.lower()\n if mfield[-1:] == '_': mfield += 'field'\n\n # Getting the keyword args string.\n kwargs_str = get_kwargs_str(field_name)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L170_C8", "label": "mfield = lower()", "type": "assigned_variable", "loc": [170, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L168_C4", "vector": [14, 2, 0.7556, 0.0044, 2, 0.38, 0.0, 921, 3, 0, 0, 0, 432, 10, 1], "semantic": {"name": "mfield", "arg_names": [], "import_names": [], "rhs_call_name": "lower", "annotation": ""}, "snippet": " mfield = field_name.lower()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L171_C8", "label": "if", "type": "if", "loc": [171, 171], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L168_C4", "vector": [4, 2, 0.76, 0.0044, 2, 0.38, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if mfield[-1:] == '_': mfield += 'field'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L174_C8", "label": "kwargs_str = get_kwargs_str()", "type": "assigned_variable", "loc": [174, 174], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L168_C4", "vector": [14, 2, 0.7733, 0.0044, 2, 0.38, 0.6667, 177, 3, 1, 0, 0, 291, 10, 1], "semantic": {"name": "kwargs_str", "arg_names": [], "import_names": [], "rhs_call_name": "get_kwargs_str", "annotation": ""}, "snippet": " kwargs_str = get_kwargs_str(field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L176_C8", "label": "if", "type": "if", "loc": [176, 195], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L168_C4", "vector": [4, 2, 0.8244, 0.0889, 2, 0.38, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_type is OFTReal:\n # By default OFTReals are mapped to `FloatField`, however, they\n # may also be mapped to `DecimalField` if specified in the\n # `decimal` keyword.\n if field_name.lower() in decimal_fields:\n yield ' %s = models.DecimalField(max_digits=%d, decimal_places=%d%s)' % (mfield, width, precision, kwargs_str)\n else:\n yield ' %s = models.FloatField(%s)' % (mfield, kwargs_str[2:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L180_C12", "label": "if", "type": "if", "loc": [180, 183], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L176_C8", "vector": [4, 3, 0.8067, 0.0178, 3, 0.25, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_name.lower() in decimal_fields:\n yield ' %s = models.DecimalField(max_digits=%d, decimal_places=%d%s)' % (mfield, width, precision, kwargs_str)\n else:\n yield ' %s = models.FloatField(%s)' % (mfield, kwargs_str[2:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L181_C16", "label": "expression", "type": "expression", "loc": [181, 181], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L180_C12", "vector": [8, 4, 0.8044, 0.0044, 4, 0.57, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ' %s = models.DecimalField(max_digits=%d, decimal_places=%d%s)' % (mfield, width, precision, kwargs_str)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L183_C16", "label": "expression", "type": "expression", "loc": [183, 183], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L180_C12", "vector": [8, 4, 0.8133, 0.0044, 4, 0.57, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ' %s = models.FloatField(%s)' % (mfield, kwargs_str[2:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L184_C8", "label": "if", "type": "if", "loc": [184, 195], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L176_C8", "vector": [4, 3, 0.8422, 0.0533, 3, 0.25, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif field_type is OFTInteger:\n yield ' %s = models.IntegerField(%s)' % (mfield, kwargs_str[2:])\n elif field_type is OFTString:\n yield ' %s = models.CharField(max_length=%s%s)' % (mfield, width, kwargs_str)\n elif field_type is OFTDate:\n yield ' %s = models.DateField(%s)' % (mfield, kwargs_str[2:])\n elif field_type is OFTDateTime:\n yield ' %s = models.DateTimeField(%s)' % (mfield, kwargs_str[2:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L185_C12", "label": "expression", "type": "expression", "loc": [185, 185], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L184_C8", "vector": [8, 4, 0.8222, 0.0044, 4, 0.34, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ' %s = models.IntegerField(%s)' % (mfield, kwargs_str[2:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L186_C8", "label": "if", "type": "if", "loc": [186, 195], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L184_C8", "vector": [4, 4, 0.8467, 0.0444, 4, 0.34, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif field_type is OFTString:\n yield ' %s = models.CharField(max_length=%s%s)' % (mfield, width, kwargs_str)\n elif field_type is OFTDate:\n yield ' %s = models.DateField(%s)' % (mfield, kwargs_str[2:])\n elif field_type is OFTDateTime:\n yield ' %s = models.DateTimeField(%s)' % (mfield, kwargs_str[2:])\n elif field_type is OFTDate:\n yield ' %s = models.TimeField(%s)' % (mfield, kwargs_str[2:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L187_C12", "label": "expression", "type": "expression", "loc": [187, 187], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L186_C8", "vector": [8, 5, 0.8311, 0.0044, 5, 0.18, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ' %s = models.CharField(max_length=%s%s)' % (mfield, width, kwargs_str)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L188_C8", "label": "if", "type": "if", "loc": [188, 195], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L186_C8", "vector": [4, 5, 0.8511, 0.0356, 5, 0.18, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif field_type is OFTDate:\n yield ' %s = models.DateField(%s)' % (mfield, kwargs_str[2:])\n elif field_type is OFTDateTime:\n yield ' %s = models.DateTimeField(%s)' % (mfield, kwargs_str[2:])\n elif field_type is OFTDate:\n yield ' %s = models.TimeField(%s)' % (mfield, kwargs_str[2:])\n else:\n raise TypeError('Unknown field type %s in %s' % (field_type, mfield))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L189_C12", "label": "expression", "type": "expression", "loc": [189, 189], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L188_C8", "vector": [8, 6, 0.84, 0.0044, 6, 0.39, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ' %s = models.DateField(%s)' % (mfield, kwargs_str[2:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L190_C8", "label": "if", "type": "if", "loc": [190, 195], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L188_C8", "vector": [4, 6, 0.8556, 0.0267, 6, 0.39, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif field_type is OFTDateTime:\n yield ' %s = models.DateTimeField(%s)' % (mfield, kwargs_str[2:])\n elif field_type is OFTDate:\n yield ' %s = models.TimeField(%s)' % (mfield, kwargs_str[2:])\n else:\n raise TypeError('Unknown field type %s in %s' % (field_type, mfield))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L191_C12", "label": "expression", "type": "expression", "loc": [191, 191], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L190_C8", "vector": [8, 7, 0.8489, 0.0044, 7, 0.38, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ' %s = models.DateTimeField(%s)' % (mfield, kwargs_str[2:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L192_C8", "label": "if", "type": "if", "loc": [192, 195], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L190_C8", "vector": [4, 7, 0.86, 0.0178, 7, 0.38, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif field_type is OFTDate:\n yield ' %s = models.TimeField(%s)' % (mfield, kwargs_str[2:])\n else:\n raise TypeError('Unknown field type %s in %s' % (field_type, mfield))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L193_C12", "label": "expression", "type": "expression", "loc": [193, 193], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L192_C8", "vector": [8, 8, 0.8578, 0.0044, 8, 0.97, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ' %s = models.TimeField(%s)' % (mfield, kwargs_str[2:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L198_C4", "label": "gtype =", "type": "assigned_variable", "loc": [198, 198], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [14, 1, 0.88, 0.0044, 1, 0.72, 0.7059, 377, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "gtype", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " gtype = layer.geom_type"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L199_C4", "label": "if", "type": "if", "loc": [199, 202], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [4, 1, 0.8911, 0.0178, 1, 0.72, 0.7647, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if multi_geom and gtype.num in (1, 2, 3):\n geom_field = 'Multi%s' % gtype.django\n else:\n geom_field = gtype.django"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L200_C8", "label": "geom_field =", "type": "assigned_variable", "loc": [200, 200], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L199_C4", "vector": [14, 2, 0.8889, 0.0044, 2, 0.68, 0.0, 424, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "geom_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " geom_field = 'Multi%s' % gtype.django"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L202_C8", "label": "geom_field =", "type": "assigned_variable", "loc": [202, 202], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L199_C4", "vector": [14, 2, 0.8978, 0.0044, 2, 0.68, 1.0, 424, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "geom_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " geom_field = gtype.django"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L205_C4", "label": "if", "type": "if", "loc": [205, 218], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [4, 1, 0.94, 0.0622, 1, 0.72, 0.8235, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if srid is None:\n if layer.srs is None:\n srid_str = 'srid=-1'\n else:\n srid = layer.srs.srid\n if srid is None:\n srid_str = 'srid=-1'\n elif srid == 4326:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L206_C8", "label": "if", "type": "if", "loc": [206, 216], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L205_C4", "vector": [4, 2, 0.9378, 0.0489, 2, 0.28, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if layer.srs is None:\n srid_str = 'srid=-1'\n else:\n srid = layer.srs.srid\n if srid is None:\n srid_str = 'srid=-1'\n elif srid == 4326:\n # WGS84 is already the default."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L207_C12", "label": "srid_str =", "type": "assigned_variable", "loc": [207, 207], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L206_C8", "vector": [14, 3, 0.92, 0.0044, 3, 0.19, 0.0, 932, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "srid_str", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " srid_str = 'srid=-1'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L209_C12", "label": "srid =", "type": "assigned_variable", "loc": [209, 209], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L206_C8", "vector": [14, 3, 0.9289, 0.0044, 3, 0.19, 0.5, 357, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "srid", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " srid = layer.srs.srid"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L210_C12", "label": "if", "type": "if", "loc": [210, 216], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L206_C8", "vector": [4, 3, 0.9467, 0.0311, 3, 0.19, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if srid is None:\n srid_str = 'srid=-1'\n elif srid == 4326:\n # WGS84 is already the default.\n srid_str = ''\n else:\n srid_str = 'srid=%s' % srid"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L211_C16", "label": "srid_str =", "type": "assigned_variable", "loc": [211, 211], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L210_C12", "vector": [14, 4, 0.9378, 0.0044, 4, 0.6, 0.0, 932, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "srid_str", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " srid_str = 'srid=-1'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L212_C12", "label": "if", "type": "if", "loc": [212, 216], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L210_C12", "vector": [4, 4, 0.9511, 0.0222, 4, 0.6, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif srid == 4326:\n # WGS84 is already the default.\n srid_str = ''\n else:\n srid_str = 'srid=%s' % srid"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L214_C16", "label": "srid_str =", "type": "assigned_variable", "loc": [214, 214], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L212_C12", "vector": [14, 5, 0.9511, 0.0044, 5, 0.25, 0.0, 932, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "srid_str", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " srid_str = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L216_C16", "label": "srid_str =", "type": "assigned_variable", "loc": [216, 216], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L212_C12", "vector": [14, 5, 0.96, 0.0044, 5, 0.25, 1.0, 932, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "srid_str", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " srid_str = 'srid=%s' % srid"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L218_C8", "label": "srid_str =", "type": "assigned_variable", "loc": [218, 218], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L205_C4", "vector": [14, 2, 0.9689, 0.0044, 2, 0.28, 1.0, 932, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "srid_str", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " srid_str = 'srid=%s' % srid"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L220_C4", "label": "expression", "type": "expression", "loc": [220, 220], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [8, 1, 0.9778, 0.0044, 1, 0.72, 0.8824, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ' %s = models.%s(%s)' % (geom_name, geom_field, srid_str)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L221_C4", "label": "expression", "type": "expression", "loc": [221, 221], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [8, 1, 0.9822, 0.0044, 1, 0.72, 0.9412, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ' objects = models.GeoManager()'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L223_C4", "label": "if", "type": "if", "loc": [223, 225], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "vector": [4, 1, 0.9956, 0.0133, 1, 0.72, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if name_field:\n yield ''\n yield ' def __unicode__(self): return self.%s' % name_field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L224_C8", "label": "expression", "type": "expression", "loc": [224, 224], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L223_C4", "vector": [8, 2, 0.9956, 0.0044, 2, 0.47, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L225_C8", "label": "expression", "type": "expression", "loc": [225, 225], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L223_C4", "vector": [8, 2, 1.0, 0.0044, 2, 0.47, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ' def __unicode__(self): return self.%s' % name_field"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L44_C46"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L45_C10"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L117_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L122_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L127_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L127_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L127_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L129_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L136_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L137_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L141_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L142_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L142_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L143_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L142_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L144_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L144_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L145_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L144_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L147_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L148_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L149_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L150_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L153_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L153_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L153_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L155_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L155_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L155_C46"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L153_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L156_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L156_C47"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L153_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L157_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L157_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L157_C19"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L157_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Return_L158_C14"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L161_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L164_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L166_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L168_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L168_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L170_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L168_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L171_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L168_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L174_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:For_L168_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L176_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L176_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L180_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L180_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L181_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L180_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L183_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L176_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L184_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L184_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L185_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L184_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L186_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L186_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L187_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L186_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L188_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L188_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L189_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L188_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L190_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L190_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L191_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L190_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L192_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L192_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L193_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L198_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L199_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L200_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L202_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L205_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L205_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L206_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L206_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L207_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L206_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L209_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L206_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L210_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L210_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L211_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L210_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L212_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L212_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L214_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L212_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L216_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L205_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Assign_L218_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L220_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L221_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L223_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L224_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98671:If_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98671:Expr_L225_C8"}] |
"""
This module includes some utility functions for inspecting the layout
of a GDAL data source -- the functionality is analogous to the output
produced by the `ogrinfo` utility.
"""
from django.contrib.gis.gdal import DataSource
from django.contrib.gis.gdal.geometries import GEO_CLASSES
def ogrinfo(data_source, num_features=10):
"""
Walks the available layers in the supplied `data_source`, displaying
the fields for the first `num_features` features.
"""
# Checking the parameters.
if isinstance(data_source, str):
data_source = DataSource(data_source)
elif isinstance(data_source, DataSource):
pass
else:
raise Exception('Data source parameter must be a string or a DataSource object.')
for i, layer in enumerate(data_source):
print "data source : %s" % data_source.name
print "==== layer %s" % i
print " shape type: %s" % GEO_CLASSES[layer.geom_type.num].__name__
print " # features: %s" % len(layer)
print " srs: %s" % layer.srs
extent_tup = layer.extent.tuple
print " extent: %s - %s" % (extent_tup[0:2], extent_tup[2:4])
print "Displaying the first %s features ====" % num_features
width = max(*map(len,layer.fields))
fmt = " %%%ss: %%s" % width
for j, feature in enumerate(layer[:num_features]):
print "=== Feature %s" % j
for fld_name in layer.fields:
type_name = feature[fld_name].type_name
output = fmt % (fld_name, type_name)
val = feature.get(fld_name)
if val:
if isinstance(val, str):
val_fmt = ' ("%s")'
else:
val_fmt = ' (%s)'
output += val_fmt % val
else:
output += ' (None)'
print output
# For backwards compatibility.
sample = ogrinfo
| ajibawa-2023/Python-Code-Large/train/row_98672 | 31 | 53 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 5], "level": 0, "parent": null, "vector": [8, 0, 0.0566, 0.0943, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nThis module includes some utility functions for inspecting the layout\nof a GDAL data source -- the functionality is analogous to the output\nproduced by the `ogrinfo` utility.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:ImportFrom_L7_C0", "label": "from django.contrib.gis.gdal import DataSource", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.1321, 0.0189, 0, 0.66, 0.25, 793, 0, 1, 0, 0, 793, 0, 0], "semantic": {"name": "django.contrib.gis.gdal", "arg_names": [], "import_names": ["DataSource"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.gdal import DataSource"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:ImportFrom_L8_C0", "label": "from django.contrib.gis.gdal.geometries import GEO_CLASSES", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.1509, 0.0189, 0, 0.66, 0.5, 671, 0, 1, 0, 0, 671, 0, 0], "semantic": {"name": "django.contrib.gis.gdal.geometries", "arg_names": [], "import_names": ["GEO_CLASSES"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.gdal.geometries import GEO_CLASSES"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:FunctionDef_L10_C0", "label": "ogrinfo", "type": "function", "loc": [10, 50], "level": 0, "parent": null, "vector": [2, 0, 0.566, 0.7736, 0, 0.66, 0.75, 856, 0, 2, 0, 0, 0, 0, 20], "semantic": {"name": "ogrinfo", "arg_names": ["data_source", "num_features"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def ogrinfo(data_source, num_features=10):\n \"\"\"\n Walks the available layers in the supplied `data_source`, displaying\n the fields for the first `num_features` features.\n \"\"\"\n\n # Checking the parameters.\n if isinstance(data_source, str):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L11_C4", "label": "expression", "type": "expression", "loc": [11, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:FunctionDef_L10_C0", "vector": [8, 1, 0.2358, 0.0755, 1, 0.85, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Walks the available layers in the supplied `data_source`, displaying\n the fields for the first `num_features` features.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L17_C4", "label": "if", "type": "if", "loc": [17, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:FunctionDef_L10_C0", "vector": [4, 1, 0.3679, 0.1132, 1, 0.85, 0.5, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(data_source, str):\n data_source = DataSource(data_source)\n elif isinstance(data_source, DataSource):\n pass\n else:\n raise Exception('Data source parameter must be a string or a DataSource object.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L18_C8", "label": "data_source = DataSource()", "type": "assigned_variable", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L17_C4", "vector": [14, 2, 0.3396, 0.0189, 2, 0.74, 0.0, 357, 3, 1, 0, 0, 717, 10, 1], "semantic": {"name": "data_source", "arg_names": [], "import_names": [], "rhs_call_name": "DataSource", "annotation": ""}, "snippet": " data_source = DataSource(data_source)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L19_C4", "label": "if", "type": "if", "loc": [19, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L17_C4", "vector": [4, 2, 0.3868, 0.0755, 2, 0.74, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(data_source, DataSource):\n pass\n else:\n raise Exception('Data source parameter must be a string or a DataSource object.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "label": "for i, layer", "type": "for", "loc": [24, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:FunctionDef_L10_C0", "vector": [6, 1, 0.6981, 0.5094, 1, 0.85, 1.0, 108, 3, 0, 0, 0, 0, 0, 16], "semantic": {"name": "i, layer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, layer in enumerate(data_source):\n print(\"data source : %s\" % data_source.name)\n print(\"==== layer %s\" % i)\n print(\" shape type: %s\" % GEO_CLASSES[layer.geom_type.num].__name__)\n print(\" # features: %s\" % len(layer))\n print(\" srs: %s\" % layer.srs)\n extent_tup = layer.extent.tuple\n print(\" extent: %s - %s\" % (extent_tup[0:2], extent_tup[2:4]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L25_C8", "label": "print()", "type": "expression", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "vector": [8, 2, 0.4717, 0.0189, 2, 0.72, 0.0, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\"data source : %s\" % data_source.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L26_C8", "label": "print()", "type": "expression", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "vector": [8, 2, 0.4906, 0.0189, 2, 0.72, 0.1, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\"==== layer %s\" % i)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L27_C8", "label": "print()", "type": "expression", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "vector": [8, 2, 0.5094, 0.0189, 2, 0.72, 0.2, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\" shape type: %s\" % GEO_CLASSES[layer.geom_type.num].__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L28_C8", "label": "print()", "type": "expression", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "vector": [8, 2, 0.5283, 0.0189, 2, 0.72, 0.3, 535, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\" # features: %s\" % len(layer))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L29_C8", "label": "print()", "type": "expression", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "vector": [8, 2, 0.5472, 0.0189, 2, 0.72, 0.4, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\" srs: %s\" % layer.srs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L30_C8", "label": "extent_tup =", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "vector": [14, 2, 0.566, 0.0189, 2, 0.72, 0.5, 685, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "extent_tup", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " extent_tup = layer.extent.tuple"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L31_C8", "label": "print()", "type": "expression", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "vector": [8, 2, 0.5849, 0.0189, 2, 0.72, 0.6, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\" extent: %s - %s\" % (extent_tup[0:2], extent_tup[2:4]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L32_C8", "label": "print()", "type": "expression", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "vector": [8, 2, 0.6038, 0.0189, 2, 0.72, 0.7, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\"Displaying the first %s features ====\" % num_features)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L34_C8", "label": "width = max()", "type": "assigned_variable", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "vector": [14, 2, 0.6415, 0.0189, 2, 0.72, 0.8, 989, 3, 1, 0, 0, 442, 10, 2], "semantic": {"name": "width", "arg_names": [], "import_names": [], "rhs_call_name": "max", "annotation": ""}, "snippet": " width = max(*map(len,layer.fields))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L35_C8", "label": "fmt =", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "vector": [14, 2, 0.6604, 0.0189, 2, 0.72, 0.9, 913, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "fmt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fmt = \" %%%ss: %%s\" % width"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L36_C8", "label": "for j, feature", "type": "for", "loc": [36, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "vector": [6, 2, 0.8113, 0.283, 2, 0.72, 1.0, 198, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "j, feature", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for j, feature in enumerate(layer[:num_features]):\n print(\"=== Feature %s\" % j)\n for fld_name in layer.fields:\n type_name = feature[fld_name].type_name\n output = fmt % (fld_name, type_name)\n val = feature.get(fld_name)\n if val:\n if isinstance(val, str):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L37_C12", "label": "print()", "type": "expression", "loc": [37, 37], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L36_C8", "vector": [8, 3, 0.6981, 0.0189, 3, 0.28, 0.0, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\"=== Feature %s\" % j)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L38_C12", "label": "for fld_name", "type": "for", "loc": [38, 50], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L36_C8", "vector": [6, 3, 0.8302, 0.2453, 3, 0.28, 1.0, 402, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "fld_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for fld_name in layer.fields:\n type_name = feature[fld_name].type_name\n output = fmt % (fld_name, type_name)\n val = feature.get(fld_name)\n if val:\n if isinstance(val, str):\n val_fmt = ' (\"%s\")'\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L39_C16", "label": "type_name =", "type": "assigned_variable", "loc": [39, 39], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L38_C12", "vector": [14, 4, 0.7358, 0.0189, 4, 0.64, 0.0, 81, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "type_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " type_name = feature[fld_name].type_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L40_C16", "label": "output =", "type": "assigned_variable", "loc": [40, 40], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L38_C12", "vector": [14, 4, 0.7547, 0.0189, 4, 0.64, 0.25, 886, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output = fmt % (fld_name, type_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L41_C16", "label": "val = get()", "type": "assigned_variable", "loc": [41, 41], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L38_C12", "vector": [14, 4, 0.7736, 0.0189, 4, 0.64, 0.5, 618, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "val", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " val = feature.get(fld_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L42_C16", "label": "if", "type": "if", "loc": [42, 49], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L38_C12", "vector": [4, 4, 0.8585, 0.1509, 4, 0.64, 0.75, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if val:\n if isinstance(val, str):\n val_fmt = ' (\"%s\")'\n else:\n val_fmt = ' (%s)'\n output += val_fmt % val\n else:\n output += ' (None)'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L43_C20", "label": "if", "type": "if", "loc": [43, 46], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L42_C16", "vector": [4, 5, 0.8396, 0.0755, 5, 0.96, 0.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(val, str):\n val_fmt = ' (\"%s\")'\n else:\n val_fmt = ' (%s)'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L44_C24", "label": "val_fmt =", "type": "assigned_variable", "loc": [44, 44], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L43_C20", "vector": [14, 6, 0.8302, 0.0189, 6, 0.8, 0.0, 485, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "val_fmt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " val_fmt = ' (\"%s\")'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L46_C24", "label": "val_fmt =", "type": "assigned_variable", "loc": [46, 46], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L43_C20", "vector": [14, 6, 0.8679, 0.0189, 6, 0.8, 1.0, 485, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "val_fmt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " val_fmt = ' (%s)'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L50_C16", "label": "print()", "type": "expression", "loc": [50, 50], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L38_C12", "vector": [8, 4, 0.9434, 0.0189, 4, 0.64, 1.0, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(output)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L53_C0", "label": "sample =", "type": "assigned_variable", "loc": [53, 53], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0189, 0, 0.66, 1.0, 513, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "sample", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "sample = ogrinfo"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98672:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L38_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L39_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L40_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L41_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L42_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L42_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L43_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L43_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L44_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:If_L43_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Assign_L46_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98672:For_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98672:Expr_L50_C16"}] |
"""
This module contains useful utilities for GeoDjango.
"""
# Importing the utilities that depend on GDAL, if available.
from django.contrib.gis.gdal import HAS_GDAL
if HAS_GDAL:
from django.contrib.gis.utils.ogrinfo import ogrinfo, sample
from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect
from django.contrib.gis.utils.srs import add_postgis_srs, add_srs_entry
try:
# LayerMapping requires DJANGO_SETTINGS_MODULE to be set,
# so this needs to be in try/except.
from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError
except:
pass
# Attempting to import the GeoIP class.
try:
from django.contrib.gis.utils.geoip import GeoIP, GeoIPException
HAS_GEOIP = True
except:
HAS_GEOIP = False
from django.contrib.gis.utils.wkt import precision_wkt
| ajibawa-2023/Python-Code-Large/train/row_98674 | 13 | 25 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98674:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.08, 0.12, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\n This module contains useful utilities for GeoDjango.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98674:ImportFrom_L5_C0", "label": "from django.contrib.gis.gdal import HAS_GDAL", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.2, 0.04, 0, 0.66, 0.25, 793, 0, 1, 0, 0, 793, 0, 0], "semantic": {"name": "django.contrib.gis.gdal", "arg_names": [], "import_names": ["HAS_GDAL"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.gdal import HAS_GDAL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98674:If_L6_C0", "label": "if", "type": "if", "loc": [6, 15], "level": 0, "parent": null, "vector": [4, 0, 0.42, 0.4, 0, 0.66, 0.5, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if HAS_GDAL:\n from django.contrib.gis.utils.ogrinfo import ogrinfo, sample\n from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect\n from django.contrib.gis.utils.srs import add_postgis_srs, add_srs_entry\n try:\n # LayerMapping requires DJANGO_SETTINGS_MODULE to be set, \n # so this needs to be in try/except.\n from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98674:ImportFrom_L7_C4", "label": "from django.contrib.gis.utils.ogrinfo import ogrinfo, sample", "type": "import", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98674:If_L6_C0", "vector": [1, 1, 0.28, 0.04, 1, 0.02, 0.0, 911, 0, 2, 0, 0, 911, 0, 0], "semantic": {"name": "django.contrib.gis.utils.ogrinfo", "arg_names": [], "import_names": ["ogrinfo", "sample"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.gis.utils.ogrinfo import ogrinfo, sample"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98674:ImportFrom_L8_C4", "label": "from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect", "type": "import", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98674:If_L6_C0", "vector": [1, 1, 0.32, 0.04, 1, 0.02, 0.3333, 612, 0, 2, 0, 0, 612, 0, 0], "semantic": {"name": "django.contrib.gis.utils.ogrinspect", "arg_names": [], "import_names": ["mapping", "ogrinspect"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98674:ImportFrom_L9_C4", "label": "from django.contrib.gis.utils.srs import add_postgis_srs, add_srs_entry", "type": "import", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98674:If_L6_C0", "vector": [1, 1, 0.36, 0.04, 1, 0.02, 0.6667, 643, 0, 2, 0, 0, 643, 0, 0], "semantic": {"name": "django.contrib.gis.utils.srs", "arg_names": [], "import_names": ["add_postgis_srs", "add_srs_entry"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.gis.utils.srs import add_postgis_srs, add_srs_entry"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98674:Try_L10_C4", "label": "try", "type": "try", "loc": [10, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98674:If_L6_C0", "vector": [7, 1, 0.5, 0.24, 1, 0.02, 1.0, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n # LayerMapping requires DJANGO_SETTINGS_MODULE to be set, \n # so this needs to be in try/except.\n from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError\n except:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98674:ImportFrom_L13_C8", "label": "from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError", "type": "import", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98674:Try_L10_C4", "vector": [1, 2, 0.52, 0.04, 2, 0.17, 0.0, 741, 0, 2, 0, 0, 741, 0, 0], "semantic": {"name": "django.contrib.gis.utils.layermapping", "arg_names": [], "import_names": ["LayerMapping", "LayerMapError"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98674:Try_L18_C0", "label": "try", "type": "try", "loc": [18, 22], "level": 0, "parent": null, "vector": [7, 0, 0.8, 0.2, 0, 0.66, 0.75, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "try:\n from django.contrib.gis.utils.geoip import GeoIP, GeoIPException\n HAS_GEOIP = True\nexcept:\n HAS_GEOIP = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98674:ImportFrom_L19_C4", "label": "from django.contrib.gis.utils.geoip import GeoIP, GeoIPException", "type": "import", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98674:Try_L18_C0", "vector": [1, 1, 0.76, 0.04, 1, 0.25, 0.0, 800, 0, 2, 0, 0, 800, 0, 0], "semantic": {"name": "django.contrib.gis.utils.geoip", "arg_names": [], "import_names": ["GeoIP", "GeoIPException"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.gis.utils.geoip import GeoIP, GeoIPException"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98674:Assign_L20_C4", "label": "HAS_GEOIP =", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98674:Try_L18_C0", "vector": [14, 1, 0.8, 0.04, 1, 0.25, 1.0, 645, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "HAS_GEOIP", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " HAS_GEOIP = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98674:Assign_L22_C4", "label": "HAS_GEOIP =", "type": "assigned_variable", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98674:Try_L18_C0", "vector": [14, 1, 0.88, 0.04, 1, 0.25, 0.0, 645, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "HAS_GEOIP", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " HAS_GEOIP = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98674:ImportFrom_L24_C0", "label": "from django.contrib.gis.utils.wkt import precision_wkt", "type": "import", "loc": [24, 24], "level": 0, "parent": null, "vector": [1, 0, 0.96, 0.04, 0, 0.66, 1.0, 283, 0, 1, 0, 0, 283, 0, 0], "semantic": {"name": "django.contrib.gis.utils.wkt", "arg_names": [], "import_names": ["precision_wkt"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.utils.wkt import precision_wkt"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98674:If_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98674:ImportFrom_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98674:If_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98674:ImportFrom_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98674:If_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98674:ImportFrom_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98674:If_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98674:Try_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98674:Try_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98674:ImportFrom_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98674:Try_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98674:ImportFrom_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98674:Try_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98674:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98674:Try_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98674:Assign_L22_C4"}] |
from django.contrib.gis.gdal import SpatialReference
from django.db import connections, DEFAULT_DB_ALIAS
def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,
database=DEFAULT_DB_ALIAS):
"""
This function takes a GDAL SpatialReference system and adds its information
to the `spatial_ref_sys` table of the spatial backend. Doing this enables
database-level spatial transformations for the backend. Thus, this utility
is useful for adding spatial reference systems not included by default with
the backend -- for example, the so-called "Google Maps Mercator Projection"
is excluded in PostGIS 1.3 and below, and the following adds it to the
`spatial_ref_sys` table:
>>> from django.contrib.gis.utils import add_srs_entry
>>> add_srs_entry(900913)
Keyword Arguments:
auth_name:
This keyword may be customized with the value of the `auth_name` field.
Defaults to 'EPSG'.
auth_srid:
This keyword may be customized with the value of the `auth_srid` field.
Defaults to the SRID determined by GDAL.
ref_sys_name:
For SpatiaLite users only, sets the value of the the `ref_sys_name` field.
Defaults to the name determined by GDAL.
database:
The name of the database connection to use; the default is the value
of `django.db.DEFAULT_DB_ALIAS` (at the time of this writing, it's value
is 'default').
"""
connection = connections[database]
if not hasattr(connection.ops, 'spatial_version'):
raise Exception('The `add_srs_entry` utility only works '
'with spatial backends.')
if connection.ops.oracle or connection.ops.mysql:
raise Exception('This utility does not support the '
'Oracle or MySQL spatial backends.')
SpatialRefSys = connection.ops.spatial_ref_sys()
# If argument is not a `SpatialReference` instance, use it as parameter
# to construct a `SpatialReference` instance.
if not isinstance(srs, SpatialReference):
srs = SpatialReference(srs)
if srs.srid is None:
raise Exception('Spatial reference requires an SRID to be '
'compatible with the spatial backend.')
# Initializing the keyword arguments dictionary for both PostGIS
# and SpatiaLite.
kwargs = {'srid' : srs.srid,
'auth_name' : auth_name,
'auth_srid' : auth_srid or srs.srid,
'proj4text' : srs.proj4,
}
# Backend-specific fields for the SpatialRefSys model.
if connection.ops.postgis:
kwargs['srtext'] = srs.wkt
if connection.ops.spatialite:
kwargs['ref_sys_name'] = ref_sys_name or srs.name
# Creating the spatial_ref_sys model.
try:
# Try getting via SRID only, because using all kwargs may
# differ from exact wkt/proj in database.
sr = SpatialRefSys.objects.get(srid=srs.srid)
except SpatialRefSys.DoesNotExist:
sr = SpatialRefSys.objects.create(**kwargs)
# Alias is for backwards-compatibility purposes.
add_postgis_srs = add_srs_entry
| ajibawa-2023/Python-Code-Large/train/row_98675 | 20 | 77 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98675:ImportFrom_L1_C0", "label": "from django.contrib.gis.gdal import SpatialReference", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.013, 0.013, 0, 0.66, 0.0, 793, 0, 1, 0, 0, 793, 0, 0], "semantic": {"name": "django.contrib.gis.gdal", "arg_names": [], "import_names": ["SpatialReference"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.gdal import SpatialReference"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:ImportFrom_L2_C0", "label": "from django.db import connections, DEFAULT_DB_ALIAS", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.026, 0.013, 0, 0.66, 0.3333, 40, 0, 2, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["connections", "DEFAULT_DB_ALIAS"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import connections, DEFAULT_DB_ALIAS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "label": "add_srs_entry", "type": "function", "loc": [4, 74], "level": 0, "parent": null, "vector": [2, 0, 0.5065, 0.9221, 0, 0.66, 0.6667, 461, 0, 5, 0, 0, 0, 0, 9], "semantic": {"name": "add_srs_entry", "arg_names": ["srs", "auth_name", "auth_srid", "ref_sys_name", "database"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,\n database=DEFAULT_DB_ALIAS):\n \"\"\"\n This function takes a GDAL SpatialReference system and adds its information\n to the `spatial_ref_sys` table of the spatial backend. Doing this enables\n database-level spatial transformations for the backend. Thus, this utility\n is useful for adding spatial reference systems not included by default with\n the backend -- for example, the so-called \"Google Maps Mercator Projection\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:Expr_L6_C4", "label": "expression", "type": "expression", "loc": [6, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "vector": [8, 1, 0.2662, 0.3896, 1, 0.09, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This function takes a GDAL SpatialReference system and adds its information\n to the `spatial_ref_sys` table of the spatial backend. Doing this enables\n database-level spatial transformations for the backend. Thus, this utility\n is useful for adding spatial reference systems not included by default with\n the backend -- for example, the so-called \"Google Maps Mercator Projection\"\n is excluded in PostGIS 1.3 and below, and the following adds it to the\n `spatial_ref_sys` table:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L36_C4", "label": "connection =", "type": "assigned_variable", "loc": [36, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "vector": [14, 1, 0.4675, 0.013, 1, 0.09, 0.1, 351, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "connection", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " connection = connections[database]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L37_C4", "label": "if", "type": "if", "loc": [37, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "vector": [4, 1, 0.4935, 0.039, 1, 0.09, 0.2, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(connection.ops, 'spatial_version'):\n raise Exception('The `add_srs_entry` utility only works '\n 'with spatial backends.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L40_C4", "label": "if", "type": "if", "loc": [40, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "vector": [4, 1, 0.5325, 0.039, 1, 0.09, 0.3, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if connection.ops.oracle or connection.ops.mysql:\n raise Exception('This utility does not support the '\n 'Oracle or MySQL spatial backends.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L43_C4", "label": "SpatialRefSys = spatial_ref_sys()", "type": "assigned_variable", "loc": [43, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "vector": [14, 1, 0.5584, 0.013, 1, 0.09, 0.4, 219, 3, 0, 0, 0, 318, 10, 1], "semantic": {"name": "SpatialRefSys", "arg_names": [], "import_names": [], "rhs_call_name": "spatial_ref_sys", "annotation": ""}, "snippet": " SpatialRefSys = connection.ops.spatial_ref_sys()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L47_C4", "label": "if", "type": "if", "loc": [47, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "vector": [4, 1, 0.6169, 0.026, 1, 0.09, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(srs, SpatialReference):\n srs = SpatialReference(srs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L48_C8", "label": "srs = SpatialReference()", "type": "assigned_variable", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L47_C4", "vector": [14, 2, 0.6234, 0.013, 2, 0.52, 0.0, 95, 3, 1, 0, 0, 590, 10, 1], "semantic": {"name": "srs", "arg_names": [], "import_names": [], "rhs_call_name": "SpatialReference", "annotation": ""}, "snippet": " srs = SpatialReference(srs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L50_C4", "label": "if", "type": "if", "loc": [50, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "vector": [4, 1, 0.6623, 0.039, 1, 0.09, 0.6, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if srs.srid is None:\n raise Exception('Spatial reference requires an SRID to be '\n 'compatible with the spatial backend.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L56_C4", "label": "kwargs =", "type": "assigned_variable", "loc": [56, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "vector": [14, 1, 0.7532, 0.0649, 1, 0.09, 0.7, 987, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "kwargs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs = {'srid' : srs.srid,\n 'auth_name' : auth_name,\n 'auth_srid' : auth_srid or srs.srid,\n 'proj4text' : srs.proj4,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L63_C4", "label": "if", "type": "if", "loc": [63, 64], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "vector": [4, 1, 0.8247, 0.026, 1, 0.09, 0.8, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if connection.ops.postgis:\n kwargs['srtext'] = srs.wkt"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L64_C8", "label": "assign", "type": "assigned_variable", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L63_C4", "vector": [14, 2, 0.8312, 0.013, 2, 0.93, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs['srtext'] = srs.wkt"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L65_C4", "label": "if", "type": "if", "loc": [65, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "vector": [4, 1, 0.8506, 0.026, 1, 0.09, 0.9, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if connection.ops.spatialite:\n kwargs['ref_sys_name'] = ref_sys_name or srs.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L66_C8", "label": "assign", "type": "assigned_variable", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L65_C4", "vector": [14, 2, 0.8571, 0.013, 2, 0.18, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs['ref_sys_name'] = ref_sys_name or srs.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:Try_L69_C4", "label": "try", "type": "try", "loc": [69, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "vector": [7, 1, 0.9286, 0.0779, 1, 0.09, 1.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n # Try getting via SRID only, because using all kwargs may\n # differ from exact wkt/proj in database.\n sr = SpatialRefSys.objects.get(srid=srs.srid)\n except SpatialRefSys.DoesNotExist:\n sr = SpatialRefSys.objects.create(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L72_C8", "label": "sr = get()", "type": "assigned_variable", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:Try_L69_C4", "vector": [14, 2, 0.9351, 0.013, 2, 0.56, 0.0, 498, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "sr", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " sr = SpatialRefSys.objects.get(srid=srs.srid)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L74_C8", "label": "sr = create()", "type": "assigned_variable", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98675:Try_L69_C4", "vector": [14, 2, 0.961, 0.013, 2, 0.56, 0.0, 498, 3, 1, 0, 0, 316, 10, 1], "semantic": {"name": "sr", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " sr = SpatialRefSys.objects.create(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L77_C0", "label": "add_postgis_srs =", "type": "assigned_variable", "loc": [77, 77], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.013, 0, 0.66, 1.0, 752, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "add_postgis_srs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "add_postgis_srs = add_srs_entry"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:Expr_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L47_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L65_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:If_L65_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:FunctionDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:Try_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:Try_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98675:Try_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98675:Assign_L74_C8"}] |
from django.contrib.gis.sitemaps import GeoRSSSitemap, KMLSitemap, KMZSitemap
from models import City, Country
from feeds import feed_dict
sitemaps = {'kml' : KMLSitemap([City, Country]),
'kmz' : KMZSitemap([City, Country]),
'georss' : GeoRSSSitemap(feed_dict),
}
| ajibawa-2023/Python-Code-Large/train/row_98676 | 4 | 8 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98676:ImportFrom_L1_C0", "label": "from django.contrib.gis.sitemaps import GeoRSSSitemap, KMLSitemap, KMZSitemap", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.125, 0.125, 0, 0.66, 0.0, 123, 0, 3, 0, 0, 123, 0, 0], "semantic": {"name": "django.contrib.gis.sitemaps", "arg_names": [], "import_names": ["GeoRSSSitemap", "KMLSitemap", "KMZSitemap"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.sitemaps import GeoRSSSitemap, KMLSitemap, KMZSitemap"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98676:ImportFrom_L2_C0", "label": "from models import City, Country", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.25, 0.125, 0, 0.66, 0.3333, 495, 0, 2, 0, 0, 495, 0, 0], "semantic": {"name": "models", "arg_names": [], "import_names": ["City", "Country"], "rhs_call_name": "", "annotation": ""}, "snippet": "from models import City, Country"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98676:ImportFrom_L3_C0", "label": "from feeds import feed_dict", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.375, 0.125, 0, 0.66, 0.6667, 11, 0, 1, 0, 0, 11, 0, 0], "semantic": {"name": "feeds", "arg_names": [], "import_names": ["feed_dict"], "rhs_call_name": "", "annotation": ""}, "snippet": "from feeds import feed_dict"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98676:Assign_L5_C0", "label": "sitemaps =", "type": "assigned_variable", "loc": [5, 8], "level": 0, "parent": null, "vector": [14, 0, 0.8125, 0.5, 0, 0.66, 1.0, 855, 0, 0, 0, 0, 0, 6, 3], "semantic": {"name": "sitemaps", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "sitemaps = {'kml' : KMLSitemap([City, Country]),\n 'kmz' : KMZSitemap([City, Country]),\n 'georss' : GeoRSSSitemap(feed_dict),\n }"}] | [] |
from django.contrib.gis.db import models
from django.contrib.gis.tests.utils import mysql, spatialite
# MySQL spatial indices can't handle NULL geometries.
null_flag = not mysql
class Country(models.Model):
name = models.CharField(max_length=30)
mpoly = models.MultiPolygonField() # SRID, by default, is 4326
objects = models.GeoManager()
def __unicode__(self): return self.name
class City(models.Model):
name = models.CharField(max_length=30)
point = models.PointField()
objects = models.GeoManager()
def __unicode__(self): return self.name
# This is an inherited model from City
class PennsylvaniaCity(City):
county = models.CharField(max_length=30)
objects = models.GeoManager() # TODO: This should be implicitly inherited.
class State(models.Model):
name = models.CharField(max_length=30)
poly = models.PolygonField(null=null_flag) # Allowing NULL geometries here.
objects = models.GeoManager()
def __unicode__(self): return self.name
class Track(models.Model):
name = models.CharField(max_length=30)
line = models.LineStringField()
objects = models.GeoManager()
def __unicode__(self): return self.name
if not spatialite:
class Feature(models.Model):
name = models.CharField(max_length=20)
geom = models.GeometryField()
objects = models.GeoManager()
def __unicode__(self): return self.name
class MinusOneSRID(models.Model):
geom = models.PointField(srid=-1) # Minus one SRID.
objects = models.GeoManager()
| ajibawa-2023/Python-Code-Large/train/row_98677 | 40 | 45 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98677:ImportFrom_L1_C0", "label": "from django.contrib.gis.db import models", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0222, 0.0222, 0, 0.66, 0.0, 964, 0, 1, 0, 0, 964, 0, 0], "semantic": {"name": "django.contrib.gis.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:ImportFrom_L2_C0", "label": "from django.contrib.gis.tests.utils import mysql, spatialite", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0444, 0.0222, 0, 0.66, 0.125, 185, 0, 2, 0, 0, 185, 0, 0], "semantic": {"name": "django.contrib.gis.tests.utils", "arg_names": [], "import_names": ["mysql", "spatialite"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.tests.utils import mysql, spatialite"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L5_C0", "label": "null_flag =", "type": "assigned_variable", "loc": [5, 5], "level": 0, "parent": null, "vector": [14, 0, 0.1111, 0.0222, 0, 0.66, 0.25, 107, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "null_flag", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "null_flag = not mysql"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L7_C0", "label": "Country", "type": "class", "loc": [7, 11], "level": 0, "parent": null, "vector": [3, 0, 0.2, 0.1111, 0, 0.66, 0.375, 133, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "Country", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Country(models.Model):\n name = models.CharField(max_length=30)\n mpoly = models.MultiPolygonField() # SRID, by default, is 4326\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L8_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L7_C0", "vector": [14, 1, 0.1778, 0.0222, 1, 0.93, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L9_C4", "label": "mpoly = MultiPolygonField()", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L7_C0", "vector": [14, 1, 0.2, 0.0222, 1, 0.93, 0.3333, 634, 3, 0, 0, 0, 682, 10, 1], "semantic": {"name": "mpoly", "arg_names": [], "import_names": [], "rhs_call_name": "MultiPolygonField", "annotation": ""}, "snippet": " mpoly = models.MultiPolygonField() # SRID, by default, is 4326"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L10_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L7_C0", "vector": [14, 1, 0.2222, 0.0222, 1, 0.93, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L11_C4", "label": "__unicode__", "type": "function", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L7_C0", "vector": [2, 1, 0.2444, 0.0222, 1, 0.93, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Return_L11_C27", "label": "return", "type": "return", "loc": [11, 11], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L11_C4", "vector": [13, 2, 0.2444, 0.0222, 2, 0.96, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L13_C0", "label": "City", "type": "class", "loc": [13, 17], "level": 0, "parent": null, "vector": [3, 0, 0.3333, 0.1111, 0, 0.66, 0.5, 801, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "City", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class City(models.Model):\n name = models.CharField(max_length=30)\n point = models.PointField()\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L14_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L13_C0", "vector": [14, 1, 0.3111, 0.0222, 1, 0.09, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L15_C4", "label": "point = PointField()", "type": "assigned_variable", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L13_C0", "vector": [14, 1, 0.3333, 0.0222, 1, 0.09, 0.3333, 16, 3, 0, 0, 0, 260, 10, 1], "semantic": {"name": "point", "arg_names": [], "import_names": [], "rhs_call_name": "PointField", "annotation": ""}, "snippet": " point = models.PointField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L16_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L13_C0", "vector": [14, 1, 0.3556, 0.0222, 1, 0.09, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L17_C4", "label": "__unicode__", "type": "function", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L13_C0", "vector": [2, 1, 0.3778, 0.0222, 1, 0.09, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Return_L17_C27", "label": "return", "type": "return", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L17_C4", "vector": [13, 2, 0.3778, 0.0222, 2, 0.5, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L20_C0", "label": "PennsylvaniaCity", "type": "class", "loc": [20, 22], "level": 0, "parent": null, "vector": [3, 0, 0.4667, 0.0667, 0, 0.66, 0.625, 152, 0, 0, 0, 0, 801, 0, 2], "semantic": {"name": "PennsylvaniaCity", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PennsylvaniaCity(City):\n county = models.CharField(max_length=30)\n objects = models.GeoManager() # TODO: This should be implicitly inherited."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L21_C4", "label": "county = CharField()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L20_C0", "vector": [14, 1, 0.4667, 0.0222, 1, 0.35, 0.0, 257, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "county", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " county = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L22_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L20_C0", "vector": [14, 1, 0.4889, 0.0222, 1, 0.35, 1.0, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager() # TODO: This should be implicitly inherited."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L24_C0", "label": "State", "type": "class", "loc": [24, 28], "level": 0, "parent": null, "vector": [3, 0, 0.5778, 0.1111, 0, 0.66, 0.75, 110, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "State", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class State(models.Model):\n name = models.CharField(max_length=30)\n poly = models.PolygonField(null=null_flag) # Allowing NULL geometries here.\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L25_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [25, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L24_C0", "vector": [14, 1, 0.5556, 0.0222, 1, 0.24, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L26_C4", "label": "poly = PolygonField()", "type": "assigned_variable", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L24_C0", "vector": [14, 1, 0.5778, 0.0222, 1, 0.24, 0.3333, 365, 3, 1, 0, 0, 736, 10, 1], "semantic": {"name": "poly", "arg_names": [], "import_names": [], "rhs_call_name": "PolygonField", "annotation": ""}, "snippet": " poly = models.PolygonField(null=null_flag) # Allowing NULL geometries here."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L27_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [27, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L24_C0", "vector": [14, 1, 0.6, 0.0222, 1, 0.24, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L28_C4", "label": "__unicode__", "type": "function", "loc": [28, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L24_C0", "vector": [2, 1, 0.6222, 0.0222, 1, 0.24, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Return_L28_C27", "label": "return", "type": "return", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L28_C4", "vector": [13, 2, 0.6222, 0.0222, 2, 0.58, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L30_C0", "label": "Track", "type": "class", "loc": [30, 34], "level": 0, "parent": null, "vector": [3, 0, 0.7111, 0.1111, 0, 0.66, 0.875, 816, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "Track", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Track(models.Model):\n name = models.CharField(max_length=30)\n line = models.LineStringField()\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L31_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [31, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L30_C0", "vector": [14, 1, 0.6889, 0.0222, 1, 0.42, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L32_C4", "label": "line = LineStringField()", "type": "assigned_variable", "loc": [32, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L30_C0", "vector": [14, 1, 0.7111, 0.0222, 1, 0.42, 0.3333, 373, 3, 0, 0, 0, 237, 10, 1], "semantic": {"name": "line", "arg_names": [], "import_names": [], "rhs_call_name": "LineStringField", "annotation": ""}, "snippet": " line = models.LineStringField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L33_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [33, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L30_C0", "vector": [14, 1, 0.7333, 0.0222, 1, 0.42, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L34_C4", "label": "__unicode__", "type": "function", "loc": [34, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L30_C0", "vector": [2, 1, 0.7556, 0.0222, 1, 0.42, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Return_L34_C27", "label": "return", "type": "return", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L34_C4", "vector": [13, 2, 0.7556, 0.0222, 2, 0.26, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:If_L36_C0", "label": "if", "type": "if", "loc": [36, 45], "level": 0, "parent": null, "vector": [4, 0, 0.9, 0.2222, 0, 0.66, 1.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if not spatialite:\n class Feature(models.Model):\n name = models.CharField(max_length=20)\n geom = models.GeometryField()\n objects = models.GeoManager()\n def __unicode__(self): return self.name\n\n class MinusOneSRID(models.Model):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L37_C4", "label": "Feature", "type": "class", "loc": [37, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:If_L36_C0", "vector": [3, 1, 0.8667, 0.1111, 1, 0.69, 0.0, 382, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "Feature", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class Feature(models.Model):\n name = models.CharField(max_length=20)\n geom = models.GeometryField()\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L38_C8", "label": "name = CharField()", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L37_C4", "vector": [14, 2, 0.8444, 0.0222, 2, 0.99, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=20)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L39_C8", "label": "geom = GeometryField()", "type": "assigned_variable", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L37_C4", "vector": [14, 2, 0.8667, 0.0222, 2, 0.99, 0.3333, 5, 3, 0, 0, 0, 100, 10, 1], "semantic": {"name": "geom", "arg_names": [], "import_names": [], "rhs_call_name": "GeometryField", "annotation": ""}, "snippet": " geom = models.GeometryField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L40_C8", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L37_C4", "vector": [14, 2, 0.8889, 0.0222, 2, 0.99, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L41_C8", "label": "__unicode__", "type": "function", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L37_C4", "vector": [2, 2, 0.9111, 0.0222, 2, 0.99, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Return_L41_C31", "label": "return", "type": "return", "loc": [41, 41], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L41_C8", "vector": [13, 3, 0.9111, 0.0222, 3, 0.57, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L43_C4", "label": "MinusOneSRID", "type": "class", "loc": [43, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:If_L36_C0", "vector": [3, 1, 0.9778, 0.0667, 1, 0.69, 1.0, 154, 0, 0, 0, 0, 996, 0, 2], "semantic": {"name": "MinusOneSRID", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class MinusOneSRID(models.Model):\n geom = models.PointField(srid=-1) # Minus one SRID.\n objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L44_C8", "label": "geom = PointField()", "type": "assigned_variable", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L43_C4", "vector": [14, 2, 0.9778, 0.0222, 2, 0.03, 0.0, 5, 3, 1, 0, 0, 260, 10, 1], "semantic": {"name": "geom", "arg_names": [], "import_names": [], "rhs_call_name": "PointField", "annotation": ""}, "snippet": " geom = models.PointField(srid=-1) # Minus one SRID."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L45_C8", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L43_C4", "vector": [14, 2, 1.0, 0.0222, 2, 0.03, 1.0, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Return_L11_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Return_L17_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Return_L28_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L30_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L31_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L30_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L32_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L30_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L30_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Return_L34_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:If_L36_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:FunctionDef_L41_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Return_L41_C31"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:If_L36_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98677:ClassDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98677:Assign_L45_C8"}] |
import re, os, unittest
from django.db import connection
from django.contrib.gis import gdal
from django.contrib.gis.geos import *
from django.contrib.gis.measure import Distance
from django.contrib.gis.tests.utils import \
no_mysql, no_oracle, no_postgis, no_spatialite, \
mysql, oracle, postgis, spatialite
from django.test import TestCase
from models import Country, City, PennsylvaniaCity, State, Track
if not spatialite:
from models import Feature, MinusOneSRID
class GeoModelTest(TestCase):
def test01_fixtures(self):
"Testing geographic model initialization from fixtures."
# Ensuring that data was loaded from initial data fixtures.
self.assertEqual(2, Country.objects.count())
self.assertEqual(8, City.objects.count())
self.assertEqual(2, State.objects.count())
def test02_proxy(self):
"Testing Lazy-Geometry support (using the GeometryProxy)."
## Testing on a Point
pnt = Point(0, 0)
nullcity = City(name='NullCity', point=pnt)
nullcity.save()
# Making sure TypeError is thrown when trying to set with an
# incompatible type.
for bad in [5, 2.0, LineString((0, 0), (1, 1))]:
try:
nullcity.point = bad
except TypeError:
pass
else:
self.fail('Should throw a TypeError')
# Now setting with a compatible GEOS Geometry, saving, and ensuring
# the save took, notice no SRID is explicitly set.
new = Point(5, 23)
nullcity.point = new
# Ensuring that the SRID is automatically set to that of the
# field after assignment, but before saving.
self.assertEqual(4326, nullcity.point.srid)
nullcity.save()
# Ensuring the point was saved correctly after saving
self.assertEqual(new, City.objects.get(name='NullCity').point)
# Setting the X and Y of the Point
nullcity.point.x = 23
nullcity.point.y = 5
# Checking assignments pre & post-save.
self.assertNotEqual(Point(23, 5), City.objects.get(name='NullCity').point)
nullcity.save()
self.assertEqual(Point(23, 5), City.objects.get(name='NullCity').point)
nullcity.delete()
## Testing on a Polygon
shell = LinearRing((0, 0), (0, 100), (100, 100), (100, 0), (0, 0))
inner = LinearRing((40, 40), (40, 60), (60, 60), (60, 40), (40, 40))
# Creating a State object using a built Polygon
ply = Polygon(shell, inner)
nullstate = State(name='NullState', poly=ply)
self.assertEqual(4326, nullstate.poly.srid) # SRID auto-set from None
nullstate.save()
ns = State.objects.get(name='NullState')
self.assertEqual(ply, ns.poly)
# Testing the `ogr` and `srs` lazy-geometry properties.
if gdal.HAS_GDAL:
self.assertEqual(True, isinstance(ns.poly.ogr, gdal.OGRGeometry))
self.assertEqual(ns.poly.wkb, ns.poly.ogr.wkb)
self.assertEqual(True, isinstance(ns.poly.srs, gdal.SpatialReference))
self.assertEqual('WGS 84', ns.poly.srs.name)
# Changing the interior ring on the poly attribute.
new_inner = LinearRing((30, 30), (30, 70), (70, 70), (70, 30), (30, 30))
ns.poly[1] = new_inner
ply[1] = new_inner
self.assertEqual(4326, ns.poly.srid)
ns.save()
self.assertEqual(ply, State.objects.get(name='NullState').poly)
ns.delete()
def test03a_kml(self):
"Testing KML output from the database using GeoQuerySet.kml()."
# Only PostGIS supports KML serialization
if not postgis:
self.assertRaises(NotImplementedError, State.objects.all().kml, field_name='poly')
return
# Should throw a TypeError when trying to obtain KML from a
# non-geometry field.
qs = City.objects.all()
self.assertRaises(TypeError, qs.kml, 'name')
# The reference KML depends on the version of PostGIS used
# (the output stopped including altitude in 1.3.3).
if connection.ops.spatial_version >= (1, 3, 3):
ref_kml = '<Point><coordinates>-104.609252,38.255001</coordinates></Point>'
else:
ref_kml = '<Point><coordinates>-104.609252,38.255001,0</coordinates></Point>'
# Ensuring the KML is as expected.
ptown1 = City.objects.kml(field_name='point', precision=9).get(name='Pueblo')
ptown2 = City.objects.kml(precision=9).get(name='Pueblo')
for ptown in [ptown1, ptown2]:
self.assertEqual(ref_kml, ptown.kml)
def test03b_gml(self):
"Testing GML output from the database using GeoQuerySet.gml()."
if mysql or spatialite:
self.assertRaises(NotImplementedError, Country.objects.all().gml, field_name='mpoly')
return
# Should throw a TypeError when tyring to obtain GML from a
# non-geometry field.
qs = City.objects.all()
self.assertRaises(TypeError, qs.gml, field_name='name')
ptown1 = City.objects.gml(field_name='point', precision=9).get(name='Pueblo')
ptown2 = City.objects.gml(precision=9).get(name='Pueblo')
if oracle:
# No precision parameter for Oracle :-/
gml_regex = re.compile(r'^<gml:Point srsName="SDO:4326" xmlns:gml="http://www.opengis.net/gml"><gml:coordinates decimal="\." cs="," ts=" ">-104.60925\d+,38.25500\d+ </gml:coordinates></gml:Point>')
for ptown in [ptown1, ptown2]:
self.failUnless(gml_regex.match(ptown.gml))
else:
gml_regex = re.compile(r'^<gml:Point srsName="EPSG:4326"><gml:coordinates>-104\.60925\d+,38\.255001</gml:coordinates></gml:Point>')
for ptown in [ptown1, ptown2]:
self.failUnless(gml_regex.match(ptown.gml))
def test03c_geojson(self):
"Testing GeoJSON output from the database using GeoQuerySet.geojson()."
# Only PostGIS 1.3.4+ supports GeoJSON.
if not connection.ops.geojson:
self.assertRaises(NotImplementedError, Country.objects.all().geojson, field_name='mpoly')
return
if connection.ops.spatial_version >= (1, 4, 0):
pueblo_json = '{"type":"Point","coordinates":[-104.609252,38.255001]}'
houston_json = '{"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"coordinates":[-95.363151,29.763374]}'
victoria_json = '{"type":"Point","bbox":[-123.30519600,48.46261100,-123.30519600,48.46261100],"coordinates":[-123.305196,48.462611]}'
chicago_json = '{"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"bbox":[-87.65018,41.85039,-87.65018,41.85039],"coordinates":[-87.65018,41.85039]}'
else:
pueblo_json = '{"type":"Point","coordinates":[-104.60925200,38.25500100]}'
houston_json = '{"type":"Point","crs":{"type":"EPSG","properties":{"EPSG":4326}},"coordinates":[-95.36315100,29.76337400]}'
victoria_json = '{"type":"Point","bbox":[-123.30519600,48.46261100,-123.30519600,48.46261100],"coordinates":[-123.30519600,48.46261100]}'
chicago_json = '{"type":"Point","crs":{"type":"EPSG","properties":{"EPSG":4326}},"bbox":[-87.65018,41.85039,-87.65018,41.85039],"coordinates":[-87.65018,41.85039]}'
# Precision argument should only be an integer
self.assertRaises(TypeError, City.objects.geojson, precision='foo')
# Reference queries and values.
# SELECT ST_AsGeoJson("geoapp_city"."point", 8, 0) FROM "geoapp_city" WHERE "geoapp_city"."name" = 'Pueblo';
self.assertEqual(pueblo_json, City.objects.geojson().get(name='Pueblo').geojson)
# 1.3.x: SELECT ST_AsGeoJson("geoapp_city"."point", 8, 1) FROM "geoapp_city" WHERE "geoapp_city"."name" = 'Houston';
# 1.4.x: SELECT ST_AsGeoJson("geoapp_city"."point", 8, 2) FROM "geoapp_city" WHERE "geoapp_city"."name" = 'Houston';
# This time we want to include the CRS by using the `crs` keyword.
self.assertEqual(houston_json, City.objects.geojson(crs=True, model_att='json').get(name='Houston').json)
# 1.3.x: SELECT ST_AsGeoJson("geoapp_city"."point", 8, 2) FROM "geoapp_city" WHERE "geoapp_city"."name" = 'Victoria';
# 1.4.x: SELECT ST_AsGeoJson("geoapp_city"."point", 8, 1) FROM "geoapp_city" WHERE "geoapp_city"."name" = 'Houston';
# This time we include the bounding box by using the `bbox` keyword.
self.assertEqual(victoria_json, City.objects.geojson(bbox=True).get(name='Victoria').geojson)
# 1.(3|4).x: SELECT ST_AsGeoJson("geoapp_city"."point", 5, 3) FROM "geoapp_city" WHERE "geoapp_city"."name" = 'Chicago';
# Finally, we set every available keyword.
self.assertEqual(chicago_json, City.objects.geojson(bbox=True, crs=True, precision=5).get(name='Chicago').geojson)
def test03d_svg(self):
"Testing SVG output using GeoQuerySet.svg()."
if mysql or oracle:
self.assertRaises(NotImplementedError, City.objects.svg)
return
self.assertRaises(TypeError, City.objects.svg, precision='foo')
# SELECT AsSVG(geoapp_city.point, 0, 8) FROM geoapp_city WHERE name = 'Pueblo';
svg1 = 'cx="-104.609252" cy="-38.255001"'
# Even though relative, only one point so it's practically the same except for
# the 'c' letter prefix on the x,y values.
svg2 = svg1.replace('c', '')
self.assertEqual(svg1, City.objects.svg().get(name='Pueblo').svg)
self.assertEqual(svg2, City.objects.svg(relative=5).get(name='Pueblo').svg)
@no_mysql
def test04_transform(self):
"Testing the transform() GeoManager method."
# Pre-transformed points for Houston and Pueblo.
htown = fromstr('POINT(1947516.83115183 6322297.06040572)', srid=3084)
ptown = fromstr('POINT(992363.390841912 481455.395105533)', srid=2774)
prec = 3 # Precision is low due to version variations in PROJ and GDAL.
# Asserting the result of the transform operation with the values in
# the pre-transformed points. Oracle does not have the 3084 SRID.
if not oracle:
h = City.objects.transform(htown.srid).get(name='Houston')
self.assertEqual(3084, h.point.srid)
self.assertAlmostEqual(htown.x, h.point.x, prec)
self.assertAlmostEqual(htown.y, h.point.y, prec)
p1 = City.objects.transform(ptown.srid, field_name='point').get(name='Pueblo')
p2 = City.objects.transform(srid=ptown.srid).get(name='Pueblo')
for p in [p1, p2]:
self.assertEqual(2774, p.point.srid)
self.assertAlmostEqual(ptown.x, p.point.x, prec)
self.assertAlmostEqual(ptown.y, p.point.y, prec)
@no_mysql
@no_spatialite # SpatiaLite does not have an Extent function
def test05_extent(self):
"Testing the `extent` GeoQuerySet method."
# Reference query:
# `SELECT ST_extent(point) FROM geoapp_city WHERE (name='Houston' or name='Dallas');`
# => BOX(-96.8016128540039 29.7633724212646,-95.3631439208984 32.7820587158203)
expected = (-96.8016128540039, 29.7633724212646, -95.3631439208984, 32.782058715820)
qs = City.objects.filter(name__in=('Houston', 'Dallas'))
extent = qs.extent()
for val, exp in zip(extent, expected):
self.assertAlmostEqual(exp, val, 4)
# Only PostGIS has support for the MakeLine aggregate.
@no_mysql
@no_oracle
@no_spatialite
def test06_make_line(self):
"Testing the `make_line` GeoQuerySet method."
# Ensuring that a `TypeError` is raised on models without PointFields.
self.assertRaises(TypeError, State.objects.make_line)
self.assertRaises(TypeError, Country.objects.make_line)
# Reference query:
# SELECT AsText(ST_MakeLine(geoapp_city.point)) FROM geoapp_city;
ref_line = GEOSGeometry('LINESTRING(-95.363151 29.763374,-96.801611 32.782057,-97.521157 34.464642,174.783117 -41.315268,-104.609252 38.255001,-95.23506 38.971823,-87.650175 41.850385,-123.305196 48.462611)', srid=4326)
self.assertEqual(ref_line, City.objects.make_line())
@no_mysql
def test09_disjoint(self):
"Testing the `disjoint` lookup type."
ptown = City.objects.get(name='Pueblo')
qs1 = City.objects.filter(point__disjoint=ptown.point)
self.assertEqual(7, qs1.count())
qs2 = State.objects.filter(poly__disjoint=ptown.point)
self.assertEqual(1, qs2.count())
self.assertEqual('Kansas', qs2[0].name)
def test10_contains_contained(self):
"Testing the 'contained', 'contains', and 'bbcontains' lookup types."
# Getting Texas, yes we were a country -- once ;)
texas = Country.objects.get(name='Texas')
# Seeing what cities are in Texas, should get Houston and Dallas,
# and Oklahoma City because 'contained' only checks on the
# _bounding box_ of the Geometries.
if not oracle:
qs = City.objects.filter(point__contained=texas.mpoly)
self.assertEqual(3, qs.count())
cities = ['Houston', 'Dallas', 'Oklahoma City']
for c in qs: self.assertEqual(True, c.name in cities)
# Pulling out some cities.
houston = City.objects.get(name='Houston')
wellington = City.objects.get(name='Wellington')
pueblo = City.objects.get(name='Pueblo')
okcity = City.objects.get(name='Oklahoma City')
lawrence = City.objects.get(name='Lawrence')
# Now testing contains on the countries using the points for
# Houston and Wellington.
tx = Country.objects.get(mpoly__contains=houston.point) # Query w/GEOSGeometry
nz = Country.objects.get(mpoly__contains=wellington.point.hex) # Query w/EWKBHEX
self.assertEqual('Texas', tx.name)
self.assertEqual('New Zealand', nz.name)
# Spatialite 2.3 thinks that Lawrence is in Puerto Rico (a NULL geometry).
if not spatialite:
ks = State.objects.get(poly__contains=lawrence.point)
self.assertEqual('Kansas', ks.name)
# Pueblo and Oklahoma City (even though OK City is within the bounding box of Texas)
# are not contained in Texas or New Zealand.
self.assertEqual(0, len(Country.objects.filter(mpoly__contains=pueblo.point))) # Query w/GEOSGeometry object
self.assertEqual((mysql and 1) or 0,
len(Country.objects.filter(mpoly__contains=okcity.point.wkt))) # Qeury w/WKT
# OK City is contained w/in bounding box of Texas.
if not oracle:
qs = Country.objects.filter(mpoly__bbcontains=okcity.point)
self.assertEqual(1, len(qs))
self.assertEqual('Texas', qs[0].name)
@no_mysql
def test11_lookup_insert_transform(self):
"Testing automatic transform for lookups and inserts."
# San Antonio in 'WGS84' (SRID 4326)
sa_4326 = 'POINT (-98.493183 29.424170)'
wgs_pnt = fromstr(sa_4326, srid=4326) # Our reference point in WGS84
# Oracle doesn't have SRID 3084, using 41157.
if oracle:
# San Antonio in 'Texas 4205, Southern Zone (1983, meters)' (SRID 41157)
# Used the following Oracle SQL to get this value:
# SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_CS.TRANSFORM(SDO_GEOMETRY('POINT (-98.493183 29.424170)', 4326), 41157)) FROM DUAL;
nad_wkt = 'POINT (300662.034646583 5416427.45974934)'
nad_srid = 41157
else:
# San Antonio in 'NAD83(HARN) / Texas Centric Lambert Conformal' (SRID 3084)
nad_wkt = 'POINT (1645978.362408288754523 6276356.025927528738976)' # Used ogr.py in gdal 1.4.1 for this transform
nad_srid = 3084
# Constructing & querying with a point from a different SRID. Oracle
# `SDO_OVERLAPBDYINTERSECT` operates differently from
# `ST_Intersects`, so contains is used instead.
nad_pnt = fromstr(nad_wkt, srid=nad_srid)
if oracle:
tx = Country.objects.get(mpoly__contains=nad_pnt)
else:
tx = Country.objects.get(mpoly__intersects=nad_pnt)
self.assertEqual('Texas', tx.name)
# Creating San Antonio. Remember the Alamo.
sa = City.objects.create(name='San Antonio', point=nad_pnt)
# Now verifying that San Antonio was transformed correctly
sa = City.objects.get(name='San Antonio')
self.assertAlmostEqual(wgs_pnt.x, sa.point.x, 6)
self.assertAlmostEqual(wgs_pnt.y, sa.point.y, 6)
# If the GeometryField SRID is -1, then we shouldn't perform any
# transformation if the SRID of the input geometry is different.
# SpatiaLite does not support missing SRID values.
if not spatialite:
m1 = MinusOneSRID(geom=Point(17, 23, srid=4326))
m1.save()
self.assertEqual(-1, m1.geom.srid)
@no_mysql
def test12_null_geometries(self):
"Testing NULL geometry support, and the `isnull` lookup type."
# Creating a state with a NULL boundary.
State.objects.create(name='Puerto Rico')
# Querying for both NULL and Non-NULL values.
nullqs = State.objects.filter(poly__isnull=True)
validqs = State.objects.filter(poly__isnull=False)
# Puerto Rico should be NULL (it's a commonwealth unincorporated territory)
self.assertEqual(1, len(nullqs))
self.assertEqual('Puerto Rico', nullqs[0].name)
# The valid states should be Colorado & Kansas
self.assertEqual(2, len(validqs))
state_names = [s.name for s in validqs]
self.assertEqual(True, 'Colorado' in state_names)
self.assertEqual(True, 'Kansas' in state_names)
# Saving another commonwealth w/a NULL geometry.
nmi = State.objects.create(name='Northern Mariana Islands', poly=None)
self.assertEqual(nmi.poly, None)
# Assigning a geomery and saving -- then UPDATE back to NULL.
nmi.poly = 'POLYGON((0 0,1 0,1 1,1 0,0 0))'
nmi.save()
State.objects.filter(name='Northern Mariana Islands').update(poly=None)
self.assertEqual(None, State.objects.get(name='Northern Mariana Islands').poly)
# Only PostGIS has `left` and `right` lookup types.
@no_mysql
@no_oracle
@no_spatialite
def test13_left_right(self):
"Testing the 'left' and 'right' lookup types."
# Left: A << B => true if xmax(A) < xmin(B)
# Right: A >> B => true if xmin(A) > xmax(B)
# See: BOX2D_left() and BOX2D_right() in lwgeom_box2dfloat4.c in PostGIS source.
# Getting the borders for Colorado & Kansas
co_border = State.objects.get(name='Colorado').poly
ks_border = State.objects.get(name='Kansas').poly
# Note: Wellington has an 'X' value of 174, so it will not be considered
# to the left of CO.
# These cities should be strictly to the right of the CO border.
cities = ['Houston', 'Dallas', 'Oklahoma City',
'Lawrence', 'Chicago', 'Wellington']
qs = City.objects.filter(point__right=co_border)
self.assertEqual(6, len(qs))
for c in qs: self.assertEqual(True, c.name in cities)
# These cities should be strictly to the right of the KS border.
cities = ['Chicago', 'Wellington']
qs = City.objects.filter(point__right=ks_border)
self.assertEqual(2, len(qs))
for c in qs: self.assertEqual(True, c.name in cities)
# Note: Wellington has an 'X' value of 174, so it will not be considered
# to the left of CO.
vic = City.objects.get(point__left=co_border)
self.assertEqual('Victoria', vic.name)
cities = ['Pueblo', 'Victoria']
qs = City.objects.filter(point__left=ks_border)
self.assertEqual(2, len(qs))
for c in qs: self.assertEqual(True, c.name in cities)
def test14_equals(self):
"Testing the 'same_as' and 'equals' lookup types."
pnt = fromstr('POINT (-95.363151 29.763374)', srid=4326)
c1 = City.objects.get(point=pnt)
c2 = City.objects.get(point__same_as=pnt)
c3 = City.objects.get(point__equals=pnt)
for c in [c1, c2, c3]: self.assertEqual('Houston', c.name)
@no_mysql
def test15_relate(self):
"Testing the 'relate' lookup type."
# To make things more interesting, we will have our Texas reference point in
# different SRIDs.
pnt1 = fromstr('POINT (649287.0363174 4177429.4494686)', srid=2847)
pnt2 = fromstr('POINT(-98.4919715741052 29.4333344025053)', srid=4326)
# Not passing in a geometry as first param shoud
# raise a type error when initializing the GeoQuerySet
self.assertRaises(ValueError, Country.objects.filter, mpoly__relate=(23, 'foo'))
# Making sure the right exception is raised for the given
# bad arguments.
for bad_args, e in [((pnt1, 0), ValueError), ((pnt2, 'T*T***FF*', 0), ValueError)]:
qs = Country.objects.filter(mpoly__relate=bad_args)
self.assertRaises(e, qs.count)
# Relate works differently for the different backends.
if postgis or spatialite:
contains_mask = 'T*T***FF*'
within_mask = 'T*F**F***'
intersects_mask = 'T********'
elif oracle:
contains_mask = 'contains'
within_mask = 'inside'
# TODO: This is not quite the same as the PostGIS mask above
intersects_mask = 'overlapbdyintersect'
# Testing contains relation mask.
self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt1, contains_mask)).name)
self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt2, contains_mask)).name)
# Testing within relation mask.
ks = State.objects.get(name='Kansas')
self.assertEqual('Lawrence', City.objects.get(point__relate=(ks.poly, within_mask)).name)
# Testing intersection relation mask.
if not oracle:
self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt1, intersects_mask)).name)
self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt2, intersects_mask)).name)
self.assertEqual('Lawrence', City.objects.get(point__relate=(ks.poly, intersects_mask)).name)
def test16_createnull(self):
"Testing creating a model instance and the geometry being None"
c = City()
self.assertEqual(c.point, None)
@no_mysql
def test17_unionagg(self):
"Testing the `unionagg` (aggregate union) GeoManager method."
tx = Country.objects.get(name='Texas').mpoly
# Houston, Dallas -- Oracle has different order.
union1 = fromstr('MULTIPOINT(-96.801611 32.782057,-95.363151 29.763374)')
union2 = fromstr('MULTIPOINT(-96.801611 32.782057,-95.363151 29.763374)')
qs = City.objects.filter(point__within=tx)
self.assertRaises(TypeError, qs.unionagg, 'name')
# Using `field_name` keyword argument in one query and specifying an
# order in the other (which should not be used because this is
# an aggregate method on a spatial column)
u1 = qs.unionagg(field_name='point')
u2 = qs.order_by('name').unionagg()
tol = 0.00001
if oracle:
union = union2
else:
union = union1
self.assertEqual(True, union.equals_exact(u1, tol))
self.assertEqual(True, union.equals_exact(u2, tol))
qs = City.objects.filter(name='NotACity')
self.assertEqual(None, qs.unionagg(field_name='point'))
@no_spatialite # SpatiaLite does not support abstract geometry columns
def test18_geometryfield(self):
"Testing the general GeometryField."
Feature(name='Point', geom=Point(1, 1)).save()
Feature(name='LineString', geom=LineString((0, 0), (1, 1), (5, 5))).save()
Feature(name='Polygon', geom=Polygon(LinearRing((0, 0), (0, 5), (5, 5), (5, 0), (0, 0)))).save()
Feature(name='GeometryCollection',
geom=GeometryCollection(Point(2, 2), LineString((0, 0), (2, 2)),
Polygon(LinearRing((0, 0), (0, 5), (5, 5), (5, 0), (0, 0))))).save()
f_1 = Feature.objects.get(name='Point')
self.assertEqual(True, isinstance(f_1.geom, Point))
self.assertEqual((1.0, 1.0), f_1.geom.tuple)
f_2 = Feature.objects.get(name='LineString')
self.assertEqual(True, isinstance(f_2.geom, LineString))
self.assertEqual(((0.0, 0.0), (1.0, 1.0), (5.0, 5.0)), f_2.geom.tuple)
f_3 = Feature.objects.get(name='Polygon')
self.assertEqual(True, isinstance(f_3.geom, Polygon))
f_4 = Feature.objects.get(name='GeometryCollection')
self.assertEqual(True, isinstance(f_4.geom, GeometryCollection))
self.assertEqual(f_3.geom, f_4.geom[2])
@no_mysql
def test19_centroid(self):
"Testing the `centroid` GeoQuerySet method."
qs = State.objects.exclude(poly__isnull=True).centroid()
if oracle:
tol = 0.1
elif spatialite:
tol = 0.000001
else:
tol = 0.000000001
for s in qs:
self.assertEqual(True, s.poly.centroid.equals_exact(s.centroid, tol))
@no_mysql
def test20_pointonsurface(self):
"Testing the `point_on_surface` GeoQuerySet method."
# Reference values.
if oracle:
# SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_GEOM.SDO_POINTONSURFACE(GEOAPP_COUNTRY.MPOLY, 0.05)) FROM GEOAPP_COUNTRY;
ref = {'New Zealand' : fromstr('POINT (174.616364 -36.100861)', srid=4326),
'Texas' : fromstr('POINT (-103.002434 36.500397)', srid=4326),
}
elif postgis or spatialite:
# Using GEOSGeometry to compute the reference point on surface values
# -- since PostGIS also uses GEOS these should be the same.
ref = {'New Zealand' : Country.objects.get(name='New Zealand').mpoly.point_on_surface,
'Texas' : Country.objects.get(name='Texas').mpoly.point_on_surface
}
for c in Country.objects.point_on_surface():
if spatialite:
# XXX This seems to be a WKT-translation-related precision issue?
tol = 0.00001
else:
tol = 0.000000001
self.assertEqual(True, ref[c.name].equals_exact(c.point_on_surface, tol))
@no_mysql
@no_oracle
def test21_scale(self):
"Testing the `scale` GeoQuerySet method."
xfac, yfac = 2, 3
tol = 5 # XXX The low precision tolerance is for SpatiaLite
qs = Country.objects.scale(xfac, yfac, model_att='scaled')
for c in qs:
for p1, p2 in zip(c.mpoly, c.scaled):
for r1, r2 in zip(p1, p2):
for c1, c2 in zip(r1.coords, r2.coords):
self.assertAlmostEqual(c1[0] * xfac, c2[0], tol)
self.assertAlmostEqual(c1[1] * yfac, c2[1], tol)
@no_mysql
@no_oracle
def test22_translate(self):
"Testing the `translate` GeoQuerySet method."
xfac, yfac = 5, -23
qs = Country.objects.translate(xfac, yfac, model_att='translated')
for c in qs:
for p1, p2 in zip(c.mpoly, c.translated):
for r1, r2 in zip(p1, p2):
for c1, c2 in zip(r1.coords, r2.coords):
# XXX The low precision is for SpatiaLite
self.assertAlmostEqual(c1[0] + xfac, c2[0], 5)
self.assertAlmostEqual(c1[1] + yfac, c2[1], 5)
@no_mysql
def test23_numgeom(self):
"Testing the `num_geom` GeoQuerySet method."
# Both 'countries' only have two geometries.
for c in Country.objects.num_geom(): self.assertEqual(2, c.num_geom)
for c in City.objects.filter(point__isnull=False).num_geom():
# Oracle will return 1 for the number of geometries on non-collections,
# whereas PostGIS will return None.
if postgis:
self.assertEqual(None, c.num_geom)
else:
self.assertEqual(1, c.num_geom)
@no_mysql
@no_spatialite # SpatiaLite can only count vertices in LineStrings
def test24_numpoints(self):
"Testing the `num_points` GeoQuerySet method."
for c in Country.objects.num_points():
self.assertEqual(c.mpoly.num_points, c.num_points)
if not oracle:
# Oracle cannot count vertices in Point geometries.
for c in City.objects.num_points(): self.assertEqual(1, c.num_points)
@no_mysql
def test25_geoset(self):
"Testing the `difference`, `intersection`, `sym_difference`, and `union` GeoQuerySet methods."
geom = Point(5, 23)
tol = 1
qs = Country.objects.all().difference(geom).sym_difference(geom).union(geom)
# XXX For some reason SpatiaLite does something screwey with the Texas geometry here. Also,
# XXX it doesn't like the null intersection.
if spatialite:
qs = qs.exclude(name='Texas')
else:
qs = qs.intersection(geom)
for c in qs:
if oracle:
# Should be able to execute the queries; however, they won't be the same
# as GEOS (because Oracle doesn't use GEOS internally like PostGIS or
# SpatiaLite).
pass
else:
self.assertEqual(c.mpoly.difference(geom), c.difference)
if not spatialite:
self.assertEqual(c.mpoly.intersection(geom), c.intersection)
self.assertEqual(c.mpoly.sym_difference(geom), c.sym_difference)
self.assertEqual(c.mpoly.union(geom), c.union)
@no_mysql
def test26_inherited_geofields(self):
"Test GeoQuerySet methods on inherited Geometry fields."
# Creating a Pennsylvanian city.
mansfield = PennsylvaniaCity.objects.create(name='Mansfield', county='Tioga', point='POINT(-77.071445 41.823881)')
# All transformation SQL will need to be performed on the
# _parent_ table.
qs = PennsylvaniaCity.objects.transform(32128)
self.assertEqual(1, qs.count())
for pc in qs: self.assertEqual(32128, pc.point.srid)
@no_mysql
@no_oracle
@no_spatialite
def test27_snap_to_grid(self):
"Testing GeoQuerySet.snap_to_grid()."
# Let's try and break snap_to_grid() with bad combinations of arguments.
for bad_args in ((), range(3), range(5)):
self.assertRaises(ValueError, Country.objects.snap_to_grid, *bad_args)
for bad_args in (('1.0',), (1.0, None), tuple(map(unicode, range(4)))):
self.assertRaises(TypeError, Country.objects.snap_to_grid, *bad_args)
# Boundary for San Marino, courtesy of Bjorn Sandvik of thematicmapping.org
# from the world borders dataset he provides.
wkt = ('MULTIPOLYGON(((12.41580 43.95795,12.45055 43.97972,12.45389 43.98167,'
'12.46250 43.98472,12.47167 43.98694,12.49278 43.98917,'
'12.50555 43.98861,12.51000 43.98694,12.51028 43.98277,'
'12.51167 43.94333,12.51056 43.93916,12.49639 43.92333,'
'12.49500 43.91472,12.48778 43.90583,12.47444 43.89722,'
'12.46472 43.89555,12.45917 43.89611,12.41639 43.90472,'
'12.41222 43.90610,12.40782 43.91366,12.40389 43.92667,'
'12.40500 43.94833,12.40889 43.95499,12.41580 43.95795)))')
sm = Country.objects.create(name='San Marino', mpoly=fromstr(wkt))
# Because floating-point arithmitic isn't exact, we set a tolerance
# to pass into GEOS `equals_exact`.
tol = 0.000000001
# SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.1)) FROM "geoapp_country" WHERE "geoapp_country"."name" = 'San Marino';
ref = fromstr('MULTIPOLYGON(((12.4 44,12.5 44,12.5 43.9,12.4 43.9,12.4 44)))')
self.failUnless(ref.equals_exact(Country.objects.snap_to_grid(0.1).get(name='San Marino').snap_to_grid, tol))
# SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.05, 0.23)) FROM "geoapp_country" WHERE "geoapp_country"."name" = 'San Marino';
ref = fromstr('MULTIPOLYGON(((12.4 43.93,12.45 43.93,12.5 43.93,12.45 43.93,12.4 43.93)))')
self.failUnless(ref.equals_exact(Country.objects.snap_to_grid(0.05, 0.23).get(name='San Marino').snap_to_grid, tol))
# SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.5, 0.17, 0.05, 0.23)) FROM "geoapp_country" WHERE "geoapp_country"."name" = 'San Marino';
ref = fromstr('MULTIPOLYGON(((12.4 43.87,12.45 43.87,12.45 44.1,12.5 44.1,12.5 43.87,12.45 43.87,12.4 43.87)))')
self.failUnless(ref.equals_exact(Country.objects.snap_to_grid(0.05, 0.23, 0.5, 0.17).get(name='San Marino').snap_to_grid, tol))
@no_mysql
@no_spatialite
def test28_reverse(self):
"Testing GeoQuerySet.reverse_geom()."
coords = [ (-95.363151, 29.763374), (-95.448601, 29.713803) ]
Track.objects.create(name='Foo', line=LineString(coords))
t = Track.objects.reverse_geom().get(name='Foo')
coords.reverse()
self.assertEqual(tuple(coords), t.reverse_geom.coords)
if oracle:
self.assertRaises(TypeError, State.objects.reverse_geom)
@no_mysql
@no_oracle
@no_spatialite
def test29_force_rhr(self):
"Testing GeoQuerySet.force_rhr()."
rings = ( ( (0, 0), (5, 0), (0, 5), (0, 0) ),
( (1, 1), (1, 3), (3, 1), (1, 1) ),
)
rhr_rings = ( ( (0, 0), (0, 5), (5, 0), (0, 0) ),
( (1, 1), (3, 1), (1, 3), (1, 1) ),
)
State.objects.create(name='Foo', poly=Polygon(*rings))
s = State.objects.force_rhr().get(name='Foo')
self.assertEqual(rhr_rings, s.force_rhr.coords)
@no_mysql
@no_oracle
@no_spatialite
def test29_force_rhr(self):
"Testing GeoQuerySet.geohash()."
if not connection.ops.geohash: return
# Reference query:
# SELECT ST_GeoHash(point) FROM geoapp_city WHERE name='Houston';
# SELECT ST_GeoHash(point, 5) FROM geoapp_city WHERE name='Houston';
ref_hash = '9vk1mfq8jx0c8e0386z6'
h1 = City.objects.geohash().get(name='Houston')
h2 = City.objects.geohash(precision=5).get(name='Houston')
self.assertEqual(ref_hash, h1.geohash)
self.assertEqual(ref_hash[:5], h2.geohash)
from test_feeds import GeoFeedTest
from test_regress import GeoRegressionTests
from test_sitemaps import GeoSitemapTest
def suite():
s = unittest.TestSuite()
s.addTest(unittest.makeSuite(GeoModelTest))
s.addTest(unittest.makeSuite(GeoFeedTest))
s.addTest(unittest.makeSuite(GeoSitemapTest))
s.addTest(unittest.makeSuite(GeoRegressionTests))
return s
| ajibawa-2023/Python-Code-Large/train/row_98678 | 438 | 742 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Import_L1_C0", "label": "re import re, os, unittest", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0013, 0.0013, 0, 0.66, 0.0, 540, 0, 3, 0, 0, 540, 0, 0], "semantic": {"name": "re", "arg_names": [], "import_names": ["re", "os", "unittest"], "rhs_call_name": "", "annotation": ""}, "snippet": "import re, os, unittest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:ImportFrom_L2_C0", "label": "from django.db import connection", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0027, 0.0013, 0, 0.66, 0.0769, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["connection"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import connection"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:ImportFrom_L3_C0", "label": "from django.contrib.gis import gdal", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.004, 0.0013, 0, 0.66, 0.1538, 735, 0, 1, 0, 0, 735, 0, 0], "semantic": {"name": "django.contrib.gis", "arg_names": [], "import_names": ["gdal"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis import gdal"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:ImportFrom_L4_C0", "label": "from django.contrib.gis.geos import *", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0054, 0.0013, 0, 0.66, 0.2308, 886, 0, 1, 0, 0, 886, 0, 0], "semantic": {"name": "django.contrib.gis.geos", "arg_names": [], "import_names": ["*"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.geos import *"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:ImportFrom_L5_C0", "label": "from django.contrib.gis.measure import Distance", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0067, 0.0013, 0, 0.66, 0.3077, 844, 0, 1, 0, 0, 844, 0, 0], "semantic": {"name": "django.contrib.gis.measure", "arg_names": [], "import_names": ["Distance"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.measure import Distance"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:ImportFrom_L6_C0", "label": "from django.contrib.gis.tests.utils import no_mysql, no_oracle, no_postgis\u2026", "type": "import", "loc": [6, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0094, 0.004, 0, 0.66, 0.3846, 185, 0, 8, 0, 0, 185, 0, 0], "semantic": {"name": "django.contrib.gis.tests.utils", "arg_names": [], "import_names": ["no_mysql", "no_oracle", "no_postgis", "no_spatialite", "mysql", "oracle", "postgis", "spatialite"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.tests.utils import \\\n no_mysql, no_oracle, no_postgis, no_spatialite, \\\n mysql, oracle, postgis, spatialite"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:ImportFrom_L9_C0", "label": "from django.test import TestCase", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0121, 0.0013, 0, 0.66, 0.4615, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.test", "arg_names": [], "import_names": ["TestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.test import TestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:ImportFrom_L11_C0", "label": "from models import Country, City, PennsylvaniaCity\u2026", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0148, 0.0013, 0, 0.66, 0.5385, 495, 0, 5, 0, 0, 495, 0, 0], "semantic": {"name": "models", "arg_names": [], "import_names": ["Country", "City", "PennsylvaniaCity", "State", "Track"], "rhs_call_name": "", "annotation": ""}, "snippet": "from models import Country, City, PennsylvaniaCity, State, Track"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L13_C0", "label": "if", "type": "if", "loc": [13, 14], "level": 0, "parent": null, "vector": [4, 0, 0.0182, 0.0027, 0, 0.66, 0.6154, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if not spatialite:\n from models import Feature, MinusOneSRID"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:ImportFrom_L14_C4", "label": "from models import Feature, MinusOneSRID", "type": "import", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L13_C0", "vector": [1, 1, 0.0189, 0.0013, 1, 0.14, 0.0, 495, 0, 2, 0, 0, 495, 0, 0], "semantic": {"name": "models", "arg_names": [], "import_names": ["Feature", "MinusOneSRID"], "rhs_call_name": "", "annotation": ""}, "snippet": " from models import Feature, MinusOneSRID"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "label": "GeoModelTest", "type": "class", "loc": [16, 730], "level": 0, "parent": null, "vector": [3, 0, 0.5027, 0.9636, 0, 0.66, 0.6923, 35, 0, 31, 0, 0, 3, 0, 99], "semantic": {"name": "GeoModelTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GeoModelTest(TestCase):\n\n def test01_fixtures(self):\n \"Testing geographic model initialization from fixtures.\"\n # Ensuring that data was loaded from initial data fixtures.\n self.assertEqual(2, Country.objects.count())\n self.assertEqual(8, City.objects.count())\n self.assertEqual(2, State.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L18_C4", "label": "test01_fixtures", "type": "function", "loc": [18, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.0276, 0.0081, 1, 0.06, 0.0, 996, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test01_fixtures", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test01_fixtures(self):\n \"Testing geographic model initialization from fixtures.\"\n # Ensuring that data was loaded from initial data fixtures.\n self.assertEqual(2, Country.objects.count())\n self.assertEqual(8, City.objects.count())\n self.assertEqual(2, State.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L19_C8", "label": "expression", "type": "expression", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L18_C4", "vector": [8, 2, 0.0256, 0.0013, 2, 0.67, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing geographic model initialization from fixtures.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L21_C8", "label": "assertEqual()", "type": "expression", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L18_C4", "vector": [8, 2, 0.0283, 0.0013, 2, 0.67, 0.3333, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(2, Country.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L22_C8", "label": "assertEqual()", "type": "expression", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L18_C4", "vector": [8, 2, 0.0296, 0.0013, 2, 0.67, 0.6667, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(8, City.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L23_C8", "label": "assertEqual()", "type": "expression", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L18_C4", "vector": [8, 2, 0.031, 0.0013, 2, 0.67, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(2, State.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "label": "test02_proxy", "type": "function", "loc": [25, 91], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.0782, 0.0903, 1, 0.06, 0.0333, 826, 0, 1, 0, 0, 0, 0, 38], "semantic": {"name": "test02_proxy", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test02_proxy(self):\n \"Testing Lazy-Geometry support (using the GeometryProxy).\"\n ## Testing on a Point\n pnt = Point(0, 0)\n nullcity = City(name='NullCity', point=pnt)\n nullcity.save()\n\n # Making sure TypeError is thrown when trying to set with an"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L26_C8", "label": "expression", "type": "expression", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.035, 0.0013, 2, 0.85, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing Lazy-Geometry support (using the GeometryProxy).\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L28_C8", "label": "pnt = Point()", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.0377, 0.0013, 2, 0.85, 0.0323, 41, 3, 2, 0, 0, 652, 10, 1], "semantic": {"name": "pnt", "arg_names": [], "import_names": [], "rhs_call_name": "Point", "annotation": ""}, "snippet": " pnt = Point(0, 0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L29_C8", "label": "nullcity = City()", "type": "assigned_variable", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.0391, 0.0013, 2, 0.85, 0.0645, 771, 3, 2, 0, 0, 801, 10, 1], "semantic": {"name": "nullcity", "arg_names": [], "import_names": [], "rhs_call_name": "City", "annotation": ""}, "snippet": " nullcity = City(name='NullCity', point=pnt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L30_C8", "label": "save()", "type": "expression", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.0404, 0.0013, 2, 0.85, 0.0968, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " nullcity.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L34_C8", "label": "for bad", "type": "for", "loc": [34, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [6, 2, 0.0499, 0.0094, 2, 0.85, 0.129, 297, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "bad", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for bad in [5, 2.0, LineString((0, 0), (1, 1))]:\n try:\n nullcity.point = bad\n except TypeError:\n pass\n else:\n self.fail('Should throw a TypeError')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Try_L35_C12", "label": "try", "type": "try", "loc": [35, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L34_C8", "vector": [7, 3, 0.0505, 0.0081, 3, 0.89, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n nullcity.point = bad\n except TypeError:\n pass\n else:\n self.fail('Should throw a TypeError')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L36_C16", "label": "nullcity.point =", "type": "assigned_variable", "loc": [36, 36], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:Try_L35_C12", "vector": [14, 4, 0.0485, 0.0013, 4, 0.74, 0.0, 632, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "nullcity.point", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " nullcity.point = bad"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L40_C16", "label": "fail()", "type": "expression", "loc": [40, 40], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:Try_L35_C12", "vector": [8, 4, 0.0539, 0.0013, 4, 0.74, 1.0, 364, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "fail", "arg_names": [], "import_names": [], "rhs_call_name": "fail", "annotation": ""}, "snippet": " self.fail('Should throw a TypeError')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L44_C8", "label": "new = Point()", "type": "assigned_variable", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.0593, 0.0013, 2, 0.85, 0.1613, 145, 3, 2, 0, 0, 652, 10, 1], "semantic": {"name": "new", "arg_names": [], "import_names": [], "rhs_call_name": "Point", "annotation": ""}, "snippet": " new = Point(5, 23)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L45_C8", "label": "nullcity.point =", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.0606, 0.0013, 2, 0.85, 0.1935, 632, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "nullcity.point", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " nullcity.point = new"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L49_C8", "label": "assertEqual()", "type": "expression", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.066, 0.0013, 2, 0.85, 0.2258, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(4326, nullcity.point.srid)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L50_C8", "label": "save()", "type": "expression", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.0674, 0.0013, 2, 0.85, 0.2581, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " nullcity.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L53_C8", "label": "assertEqual()", "type": "expression", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.0714, 0.0013, 2, 0.85, 0.2903, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(new, City.objects.get(name='NullCity').point)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L56_C8", "label": "nullcity.point.x =", "type": "assigned_variable", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.0755, 0.0013, 2, 0.85, 0.3226, 76, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "nullcity.point.x", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " nullcity.point.x = 23"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L57_C8", "label": "nullcity.point.y =", "type": "assigned_variable", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.0768, 0.0013, 2, 0.85, 0.3548, 889, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "nullcity.point.y", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " nullcity.point.y = 5"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L59_C8", "label": "assertNotEqual()", "type": "expression", "loc": [59, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.0795, 0.0013, 2, 0.85, 0.3871, 120, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertNotEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertNotEqual", "annotation": ""}, "snippet": " self.assertNotEqual(Point(23, 5), City.objects.get(name='NullCity').point)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L60_C8", "label": "save()", "type": "expression", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.0809, 0.0013, 2, 0.85, 0.4194, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " nullcity.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L61_C8", "label": "assertEqual()", "type": "expression", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.0822, 0.0013, 2, 0.85, 0.4516, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(Point(23, 5), City.objects.get(name='NullCity').point)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L62_C8", "label": "delete()", "type": "expression", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.0836, 0.0013, 2, 0.85, 0.4839, 266, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " nullcity.delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L65_C8", "label": "shell = LinearRing()", "type": "assigned_variable", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.0876, 0.0013, 2, 0.85, 0.5161, 192, 3, 5, 0, 0, 441, 10, 1], "semantic": {"name": "shell", "arg_names": [], "import_names": [], "rhs_call_name": "LinearRing", "annotation": ""}, "snippet": " shell = LinearRing((0, 0), (0, 100), (100, 100), (100, 0), (0, 0))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L66_C8", "label": "inner = LinearRing()", "type": "assigned_variable", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.0889, 0.0013, 2, 0.85, 0.5484, 763, 3, 5, 0, 0, 441, 10, 1], "semantic": {"name": "inner", "arg_names": [], "import_names": [], "rhs_call_name": "LinearRing", "annotation": ""}, "snippet": " inner = LinearRing((40, 40), (40, 60), (60, 60), (60, 40), (40, 40))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L69_C8", "label": "ply = Polygon()", "type": "assigned_variable", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.093, 0.0013, 2, 0.85, 0.5806, 645, 3, 2, 0, 0, 818, 10, 1], "semantic": {"name": "ply", "arg_names": [], "import_names": [], "rhs_call_name": "Polygon", "annotation": ""}, "snippet": " ply = Polygon(shell, inner)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L70_C8", "label": "nullstate = State()", "type": "assigned_variable", "loc": [70, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.0943, 0.0013, 2, 0.85, 0.6129, 23, 3, 2, 0, 0, 110, 10, 1], "semantic": {"name": "nullstate", "arg_names": [], "import_names": [], "rhs_call_name": "State", "annotation": ""}, "snippet": " nullstate = State(name='NullState', poly=ply)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L71_C8", "label": "assertEqual()", "type": "expression", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.0957, 0.0013, 2, 0.85, 0.6452, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(4326, nullstate.poly.srid) # SRID auto-set from None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L72_C8", "label": "save()", "type": "expression", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.097, 0.0013, 2, 0.85, 0.6774, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " nullstate.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L74_C8", "label": "ns = get()", "type": "assigned_variable", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.0997, 0.0013, 2, 0.85, 0.7097, 638, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "ns", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " ns = State.objects.get(name='NullState')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L75_C8", "label": "assertEqual()", "type": "expression", "loc": [75, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.1011, 0.0013, 2, 0.85, 0.7419, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(ply, ns.poly)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L78_C8", "label": "if", "type": "if", "loc": [78, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [4, 2, 0.1078, 0.0067, 2, 0.85, 0.7742, 0, 7, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if gdal.HAS_GDAL:\n self.assertEqual(True, isinstance(ns.poly.ogr, gdal.OGRGeometry))\n self.assertEqual(ns.poly.wkb, ns.poly.ogr.wkb)\n self.assertEqual(True, isinstance(ns.poly.srs, gdal.SpatialReference))\n self.assertEqual('WGS 84', ns.poly.srs.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L79_C12", "label": "assertEqual()", "type": "expression", "loc": [79, 79], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L78_C8", "vector": [8, 3, 0.1065, 0.0013, 3, 0.02, 0.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(True, isinstance(ns.poly.ogr, gdal.OGRGeometry))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L80_C12", "label": "assertEqual()", "type": "expression", "loc": [80, 80], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L78_C8", "vector": [8, 3, 0.1078, 0.0013, 3, 0.02, 0.3333, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(ns.poly.wkb, ns.poly.ogr.wkb)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L81_C12", "label": "assertEqual()", "type": "expression", "loc": [81, 81], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L78_C8", "vector": [8, 3, 0.1092, 0.0013, 3, 0.02, 0.6667, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(True, isinstance(ns.poly.srs, gdal.SpatialReference))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L82_C12", "label": "assertEqual()", "type": "expression", "loc": [82, 82], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L78_C8", "vector": [8, 3, 0.1105, 0.0013, 3, 0.02, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('WGS 84', ns.poly.srs.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L85_C8", "label": "new_inner = LinearRing()", "type": "assigned_variable", "loc": [85, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.1146, 0.0013, 2, 0.85, 0.8065, 195, 3, 5, 0, 0, 441, 10, 1], "semantic": {"name": "new_inner", "arg_names": [], "import_names": [], "rhs_call_name": "LinearRing", "annotation": ""}, "snippet": " new_inner = LinearRing((30, 30), (30, 70), (70, 70), (70, 30), (30, 30))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L86_C8", "label": "assign", "type": "assigned_variable", "loc": [86, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.1159, 0.0013, 2, 0.85, 0.8387, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ns.poly[1] = new_inner"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L87_C8", "label": "assign", "type": "assigned_variable", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [14, 2, 0.1173, 0.0013, 2, 0.85, 0.871, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ply[1] = new_inner"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L88_C8", "label": "assertEqual()", "type": "expression", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.1186, 0.0013, 2, 0.85, 0.9032, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(4326, ns.poly.srid)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L89_C8", "label": "save()", "type": "expression", "loc": [89, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.1199, 0.0013, 2, 0.85, 0.9355, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " ns.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L90_C8", "label": "assertEqual()", "type": "expression", "loc": [90, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.1213, 0.0013, 2, 0.85, 0.9677, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(ply, State.objects.get(name='NullState').poly)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L91_C8", "label": "delete()", "type": "expression", "loc": [91, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "vector": [8, 2, 0.1226, 0.0013, 2, 0.85, 1.0, 266, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " ns.delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "label": "test03a_kml", "type": "function", "loc": [93, 116], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.1408, 0.0323, 1, 0.06, 0.0667, 908, 0, 1, 0, 0, 0, 0, 9], "semantic": {"name": "test03a_kml", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test03a_kml(self):\n \"Testing KML output from the database using GeoQuerySet.kml().\"\n # Only PostGIS supports KML serialization\n if not postgis:\n self.assertRaises(NotImplementedError, State.objects.all().kml, field_name='poly')\n return\n\n # Should throw a TypeError when trying to obtain KML from a"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L94_C8", "label": "expression", "type": "expression", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "vector": [8, 2, 0.1267, 0.0013, 2, 0.72, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing KML output from the database using GeoQuerySet.kml().\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L96_C8", "label": "if", "type": "if", "loc": [96, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "vector": [4, 2, 0.1307, 0.004, 2, 0.72, 0.1429, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not postgis:\n self.assertRaises(NotImplementedError, State.objects.all().kml, field_name='poly')\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L97_C12", "label": "assertRaises()", "type": "expression", "loc": [97, 97], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L96_C8", "vector": [8, 3, 0.1307, 0.0013, 3, 0.91, 0.0, 11, 3, 3, 0, 0, 0, 0, 2], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(NotImplementedError, State.objects.all().kml, field_name='poly')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Return_L98_C12", "label": "return", "type": "return", "loc": [98, 98], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L96_C8", "vector": [13, 3, 0.1321, 0.0013, 3, 0.91, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L102_C8", "label": "qs = all()", "type": "assigned_variable", "loc": [102, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "vector": [14, 2, 0.1375, 0.0013, 2, 0.72, 0.2857, 251, 3, 0, 0, 0, 895, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "all", "annotation": ""}, "snippet": " qs = City.objects.all()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L103_C8", "label": "assertRaises()", "type": "expression", "loc": [103, 103], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "vector": [8, 2, 0.1388, 0.0013, 2, 0.72, 0.4286, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(TypeError, qs.kml, 'name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L107_C8", "label": "if", "type": "if", "loc": [107, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "vector": [4, 2, 0.1462, 0.0054, 2, 0.72, 0.5714, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if connection.ops.spatial_version >= (1, 3, 3):\n ref_kml = '<Point><coordinates>-104.609252,38.255001</coordinates></Point>'\n else:\n ref_kml = '<Point><coordinates>-104.609252,38.255001,0</coordinates></Point>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L108_C12", "label": "ref_kml =", "type": "assigned_variable", "loc": [108, 108], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L107_C8", "vector": [14, 3, 0.1456, 0.0013, 3, 0.43, 0.0, 235, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "ref_kml", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_kml = '<Point><coordinates>-104.609252,38.255001</coordinates></Point>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L110_C12", "label": "ref_kml =", "type": "assigned_variable", "loc": [110, 110], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L107_C8", "vector": [14, 3, 0.1482, 0.0013, 3, 0.43, 1.0, 235, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "ref_kml", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_kml = '<Point><coordinates>-104.609252,38.255001,0</coordinates></Point>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L113_C8", "label": "ptown1 = get()", "type": "assigned_variable", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "vector": [14, 2, 0.1523, 0.0013, 2, 0.72, 0.7143, 120, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "ptown1", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " ptown1 = City.objects.kml(field_name='point', precision=9).get(name='Pueblo')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L114_C8", "label": "ptown2 = get()", "type": "assigned_variable", "loc": [114, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "vector": [14, 2, 0.1536, 0.0013, 2, 0.72, 0.8571, 863, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "ptown2", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " ptown2 = City.objects.kml(precision=9).get(name='Pueblo')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L115_C8", "label": "for ptown", "type": "for", "loc": [115, 116], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "vector": [6, 2, 0.1557, 0.0027, 2, 0.72, 1.0, 167, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "ptown", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for ptown in [ptown1, ptown2]:\n self.assertEqual(ref_kml, ptown.kml)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L116_C12", "label": "assertEqual()", "type": "expression", "loc": [116, 116], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L115_C8", "vector": [8, 3, 0.1563, 0.0013, 3, 0.36, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(ref_kml, ptown.kml)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "label": "test03b_gml", "type": "function", "loc": [118, 139], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.1732, 0.0296, 1, 0.06, 0.1, 494, 0, 1, 0, 0, 0, 0, 14], "semantic": {"name": "test03b_gml", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test03b_gml(self):\n \"Testing GML output from the database using GeoQuerySet.gml().\"\n if mysql or spatialite:\n self.assertRaises(NotImplementedError, Country.objects.all().gml, field_name='mpoly')\n return\n\n # Should throw a TypeError when tyring to obtain GML from a\n # non-geometry field."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L119_C8", "label": "expression", "type": "expression", "loc": [119, 119], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "vector": [8, 2, 0.1604, 0.0013, 2, 0.02, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing GML output from the database using GeoQuerySet.gml().\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L120_C8", "label": "if", "type": "if", "loc": [120, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "vector": [4, 2, 0.1631, 0.004, 2, 0.02, 0.1667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if mysql or spatialite:\n self.assertRaises(NotImplementedError, Country.objects.all().gml, field_name='mpoly')\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L121_C12", "label": "assertRaises()", "type": "expression", "loc": [121, 121], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L120_C8", "vector": [8, 3, 0.1631, 0.0013, 3, 0.18, 0.0, 11, 3, 3, 0, 0, 0, 0, 2], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(NotImplementedError, Country.objects.all().gml, field_name='mpoly')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Return_L122_C12", "label": "return", "type": "return", "loc": [122, 122], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L120_C8", "vector": [13, 3, 0.1644, 0.0013, 3, 0.18, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L126_C8", "label": "qs = all()", "type": "assigned_variable", "loc": [126, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "vector": [14, 2, 0.1698, 0.0013, 2, 0.02, 0.3333, 251, 3, 0, 0, 0, 895, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "all", "annotation": ""}, "snippet": " qs = City.objects.all()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L127_C8", "label": "assertRaises()", "type": "expression", "loc": [127, 127], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "vector": [8, 2, 0.1712, 0.0013, 2, 0.02, 0.5, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(TypeError, qs.gml, field_name='name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L128_C8", "label": "ptown1 = get()", "type": "assigned_variable", "loc": [128, 128], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "vector": [14, 2, 0.1725, 0.0013, 2, 0.02, 0.6667, 120, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "ptown1", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " ptown1 = City.objects.gml(field_name='point', precision=9).get(name='Pueblo')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L129_C8", "label": "ptown2 = get()", "type": "assigned_variable", "loc": [129, 129], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "vector": [14, 2, 0.1739, 0.0013, 2, 0.02, 0.8333, 863, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "ptown2", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " ptown2 = City.objects.gml(precision=9).get(name='Pueblo')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L131_C8", "label": "if", "type": "if", "loc": [131, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "vector": [4, 2, 0.1819, 0.0121, 2, 0.02, 1.0, 0, 2, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle:\n # No precision parameter for Oracle :-/\n gml_regex = re.compile(r'^<gml:Point srsName=\"SDO:4326\" xmlns:gml=\"http://www.opengis.net/gml\"><gml:coordinates decimal=\"\\.\" cs=\",\" ts=\" \">-104.60925\\d+,38.25500\\d+ </gml:coordinates></gml:Point>')\n for ptown in [ptown1, ptown2]:\n self.failUnless(gml_regex.match(ptown.gml))\n else:\n gml_regex = re.compile(r'^<gml:Point srsName=\"EPSG:4326\"><gml:coordinates>-104\\.60925\\d+,38\\.255001</gml:coordinates></gml:Point>')\n for ptown in [ptown1, ptown2]:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L133_C12", "label": "gml_regex = compile()", "type": "assigned_variable", "loc": [133, 133], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L131_C8", "vector": [14, 3, 0.1792, 0.0013, 3, 0.85, 0.0, 77, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "gml_regex", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": " gml_regex = re.compile(r'^<gml:Point srsName=\"SDO:4326\" xmlns:gml=\"http://www.opengis.net/gml\"><gml:coordinates decimal=\"\\.\" cs=\",\" ts=\" \">-104.60925\\d+,38.25500\\d+ </gml:coordinates></gml:Point>')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L134_C12", "label": "for ptown", "type": "for", "loc": [134, 135], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L131_C8", "vector": [6, 3, 0.1813, 0.0027, 3, 0.85, 0.3333, 167, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "ptown", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for ptown in [ptown1, ptown2]:\n self.failUnless(gml_regex.match(ptown.gml))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L135_C16", "label": "failUnless()", "type": "expression", "loc": [135, 135], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L134_C12", "vector": [8, 4, 0.1819, 0.0013, 4, 0.12, 0.0, 252, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "failUnless", "arg_names": [], "import_names": [], "rhs_call_name": "failUnless", "annotation": ""}, "snippet": " self.failUnless(gml_regex.match(ptown.gml))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L137_C12", "label": "gml_regex = compile()", "type": "assigned_variable", "loc": [137, 137], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L131_C8", "vector": [14, 3, 0.1846, 0.0013, 3, 0.85, 0.6667, 77, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "gml_regex", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": " gml_regex = re.compile(r'^<gml:Point srsName=\"EPSG:4326\"><gml:coordinates>-104\\.60925\\d+,38\\.255001</gml:coordinates></gml:Point>')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L138_C12", "label": "for ptown", "type": "for", "loc": [138, 139], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L131_C8", "vector": [6, 3, 0.1867, 0.0027, 3, 0.85, 1.0, 167, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "ptown", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for ptown in [ptown1, ptown2]:\n self.failUnless(gml_regex.match(ptown.gml))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L139_C16", "label": "failUnless()", "type": "expression", "loc": [139, 139], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L138_C12", "vector": [8, 4, 0.1873, 0.0013, 4, 0.78, 0.0, 252, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "failUnless", "arg_names": [], "import_names": [], "rhs_call_name": "failUnless", "annotation": ""}, "snippet": " self.failUnless(gml_regex.match(ptown.gml))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "label": "test03c_geojson", "type": "function", "loc": [141, 178], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.215, 0.0512, 1, 0.06, 0.1333, 627, 0, 1, 0, 0, 0, 0, 15], "semantic": {"name": "test03c_geojson", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test03c_geojson(self):\n \"Testing GeoJSON output from the database using GeoQuerySet.geojson().\"\n # Only PostGIS 1.3.4+ supports GeoJSON.\n if not connection.ops.geojson:\n self.assertRaises(NotImplementedError, Country.objects.all().geojson, field_name='mpoly')\n return\n\n if connection.ops.spatial_version >= (1, 4, 0):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L142_C8", "label": "expression", "type": "expression", "loc": [142, 142], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "vector": [8, 2, 0.1914, 0.0013, 2, 0.57, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing GeoJSON output from the database using GeoQuerySet.geojson().\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L144_C8", "label": "if", "type": "if", "loc": [144, 146], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "vector": [4, 2, 0.1954, 0.004, 2, 0.57, 0.1429, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not connection.ops.geojson:\n self.assertRaises(NotImplementedError, Country.objects.all().geojson, field_name='mpoly')\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L145_C12", "label": "assertRaises()", "type": "expression", "loc": [145, 145], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L144_C8", "vector": [8, 3, 0.1954, 0.0013, 3, 0.03, 0.0, 11, 3, 3, 0, 0, 0, 0, 2], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(NotImplementedError, Country.objects.all().geojson, field_name='mpoly')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Return_L146_C12", "label": "return", "type": "return", "loc": [146, 146], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L144_C8", "vector": [13, 3, 0.1968, 0.0013, 3, 0.03, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "label": "if", "type": "if", "loc": [148, 157], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "vector": [4, 2, 0.2055, 0.0135, 2, 0.57, 0.2857, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if connection.ops.spatial_version >= (1, 4, 0):\n pueblo_json = '{\"type\":\"Point\",\"coordinates\":[-104.609252,38.255001]}'\n houston_json = '{\"type\":\"Point\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"coordinates\":[-95.363151,29.763374]}'\n victoria_json = '{\"type\":\"Point\",\"bbox\":[-123.30519600,48.46261100,-123.30519600,48.46261100],\"coordinates\":[-123.305196,48.462611]}'\n chicago_json = '{\"type\":\"Point\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"bbox\":[-87.65018,41.85039,-87.65018,41.85039],\"coordinates\":[-87.65018,41.85039]}'\n else:\n pueblo_json = '{\"type\":\"Point\",\"coordinates\":[-104.60925200,38.25500100]}'\n houston_json = '{\"type\":\"Point\",\"crs\":{\"type\":\"EPSG\",\"properties\":{\"EPSG\":4326}},\"coordinates\":[-95.36315100,29.76337400]}'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L149_C12", "label": "pueblo_json =", "type": "assigned_variable", "loc": [149, 149], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "vector": [14, 3, 0.2008, 0.0013, 3, 0.75, 0.0, 650, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "pueblo_json", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pueblo_json = '{\"type\":\"Point\",\"coordinates\":[-104.609252,38.255001]}'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L150_C12", "label": "houston_json =", "type": "assigned_variable", "loc": [150, 150], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "vector": [14, 3, 0.2022, 0.0013, 3, 0.75, 0.1429, 548, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "houston_json", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " houston_json = '{\"type\":\"Point\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"coordinates\":[-95.363151,29.763374]}'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L151_C12", "label": "victoria_json =", "type": "assigned_variable", "loc": [151, 151], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "vector": [14, 3, 0.2035, 0.0013, 3, 0.75, 0.2857, 67, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "victoria_json", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " victoria_json = '{\"type\":\"Point\",\"bbox\":[-123.30519600,48.46261100,-123.30519600,48.46261100],\"coordinates\":[-123.305196,48.462611]}'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L152_C12", "label": "chicago_json =", "type": "assigned_variable", "loc": [152, 152], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "vector": [14, 3, 0.2049, 0.0013, 3, 0.75, 0.4286, 979, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "chicago_json", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " chicago_json = '{\"type\":\"Point\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"bbox\":[-87.65018,41.85039,-87.65018,41.85039],\"coordinates\":[-87.65018,41.85039]}'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L154_C12", "label": "pueblo_json =", "type": "assigned_variable", "loc": [154, 154], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "vector": [14, 3, 0.2075, 0.0013, 3, 0.75, 0.5714, 650, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "pueblo_json", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pueblo_json = '{\"type\":\"Point\",\"coordinates\":[-104.60925200,38.25500100]}'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L155_C12", "label": "houston_json =", "type": "assigned_variable", "loc": [155, 155], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "vector": [14, 3, 0.2089, 0.0013, 3, 0.75, 0.7143, 548, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "houston_json", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " houston_json = '{\"type\":\"Point\",\"crs\":{\"type\":\"EPSG\",\"properties\":{\"EPSG\":4326}},\"coordinates\":[-95.36315100,29.76337400]}'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L156_C12", "label": "victoria_json =", "type": "assigned_variable", "loc": [156, 156], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "vector": [14, 3, 0.2102, 0.0013, 3, 0.75, 0.8571, 67, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "victoria_json", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " victoria_json = '{\"type\":\"Point\",\"bbox\":[-123.30519600,48.46261100,-123.30519600,48.46261100],\"coordinates\":[-123.30519600,48.46261100]}'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L157_C12", "label": "chicago_json =", "type": "assigned_variable", "loc": [157, 157], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "vector": [14, 3, 0.2116, 0.0013, 3, 0.75, 1.0, 979, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "chicago_json", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " chicago_json = '{\"type\":\"Point\",\"crs\":{\"type\":\"EPSG\",\"properties\":{\"EPSG\":4326}},\"bbox\":[-87.65018,41.85039,-87.65018,41.85039],\"coordinates\":[-87.65018,41.85039]}'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L160_C8", "label": "assertRaises()", "type": "expression", "loc": [160, 160], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "vector": [8, 2, 0.2156, 0.0013, 2, 0.57, 0.4286, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(TypeError, City.objects.geojson, precision='foo')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L164_C8", "label": "assertEqual()", "type": "expression", "loc": [164, 164], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "vector": [8, 2, 0.221, 0.0013, 2, 0.57, 0.5714, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(pueblo_json, City.objects.geojson().get(name='Pueblo').geojson)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L169_C8", "label": "assertEqual()", "type": "expression", "loc": [169, 169], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "vector": [8, 2, 0.2278, 0.0013, 2, 0.57, 0.7143, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(houston_json, City.objects.geojson(crs=True, model_att='json').get(name='Houston').json)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L174_C8", "label": "assertEqual()", "type": "expression", "loc": [174, 174], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "vector": [8, 2, 0.2345, 0.0013, 2, 0.57, 0.8571, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(victoria_json, City.objects.geojson(bbox=True).get(name='Victoria').geojson)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L178_C8", "label": "assertEqual()", "type": "expression", "loc": [178, 178], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "vector": [8, 2, 0.2399, 0.0013, 2, 0.57, 1.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(chicago_json, City.objects.geojson(bbox=True, crs=True, precision=5).get(name='Chicago').geojson)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "label": "test03d_svg", "type": "function", "loc": [180, 193], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.2513, 0.0189, 1, 0.06, 0.1667, 80, 0, 1, 0, 0, 0, 0, 9], "semantic": {"name": "test03d_svg", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test03d_svg(self):\n \"Testing SVG output using GeoQuerySet.svg().\"\n if mysql or oracle:\n self.assertRaises(NotImplementedError, City.objects.svg)\n return\n\n self.assertRaises(TypeError, City.objects.svg, precision='foo')\n # SELECT AsSVG(geoapp_city.point, 0, 8) FROM geoapp_city WHERE name = 'Pueblo';"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L181_C8", "label": "expression", "type": "expression", "loc": [181, 181], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "vector": [8, 2, 0.2439, 0.0013, 2, 0.18, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing SVG output using GeoQuerySet.svg().\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L182_C8", "label": "if", "type": "if", "loc": [182, 184], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "vector": [4, 2, 0.2466, 0.004, 2, 0.18, 0.1667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if mysql or oracle:\n self.assertRaises(NotImplementedError, City.objects.svg)\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L183_C12", "label": "assertRaises()", "type": "expression", "loc": [183, 183], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L182_C8", "vector": [8, 3, 0.2466, 0.0013, 3, 0.1, 0.0, 11, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(NotImplementedError, City.objects.svg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Return_L184_C12", "label": "return", "type": "return", "loc": [184, 184], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L182_C8", "vector": [13, 3, 0.248, 0.0013, 3, 0.1, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L186_C8", "label": "assertRaises()", "type": "expression", "loc": [186, 186], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "vector": [8, 2, 0.2507, 0.0013, 2, 0.18, 0.3333, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(TypeError, City.objects.svg, precision='foo')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L188_C8", "label": "svg1 =", "type": "assigned_variable", "loc": [188, 188], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "vector": [14, 2, 0.2534, 0.0013, 2, 0.18, 0.5, 749, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "svg1", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " svg1 = 'cx=\"-104.609252\" cy=\"-38.255001\"'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L191_C8", "label": "svg2 = replace()", "type": "assigned_variable", "loc": [191, 191], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "vector": [14, 2, 0.2574, 0.0013, 2, 0.18, 0.6667, 235, 3, 2, 0, 0, 293, 10, 1], "semantic": {"name": "svg2", "arg_names": [], "import_names": [], "rhs_call_name": "replace", "annotation": ""}, "snippet": " svg2 = svg1.replace('c', '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L192_C8", "label": "assertEqual()", "type": "expression", "loc": [192, 192], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "vector": [8, 2, 0.2588, 0.0013, 2, 0.18, 0.8333, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(svg1, City.objects.svg().get(name='Pueblo').svg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L193_C8", "label": "assertEqual()", "type": "expression", "loc": [193, 193], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "vector": [8, 2, 0.2601, 0.0013, 2, 0.18, 1.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(svg2, City.objects.svg(relative=5).get(name='Pueblo').svg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "label": "test04_transform", "type": "function", "loc": [196, 216], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.2776, 0.0283, 1, 0.06, 0.2, 956, 0, 1, 0, 0, 0, 0, 14], "semantic": {"name": "test04_transform", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test04_transform(self):\n \"Testing the transform() GeoManager method.\"\n # Pre-transformed points for Houston and Pueblo.\n htown = fromstr('POINT(1947516.83115183 6322297.06040572)', srid=3084)\n ptown = fromstr('POINT(992363.390841912 481455.395105533)', srid=2774)\n prec = 3 # Precision is low due to version variations in PROJ and GDAL.\n\n # Asserting the result of the transform operation with the values in"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L197_C8", "label": "expression", "type": "expression", "loc": [197, 197], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "vector": [8, 2, 0.2655, 0.0013, 2, 0.79, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the transform() GeoManager method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L199_C8", "label": "htown = fromstr()", "type": "assigned_variable", "loc": [199, 199], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "vector": [14, 2, 0.2682, 0.0013, 2, 0.79, 0.1429, 968, 3, 2, 0, 0, 946, 10, 1], "semantic": {"name": "htown", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " htown = fromstr('POINT(1947516.83115183 6322297.06040572)', srid=3084)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L200_C8", "label": "ptown = fromstr()", "type": "assigned_variable", "loc": [200, 200], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "vector": [14, 2, 0.2695, 0.0013, 2, 0.79, 0.2857, 167, 3, 2, 0, 0, 946, 10, 1], "semantic": {"name": "ptown", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " ptown = fromstr('POINT(992363.390841912 481455.395105533)', srid=2774)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L201_C8", "label": "prec =", "type": "assigned_variable", "loc": [201, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "vector": [14, 2, 0.2709, 0.0013, 2, 0.79, 0.4286, 523, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "prec", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prec = 3 # Precision is low due to version variations in PROJ and GDAL."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L205_C8", "label": "if", "type": "if", "loc": [205, 209], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "vector": [4, 2, 0.279, 0.0067, 2, 0.79, 0.5714, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not oracle:\n h = City.objects.transform(htown.srid).get(name='Houston')\n self.assertEqual(3084, h.point.srid)\n self.assertAlmostEqual(htown.x, h.point.x, prec)\n self.assertAlmostEqual(htown.y, h.point.y, prec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L206_C12", "label": "h = get()", "type": "assigned_variable", "loc": [206, 206], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L205_C8", "vector": [14, 3, 0.2776, 0.0013, 3, 0.9, 0.0, 686, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "h", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " h = City.objects.transform(htown.srid).get(name='Houston')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L207_C12", "label": "assertEqual()", "type": "expression", "loc": [207, 207], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L205_C8", "vector": [8, 3, 0.279, 0.0013, 3, 0.9, 0.3333, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(3084, h.point.srid)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L208_C12", "label": "assertAlmostEqual()", "type": "expression", "loc": [208, 208], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L205_C8", "vector": [8, 3, 0.2803, 0.0013, 3, 0.9, 0.6667, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(htown.x, h.point.x, prec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L209_C12", "label": "assertAlmostEqual()", "type": "expression", "loc": [209, 209], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L205_C8", "vector": [8, 3, 0.2817, 0.0013, 3, 0.9, 1.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(htown.y, h.point.y, prec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L211_C8", "label": "p1 = get()", "type": "assigned_variable", "loc": [211, 211], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "vector": [14, 2, 0.2844, 0.0013, 2, 0.79, 0.7143, 87, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "p1", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " p1 = City.objects.transform(ptown.srid, field_name='point').get(name='Pueblo')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L212_C8", "label": "p2 = get()", "type": "assigned_variable", "loc": [212, 212], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "vector": [14, 2, 0.2857, 0.0013, 2, 0.79, 0.8571, 843, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "p2", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " p2 = City.objects.transform(srid=ptown.srid).get(name='Pueblo')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L213_C8", "label": "for p", "type": "for", "loc": [213, 216], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "vector": [6, 2, 0.2891, 0.0054, 2, 0.79, 1.0, 491, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "p", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for p in [p1, p2]:\n self.assertEqual(2774, p.point.srid)\n self.assertAlmostEqual(ptown.x, p.point.x, prec)\n self.assertAlmostEqual(ptown.y, p.point.y, prec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L214_C12", "label": "assertEqual()", "type": "expression", "loc": [214, 214], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L213_C8", "vector": [8, 3, 0.2884, 0.0013, 3, 0.17, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(2774, p.point.srid)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L215_C12", "label": "assertAlmostEqual()", "type": "expression", "loc": [215, 215], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L213_C8", "vector": [8, 3, 0.2898, 0.0013, 3, 0.17, 0.5, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(ptown.x, p.point.x, prec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L216_C12", "label": "assertAlmostEqual()", "type": "expression", "loc": [216, 216], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L213_C8", "vector": [8, 3, 0.2911, 0.0013, 3, 0.17, 1.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(ptown.y, p.point.y, prec)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L220_C4", "label": "test05_extent", "type": "function", "loc": [220, 231], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.3039, 0.0162, 1, 0.06, 0.2333, 220, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test05_extent", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test05_extent(self):\n \"Testing the `extent` GeoQuerySet method.\"\n # Reference query:\n # `SELECT ST_extent(point) FROM geoapp_city WHERE (name='Houston' or name='Dallas');`\n # => BOX(-96.8016128540039 29.7633724212646,-95.3631439208984 32.7820587158203)\n expected = (-96.8016128540039, 29.7633724212646, -95.3631439208984, 32.782058715820)\n\n qs = City.objects.filter(name__in=('Houston', 'Dallas'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L221_C8", "label": "expression", "type": "expression", "loc": [221, 221], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L220_C4", "vector": [8, 2, 0.2978, 0.0013, 2, 0.54, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `extent` GeoQuerySet method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L225_C8", "label": "expected =", "type": "assigned_variable", "loc": [225, 225], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L220_C4", "vector": [14, 2, 0.3032, 0.0013, 2, 0.54, 0.25, 361, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "expected", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " expected = (-96.8016128540039, 29.7633724212646, -95.3631439208984, 32.782058715820)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L227_C8", "label": "qs = filter()", "type": "assigned_variable", "loc": [227, 227], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L220_C4", "vector": [14, 2, 0.3059, 0.0013, 2, 0.54, 0.5, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = City.objects.filter(name__in=('Houston', 'Dallas'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L228_C8", "label": "extent = extent()", "type": "assigned_variable", "loc": [228, 228], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L220_C4", "vector": [14, 2, 0.3073, 0.0013, 2, 0.54, 0.75, 962, 3, 0, 0, 0, 962, 10, 1], "semantic": {"name": "extent", "arg_names": [], "import_names": [], "rhs_call_name": "extent", "annotation": ""}, "snippet": " extent = qs.extent()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L230_C8", "label": "for val, exp", "type": "for", "loc": [230, 231], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L220_C4", "vector": [6, 2, 0.3106, 0.0027, 2, 0.54, 1.0, 333, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "val, exp", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for val, exp in zip(extent, expected):\n self.assertAlmostEqual(exp, val, 4)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L231_C12", "label": "assertAlmostEqual()", "type": "expression", "loc": [231, 231], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L230_C8", "vector": [8, 3, 0.3113, 0.0013, 3, 0.72, 0.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(exp, val, 4)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L237_C4", "label": "test06_make_line", "type": "function", "loc": [237, 245], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.3248, 0.0121, 1, 0.06, 0.2667, 574, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test06_make_line", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test06_make_line(self):\n \"Testing the `make_line` GeoQuerySet method.\"\n # Ensuring that a `TypeError` is raised on models without PointFields.\n self.assertRaises(TypeError, State.objects.make_line)\n self.assertRaises(TypeError, Country.objects.make_line)\n # Reference query:\n # SELECT AsText(ST_MakeLine(geoapp_city.point)) FROM geoapp_city;\n ref_line = GEOSGeometry('LINESTRING(-95.363151 29.763374,-96.801611 32.782057,-97.521157 34.464642,174.783117 -41.315268,-104.609252 38.255001,-95.23506 38.971823,-87.650175 41.850385,-123.305196 48.462611)', srid=4326)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L238_C8", "label": "expression", "type": "expression", "loc": [238, 238], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L237_C4", "vector": [8, 2, 0.3208, 0.0013, 2, 0.21, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `make_line` GeoQuerySet method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L240_C8", "label": "assertRaises()", "type": "expression", "loc": [240, 240], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L237_C4", "vector": [8, 2, 0.3235, 0.0013, 2, 0.21, 0.25, 11, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(TypeError, State.objects.make_line)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L241_C8", "label": "assertRaises()", "type": "expression", "loc": [241, 241], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L237_C4", "vector": [8, 2, 0.3248, 0.0013, 2, 0.21, 0.5, 11, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(TypeError, Country.objects.make_line)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L244_C8", "label": "ref_line = GEOSGeometry()", "type": "assigned_variable", "loc": [244, 244], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L237_C4", "vector": [14, 2, 0.3288, 0.0013, 2, 0.21, 0.75, 608, 3, 2, 0, 0, 958, 10, 1], "semantic": {"name": "ref_line", "arg_names": [], "import_names": [], "rhs_call_name": "GEOSGeometry", "annotation": ""}, "snippet": " ref_line = GEOSGeometry('LINESTRING(-95.363151 29.763374,-96.801611 32.782057,-97.521157 34.464642,174.783117 -41.315268,-104.609252 38.255001,-95.23506 38.971823,-87.650175 41.850385,-123.305196 48.462611)', srid=4326)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L245_C8", "label": "assertEqual()", "type": "expression", "loc": [245, 245], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L237_C4", "vector": [8, 2, 0.3302, 0.0013, 2, 0.21, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(ref_line, City.objects.make_line())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "label": "test09_disjoint", "type": "function", "loc": [248, 256], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.3396, 0.0121, 1, 0.06, 0.3, 295, 0, 1, 0, 0, 0, 0, 8], "semantic": {"name": "test09_disjoint", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test09_disjoint(self):\n \"Testing the `disjoint` lookup type.\"\n ptown = City.objects.get(name='Pueblo')\n qs1 = City.objects.filter(point__disjoint=ptown.point)\n self.assertEqual(7, qs1.count())\n\n qs2 = State.objects.filter(poly__disjoint=ptown.point)\n self.assertEqual(1, qs2.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L249_C8", "label": "expression", "type": "expression", "loc": [249, 249], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "vector": [8, 2, 0.3356, 0.0013, 2, 0.73, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `disjoint` lookup type.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L250_C8", "label": "ptown = get()", "type": "assigned_variable", "loc": [250, 250], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "vector": [14, 2, 0.3369, 0.0013, 2, 0.73, 0.1667, 167, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "ptown", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " ptown = City.objects.get(name='Pueblo')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L251_C8", "label": "qs1 = filter()", "type": "assigned_variable", "loc": [251, 251], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "vector": [14, 2, 0.3383, 0.0013, 2, 0.73, 0.3333, 811, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs1", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs1 = City.objects.filter(point__disjoint=ptown.point)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L252_C8", "label": "assertEqual()", "type": "expression", "loc": [252, 252], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "vector": [8, 2, 0.3396, 0.0013, 2, 0.73, 0.5, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(7, qs1.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L254_C8", "label": "qs2 = filter()", "type": "assigned_variable", "loc": [254, 254], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "vector": [14, 2, 0.3423, 0.0013, 2, 0.73, 0.6667, 595, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs2", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs2 = State.objects.filter(poly__disjoint=ptown.point)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L255_C8", "label": "assertEqual()", "type": "expression", "loc": [255, 255], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "vector": [8, 2, 0.3437, 0.0013, 2, 0.73, 0.8333, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(1, qs2.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L256_C8", "label": "assertEqual()", "type": "expression", "loc": [256, 256], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "vector": [8, 2, 0.345, 0.0013, 2, 0.73, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Kansas', qs2[0].name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "label": "test10_contains_contained", "type": "function", "loc": [258, 301], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.3767, 0.0593, 1, 0.06, 0.3333, 114, 0, 1, 0, 0, 0, 0, 26], "semantic": {"name": "test10_contains_contained", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test10_contains_contained(self):\n \"Testing the 'contained', 'contains', and 'bbcontains' lookup types.\"\n # Getting Texas, yes we were a country -- once ;)\n texas = Country.objects.get(name='Texas')\n\n # Seeing what cities are in Texas, should get Houston and Dallas,\n # and Oklahoma City because 'contained' only checks on the\n # _bounding box_ of the Geometries."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L259_C8", "label": "expression", "type": "expression", "loc": [259, 259], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [8, 2, 0.3491, 0.0013, 2, 0.4, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the 'contained', 'contains', and 'bbcontains' lookup types.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L261_C8", "label": "texas = get()", "type": "assigned_variable", "loc": [261, 261], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [14, 2, 0.3518, 0.0013, 2, 0.4, 0.0667, 96, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "texas", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " texas = Country.objects.get(name='Texas')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L266_C8", "label": "if", "type": "if", "loc": [266, 270], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [4, 2, 0.3612, 0.0067, 2, 0.4, 0.1333, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not oracle:\n qs = City.objects.filter(point__contained=texas.mpoly)\n self.assertEqual(3, qs.count())\n cities = ['Houston', 'Dallas', 'Oklahoma City']\n for c in qs: self.assertEqual(True, c.name in cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L267_C12", "label": "qs = filter()", "type": "assigned_variable", "loc": [267, 267], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L266_C8", "vector": [14, 3, 0.3598, 0.0013, 3, 0.21, 0.0, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = City.objects.filter(point__contained=texas.mpoly)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L268_C12", "label": "assertEqual()", "type": "expression", "loc": [268, 268], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L266_C8", "vector": [8, 3, 0.3612, 0.0013, 3, 0.21, 0.3333, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(3, qs.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L269_C12", "label": "cities =", "type": "assigned_variable", "loc": [269, 269], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L266_C8", "vector": [14, 3, 0.3625, 0.0013, 3, 0.21, 0.6667, 884, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "cities", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cities = ['Houston', 'Dallas', 'Oklahoma City']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L270_C12", "label": "for c", "type": "for", "loc": [270, 270], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L266_C8", "vector": [6, 3, 0.3639, 0.0013, 3, 0.21, 1.0, 411, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in qs: self.assertEqual(True, c.name in cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L270_C25", "label": "assertEqual()", "type": "expression", "loc": [270, 270], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L270_C12", "vector": [8, 4, 0.3639, 0.0013, 4, 0.65, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " for c in qs: self.assertEqual(True, c.name in cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L273_C8", "label": "houston = get()", "type": "assigned_variable", "loc": [273, 273], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [14, 2, 0.3679, 0.0013, 2, 0.4, 0.2, 402, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "houston", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " houston = City.objects.get(name='Houston')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L274_C8", "label": "wellington = get()", "type": "assigned_variable", "loc": [274, 274], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [14, 2, 0.3693, 0.0013, 2, 0.4, 0.2667, 293, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "wellington", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " wellington = City.objects.get(name='Wellington')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L275_C8", "label": "pueblo = get()", "type": "assigned_variable", "loc": [275, 275], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [14, 2, 0.3706, 0.0013, 2, 0.4, 0.3333, 14, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "pueblo", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " pueblo = City.objects.get(name='Pueblo')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L276_C8", "label": "okcity = get()", "type": "assigned_variable", "loc": [276, 276], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [14, 2, 0.372, 0.0013, 2, 0.4, 0.4, 714, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "okcity", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " okcity = City.objects.get(name='Oklahoma City')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L277_C8", "label": "lawrence = get()", "type": "assigned_variable", "loc": [277, 277], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [14, 2, 0.3733, 0.0013, 2, 0.4, 0.4667, 195, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "lawrence", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " lawrence = City.objects.get(name='Lawrence')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L281_C8", "label": "tx = get()", "type": "assigned_variable", "loc": [281, 281], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [14, 2, 0.3787, 0.0013, 2, 0.4, 0.5333, 82, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "tx", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " tx = Country.objects.get(mpoly__contains=houston.point) # Query w/GEOSGeometry"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L282_C8", "label": "nz = get()", "type": "assigned_variable", "loc": [282, 282], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [14, 2, 0.3801, 0.0013, 2, 0.4, 0.6, 880, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "nz", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " nz = Country.objects.get(mpoly__contains=wellington.point.hex) # Query w/EWKBHEX"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L283_C8", "label": "assertEqual()", "type": "expression", "loc": [283, 283], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [8, 2, 0.3814, 0.0013, 2, 0.4, 0.6667, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Texas', tx.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L284_C8", "label": "assertEqual()", "type": "expression", "loc": [284, 284], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [8, 2, 0.3827, 0.0013, 2, 0.4, 0.7333, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('New Zealand', nz.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L287_C8", "label": "if", "type": "if", "loc": [287, 289], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [4, 2, 0.3881, 0.004, 2, 0.4, 0.8, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not spatialite:\n ks = State.objects.get(poly__contains=lawrence.point)\n self.assertEqual('Kansas', ks.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L288_C12", "label": "ks = get()", "type": "assigned_variable", "loc": [288, 288], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L287_C8", "vector": [14, 3, 0.3881, 0.0013, 3, 0.28, 0.0, 316, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "ks", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " ks = State.objects.get(poly__contains=lawrence.point)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L289_C12", "label": "assertEqual()", "type": "expression", "loc": [289, 289], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L287_C8", "vector": [8, 3, 0.3895, 0.0013, 3, 0.28, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Kansas', ks.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L293_C8", "label": "assertEqual()", "type": "expression", "loc": [293, 293], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [8, 2, 0.3949, 0.0013, 2, 0.4, 0.8667, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(0, len(Country.objects.filter(mpoly__contains=pueblo.point))) # Query w/GEOSGeometry object"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L294_C8", "label": "assertEqual()", "type": "expression", "loc": [294, 295], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [8, 2, 0.3969, 0.0027, 2, 0.4, 0.9333, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual((mysql and 1) or 0,\n len(Country.objects.filter(mpoly__contains=okcity.point.wkt))) # Qeury w/WKT"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L298_C8", "label": "if", "type": "if", "loc": [298, 301], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "vector": [4, 2, 0.4036, 0.0054, 2, 0.4, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not oracle:\n qs = Country.objects.filter(mpoly__bbcontains=okcity.point)\n self.assertEqual(1, len(qs))\n self.assertEqual('Texas', qs[0].name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L299_C12", "label": "qs = filter()", "type": "assigned_variable", "loc": [299, 299], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L298_C8", "vector": [14, 3, 0.403, 0.0013, 3, 0.87, 0.0, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = Country.objects.filter(mpoly__bbcontains=okcity.point)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L300_C12", "label": "assertEqual()", "type": "expression", "loc": [300, 300], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L298_C8", "vector": [8, 3, 0.4043, 0.0013, 3, 0.87, 0.5, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(1, len(qs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L301_C12", "label": "assertEqual()", "type": "expression", "loc": [301, 301], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L298_C8", "vector": [8, 3, 0.4057, 0.0013, 3, 0.87, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Texas', qs[0].name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "label": "test11_lookup_insert_transform", "type": "function", "loc": [304, 346], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.438, 0.058, 1, 0.06, 0.3667, 17, 0, 1, 0, 0, 0, 0, 13], "semantic": {"name": "test11_lookup_insert_transform", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test11_lookup_insert_transform(self):\n \"Testing automatic transform for lookups and inserts.\"\n # San Antonio in 'WGS84' (SRID 4326)\n sa_4326 = 'POINT (-98.493183 29.424170)'\n wgs_pnt = fromstr(sa_4326, srid=4326) # Our reference point in WGS84\n\n # Oracle doesn't have SRID 3084, using 41157.\n if oracle:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L305_C8", "label": "expression", "type": "expression", "loc": [305, 305], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "vector": [8, 2, 0.4111, 0.0013, 2, 0.01, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing automatic transform for lookups and inserts.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L307_C8", "label": "sa_4326 =", "type": "assigned_variable", "loc": [307, 307], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "vector": [14, 2, 0.4137, 0.0013, 2, 0.01, 0.0909, 976, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "sa_4326", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " sa_4326 = 'POINT (-98.493183 29.424170)'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L308_C8", "label": "wgs_pnt = fromstr()", "type": "assigned_variable", "loc": [308, 308], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "vector": [14, 2, 0.4151, 0.0013, 2, 0.01, 0.1818, 340, 3, 2, 0, 0, 946, 10, 1], "semantic": {"name": "wgs_pnt", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " wgs_pnt = fromstr(sa_4326, srid=4326) # Our reference point in WGS84"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L311_C8", "label": "if", "type": "if", "loc": [311, 320], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "vector": [4, 2, 0.4252, 0.0135, 2, 0.01, 0.2727, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle:\n # San Antonio in 'Texas 4205, Southern Zone (1983, meters)' (SRID 41157)\n # Used the following Oracle SQL to get this value:\n # SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_CS.TRANSFORM(SDO_GEOMETRY('POINT (-98.493183 29.424170)', 4326), 41157)) FROM DUAL;\n nad_wkt = 'POINT (300662.034646583 5416427.45974934)'\n nad_srid = 41157\n else:\n # San Antonio in 'NAD83(HARN) / Texas Centric Lambert Conformal' (SRID 3084)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L315_C12", "label": "nad_wkt =", "type": "assigned_variable", "loc": [315, 315], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L311_C8", "vector": [14, 3, 0.4245, 0.0013, 3, 0.44, 0.0, 630, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "nad_wkt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " nad_wkt = 'POINT (300662.034646583 5416427.45974934)'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L316_C12", "label": "nad_srid =", "type": "assigned_variable", "loc": [316, 316], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L311_C8", "vector": [14, 3, 0.4259, 0.0013, 3, 0.44, 0.3333, 906, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "nad_srid", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " nad_srid = 41157"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L319_C12", "label": "nad_wkt =", "type": "assigned_variable", "loc": [319, 319], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L311_C8", "vector": [14, 3, 0.4299, 0.0013, 3, 0.44, 0.6667, 630, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "nad_wkt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " nad_wkt = 'POINT (1645978.362408288754523 6276356.025927528738976)' # Used ogr.py in gdal 1.4.1 for this transform"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L320_C12", "label": "nad_srid =", "type": "assigned_variable", "loc": [320, 320], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L311_C8", "vector": [14, 3, 0.4313, 0.0013, 3, 0.44, 1.0, 906, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "nad_srid", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " nad_srid = 3084"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L325_C8", "label": "nad_pnt = fromstr()", "type": "assigned_variable", "loc": [325, 325], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "vector": [14, 2, 0.438, 0.0013, 2, 0.01, 0.3636, 461, 3, 2, 0, 0, 946, 10, 1], "semantic": {"name": "nad_pnt", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " nad_pnt = fromstr(nad_wkt, srid=nad_srid)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L326_C8", "label": "if", "type": "if", "loc": [326, 329], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "vector": [4, 2, 0.4414, 0.0054, 2, 0.01, 0.4545, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle:\n tx = Country.objects.get(mpoly__contains=nad_pnt)\n else:\n tx = Country.objects.get(mpoly__intersects=nad_pnt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L327_C12", "label": "tx = get()", "type": "assigned_variable", "loc": [327, 327], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L326_C8", "vector": [14, 3, 0.4407, 0.0013, 3, 0.4, 0.0, 82, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "tx", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " tx = Country.objects.get(mpoly__contains=nad_pnt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L329_C12", "label": "tx = get()", "type": "assigned_variable", "loc": [329, 329], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L326_C8", "vector": [14, 3, 0.4434, 0.0013, 3, 0.4, 1.0, 82, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "tx", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " tx = Country.objects.get(mpoly__intersects=nad_pnt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L330_C8", "label": "assertEqual()", "type": "expression", "loc": [330, 330], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "vector": [8, 2, 0.4447, 0.0013, 2, 0.01, 0.5455, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Texas', tx.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L333_C8", "label": "sa = create()", "type": "assigned_variable", "loc": [333, 333], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "vector": [14, 2, 0.4488, 0.0013, 2, 0.01, 0.6364, 756, 3, 2, 0, 0, 316, 10, 1], "semantic": {"name": "sa", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " sa = City.objects.create(name='San Antonio', point=nad_pnt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L336_C8", "label": "sa = get()", "type": "assigned_variable", "loc": [336, 336], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "vector": [14, 2, 0.4528, 0.0013, 2, 0.01, 0.7273, 756, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "sa", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " sa = City.objects.get(name='San Antonio')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L337_C8", "label": "assertAlmostEqual()", "type": "expression", "loc": [337, 337], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "vector": [8, 2, 0.4542, 0.0013, 2, 0.01, 0.8182, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(wgs_pnt.x, sa.point.x, 6)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L338_C8", "label": "assertAlmostEqual()", "type": "expression", "loc": [338, 338], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "vector": [8, 2, 0.4555, 0.0013, 2, 0.01, 0.9091, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(wgs_pnt.y, sa.point.y, 6)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L343_C8", "label": "if", "type": "if", "loc": [343, 346], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "vector": [4, 2, 0.4643, 0.0054, 2, 0.01, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not spatialite:\n m1 = MinusOneSRID(geom=Point(17, 23, srid=4326))\n m1.save()\n self.assertEqual(-1, m1.geom.srid)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L344_C12", "label": "m1 = MinusOneSRID()", "type": "assigned_variable", "loc": [344, 344], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L343_C8", "vector": [14, 3, 0.4636, 0.0013, 3, 0.05, 0.0, 814, 3, 1, 0, 0, 154, 10, 2], "semantic": {"name": "m1", "arg_names": [], "import_names": [], "rhs_call_name": "MinusOneSRID", "annotation": ""}, "snippet": " m1 = MinusOneSRID(geom=Point(17, 23, srid=4326))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L345_C12", "label": "save()", "type": "expression", "loc": [345, 345], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L343_C8", "vector": [8, 3, 0.465, 0.0013, 3, 0.05, 0.5, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " m1.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L346_C12", "label": "assertEqual()", "type": "expression", "loc": [346, 346], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L343_C8", "vector": [8, 3, 0.4663, 0.0013, 3, 0.05, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(-1, m1.geom.srid)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "label": "test12_null_geometries", "type": "function", "loc": [349, 376], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.4885, 0.0377, 1, 0.06, 0.4, 773, 0, 1, 0, 0, 0, 0, 17], "semantic": {"name": "test12_null_geometries", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test12_null_geometries(self):\n \"Testing NULL geometry support, and the `isnull` lookup type.\"\n # Creating a state with a NULL boundary.\n State.objects.create(name='Puerto Rico')\n\n # Querying for both NULL and Non-NULL values.\n nullqs = State.objects.filter(poly__isnull=True)\n validqs = State.objects.filter(poly__isnull=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L350_C8", "label": "expression", "type": "expression", "loc": [350, 350], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [8, 2, 0.4717, 0.0013, 2, 0.73, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing NULL geometry support, and the `isnull` lookup type.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L352_C8", "label": "create()", "type": "expression", "loc": [352, 352], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [8, 2, 0.4744, 0.0013, 2, 0.73, 0.0667, 316, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " State.objects.create(name='Puerto Rico')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L355_C8", "label": "nullqs = filter()", "type": "assigned_variable", "loc": [355, 355], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [14, 2, 0.4784, 0.0013, 2, 0.73, 0.1333, 427, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "nullqs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " nullqs = State.objects.filter(poly__isnull=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L356_C8", "label": "validqs = filter()", "type": "assigned_variable", "loc": [356, 356], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [14, 2, 0.4798, 0.0013, 2, 0.73, 0.2, 2, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "validqs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " validqs = State.objects.filter(poly__isnull=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L359_C8", "label": "assertEqual()", "type": "expression", "loc": [359, 359], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [8, 2, 0.4838, 0.0013, 2, 0.73, 0.2667, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(1, len(nullqs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L360_C8", "label": "assertEqual()", "type": "expression", "loc": [360, 360], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [8, 2, 0.4852, 0.0013, 2, 0.73, 0.3333, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Puerto Rico', nullqs[0].name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L363_C8", "label": "assertEqual()", "type": "expression", "loc": [363, 363], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [8, 2, 0.4892, 0.0013, 2, 0.73, 0.4, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(2, len(validqs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L364_C8", "label": "state_names =", "type": "assigned_variable", "loc": [364, 364], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [14, 2, 0.4906, 0.0013, 2, 0.73, 0.4667, 681, 5, 0, 0, 0, 0, 0, 0], "semantic": {"name": "state_names", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " state_names = [s.name for s in validqs]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L365_C8", "label": "assertEqual()", "type": "expression", "loc": [365, 365], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [8, 2, 0.4919, 0.0013, 2, 0.73, 0.5333, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(True, 'Colorado' in state_names)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L366_C8", "label": "assertEqual()", "type": "expression", "loc": [366, 366], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [8, 2, 0.4933, 0.0013, 2, 0.73, 0.6, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(True, 'Kansas' in state_names)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L369_C8", "label": "nmi = create()", "type": "assigned_variable", "loc": [369, 369], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [14, 2, 0.4973, 0.0013, 2, 0.73, 0.6667, 217, 3, 2, 0, 0, 316, 10, 1], "semantic": {"name": "nmi", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " nmi = State.objects.create(name='Northern Mariana Islands', poly=None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L370_C8", "label": "assertEqual()", "type": "expression", "loc": [370, 370], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [8, 2, 0.4987, 0.0013, 2, 0.73, 0.7333, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(nmi.poly, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L373_C8", "label": "nmi.poly =", "type": "assigned_variable", "loc": [373, 373], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [14, 2, 0.5027, 0.0013, 2, 0.73, 0.8, 121, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "nmi.poly", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " nmi.poly = 'POLYGON((0 0,1 0,1 1,1 0,0 0))'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L374_C8", "label": "save()", "type": "expression", "loc": [374, 374], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [8, 2, 0.504, 0.0013, 2, 0.73, 0.8667, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " nmi.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L375_C8", "label": "update()", "type": "expression", "loc": [375, 375], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [8, 2, 0.5054, 0.0013, 2, 0.73, 0.9333, 637, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " State.objects.filter(name='Northern Mariana Islands').update(poly=None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L376_C8", "label": "assertEqual()", "type": "expression", "loc": [376, 376], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "vector": [8, 2, 0.5067, 0.0013, 2, 0.73, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(None, State.objects.get(name='Northern Mariana Islands').poly)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "label": "test13_left_right", "type": "function", "loc": [382, 416], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.5377, 0.0472, 1, 0.06, 0.4333, 415, 0, 1, 0, 0, 0, 0, 16], "semantic": {"name": "test13_left_right", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test13_left_right(self):\n \"Testing the 'left' and 'right' lookup types.\"\n # Left: A << B => true if xmax(A) < xmin(B)\n # Right: A >> B => true if xmin(A) > xmax(B)\n # See: BOX2D_left() and BOX2D_right() in lwgeom_box2dfloat4.c in PostGIS source.\n\n # Getting the borders for Colorado & Kansas\n co_border = State.objects.get(name='Colorado').poly"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L383_C8", "label": "expression", "type": "expression", "loc": [383, 383], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [8, 2, 0.5162, 0.0013, 2, 0.63, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the 'left' and 'right' lookup types.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L389_C8", "label": "co_border =", "type": "assigned_variable", "loc": [389, 389], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [14, 2, 0.5243, 0.0013, 2, 0.63, 0.0625, 125, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "co_border", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " co_border = State.objects.get(name='Colorado').poly"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L390_C8", "label": "ks_border =", "type": "assigned_variable", "loc": [390, 390], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [14, 2, 0.5256, 0.0013, 2, 0.63, 0.125, 160, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "ks_border", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ks_border = State.objects.get(name='Kansas').poly"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L396_C8", "label": "cities =", "type": "assigned_variable", "loc": [396, 397], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [14, 2, 0.5344, 0.0027, 2, 0.63, 0.1875, 884, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "cities", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cities = ['Houston', 'Dallas', 'Oklahoma City',\n 'Lawrence', 'Chicago', 'Wellington']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L398_C8", "label": "qs = filter()", "type": "assigned_variable", "loc": [398, 398], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [14, 2, 0.5364, 0.0013, 2, 0.63, 0.25, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = City.objects.filter(point__right=co_border)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L399_C8", "label": "assertEqual()", "type": "expression", "loc": [399, 399], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [8, 2, 0.5377, 0.0013, 2, 0.63, 0.3125, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(6, len(qs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L400_C8", "label": "for c", "type": "for", "loc": [400, 400], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [6, 2, 0.5391, 0.0013, 2, 0.63, 0.375, 411, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in qs: self.assertEqual(True, c.name in cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L400_C21", "label": "assertEqual()", "type": "expression", "loc": [400, 400], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L400_C8", "vector": [8, 3, 0.5391, 0.0013, 3, 0.4, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " for c in qs: self.assertEqual(True, c.name in cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L403_C8", "label": "cities =", "type": "assigned_variable", "loc": [403, 403], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [14, 2, 0.5431, 0.0013, 2, 0.63, 0.4375, 884, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "cities", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cities = ['Chicago', 'Wellington']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L404_C8", "label": "qs = filter()", "type": "assigned_variable", "loc": [404, 404], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [14, 2, 0.5445, 0.0013, 2, 0.63, 0.5, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = City.objects.filter(point__right=ks_border)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L405_C8", "label": "assertEqual()", "type": "expression", "loc": [405, 405], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [8, 2, 0.5458, 0.0013, 2, 0.63, 0.5625, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(2, len(qs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L406_C8", "label": "for c", "type": "for", "loc": [406, 406], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [6, 2, 0.5472, 0.0013, 2, 0.63, 0.625, 411, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in qs: self.assertEqual(True, c.name in cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L406_C21", "label": "assertEqual()", "type": "expression", "loc": [406, 406], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L406_C8", "vector": [8, 3, 0.5472, 0.0013, 3, 0.91, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " for c in qs: self.assertEqual(True, c.name in cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L410_C8", "label": "vic = get()", "type": "assigned_variable", "loc": [410, 410], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [14, 2, 0.5526, 0.0013, 2, 0.63, 0.6875, 498, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "vic", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " vic = City.objects.get(point__left=co_border)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L411_C8", "label": "assertEqual()", "type": "expression", "loc": [411, 411], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [8, 2, 0.5539, 0.0013, 2, 0.63, 0.75, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Victoria', vic.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L413_C8", "label": "cities =", "type": "assigned_variable", "loc": [413, 413], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [14, 2, 0.5566, 0.0013, 2, 0.63, 0.8125, 884, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "cities", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cities = ['Pueblo', 'Victoria']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L414_C8", "label": "qs = filter()", "type": "assigned_variable", "loc": [414, 414], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [14, 2, 0.558, 0.0013, 2, 0.63, 0.875, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = City.objects.filter(point__left=ks_border)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L415_C8", "label": "assertEqual()", "type": "expression", "loc": [415, 415], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [8, 2, 0.5593, 0.0013, 2, 0.63, 0.9375, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(2, len(qs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L416_C8", "label": "for c", "type": "for", "loc": [416, 416], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "vector": [6, 2, 0.5606, 0.0013, 2, 0.63, 1.0, 411, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in qs: self.assertEqual(True, c.name in cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L416_C21", "label": "assertEqual()", "type": "expression", "loc": [416, 416], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L416_C8", "vector": [8, 3, 0.5606, 0.0013, 3, 0.84, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " for c in qs: self.assertEqual(True, c.name in cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "label": "test14_equals", "type": "function", "loc": [418, 424], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.5674, 0.0094, 1, 0.06, 0.4667, 559, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test14_equals", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test14_equals(self):\n \"Testing the 'same_as' and 'equals' lookup types.\"\n pnt = fromstr('POINT (-95.363151 29.763374)', srid=4326)\n c1 = City.objects.get(point=pnt)\n c2 = City.objects.get(point__same_as=pnt)\n c3 = City.objects.get(point__equals=pnt)\n for c in [c1, c2, c3]: self.assertEqual('Houston', c.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L419_C8", "label": "expression", "type": "expression", "loc": [419, 419], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "vector": [8, 2, 0.5647, 0.0013, 2, 0.39, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the 'same_as' and 'equals' lookup types.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L420_C8", "label": "pnt = fromstr()", "type": "assigned_variable", "loc": [420, 420], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "vector": [14, 2, 0.566, 0.0013, 2, 0.39, 0.2, 41, 3, 2, 0, 0, 946, 10, 1], "semantic": {"name": "pnt", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " pnt = fromstr('POINT (-95.363151 29.763374)', srid=4326)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L421_C8", "label": "c1 = get()", "type": "assigned_variable", "loc": [421, 421], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "vector": [14, 2, 0.5674, 0.0013, 2, 0.39, 0.4, 452, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "c1", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " c1 = City.objects.get(point=pnt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L422_C8", "label": "c2 = get()", "type": "assigned_variable", "loc": [422, 422], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "vector": [14, 2, 0.5687, 0.0013, 2, 0.39, 0.6, 600, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "c2", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " c2 = City.objects.get(point__same_as=pnt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L423_C8", "label": "c3 = get()", "type": "assigned_variable", "loc": [423, 423], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "vector": [14, 2, 0.5701, 0.0013, 2, 0.39, 0.8, 357, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "c3", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " c3 = City.objects.get(point__equals=pnt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L424_C8", "label": "for c", "type": "for", "loc": [424, 424], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "vector": [6, 2, 0.5714, 0.0013, 2, 0.39, 1.0, 411, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in [c1, c2, c3]: self.assertEqual('Houston', c.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L424_C31", "label": "assertEqual()", "type": "expression", "loc": [424, 424], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L424_C8", "vector": [8, 3, 0.5714, 0.0013, 3, 0.16, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " for c in [c1, c2, c3]: self.assertEqual('Houston', c.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "label": "test15_relate", "type": "function", "loc": [427, 467], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.6024, 0.0553, 1, 0.06, 0.5, 190, 0, 1, 0, 0, 0, 0, 18], "semantic": {"name": "test15_relate", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test15_relate(self):\n \"Testing the 'relate' lookup type.\"\n # To make things more interesting, we will have our Texas reference point in\n # different SRIDs.\n pnt1 = fromstr('POINT (649287.0363174 4177429.4494686)', srid=2847)\n pnt2 = fromstr('POINT(-98.4919715741052 29.4333344025053)', srid=4326)\n\n # Not passing in a geometry as first param shoud"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L428_C8", "label": "expression", "type": "expression", "loc": [428, 428], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "vector": [8, 2, 0.5768, 0.0013, 2, 0.16, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the 'relate' lookup type.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L431_C8", "label": "pnt1 = fromstr()", "type": "assigned_variable", "loc": [431, 431], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "vector": [14, 2, 0.5809, 0.0013, 2, 0.16, 0.1, 149, 3, 2, 0, 0, 946, 10, 1], "semantic": {"name": "pnt1", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " pnt1 = fromstr('POINT (649287.0363174 4177429.4494686)', srid=2847)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L432_C8", "label": "pnt2 = fromstr()", "type": "assigned_variable", "loc": [432, 432], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "vector": [14, 2, 0.5822, 0.0013, 2, 0.16, 0.2, 841, 3, 2, 0, 0, 946, 10, 1], "semantic": {"name": "pnt2", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " pnt2 = fromstr('POINT(-98.4919715741052 29.4333344025053)', srid=4326)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L436_C8", "label": "assertRaises()", "type": "expression", "loc": [436, 436], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "vector": [8, 2, 0.5876, 0.0013, 2, 0.16, 0.3, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, Country.objects.filter, mpoly__relate=(23, 'foo'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L440_C8", "label": "for bad_args, e", "type": "for", "loc": [440, 442], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "vector": [6, 2, 0.5943, 0.004, 2, 0.16, 0.4, 322, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "bad_args, e", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for bad_args, e in [((pnt1, 0), ValueError), ((pnt2, 'T*T***FF*', 0), ValueError)]:\n qs = Country.objects.filter(mpoly__relate=bad_args)\n self.assertRaises(e, qs.count)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L441_C12", "label": "qs = filter()", "type": "assigned_variable", "loc": [441, 441], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L440_C8", "vector": [14, 3, 0.5943, 0.0013, 3, 0.06, 0.0, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = Country.objects.filter(mpoly__relate=bad_args)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L442_C12", "label": "assertRaises()", "type": "expression", "loc": [442, 442], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L440_C8", "vector": [8, 3, 0.5957, 0.0013, 3, 0.06, 1.0, 11, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(e, qs.count)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L445_C8", "label": "if", "type": "if", "loc": [445, 453], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "vector": [4, 2, 0.6051, 0.0121, 2, 0.16, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if postgis or spatialite:\n contains_mask = 'T*T***FF*'\n within_mask = 'T*F**F***'\n intersects_mask = 'T********'\n elif oracle:\n contains_mask = 'contains'\n within_mask = 'inside'\n # TODO: This is not quite the same as the PostGIS mask above"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L446_C12", "label": "contains_mask =", "type": "assigned_variable", "loc": [446, 446], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L445_C8", "vector": [14, 3, 0.6011, 0.0013, 3, 0.75, 0.0, 117, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "contains_mask", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " contains_mask = 'T*T***FF*'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L447_C12", "label": "within_mask =", "type": "assigned_variable", "loc": [447, 447], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L445_C8", "vector": [14, 3, 0.6024, 0.0013, 3, 0.75, 0.3333, 649, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "within_mask", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " within_mask = 'T*F**F***'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L448_C12", "label": "intersects_mask =", "type": "assigned_variable", "loc": [448, 448], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L445_C8", "vector": [14, 3, 0.6038, 0.0013, 3, 0.75, 0.6667, 151, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "intersects_mask", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " intersects_mask = 'T********'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L449_C8", "label": "if", "type": "if", "loc": [449, 453], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L445_C8", "vector": [4, 3, 0.6078, 0.0067, 3, 0.75, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif oracle:\n contains_mask = 'contains'\n within_mask = 'inside'\n # TODO: This is not quite the same as the PostGIS mask above\n intersects_mask = 'overlapbdyintersect'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L450_C12", "label": "contains_mask =", "type": "assigned_variable", "loc": [450, 450], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L449_C8", "vector": [14, 4, 0.6065, 0.0013, 4, 0.23, 0.0, 117, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "contains_mask", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " contains_mask = 'contains'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L451_C12", "label": "within_mask =", "type": "assigned_variable", "loc": [451, 451], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L449_C8", "vector": [14, 4, 0.6078, 0.0013, 4, 0.23, 0.5, 649, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "within_mask", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " within_mask = 'inside'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L453_C12", "label": "intersects_mask =", "type": "assigned_variable", "loc": [453, 453], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L449_C8", "vector": [14, 4, 0.6105, 0.0013, 4, 0.23, 1.0, 151, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "intersects_mask", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " intersects_mask = 'overlapbdyintersect'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L456_C8", "label": "assertEqual()", "type": "expression", "loc": [456, 456], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "vector": [8, 2, 0.6146, 0.0013, 2, 0.16, 0.6, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt1, contains_mask)).name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L457_C8", "label": "assertEqual()", "type": "expression", "loc": [457, 457], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "vector": [8, 2, 0.6159, 0.0013, 2, 0.16, 0.7, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt2, contains_mask)).name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L460_C8", "label": "ks = get()", "type": "assigned_variable", "loc": [460, 460], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "vector": [14, 2, 0.6199, 0.0013, 2, 0.16, 0.8, 316, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "ks", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " ks = State.objects.get(name='Kansas')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L461_C8", "label": "assertEqual()", "type": "expression", "loc": [461, 461], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "vector": [8, 2, 0.6213, 0.0013, 2, 0.16, 0.9, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Lawrence', City.objects.get(point__relate=(ks.poly, within_mask)).name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L464_C8", "label": "if", "type": "if", "loc": [464, 467], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "vector": [4, 2, 0.6274, 0.0054, 2, 0.16, 1.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not oracle:\n self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt1, intersects_mask)).name)\n self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt2, intersects_mask)).name)\n self.assertEqual('Lawrence', City.objects.get(point__relate=(ks.poly, intersects_mask)).name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L465_C12", "label": "assertEqual()", "type": "expression", "loc": [465, 465], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L464_C8", "vector": [8, 3, 0.6267, 0.0013, 3, 0.5, 0.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt1, intersects_mask)).name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L466_C12", "label": "assertEqual()", "type": "expression", "loc": [466, 466], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L464_C8", "vector": [8, 3, 0.628, 0.0013, 3, 0.5, 0.5, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt2, intersects_mask)).name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L467_C12", "label": "assertEqual()", "type": "expression", "loc": [467, 467], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L464_C8", "vector": [8, 3, 0.6294, 0.0013, 3, 0.5, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Lawrence', City.objects.get(point__relate=(ks.poly, intersects_mask)).name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L469_C4", "label": "test16_createnull", "type": "function", "loc": [469, 472], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.6341, 0.0054, 1, 0.06, 0.5333, 177, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test16_createnull", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test16_createnull(self):\n \"Testing creating a model instance and the geometry being None\"\n c = City()\n self.assertEqual(c.point, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L470_C8", "label": "expression", "type": "expression", "loc": [470, 470], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L469_C4", "vector": [8, 2, 0.6334, 0.0013, 2, 0.39, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing creating a model instance and the geometry being None\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L471_C8", "label": "c = City()", "type": "assigned_variable", "loc": [471, 471], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L469_C4", "vector": [14, 2, 0.6348, 0.0013, 2, 0.39, 0.5, 411, 3, 0, 0, 0, 801, 10, 1], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "City", "annotation": ""}, "snippet": " c = City()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L472_C8", "label": "assertEqual()", "type": "expression", "loc": [472, 472], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L469_C4", "vector": [8, 2, 0.6361, 0.0013, 2, 0.39, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(c.point, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "label": "test17_unionagg", "type": "function", "loc": [475, 496], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.6543, 0.0296, 1, 0.06, 0.5667, 707, 0, 1, 0, 0, 0, 0, 15], "semantic": {"name": "test17_unionagg", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test17_unionagg(self):\n \"Testing the `unionagg` (aggregate union) GeoManager method.\"\n tx = Country.objects.get(name='Texas').mpoly\n # Houston, Dallas -- Oracle has different order.\n union1 = fromstr('MULTIPOINT(-96.801611 32.782057,-95.363151 29.763374)')\n union2 = fromstr('MULTIPOINT(-96.801611 32.782057,-95.363151 29.763374)')\n qs = City.objects.filter(point__within=tx)\n self.assertRaises(TypeError, qs.unionagg, 'name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L476_C8", "label": "expression", "type": "expression", "loc": [476, 476], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [8, 2, 0.6415, 0.0013, 2, 0.71, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `unionagg` (aggregate union) GeoManager method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L477_C8", "label": "tx =", "type": "assigned_variable", "loc": [477, 477], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [14, 2, 0.6429, 0.0013, 2, 0.71, 0.0769, 82, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "tx", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tx = Country.objects.get(name='Texas').mpoly"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L479_C8", "label": "union1 = fromstr()", "type": "assigned_variable", "loc": [479, 479], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [14, 2, 0.6456, 0.0013, 2, 0.71, 0.1538, 503, 3, 1, 0, 0, 946, 10, 1], "semantic": {"name": "union1", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " union1 = fromstr('MULTIPOINT(-96.801611 32.782057,-95.363151 29.763374)')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L480_C8", "label": "union2 = fromstr()", "type": "assigned_variable", "loc": [480, 480], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [14, 2, 0.6469, 0.0013, 2, 0.71, 0.2308, 937, 3, 1, 0, 0, 946, 10, 1], "semantic": {"name": "union2", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " union2 = fromstr('MULTIPOINT(-96.801611 32.782057,-95.363151 29.763374)')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L481_C8", "label": "qs = filter()", "type": "assigned_variable", "loc": [481, 481], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [14, 2, 0.6482, 0.0013, 2, 0.71, 0.3077, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = City.objects.filter(point__within=tx)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L482_C8", "label": "assertRaises()", "type": "expression", "loc": [482, 482], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [8, 2, 0.6496, 0.0013, 2, 0.71, 0.3846, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(TypeError, qs.unionagg, 'name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L486_C8", "label": "u1 = unionagg()", "type": "assigned_variable", "loc": [486, 486], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [14, 2, 0.655, 0.0013, 2, 0.71, 0.4615, 74, 3, 1, 0, 0, 886, 10, 1], "semantic": {"name": "u1", "arg_names": [], "import_names": [], "rhs_call_name": "unionagg", "annotation": ""}, "snippet": " u1 = qs.unionagg(field_name='point')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L487_C8", "label": "u2 = unionagg()", "type": "assigned_variable", "loc": [487, 487], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [14, 2, 0.6563, 0.0013, 2, 0.71, 0.5385, 420, 3, 0, 0, 0, 886, 10, 2], "semantic": {"name": "u2", "arg_names": [], "import_names": [], "rhs_call_name": "unionagg", "annotation": ""}, "snippet": " u2 = qs.order_by('name').unionagg()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L488_C8", "label": "tol =", "type": "assigned_variable", "loc": [488, 488], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [14, 2, 0.6577, 0.0013, 2, 0.71, 0.6154, 422, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 0.00001"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L489_C8", "label": "if", "type": "if", "loc": [489, 492], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [4, 2, 0.6611, 0.0054, 2, 0.71, 0.6923, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle:\n union = union2\n else:\n union = union1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L490_C12", "label": "union =", "type": "assigned_variable", "loc": [490, 490], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L489_C8", "vector": [14, 3, 0.6604, 0.0013, 3, 0.9, 0.0, 140, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "union", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " union = union2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L492_C12", "label": "union =", "type": "assigned_variable", "loc": [492, 492], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L489_C8", "vector": [14, 3, 0.6631, 0.0013, 3, 0.9, 1.0, 140, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "union", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " union = union1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L493_C8", "label": "assertEqual()", "type": "expression", "loc": [493, 493], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [8, 2, 0.6644, 0.0013, 2, 0.71, 0.7692, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(True, union.equals_exact(u1, tol))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L494_C8", "label": "assertEqual()", "type": "expression", "loc": [494, 494], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [8, 2, 0.6658, 0.0013, 2, 0.71, 0.8462, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(True, union.equals_exact(u2, tol))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L495_C8", "label": "qs = filter()", "type": "assigned_variable", "loc": [495, 495], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [14, 2, 0.6671, 0.0013, 2, 0.71, 0.9231, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = City.objects.filter(name='NotACity')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L496_C8", "label": "assertEqual()", "type": "expression", "loc": [496, 496], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "vector": [8, 2, 0.6685, 0.0013, 2, 0.71, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(None, qs.unionagg(field_name='point'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "label": "test18_geometryfield", "type": "function", "loc": [499, 519], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.686, 0.0283, 1, 0.06, 0.6, 521, 0, 1, 0, 0, 0, 0, 32], "semantic": {"name": "test18_geometryfield", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test18_geometryfield(self):\n \"Testing the general GeometryField.\"\n Feature(name='Point', geom=Point(1, 1)).save()\n Feature(name='LineString', geom=LineString((0, 0), (1, 1), (5, 5))).save()\n Feature(name='Polygon', geom=Polygon(LinearRing((0, 0), (0, 5), (5, 5), (5, 0), (0, 0)))).save()\n Feature(name='GeometryCollection',\n geom=GeometryCollection(Point(2, 2), LineString((0, 0), (2, 2)),\n Polygon(LinearRing((0, 0), (0, 5), (5, 5), (5, 0), (0, 0))))).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L500_C8", "label": "expression", "type": "expression", "loc": [500, 500], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [8, 2, 0.6739, 0.0013, 2, 0.17, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the general GeometryField.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L501_C8", "label": "save()", "type": "expression", "loc": [501, 501], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [8, 2, 0.6752, 0.0013, 2, 0.17, 0.0667, 928, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " Feature(name='Point', geom=Point(1, 1)).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L502_C8", "label": "save()", "type": "expression", "loc": [502, 502], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [8, 2, 0.6765, 0.0013, 2, 0.17, 0.1333, 928, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " Feature(name='LineString', geom=LineString((0, 0), (1, 1), (5, 5))).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L503_C8", "label": "save()", "type": "expression", "loc": [503, 503], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [8, 2, 0.6779, 0.0013, 2, 0.17, 0.2, 928, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " Feature(name='Polygon', geom=Polygon(LinearRing((0, 0), (0, 5), (5, 5), (5, 0), (0, 0)))).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L504_C8", "label": "save()", "type": "expression", "loc": [504, 506], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [8, 2, 0.6806, 0.004, 2, 0.17, 0.2667, 928, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " Feature(name='GeometryCollection',\n geom=GeometryCollection(Point(2, 2), LineString((0, 0), (2, 2)),\n Polygon(LinearRing((0, 0), (0, 5), (5, 5), (5, 0), (0, 0))))).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L508_C8", "label": "f_1 = get()", "type": "assigned_variable", "loc": [508, 508], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [14, 2, 0.6846, 0.0013, 2, 0.17, 0.3333, 640, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "f_1", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " f_1 = Feature.objects.get(name='Point')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L509_C8", "label": "assertEqual()", "type": "expression", "loc": [509, 509], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [8, 2, 0.686, 0.0013, 2, 0.17, 0.4, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(True, isinstance(f_1.geom, Point))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L510_C8", "label": "assertEqual()", "type": "expression", "loc": [510, 510], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [8, 2, 0.6873, 0.0013, 2, 0.17, 0.4667, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual((1.0, 1.0), f_1.geom.tuple)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L511_C8", "label": "f_2 = get()", "type": "assigned_variable", "loc": [511, 511], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [14, 2, 0.6887, 0.0013, 2, 0.17, 0.5333, 471, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "f_2", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " f_2 = Feature.objects.get(name='LineString')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L512_C8", "label": "assertEqual()", "type": "expression", "loc": [512, 512], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [8, 2, 0.69, 0.0013, 2, 0.17, 0.6, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(True, isinstance(f_2.geom, LineString))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L513_C8", "label": "assertEqual()", "type": "expression", "loc": [513, 513], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [8, 2, 0.6914, 0.0013, 2, 0.17, 0.6667, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(((0.0, 0.0), (1.0, 1.0), (5.0, 5.0)), f_2.geom.tuple)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L515_C8", "label": "f_3 = get()", "type": "assigned_variable", "loc": [515, 515], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [14, 2, 0.6941, 0.0013, 2, 0.17, 0.7333, 515, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "f_3", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " f_3 = Feature.objects.get(name='Polygon')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L516_C8", "label": "assertEqual()", "type": "expression", "loc": [516, 516], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [8, 2, 0.6954, 0.0013, 2, 0.17, 0.8, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(True, isinstance(f_3.geom, Polygon))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L517_C8", "label": "f_4 = get()", "type": "assigned_variable", "loc": [517, 517], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [14, 2, 0.6968, 0.0013, 2, 0.17, 0.8667, 805, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "f_4", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " f_4 = Feature.objects.get(name='GeometryCollection')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L518_C8", "label": "assertEqual()", "type": "expression", "loc": [518, 518], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [8, 2, 0.6981, 0.0013, 2, 0.17, 0.9333, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(True, isinstance(f_4.geom, GeometryCollection))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L519_C8", "label": "assertEqual()", "type": "expression", "loc": [519, 519], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "vector": [8, 2, 0.6995, 0.0013, 2, 0.17, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(f_3.geom, f_4.geom[2])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L522_C4", "label": "test19_centroid", "type": "function", "loc": [522, 532], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.7102, 0.0148, 1, 0.06, 0.6333, 321, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test19_centroid", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test19_centroid(self):\n \"Testing the `centroid` GeoQuerySet method.\"\n qs = State.objects.exclude(poly__isnull=True).centroid()\n if oracle:\n tol = 0.1\n elif spatialite:\n tol = 0.000001\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L523_C8", "label": "expression", "type": "expression", "loc": [523, 523], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L522_C4", "vector": [8, 2, 0.7049, 0.0013, 2, 0.05, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `centroid` GeoQuerySet method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L524_C8", "label": "qs = centroid()", "type": "assigned_variable", "loc": [524, 524], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L522_C4", "vector": [14, 2, 0.7062, 0.0013, 2, 0.05, 0.3333, 251, 3, 0, 0, 0, 439, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "centroid", "annotation": ""}, "snippet": " qs = State.objects.exclude(poly__isnull=True).centroid()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L525_C8", "label": "if", "type": "if", "loc": [525, 530], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L522_C4", "vector": [4, 2, 0.7109, 0.0081, 2, 0.05, 0.6667, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle:\n tol = 0.1\n elif spatialite:\n tol = 0.000001\n else:\n tol = 0.000000001"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L526_C12", "label": "tol =", "type": "assigned_variable", "loc": [526, 526], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L525_C8", "vector": [14, 3, 0.7089, 0.0013, 3, 0.17, 0.0, 422, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 0.1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L527_C8", "label": "if", "type": "if", "loc": [527, 530], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L525_C8", "vector": [4, 3, 0.7123, 0.0054, 3, 0.17, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif spatialite:\n tol = 0.000001\n else:\n tol = 0.000000001"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L528_C12", "label": "tol =", "type": "assigned_variable", "loc": [528, 528], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L527_C8", "vector": [14, 4, 0.7116, 0.0013, 4, 0.98, 0.0, 422, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 0.000001"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L530_C12", "label": "tol =", "type": "assigned_variable", "loc": [530, 530], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L527_C8", "vector": [14, 4, 0.7143, 0.0013, 4, 0.98, 1.0, 422, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 0.000000001"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L531_C8", "label": "for s", "type": "for", "loc": [531, 532], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L522_C4", "vector": [6, 2, 0.7163, 0.0027, 2, 0.05, 1.0, 553, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "s", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for s in qs:\n self.assertEqual(True, s.poly.centroid.equals_exact(s.centroid, tol))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L532_C12", "label": "assertEqual()", "type": "expression", "loc": [532, 532], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L531_C8", "vector": [8, 3, 0.717, 0.0013, 3, 0.03, 0.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(True, s.poly.centroid.equals_exact(s.centroid, tol))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L535_C4", "label": "test20_pointonsurface", "type": "function", "loc": [535, 557], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.7358, 0.031, 1, 0.06, 0.6667, 107, 0, 1, 0, 0, 0, 0, 7], "semantic": {"name": "test20_pointonsurface", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test20_pointonsurface(self):\n \"Testing the `point_on_surface` GeoQuerySet method.\"\n # Reference values.\n if oracle:\n # SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_GEOM.SDO_POINTONSURFACE(GEOAPP_COUNTRY.MPOLY, 0.05)) FROM GEOAPP_COUNTRY;\n ref = {'New Zealand' : fromstr('POINT (174.616364 -36.100861)', srid=4326),\n 'Texas' : fromstr('POINT (-103.002434 36.500397)', srid=4326),\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L536_C8", "label": "expression", "type": "expression", "loc": [536, 536], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L535_C4", "vector": [8, 2, 0.7224, 0.0013, 2, 0.37, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `point_on_surface` GeoQuerySet method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L538_C8", "label": "if", "type": "if", "loc": [538, 549], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L535_C4", "vector": [4, 2, 0.7325, 0.0162, 2, 0.37, 0.5, 0, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle:\n # SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_GEOM.SDO_POINTONSURFACE(GEOAPP_COUNTRY.MPOLY, 0.05)) FROM GEOAPP_COUNTRY;\n ref = {'New Zealand' : fromstr('POINT (174.616364 -36.100861)', srid=4326),\n 'Texas' : fromstr('POINT (-103.002434 36.500397)', srid=4326),\n }\n\n elif postgis or spatialite:\n # Using GEOSGeometry to compute the reference point on surface values"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L540_C12", "label": "ref =", "type": "assigned_variable", "loc": [540, 542], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L538_C8", "vector": [14, 3, 0.7291, 0.004, 3, 0.77, 0.0, 686, 0, 0, 0, 0, 0, 6, 2], "semantic": {"name": "ref", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref = {'New Zealand' : fromstr('POINT (174.616364 -36.100861)', srid=4326),\n 'Texas' : fromstr('POINT (-103.002434 36.500397)', srid=4326),\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L544_C8", "label": "if", "type": "if", "loc": [544, 549], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L538_C8", "vector": [4, 3, 0.7365, 0.0081, 3, 0.77, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif postgis or spatialite:\n # Using GEOSGeometry to compute the reference point on surface values\n # -- since PostGIS also uses GEOS these should be the same.\n ref = {'New Zealand' : Country.objects.get(name='New Zealand').mpoly.point_on_surface,\n 'Texas' : Country.objects.get(name='Texas').mpoly.point_on_surface\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L547_C12", "label": "ref =", "type": "assigned_variable", "loc": [547, 549], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L544_C8", "vector": [14, 4, 0.7385, 0.004, 4, 0.35, 0.0, 686, 0, 0, 0, 0, 0, 6, 2], "semantic": {"name": "ref", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref = {'New Zealand' : Country.objects.get(name='New Zealand').mpoly.point_on_surface,\n 'Texas' : Country.objects.get(name='Texas').mpoly.point_on_surface\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L551_C8", "label": "for c", "type": "for", "loc": [551, 557], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L535_C4", "vector": [6, 2, 0.7466, 0.0094, 2, 0.37, 1.0, 411, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in Country.objects.point_on_surface():\n if spatialite:\n # XXX This seems to be a WKT-translation-related precision issue?\n tol = 0.00001\n else:\n tol = 0.000000001\n self.assertEqual(True, ref[c.name].equals_exact(c.point_on_surface, tol))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L552_C12", "label": "if", "type": "if", "loc": [552, 556], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L551_C8", "vector": [4, 3, 0.7466, 0.0067, 3, 0.93, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if spatialite:\n # XXX This seems to be a WKT-translation-related precision issue?\n tol = 0.00001\n else:\n tol = 0.000000001"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L554_C16", "label": "tol =", "type": "assigned_variable", "loc": [554, 554], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L552_C12", "vector": [14, 4, 0.7466, 0.0013, 4, 0.51, 0.0, 422, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 0.00001"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L556_C16", "label": "tol =", "type": "assigned_variable", "loc": [556, 556], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L552_C12", "vector": [14, 4, 0.7493, 0.0013, 4, 0.51, 1.0, 422, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 0.000000001"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L557_C12", "label": "assertEqual()", "type": "expression", "loc": [557, 557], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L551_C8", "vector": [8, 3, 0.7507, 0.0013, 3, 0.93, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(True, ref[c.name].equals_exact(c.point_on_surface, tol))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L561_C4", "label": "test21_scale", "type": "function", "loc": [561, 571], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.7628, 0.0148, 1, 0.06, 0.7, 622, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test21_scale", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test21_scale(self):\n \"Testing the `scale` GeoQuerySet method.\"\n xfac, yfac = 2, 3\n tol = 5 # XXX The low precision tolerance is for SpatiaLite\n qs = Country.objects.scale(xfac, yfac, model_att='scaled')\n for c in qs:\n for p1, p2 in zip(c.mpoly, c.scaled):\n for r1, r2 in zip(p1, p2):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L562_C8", "label": "expression", "type": "expression", "loc": [562, 562], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L561_C4", "vector": [8, 2, 0.7574, 0.0013, 2, 0.91, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `scale` GeoQuerySet method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L563_C8", "label": "xfac, yfac =", "type": "assigned_variable", "loc": [563, 563], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L561_C4", "vector": [14, 2, 0.7588, 0.0013, 2, 0.91, 0.25, 649, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "xfac, yfac", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " xfac, yfac = 2, 3"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L564_C8", "label": "tol =", "type": "assigned_variable", "loc": [564, 564], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L561_C4", "vector": [14, 2, 0.7601, 0.0013, 2, 0.91, 0.5, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 5 # XXX The low precision tolerance is for SpatiaLite"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L565_C8", "label": "qs = scale()", "type": "assigned_variable", "loc": [565, 565], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L561_C4", "vector": [14, 2, 0.7615, 0.0013, 2, 0.91, 0.75, 251, 3, 3, 0, 0, 18, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "scale", "annotation": ""}, "snippet": " qs = Country.objects.scale(xfac, yfac, model_att='scaled')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L566_C8", "label": "for c", "type": "for", "loc": [566, 571], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L561_C4", "vector": [6, 2, 0.7662, 0.0081, 2, 0.91, 1.0, 411, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in qs:\n for p1, p2 in zip(c.mpoly, c.scaled):\n for r1, r2 in zip(p1, p2):\n for c1, c2 in zip(r1.coords, r2.coords):\n self.assertAlmostEqual(c1[0] * xfac, c2[0], tol)\n self.assertAlmostEqual(c1[1] * yfac, c2[1], tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L567_C12", "label": "for p1, p2", "type": "for", "loc": [567, 571], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L566_C8", "vector": [6, 3, 0.7668, 0.0067, 3, 0.8, 0.0, 581, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "p1, p2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for p1, p2 in zip(c.mpoly, c.scaled):\n for r1, r2 in zip(p1, p2):\n for c1, c2 in zip(r1.coords, r2.coords):\n self.assertAlmostEqual(c1[0] * xfac, c2[0], tol)\n self.assertAlmostEqual(c1[1] * yfac, c2[1], tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L568_C16", "label": "for r1, r2", "type": "for", "loc": [568, 571], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L567_C12", "vector": [6, 4, 0.7675, 0.0054, 4, 0.88, 0.0, 428, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "r1, r2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for r1, r2 in zip(p1, p2):\n for c1, c2 in zip(r1.coords, r2.coords):\n self.assertAlmostEqual(c1[0] * xfac, c2[0], tol)\n self.assertAlmostEqual(c1[1] * yfac, c2[1], tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L569_C20", "label": "for c1, c2", "type": "for", "loc": [569, 571], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L568_C16", "vector": [6, 5, 0.7682, 0.004, 5, 0.47, 0.0, 680, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "c1, c2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c1, c2 in zip(r1.coords, r2.coords):\n self.assertAlmostEqual(c1[0] * xfac, c2[0], tol)\n self.assertAlmostEqual(c1[1] * yfac, c2[1], tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L570_C24", "label": "assertAlmostEqual()", "type": "expression", "loc": [570, 570], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L569_C20", "vector": [8, 6, 0.7682, 0.0013, 6, 0.23, 0.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(c1[0] * xfac, c2[0], tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L571_C24", "label": "assertAlmostEqual()", "type": "expression", "loc": [571, 571], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L569_C20", "vector": [8, 6, 0.7695, 0.0013, 6, 0.23, 1.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(c1[1] * yfac, c2[1], tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L575_C4", "label": "test22_translate", "type": "function", "loc": [575, 585], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.7817, 0.0148, 1, 0.06, 0.7333, 809, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test22_translate", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test22_translate(self):\n \"Testing the `translate` GeoQuerySet method.\"\n xfac, yfac = 5, -23\n qs = Country.objects.translate(xfac, yfac, model_att='translated')\n for c in qs:\n for p1, p2 in zip(c.mpoly, c.translated):\n for r1, r2 in zip(p1, p2):\n for c1, c2 in zip(r1.coords, r2.coords):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L576_C8", "label": "expression", "type": "expression", "loc": [576, 576], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L575_C4", "vector": [8, 2, 0.7763, 0.0013, 2, 0.5, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `translate` GeoQuerySet method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L577_C8", "label": "xfac, yfac =", "type": "assigned_variable", "loc": [577, 577], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L575_C4", "vector": [14, 2, 0.7776, 0.0013, 2, 0.5, 0.3333, 649, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "xfac, yfac", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " xfac, yfac = 5, -23"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L578_C8", "label": "qs = translate()", "type": "assigned_variable", "loc": [578, 578], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L575_C4", "vector": [14, 2, 0.779, 0.0013, 2, 0.5, 0.6667, 251, 3, 3, 0, 0, 384, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "translate", "annotation": ""}, "snippet": " qs = Country.objects.translate(xfac, yfac, model_att='translated')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L579_C8", "label": "for c", "type": "for", "loc": [579, 585], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L575_C4", "vector": [6, 2, 0.7844, 0.0094, 2, 0.5, 1.0, 411, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in qs:\n for p1, p2 in zip(c.mpoly, c.translated):\n for r1, r2 in zip(p1, p2):\n for c1, c2 in zip(r1.coords, r2.coords):\n # XXX The low precision is for SpatiaLite\n self.assertAlmostEqual(c1[0] + xfac, c2[0], 5)\n self.assertAlmostEqual(c1[1] + yfac, c2[1], 5)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L580_C12", "label": "for p1, p2", "type": "for", "loc": [580, 585], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L579_C8", "vector": [6, 3, 0.785, 0.0081, 3, 0.79, 0.0, 581, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "p1, p2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for p1, p2 in zip(c.mpoly, c.translated):\n for r1, r2 in zip(p1, p2):\n for c1, c2 in zip(r1.coords, r2.coords):\n # XXX The low precision is for SpatiaLite\n self.assertAlmostEqual(c1[0] + xfac, c2[0], 5)\n self.assertAlmostEqual(c1[1] + yfac, c2[1], 5)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L581_C16", "label": "for r1, r2", "type": "for", "loc": [581, 585], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L580_C12", "vector": [6, 4, 0.7857, 0.0067, 4, 0.46, 0.0, 428, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "r1, r2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for r1, r2 in zip(p1, p2):\n for c1, c2 in zip(r1.coords, r2.coords):\n # XXX The low precision is for SpatiaLite\n self.assertAlmostEqual(c1[0] + xfac, c2[0], 5)\n self.assertAlmostEqual(c1[1] + yfac, c2[1], 5)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L582_C20", "label": "for c1, c2", "type": "for", "loc": [582, 585], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L581_C16", "vector": [6, 5, 0.7864, 0.0054, 5, 0.69, 0.0, 680, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "c1, c2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c1, c2 in zip(r1.coords, r2.coords):\n # XXX The low precision is for SpatiaLite\n self.assertAlmostEqual(c1[0] + xfac, c2[0], 5)\n self.assertAlmostEqual(c1[1] + yfac, c2[1], 5)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L584_C24", "label": "assertAlmostEqual()", "type": "expression", "loc": [584, 584], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L582_C20", "vector": [8, 6, 0.7871, 0.0013, 6, 0.41, 0.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(c1[0] + xfac, c2[0], 5)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L585_C24", "label": "assertAlmostEqual()", "type": "expression", "loc": [585, 585], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L582_C20", "vector": [8, 6, 0.7884, 0.0013, 6, 0.41, 1.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(c1[1] + yfac, c2[1], 5)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L588_C4", "label": "test23_numgeom", "type": "function", "loc": [588, 598], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.7992, 0.0148, 1, 0.06, 0.7667, 881, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test23_numgeom", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test23_numgeom(self):\n \"Testing the `num_geom` GeoQuerySet method.\"\n # Both 'countries' only have two geometries.\n for c in Country.objects.num_geom(): self.assertEqual(2, c.num_geom)\n for c in City.objects.filter(point__isnull=False).num_geom():\n # Oracle will return 1 for the number of geometries on non-collections,\n # whereas PostGIS will return None.\n if postgis:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L589_C8", "label": "expression", "type": "expression", "loc": [589, 589], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L588_C4", "vector": [8, 2, 0.7938, 0.0013, 2, 0.74, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `num_geom` GeoQuerySet method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L591_C8", "label": "for c", "type": "for", "loc": [591, 591], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L588_C4", "vector": [6, 2, 0.7965, 0.0013, 2, 0.74, 0.5, 411, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in Country.objects.num_geom(): self.assertEqual(2, c.num_geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L591_C45", "label": "assertEqual()", "type": "expression", "loc": [591, 591], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L591_C8", "vector": [8, 3, 0.7965, 0.0013, 3, 0.64, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " for c in Country.objects.num_geom(): self.assertEqual(2, c.num_geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L592_C8", "label": "for c", "type": "for", "loc": [592, 598], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L588_C4", "vector": [6, 2, 0.8019, 0.0094, 2, 0.74, 1.0, 411, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in City.objects.filter(point__isnull=False).num_geom():\n # Oracle will return 1 for the number of geometries on non-collections,\n # whereas PostGIS will return None.\n if postgis:\n self.assertEqual(None, c.num_geom)\n else:\n self.assertEqual(1, c.num_geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L595_C12", "label": "if", "type": "if", "loc": [595, 598], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L592_C8", "vector": [4, 3, 0.8039, 0.0054, 3, 0.29, 0.0, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if postgis:\n self.assertEqual(None, c.num_geom)\n else:\n self.assertEqual(1, c.num_geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L596_C16", "label": "assertEqual()", "type": "expression", "loc": [596, 596], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L595_C12", "vector": [8, 4, 0.8032, 0.0013, 4, 0.8, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(None, c.num_geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L598_C16", "label": "assertEqual()", "type": "expression", "loc": [598, 598], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L595_C12", "vector": [8, 4, 0.8059, 0.0013, 4, 0.8, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(1, c.num_geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L602_C4", "label": "test24_numpoints", "type": "function", "loc": [602, 609], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.816, 0.0108, 1, 0.06, 0.8, 263, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test24_numpoints", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test24_numpoints(self):\n \"Testing the `num_points` GeoQuerySet method.\"\n for c in Country.objects.num_points():\n self.assertEqual(c.mpoly.num_points, c.num_points)\n\n if not oracle:\n # Oracle cannot count vertices in Point geometries.\n for c in City.objects.num_points(): self.assertEqual(1, c.num_points)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L603_C8", "label": "expression", "type": "expression", "loc": [603, 603], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L602_C4", "vector": [8, 2, 0.8127, 0.0013, 2, 0.09, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `num_points` GeoQuerySet method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L604_C8", "label": "for c", "type": "for", "loc": [604, 605], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L602_C4", "vector": [6, 2, 0.8147, 0.0027, 2, 0.09, 0.5, 411, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in Country.objects.num_points():\n self.assertEqual(c.mpoly.num_points, c.num_points)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L605_C12", "label": "assertEqual()", "type": "expression", "loc": [605, 605], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L604_C8", "vector": [8, 3, 0.8154, 0.0013, 3, 0.89, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(c.mpoly.num_points, c.num_points)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L607_C8", "label": "if", "type": "if", "loc": [607, 609], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L602_C4", "vector": [4, 2, 0.8194, 0.004, 2, 0.09, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not oracle:\n # Oracle cannot count vertices in Point geometries.\n for c in City.objects.num_points(): self.assertEqual(1, c.num_points)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L609_C12", "label": "for c", "type": "for", "loc": [609, 609], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L607_C8", "vector": [6, 3, 0.8208, 0.0013, 3, 0.5, 0.0, 411, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in City.objects.num_points(): self.assertEqual(1, c.num_points)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L609_C48", "label": "assertEqual()", "type": "expression", "loc": [609, 609], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L609_C12", "vector": [8, 4, 0.8208, 0.0013, 4, 0.8, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " for c in City.objects.num_points(): self.assertEqual(1, c.num_points)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "label": "test25_geoset", "type": "function", "loc": [612, 636], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.841, 0.0337, 1, 0.06, 0.8333, 697, 0, 1, 0, 0, 0, 0, 15], "semantic": {"name": "test25_geoset", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test25_geoset(self):\n \"Testing the `difference`, `intersection`, `sym_difference`, and `union` GeoQuerySet methods.\"\n geom = Point(5, 23)\n tol = 1\n qs = Country.objects.all().difference(geom).sym_difference(geom).union(geom)\n\n # XXX For some reason SpatiaLite does something screwey with the Texas geometry here. Also,\n # XXX it doesn't like the null intersection."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L613_C8", "label": "expression", "type": "expression", "loc": [613, 613], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "vector": [8, 2, 0.8261, 0.0013, 2, 0.99, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `difference`, `intersection`, `sym_difference`, and `union` GeoQuerySet methods.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L614_C8", "label": "geom = Point()", "type": "assigned_variable", "loc": [614, 614], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "vector": [14, 2, 0.8275, 0.0013, 2, 0.99, 0.2, 5, 3, 2, 0, 0, 652, 10, 1], "semantic": {"name": "geom", "arg_names": [], "import_names": [], "rhs_call_name": "Point", "annotation": ""}, "snippet": " geom = Point(5, 23)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L615_C8", "label": "tol =", "type": "assigned_variable", "loc": [615, 615], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "vector": [14, 2, 0.8288, 0.0013, 2, 0.99, 0.4, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L616_C8", "label": "qs = union()", "type": "assigned_variable", "loc": [616, 616], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "vector": [14, 2, 0.8302, 0.0013, 2, 0.99, 0.6, 251, 3, 1, 0, 0, 140, 10, 4], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "union", "annotation": ""}, "snippet": " qs = Country.objects.all().difference(geom).sym_difference(geom).union(geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L620_C8", "label": "if", "type": "if", "loc": [620, 623], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "vector": [4, 2, 0.8376, 0.0054, 2, 0.99, 0.8, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if spatialite:\n qs = qs.exclude(name='Texas')\n else:\n qs = qs.intersection(geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L621_C12", "label": "qs = exclude()", "type": "assigned_variable", "loc": [621, 621], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L620_C8", "vector": [14, 3, 0.8369, 0.0013, 3, 0.66, 0.0, 251, 3, 1, 0, 0, 739, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "exclude", "annotation": ""}, "snippet": " qs = qs.exclude(name='Texas')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L623_C12", "label": "qs = intersection()", "type": "assigned_variable", "loc": [623, 623], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L620_C8", "vector": [14, 3, 0.8396, 0.0013, 3, 0.66, 1.0, 251, 3, 1, 0, 0, 568, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "intersection", "annotation": ""}, "snippet": " qs = qs.intersection(geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L625_C8", "label": "for c", "type": "for", "loc": [625, 636], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "vector": [6, 2, 0.8497, 0.0162, 2, 0.99, 1.0, 411, 2, 0, 0, 0, 0, 0, 8], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in qs:\n if oracle:\n # Should be able to execute the queries; however, they won't be the same\n # as GEOS (because Oracle doesn't use GEOS internally like PostGIS or\n # SpatiaLite).\n pass\n else:\n self.assertEqual(c.mpoly.difference(geom), c.difference)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L626_C12", "label": "if", "type": "if", "loc": [626, 636], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L625_C8", "vector": [4, 3, 0.8504, 0.0148, 3, 0.78, 0.0, 0, 2, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle:\n # Should be able to execute the queries; however, they won't be the same\n # as GEOS (because Oracle doesn't use GEOS internally like PostGIS or\n # SpatiaLite).\n pass\n else:\n self.assertEqual(c.mpoly.difference(geom), c.difference)\n if not spatialite:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L632_C16", "label": "assertEqual()", "type": "expression", "loc": [632, 632], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L626_C12", "vector": [8, 4, 0.8518, 0.0013, 4, 0.21, 0.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(c.mpoly.difference(geom), c.difference)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L633_C16", "label": "if", "type": "if", "loc": [633, 634], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L626_C12", "vector": [4, 4, 0.8538, 0.0027, 4, 0.21, 0.3333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not spatialite:\n self.assertEqual(c.mpoly.intersection(geom), c.intersection)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L634_C20", "label": "assertEqual()", "type": "expression", "loc": [634, 634], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L633_C16", "vector": [8, 5, 0.8544, 0.0013, 5, 0.68, 0.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(c.mpoly.intersection(geom), c.intersection)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L635_C16", "label": "assertEqual()", "type": "expression", "loc": [635, 635], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L626_C12", "vector": [8, 4, 0.8558, 0.0013, 4, 0.21, 0.6667, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(c.mpoly.sym_difference(geom), c.sym_difference)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L636_C16", "label": "assertEqual()", "type": "expression", "loc": [636, 636], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L626_C12", "vector": [8, 4, 0.8571, 0.0013, 4, 0.21, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(c.mpoly.union(geom), c.union)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L639_C4", "label": "test26_inherited_geofields", "type": "function", "loc": [639, 649], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.8679, 0.0148, 1, 0.06, 0.8667, 770, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test26_inherited_geofields", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test26_inherited_geofields(self):\n \"Test GeoQuerySet methods on inherited Geometry fields.\"\n # Creating a Pennsylvanian city.\n mansfield = PennsylvaniaCity.objects.create(name='Mansfield', county='Tioga', point='POINT(-77.071445 41.823881)')\n\n # All transformation SQL will need to be performed on the\n # _parent_ table.\n qs = PennsylvaniaCity.objects.transform(32128)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L640_C8", "label": "expression", "type": "expression", "loc": [640, 640], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L639_C4", "vector": [8, 2, 0.8625, 0.0013, 2, 0.49, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Test GeoQuerySet methods on inherited Geometry fields.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L642_C8", "label": "mansfield = create()", "type": "assigned_variable", "loc": [642, 642], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L639_C4", "vector": [14, 2, 0.8652, 0.0013, 2, 0.49, 0.25, 219, 3, 3, 0, 0, 316, 10, 1], "semantic": {"name": "mansfield", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " mansfield = PennsylvaniaCity.objects.create(name='Mansfield', county='Tioga', point='POINT(-77.071445 41.823881)')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L646_C8", "label": "qs = transform()", "type": "assigned_variable", "loc": [646, 646], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L639_C4", "vector": [14, 2, 0.8706, 0.0013, 2, 0.49, 0.5, 251, 3, 1, 0, 0, 48, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "transform", "annotation": ""}, "snippet": " qs = PennsylvaniaCity.objects.transform(32128)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L648_C8", "label": "assertEqual()", "type": "expression", "loc": [648, 648], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L639_C4", "vector": [8, 2, 0.8733, 0.0013, 2, 0.49, 0.75, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(1, qs.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L649_C8", "label": "for pc", "type": "for", "loc": [649, 649], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L639_C4", "vector": [6, 2, 0.8747, 0.0013, 2, 0.49, 1.0, 876, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "pc", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for pc in qs: self.assertEqual(32128, pc.point.srid)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L649_C22", "label": "assertEqual()", "type": "expression", "loc": [649, 649], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L649_C8", "vector": [8, 3, 0.8747, 0.0013, 3, 0.41, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " for pc in qs: self.assertEqual(32128, pc.point.srid)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "label": "test27_snap_to_grid", "type": "function", "loc": [654, 688], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.9043, 0.0472, 1, 0.06, 0.9, 692, 0, 1, 0, 0, 0, 0, 24], "semantic": {"name": "test27_snap_to_grid", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test27_snap_to_grid(self):\n \"Testing GeoQuerySet.snap_to_grid().\"\n # Let's try and break snap_to_grid() with bad combinations of arguments.\n for bad_args in ((), range(3), range(5)):\n self.assertRaises(ValueError, Country.objects.snap_to_grid, *bad_args)\n for bad_args in (('1.0',), (1.0, None), tuple(map(unicode, range(4)))):\n self.assertRaises(TypeError, Country.objects.snap_to_grid, *bad_args)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L655_C8", "label": "expression", "type": "expression", "loc": [655, 655], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "vector": [8, 2, 0.8827, 0.0013, 2, 0.23, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing GeoQuerySet.snap_to_grid().\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L657_C8", "label": "for bad_args", "type": "for", "loc": [657, 658], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "vector": [6, 2, 0.8861, 0.0027, 2, 0.23, 0.0909, 253, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "bad_args", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for bad_args in ((), range(3), range(5)):\n self.assertRaises(ValueError, Country.objects.snap_to_grid, *bad_args)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L658_C12", "label": "assertRaises()", "type": "expression", "loc": [658, 658], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L657_C8", "vector": [8, 3, 0.8868, 0.0013, 3, 0.05, 0.0, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, Country.objects.snap_to_grid, *bad_args)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L659_C8", "label": "for bad_args", "type": "for", "loc": [659, 660], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "vector": [6, 2, 0.8888, 0.0027, 2, 0.23, 0.1818, 253, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "bad_args", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for bad_args in (('1.0',), (1.0, None), tuple(map(unicode, range(4)))):\n self.assertRaises(TypeError, Country.objects.snap_to_grid, *bad_args)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L660_C12", "label": "assertRaises()", "type": "expression", "loc": [660, 660], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L659_C8", "vector": [8, 3, 0.8895, 0.0013, 3, 0.27, 0.0, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(TypeError, Country.objects.snap_to_grid, *bad_args)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L664_C8", "label": "wkt =", "type": "assigned_variable", "loc": [664, 671], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "vector": [14, 2, 0.8996, 0.0108, 2, 0.23, 0.2727, 836, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "wkt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " wkt = ('MULTIPOLYGON(((12.41580 43.95795,12.45055 43.97972,12.45389 43.98167,'\n '12.46250 43.98472,12.47167 43.98694,12.49278 43.98917,'\n '12.50555 43.98861,12.51000 43.98694,12.51028 43.98277,'\n '12.51167 43.94333,12.51056 43.93916,12.49639 43.92333,'\n '12.49500 43.91472,12.48778 43.90583,12.47444 43.89722,'\n '12.46472 43.89555,12.45917 43.89611,12.41639 43.90472,'\n '12.41222 43.90610,12.40782 43.91366,12.40389 43.92667,'\n '12.40500 43.94833,12.40889 43.95499,12.41580 43.95795)))')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L672_C8", "label": "sm = create()", "type": "assigned_variable", "loc": [672, 672], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "vector": [14, 2, 0.9057, 0.0013, 2, 0.23, 0.3636, 21, 3, 2, 0, 0, 316, 10, 2], "semantic": {"name": "sm", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " sm = Country.objects.create(name='San Marino', mpoly=fromstr(wkt))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L676_C8", "label": "tol =", "type": "assigned_variable", "loc": [676, 676], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "vector": [14, 2, 0.9111, 0.0013, 2, 0.23, 0.4545, 422, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 0.000000001"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L679_C8", "label": "ref = fromstr()", "type": "assigned_variable", "loc": [679, 679], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "vector": [14, 2, 0.9151, 0.0013, 2, 0.23, 0.5455, 686, 3, 1, 0, 0, 946, 10, 1], "semantic": {"name": "ref", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " ref = fromstr('MULTIPOLYGON(((12.4 44,12.5 44,12.5 43.9,12.4 43.9,12.4 44)))')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L680_C8", "label": "failUnless()", "type": "expression", "loc": [680, 680], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "vector": [8, 2, 0.9164, 0.0013, 2, 0.23, 0.6364, 252, 3, 1, 0, 0, 0, 0, 4], "semantic": {"name": "failUnless", "arg_names": [], "import_names": [], "rhs_call_name": "failUnless", "annotation": ""}, "snippet": " self.failUnless(ref.equals_exact(Country.objects.snap_to_grid(0.1).get(name='San Marino').snap_to_grid, tol))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L683_C8", "label": "ref = fromstr()", "type": "assigned_variable", "loc": [683, 683], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "vector": [14, 2, 0.9205, 0.0013, 2, 0.23, 0.7273, 686, 3, 1, 0, 0, 946, 10, 1], "semantic": {"name": "ref", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " ref = fromstr('MULTIPOLYGON(((12.4 43.93,12.45 43.93,12.5 43.93,12.45 43.93,12.4 43.93)))')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L684_C8", "label": "failUnless()", "type": "expression", "loc": [684, 684], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "vector": [8, 2, 0.9218, 0.0013, 2, 0.23, 0.8182, 252, 3, 1, 0, 0, 0, 0, 4], "semantic": {"name": "failUnless", "arg_names": [], "import_names": [], "rhs_call_name": "failUnless", "annotation": ""}, "snippet": " self.failUnless(ref.equals_exact(Country.objects.snap_to_grid(0.05, 0.23).get(name='San Marino').snap_to_grid, tol))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L687_C8", "label": "ref = fromstr()", "type": "assigned_variable", "loc": [687, 687], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "vector": [14, 2, 0.9259, 0.0013, 2, 0.23, 0.9091, 686, 3, 1, 0, 0, 946, 10, 1], "semantic": {"name": "ref", "arg_names": [], "import_names": [], "rhs_call_name": "fromstr", "annotation": ""}, "snippet": " ref = fromstr('MULTIPOLYGON(((12.4 43.87,12.45 43.87,12.45 44.1,12.5 44.1,12.5 43.87,12.45 43.87,12.4 43.87)))')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L688_C8", "label": "failUnless()", "type": "expression", "loc": [688, 688], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "vector": [8, 2, 0.9272, 0.0013, 2, 0.23, 1.0, 252, 3, 1, 0, 0, 0, 0, 4], "semantic": {"name": "failUnless", "arg_names": [], "import_names": [], "rhs_call_name": "failUnless", "annotation": ""}, "snippet": " self.failUnless(ref.equals_exact(Country.objects.snap_to_grid(0.05, 0.23, 0.5, 0.17).get(name='San Marino').snap_to_grid, tol))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "label": "test28_reverse", "type": "function", "loc": [692, 700], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.938, 0.0121, 1, 0.06, 0.9333, 388, 0, 1, 0, 0, 0, 0, 8], "semantic": {"name": "test28_reverse", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test28_reverse(self):\n \"Testing GeoQuerySet.reverse_geom().\"\n coords = [ (-95.363151, 29.763374), (-95.448601, 29.713803) ]\n Track.objects.create(name='Foo', line=LineString(coords))\n t = Track.objects.reverse_geom().get(name='Foo')\n coords.reverse()\n self.assertEqual(tuple(coords), t.reverse_geom.coords)\n if oracle:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L693_C8", "label": "expression", "type": "expression", "loc": [693, 693], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "vector": [8, 2, 0.934, 0.0013, 2, 0.88, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing GeoQuerySet.reverse_geom().\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L694_C8", "label": "coords =", "type": "assigned_variable", "loc": [694, 694], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "vector": [14, 2, 0.9353, 0.0013, 2, 0.88, 0.1667, 216, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "coords", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " coords = [ (-95.363151, 29.763374), (-95.448601, 29.713803) ]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L695_C8", "label": "create()", "type": "expression", "loc": [695, 695], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "vector": [8, 2, 0.9367, 0.0013, 2, 0.88, 0.3333, 316, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " Track.objects.create(name='Foo', line=LineString(coords))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L696_C8", "label": "t = get()", "type": "assigned_variable", "loc": [696, 696], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "vector": [14, 2, 0.938, 0.0013, 2, 0.88, 0.5, 15, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "t", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " t = Track.objects.reverse_geom().get(name='Foo')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L697_C8", "label": "reverse()", "type": "expression", "loc": [697, 697], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "vector": [8, 2, 0.9394, 0.0013, 2, 0.88, 0.6667, 109, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "reverse", "arg_names": [], "import_names": [], "rhs_call_name": "reverse", "annotation": ""}, "snippet": " coords.reverse()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L698_C8", "label": "assertEqual()", "type": "expression", "loc": [698, 698], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "vector": [8, 2, 0.9407, 0.0013, 2, 0.88, 0.8333, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(tuple(coords), t.reverse_geom.coords)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L699_C8", "label": "if", "type": "if", "loc": [699, 700], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "vector": [4, 2, 0.9427, 0.0027, 2, 0.88, 1.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle:\n self.assertRaises(TypeError, State.objects.reverse_geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L700_C12", "label": "assertRaises()", "type": "expression", "loc": [700, 700], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L699_C8", "vector": [8, 3, 0.9434, 0.0013, 3, 0.15, 0.0, 11, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(TypeError, State.objects.reverse_geom)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "label": "test29_force_rhr", "type": "function", "loc": [705, 715], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.9569, 0.0148, 1, 0.06, 0.9667, 361, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test29_force_rhr", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test29_force_rhr(self):\n \"Testing GeoQuerySet.force_rhr().\"\n rings = ( ( (0, 0), (5, 0), (0, 5), (0, 0) ),\n ( (1, 1), (1, 3), (3, 1), (1, 1) ),\n )\n rhr_rings = ( ( (0, 0), (0, 5), (5, 0), (0, 0) ),\n ( (1, 1), (3, 1), (1, 3), (1, 1) ),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L706_C8", "label": "expression", "type": "expression", "loc": [706, 706], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "vector": [8, 2, 0.9515, 0.0013, 2, 0.07, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing GeoQuerySet.force_rhr().\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L707_C8", "label": "rings =", "type": "assigned_variable", "loc": [707, 709], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "vector": [14, 2, 0.9542, 0.004, 2, 0.07, 0.2, 462, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "rings", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " rings = ( ( (0, 0), (5, 0), (0, 5), (0, 0) ),\n ( (1, 1), (1, 3), (3, 1), (1, 1) ),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L710_C8", "label": "rhr_rings =", "type": "assigned_variable", "loc": [710, 712], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "vector": [14, 2, 0.9582, 0.004, 2, 0.07, 0.4, 917, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "rhr_rings", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " rhr_rings = ( ( (0, 0), (0, 5), (5, 0), (0, 0) ),\n ( (1, 1), (3, 1), (1, 3), (1, 1) ),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L713_C8", "label": "create()", "type": "expression", "loc": [713, 713], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "vector": [8, 2, 0.9609, 0.0013, 2, 0.07, 0.6, 316, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " State.objects.create(name='Foo', poly=Polygon(*rings))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L714_C8", "label": "s = get()", "type": "assigned_variable", "loc": [714, 714], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "vector": [14, 2, 0.9623, 0.0013, 2, 0.07, 0.8, 553, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "s", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " s = State.objects.force_rhr().get(name='Foo')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L715_C8", "label": "assertEqual()", "type": "expression", "loc": [715, 715], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "vector": [8, 2, 0.9636, 0.0013, 2, 0.07, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(rhr_rings, s.force_rhr.coords)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "label": "test29_force_rhr", "type": "function", "loc": [720, 730], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "vector": [2, 1, 0.9771, 0.0148, 1, 0.06, 1.0, 361, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test29_force_rhr", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test29_force_rhr(self):\n \"Testing GeoQuerySet.geohash().\"\n if not connection.ops.geohash: return\n # Reference query:\n # SELECT ST_GeoHash(point) FROM geoapp_city WHERE name='Houston';\n # SELECT ST_GeoHash(point, 5) FROM geoapp_city WHERE name='Houston';\n ref_hash = '9vk1mfq8jx0c8e0386z6'\n h1 = City.objects.geohash().get(name='Houston')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L721_C8", "label": "expression", "type": "expression", "loc": [721, 721], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "vector": [8, 2, 0.9717, 0.0013, 2, 0.58, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing GeoQuerySet.geohash().\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L722_C8", "label": "if", "type": "if", "loc": [722, 722], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "vector": [4, 2, 0.973, 0.0013, 2, 0.58, 0.1667, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not connection.ops.geohash: return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Return_L722_C39", "label": "return", "type": "return", "loc": [722, 722], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L722_C8", "vector": [13, 3, 0.973, 0.0013, 3, 0.97, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not connection.ops.geohash: return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L726_C8", "label": "ref_hash =", "type": "assigned_variable", "loc": [726, 726], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "vector": [14, 2, 0.9784, 0.0013, 2, 0.58, 0.3333, 500, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "ref_hash", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_hash = '9vk1mfq8jx0c8e0386z6'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L727_C8", "label": "h1 = get()", "type": "assigned_variable", "loc": [727, 727], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "vector": [14, 2, 0.9798, 0.0013, 2, 0.58, 0.5, 428, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "h1", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " h1 = City.objects.geohash().get(name='Houston')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L728_C8", "label": "h2 = get()", "type": "assigned_variable", "loc": [728, 728], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "vector": [14, 2, 0.9811, 0.0013, 2, 0.58, 0.6667, 265, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "h2", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " h2 = City.objects.geohash(precision=5).get(name='Houston')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L729_C8", "label": "assertEqual()", "type": "expression", "loc": [729, 729], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "vector": [8, 2, 0.9825, 0.0013, 2, 0.58, 0.8333, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(ref_hash, h1.geohash)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L730_C8", "label": "assertEqual()", "type": "expression", "loc": [730, 730], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "vector": [8, 2, 0.9838, 0.0013, 2, 0.58, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(ref_hash[:5], h2.geohash)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:ImportFrom_L732_C0", "label": "from test_feeds import GeoFeedTest", "type": "import", "loc": [732, 732], "level": 0, "parent": null, "vector": [1, 0, 0.9865, 0.0013, 0, 0.66, 0.7692, 993, 0, 1, 0, 0, 993, 0, 0], "semantic": {"name": "test_feeds", "arg_names": [], "import_names": ["GeoFeedTest"], "rhs_call_name": "", "annotation": ""}, "snippet": "from test_feeds import GeoFeedTest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:ImportFrom_L733_C0", "label": "from test_regress import GeoRegressionTests", "type": "import", "loc": [733, 733], "level": 0, "parent": null, "vector": [1, 0, 0.9879, 0.0013, 0, 0.66, 0.8462, 881, 0, 1, 0, 0, 881, 0, 0], "semantic": {"name": "test_regress", "arg_names": [], "import_names": ["GeoRegressionTests"], "rhs_call_name": "", "annotation": ""}, "snippet": "from test_regress import GeoRegressionTests"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:ImportFrom_L734_C0", "label": "from test_sitemaps import GeoSitemapTest", "type": "import", "loc": [734, 734], "level": 0, "parent": null, "vector": [1, 0, 0.9892, 0.0013, 0, 0.66, 0.9231, 560, 0, 1, 0, 0, 560, 0, 0], "semantic": {"name": "test_sitemaps", "arg_names": [], "import_names": ["GeoSitemapTest"], "rhs_call_name": "", "annotation": ""}, "snippet": "from test_sitemaps import GeoSitemapTest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "label": "suite", "type": "function", "loc": [736, 742], "level": 0, "parent": null, "vector": [2, 0, 0.996, 0.0094, 0, 0.66, 1.0, 425, 0, 0, 1, 0, 0, 0, 9], "semantic": {"name": "suite", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def suite():\n s = unittest.TestSuite()\n s.addTest(unittest.makeSuite(GeoModelTest))\n s.addTest(unittest.makeSuite(GeoFeedTest))\n s.addTest(unittest.makeSuite(GeoSitemapTest))\n s.addTest(unittest.makeSuite(GeoRegressionTests))\n return s"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L737_C4", "label": "s = TestSuite()", "type": "assigned_variable", "loc": [737, 737], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "vector": [14, 1, 0.9933, 0.0013, 1, 0.94, 0.0, 553, 3, 0, 0, 0, 75, 10, 1], "semantic": {"name": "s", "arg_names": [], "import_names": [], "rhs_call_name": "TestSuite", "annotation": ""}, "snippet": " s = unittest.TestSuite()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L738_C4", "label": "addTest()", "type": "expression", "loc": [738, 738], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "vector": [8, 1, 0.9946, 0.0013, 1, 0.94, 0.2, 786, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "addTest", "arg_names": [], "import_names": [], "rhs_call_name": "addTest", "annotation": ""}, "snippet": " s.addTest(unittest.makeSuite(GeoModelTest))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L739_C4", "label": "addTest()", "type": "expression", "loc": [739, 739], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "vector": [8, 1, 0.996, 0.0013, 1, 0.94, 0.4, 786, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "addTest", "arg_names": [], "import_names": [], "rhs_call_name": "addTest", "annotation": ""}, "snippet": " s.addTest(unittest.makeSuite(GeoFeedTest))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L740_C4", "label": "addTest()", "type": "expression", "loc": [740, 740], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "vector": [8, 1, 0.9973, 0.0013, 1, 0.94, 0.6, 786, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "addTest", "arg_names": [], "import_names": [], "rhs_call_name": "addTest", "annotation": ""}, "snippet": " s.addTest(unittest.makeSuite(GeoSitemapTest))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L741_C4", "label": "addTest()", "type": "expression", "loc": [741, 741], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "vector": [8, 1, 0.9987, 0.0013, 1, 0.94, 0.8, 786, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "addTest", "arg_names": [], "import_names": [], "rhs_call_name": "addTest", "annotation": ""}, "snippet": " s.addTest(unittest.makeSuite(GeoRegressionTests))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98678:Return_L742_C4", "label": "return", "type": "return", "loc": [742, 742], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "vector": [13, 1, 1.0, 0.0013, 1, 0.94, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return s"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:ImportFrom_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L34_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Try_L35_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:Try_L35_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L36_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:Try_L35_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L40_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L78_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L79_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L78_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L80_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L78_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L81_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L78_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L82_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L96_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L97_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L96_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Return_L98_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L102_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L103_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L107_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L108_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L107_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L110_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L115_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L115_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L116_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L120_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L120_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L121_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L120_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Return_L122_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L127_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L129_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L131_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L133_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L131_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L134_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L134_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L135_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L131_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L137_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L131_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L138_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L138_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L139_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L142_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L144_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L144_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L145_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L144_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Return_L146_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L149_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L150_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L151_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L152_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L154_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L155_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L156_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L148_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L157_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L160_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L164_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L169_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L174_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L178_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L181_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L182_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L182_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L183_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L182_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Return_L184_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L186_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L188_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L191_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L192_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L180_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L193_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L197_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L199_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L200_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L201_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L205_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L205_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L206_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L205_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L207_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L205_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L208_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L205_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L209_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L211_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L212_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L213_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L213_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L214_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L213_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L215_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L213_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L216_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L220_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L220_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L221_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L220_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L225_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L220_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L227_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L220_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L228_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L220_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L230_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L230_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L231_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L237_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L237_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L238_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L237_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L240_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L237_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L241_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L237_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L244_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L237_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L245_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L249_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L250_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L251_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L252_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L254_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L255_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L248_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L256_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L259_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L261_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L266_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L266_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L267_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L266_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L268_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L266_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L269_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L266_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L270_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L270_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L270_C25"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L273_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L274_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L275_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L276_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L277_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L281_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L282_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L283_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L284_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L287_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L287_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L288_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L287_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L289_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L293_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L294_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L298_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L298_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L299_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L298_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L300_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L298_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L301_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L305_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L307_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L308_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L311_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L311_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L315_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L311_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L316_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L311_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L319_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L311_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L320_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L325_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L326_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L326_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L327_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L326_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L329_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L330_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L333_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L336_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L337_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L338_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L304_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L343_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L343_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L344_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L343_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L345_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L343_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L346_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L350_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L352_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L355_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L356_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L359_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L360_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L363_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L364_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L365_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L366_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L369_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L370_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L373_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L374_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L375_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L349_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L376_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L383_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L389_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L390_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L396_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L398_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L399_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L400_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L400_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L400_C21"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L403_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L404_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L405_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L406_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L406_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L406_C21"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L410_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L411_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L413_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L414_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L415_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L382_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L416_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L416_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L416_C21"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L419_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L420_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L421_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L422_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L423_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L418_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L424_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L424_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L424_C31"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L428_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L431_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L432_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L436_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L440_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L440_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L441_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L440_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L442_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L445_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L445_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L446_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L445_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L447_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L445_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L448_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L445_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L449_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L449_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L450_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L449_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L451_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L449_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L453_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L456_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L457_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L460_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L461_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L427_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L464_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L464_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L465_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L464_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L466_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L464_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L467_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L469_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L469_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L470_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L469_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L471_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L469_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L472_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L476_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L477_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L479_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L480_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L481_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L482_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L486_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L487_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L488_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L489_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L489_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L490_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L489_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L492_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L493_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L494_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L495_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L475_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L496_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L500_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L501_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L502_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L503_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L504_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L508_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L509_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L510_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L511_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L512_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L513_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L515_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L516_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L517_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L518_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L499_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L519_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L522_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L522_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L523_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L522_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L524_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L522_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L525_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L525_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L526_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L525_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L527_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L527_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L528_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L527_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L530_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L522_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L531_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L531_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L532_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L535_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L535_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L536_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L535_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L538_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L538_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L540_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L538_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L544_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L544_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L547_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L535_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L551_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L551_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L552_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L552_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L554_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L552_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L556_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L551_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L557_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L561_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L561_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L562_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L561_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L563_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L561_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L564_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L561_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L565_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L561_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L566_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L566_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L567_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L567_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L568_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L568_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L569_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L569_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L570_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L569_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L571_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L575_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L575_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L576_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L575_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L577_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L575_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L578_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L575_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L579_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L579_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L580_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L580_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L581_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L581_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L582_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L582_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L584_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L582_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L585_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L588_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L588_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L589_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L588_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L591_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L591_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L591_C45"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L588_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L592_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L592_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L595_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L595_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L596_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L595_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L598_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L602_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L602_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L603_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L602_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L604_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L604_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L605_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L602_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L607_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L607_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L609_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L609_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L609_C48"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L613_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L614_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L615_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L616_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L620_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L620_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L621_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L620_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L623_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L612_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L625_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L625_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L626_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L626_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L632_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L626_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L633_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L633_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L634_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L626_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L635_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L626_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L636_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L639_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L639_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L640_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L639_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L642_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L639_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L646_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L639_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L648_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L639_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L649_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L649_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L649_C22"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L655_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L657_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L657_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L658_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L659_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:For_L659_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L660_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L664_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L672_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L676_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L679_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L680_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L683_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L684_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L687_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L654_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L688_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L693_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L694_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L695_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L696_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L697_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L698_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L692_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L699_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L699_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L700_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L706_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L707_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L710_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L713_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L714_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L705_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L715_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L721_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L722_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:If_L722_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Return_L722_C39"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L726_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L727_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L728_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L729_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L720_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L730_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Assign_L737_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L738_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L739_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L740_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Expr_L741_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98678:FunctionDef_L736_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98678:Return_L742_C4"}] |
from django.contrib.gis import feeds
from django.contrib.gis.tests.utils import mysql
from models import City, Country
class TestGeoRSS1(feeds.Feed):
link = '/city/'
title = 'Test GeoDjango Cities'
def items(self):
return City.objects.all()
def item_link(self, item):
return '/city/%s/' % item.pk
def item_geometry(self, item):
return item.point
class TestGeoRSS2(TestGeoRSS1):
def geometry(self, obj):
# This should attach a <georss:box> element for the extent of
# of the cities in the database. This tuple came from
# calling `City.objects.extent()` -- we can't do that call here
# because `extent` is not implemented for MySQL/Oracle.
return (-123.30, -41.32, 174.78, 48.46)
def item_geometry(self, item):
# Returning a simple tuple for the geometry.
return item.point.x, item.point.y
class TestGeoAtom1(TestGeoRSS1):
feed_type = feeds.GeoAtom1Feed
class TestGeoAtom2(TestGeoRSS2):
feed_type = feeds.GeoAtom1Feed
def geometry(self, obj):
# This time we'll use a 2-tuple of coordinates for the box.
return ((-123.30, -41.32), (174.78, 48.46))
class TestW3CGeo1(TestGeoRSS1):
feed_type = feeds.W3CGeoFeed
# The following feeds are invalid, and will raise exceptions.
class TestW3CGeo2(TestGeoRSS2):
feed_type = feeds.W3CGeoFeed
class TestW3CGeo3(TestGeoRSS1):
feed_type = feeds.W3CGeoFeed
def item_geometry(self, item):
from django.contrib.gis.geos import Polygon
return Polygon(((0, 0), (0, 1), (1, 1), (1, 0), (0, 0)))
# The feed dictionary to use for URLs.
feed_dict = {
'rss1' : TestGeoRSS1,
'rss2' : TestGeoRSS2,
'atom1' : TestGeoAtom1,
'atom2' : TestGeoAtom2,
'w3cgeo1' : TestW3CGeo1,
'w3cgeo2' : TestW3CGeo2,
'w3cgeo3' : TestW3CGeo3,
}
| ajibawa-2023/Python-Code-Large/train/row_98679 | 33 | 63 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98679:ImportFrom_L1_C0", "label": "from django.contrib.gis import feeds", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0159, 0.0159, 0, 0.66, 0.0, 735, 0, 1, 0, 0, 735, 0, 0], "semantic": {"name": "django.contrib.gis", "arg_names": [], "import_names": ["feeds"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis import feeds"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:ImportFrom_L2_C0", "label": "from django.contrib.gis.tests.utils import mysql", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0317, 0.0159, 0, 0.66, 0.1, 185, 0, 1, 0, 0, 185, 0, 0], "semantic": {"name": "django.contrib.gis.tests.utils", "arg_names": [], "import_names": ["mysql"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.tests.utils import mysql"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:ImportFrom_L3_C0", "label": "from models import City, Country", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0476, 0.0159, 0, 0.66, 0.2, 495, 0, 2, 0, 0, 495, 0, 0], "semantic": {"name": "models", "arg_names": [], "import_names": ["City", "Country"], "rhs_call_name": "", "annotation": ""}, "snippet": "from models import City, Country"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L5_C0", "label": "TestGeoRSS1", "type": "class", "loc": [5, 16], "level": 0, "parent": null, "vector": [3, 0, 0.1667, 0.1905, 0, 0.66, 0.3, 401, 0, 3, 0, 0, 989, 0, 1], "semantic": {"name": "TestGeoRSS1", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TestGeoRSS1(feeds.Feed):\n link = '/city/'\n title = 'Test GeoDjango Cities'\n\n def items(self):\n return City.objects.all()\n\n def item_link(self, item):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L6_C4", "label": "link =", "type": "assigned_variable", "loc": [6, 6], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L5_C0", "vector": [14, 1, 0.0952, 0.0159, 1, 0.54, 0.0, 880, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "link", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " link = '/city/'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L7_C4", "label": "title =", "type": "assigned_variable", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L5_C0", "vector": [14, 1, 0.1111, 0.0159, 1, 0.54, 0.25, 48, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "title", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " title = 'Test GeoDjango Cities'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L9_C4", "label": "items", "type": "function", "loc": [9, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L5_C0", "vector": [2, 1, 0.1508, 0.0317, 1, 0.54, 0.5, 339, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "items", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def items(self):\n return City.objects.all()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L10_C8", "label": "return", "type": "return", "loc": [10, 10], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L9_C4", "vector": [13, 2, 0.1587, 0.0159, 2, 0.58, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return City.objects.all()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L12_C4", "label": "item_link", "type": "function", "loc": [12, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L5_C0", "vector": [2, 1, 0.1984, 0.0317, 1, 0.54, 0.75, 709, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "item_link", "arg_names": ["self", "item"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def item_link(self, item):\n return '/city/%s/' % item.pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L13_C8", "label": "return", "type": "return", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L12_C4", "vector": [13, 2, 0.2063, 0.0159, 2, 0.39, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '/city/%s/' % item.pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L15_C4", "label": "item_geometry", "type": "function", "loc": [15, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L5_C0", "vector": [2, 1, 0.246, 0.0317, 1, 0.54, 1.0, 623, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "item_geometry", "arg_names": ["self", "item"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def item_geometry(self, item):\n return item.point"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L16_C8", "label": "return", "type": "return", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L15_C4", "vector": [13, 2, 0.254, 0.0159, 2, 0.48, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return item.point"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L18_C0", "label": "TestGeoRSS2", "type": "class", "loc": [18, 28], "level": 0, "parent": null, "vector": [3, 0, 0.3651, 0.1746, 0, 0.66, 0.4, 234, 0, 2, 0, 0, 401, 0, 0], "semantic": {"name": "TestGeoRSS2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TestGeoRSS2(TestGeoRSS1):\n def geometry(self, obj):\n # This should attach a <georss:box> element for the extent of\n # of the cities in the database. This tuple came from\n # calling `City.objects.extent()` -- we can't do that call here\n # because `extent` is not implemented for MySQL/Oracle.\n return (-123.30, -41.32, 174.78, 48.46)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L19_C4", "label": "geometry", "type": "function", "loc": [19, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L18_C0", "vector": [2, 1, 0.3413, 0.0952, 1, 0.78, 0.0, 486, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "geometry", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def geometry(self, obj):\n # This should attach a <georss:box> element for the extent of\n # of the cities in the database. This tuple came from\n # calling `City.objects.extent()` -- we can't do that call here\n # because `extent` is not implemented for MySQL/Oracle.\n return (-123.30, -41.32, 174.78, 48.46)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L24_C8", "label": "return", "type": "return", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L19_C4", "vector": [13, 2, 0.381, 0.0159, 2, 0.68, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return (-123.30, -41.32, 174.78, 48.46)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L26_C4", "label": "item_geometry", "type": "function", "loc": [26, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L18_C0", "vector": [2, 1, 0.4286, 0.0476, 1, 0.78, 1.0, 623, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "item_geometry", "arg_names": ["self", "item"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def item_geometry(self, item):\n # Returning a simple tuple for the geometry.\n return item.point.x, item.point.y"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L28_C8", "label": "return", "type": "return", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L26_C4", "vector": [13, 2, 0.4444, 0.0159, 2, 0.75, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return item.point.x, item.point.y"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L30_C0", "label": "TestGeoAtom1", "type": "class", "loc": [30, 31], "level": 0, "parent": null, "vector": [3, 0, 0.4841, 0.0317, 0, 0.66, 0.5, 129, 0, 0, 0, 0, 401, 0, 0], "semantic": {"name": "TestGeoAtom1", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TestGeoAtom1(TestGeoRSS1):\n feed_type = feeds.GeoAtom1Feed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L31_C4", "label": "feed_type =", "type": "assigned_variable", "loc": [31, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L30_C0", "vector": [14, 1, 0.4921, 0.0159, 1, 0.17, 0.0, 55, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "feed_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " feed_type = feeds.GeoAtom1Feed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L33_C0", "label": "TestGeoAtom2", "type": "class", "loc": [33, 38], "level": 0, "parent": null, "vector": [3, 0, 0.5635, 0.0952, 0, 0.66, 0.6, 18, 0, 1, 0, 0, 234, 0, 0], "semantic": {"name": "TestGeoAtom2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TestGeoAtom2(TestGeoRSS2):\n feed_type = feeds.GeoAtom1Feed\n\n def geometry(self, obj):\n # This time we'll use a 2-tuple of coordinates for the box.\n return ((-123.30, -41.32), (174.78, 48.46))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L34_C4", "label": "feed_type =", "type": "assigned_variable", "loc": [34, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L33_C0", "vector": [14, 1, 0.5397, 0.0159, 1, 0.77, 0.0, 55, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "feed_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " feed_type = feeds.GeoAtom1Feed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L36_C4", "label": "geometry", "type": "function", "loc": [36, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L33_C0", "vector": [2, 1, 0.5873, 0.0476, 1, 0.77, 1.0, 486, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "geometry", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def geometry(self, obj):\n # This time we'll use a 2-tuple of coordinates for the box.\n return ((-123.30, -41.32), (174.78, 48.46))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L38_C8", "label": "return", "type": "return", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L36_C4", "vector": [13, 2, 0.6032, 0.0159, 2, 0.27, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ((-123.30, -41.32), (174.78, 48.46))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L40_C0", "label": "TestW3CGeo1", "type": "class", "loc": [40, 41], "level": 0, "parent": null, "vector": [3, 0, 0.6429, 0.0317, 0, 0.66, 0.7, 404, 0, 0, 0, 0, 401, 0, 0], "semantic": {"name": "TestW3CGeo1", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TestW3CGeo1(TestGeoRSS1):\n feed_type = feeds.W3CGeoFeed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L41_C4", "label": "feed_type =", "type": "assigned_variable", "loc": [41, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L40_C0", "vector": [14, 1, 0.6508, 0.0159, 1, 0.46, 0.0, 55, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "feed_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " feed_type = feeds.W3CGeoFeed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L44_C0", "label": "TestW3CGeo2", "type": "class", "loc": [44, 45], "level": 0, "parent": null, "vector": [3, 0, 0.7063, 0.0317, 0, 0.66, 0.8, 208, 0, 0, 0, 0, 234, 0, 0], "semantic": {"name": "TestW3CGeo2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TestW3CGeo2(TestGeoRSS2):\n feed_type = feeds.W3CGeoFeed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L45_C4", "label": "feed_type =", "type": "assigned_variable", "loc": [45, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L44_C0", "vector": [14, 1, 0.7143, 0.0159, 1, 0.04, 0.0, 55, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "feed_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " feed_type = feeds.W3CGeoFeed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L47_C0", "label": "TestW3CGeo3", "type": "class", "loc": [47, 52], "level": 0, "parent": null, "vector": [3, 0, 0.7857, 0.0952, 0, 0.66, 0.9, 182, 0, 1, 0, 0, 401, 0, 1], "semantic": {"name": "TestW3CGeo3", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TestW3CGeo3(TestGeoRSS1):\n feed_type = feeds.W3CGeoFeed\n\n def item_geometry(self, item):\n from django.contrib.gis.geos import Polygon\n return Polygon(((0, 0), (0, 1), (1, 1), (1, 0), (0, 0)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L48_C4", "label": "feed_type =", "type": "assigned_variable", "loc": [48, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L47_C0", "vector": [14, 1, 0.7619, 0.0159, 1, 0.58, 0.0, 55, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "feed_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " feed_type = feeds.W3CGeoFeed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L50_C4", "label": "item_geometry", "type": "function", "loc": [50, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L47_C0", "vector": [2, 1, 0.8095, 0.0476, 1, 0.58, 1.0, 623, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "item_geometry", "arg_names": ["self", "item"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def item_geometry(self, item):\n from django.contrib.gis.geos import Polygon\n return Polygon(((0, 0), (0, 1), (1, 1), (1, 0), (0, 0)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:ImportFrom_L51_C8", "label": "from django.contrib.gis.geos import Polygon", "type": "import", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L50_C4", "vector": [1, 2, 0.8095, 0.0159, 2, 0.25, 0.0, 886, 0, 1, 0, 0, 886, 0, 0], "semantic": {"name": "django.contrib.gis.geos", "arg_names": [], "import_names": ["Polygon"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.gis.geos import Polygon"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L52_C8", "label": "return", "type": "return", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L50_C4", "vector": [13, 2, 0.8254, 0.0159, 2, 0.25, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return Polygon(((0, 0), (0, 1), (1, 1), (1, 0), (0, 0)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L55_C0", "label": "feed_dict =", "type": "assigned_variable", "loc": [55, 63], "level": 0, "parent": null, "vector": [14, 0, 0.9365, 0.1429, 0, 0.66, 1.0, 770, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "feed_dict", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "feed_dict = {\n 'rss1' : TestGeoRSS1,\n 'rss2' : TestGeoRSS2,\n 'atom1' : TestGeoAtom1,\n 'atom2' : TestGeoAtom2,\n 'w3cgeo1' : TestW3CGeo1,\n 'w3cgeo2' : TestW3CGeo2,\n 'w3cgeo3' : TestW3CGeo3,"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L9_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L30_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L31_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L40_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L44_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Assign_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:ClassDef_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:ImportFrom_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98679:FunctionDef_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98679:Return_L52_C8"}] |
from django.conf.urls.defaults import *
from feeds import feed_dict
urlpatterns = patterns('',
(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feed_dict}),
)
from sitemaps import sitemaps
urlpatterns += patterns('django.contrib.gis.sitemaps.views',
(r'^sitemap.xml$', 'index', {'sitemaps' : sitemaps}),
(r'^sitemaps/(?P<section>\w+)\.xml$', 'sitemap', {'sitemaps' : sitemaps}),
(r'^sitemaps/kml/(?P<label>\w+)/(?P<model>\w+)/(?P<field_name>\w+)\.kml$', 'kml'),
(r'^sitemaps/kml/(?P<label>\w+)/(?P<model>\w+)/(?P<field_name>\w+)\.kmz$', 'kmz'),
)
| ajibawa-2023/Python-Code-Large/train/row_98680 | 4 | 14 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98680:ImportFrom_L1_C0", "label": "from django.conf.urls.defaults import *", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0714, 0.0714, 0, 0.66, 0.0, 341, 0, 1, 0, 0, 341, 0, 0], "semantic": {"name": "django.conf.urls.defaults", "arg_names": [], "import_names": ["*"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf.urls.defaults import *"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98680:ImportFrom_L2_C0", "label": "from feeds import feed_dict", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1429, 0.0714, 0, 0.66, 0.3333, 11, 0, 1, 0, 0, 11, 0, 0], "semantic": {"name": "feeds", "arg_names": [], "import_names": ["feed_dict"], "rhs_call_name": "", "annotation": ""}, "snippet": "from feeds import feed_dict"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98680:Assign_L4_C0", "label": "urlpatterns = patterns()", "type": "assigned_variable", "loc": [4, 6], "level": 0, "parent": null, "vector": [14, 0, 0.3571, 0.2143, 0, 0.66, 0.6667, 990, 3, 2, 0, 0, 75, 10, 1], "semantic": {"name": "urlpatterns", "arg_names": [], "import_names": [], "rhs_call_name": "patterns", "annotation": ""}, "snippet": "urlpatterns = patterns('',\n (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feed_dict}),\n)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98680:ImportFrom_L8_C0", "label": "from sitemaps import sitemaps", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.5714, 0.0714, 0, 0.66, 1.0, 855, 0, 1, 0, 0, 855, 0, 0], "semantic": {"name": "sitemaps", "arg_names": [], "import_names": ["sitemaps"], "rhs_call_name": "", "annotation": ""}, "snippet": "from sitemaps import sitemaps"}] | [] |
from django.contrib.gis.db import models
class City3D(models.Model):
name = models.CharField(max_length=30)
point = models.PointField(dim=3)
objects = models.GeoManager()
def __unicode__(self):
return self.name
class Interstate2D(models.Model):
name = models.CharField(max_length=30)
line = models.LineStringField(srid=4269)
objects = models.GeoManager()
def __unicode__(self):
return self.name
class Interstate3D(models.Model):
name = models.CharField(max_length=30)
line = models.LineStringField(dim=3, srid=4269)
objects = models.GeoManager()
def __unicode__(self):
return self.name
class InterstateProj2D(models.Model):
name = models.CharField(max_length=30)
line = models.LineStringField(srid=32140)
objects = models.GeoManager()
def __unicode__(self):
return self.name
class InterstateProj3D(models.Model):
name = models.CharField(max_length=30)
line = models.LineStringField(dim=3, srid=32140)
objects = models.GeoManager()
def __unicode__(self):
return self.name
class Polygon2D(models.Model):
name = models.CharField(max_length=30)
poly = models.PolygonField(srid=32140)
objects = models.GeoManager()
def __unicode__(self):
return self.name
class Polygon3D(models.Model):
name = models.CharField(max_length=30)
poly = models.PolygonField(dim=3, srid=32140)
objects = models.GeoManager()
def __unicode__(self):
return self.name
class Point2D(models.Model):
point = models.PointField()
objects = models.GeoManager()
class Point3D(models.Model):
point = models.PointField(dim=3)
objects = models.GeoManager()
class MultiPoint3D(models.Model):
mpoint = models.MultiPointField(dim=3)
objects = models.GeoManager()
| ajibawa-2023/Python-Code-Large/train/row_98681 | 52 | 69 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98681:ImportFrom_L1_C0", "label": "from django.contrib.gis.db import models", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0145, 0.0145, 0, 0.66, 0.0, 964, 0, 1, 0, 0, 964, 0, 0], "semantic": {"name": "django.contrib.gis.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L3_C0", "label": "City3D", "type": "class", "loc": [3, 9], "level": 0, "parent": null, "vector": [3, 0, 0.087, 0.1014, 0, 0.66, 0.1, 877, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "City3D", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class City3D(models.Model):\n name = models.CharField(max_length=30)\n point = models.PointField(dim=3)\n objects = models.GeoManager()\n\n def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L4_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [4, 4], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L3_C0", "vector": [14, 1, 0.058, 0.0145, 1, 0.1, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L5_C4", "label": "point = PointField()", "type": "assigned_variable", "loc": [5, 5], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L3_C0", "vector": [14, 1, 0.0725, 0.0145, 1, 0.1, 0.3333, 16, 3, 1, 0, 0, 260, 10, 1], "semantic": {"name": "point", "arg_names": [], "import_names": [], "rhs_call_name": "PointField", "annotation": ""}, "snippet": " point = models.PointField(dim=3)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L6_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [6, 6], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L3_C0", "vector": [14, 1, 0.087, 0.0145, 1, 0.1, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L8_C4", "label": "__unicode__", "type": "function", "loc": [8, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L3_C0", "vector": [2, 1, 0.1232, 0.029, 1, 0.1, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L9_C8", "label": "return", "type": "return", "loc": [9, 9], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L8_C4", "vector": [13, 2, 0.1304, 0.0145, 2, 0.26, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L11_C0", "label": "Interstate2D", "type": "class", "loc": [11, 17], "level": 0, "parent": null, "vector": [3, 0, 0.2029, 0.1014, 0, 0.66, 0.2, 944, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "Interstate2D", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Interstate2D(models.Model):\n name = models.CharField(max_length=30)\n line = models.LineStringField(srid=4269)\n objects = models.GeoManager()\n\n def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L12_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L11_C0", "vector": [14, 1, 0.1739, 0.0145, 1, 0.5, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L13_C4", "label": "line = LineStringField()", "type": "assigned_variable", "loc": [13, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L11_C0", "vector": [14, 1, 0.1884, 0.0145, 1, 0.5, 0.3333, 373, 3, 1, 0, 0, 237, 10, 1], "semantic": {"name": "line", "arg_names": [], "import_names": [], "rhs_call_name": "LineStringField", "annotation": ""}, "snippet": " line = models.LineStringField(srid=4269)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L14_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L11_C0", "vector": [14, 1, 0.2029, 0.0145, 1, 0.5, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L16_C4", "label": "__unicode__", "type": "function", "loc": [16, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L11_C0", "vector": [2, 1, 0.2391, 0.029, 1, 0.5, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L17_C8", "label": "return", "type": "return", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L16_C4", "vector": [13, 2, 0.2464, 0.0145, 2, 0.65, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L19_C0", "label": "Interstate3D", "type": "class", "loc": [19, 25], "level": 0, "parent": null, "vector": [3, 0, 0.3188, 0.1014, 0, 0.66, 0.3, 616, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "Interstate3D", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Interstate3D(models.Model):\n name = models.CharField(max_length=30)\n line = models.LineStringField(dim=3, srid=4269)\n objects = models.GeoManager()\n\n def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L20_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L19_C0", "vector": [14, 1, 0.2899, 0.0145, 1, 0.42, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L21_C4", "label": "line = LineStringField()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L19_C0", "vector": [14, 1, 0.3043, 0.0145, 1, 0.42, 0.3333, 373, 3, 2, 0, 0, 237, 10, 1], "semantic": {"name": "line", "arg_names": [], "import_names": [], "rhs_call_name": "LineStringField", "annotation": ""}, "snippet": " line = models.LineStringField(dim=3, srid=4269)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L22_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L19_C0", "vector": [14, 1, 0.3188, 0.0145, 1, 0.42, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L24_C4", "label": "__unicode__", "type": "function", "loc": [24, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L19_C0", "vector": [2, 1, 0.3551, 0.029, 1, 0.42, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L25_C8", "label": "return", "type": "return", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L24_C4", "vector": [13, 2, 0.3623, 0.0145, 2, 0.78, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L27_C0", "label": "InterstateProj2D", "type": "class", "loc": [27, 33], "level": 0, "parent": null, "vector": [3, 0, 0.4348, 0.1014, 0, 0.66, 0.4, 464, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "InterstateProj2D", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class InterstateProj2D(models.Model):\n name = models.CharField(max_length=30)\n line = models.LineStringField(srid=32140)\n objects = models.GeoManager()\n\n def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L28_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [28, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L27_C0", "vector": [14, 1, 0.4058, 0.0145, 1, 0.37, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L29_C4", "label": "line = LineStringField()", "type": "assigned_variable", "loc": [29, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L27_C0", "vector": [14, 1, 0.4203, 0.0145, 1, 0.37, 0.3333, 373, 3, 1, 0, 0, 237, 10, 1], "semantic": {"name": "line", "arg_names": [], "import_names": [], "rhs_call_name": "LineStringField", "annotation": ""}, "snippet": " line = models.LineStringField(srid=32140)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L30_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [30, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L27_C0", "vector": [14, 1, 0.4348, 0.0145, 1, 0.37, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L32_C4", "label": "__unicode__", "type": "function", "loc": [32, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L27_C0", "vector": [2, 1, 0.471, 0.029, 1, 0.37, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L33_C8", "label": "return", "type": "return", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L32_C4", "vector": [13, 2, 0.4783, 0.0145, 2, 0.93, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L35_C0", "label": "InterstateProj3D", "type": "class", "loc": [35, 41], "level": 0, "parent": null, "vector": [3, 0, 0.5507, 0.1014, 0, 0.66, 0.5, 284, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "InterstateProj3D", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class InterstateProj3D(models.Model):\n name = models.CharField(max_length=30)\n line = models.LineStringField(dim=3, srid=32140)\n objects = models.GeoManager()\n\n def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L36_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [36, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L35_C0", "vector": [14, 1, 0.5217, 0.0145, 1, 0.16, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L37_C4", "label": "line = LineStringField()", "type": "assigned_variable", "loc": [37, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L35_C0", "vector": [14, 1, 0.5362, 0.0145, 1, 0.16, 0.3333, 373, 3, 2, 0, 0, 237, 10, 1], "semantic": {"name": "line", "arg_names": [], "import_names": [], "rhs_call_name": "LineStringField", "annotation": ""}, "snippet": " line = models.LineStringField(dim=3, srid=32140)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L38_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [38, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L35_C0", "vector": [14, 1, 0.5507, 0.0145, 1, 0.16, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L40_C4", "label": "__unicode__", "type": "function", "loc": [40, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L35_C0", "vector": [2, 1, 0.587, 0.029, 1, 0.16, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L41_C8", "label": "return", "type": "return", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L40_C4", "vector": [13, 2, 0.5942, 0.0145, 2, 0.42, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L43_C0", "label": "Polygon2D", "type": "class", "loc": [43, 49], "level": 0, "parent": null, "vector": [3, 0, 0.6667, 0.1014, 0, 0.66, 0.6, 748, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "Polygon2D", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Polygon2D(models.Model):\n name = models.CharField(max_length=30)\n poly = models.PolygonField(srid=32140)\n objects = models.GeoManager()\n \n def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L44_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [44, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L43_C0", "vector": [14, 1, 0.6377, 0.0145, 1, 0.5, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L45_C4", "label": "poly = PolygonField()", "type": "assigned_variable", "loc": [45, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L43_C0", "vector": [14, 1, 0.6522, 0.0145, 1, 0.5, 0.3333, 365, 3, 1, 0, 0, 736, 10, 1], "semantic": {"name": "poly", "arg_names": [], "import_names": [], "rhs_call_name": "PolygonField", "annotation": ""}, "snippet": " poly = models.PolygonField(srid=32140)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L46_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [46, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L43_C0", "vector": [14, 1, 0.6667, 0.0145, 1, 0.5, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L48_C4", "label": "__unicode__", "type": "function", "loc": [48, 49], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L43_C0", "vector": [2, 1, 0.7029, 0.029, 1, 0.5, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L49_C8", "label": "return", "type": "return", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L48_C4", "vector": [13, 2, 0.7101, 0.0145, 2, 0.35, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L51_C0", "label": "Polygon3D", "type": "class", "loc": [51, 57], "level": 0, "parent": null, "vector": [3, 0, 0.7826, 0.1014, 0, 0.66, 0.7, 338, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "Polygon3D", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Polygon3D(models.Model):\n name = models.CharField(max_length=30)\n poly = models.PolygonField(dim=3, srid=32140)\n objects = models.GeoManager()\n \n def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L52_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [52, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L51_C0", "vector": [14, 1, 0.7536, 0.0145, 1, 0.37, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L53_C4", "label": "poly = PolygonField()", "type": "assigned_variable", "loc": [53, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L51_C0", "vector": [14, 1, 0.7681, 0.0145, 1, 0.37, 0.3333, 365, 3, 2, 0, 0, 736, 10, 1], "semantic": {"name": "poly", "arg_names": [], "import_names": [], "rhs_call_name": "PolygonField", "annotation": ""}, "snippet": " poly = models.PolygonField(dim=3, srid=32140)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L54_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [54, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L51_C0", "vector": [14, 1, 0.7826, 0.0145, 1, 0.37, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L56_C4", "label": "__unicode__", "type": "function", "loc": [56, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L51_C0", "vector": [2, 1, 0.8188, 0.029, 1, 0.37, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L57_C8", "label": "return", "type": "return", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L56_C4", "vector": [13, 2, 0.8261, 0.0145, 2, 0.71, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L59_C0", "label": "Point2D", "type": "class", "loc": [59, 61], "level": 0, "parent": null, "vector": [3, 0, 0.8696, 0.0435, 0, 0.66, 0.8, 624, 0, 0, 0, 0, 996, 0, 2], "semantic": {"name": "Point2D", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Point2D(models.Model):\n point = models.PointField()\n objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L60_C4", "label": "point = PointField()", "type": "assigned_variable", "loc": [60, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L59_C0", "vector": [14, 1, 0.8696, 0.0145, 1, 0.74, 0.0, 16, 3, 0, 0, 0, 260, 10, 1], "semantic": {"name": "point", "arg_names": [], "import_names": [], "rhs_call_name": "PointField", "annotation": ""}, "snippet": " point = models.PointField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L61_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [61, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L59_C0", "vector": [14, 1, 0.8841, 0.0145, 1, 0.74, 1.0, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L63_C0", "label": "Point3D", "type": "class", "loc": [63, 65], "level": 0, "parent": null, "vector": [3, 0, 0.9275, 0.0435, 0, 0.66, 0.9, 344, 0, 0, 0, 0, 996, 0, 2], "semantic": {"name": "Point3D", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Point3D(models.Model):\n point = models.PointField(dim=3)\n objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L64_C4", "label": "point = PointField()", "type": "assigned_variable", "loc": [64, 64], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L63_C0", "vector": [14, 1, 0.9275, 0.0145, 1, 0.92, 0.0, 16, 3, 1, 0, 0, 260, 10, 1], "semantic": {"name": "point", "arg_names": [], "import_names": [], "rhs_call_name": "PointField", "annotation": ""}, "snippet": " point = models.PointField(dim=3)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L65_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [65, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L63_C0", "vector": [14, 1, 0.942, 0.0145, 1, 0.92, 1.0, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L67_C0", "label": "MultiPoint3D", "type": "class", "loc": [67, 69], "level": 0, "parent": null, "vector": [3, 0, 0.9855, 0.0435, 0, 0.66, 1.0, 338, 0, 0, 0, 0, 996, 0, 2], "semantic": {"name": "MultiPoint3D", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class MultiPoint3D(models.Model):\n mpoint = models.MultiPointField(dim=3)\n objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L68_C4", "label": "mpoint = MultiPointField()", "type": "assigned_variable", "loc": [68, 68], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L67_C0", "vector": [14, 1, 0.9855, 0.0145, 1, 0.04, 0.0, 212, 3, 1, 0, 0, 240, 10, 1], "semantic": {"name": "mpoint", "arg_names": [], "import_names": [], "rhs_call_name": "MultiPointField", "annotation": ""}, "snippet": " mpoint = models.MultiPointField(dim=3)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L69_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [69, 69], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L67_C0", "vector": [14, 1, 1.0, 0.0145, 1, 0.04, 1.0, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L32_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L43_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L43_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L43_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L43_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L51_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L51_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L53_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L51_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L51_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:FunctionDef_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Return_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L60_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L61_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L64_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L63_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L65_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L67_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L68_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98681:ClassDef_L67_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98681:Assign_L69_C4"}] |
import os, re, unittest
from django.contrib.gis.db.models import Union, Extent3D
from django.contrib.gis.geos import GEOSGeometry, Point, Polygon
from django.contrib.gis.utils import LayerMapping, LayerMapError
from models import City3D, Interstate2D, Interstate3D, \
InterstateProj2D, InterstateProj3D, \
Point2D, Point3D, MultiPoint3D, Polygon2D, Polygon3D
data_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))
city_file = os.path.join(data_path, 'cities', 'cities.shp')
vrt_file = os.path.join(data_path, 'test_vrt', 'test_vrt.vrt')
# The coordinates of each city, with Z values corresponding to their
# altitude in meters.
city_data = (
('Houston', (-95.363151, 29.763374, 18)),
('Dallas', (-96.801611, 32.782057, 147)),
('Oklahoma City', (-97.521157, 34.464642, 380)),
('Wellington', (174.783117, -41.315268, 14)),
('Pueblo', (-104.609252, 38.255001, 1433)),
('Lawrence', (-95.235060, 38.971823, 251)),
('Chicago', (-87.650175, 41.850385, 181)),
('Victoria', (-123.305196, 48.462611, 15)),
)
# Reference mapping of city name to its altitude (Z value).
city_dict = dict((name, coords) for name, coords in city_data)
# 3D freeway data derived from the National Elevation Dataset:
# http://seamless.usgs.gov/products/9arc.php
interstate_data = (
('I-45',
'LINESTRING(-95.3708481 29.7765870 11.339,-95.3694580 29.7787980 4.536,-95.3690305 29.7797359 9.762,-95.3691886 29.7812450 12.448,-95.3696447 29.7850144 10.457,-95.3702511 29.7868518 9.418,-95.3706724 29.7881286 14.858,-95.3711632 29.7896157 15.386,-95.3714525 29.7936267 13.168,-95.3717848 29.7955007 15.104,-95.3717719 29.7969804 16.516,-95.3717305 29.7982117 13.923,-95.3717254 29.8000778 14.385,-95.3719875 29.8013539 15.160,-95.3720575 29.8026785 15.544,-95.3721321 29.8040912 14.975,-95.3722074 29.8050998 15.688,-95.3722779 29.8060430 16.099,-95.3733818 29.8076750 15.197,-95.3741563 29.8103686 17.268,-95.3749458 29.8129927 19.857,-95.3763564 29.8144557 15.435)',
( 11.339, 4.536, 9.762, 12.448, 10.457, 9.418, 14.858,
15.386, 13.168, 15.104, 16.516, 13.923, 14.385, 15.16 ,
15.544, 14.975, 15.688, 16.099, 15.197, 17.268, 19.857,
15.435),
),
)
# Bounding box polygon for inner-loop of Houston (in projected coordinate
# system 32140), with elevation values from the National Elevation Dataset
# (see above).
bbox_wkt = 'POLYGON((941527.97 4225693.20,962596.48 4226349.75,963152.57 4209023.95,942051.75 4208366.38,941527.97 4225693.20))'
bbox_z = (21.71, 13.21, 9.12, 16.40, 21.71)
def gen_bbox():
bbox_2d = GEOSGeometry(bbox_wkt, srid=32140)
bbox_3d = Polygon(tuple((x, y, z) for (x, y), z in zip(bbox_2d[0].coords, bbox_z)), srid=32140)
return bbox_2d, bbox_3d
class Geo3DTest(unittest.TestCase):
"""
Only a subset of the PostGIS routines are 3D-enabled, and this TestCase
tries to test the features that can handle 3D and that are also
available within GeoDjango. For more information, see the PostGIS docs
on the routines that support 3D:
http://postgis.refractions.net/documentation/manual-1.4/ch08.html#PostGIS_3D_Functions
"""
def test01_3d(self):
"Test the creation of 3D models."
# 3D models for the rest of the tests will be populated in here.
# For each 3D data set create model (and 2D version if necessary),
# retrieve, and assert geometry is in 3D and contains the expected
# 3D values.
for name, pnt_data in city_data:
x, y, z = pnt_data
pnt = Point(x, y, z, srid=4326)
City3D.objects.create(name=name, point=pnt)
city = City3D.objects.get(name=name)
self.failUnless(city.point.hasz)
self.assertEqual(z, city.point.z)
# Interstate (2D / 3D and Geographic/Projected variants)
for name, line, exp_z in interstate_data:
line_3d = GEOSGeometry(line, srid=4269)
# Using `hex` attribute because it omits 3D.
line_2d = GEOSGeometry(line_3d.hex, srid=4269)
# Creating a geographic and projected version of the
# interstate in both 2D and 3D.
Interstate3D.objects.create(name=name, line=line_3d)
InterstateProj3D.objects.create(name=name, line=line_3d)
Interstate2D.objects.create(name=name, line=line_2d)
InterstateProj2D.objects.create(name=name, line=line_2d)
# Retrieving and making sure it's 3D and has expected
# Z values -- shouldn't change because of coordinate system.
interstate = Interstate3D.objects.get(name=name)
interstate_proj = InterstateProj3D.objects.get(name=name)
for i in [interstate, interstate_proj]:
self.failUnless(i.line.hasz)
self.assertEqual(exp_z, tuple(i.line.z))
# Creating 3D Polygon.
bbox2d, bbox3d = gen_bbox()
Polygon2D.objects.create(name='2D BBox', poly=bbox2d)
Polygon3D.objects.create(name='3D BBox', poly=bbox3d)
p3d = Polygon3D.objects.get(name='3D BBox')
self.failUnless(p3d.poly.hasz)
self.assertEqual(bbox3d, p3d.poly)
def test01a_3d_layermapping(self):
"Testing LayerMapping on 3D models."
from models import Point2D, Point3D
point_mapping = {'point' : 'POINT'}
mpoint_mapping = {'mpoint' : 'MULTIPOINT'}
# The VRT is 3D, but should still be able to map sans the Z.
lm = LayerMapping(Point2D, vrt_file, point_mapping, transform=False)
lm.save()
self.assertEqual(3, Point2D.objects.count())
# The city shapefile is 2D, and won't be able to fill the coordinates
# in the 3D model -- thus, a LayerMapError is raised.
self.assertRaises(LayerMapError, LayerMapping,
Point3D, city_file, point_mapping, transform=False)
# 3D model should take 3D data just fine.
lm = LayerMapping(Point3D, vrt_file, point_mapping, transform=False)
lm.save()
self.assertEqual(3, Point3D.objects.count())
# Making sure LayerMapping.make_multi works right, by converting
# a Point25D into a MultiPoint25D.
lm = LayerMapping(MultiPoint3D, vrt_file, mpoint_mapping, transform=False)
lm.save()
self.assertEqual(3, MultiPoint3D.objects.count())
def test02a_kml(self):
"Test GeoQuerySet.kml() with Z values."
h = City3D.objects.kml(precision=6).get(name='Houston')
# KML should be 3D.
# `SELECT ST_AsKML(point, 6) FROM geo3d_city3d WHERE name = 'Houston';`
ref_kml_regex = re.compile(r'^<Point><coordinates>-95.363\d+,29.763\d+,18</coordinates></Point>$')
self.failUnless(ref_kml_regex.match(h.kml))
def test02b_geojson(self):
"Test GeoQuerySet.geojson() with Z values."
h = City3D.objects.geojson(precision=6).get(name='Houston')
# GeoJSON should be 3D
# `SELECT ST_AsGeoJSON(point, 6) FROM geo3d_city3d WHERE name='Houston';`
ref_json_regex = re.compile(r'^{"type":"Point","coordinates":\[-95.363151,29.763374,18(\.0+)?\]}$')
self.failUnless(ref_json_regex.match(h.geojson))
def test03a_union(self):
"Testing the Union aggregate of 3D models."
# PostGIS query that returned the reference EWKT for this test:
# `SELECT ST_AsText(ST_Union(point)) FROM geo3d_city3d;`
ref_ewkt = 'SRID=4326;MULTIPOINT(-123.305196 48.462611 15,-104.609252 38.255001 1433,-97.521157 34.464642 380,-96.801611 32.782057 147,-95.363151 29.763374 18,-95.23506 38.971823 251,-87.650175 41.850385 181,174.783117 -41.315268 14)'
ref_union = GEOSGeometry(ref_ewkt)
union = City3D.objects.aggregate(Union('point'))['point__union']
self.failUnless(union.hasz)
self.assertEqual(ref_union, union)
def test03b_extent(self):
"Testing the Extent3D aggregate for 3D models."
# `SELECT ST_Extent3D(point) FROM geo3d_city3d;`
ref_extent3d = (-123.305196, -41.315268, 14,174.783117, 48.462611, 1433)
extent1 = City3D.objects.aggregate(Extent3D('point'))['point__extent3d']
extent2 = City3D.objects.extent3d()
def check_extent3d(extent3d, tol=6):
for ref_val, ext_val in zip(ref_extent3d, extent3d):
self.assertAlmostEqual(ref_val, ext_val, tol)
for e3d in [extent1, extent2]:
check_extent3d(e3d)
def test04_perimeter(self):
"Testing GeoQuerySet.perimeter() on 3D fields."
# Reference query for values below:
# `SELECT ST_Perimeter3D(poly), ST_Perimeter2D(poly) FROM geo3d_polygon3d;`
ref_perim_3d = 76859.2620451
ref_perim_2d = 76859.2577803
tol = 6
self.assertAlmostEqual(ref_perim_2d,
Polygon2D.objects.perimeter().get(name='2D BBox').perimeter.m,
tol)
self.assertAlmostEqual(ref_perim_3d,
Polygon3D.objects.perimeter().get(name='3D BBox').perimeter.m,
tol)
def test05_length(self):
"Testing GeoQuerySet.length() on 3D fields."
# ST_Length_Spheroid Z-aware, and thus does not need to use
# a separate function internally.
# `SELECT ST_Length_Spheroid(line, 'SPHEROID["GRS 1980",6378137,298.257222101]')
# FROM geo3d_interstate[2d|3d];`
tol = 3
ref_length_2d = 4368.1721949481
ref_length_3d = 4368.62547052088
self.assertAlmostEqual(ref_length_2d,
Interstate2D.objects.length().get(name='I-45').length.m,
tol)
self.assertAlmostEqual(ref_length_3d,
Interstate3D.objects.length().get(name='I-45').length.m,
tol)
# Making sure `ST_Length3D` is used on for a projected
# and 3D model rather than `ST_Length`.
# `SELECT ST_Length(line) FROM geo3d_interstateproj2d;`
ref_length_2d = 4367.71564892392
# `SELECT ST_Length3D(line) FROM geo3d_interstateproj3d;`
ref_length_3d = 4368.16897234101
self.assertAlmostEqual(ref_length_2d,
InterstateProj2D.objects.length().get(name='I-45').length.m,
tol)
self.assertAlmostEqual(ref_length_3d,
InterstateProj3D.objects.length().get(name='I-45').length.m,
tol)
def test06_scale(self):
"Testing GeoQuerySet.scale() on Z values."
# Mapping of City name to reference Z values.
zscales = (-3, 4, 23)
for zscale in zscales:
for city in City3D.objects.scale(1.0, 1.0, zscale):
self.assertEqual(city_dict[city.name][2] * zscale, city.scale.z)
def test07_translate(self):
"Testing GeoQuerySet.translate() on Z values."
ztranslations = (5.23, 23, -17)
for ztrans in ztranslations:
for city in City3D.objects.translate(0, 0, ztrans):
self.assertEqual(city_dict[city.name][2] + ztrans, city.translate.z)
def suite():
s = unittest.TestSuite()
s.addTest(unittest.makeSuite(Geo3DTest))
return s
| ajibawa-2023/Python-Code-Large/train/row_98682 | 122 | 234 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Import_L1_C0", "label": "os import os, re, unittest", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0043, 0.0043, 0, 0.66, 0.0, 688, 0, 3, 0, 0, 688, 0, 0], "semantic": {"name": "os", "arg_names": [], "import_names": ["os", "re", "unittest"], "rhs_call_name": "", "annotation": ""}, "snippet": "import os, re, unittest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:ImportFrom_L2_C0", "label": "from django.contrib.gis.db.models import Union, Extent3D", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0085, 0.0043, 0, 0.66, 0.0667, 472, 0, 2, 0, 0, 472, 0, 0], "semantic": {"name": "django.contrib.gis.db.models", "arg_names": [], "import_names": ["Union", "Extent3D"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.db.models import Union, Extent3D"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:ImportFrom_L3_C0", "label": "from django.contrib.gis.geos import GEOSGeometry, Point, Polygon", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0128, 0.0043, 0, 0.66, 0.1333, 886, 0, 3, 0, 0, 886, 0, 0], "semantic": {"name": "django.contrib.gis.geos", "arg_names": [], "import_names": ["GEOSGeometry", "Point", "Polygon"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.geos import GEOSGeometry, Point, Polygon"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:ImportFrom_L4_C0", "label": "from django.contrib.gis.utils import LayerMapping, LayerMapError", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0171, 0.0043, 0, 0.66, 0.2, 917, 0, 2, 0, 0, 917, 0, 0], "semantic": {"name": "django.contrib.gis.utils", "arg_names": [], "import_names": ["LayerMapping", "LayerMapError"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.utils import LayerMapping, LayerMapError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:ImportFrom_L6_C0", "label": "from models import City3D, Interstate2D, Interstate3D\u2026", "type": "import", "loc": [6, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0299, 0.0128, 0, 0.66, 0.2667, 495, 0, 10, 0, 0, 495, 0, 0], "semantic": {"name": "models", "arg_names": [], "import_names": ["City3D", "Interstate2D", "Interstate3D", "InterstateProj2D", "InterstateProj3D", "Point2D", "Point3D", "MultiPoint3D", "Polygon2D", "Polygon3D"], "rhs_call_name": "", "annotation": ""}, "snippet": "from models import City3D, Interstate2D, Interstate3D, \\\n InterstateProj2D, InterstateProj3D, \\\n Point2D, Point3D, MultiPoint3D, Polygon2D, Polygon3D"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L10_C0", "label": "data_path = realpath()", "type": "assigned_variable", "loc": [10, 10], "level": 0, "parent": null, "vector": [14, 0, 0.0427, 0.0043, 0, 0.66, 0.3333, 531, 3, 1, 0, 0, 45, 10, 3], "semantic": {"name": "data_path", "arg_names": [], "import_names": [], "rhs_call_name": "realpath", "annotation": ""}, "snippet": "data_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L11_C0", "label": "city_file = join()", "type": "assigned_variable", "loc": [11, 11], "level": 0, "parent": null, "vector": [14, 0, 0.047, 0.0043, 0, 0.66, 0.4, 584, 3, 3, 0, 0, 933, 10, 1], "semantic": {"name": "city_file", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": "city_file = os.path.join(data_path, 'cities', 'cities.shp')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L12_C0", "label": "vrt_file = join()", "type": "assigned_variable", "loc": [12, 12], "level": 0, "parent": null, "vector": [14, 0, 0.0513, 0.0043, 0, 0.66, 0.4667, 738, 3, 3, 0, 0, 933, 10, 1], "semantic": {"name": "vrt_file", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": "vrt_file = os.path.join(data_path, 'test_vrt', 'test_vrt.vrt')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L16_C0", "label": "city_data =", "type": "assigned_variable", "loc": [16, 25], "level": 0, "parent": null, "vector": [14, 0, 0.0876, 0.0427, 0, 0.66, 0.5333, 444, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "city_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "city_data = (\n ('Houston', (-95.363151, 29.763374, 18)),\n ('Dallas', (-96.801611, 32.782057, 147)),\n ('Oklahoma City', (-97.521157, 34.464642, 380)),\n ('Wellington', (174.783117, -41.315268, 14)),\n ('Pueblo', (-104.609252, 38.255001, 1433)),\n ('Lawrence', (-95.235060, 38.971823, 251)),\n ('Chicago', (-87.650175, 41.850385, 181)),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L28_C0", "label": "city_dict = dict()", "type": "assigned_variable", "loc": [28, 28], "level": 0, "parent": null, "vector": [14, 0, 0.1197, 0.0043, 0, 0.66, 0.6, 331, 3, 1, 0, 0, 827, 10, 1], "semantic": {"name": "city_dict", "arg_names": [], "import_names": [], "rhs_call_name": "dict", "annotation": ""}, "snippet": "city_dict = dict((name, coords) for name, coords in city_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L32_C0", "label": "interstate_data =", "type": "assigned_variable", "loc": [32, 40], "level": 0, "parent": null, "vector": [14, 0, 0.1538, 0.0385, 0, 0.66, 0.6667, 747, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "interstate_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "interstate_data = (\n ('I-45', \n 'LINESTRING(-95.3708481 29.7765870 11.339,-95.3694580 29.7787980 4.536,-95.3690305 29.7797359 9.762,-95.3691886 29.7812450 12.448,-95.3696447 29.7850144 10.457,-95.3702511 29.7868518 9.418,-95.3706724 29.7881286 14.858,-95.3711632 29.7896157 15.386,-95.3714525 29.7936267 13.168,-95.3717848 29.7955007 15.104,-95.3717719 29.7969804 16.516,-95.3717305 29.7982117 13.923,-95.3717254 29.8000778 14.385,-95.3719875 29.8013539 15.160,-95.3720575 29.8026785 15.544,-95.3721321 29.8040912 14.975,-95.3722074 29.8050998 15.688,-95.3722779 29.8060430 16.099,-95.3733818 29.8076750 15.197,-95.3741563 29.8103686 17.268,-95.3749458 29.8129927 19.857,-95.3763564 29.8144557 15.435)',\n ( 11.339, 4.536, 9.762, 12.448, 10.457, 9.418, 14.858,\n 15.386, 13.168, 15.104, 16.516, 13.923, 14.385, 15.16 ,\n 15.544, 14.975, 15.688, 16.099, 15.197, 17.268, 19.857,\n 15.435),\n ),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L45_C0", "label": "bbox_wkt =", "type": "assigned_variable", "loc": [45, 45], "level": 0, "parent": null, "vector": [14, 0, 0.1923, 0.0043, 0, 0.66, 0.7333, 143, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "bbox_wkt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "bbox_wkt = 'POLYGON((941527.97 4225693.20,962596.48 4226349.75,963152.57 4209023.95,942051.75 4208366.38,941527.97 4225693.20))'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L46_C0", "label": "bbox_z =", "type": "assigned_variable", "loc": [46, 46], "level": 0, "parent": null, "vector": [14, 0, 0.1966, 0.0043, 0, 0.66, 0.8, 543, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "bbox_z", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "bbox_z = (21.71, 13.21, 9.12, 16.40, 21.71)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L47_C0", "label": "gen_bbox", "type": "function", "loc": [47, 50], "level": 0, "parent": null, "vector": [2, 0, 0.2073, 0.0171, 0, 0.66, 0.8667, 892, 0, 0, 1, 0, 0, 0, 4], "semantic": {"name": "gen_bbox", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def gen_bbox():\n bbox_2d = GEOSGeometry(bbox_wkt, srid=32140)\n bbox_3d = Polygon(tuple((x, y, z) for (x, y), z in zip(bbox_2d[0].coords, bbox_z)), srid=32140) \n return bbox_2d, bbox_3d"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L48_C4", "label": "bbox_2d = GEOSGeometry()", "type": "assigned_variable", "loc": [48, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L47_C0", "vector": [14, 1, 0.2051, 0.0043, 1, 0.87, 0.0, 387, 3, 2, 0, 0, 958, 10, 1], "semantic": {"name": "bbox_2d", "arg_names": [], "import_names": [], "rhs_call_name": "GEOSGeometry", "annotation": ""}, "snippet": " bbox_2d = GEOSGeometry(bbox_wkt, srid=32140)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L49_C4", "label": "bbox_3d = Polygon()", "type": "assigned_variable", "loc": [49, 49], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L47_C0", "vector": [14, 1, 0.2094, 0.0043, 1, 0.87, 0.5, 866, 3, 2, 0, 0, 818, 10, 3], "semantic": {"name": "bbox_3d", "arg_names": [], "import_names": [], "rhs_call_name": "Polygon", "annotation": ""}, "snippet": " bbox_3d = Polygon(tuple((x, y, z) for (x, y), z in zip(bbox_2d[0].coords, bbox_z)), srid=32140) "}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Return_L50_C4", "label": "return", "type": "return", "loc": [50, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L47_C0", "vector": [13, 1, 0.2137, 0.0043, 1, 0.87, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return bbox_2d, bbox_3d"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "label": "Geo3DTest", "type": "class", "loc": [52, 229], "level": 0, "parent": null, "vector": [3, 0, 0.6004, 0.7607, 0, 0.66, 0.9333, 335, 0, 11, 0, 0, 878, 0, 78], "semantic": {"name": "Geo3DTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Geo3DTest(unittest.TestCase):\n \"\"\"\n Only a subset of the PostGIS routines are 3D-enabled, and this TestCase\n tries to test the features that can handle 3D and that are also \n available within GeoDjango. For more information, see the PostGIS docs\n on the routines that support 3D:\n\n http://postgis.refractions.net/documentation/manual-1.4/ch08.html#PostGIS_3D_Functions"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L53_C4", "label": "expression", "type": "expression", "loc": [53, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "vector": [8, 1, 0.2415, 0.0342, 1, 0.01, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Only a subset of the PostGIS routines are 3D-enabled, and this TestCase\n tries to test the features that can handle 3D and that are also \n available within GeoDjango. For more information, see the PostGIS docs\n on the routines that support 3D:\n\n http://postgis.refractions.net/documentation/manual-1.4/ch08.html#PostGIS_3D_Functions\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "label": "test01_3d", "type": "function", "loc": [62, 103], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "vector": [2, 1, 0.3526, 0.1795, 1, 0.01, 0.1, 407, 0, 1, 0, 0, 0, 0, 22], "semantic": {"name": "test01_3d", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test01_3d(self):\n \"Test the creation of 3D models.\"\n # 3D models for the rest of the tests will be populated in here.\n # For each 3D data set create model (and 2D version if necessary), \n # retrieve, and assert geometry is in 3D and contains the expected\n # 3D values.\n for name, pnt_data in city_data:\n x, y, z = pnt_data"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L63_C8", "label": "expression", "type": "expression", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "vector": [8, 2, 0.2692, 0.0043, 2, 0.97, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Test the creation of 3D models.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "label": "for name, pnt_data", "type": "for", "loc": [68, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "vector": [6, 2, 0.3034, 0.0299, 2, 0.97, 0.125, 576, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "name, pnt_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name, pnt_data in city_data:\n x, y, z = pnt_data\n pnt = Point(x, y, z, srid=4326)\n City3D.objects.create(name=name, point=pnt)\n city = City3D.objects.get(name=name)\n self.failUnless(city.point.hasz)\n self.assertEqual(z, city.point.z)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L69_C12", "label": "x, y, z =", "type": "assigned_variable", "loc": [69, 69], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "vector": [14, 3, 0.2949, 0.0043, 3, 0.55, 0.0, 971, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "x, y, z", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " x, y, z = pnt_data"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L70_C12", "label": "pnt = Point()", "type": "assigned_variable", "loc": [70, 70], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "vector": [14, 3, 0.2991, 0.0043, 3, 0.55, 0.2, 41, 3, 4, 0, 0, 652, 10, 1], "semantic": {"name": "pnt", "arg_names": [], "import_names": [], "rhs_call_name": "Point", "annotation": ""}, "snippet": " pnt = Point(x, y, z, srid=4326)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L71_C12", "label": "create()", "type": "expression", "loc": [71, 71], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "vector": [8, 3, 0.3034, 0.0043, 3, 0.55, 0.4, 316, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " City3D.objects.create(name=name, point=pnt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L72_C12", "label": "city = get()", "type": "assigned_variable", "loc": [72, 72], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "vector": [14, 3, 0.3077, 0.0043, 3, 0.55, 0.6, 825, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "city", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " city = City3D.objects.get(name=name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L73_C12", "label": "failUnless()", "type": "expression", "loc": [73, 73], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "vector": [8, 3, 0.312, 0.0043, 3, 0.55, 0.8, 252, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "failUnless", "arg_names": [], "import_names": [], "rhs_call_name": "failUnless", "annotation": ""}, "snippet": " self.failUnless(city.point.hasz)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L74_C12", "label": "assertEqual()", "type": "expression", "loc": [74, 74], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "vector": [8, 3, 0.3162, 0.0043, 3, 0.55, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(z, city.point.z)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "label": "for name, line, exp_z", "type": "for", "loc": [77, 95], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "vector": [6, 2, 0.3675, 0.0812, 2, 0.97, 0.25, 517, 2, 0, 0, 0, 0, 0, 11], "semantic": {"name": "name, line, exp_z", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name, line, exp_z in interstate_data:\n line_3d = GEOSGeometry(line, srid=4269)\n # Using `hex` attribute because it omits 3D.\n line_2d = GEOSGeometry(line_3d.hex, srid=4269)\n\n # Creating a geographic and projected version of the\n # interstate in both 2D and 3D.\n Interstate3D.objects.create(name=name, line=line_3d)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L78_C12", "label": "line_3d = GEOSGeometry()", "type": "assigned_variable", "loc": [78, 78], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "vector": [14, 3, 0.3333, 0.0043, 3, 0.98, 0.0, 716, 3, 2, 0, 0, 958, 10, 1], "semantic": {"name": "line_3d", "arg_names": [], "import_names": [], "rhs_call_name": "GEOSGeometry", "annotation": ""}, "snippet": " line_3d = GEOSGeometry(line, srid=4269)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L80_C12", "label": "line_2d = GEOSGeometry()", "type": "assigned_variable", "loc": [80, 80], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "vector": [14, 3, 0.3419, 0.0043, 3, 0.98, 0.125, 300, 3, 2, 0, 0, 958, 10, 1], "semantic": {"name": "line_2d", "arg_names": [], "import_names": [], "rhs_call_name": "GEOSGeometry", "annotation": ""}, "snippet": " line_2d = GEOSGeometry(line_3d.hex, srid=4269)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L84_C12", "label": "create()", "type": "expression", "loc": [84, 84], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "vector": [8, 3, 0.359, 0.0043, 3, 0.98, 0.25, 316, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " Interstate3D.objects.create(name=name, line=line_3d)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L85_C12", "label": "create()", "type": "expression", "loc": [85, 85], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "vector": [8, 3, 0.3632, 0.0043, 3, 0.98, 0.375, 316, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " InterstateProj3D.objects.create(name=name, line=line_3d)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L86_C12", "label": "create()", "type": "expression", "loc": [86, 86], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "vector": [8, 3, 0.3675, 0.0043, 3, 0.98, 0.5, 316, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " Interstate2D.objects.create(name=name, line=line_2d)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L87_C12", "label": "create()", "type": "expression", "loc": [87, 87], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "vector": [8, 3, 0.3718, 0.0043, 3, 0.98, 0.625, 316, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " InterstateProj2D.objects.create(name=name, line=line_2d)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L91_C12", "label": "interstate = get()", "type": "assigned_variable", "loc": [91, 91], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "vector": [14, 3, 0.3889, 0.0043, 3, 0.98, 0.75, 956, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "interstate", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " interstate = Interstate3D.objects.get(name=name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L92_C12", "label": "interstate_proj = get()", "type": "assigned_variable", "loc": [92, 92], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "vector": [14, 3, 0.3932, 0.0043, 3, 0.98, 0.875, 559, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "interstate_proj", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " interstate_proj = InterstateProj3D.objects.get(name=name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L93_C12", "label": "for i", "type": "for", "loc": [93, 95], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "vector": [6, 3, 0.4017, 0.0128, 3, 0.98, 1.0, 826, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "i", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i in [interstate, interstate_proj]:\n self.failUnless(i.line.hasz)\n self.assertEqual(exp_z, tuple(i.line.z))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L94_C16", "label": "failUnless()", "type": "expression", "loc": [94, 94], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L93_C12", "vector": [8, 4, 0.4017, 0.0043, 4, 0.54, 0.0, 252, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "failUnless", "arg_names": [], "import_names": [], "rhs_call_name": "failUnless", "annotation": ""}, "snippet": " self.failUnless(i.line.hasz)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L95_C16", "label": "assertEqual()", "type": "expression", "loc": [95, 95], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L93_C12", "vector": [8, 4, 0.406, 0.0043, 4, 0.54, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(exp_z, tuple(i.line.z))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L98_C8", "label": "bbox2d, bbox3d = gen_bbox()", "type": "assigned_variable", "loc": [98, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "vector": [14, 2, 0.4188, 0.0043, 2, 0.97, 0.375, 379, 3, 0, 0, 0, 892, 10, 1], "semantic": {"name": "bbox2d, bbox3d", "arg_names": [], "import_names": [], "rhs_call_name": "gen_bbox", "annotation": ""}, "snippet": " bbox2d, bbox3d = gen_bbox()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L99_C8", "label": "create()", "type": "expression", "loc": [99, 99], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "vector": [8, 2, 0.4231, 0.0043, 2, 0.97, 0.5, 316, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " Polygon2D.objects.create(name='2D BBox', poly=bbox2d)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L100_C8", "label": "create()", "type": "expression", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "vector": [8, 2, 0.4274, 0.0043, 2, 0.97, 0.625, 316, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " Polygon3D.objects.create(name='3D BBox', poly=bbox3d)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L101_C8", "label": "p3d = get()", "type": "assigned_variable", "loc": [101, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "vector": [14, 2, 0.4316, 0.0043, 2, 0.97, 0.75, 693, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "p3d", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " p3d = Polygon3D.objects.get(name='3D BBox')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L102_C8", "label": "failUnless()", "type": "expression", "loc": [102, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "vector": [8, 2, 0.4359, 0.0043, 2, 0.97, 0.875, 252, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "failUnless", "arg_names": [], "import_names": [], "rhs_call_name": "failUnless", "annotation": ""}, "snippet": " self.failUnless(p3d.poly.hasz)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L103_C8", "label": "assertEqual()", "type": "expression", "loc": [103, 103], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "vector": [8, 2, 0.4402, 0.0043, 2, 0.97, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(bbox3d, p3d.poly)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "label": "test01a_3d_layermapping", "type": "function", "loc": [105, 131], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "vector": [2, 1, 0.5043, 0.1154, 1, 0.01, 0.2, 86, 0, 1, 0, 0, 0, 0, 13], "semantic": {"name": "test01a_3d_layermapping", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test01a_3d_layermapping(self):\n \"Testing LayerMapping on 3D models.\"\n from models import Point2D, Point3D\n\n point_mapping = {'point' : 'POINT'}\n mpoint_mapping = {'mpoint' : 'MULTIPOINT'}\n\n # The VRT is 3D, but should still be able to map sans the Z."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L106_C8", "label": "expression", "type": "expression", "loc": [106, 106], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [8, 2, 0.453, 0.0043, 2, 0.17, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing LayerMapping on 3D models.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:ImportFrom_L107_C8", "label": "from models import Point2D, Point3D", "type": "import", "loc": [107, 107], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [1, 2, 0.4573, 0.0043, 2, 0.17, 0.0769, 495, 0, 2, 0, 0, 495, 0, 0], "semantic": {"name": "models", "arg_names": [], "import_names": ["Point2D", "Point3D"], "rhs_call_name": "", "annotation": ""}, "snippet": " from models import Point2D, Point3D"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L109_C8", "label": "point_mapping =", "type": "assigned_variable", "loc": [109, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [14, 2, 0.4658, 0.0043, 2, 0.17, 0.1538, 299, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "point_mapping", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " point_mapping = {'point' : 'POINT'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L110_C8", "label": "mpoint_mapping =", "type": "assigned_variable", "loc": [110, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [14, 2, 0.4701, 0.0043, 2, 0.17, 0.2308, 84, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "mpoint_mapping", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " mpoint_mapping = {'mpoint' : 'MULTIPOINT'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L113_C8", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [14, 2, 0.4829, 0.0043, 2, 0.17, 0.3077, 376, 3, 4, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(Point2D, vrt_file, point_mapping, transform=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L114_C8", "label": "save()", "type": "expression", "loc": [114, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [8, 2, 0.4872, 0.0043, 2, 0.17, 0.3846, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L115_C8", "label": "assertEqual()", "type": "expression", "loc": [115, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [8, 2, 0.4915, 0.0043, 2, 0.17, 0.4615, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(3, Point2D.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L119_C8", "label": "assertRaises()", "type": "expression", "loc": [119, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [8, 2, 0.5107, 0.0085, 2, 0.17, 0.5385, 11, 3, 6, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(LayerMapError, LayerMapping,\n Point3D, city_file, point_mapping, transform=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L123_C8", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [123, 123], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [14, 2, 0.5256, 0.0043, 2, 0.17, 0.6154, 376, 3, 4, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(Point3D, vrt_file, point_mapping, transform=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L124_C8", "label": "save()", "type": "expression", "loc": [124, 124], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [8, 2, 0.5299, 0.0043, 2, 0.17, 0.6923, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L125_C8", "label": "assertEqual()", "type": "expression", "loc": [125, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [8, 2, 0.5342, 0.0043, 2, 0.17, 0.7692, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(3, Point3D.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L129_C8", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [129, 129], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [14, 2, 0.5513, 0.0043, 2, 0.17, 0.8462, 376, 3, 4, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(MultiPoint3D, vrt_file, mpoint_mapping, transform=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L130_C8", "label": "save()", "type": "expression", "loc": [130, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [8, 2, 0.5556, 0.0043, 2, 0.17, 0.9231, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L131_C8", "label": "assertEqual()", "type": "expression", "loc": [131, 131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "vector": [8, 2, 0.5598, 0.0043, 2, 0.17, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(3, MultiPoint3D.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L133_C4", "label": "test02a_kml", "type": "function", "loc": [133, 139], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "vector": [2, 1, 0.5812, 0.0299, 1, 0.01, 0.3, 38, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test02a_kml", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test02a_kml(self):\n \"Test GeoQuerySet.kml() with Z values.\"\n h = City3D.objects.kml(precision=6).get(name='Houston')\n # KML should be 3D.\n # `SELECT ST_AsKML(point, 6) FROM geo3d_city3d WHERE name = 'Houston';`\n ref_kml_regex = re.compile(r'^<Point><coordinates>-95.363\\d+,29.763\\d+,18</coordinates></Point>$')\n self.failUnless(ref_kml_regex.match(h.kml))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L134_C8", "label": "expression", "type": "expression", "loc": [134, 134], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L133_C4", "vector": [8, 2, 0.5726, 0.0043, 2, 0.47, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Test GeoQuerySet.kml() with Z values.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L135_C8", "label": "h = get()", "type": "assigned_variable", "loc": [135, 135], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L133_C4", "vector": [14, 2, 0.5769, 0.0043, 2, 0.47, 0.3333, 686, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "h", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " h = City3D.objects.kml(precision=6).get(name='Houston')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L138_C8", "label": "ref_kml_regex = compile()", "type": "assigned_variable", "loc": [138, 138], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L133_C4", "vector": [14, 2, 0.5897, 0.0043, 2, 0.47, 0.6667, 748, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "ref_kml_regex", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": " ref_kml_regex = re.compile(r'^<Point><coordinates>-95.363\\d+,29.763\\d+,18</coordinates></Point>$')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L139_C8", "label": "failUnless()", "type": "expression", "loc": [139, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L133_C4", "vector": [8, 2, 0.594, 0.0043, 2, 0.47, 1.0, 252, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "failUnless", "arg_names": [], "import_names": [], "rhs_call_name": "failUnless", "annotation": ""}, "snippet": " self.failUnless(ref_kml_regex.match(h.kml))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L141_C4", "label": "test02b_geojson", "type": "function", "loc": [141, 147], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "vector": [2, 1, 0.6154, 0.0299, 1, 0.01, 0.4, 24, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test02b_geojson", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test02b_geojson(self):\n \"Test GeoQuerySet.geojson() with Z values.\"\n h = City3D.objects.geojson(precision=6).get(name='Houston')\n # GeoJSON should be 3D\n # `SELECT ST_AsGeoJSON(point, 6) FROM geo3d_city3d WHERE name='Houston';`\n ref_json_regex = re.compile(r'^{\"type\":\"Point\",\"coordinates\":\\[-95.363151,29.763374,18(\\.0+)?\\]}$')\n self.failUnless(ref_json_regex.match(h.geojson))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L142_C8", "label": "expression", "type": "expression", "loc": [142, 142], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L141_C4", "vector": [8, 2, 0.6068, 0.0043, 2, 0.0, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Test GeoQuerySet.geojson() with Z values.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L143_C8", "label": "h = get()", "type": "assigned_variable", "loc": [143, 143], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L141_C4", "vector": [14, 2, 0.6111, 0.0043, 2, 0.0, 0.3333, 686, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "h", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " h = City3D.objects.geojson(precision=6).get(name='Houston')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L146_C8", "label": "ref_json_regex = compile()", "type": "assigned_variable", "loc": [146, 146], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L141_C4", "vector": [14, 2, 0.6239, 0.0043, 2, 0.0, 0.6667, 569, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "ref_json_regex", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": " ref_json_regex = re.compile(r'^{\"type\":\"Point\",\"coordinates\":\\[-95.363151,29.763374,18(\\.0+)?\\]}$')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L147_C8", "label": "failUnless()", "type": "expression", "loc": [147, 147], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L141_C4", "vector": [8, 2, 0.6282, 0.0043, 2, 0.0, 1.0, 252, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "failUnless", "arg_names": [], "import_names": [], "rhs_call_name": "failUnless", "annotation": ""}, "snippet": " self.failUnless(ref_json_regex.match(h.geojson))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "label": "test03a_union", "type": "function", "loc": [149, 157], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "vector": [2, 1, 0.6538, 0.0385, 1, 0.01, 0.5, 131, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test03a_union", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test03a_union(self):\n \"Testing the Union aggregate of 3D models.\"\n # PostGIS query that returned the reference EWKT for this test:\n # `SELECT ST_AsText(ST_Union(point)) FROM geo3d_city3d;`\n ref_ewkt = 'SRID=4326;MULTIPOINT(-123.305196 48.462611 15,-104.609252 38.255001 1433,-97.521157 34.464642 380,-96.801611 32.782057 147,-95.363151 29.763374 18,-95.23506 38.971823 251,-87.650175 41.850385 181,174.783117 -41.315268 14)'\n ref_union = GEOSGeometry(ref_ewkt)\n union = City3D.objects.aggregate(Union('point'))['point__union']\n self.failUnless(union.hasz)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L150_C8", "label": "expression", "type": "expression", "loc": [150, 150], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "vector": [8, 2, 0.641, 0.0043, 2, 0.27, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the Union aggregate of 3D models.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L153_C8", "label": "ref_ewkt =", "type": "assigned_variable", "loc": [153, 153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "vector": [14, 2, 0.6538, 0.0043, 2, 0.27, 0.2, 625, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "ref_ewkt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_ewkt = 'SRID=4326;MULTIPOINT(-123.305196 48.462611 15,-104.609252 38.255001 1433,-97.521157 34.464642 380,-96.801611 32.782057 147,-95.363151 29.763374 18,-95.23506 38.971823 251,-87.650175 41.850385 181,174.783117 -41.315268 14)'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L154_C8", "label": "ref_union = GEOSGeometry()", "type": "assigned_variable", "loc": [154, 154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "vector": [14, 2, 0.6581, 0.0043, 2, 0.27, 0.4, 450, 3, 1, 0, 0, 958, 10, 1], "semantic": {"name": "ref_union", "arg_names": [], "import_names": [], "rhs_call_name": "GEOSGeometry", "annotation": ""}, "snippet": " ref_union = GEOSGeometry(ref_ewkt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L155_C8", "label": "union =", "type": "assigned_variable", "loc": [155, 155], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "vector": [14, 2, 0.6624, 0.0043, 2, 0.27, 0.6, 140, 6, 0, 0, 0, 0, 0, 2], "semantic": {"name": "union", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " union = City3D.objects.aggregate(Union('point'))['point__union']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L156_C8", "label": "failUnless()", "type": "expression", "loc": [156, 156], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "vector": [8, 2, 0.6667, 0.0043, 2, 0.27, 0.8, 252, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "failUnless", "arg_names": [], "import_names": [], "rhs_call_name": "failUnless", "annotation": ""}, "snippet": " self.failUnless(union.hasz)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L157_C8", "label": "assertEqual()", "type": "expression", "loc": [157, 157], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "vector": [8, 2, 0.6709, 0.0043, 2, 0.27, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(ref_union, union)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "label": "test03b_extent", "type": "function", "loc": [159, 171], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "vector": [2, 1, 0.7051, 0.0556, 1, 0.01, 0.6, 516, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test03b_extent", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test03b_extent(self):\n \"Testing the Extent3D aggregate for 3D models.\"\n # `SELECT ST_Extent3D(point) FROM geo3d_city3d;`\n ref_extent3d = (-123.305196, -41.315268, 14,174.783117, 48.462611, 1433)\n extent1 = City3D.objects.aggregate(Extent3D('point'))['point__extent3d']\n extent2 = City3D.objects.extent3d()\n\n def check_extent3d(extent3d, tol=6):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L160_C8", "label": "expression", "type": "expression", "loc": [160, 160], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "vector": [8, 2, 0.6838, 0.0043, 2, 0.07, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the Extent3D aggregate for 3D models.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L162_C8", "label": "ref_extent3d =", "type": "assigned_variable", "loc": [162, 162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "vector": [14, 2, 0.6923, 0.0043, 2, 0.07, 0.2, 503, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "ref_extent3d", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_extent3d = (-123.305196, -41.315268, 14,174.783117, 48.462611, 1433)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L163_C8", "label": "extent1 =", "type": "assigned_variable", "loc": [163, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "vector": [14, 2, 0.6966, 0.0043, 2, 0.07, 0.4, 901, 6, 0, 0, 0, 0, 0, 2], "semantic": {"name": "extent1", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " extent1 = City3D.objects.aggregate(Extent3D('point'))['point__extent3d']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L164_C8", "label": "extent2 = extent3d()", "type": "assigned_variable", "loc": [164, 164], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "vector": [14, 2, 0.7009, 0.0043, 2, 0.07, 0.6, 888, 3, 0, 0, 0, 187, 10, 1], "semantic": {"name": "extent2", "arg_names": [], "import_names": [], "rhs_call_name": "extent3d", "annotation": ""}, "snippet": " extent2 = City3D.objects.extent3d()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L166_C8", "label": "check_extent3d", "type": "function", "loc": [166, 168], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "vector": [2, 2, 0.7137, 0.0128, 2, 0.07, 0.8, 750, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "check_extent3d", "arg_names": ["extent3d", "tol"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def check_extent3d(extent3d, tol=6):\n for ref_val, ext_val in zip(ref_extent3d, extent3d):\n self.assertAlmostEqual(ref_val, ext_val, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L167_C12", "label": "for ref_val, ext_val", "type": "for", "loc": [167, 168], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L166_C8", "vector": [6, 3, 0.7158, 0.0085, 3, 0.02, 0.0, 611, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "ref_val, ext_val", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for ref_val, ext_val in zip(ref_extent3d, extent3d):\n self.assertAlmostEqual(ref_val, ext_val, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L168_C16", "label": "assertAlmostEqual()", "type": "expression", "loc": [168, 168], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L167_C12", "vector": [8, 4, 0.7179, 0.0043, 4, 0.58, 0.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(ref_val, ext_val, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L170_C8", "label": "for e3d", "type": "for", "loc": [170, 171], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "vector": [6, 2, 0.7286, 0.0085, 2, 0.07, 1.0, 194, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "e3d", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for e3d in [extent1, extent2]:\n check_extent3d(e3d)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L171_C12", "label": "check_extent3d()", "type": "expression", "loc": [171, 171], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L170_C8", "vector": [8, 3, 0.7308, 0.0043, 3, 0.01, 0.0, 750, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "check_extent3d", "arg_names": [], "import_names": [], "rhs_call_name": "check_extent3d", "annotation": ""}, "snippet": " check_extent3d(e3d)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "label": "test04_perimeter", "type": "function", "loc": [173, 185], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "vector": [2, 1, 0.765, 0.0556, 1, 0.01, 0.7, 782, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test04_perimeter", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test04_perimeter(self):\n \"Testing GeoQuerySet.perimeter() on 3D fields.\"\n # Reference query for values below:\n # `SELECT ST_Perimeter3D(poly), ST_Perimeter2D(poly) FROM geo3d_polygon3d;`\n ref_perim_3d = 76859.2620451\n ref_perim_2d = 76859.2577803\n tol = 6\n self.assertAlmostEqual(ref_perim_2d,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L174_C8", "label": "expression", "type": "expression", "loc": [174, 174], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "vector": [8, 2, 0.7436, 0.0043, 2, 0.58, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing GeoQuerySet.perimeter() on 3D fields.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L177_C8", "label": "ref_perim_3d =", "type": "assigned_variable", "loc": [177, 177], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "vector": [14, 2, 0.7564, 0.0043, 2, 0.58, 0.2, 640, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "ref_perim_3d", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_perim_3d = 76859.2620451"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L178_C8", "label": "ref_perim_2d =", "type": "assigned_variable", "loc": [178, 178], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "vector": [14, 2, 0.7607, 0.0043, 2, 0.58, 0.4, 759, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "ref_perim_2d", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_perim_2d = 76859.2577803"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L179_C8", "label": "tol =", "type": "assigned_variable", "loc": [179, 179], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "vector": [14, 2, 0.765, 0.0043, 2, 0.58, 0.6, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 6"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L180_C8", "label": "assertAlmostEqual()", "type": "expression", "loc": [180, 182], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "vector": [8, 2, 0.7735, 0.0128, 2, 0.58, 0.8, 448, 3, 3, 0, 0, 0, 0, 3], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(ref_perim_2d,\n Polygon2D.objects.perimeter().get(name='2D BBox').perimeter.m,\n tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L183_C8", "label": "assertAlmostEqual()", "type": "expression", "loc": [183, 185], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "vector": [8, 2, 0.7863, 0.0128, 2, 0.58, 1.0, 448, 3, 3, 0, 0, 0, 0, 3], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(ref_perim_3d,\n Polygon3D.objects.perimeter().get(name='3D BBox').perimeter.m,\n tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "label": "test05_length", "type": "function", "loc": [187, 214], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "vector": [2, 1, 0.8568, 0.1197, 1, 0.01, 0.8, 831, 0, 1, 0, 0, 0, 0, 12], "semantic": {"name": "test05_length", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test05_length(self):\n \"Testing GeoQuerySet.length() on 3D fields.\"\n # ST_Length_Spheroid Z-aware, and thus does not need to use\n # a separate function internally.\n # `SELECT ST_Length_Spheroid(line, 'SPHEROID[\"GRS 1980\",6378137,298.257222101]') \n # FROM geo3d_interstate[2d|3d];`\n tol = 3\n ref_length_2d = 4368.1721949481"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L188_C8", "label": "expression", "type": "expression", "loc": [188, 188], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "vector": [8, 2, 0.8034, 0.0043, 2, 0.05, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing GeoQuerySet.length() on 3D fields.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L193_C8", "label": "tol =", "type": "assigned_variable", "loc": [193, 193], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "vector": [14, 2, 0.8248, 0.0043, 2, 0.05, 0.1111, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 3"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L194_C8", "label": "ref_length_2d =", "type": "assigned_variable", "loc": [194, 194], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "vector": [14, 2, 0.8291, 0.0043, 2, 0.05, 0.2222, 734, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "ref_length_2d", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_length_2d = 4368.1721949481"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L195_C8", "label": "ref_length_3d =", "type": "assigned_variable", "loc": [195, 195], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "vector": [14, 2, 0.8333, 0.0043, 2, 0.05, 0.3333, 207, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "ref_length_3d", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_length_3d = 4368.62547052088"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L196_C8", "label": "assertAlmostEqual()", "type": "expression", "loc": [196, 198], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "vector": [8, 2, 0.8419, 0.0128, 2, 0.05, 0.4444, 448, 3, 3, 0, 0, 0, 0, 3], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(ref_length_2d,\n Interstate2D.objects.length().get(name='I-45').length.m,\n tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L199_C8", "label": "assertAlmostEqual()", "type": "expression", "loc": [199, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "vector": [8, 2, 0.8547, 0.0128, 2, 0.05, 0.5556, 448, 3, 3, 0, 0, 0, 0, 3], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(ref_length_3d,\n Interstate3D.objects.length().get(name='I-45').length.m,\n tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L206_C8", "label": "ref_length_2d =", "type": "assigned_variable", "loc": [206, 206], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "vector": [14, 2, 0.8803, 0.0043, 2, 0.05, 0.6667, 734, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "ref_length_2d", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_length_2d = 4367.71564892392"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L208_C8", "label": "ref_length_3d =", "type": "assigned_variable", "loc": [208, 208], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "vector": [14, 2, 0.8889, 0.0043, 2, 0.05, 0.7778, 207, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "ref_length_3d", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_length_3d = 4368.16897234101"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L209_C8", "label": "assertAlmostEqual()", "type": "expression", "loc": [209, 211], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "vector": [8, 2, 0.8974, 0.0128, 2, 0.05, 0.8889, 448, 3, 3, 0, 0, 0, 0, 3], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(ref_length_2d,\n InterstateProj2D.objects.length().get(name='I-45').length.m,\n tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L212_C8", "label": "assertAlmostEqual()", "type": "expression", "loc": [212, 214], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "vector": [8, 2, 0.9103, 0.0128, 2, 0.05, 1.0, 448, 3, 3, 0, 0, 0, 0, 3], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(ref_length_3d,\n InterstateProj3D.objects.length().get(name='I-45').length.m,\n tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L216_C4", "label": "test06_scale", "type": "function", "loc": [216, 222], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "vector": [2, 1, 0.9359, 0.0299, 1, 0.01, 0.9, 732, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test06_scale", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test06_scale(self):\n \"Testing GeoQuerySet.scale() on Z values.\"\n # Mapping of City name to reference Z values.\n zscales = (-3, 4, 23)\n for zscale in zscales:\n for city in City3D.objects.scale(1.0, 1.0, zscale):\n self.assertEqual(city_dict[city.name][2] * zscale, city.scale.z)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L217_C8", "label": "expression", "type": "expression", "loc": [217, 217], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L216_C4", "vector": [8, 2, 0.9274, 0.0043, 2, 0.77, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing GeoQuerySet.scale() on Z values.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L219_C8", "label": "zscales =", "type": "assigned_variable", "loc": [219, 219], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L216_C4", "vector": [14, 2, 0.9359, 0.0043, 2, 0.77, 0.5, 244, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "zscales", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " zscales = (-3, 4, 23)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L220_C8", "label": "for zscale", "type": "for", "loc": [220, 222], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L216_C4", "vector": [6, 2, 0.9444, 0.0128, 2, 0.77, 1.0, 152, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "zscale", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for zscale in zscales:\n for city in City3D.objects.scale(1.0, 1.0, zscale):\n self.assertEqual(city_dict[city.name][2] * zscale, city.scale.z)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L221_C12", "label": "for city", "type": "for", "loc": [221, 222], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L220_C8", "vector": [6, 3, 0.9466, 0.0085, 3, 0.26, 0.0, 825, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "city", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for city in City3D.objects.scale(1.0, 1.0, zscale):\n self.assertEqual(city_dict[city.name][2] * zscale, city.scale.z)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L222_C16", "label": "assertEqual()", "type": "expression", "loc": [222, 222], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L221_C12", "vector": [8, 4, 0.9487, 0.0043, 4, 0.97, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(city_dict[city.name][2] * zscale, city.scale.z)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L224_C4", "label": "test07_translate", "type": "function", "loc": [224, 229], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "vector": [2, 1, 0.9679, 0.0256, 1, 0.01, 1.0, 878, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test07_translate", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test07_translate(self):\n \"Testing GeoQuerySet.translate() on Z values.\"\n ztranslations = (5.23, 23, -17)\n for ztrans in ztranslations:\n for city in City3D.objects.translate(0, 0, ztrans):\n self.assertEqual(city_dict[city.name][2] + ztrans, city.translate.z)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L225_C8", "label": "expression", "type": "expression", "loc": [225, 225], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L224_C4", "vector": [8, 2, 0.9615, 0.0043, 2, 0.39, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing GeoQuerySet.translate() on Z values.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L226_C8", "label": "ztranslations =", "type": "assigned_variable", "loc": [226, 226], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L224_C4", "vector": [14, 2, 0.9658, 0.0043, 2, 0.39, 0.5, 316, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "ztranslations", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ztranslations = (5.23, 23, -17)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L227_C8", "label": "for ztrans", "type": "for", "loc": [227, 229], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L224_C4", "vector": [6, 2, 0.9744, 0.0128, 2, 0.39, 1.0, 352, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "ztrans", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for ztrans in ztranslations:\n for city in City3D.objects.translate(0, 0, ztrans):\n self.assertEqual(city_dict[city.name][2] + ztrans, city.translate.z)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L228_C12", "label": "for city", "type": "for", "loc": [228, 229], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L227_C8", "vector": [6, 3, 0.9765, 0.0085, 3, 0.68, 0.0, 825, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "city", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for city in City3D.objects.translate(0, 0, ztrans):\n self.assertEqual(city_dict[city.name][2] + ztrans, city.translate.z)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L229_C16", "label": "assertEqual()", "type": "expression", "loc": [229, 229], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L228_C12", "vector": [8, 4, 0.9786, 0.0043, 4, 0.0, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(city_dict[city.name][2] + ztrans, city.translate.z)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L231_C0", "label": "suite", "type": "function", "loc": [231, 234], "level": 0, "parent": null, "vector": [2, 0, 0.9936, 0.0171, 0, 0.66, 1.0, 425, 0, 0, 1, 0, 0, 0, 3], "semantic": {"name": "suite", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def suite():\n s = unittest.TestSuite()\n s.addTest(unittest.makeSuite(Geo3DTest))\n return s"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L232_C4", "label": "s = TestSuite()", "type": "assigned_variable", "loc": [232, 232], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L231_C0", "vector": [14, 1, 0.9915, 0.0043, 1, 0.52, 0.0, 553, 3, 0, 0, 0, 75, 10, 1], "semantic": {"name": "s", "arg_names": [], "import_names": [], "rhs_call_name": "TestSuite", "annotation": ""}, "snippet": " s = unittest.TestSuite()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L233_C4", "label": "addTest()", "type": "expression", "loc": [233, 233], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L231_C0", "vector": [8, 1, 0.9957, 0.0043, 1, 0.52, 0.5, 786, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "addTest", "arg_names": [], "import_names": [], "rhs_call_name": "addTest", "annotation": ""}, "snippet": " s.addTest(unittest.makeSuite(Geo3DTest))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98682:Return_L234_C4", "label": "return", "type": "return", "loc": [234, 234], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L231_C0", "vector": [13, 1, 1.0, 0.0043, 1, 0.52, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return s"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Return_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L53_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L69_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L70_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L71_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L72_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L73_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L74_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L80_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L84_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L85_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L86_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L87_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L91_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L92_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L93_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L93_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L94_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L93_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L95_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L98_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L99_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L102_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L103_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L106_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:ImportFrom_L107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L115_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L123_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L124_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L129_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L130_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L133_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L133_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L134_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L133_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L135_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L133_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L138_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L133_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L139_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L141_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L142_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L143_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L146_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L147_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L150_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L153_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L155_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L157_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L160_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L164_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L166_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L167_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L167_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L168_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L170_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L170_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L171_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L174_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L177_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L178_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L179_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L180_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L183_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L188_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L193_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L194_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L195_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L199_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L206_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L208_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L209_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L187_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L212_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L216_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L216_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L217_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L216_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L219_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L216_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L220_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L220_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L221_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L221_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L222_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:ClassDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L224_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L224_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L225_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L224_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L226_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L224_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L227_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L227_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L228_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:For_L228_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L229_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L231_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Assign_L232_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L231_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Expr_L233_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98682:FunctionDef_L231_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98682:Return_L234_C4"}] |
# Create your views here.
| ajibawa-2023/Python-Code-Large/train/row_98683 | 0 | 1 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [] | [] |
au_cities = (('Wollongong', 150.902, -34.4245),
('Shellharbour', 150.87, -34.5789),
('Thirroul', 150.924, -34.3147),
('Mittagong', 150.449, -34.4509),
('Batemans Bay', 150.175, -35.7082),
('Canberra', 144.963, -37.8143),
('Melbourne', 145.963, -37.8143),
('Sydney', 151.26071, -33.887034),
('Hobart', 147.33, -42.8827),
('Adelaide', 138.6, -34.9258),
('Hillsdale', 151.231341, -33.952685),
)
stx_cities = (('Downtown Houston', -95.363151, 29.763374),
('West University Place', -95.448601, 29.713803),
('Southside Place', -95.436920, 29.705777),
('Bellaire', -95.458732, 29.705614),
('Pearland', -95.287303, 29.563568),
('Galveston', -94.797489, 29.301336),
('Sealy', -96.156952, 29.780918),
('San Antonio', -98.493183, 29.424170),
('Saint Hedwig', -98.199820, 29.414197),
)
# Data from U.S. Census ZCTA cartographic boundary file for Texas (`zt48_d00.shp`).
stx_zips = (('77002', 'POLYGON ((-95.365015 29.772327, -95.362415 29.772327, -95.360915 29.771827, -95.354615 29.771827, -95.351515 29.772527, -95.350915 29.765327, -95.351015 29.762436, -95.350115 29.760328, -95.347515 29.758528, -95.352315 29.753928, -95.356415 29.756328, -95.358215 29.754028, -95.360215 29.756328, -95.363415 29.757128, -95.364014 29.75638, -95.363415 29.753928, -95.360015 29.751828, -95.361815 29.749528, -95.362715 29.750028, -95.367516 29.744128, -95.369316 29.745128, -95.373916 29.744128, -95.380116 29.738028, -95.387916 29.727929, -95.388516 29.729629, -95.387916 29.732129, -95.382916 29.737428, -95.376616 29.742228, -95.372616 29.747228, -95.378601 29.750846, -95.378616 29.752028, -95.378616 29.754428, -95.376016 29.754528, -95.374616 29.759828, -95.373616 29.761128, -95.371916 29.763928, -95.372316 29.768727, -95.365884 29.76791, -95.366015 29.767127, -95.358715 29.765327, -95.358615 29.766327, -95.359115 29.767227, -95.360215 29.767027, -95.362783 29.768267, -95.365315 29.770527, -95.365015 29.772327))'),
('77005', 'POLYGON ((-95.447918 29.727275, -95.428017 29.728729, -95.421117 29.729029, -95.418617 29.727629, -95.418517 29.726429, -95.402117 29.726629, -95.402117 29.725729, -95.395316 29.725729, -95.391916 29.726229, -95.389716 29.725829, -95.396517 29.715429, -95.397517 29.715929, -95.400917 29.711429, -95.411417 29.715029, -95.418417 29.714729, -95.418317 29.70623, -95.440818 29.70593, -95.445018 29.70683, -95.446618 29.70763, -95.447418 29.71003, -95.447918 29.727275))'),
('77025', 'POLYGON ((-95.418317 29.70623, -95.414717 29.706129, -95.414617 29.70533, -95.418217 29.70533, -95.419817 29.69533, -95.419484 29.694196, -95.417166 29.690901, -95.414517 29.69433, -95.413317 29.69263, -95.412617 29.68973, -95.412817 29.68753, -95.414087 29.685055, -95.419165 29.685428, -95.421617 29.68513, -95.425717 29.67983, -95.425017 29.67923, -95.424517 29.67763, -95.427418 29.67763, -95.438018 29.664631, -95.436713 29.664411, -95.440118 29.662231, -95.439218 29.661031, -95.437718 29.660131, -95.435718 29.659731, -95.431818 29.660331, -95.441418 29.656631, -95.441318 29.656331, -95.441818 29.656131, -95.441718 29.659031, -95.441118 29.661031, -95.446718 29.656431, -95.446518 29.673431, -95.446918 29.69013, -95.447418 29.71003, -95.446618 29.70763, -95.445018 29.70683, -95.440818 29.70593, -95.418317 29.70623))'),
('77401', 'POLYGON ((-95.447918 29.727275, -95.447418 29.71003, -95.446918 29.69013, -95.454318 29.68893, -95.475819 29.68903, -95.475819 29.69113, -95.484419 29.69103, -95.484519 29.69903, -95.480419 29.70133, -95.480419 29.69833, -95.474119 29.69833, -95.474119 29.70453, -95.472719 29.71283, -95.468019 29.71293, -95.468219 29.720229, -95.464018 29.720229, -95.464118 29.724529, -95.463018 29.725929, -95.459818 29.726129, -95.459918 29.720329, -95.451418 29.720429, -95.451775 29.726303, -95.451318 29.727029, -95.447918 29.727275))'),
)
interstates = (('I-25', 'LINESTRING(-104.4780170766108 36.66698791870694, -104.4468522338495 36.79925409393386, -104.46212692626 36.9372149776075, -104.5126119783768 37.08163268820887, -104.5247764602161 37.29300499892048, -104.7084397427668 37.49150259925398, -104.8126599016282 37.69514285621863, -104.8452887035466 37.87613395659479, -104.7160169341003 38.05951763337799, -104.6165437927668 38.30432045855106, -104.6437227858174 38.53979986564737, -104.7596170387259 38.7322907594295, -104.8380078676822 38.89998460604341, -104.8501253693506 39.09980189213358, -104.8791648316464 39.24368776457503, -104.8635041274215 39.3785278162751, -104.8894471170052 39.5929228239605, -104.9721242843344 39.69528482419685, -105.0112104500356 39.7273080432394, -105.0010368577104 39.76677607811571, -104.981835619 39.81466504121967, -104.9858891550477 39.88806911250832, -104.9873548059578 39.98117234571016, -104.9766220487419 40.09796423450692, -104.9818565932953 40.36056530662884, -104.9912746373997 40.74904484447656)'),
)
stx_interstates = (('I-10', 'LINESTRING(924952.5 4220931.6,925065.3 4220931.6,929568.4 4221057.8)'),
)
| ajibawa-2023/Python-Code-Large/train/row_98684 | 5 | 36 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98684:Assign_L1_C0", "label": "au_cities =", "type": "assigned_variable", "loc": [1, 12], "level": 0, "parent": null, "vector": [14, 0, 0.1806, 0.3333, 0, 0.66, 0.0, 425, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "au_cities", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "au_cities = (('Wollongong', 150.902, -34.4245),\n ('Shellharbour', 150.87, -34.5789),\n ('Thirroul', 150.924, -34.3147),\n ('Mittagong', 150.449, -34.4509),\n ('Batemans Bay', 150.175, -35.7082),\n ('Canberra', 144.963, -37.8143),\n ('Melbourne', 145.963, -37.8143),\n ('Sydney', 151.26071, -33.887034),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98684:Assign_L14_C0", "label": "stx_cities =", "type": "assigned_variable", "loc": [14, 23], "level": 0, "parent": null, "vector": [14, 0, 0.5139, 0.2778, 0, 0.66, 0.25, 989, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "stx_cities", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "stx_cities = (('Downtown Houston', -95.363151, 29.763374),\n ('West University Place', -95.448601, 29.713803),\n ('Southside Place', -95.436920, 29.705777),\n ('Bellaire', -95.458732, 29.705614),\n ('Pearland', -95.287303, 29.563568),\n ('Galveston', -94.797489, 29.301336),\n ('Sealy', -96.156952, 29.780918),\n ('San Antonio', -98.493183, 29.424170),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98684:Assign_L26_C0", "label": "stx_zips =", "type": "assigned_variable", "loc": [26, 30], "level": 0, "parent": null, "vector": [14, 0, 0.7778, 0.1389, 0, 0.66, 0.5, 222, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "stx_zips", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "stx_zips = (('77002', 'POLYGON ((-95.365015 29.772327, -95.362415 29.772327, -95.360915 29.771827, -95.354615 29.771827, -95.351515 29.772527, -95.350915 29.765327, -95.351015 29.762436, -95.350115 29.760328, -95.347515 29.758528, -95.352315 29.753928, -95.356415 29.756328, -95.358215 29.754028, -95.360215 29.756328, -95.363415 29.757128, -95.364014 29.75638, -95.363415 29.753928, -95.360015 29.751828, -95.361815 29.749528, -95.362715 29.750028, -95.367516 29.744128, -95.369316 29.745128, -95.373916 29.744128, -95.380116 29.738028, -95.387916 29.727929, -95.388516 29.729629, -95.387916 29.732129, -95.382916 29.737428, -95.376616 29.742228, -95.372616 29.747228, -95.378601 29.750846, -95.378616 29.752028, -95.378616 29.754428, -95.376016 29.754528, -95.374616 29.759828, -95.373616 29.761128, -95.371916 29.763928, -95.372316 29.768727, -95.365884 29.76791, -95.366015 29.767127, -95.358715 29.765327, -95.358615 29.766327, -95.359115 29.767227, -95.360215 29.767027, -95.362783 29.768267, -95.365315 29.770527, -95.365015 29.772327))'),\n ('77005', 'POLYGON ((-95.447918 29.727275, -95.428017 29.728729, -95.421117 29.729029, -95.418617 29.727629, -95.418517 29.726429, -95.402117 29.726629, -95.402117 29.725729, -95.395316 29.725729, -95.391916 29.726229, -95.389716 29.725829, -95.396517 29.715429, -95.397517 29.715929, -95.400917 29.711429, -95.411417 29.715029, -95.418417 29.714729, -95.418317 29.70623, -95.440818 29.70593, -95.445018 29.70683, -95.446618 29.70763, -95.447418 29.71003, -95.447918 29.727275))'),\n ('77025', 'POLYGON ((-95.418317 29.70623, -95.414717 29.706129, -95.414617 29.70533, -95.418217 29.70533, -95.419817 29.69533, -95.419484 29.694196, -95.417166 29.690901, -95.414517 29.69433, -95.413317 29.69263, -95.412617 29.68973, -95.412817 29.68753, -95.414087 29.685055, -95.419165 29.685428, -95.421617 29.68513, -95.425717 29.67983, -95.425017 29.67923, -95.424517 29.67763, -95.427418 29.67763, -95.438018 29.664631, -95.436713 29.664411, -95.440118 29.662231, -95.439218 29.661031, -95.437718 29.660131, -95.435718 29.659731, -95.431818 29.660331, -95.441418 29.656631, -95.441318 29.656331, -95.441818 29.656131, -95.441718 29.659031, -95.441118 29.661031, -95.446718 29.656431, -95.446518 29.673431, -95.446918 29.69013, -95.447418 29.71003, -95.446618 29.70763, -95.445018 29.70683, -95.440818 29.70593, -95.418317 29.70623))'),\n ('77401', 'POLYGON ((-95.447918 29.727275, -95.447418 29.71003, -95.446918 29.69013, -95.454318 29.68893, -95.475819 29.68903, -95.475819 29.69113, -95.484419 29.69103, -95.484519 29.69903, -95.480419 29.70133, -95.480419 29.69833, -95.474119 29.69833, -95.474119 29.70453, -95.472719 29.71283, -95.468019 29.71293, -95.468219 29.720229, -95.464018 29.720229, -95.464118 29.724529, -95.463018 29.725929, -95.459818 29.726129, -95.459918 29.720329, -95.451418 29.720429, -95.451775 29.726303, -95.451318 29.727029, -95.447918 29.727275))'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98684:Assign_L32_C0", "label": "interstates =", "type": "assigned_variable", "loc": [32, 33], "level": 0, "parent": null, "vector": [14, 0, 0.9028, 0.0556, 0, 0.66, 0.75, 609, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "interstates", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "interstates = (('I-25', 'LINESTRING(-104.4780170766108 36.66698791870694, -104.4468522338495 36.79925409393386, -104.46212692626 36.9372149776075, -104.5126119783768 37.08163268820887, -104.5247764602161 37.29300499892048, -104.7084397427668 37.49150259925398, -104.8126599016282 37.69514285621863, -104.8452887035466 37.87613395659479, -104.7160169341003 38.05951763337799, -104.6165437927668 38.30432045855106, -104.6437227858174 38.53979986564737, -104.7596170387259 38.7322907594295, -104.8380078676822 38.89998460604341, -104.8501253693506 39.09980189213358, -104.8791648316464 39.24368776457503, -104.8635041274215 39.3785278162751, -104.8894471170052 39.5929228239605, -104.9721242843344 39.69528482419685, -105.0112104500356 39.7273080432394, -105.0010368577104 39.76677607811571, -104.981835619 39.81466504121967, -104.9858891550477 39.88806911250832, -104.9873548059578 39.98117234571016, -104.9766220487419 40.09796423450692, -104.9818565932953 40.36056530662884, -104.9912746373997 40.74904484447656)'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98684:Assign_L35_C0", "label": "stx_interstates =", "type": "assigned_variable", "loc": [35, 36], "level": 0, "parent": null, "vector": [14, 0, 0.9861, 0.0556, 0, 0.66, 1.0, 804, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "stx_interstates", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "stx_interstates = (('I-10', 'LINESTRING(924952.5 4220931.6,925065.3 4220931.6,929568.4 4221057.8)'),\n )"}] | [] |
from django.contrib.gis.db import models
class SouthTexasCity(models.Model):
"City model on projected coordinate system for South Texas."
name = models.CharField(max_length=30)
point = models.PointField(srid=32140)
objects = models.GeoManager()
def __unicode__(self): return self.name
class SouthTexasCityFt(models.Model):
"Same City model as above, but U.S. survey feet are the units."
name = models.CharField(max_length=30)
point = models.PointField(srid=2278)
objects = models.GeoManager()
def __unicode__(self): return self.name
class AustraliaCity(models.Model):
"City model for Australia, using WGS84."
name = models.CharField(max_length=30)
point = models.PointField()
objects = models.GeoManager()
def __unicode__(self): return self.name
class CensusZipcode(models.Model):
"Model for a few South Texas ZIP codes (in original Census NAD83)."
name = models.CharField(max_length=5)
poly = models.PolygonField(srid=4269)
objects = models.GeoManager()
def __unicode__(self): return self.name
class SouthTexasZipcode(models.Model):
"Model for a few South Texas ZIP codes."
name = models.CharField(max_length=5)
poly = models.PolygonField(srid=32140, null=True)
objects = models.GeoManager()
def __unicode__(self): return self.name
class Interstate(models.Model):
"Geodetic model for U.S. Interstates."
name = models.CharField(max_length=10)
path = models.LineStringField()
objects = models.GeoManager()
def __unicode__(self): return self.name
class SouthTexasInterstate(models.Model):
"Projected model for South Texas Interstates."
name = models.CharField(max_length=10)
path = models.LineStringField(srid=32140)
objects = models.GeoManager()
def __unicode__(self): return self.name
| ajibawa-2023/Python-Code-Large/train/row_98685 | 50 | 50 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98685:ImportFrom_L1_C0", "label": "from django.contrib.gis.db import models", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.02, 0.02, 0, 0.66, 0.0, 964, 0, 1, 0, 0, 964, 0, 0], "semantic": {"name": "django.contrib.gis.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L3_C0", "label": "SouthTexasCity", "type": "class", "loc": [3, 8], "level": 0, "parent": null, "vector": [3, 0, 0.11, 0.12, 0, 0.66, 0.1429, 516, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "SouthTexasCity", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SouthTexasCity(models.Model):\n \"City model on projected coordinate system for South Texas.\"\n name = models.CharField(max_length=30)\n point = models.PointField(srid=32140)\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L4_C4", "label": "expression", "type": "expression", "loc": [4, 4], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L3_C0", "vector": [8, 1, 0.08, 0.02, 1, 0.24, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"City model on projected coordinate system for South Texas.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L5_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [5, 5], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L3_C0", "vector": [14, 1, 0.1, 0.02, 1, 0.24, 0.25, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L6_C4", "label": "point = PointField()", "type": "assigned_variable", "loc": [6, 6], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L3_C0", "vector": [14, 1, 0.12, 0.02, 1, 0.24, 0.5, 16, 3, 1, 0, 0, 260, 10, 1], "semantic": {"name": "point", "arg_names": [], "import_names": [], "rhs_call_name": "PointField", "annotation": ""}, "snippet": " point = models.PointField(srid=32140)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L7_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L3_C0", "vector": [14, 1, 0.14, 0.02, 1, 0.24, 0.75, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L8_C4", "label": "__unicode__", "type": "function", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L3_C0", "vector": [2, 1, 0.16, 0.02, 1, 0.24, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L8_C27", "label": "return", "type": "return", "loc": [8, 8], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L8_C4", "vector": [13, 2, 0.16, 0.02, 2, 0.08, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L10_C0", "label": "SouthTexasCityFt", "type": "class", "loc": [10, 15], "level": 0, "parent": null, "vector": [3, 0, 0.25, 0.12, 0, 0.66, 0.2857, 393, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "SouthTexasCityFt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SouthTexasCityFt(models.Model):\n \"Same City model as above, but U.S. survey feet are the units.\"\n name = models.CharField(max_length=30)\n point = models.PointField(srid=2278)\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L11_C4", "label": "expression", "type": "expression", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L10_C0", "vector": [8, 1, 0.22, 0.02, 1, 0.69, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Same City model as above, but U.S. survey feet are the units.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L12_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L10_C0", "vector": [14, 1, 0.24, 0.02, 1, 0.69, 0.25, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L13_C4", "label": "point = PointField()", "type": "assigned_variable", "loc": [13, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L10_C0", "vector": [14, 1, 0.26, 0.02, 1, 0.69, 0.5, 16, 3, 1, 0, 0, 260, 10, 1], "semantic": {"name": "point", "arg_names": [], "import_names": [], "rhs_call_name": "PointField", "annotation": ""}, "snippet": " point = models.PointField(srid=2278)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L14_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L10_C0", "vector": [14, 1, 0.28, 0.02, 1, 0.69, 0.75, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L15_C4", "label": "__unicode__", "type": "function", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L10_C0", "vector": [2, 1, 0.3, 0.02, 1, 0.69, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L15_C27", "label": "return", "type": "return", "loc": [15, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L15_C4", "vector": [13, 2, 0.3, 0.02, 2, 0.35, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L17_C0", "label": "AustraliaCity", "type": "class", "loc": [17, 22], "level": 0, "parent": null, "vector": [3, 0, 0.39, 0.12, 0, 0.66, 0.4286, 477, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "AustraliaCity", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class AustraliaCity(models.Model):\n \"City model for Australia, using WGS84.\"\n name = models.CharField(max_length=30)\n point = models.PointField()\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L18_C4", "label": "expression", "type": "expression", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L17_C0", "vector": [8, 1, 0.36, 0.02, 1, 0.61, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"City model for Australia, using WGS84.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L19_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L17_C0", "vector": [14, 1, 0.38, 0.02, 1, 0.61, 0.25, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L20_C4", "label": "point = PointField()", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L17_C0", "vector": [14, 1, 0.4, 0.02, 1, 0.61, 0.5, 16, 3, 0, 0, 0, 260, 10, 1], "semantic": {"name": "point", "arg_names": [], "import_names": [], "rhs_call_name": "PointField", "annotation": ""}, "snippet": " point = models.PointField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L21_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L17_C0", "vector": [14, 1, 0.42, 0.02, 1, 0.61, 0.75, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L22_C4", "label": "__unicode__", "type": "function", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L17_C0", "vector": [2, 1, 0.44, 0.02, 1, 0.61, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L22_C27", "label": "return", "type": "return", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L22_C4", "vector": [13, 2, 0.44, 0.02, 2, 0.94, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L24_C0", "label": "CensusZipcode", "type": "class", "loc": [24, 29], "level": 0, "parent": null, "vector": [3, 0, 0.53, 0.12, 0, 0.66, 0.5714, 616, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "CensusZipcode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CensusZipcode(models.Model):\n \"Model for a few South Texas ZIP codes (in original Census NAD83).\"\n name = models.CharField(max_length=5)\n poly = models.PolygonField(srid=4269)\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L25_C4", "label": "expression", "type": "expression", "loc": [25, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L24_C0", "vector": [8, 1, 0.5, 0.02, 1, 0.81, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Model for a few South Texas ZIP codes (in original Census NAD83).\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L26_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L24_C0", "vector": [14, 1, 0.52, 0.02, 1, 0.81, 0.25, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=5)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L27_C4", "label": "poly = PolygonField()", "type": "assigned_variable", "loc": [27, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L24_C0", "vector": [14, 1, 0.54, 0.02, 1, 0.81, 0.5, 365, 3, 1, 0, 0, 736, 10, 1], "semantic": {"name": "poly", "arg_names": [], "import_names": [], "rhs_call_name": "PolygonField", "annotation": ""}, "snippet": " poly = models.PolygonField(srid=4269)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L28_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [28, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L24_C0", "vector": [14, 1, 0.56, 0.02, 1, 0.81, 0.75, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L29_C4", "label": "__unicode__", "type": "function", "loc": [29, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L24_C0", "vector": [2, 1, 0.58, 0.02, 1, 0.81, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L29_C27", "label": "return", "type": "return", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L29_C4", "vector": [13, 2, 0.58, 0.02, 2, 0.88, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L31_C0", "label": "SouthTexasZipcode", "type": "class", "loc": [31, 36], "level": 0, "parent": null, "vector": [3, 0, 0.67, 0.12, 0, 0.66, 0.7143, 41, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "SouthTexasZipcode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SouthTexasZipcode(models.Model):\n \"Model for a few South Texas ZIP codes.\"\n name = models.CharField(max_length=5)\n poly = models.PolygonField(srid=32140, null=True)\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L32_C4", "label": "expression", "type": "expression", "loc": [32, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L31_C0", "vector": [8, 1, 0.64, 0.02, 1, 0.32, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Model for a few South Texas ZIP codes.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L33_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [33, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L31_C0", "vector": [14, 1, 0.66, 0.02, 1, 0.32, 0.25, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=5)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L34_C4", "label": "poly = PolygonField()", "type": "assigned_variable", "loc": [34, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L31_C0", "vector": [14, 1, 0.68, 0.02, 1, 0.32, 0.5, 365, 3, 2, 0, 0, 736, 10, 1], "semantic": {"name": "poly", "arg_names": [], "import_names": [], "rhs_call_name": "PolygonField", "annotation": ""}, "snippet": " poly = models.PolygonField(srid=32140, null=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L35_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [35, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L31_C0", "vector": [14, 1, 0.7, 0.02, 1, 0.32, 0.75, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L36_C4", "label": "__unicode__", "type": "function", "loc": [36, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L31_C0", "vector": [2, 1, 0.72, 0.02, 1, 0.32, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L36_C27", "label": "return", "type": "return", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L36_C4", "vector": [13, 2, 0.72, 0.02, 2, 0.59, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L38_C0", "label": "Interstate", "type": "class", "loc": [38, 43], "level": 0, "parent": null, "vector": [3, 0, 0.81, 0.12, 0, 0.66, 0.8571, 128, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "Interstate", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Interstate(models.Model):\n \"Geodetic model for U.S. Interstates.\"\n name = models.CharField(max_length=10)\n path = models.LineStringField()\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L39_C4", "label": "expression", "type": "expression", "loc": [39, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L38_C0", "vector": [8, 1, 0.78, 0.02, 1, 0.81, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Geodetic model for U.S. Interstates.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L40_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [40, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L38_C0", "vector": [14, 1, 0.8, 0.02, 1, 0.81, 0.25, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=10)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L41_C4", "label": "path = LineStringField()", "type": "assigned_variable", "loc": [41, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L38_C0", "vector": [14, 1, 0.82, 0.02, 1, 0.81, 0.5, 358, 3, 0, 0, 0, 237, 10, 1], "semantic": {"name": "path", "arg_names": [], "import_names": [], "rhs_call_name": "LineStringField", "annotation": ""}, "snippet": " path = models.LineStringField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L42_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [42, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L38_C0", "vector": [14, 1, 0.84, 0.02, 1, 0.81, 0.75, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L43_C4", "label": "__unicode__", "type": "function", "loc": [43, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L38_C0", "vector": [2, 1, 0.86, 0.02, 1, 0.81, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L43_C27", "label": "return", "type": "return", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L43_C4", "vector": [13, 2, 0.86, 0.02, 2, 0.28, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L45_C0", "label": "SouthTexasInterstate", "type": "class", "loc": [45, 50], "level": 0, "parent": null, "vector": [3, 0, 0.95, 0.12, 0, 0.66, 1.0, 299, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "SouthTexasInterstate", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SouthTexasInterstate(models.Model):\n \"Projected model for South Texas Interstates.\"\n name = models.CharField(max_length=10)\n path = models.LineStringField(srid=32140)\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L46_C4", "label": "expression", "type": "expression", "loc": [46, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L45_C0", "vector": [8, 1, 0.92, 0.02, 1, 0.98, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Projected model for South Texas Interstates.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L47_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [47, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L45_C0", "vector": [14, 1, 0.94, 0.02, 1, 0.98, 0.25, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=10)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L48_C4", "label": "path = LineStringField()", "type": "assigned_variable", "loc": [48, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L45_C0", "vector": [14, 1, 0.96, 0.02, 1, 0.98, 0.5, 358, 3, 1, 0, 0, 237, 10, 1], "semantic": {"name": "path", "arg_names": [], "import_names": [], "rhs_call_name": "LineStringField", "annotation": ""}, "snippet": " path = models.LineStringField(srid=32140)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L49_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [49, 49], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L45_C0", "vector": [14, 1, 0.98, 0.02, 1, 0.98, 0.75, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L50_C4", "label": "__unicode__", "type": "function", "loc": [50, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L45_C0", "vector": [2, 1, 1.0, 0.02, 1, 0.98, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L50_C27", "label": "return", "type": "return", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L50_C4", "vector": [13, 2, 1.0, 0.02, 2, 0.9, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L8_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L15_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L22_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L29_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L31_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L32_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L31_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L31_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L31_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L35_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L31_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L36_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L38_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L38_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L38_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L38_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L38_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L43_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Expr_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Assign_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:ClassDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98685:FunctionDef_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98685:Return_L50_C27"}] |
import os, unittest
from decimal import Decimal
from django.db import connection
from django.db.models import Q
from django.contrib.gis.gdal import DataSource
from django.contrib.gis.geos import GEOSGeometry, Point, LineString
from django.contrib.gis.measure import D # alias for Distance
from django.contrib.gis.tests.utils import oracle, postgis, spatialite, no_oracle, no_spatialite
from models import AustraliaCity, Interstate, SouthTexasInterstate, \
SouthTexasCity, SouthTexasCityFt, CensusZipcode, SouthTexasZipcode
from data import au_cities, interstates, stx_interstates, stx_cities, stx_zips
class DistanceTest(unittest.TestCase):
# A point we are testing distances with -- using a WGS84
# coordinate that'll be implicitly transormed to that to
# the coordinate system of the field, EPSG:32140 (Texas South Central
# w/units in meters)
stx_pnt = GEOSGeometry('POINT (-95.370401017314293 29.704867409475465)', 4326)
# Another one for Australia
au_pnt = GEOSGeometry('POINT (150.791 -34.4919)', 4326)
def get_names(self, qs):
cities = [c.name for c in qs]
cities.sort()
return cities
def test01_init(self):
"Initialization of distance models."
# Loading up the cities.
def load_cities(city_model, data_tup):
for name, x, y in data_tup:
city_model(name=name, point=Point(x, y, srid=4326)).save()
def load_interstates(imodel, data_tup):
for name, wkt in data_tup:
imodel(name=name, path=wkt).save()
load_cities(SouthTexasCity, stx_cities)
load_cities(SouthTexasCityFt, stx_cities)
load_cities(AustraliaCity, au_cities)
self.assertEqual(9, SouthTexasCity.objects.count())
self.assertEqual(9, SouthTexasCityFt.objects.count())
self.assertEqual(11, AustraliaCity.objects.count())
# Loading up the South Texas Zip Codes.
for name, wkt in stx_zips:
poly = GEOSGeometry(wkt, srid=4269)
SouthTexasZipcode(name=name, poly=poly).save()
CensusZipcode(name=name, poly=poly).save()
self.assertEqual(4, SouthTexasZipcode.objects.count())
self.assertEqual(4, CensusZipcode.objects.count())
# Loading up the Interstates.
load_interstates(Interstate, interstates)
load_interstates(SouthTexasInterstate, stx_interstates)
self.assertEqual(1, Interstate.objects.count())
self.assertEqual(1, SouthTexasInterstate.objects.count())
@no_spatialite
def test02_dwithin(self):
"Testing the `dwithin` lookup type."
# Distances -- all should be equal (except for the
# degree/meter pair in au_cities, that's somewhat
# approximate).
tx_dists = [(7000, 22965.83), D(km=7), D(mi=4.349)]
au_dists = [(0.5, 32000), D(km=32), D(mi=19.884)]
# Expected cities for Australia and Texas.
tx_cities = ['Downtown Houston', 'Southside Place']
au_cities = ['Mittagong', 'Shellharbour', 'Thirroul', 'Wollongong']
# Performing distance queries on two projected coordinate systems one
# with units in meters and the other in units of U.S. survey feet.
for dist in tx_dists:
if isinstance(dist, tuple): dist1, dist2 = dist
else: dist1 = dist2 = dist
qs1 = SouthTexasCity.objects.filter(point__dwithin=(self.stx_pnt, dist1))
qs2 = SouthTexasCityFt.objects.filter(point__dwithin=(self.stx_pnt, dist2))
for qs in qs1, qs2:
self.assertEqual(tx_cities, self.get_names(qs))
# Now performing the `dwithin` queries on a geodetic coordinate system.
for dist in au_dists:
if isinstance(dist, D) and not oracle: type_error = True
else: type_error = False
if isinstance(dist, tuple):
if oracle: dist = dist[1]
else: dist = dist[0]
# Creating the query set.
qs = AustraliaCity.objects.order_by('name')
if type_error:
# A ValueError should be raised on PostGIS when trying to pass
# Distance objects into a DWithin query using a geodetic field.
self.assertRaises(ValueError, AustraliaCity.objects.filter(point__dwithin=(self.au_pnt, dist)).count)
else:
self.assertEqual(au_cities, self.get_names(qs.filter(point__dwithin=(self.au_pnt, dist))))
def test03a_distance_method(self):
"Testing the `distance` GeoQuerySet method on projected coordinate systems."
# The point for La Grange, TX
lagrange = GEOSGeometry('POINT(-96.876369 29.905320)', 4326)
# Reference distances in feet and in meters. Got these values from
# using the provided raw SQL statements.
# SELECT ST_Distance(point, ST_Transform(ST_GeomFromText('POINT(-96.876369 29.905320)', 4326), 32140)) FROM distapp_southtexascity;
m_distances = [147075.069813, 139630.198056, 140888.552826,
138809.684197, 158309.246259, 212183.594374,
70870.188967, 165337.758878, 139196.085105]
# SELECT ST_Distance(point, ST_Transform(ST_GeomFromText('POINT(-96.876369 29.905320)', 4326), 2278)) FROM distapp_southtexascityft;
# Oracle 11 thinks this is not a projected coordinate system, so it's s
# not tested.
ft_distances = [482528.79154625, 458103.408123001, 462231.860397575,
455411.438904354, 519386.252102563, 696139.009211594,
232513.278304279, 542445.630586414, 456679.155883207]
# Testing using different variations of parameters and using models
# with different projected coordinate systems.
dist1 = SouthTexasCity.objects.distance(lagrange, field_name='point')
dist2 = SouthTexasCity.objects.distance(lagrange) # Using GEOSGeometry parameter
if spatialite or oracle:
dist_qs = [dist1, dist2]
else:
dist3 = SouthTexasCityFt.objects.distance(lagrange.ewkt) # Using EWKT string parameter.
dist4 = SouthTexasCityFt.objects.distance(lagrange)
dist_qs = [dist1, dist2, dist3, dist4]
# Original query done on PostGIS, have to adjust AlmostEqual tolerance
# for Oracle.
if oracle: tol = 2
else: tol = 5
# Ensuring expected distances are returned for each distance queryset.
for qs in dist_qs:
for i, c in enumerate(qs):
self.assertAlmostEqual(m_distances[i], c.distance.m, tol)
self.assertAlmostEqual(ft_distances[i], c.distance.survey_ft, tol)
@no_spatialite
def test03b_distance_method(self):
"Testing the `distance` GeoQuerySet method on geodetic coordnate systems."
if oracle: tol = 2
else: tol = 5
# Testing geodetic distance calculation with a non-point geometry
# (a LineString of Wollongong and Shellharbour coords).
ls = LineString( ( (150.902, -34.4245), (150.87, -34.5789) ) )
if oracle or connection.ops.geography:
# Reference query:
# SELECT ST_distance_sphere(point, ST_GeomFromText('LINESTRING(150.9020 -34.4245,150.8700 -34.5789)', 4326)) FROM distapp_australiacity ORDER BY name;
distances = [1120954.92533513, 140575.720018241, 640396.662906304,
60580.9693849269, 972807.955955075, 568451.8357838,
40435.4335201384, 0, 68272.3896586844, 12375.0643697706, 0]
qs = AustraliaCity.objects.distance(ls).order_by('name')
for city, distance in zip(qs, distances):
# Testing equivalence to within a meter.
self.assertAlmostEqual(distance, city.distance.m, 0)
else:
# PostGIS 1.4 and below is limited to disance queries only
# to/from point geometries, check for raising of ValueError.
self.assertRaises(ValueError, AustraliaCity.objects.distance, ls)
self.assertRaises(ValueError, AustraliaCity.objects.distance, ls.wkt)
# Got the reference distances using the raw SQL statements:
# SELECT ST_distance_spheroid(point, ST_GeomFromText('POINT(151.231341 -33.952685)', 4326), 'SPHEROID["WGS 84",6378137.0,298.257223563]') FROM distapp_australiacity WHERE (NOT (id = 11));
# SELECT ST_distance_sphere(point, ST_GeomFromText('POINT(151.231341 -33.952685)', 4326)) FROM distapp_australiacity WHERE (NOT (id = 11)); st_distance_sphere
if connection.ops.postgis and connection.ops.proj_version_tuple() >= (4, 7, 0):
# PROJ.4 versions 4.7+ have updated datums, and thus different
# distance values.
spheroid_distances = [60504.0628957201, 77023.9489850262, 49154.8867574404,
90847.4358768573, 217402.811919332, 709599.234564757,
640011.483550888, 7772.00667991925, 1047861.78619339,
1165126.55236034]
sphere_distances = [60580.9693849267, 77144.0435286473, 49199.4415344719,
90804.7533823494, 217713.384600405, 709134.127242793,
639828.157159169, 7786.82949717788, 1049204.06569028,
1162623.7238134]
else:
spheroid_distances = [60504.0628825298, 77023.948962654, 49154.8867507115,
90847.435881812, 217402.811862568, 709599.234619957,
640011.483583758, 7772.00667666425, 1047861.7859506,
1165126.55237647]
sphere_distances = [60580.7612632291, 77143.7785056615, 49199.2725132184,
90804.4414289463, 217712.63666124, 709131.691061906,
639825.959074112, 7786.80274606706, 1049200.46122281,
1162619.7297006]
# Testing with spheroid distances first.
hillsdale = AustraliaCity.objects.get(name='Hillsdale')
qs = AustraliaCity.objects.exclude(id=hillsdale.id).distance(hillsdale.point, spheroid=True)
for i, c in enumerate(qs):
self.assertAlmostEqual(spheroid_distances[i], c.distance.m, tol)
if postgis:
# PostGIS uses sphere-only distances by default, testing these as well.
qs = AustraliaCity.objects.exclude(id=hillsdale.id).distance(hillsdale.point)
for i, c in enumerate(qs):
self.assertAlmostEqual(sphere_distances[i], c.distance.m, tol)
@no_oracle # Oracle already handles geographic distance calculation.
def test03c_distance_method(self):
"Testing the `distance` GeoQuerySet method used with `transform` on a geographic field."
# Normally you can't compute distances from a geometry field
# that is not a PointField (on PostGIS 1.4 and below).
if not connection.ops.geography:
self.assertRaises(ValueError, CensusZipcode.objects.distance, self.stx_pnt)
# We'll be using a Polygon (created by buffering the centroid
# of 77005 to 100m) -- which aren't allowed in geographic distance
# queries normally, however our field has been transformed to
# a non-geographic system.
z = SouthTexasZipcode.objects.get(name='77005')
# Reference query:
# SELECT ST_Distance(ST_Transform("distapp_censuszipcode"."poly", 32140), ST_GeomFromText('<buffer_wkt>', 32140)) FROM "distapp_censuszipcode";
dists_m = [3553.30384972258, 1243.18391525602, 2186.15439472242]
# Having our buffer in the SRID of the transformation and of the field
# -- should get the same results. The first buffer has no need for
# transformation SQL because it is the same SRID as what was given
# to `transform()`. The second buffer will need to be transformed,
# however.
buf1 = z.poly.centroid.buffer(100)
buf2 = buf1.transform(4269, clone=True)
ref_zips = ['77002', '77025', '77401']
for buf in [buf1, buf2]:
qs = CensusZipcode.objects.exclude(name='77005').transform(32140).distance(buf)
self.assertEqual(ref_zips, self.get_names(qs))
for i, z in enumerate(qs):
self.assertAlmostEqual(z.distance.m, dists_m[i], 5)
def test04_distance_lookups(self):
"Testing the `distance_lt`, `distance_gt`, `distance_lte`, and `distance_gte` lookup types."
# Retrieving the cities within a 20km 'donut' w/a 7km radius 'hole'
# (thus, Houston and Southside place will be excluded as tested in
# the `test02_dwithin` above).
qs1 = SouthTexasCity.objects.filter(point__distance_gte=(self.stx_pnt, D(km=7))).filter(point__distance_lte=(self.stx_pnt, D(km=20)))
# Can't determine the units on SpatiaLite from PROJ.4 string, and
# Oracle 11 incorrectly thinks it is not projected.
if spatialite or oracle:
dist_qs = (qs1,)
else:
qs2 = SouthTexasCityFt.objects.filter(point__distance_gte=(self.stx_pnt, D(km=7))).filter(point__distance_lte=(self.stx_pnt, D(km=20)))
dist_qs = (qs1, qs2)
for qs in dist_qs:
cities = self.get_names(qs)
self.assertEqual(cities, ['Bellaire', 'Pearland', 'West University Place'])
# Doing a distance query using Polygons instead of a Point.
z = SouthTexasZipcode.objects.get(name='77005')
qs = SouthTexasZipcode.objects.exclude(name='77005').filter(poly__distance_lte=(z.poly, D(m=275)))
self.assertEqual(['77025', '77401'], self.get_names(qs))
# If we add a little more distance 77002 should be included.
qs = SouthTexasZipcode.objects.exclude(name='77005').filter(poly__distance_lte=(z.poly, D(m=300)))
self.assertEqual(['77002', '77025', '77401'], self.get_names(qs))
def test05_geodetic_distance_lookups(self):
"Testing distance lookups on geodetic coordinate systems."
# Line is from Canberra to Sydney. Query is for all other cities within
# a 100km of that line (which should exclude only Hobart & Adelaide).
line = GEOSGeometry('LINESTRING(144.9630 -37.8143,151.2607 -33.8870)', 4326)
dist_qs = AustraliaCity.objects.filter(point__distance_lte=(line, D(km=100)))
if oracle or connection.ops.geography:
# Oracle and PostGIS 1.5 can do distance lookups on arbitrary geometries.
self.assertEqual(9, dist_qs.count())
self.assertEqual(['Batemans Bay', 'Canberra', 'Hillsdale',
'Melbourne', 'Mittagong', 'Shellharbour',
'Sydney', 'Thirroul', 'Wollongong'],
self.get_names(dist_qs))
else:
# PostGIS 1.4 and below only allows geodetic distance queries (utilizing
# ST_Distance_Sphere/ST_Distance_Spheroid) from Points to PointFields
# on geometry columns.
self.assertRaises(ValueError, dist_qs.count)
# Ensured that a ValueError was raised, none of the rest of the test is
# support on this backend, so bail now.
if spatialite: return
# Too many params (4 in this case) should raise a ValueError.
self.assertRaises(ValueError, len,
AustraliaCity.objects.filter(point__distance_lte=('POINT(5 23)', D(km=100), 'spheroid', '4')))
# Not enough params should raise a ValueError.
self.assertRaises(ValueError, len,
AustraliaCity.objects.filter(point__distance_lte=('POINT(5 23)',)))
# Getting all cities w/in 550 miles of Hobart.
hobart = AustraliaCity.objects.get(name='Hobart')
qs = AustraliaCity.objects.exclude(name='Hobart').filter(point__distance_lte=(hobart.point, D(mi=550)))
cities = self.get_names(qs)
self.assertEqual(cities, ['Batemans Bay', 'Canberra', 'Melbourne'])
# Cities that are either really close or really far from Wollongong --
# and using different units of distance.
wollongong = AustraliaCity.objects.get(name='Wollongong')
d1, d2 = D(yd=19500), D(nm=400) # Yards (~17km) & Nautical miles.
# Normal geodetic distance lookup (uses `distance_sphere` on PostGIS.
gq1 = Q(point__distance_lte=(wollongong.point, d1))
gq2 = Q(point__distance_gte=(wollongong.point, d2))
qs1 = AustraliaCity.objects.exclude(name='Wollongong').filter(gq1 | gq2)
# Geodetic distance lookup but telling GeoDjango to use `distance_spheroid`
# instead (we should get the same results b/c accuracy variance won't matter
# in this test case).
if postgis:
gq3 = Q(point__distance_lte=(wollongong.point, d1, 'spheroid'))
gq4 = Q(point__distance_gte=(wollongong.point, d2, 'spheroid'))
qs2 = AustraliaCity.objects.exclude(name='Wollongong').filter(gq3 | gq4)
querysets = [qs1, qs2]
else:
querysets = [qs1]
for qs in querysets:
cities = self.get_names(qs)
self.assertEqual(cities, ['Adelaide', 'Hobart', 'Shellharbour', 'Thirroul'])
def test06_area(self):
"Testing the `area` GeoQuerySet method."
# Reference queries:
# SELECT ST_Area(poly) FROM distapp_southtexaszipcode;
area_sq_m = [5437908.90234375, 10183031.4389648, 11254471.0073242, 9881708.91772461]
# Tolerance has to be lower for Oracle and differences
# with GEOS 3.0.0RC4
tol = 2
for i, z in enumerate(SouthTexasZipcode.objects.area()):
self.assertAlmostEqual(area_sq_m[i], z.area.sq_m, tol)
def test07_length(self):
"Testing the `length` GeoQuerySet method."
# Reference query (should use `length_spheroid`).
# SELECT ST_length_spheroid(ST_GeomFromText('<wkt>', 4326) 'SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]]');
len_m1 = 473504.769553813
len_m2 = 4617.668
if spatialite:
# Does not support geodetic coordinate systems.
self.assertRaises(ValueError, Interstate.objects.length)
else:
qs = Interstate.objects.length()
if oracle: tol = 2
else: tol = 5
self.assertAlmostEqual(len_m1, qs[0].length.m, tol)
# Now doing length on a projected coordinate system.
i10 = SouthTexasInterstate.objects.length().get(name='I-10')
self.assertAlmostEqual(len_m2, i10.length.m, 2)
@no_spatialite
def test08_perimeter(self):
"Testing the `perimeter` GeoQuerySet method."
# Reference query:
# SELECT ST_Perimeter(distapp_southtexaszipcode.poly) FROM distapp_southtexaszipcode;
perim_m = [18404.3550889361, 15627.2108551001, 20632.5588368978, 17094.5996143697]
if oracle: tol = 2
else: tol = 7
for i, z in enumerate(SouthTexasZipcode.objects.perimeter()):
self.assertAlmostEqual(perim_m[i], z.perimeter.m, tol)
# Running on points; should return 0.
for i, c in enumerate(SouthTexasCity.objects.perimeter(model_att='perim')):
self.assertEqual(0, c.perim.m)
def test09_measurement_null_fields(self):
"Testing the measurement GeoQuerySet methods on fields with NULL values."
# Creating SouthTexasZipcode w/NULL value.
SouthTexasZipcode.objects.create(name='78212')
# Performing distance/area queries against the NULL PolygonField,
# and ensuring the result of the operations is None.
htown = SouthTexasCity.objects.get(name='Downtown Houston')
z = SouthTexasZipcode.objects.distance(htown.point).area().get(name='78212')
self.assertEqual(None, z.distance)
self.assertEqual(None, z.area)
def suite():
s = unittest.TestSuite()
s.addTest(unittest.makeSuite(DistanceTest))
return s
| ajibawa-2023/Python-Code-Large/train/row_98686 | 211 | 389 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Import_L1_C0", "label": "os import os, unittest", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0026, 0.0026, 0, 0.66, 0.0, 688, 0, 2, 0, 0, 688, 0, 0], "semantic": {"name": "os", "arg_names": [], "import_names": ["os", "unittest"], "rhs_call_name": "", "annotation": ""}, "snippet": "import os, unittest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:ImportFrom_L2_C0", "label": "from decimal import Decimal", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0051, 0.0026, 0, 0.66, 0.0909, 349, 0, 1, 0, 0, 349, 0, 0], "semantic": {"name": "decimal", "arg_names": [], "import_names": ["Decimal"], "rhs_call_name": "", "annotation": ""}, "snippet": "from decimal import Decimal"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:ImportFrom_L4_C0", "label": "from django.db import connection", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0103, 0.0026, 0, 0.66, 0.1818, 40, 0, 1, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["connection"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import connection"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:ImportFrom_L5_C0", "label": "from django.db.models import Q", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0129, 0.0026, 0, 0.66, 0.2727, 680, 0, 1, 0, 0, 680, 0, 0], "semantic": {"name": "django.db.models", "arg_names": [], "import_names": ["Q"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models import Q"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:ImportFrom_L6_C0", "label": "from django.contrib.gis.gdal import DataSource", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0154, 0.0026, 0, 0.66, 0.3636, 793, 0, 1, 0, 0, 793, 0, 0], "semantic": {"name": "django.contrib.gis.gdal", "arg_names": [], "import_names": ["DataSource"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.gdal import DataSource"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:ImportFrom_L7_C0", "label": "from django.contrib.gis.geos import GEOSGeometry, Point, LineString", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.018, 0.0026, 0, 0.66, 0.4545, 886, 0, 3, 0, 0, 886, 0, 0], "semantic": {"name": "django.contrib.gis.geos", "arg_names": [], "import_names": ["GEOSGeometry", "Point", "LineString"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.geos import GEOSGeometry, Point, LineString"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:ImportFrom_L8_C0", "label": "from django.contrib.gis.measure import D", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0206, 0.0026, 0, 0.66, 0.5455, 844, 0, 1, 0, 0, 844, 0, 0], "semantic": {"name": "django.contrib.gis.measure", "arg_names": [], "import_names": ["D"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.measure import D # alias for Distance"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:ImportFrom_L9_C0", "label": "from django.contrib.gis.tests.utils import oracle, postgis, spatialite\u2026", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0231, 0.0026, 0, 0.66, 0.6364, 185, 0, 5, 0, 0, 185, 0, 0], "semantic": {"name": "django.contrib.gis.tests.utils", "arg_names": [], "import_names": ["oracle", "postgis", "spatialite", "no_oracle", "no_spatialite"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.tests.utils import oracle, postgis, spatialite, no_oracle, no_spatialite"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:ImportFrom_L11_C0", "label": "from models import AustraliaCity, Interstate, SouthTexasInterstate\u2026", "type": "import", "loc": [11, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0296, 0.0051, 0, 0.66, 0.7273, 495, 0, 7, 0, 0, 495, 0, 0], "semantic": {"name": "models", "arg_names": [], "import_names": ["AustraliaCity", "Interstate", "SouthTexasInterstate", "SouthTexasCity", "SouthTexasCityFt", "CensusZipcode", "SouthTexasZipcode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from models import AustraliaCity, Interstate, SouthTexasInterstate, \\\n SouthTexasCity, SouthTexasCityFt, CensusZipcode, SouthTexasZipcode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:ImportFrom_L13_C0", "label": "from data import au_cities, interstates, stx_interstates\u2026", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0334, 0.0026, 0, 0.66, 0.8182, 929, 0, 5, 0, 0, 929, 0, 0], "semantic": {"name": "data", "arg_names": [], "import_names": ["au_cities", "interstates", "stx_interstates", "stx_cities", "stx_zips"], "rhs_call_name": "", "annotation": ""}, "snippet": "from data import au_cities, interstates, stx_interstates, stx_cities, stx_zips"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "label": "DistanceTest", "type": "class", "loc": [15, 384], "level": 0, "parent": null, "vector": [3, 0, 0.5129, 0.9512, 0, 0.66, 0.9091, 842, 0, 14, 0, 0, 878, 0, 99], "semantic": {"name": "DistanceTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DistanceTest(unittest.TestCase):\n\n # A point we are testing distances with -- using a WGS84\n # coordinate that'll be implicitly transormed to that to\n # the coordinate system of the field, EPSG:32140 (Texas South Central\n # w/units in meters)\n stx_pnt = GEOSGeometry('POINT (-95.370401017314293 29.704867409475465)', 4326)\n # Another one for Australia"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L21_C4", "label": "stx_pnt = GEOSGeometry()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [14, 1, 0.054, 0.0026, 1, 0.12, 0.0, 214, 3, 2, 0, 0, 958, 10, 1], "semantic": {"name": "stx_pnt", "arg_names": [], "import_names": [], "rhs_call_name": "GEOSGeometry", "annotation": ""}, "snippet": " stx_pnt = GEOSGeometry('POINT (-95.370401017314293 29.704867409475465)', 4326)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L23_C4", "label": "au_pnt = GEOSGeometry()", "type": "assigned_variable", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [14, 1, 0.0591, 0.0026, 1, 0.12, 0.0769, 21, 3, 2, 0, 0, 958, 10, 1], "semantic": {"name": "au_pnt", "arg_names": [], "import_names": [], "rhs_call_name": "GEOSGeometry", "annotation": ""}, "snippet": " au_pnt = GEOSGeometry('POINT (150.791 -34.4919)', 4326)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L25_C4", "label": "get_names", "type": "function", "loc": [25, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [2, 1, 0.0681, 0.0103, 1, 0.12, 0.1538, 21, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "get_names", "arg_names": ["self", "qs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_names(self, qs):\n cities = [c.name for c in qs]\n cities.sort()\n return cities"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L26_C8", "label": "cities =", "type": "assigned_variable", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L25_C4", "vector": [14, 2, 0.0668, 0.0026, 2, 0.62, 0.0, 884, 5, 0, 0, 0, 0, 0, 0], "semantic": {"name": "cities", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cities = [c.name for c in qs]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L27_C8", "label": "sort()", "type": "expression", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L25_C4", "vector": [8, 2, 0.0694, 0.0026, 2, 0.62, 0.5, 489, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "sort", "arg_names": [], "import_names": [], "rhs_call_name": "sort", "annotation": ""}, "snippet": " cities.sort()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Return_L28_C8", "label": "return", "type": "return", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L25_C4", "vector": [13, 2, 0.072, 0.0026, 2, 0.62, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return cities"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "label": "test01_init", "type": "function", "loc": [30, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [2, 1, 0.1195, 0.0874, 1, 0.12, 0.2308, 64, 0, 1, 0, 0, 0, 0, 29], "semantic": {"name": "test01_init", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test01_init(self):\n \"Initialization of distance models.\"\n\n # Loading up the cities.\n def load_cities(city_model, data_tup):\n for name, x, y in data_tup:\n city_model(name=name, point=Point(x, y, srid=4326)).save()\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L31_C8", "label": "expression", "type": "expression", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.0797, 0.0026, 2, 0.24, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Initialization of distance models.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L34_C8", "label": "load_cities", "type": "function", "loc": [34, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [2, 2, 0.09, 0.0077, 2, 0.24, 0.0667, 74, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "load_cities", "arg_names": ["city_model", "data_tup"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def load_cities(city_model, data_tup):\n for name, x, y in data_tup:\n city_model(name=name, point=Point(x, y, srid=4326)).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L35_C12", "label": "for name, x, y", "type": "for", "loc": [35, 36], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L34_C8", "vector": [6, 3, 0.0913, 0.0051, 3, 0.0, 0.0, 412, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "name, x, y", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name, x, y in data_tup:\n city_model(name=name, point=Point(x, y, srid=4326)).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L36_C16", "label": "save()", "type": "expression", "loc": [36, 36], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L35_C12", "vector": [8, 4, 0.0925, 0.0026, 4, 0.59, 0.0, 928, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " city_model(name=name, point=Point(x, y, srid=4326)).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L38_C8", "label": "load_interstates", "type": "function", "loc": [38, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [2, 2, 0.1003, 0.0077, 2, 0.24, 0.1333, 706, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "load_interstates", "arg_names": ["imodel", "data_tup"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def load_interstates(imodel, data_tup):\n for name, wkt in data_tup:\n imodel(name=name, path=wkt).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L39_C12", "label": "for name, wkt", "type": "for", "loc": [39, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L38_C8", "vector": [6, 3, 0.1015, 0.0051, 3, 0.64, 0.0, 457, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "name, wkt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name, wkt in data_tup:\n imodel(name=name, path=wkt).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L40_C16", "label": "save()", "type": "expression", "loc": [40, 40], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L39_C12", "vector": [8, 4, 0.1028, 0.0026, 4, 0.2, 0.0, 928, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " imodel(name=name, path=wkt).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L42_C8", "label": "load_cities()", "type": "expression", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.108, 0.0026, 2, 0.24, 0.2, 74, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "load_cities", "arg_names": [], "import_names": [], "rhs_call_name": "load_cities", "annotation": ""}, "snippet": " load_cities(SouthTexasCity, stx_cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L43_C8", "label": "load_cities()", "type": "expression", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.1105, 0.0026, 2, 0.24, 0.2667, 74, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "load_cities", "arg_names": [], "import_names": [], "rhs_call_name": "load_cities", "annotation": ""}, "snippet": " load_cities(SouthTexasCityFt, stx_cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L44_C8", "label": "load_cities()", "type": "expression", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.1131, 0.0026, 2, 0.24, 0.3333, 74, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "load_cities", "arg_names": [], "import_names": [], "rhs_call_name": "load_cities", "annotation": ""}, "snippet": " load_cities(AustraliaCity, au_cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L46_C8", "label": "assertEqual()", "type": "expression", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.1183, 0.0026, 2, 0.24, 0.4, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(9, SouthTexasCity.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L47_C8", "label": "assertEqual()", "type": "expression", "loc": [47, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.1208, 0.0026, 2, 0.24, 0.4667, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(9, SouthTexasCityFt.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L48_C8", "label": "assertEqual()", "type": "expression", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.1234, 0.0026, 2, 0.24, 0.5333, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(11, AustraliaCity.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L51_C8", "label": "for name, wkt", "type": "for", "loc": [51, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [6, 2, 0.135, 0.0103, 2, 0.24, 0.6, 457, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "name, wkt", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name, wkt in stx_zips:\n poly = GEOSGeometry(wkt, srid=4269)\n SouthTexasZipcode(name=name, poly=poly).save()\n CensusZipcode(name=name, poly=poly).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L52_C12", "label": "poly = GEOSGeometry()", "type": "assigned_variable", "loc": [52, 52], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L51_C8", "vector": [14, 3, 0.1337, 0.0026, 3, 0.38, 0.0, 365, 3, 2, 0, 0, 958, 10, 1], "semantic": {"name": "poly", "arg_names": [], "import_names": [], "rhs_call_name": "GEOSGeometry", "annotation": ""}, "snippet": " poly = GEOSGeometry(wkt, srid=4269)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L53_C12", "label": "save()", "type": "expression", "loc": [53, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L51_C8", "vector": [8, 3, 0.1362, 0.0026, 3, 0.38, 0.5, 928, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " SouthTexasZipcode(name=name, poly=poly).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L54_C12", "label": "save()", "type": "expression", "loc": [54, 54], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L51_C8", "vector": [8, 3, 0.1388, 0.0026, 3, 0.38, 1.0, 928, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " CensusZipcode(name=name, poly=poly).save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L55_C8", "label": "assertEqual()", "type": "expression", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.1414, 0.0026, 2, 0.24, 0.6667, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(4, SouthTexasZipcode.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L56_C8", "label": "assertEqual()", "type": "expression", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.144, 0.0026, 2, 0.24, 0.7333, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(4, CensusZipcode.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L59_C8", "label": "load_interstates()", "type": "expression", "loc": [59, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.1517, 0.0026, 2, 0.24, 0.8, 706, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "load_interstates", "arg_names": [], "import_names": [], "rhs_call_name": "load_interstates", "annotation": ""}, "snippet": " load_interstates(Interstate, interstates)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L60_C8", "label": "load_interstates()", "type": "expression", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.1542, 0.0026, 2, 0.24, 0.8667, 706, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "load_interstates", "arg_names": [], "import_names": [], "rhs_call_name": "load_interstates", "annotation": ""}, "snippet": " load_interstates(SouthTexasInterstate, stx_interstates)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L62_C8", "label": "assertEqual()", "type": "expression", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.1594, 0.0026, 2, 0.24, 0.9333, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(1, Interstate.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L63_C8", "label": "assertEqual()", "type": "expression", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "vector": [8, 2, 0.162, 0.0026, 2, 0.24, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(1, SouthTexasInterstate.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "label": "test02_dwithin", "type": "function", "loc": [66, 104], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [2, 1, 0.2185, 0.1003, 1, 0.12, 0.3077, 763, 0, 1, 0, 0, 0, 0, 17], "semantic": {"name": "test02_dwithin", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test02_dwithin(self):\n \"Testing the `dwithin` lookup type.\"\n # Distances -- all should be equal (except for the\n # degree/meter pair in au_cities, that's somewhat\n # approximate).\n tx_dists = [(7000, 22965.83), D(km=7), D(mi=4.349)]\n au_dists = [(0.5, 32000), D(km=32), D(mi=19.884)]\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L67_C8", "label": "expression", "type": "expression", "loc": [67, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "vector": [8, 2, 0.1722, 0.0026, 2, 0.47, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `dwithin` lookup type.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L71_C8", "label": "tx_dists =", "type": "assigned_variable", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "vector": [14, 2, 0.1825, 0.0026, 2, 0.47, 0.1667, 88, 0, 0, 0, 0, 0, 5, 2], "semantic": {"name": "tx_dists", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tx_dists = [(7000, 22965.83), D(km=7), D(mi=4.349)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L72_C8", "label": "au_dists =", "type": "assigned_variable", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "vector": [14, 2, 0.1851, 0.0026, 2, 0.47, 0.3333, 898, 0, 0, 0, 0, 0, 5, 2], "semantic": {"name": "au_dists", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " au_dists = [(0.5, 32000), D(km=32), D(mi=19.884)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L75_C8", "label": "tx_cities =", "type": "assigned_variable", "loc": [75, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "vector": [14, 2, 0.1928, 0.0026, 2, 0.47, 0.5, 324, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "tx_cities", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tx_cities = ['Downtown Houston', 'Southside Place']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L76_C8", "label": "au_cities =", "type": "assigned_variable", "loc": [76, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "vector": [14, 2, 0.1954, 0.0026, 2, 0.47, 0.6667, 425, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "au_cities", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " au_cities = ['Mittagong', 'Shellharbour', 'Thirroul', 'Wollongong']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L80_C8", "label": "for dist", "type": "for", "loc": [80, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "vector": [6, 2, 0.2134, 0.018, 2, 0.47, 0.8333, 673, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "dist", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for dist in tx_dists:\n if isinstance(dist, tuple): dist1, dist2 = dist\n else: dist1 = dist2 = dist\n qs1 = SouthTexasCity.objects.filter(point__dwithin=(self.stx_pnt, dist1))\n qs2 = SouthTexasCityFt.objects.filter(point__dwithin=(self.stx_pnt, dist2))\n for qs in qs1, qs2:\n self.assertEqual(tx_cities, self.get_names(qs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L81_C12", "label": "if", "type": "if", "loc": [81, 82], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L80_C8", "vector": [4, 3, 0.2095, 0.0051, 3, 0.66, 0.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(dist, tuple): dist1, dist2 = dist\n else: dist1 = dist2 = dist"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L81_C40", "label": "dist1, dist2 =", "type": "assigned_variable", "loc": [81, 81], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L81_C12", "vector": [14, 4, 0.2082, 0.0026, 4, 0.33, 0.0, 684, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "dist1, dist2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(dist, tuple): dist1, dist2 = dist"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L82_C18", "label": "dist1 =", "type": "assigned_variable", "loc": [82, 82], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L81_C12", "vector": [14, 4, 0.2108, 0.0026, 4, 0.33, 1.0, 119, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "dist1", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " else: dist1 = dist2 = dist"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L83_C12", "label": "qs1 = filter()", "type": "assigned_variable", "loc": [83, 83], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L80_C8", "vector": [14, 3, 0.2134, 0.0026, 3, 0.66, 0.3333, 811, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs1", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs1 = SouthTexasCity.objects.filter(point__dwithin=(self.stx_pnt, dist1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L84_C12", "label": "qs2 = filter()", "type": "assigned_variable", "loc": [84, 84], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L80_C8", "vector": [14, 3, 0.2159, 0.0026, 3, 0.66, 0.6667, 595, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs2", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs2 = SouthTexasCityFt.objects.filter(point__dwithin=(self.stx_pnt, dist2))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L85_C12", "label": "for qs", "type": "for", "loc": [85, 86], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L80_C8", "vector": [6, 3, 0.2198, 0.0051, 3, 0.66, 1.0, 251, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for qs in qs1, qs2:\n self.assertEqual(tx_cities, self.get_names(qs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L86_C16", "label": "assertEqual()", "type": "expression", "loc": [86, 86], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L85_C12", "vector": [8, 4, 0.2211, 0.0026, 4, 0.22, 0.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(tx_cities, self.get_names(qs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L89_C8", "label": "for dist", "type": "for", "loc": [89, 104], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "vector": [6, 2, 0.2481, 0.0411, 2, 0.47, 1.0, 673, 2, 0, 0, 0, 0, 0, 8], "semantic": {"name": "dist", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for dist in au_dists:\n if isinstance(dist, D) and not oracle: type_error = True\n else: type_error = False\n\n if isinstance(dist, tuple):\n if oracle: dist = dist[1]\n else: dist = dist[0]\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L90_C12", "label": "if", "type": "if", "loc": [90, 91], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L89_C8", "vector": [4, 3, 0.2326, 0.0051, 3, 0.4, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(dist, D) and not oracle: type_error = True\n else: type_error = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L90_C51", "label": "type_error =", "type": "assigned_variable", "loc": [90, 90], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L90_C12", "vector": [14, 4, 0.2314, 0.0026, 4, 0.53, 0.0, 490, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "type_error", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(dist, D) and not oracle: type_error = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L91_C18", "label": "type_error =", "type": "assigned_variable", "loc": [91, 91], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L90_C12", "vector": [14, 4, 0.2339, 0.0026, 4, 0.53, 1.0, 490, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "type_error", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " else: type_error = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L93_C12", "label": "if", "type": "if", "loc": [93, 95], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L89_C8", "vector": [4, 3, 0.2416, 0.0077, 3, 0.4, 0.3333, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(dist, tuple):\n if oracle: dist = dist[1]\n else: dist = dist[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L94_C16", "label": "if", "type": "if", "loc": [94, 95], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L93_C12", "vector": [4, 4, 0.2429, 0.0051, 4, 0.54, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle: dist = dist[1]\n else: dist = dist[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L94_C27", "label": "dist =", "type": "assigned_variable", "loc": [94, 94], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L94_C16", "vector": [14, 5, 0.2416, 0.0026, 5, 0.95, 0.0, 673, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "dist", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle: dist = dist[1]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L95_C22", "label": "dist =", "type": "assigned_variable", "loc": [95, 95], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L94_C16", "vector": [14, 5, 0.2442, 0.0026, 5, 0.95, 1.0, 673, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "dist", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " else: dist = dist[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L98_C12", "label": "qs = order_by()", "type": "assigned_variable", "loc": [98, 98], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L89_C8", "vector": [14, 3, 0.2519, 0.0026, 3, 0.4, 0.6667, 251, 3, 1, 0, 0, 23, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "order_by", "annotation": ""}, "snippet": " qs = AustraliaCity.objects.order_by('name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L99_C12", "label": "if", "type": "if", "loc": [99, 104], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L89_C8", "vector": [4, 3, 0.2609, 0.0154, 3, 0.4, 1.0, 0, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if type_error:\n # A ValueError should be raised on PostGIS when trying to pass\n # Distance objects into a DWithin query using a geodetic field.\n self.assertRaises(ValueError, AustraliaCity.objects.filter(point__dwithin=(self.au_pnt, dist)).count)\n else:\n self.assertEqual(au_cities, self.get_names(qs.filter(point__dwithin=(self.au_pnt, dist))))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L102_C16", "label": "assertRaises()", "type": "expression", "loc": [102, 102], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L99_C12", "vector": [8, 4, 0.2622, 0.0026, 4, 0.67, 0.0, 11, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, AustraliaCity.objects.filter(point__dwithin=(self.au_pnt, dist)).count)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L104_C16", "label": "assertEqual()", "type": "expression", "loc": [104, 104], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L99_C12", "vector": [8, 4, 0.2674, 0.0026, 4, 0.67, 1.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(au_cities, self.get_names(qs.filter(point__dwithin=(self.au_pnt, dist))))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "label": "test03a_distance_method", "type": "function", "loc": [106, 143], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [2, 1, 0.3201, 0.0977, 1, 0.12, 0.3846, 270, 0, 1, 0, 0, 0, 0, 8], "semantic": {"name": "test03a_distance_method", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test03a_distance_method(self):\n \"Testing the `distance` GeoQuerySet method on projected coordinate systems.\"\n # The point for La Grange, TX\n lagrange = GEOSGeometry('POINT(-96.876369 29.905320)', 4326)\n # Reference distances in feet and in meters. Got these values from\n # using the provided raw SQL statements.\n # SELECT ST_Distance(point, ST_Transform(ST_GeomFromText('POINT(-96.876369 29.905320)', 4326), 32140)) FROM distapp_southtexascity;\n m_distances = [147075.069813, 139630.198056, 140888.552826,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L107_C8", "label": "expression", "type": "expression", "loc": [107, 107], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "vector": [8, 2, 0.2751, 0.0026, 2, 0.11, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `distance` GeoQuerySet method on projected coordinate systems.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L109_C8", "label": "lagrange = GEOSGeometry()", "type": "assigned_variable", "loc": [109, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "vector": [14, 2, 0.2802, 0.0026, 2, 0.11, 0.125, 377, 3, 2, 0, 0, 958, 10, 1], "semantic": {"name": "lagrange", "arg_names": [], "import_names": [], "rhs_call_name": "GEOSGeometry", "annotation": ""}, "snippet": " lagrange = GEOSGeometry('POINT(-96.876369 29.905320)', 4326)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L113_C8", "label": "m_distances =", "type": "assigned_variable", "loc": [113, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "vector": [14, 2, 0.2931, 0.0077, 2, 0.11, 0.25, 536, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "m_distances", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " m_distances = [147075.069813, 139630.198056, 140888.552826,\n 138809.684197, 158309.246259, 212183.594374,\n 70870.188967, 165337.758878, 139196.085105]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L119_C8", "label": "ft_distances =", "type": "assigned_variable", "loc": [119, 121], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "vector": [14, 2, 0.3085, 0.0077, 2, 0.11, 0.375, 167, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "ft_distances", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ft_distances = [482528.79154625, 458103.408123001, 462231.860397575,\n 455411.438904354, 519386.252102563, 696139.009211594,\n 232513.278304279, 542445.630586414, 456679.155883207]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L125_C8", "label": "dist1 = distance()", "type": "assigned_variable", "loc": [125, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "vector": [14, 2, 0.3213, 0.0026, 2, 0.11, 0.5, 119, 3, 2, 0, 0, 145, 10, 1], "semantic": {"name": "dist1", "arg_names": [], "import_names": [], "rhs_call_name": "distance", "annotation": ""}, "snippet": " dist1 = SouthTexasCity.objects.distance(lagrange, field_name='point')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L126_C8", "label": "dist2 = distance()", "type": "assigned_variable", "loc": [126, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "vector": [14, 2, 0.3239, 0.0026, 2, 0.11, 0.625, 533, 3, 1, 0, 0, 145, 10, 1], "semantic": {"name": "dist2", "arg_names": [], "import_names": [], "rhs_call_name": "distance", "annotation": ""}, "snippet": " dist2 = SouthTexasCity.objects.distance(lagrange) # Using GEOSGeometry parameter"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L127_C8", "label": "if", "type": "if", "loc": [127, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "vector": [4, 2, 0.3329, 0.0154, 2, 0.11, 0.75, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if spatialite or oracle:\n dist_qs = [dist1, dist2]\n else:\n dist3 = SouthTexasCityFt.objects.distance(lagrange.ewkt) # Using EWKT string parameter.\n dist4 = SouthTexasCityFt.objects.distance(lagrange)\n dist_qs = [dist1, dist2, dist3, dist4]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L128_C12", "label": "dist_qs =", "type": "assigned_variable", "loc": [128, 128], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L127_C8", "vector": [14, 3, 0.329, 0.0026, 3, 0.92, 0.0, 536, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "dist_qs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " dist_qs = [dist1, dist2]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L130_C12", "label": "dist3 = distance()", "type": "assigned_variable", "loc": [130, 130], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L127_C8", "vector": [14, 3, 0.3342, 0.0026, 3, 0.92, 0.3333, 659, 3, 1, 0, 0, 145, 10, 1], "semantic": {"name": "dist3", "arg_names": [], "import_names": [], "rhs_call_name": "distance", "annotation": ""}, "snippet": " dist3 = SouthTexasCityFt.objects.distance(lagrange.ewkt) # Using EWKT string parameter."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L131_C12", "label": "dist4 = distance()", "type": "assigned_variable", "loc": [131, 131], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L127_C8", "vector": [14, 3, 0.3368, 0.0026, 3, 0.92, 0.6667, 225, 3, 1, 0, 0, 145, 10, 1], "semantic": {"name": "dist4", "arg_names": [], "import_names": [], "rhs_call_name": "distance", "annotation": ""}, "snippet": " dist4 = SouthTexasCityFt.objects.distance(lagrange)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L132_C12", "label": "dist_qs =", "type": "assigned_variable", "loc": [132, 132], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L127_C8", "vector": [14, 3, 0.3393, 0.0026, 3, 0.92, 1.0, 536, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "dist_qs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " dist_qs = [dist1, dist2, dist3, dist4]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L136_C8", "label": "if", "type": "if", "loc": [136, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "vector": [4, 2, 0.3509, 0.0051, 2, 0.11, 0.875, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle: tol = 2\n else: tol = 5"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L136_C19", "label": "tol =", "type": "assigned_variable", "loc": [136, 136], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L136_C8", "vector": [14, 3, 0.3496, 0.0026, 3, 0.52, 0.0, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle: tol = 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L137_C14", "label": "tol =", "type": "assigned_variable", "loc": [137, 137], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L136_C8", "vector": [14, 3, 0.3522, 0.0026, 3, 0.52, 1.0, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " else: tol = 5"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L140_C8", "label": "for qs", "type": "for", "loc": [140, 143], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "vector": [6, 2, 0.3638, 0.0103, 2, 0.11, 1.0, 251, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for qs in dist_qs:\n for i, c in enumerate(qs):\n self.assertAlmostEqual(m_distances[i], c.distance.m, tol)\n self.assertAlmostEqual(ft_distances[i], c.distance.survey_ft, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L141_C12", "label": "for i, c", "type": "for", "loc": [141, 143], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L140_C8", "vector": [6, 3, 0.365, 0.0077, 3, 0.84, 0.0, 787, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "i, c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, c in enumerate(qs):\n self.assertAlmostEqual(m_distances[i], c.distance.m, tol)\n self.assertAlmostEqual(ft_distances[i], c.distance.survey_ft, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L142_C16", "label": "assertAlmostEqual()", "type": "expression", "loc": [142, 142], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L141_C12", "vector": [8, 4, 0.365, 0.0026, 4, 0.31, 0.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(m_distances[i], c.distance.m, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L143_C16", "label": "assertAlmostEqual()", "type": "expression", "loc": [143, 143], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L141_C12", "vector": [8, 4, 0.3676, 0.0026, 4, 0.31, 1.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(ft_distances[i], c.distance.survey_ft, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "label": "test03b_distance_method", "type": "function", "loc": [146, 204], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [2, 1, 0.4499, 0.1517, 1, 0.12, 0.4615, 496, 0, 1, 0, 0, 0, 0, 17], "semantic": {"name": "test03b_distance_method", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test03b_distance_method(self):\n \"Testing the `distance` GeoQuerySet method on geodetic coordnate systems.\"\n if oracle: tol = 2\n else: tol = 5\n\n # Testing geodetic distance calculation with a non-point geometry\n # (a LineString of Wollongong and Shellharbour coords).\n ls = LineString( ( (150.902, -34.4245), (150.87, -34.5789) ) )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L147_C8", "label": "expression", "type": "expression", "loc": [147, 147], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "vector": [8, 2, 0.3779, 0.0026, 2, 0.32, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `distance` GeoQuerySet method on geodetic coordnate systems.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L148_C8", "label": "if", "type": "if", "loc": [148, 149], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "vector": [4, 2, 0.3817, 0.0051, 2, 0.32, 0.125, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle: tol = 2\n else: tol = 5"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L148_C19", "label": "tol =", "type": "assigned_variable", "loc": [148, 148], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L148_C8", "vector": [14, 3, 0.3805, 0.0026, 3, 0.28, 0.0, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle: tol = 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L149_C14", "label": "tol =", "type": "assigned_variable", "loc": [149, 149], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L148_C8", "vector": [14, 3, 0.383, 0.0026, 3, 0.28, 1.0, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " else: tol = 5"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L153_C8", "label": "ls = LineString()", "type": "assigned_variable", "loc": [153, 153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "vector": [14, 2, 0.3933, 0.0026, 2, 0.32, 0.25, 174, 3, 1, 0, 0, 440, 10, 1], "semantic": {"name": "ls", "arg_names": [], "import_names": [], "rhs_call_name": "LineString", "annotation": ""}, "snippet": " ls = LineString( ( (150.902, -34.4245), (150.87, -34.5789) ) )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L154_C8", "label": "if", "type": "if", "loc": [154, 168], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "vector": [4, 2, 0.4139, 0.0386, 2, 0.32, 0.375, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle or connection.ops.geography:\n # Reference query:\n # SELECT ST_distance_sphere(point, ST_GeomFromText('LINESTRING(150.9020 -34.4245,150.8700 -34.5789)', 4326)) FROM distapp_australiacity ORDER BY name;\n distances = [1120954.92533513, 140575.720018241, 640396.662906304,\n 60580.9693849269, 972807.955955075, 568451.8357838,\n 40435.4335201384, 0, 68272.3896586844, 12375.0643697706, 0]\n qs = AustraliaCity.objects.distance(ls).order_by('name')\n for city, distance in zip(qs, distances):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L157_C12", "label": "distances =", "type": "assigned_variable", "loc": [157, 159], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L154_C8", "vector": [14, 3, 0.4062, 0.0077, 3, 0.23, 0.0, 28, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "distances", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " distances = [1120954.92533513, 140575.720018241, 640396.662906304,\n 60580.9693849269, 972807.955955075, 568451.8357838,\n 40435.4335201384, 0, 68272.3896586844, 12375.0643697706, 0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L160_C12", "label": "qs = order_by()", "type": "assigned_variable", "loc": [160, 160], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L154_C8", "vector": [14, 3, 0.4113, 0.0026, 3, 0.23, 0.25, 251, 3, 1, 0, 0, 23, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "order_by", "annotation": ""}, "snippet": " qs = AustraliaCity.objects.distance(ls).order_by('name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L161_C12", "label": "for city, distance", "type": "for", "loc": [161, 163], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L154_C8", "vector": [6, 3, 0.4165, 0.0077, 3, 0.23, 0.5, 160, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "city, distance", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for city, distance in zip(qs, distances):\n # Testing equivalence to within a meter.\n self.assertAlmostEqual(distance, city.distance.m, 0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L163_C16", "label": "assertAlmostEqual()", "type": "expression", "loc": [163, 163], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L161_C12", "vector": [8, 4, 0.419, 0.0026, 4, 0.88, 0.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(distance, city.distance.m, 0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L167_C12", "label": "assertRaises()", "type": "expression", "loc": [167, 167], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L154_C8", "vector": [8, 3, 0.4293, 0.0026, 3, 0.23, 0.75, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, AustraliaCity.objects.distance, ls)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L168_C12", "label": "assertRaises()", "type": "expression", "loc": [168, 168], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L154_C8", "vector": [8, 3, 0.4319, 0.0026, 3, 0.23, 1.0, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, AustraliaCity.objects.distance, ls.wkt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L173_C8", "label": "if", "type": "if", "loc": [173, 193], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "vector": [4, 2, 0.4704, 0.054, 2, 0.32, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if connection.ops.postgis and connection.ops.proj_version_tuple() >= (4, 7, 0):\n # PROJ.4 versions 4.7+ have updated datums, and thus different\n # distance values.\n spheroid_distances = [60504.0628957201, 77023.9489850262, 49154.8867574404,\n 90847.4358768573, 217402.811919332, 709599.234564757,\n 640011.483550888, 7772.00667991925, 1047861.78619339,\n 1165126.55236034]\n sphere_distances = [60580.9693849267, 77144.0435286473, 49199.4415344719,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L176_C12", "label": "spheroid_distances =", "type": "assigned_variable", "loc": [176, 179], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L173_C8", "vector": [14, 3, 0.4563, 0.0103, 3, 0.12, 0.0, 472, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "spheroid_distances", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " spheroid_distances = [60504.0628957201, 77023.9489850262, 49154.8867574404,\n 90847.4358768573, 217402.811919332, 709599.234564757,\n 640011.483550888, 7772.00667991925, 1047861.78619339,\n 1165126.55236034]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L180_C12", "label": "sphere_distances =", "type": "assigned_variable", "loc": [180, 183], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L173_C8", "vector": [14, 3, 0.4666, 0.0103, 3, 0.12, 0.3333, 162, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "sphere_distances", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " sphere_distances = [60580.9693849267, 77144.0435286473, 49199.4415344719,\n 90804.7533823494, 217713.384600405, 709134.127242793,\n 639828.157159169, 7786.82949717788, 1049204.06569028,\n 1162623.7238134]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L186_C12", "label": "spheroid_distances =", "type": "assigned_variable", "loc": [186, 189], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L173_C8", "vector": [14, 3, 0.482, 0.0103, 3, 0.12, 0.6667, 472, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "spheroid_distances", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " spheroid_distances = [60504.0628825298, 77023.948962654, 49154.8867507115,\n 90847.435881812, 217402.811862568, 709599.234619957,\n 640011.483583758, 7772.00667666425, 1047861.7859506,\n 1165126.55237647]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L190_C12", "label": "sphere_distances =", "type": "assigned_variable", "loc": [190, 193], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L173_C8", "vector": [14, 3, 0.4923, 0.0103, 3, 0.12, 1.0, 162, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "sphere_distances", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " sphere_distances = [60580.7612632291, 77143.7785056615, 49199.2725132184,\n 90804.4414289463, 217712.63666124, 709131.691061906,\n 639825.959074112, 7786.80274606706, 1049200.46122281,\n 1162619.7297006]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L196_C8", "label": "hillsdale = get()", "type": "assigned_variable", "loc": [196, 196], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "vector": [14, 2, 0.5039, 0.0026, 2, 0.32, 0.625, 381, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "hillsdale", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " hillsdale = AustraliaCity.objects.get(name='Hillsdale')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L197_C8", "label": "qs = distance()", "type": "assigned_variable", "loc": [197, 197], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "vector": [14, 2, 0.5064, 0.0026, 2, 0.32, 0.75, 251, 3, 2, 0, 0, 145, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "distance", "annotation": ""}, "snippet": " qs = AustraliaCity.objects.exclude(id=hillsdale.id).distance(hillsdale.point, spheroid=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L198_C8", "label": "for i, c", "type": "for", "loc": [198, 199], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "vector": [6, 2, 0.5103, 0.0051, 2, 0.32, 0.875, 787, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "i, c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, c in enumerate(qs):\n self.assertAlmostEqual(spheroid_distances[i], c.distance.m, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L199_C12", "label": "assertAlmostEqual()", "type": "expression", "loc": [199, 199], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L198_C8", "vector": [8, 3, 0.5116, 0.0026, 3, 0.53, 0.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(spheroid_distances[i], c.distance.m, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L200_C8", "label": "if", "type": "if", "loc": [200, 204], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "vector": [4, 2, 0.5193, 0.0129, 2, 0.32, 1.0, 0, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if postgis:\n # PostGIS uses sphere-only distances by default, testing these as well.\n qs = AustraliaCity.objects.exclude(id=hillsdale.id).distance(hillsdale.point)\n for i, c in enumerate(qs):\n self.assertAlmostEqual(sphere_distances[i], c.distance.m, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L202_C12", "label": "qs = distance()", "type": "assigned_variable", "loc": [202, 202], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L200_C8", "vector": [14, 3, 0.5193, 0.0026, 3, 0.18, 0.0, 251, 3, 1, 0, 0, 145, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "distance", "annotation": ""}, "snippet": " qs = AustraliaCity.objects.exclude(id=hillsdale.id).distance(hillsdale.point)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L203_C12", "label": "for i, c", "type": "for", "loc": [203, 204], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L200_C8", "vector": [6, 3, 0.5231, 0.0051, 3, 0.18, 1.0, 787, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "i, c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, c in enumerate(qs):\n self.assertAlmostEqual(sphere_distances[i], c.distance.m, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L204_C16", "label": "assertAlmostEqual()", "type": "expression", "loc": [204, 204], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L203_C12", "vector": [8, 4, 0.5244, 0.0026, 4, 0.53, 0.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(sphere_distances[i], c.distance.m, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "label": "test03c_distance_method", "type": "function", "loc": [207, 237], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [2, 1, 0.5707, 0.0797, 1, 0.12, 0.5385, 348, 0, 1, 0, 0, 0, 0, 11], "semantic": {"name": "test03c_distance_method", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test03c_distance_method(self):\n \"Testing the `distance` GeoQuerySet method used with `transform` on a geographic field.\"\n # Normally you can't compute distances from a geometry field\n # that is not a PointField (on PostGIS 1.4 and below).\n if not connection.ops.geography:\n self.assertRaises(ValueError, CensusZipcode.objects.distance, self.stx_pnt)\n\n # We'll be using a Polygon (created by buffering the centroid"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L208_C8", "label": "expression", "type": "expression", "loc": [208, 208], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "vector": [8, 2, 0.5347, 0.0026, 2, 0.58, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `distance` GeoQuerySet method used with `transform` on a geographic field.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L211_C8", "label": "if", "type": "if", "loc": [211, 212], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "vector": [4, 2, 0.5437, 0.0051, 2, 0.58, 0.1429, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not connection.ops.geography:\n self.assertRaises(ValueError, CensusZipcode.objects.distance, self.stx_pnt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L212_C12", "label": "assertRaises()", "type": "expression", "loc": [212, 212], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L211_C8", "vector": [8, 3, 0.545, 0.0026, 3, 0.54, 0.0, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, CensusZipcode.objects.distance, self.stx_pnt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L218_C8", "label": "z = get()", "type": "assigned_variable", "loc": [218, 218], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "vector": [14, 2, 0.5604, 0.0026, 2, 0.58, 0.2857, 859, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "z", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " z = SouthTexasZipcode.objects.get(name='77005')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L222_C8", "label": "dists_m =", "type": "assigned_variable", "loc": [222, 222], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "vector": [14, 2, 0.5707, 0.0026, 2, 0.58, 0.4286, 816, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "dists_m", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " dists_m = [3553.30384972258, 1243.18391525602, 2186.15439472242]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L229_C8", "label": "buf1 = buffer()", "type": "assigned_variable", "loc": [229, 229], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "vector": [14, 2, 0.5887, 0.0026, 2, 0.58, 0.5714, 943, 3, 1, 0, 0, 640, 10, 1], "semantic": {"name": "buf1", "arg_names": [], "import_names": [], "rhs_call_name": "buffer", "annotation": ""}, "snippet": " buf1 = z.poly.centroid.buffer(100)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L230_C8", "label": "buf2 = transform()", "type": "assigned_variable", "loc": [230, 230], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "vector": [14, 2, 0.5913, 0.0026, 2, 0.58, 0.7143, 846, 3, 2, 0, 0, 48, 10, 1], "semantic": {"name": "buf2", "arg_names": [], "import_names": [], "rhs_call_name": "transform", "annotation": ""}, "snippet": " buf2 = buf1.transform(4269, clone=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L231_C8", "label": "ref_zips =", "type": "assigned_variable", "loc": [231, 231], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "vector": [14, 2, 0.5938, 0.0026, 2, 0.58, 0.8571, 937, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "ref_zips", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_zips = ['77002', '77025', '77401']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L233_C8", "label": "for buf", "type": "for", "loc": [233, 237], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "vector": [6, 2, 0.6041, 0.0129, 2, 0.58, 1.0, 840, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "buf", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for buf in [buf1, buf2]:\n qs = CensusZipcode.objects.exclude(name='77005').transform(32140).distance(buf)\n self.assertEqual(ref_zips, self.get_names(qs))\n for i, z in enumerate(qs):\n self.assertAlmostEqual(z.distance.m, dists_m[i], 5)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L234_C12", "label": "qs = distance()", "type": "assigned_variable", "loc": [234, 234], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L233_C8", "vector": [14, 3, 0.6015, 0.0026, 3, 0.01, 0.0, 251, 3, 1, 0, 0, 145, 10, 3], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "distance", "annotation": ""}, "snippet": " qs = CensusZipcode.objects.exclude(name='77005').transform(32140).distance(buf)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L235_C12", "label": "assertEqual()", "type": "expression", "loc": [235, 235], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L233_C8", "vector": [8, 3, 0.6041, 0.0026, 3, 0.01, 0.5, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(ref_zips, self.get_names(qs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L236_C12", "label": "for i, z", "type": "for", "loc": [236, 237], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L233_C8", "vector": [6, 3, 0.608, 0.0051, 3, 0.01, 1.0, 930, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "i, z", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, z in enumerate(qs):\n self.assertAlmostEqual(z.distance.m, dists_m[i], 5)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L237_C16", "label": "assertAlmostEqual()", "type": "expression", "loc": [237, 237], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L236_C12", "vector": [8, 4, 0.6093, 0.0026, 4, 0.89, 0.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(z.distance.m, dists_m[i], 5)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "label": "test04_distance_lookups", "type": "function", "loc": [239, 264], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [2, 1, 0.6465, 0.0668, 1, 0.12, 0.6154, 439, 0, 1, 0, 0, 0, 0, 21], "semantic": {"name": "test04_distance_lookups", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test04_distance_lookups(self):\n \"Testing the `distance_lt`, `distance_gt`, `distance_lte`, and `distance_gte` lookup types.\"\n # Retrieving the cities within a 20km 'donut' w/a 7km radius 'hole'\n # (thus, Houston and Southside place will be excluded as tested in\n # the `test02_dwithin` above).\n qs1 = SouthTexasCity.objects.filter(point__distance_gte=(self.stx_pnt, D(km=7))).filter(point__distance_lte=(self.stx_pnt, D(km=20)))\n\n # Can't determine the units on SpatiaLite from PROJ.4 string, and"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L240_C8", "label": "expression", "type": "expression", "loc": [240, 240], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "vector": [8, 2, 0.617, 0.0026, 2, 0.68, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `distance_lt`, `distance_gt`, `distance_lte`, and `distance_gte` lookup types.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L244_C8", "label": "qs1 = filter()", "type": "assigned_variable", "loc": [244, 244], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "vector": [14, 2, 0.6272, 0.0026, 2, 0.68, 0.125, 811, 3, 1, 0, 0, 526, 10, 4], "semantic": {"name": "qs1", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs1 = SouthTexasCity.objects.filter(point__distance_gte=(self.stx_pnt, D(km=7))).filter(point__distance_lte=(self.stx_pnt, D(km=20)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L248_C8", "label": "if", "type": "if", "loc": [248, 252], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "vector": [4, 2, 0.6427, 0.0129, 2, 0.68, 0.25, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if spatialite or oracle:\n dist_qs = (qs1,)\n else:\n qs2 = SouthTexasCityFt.objects.filter(point__distance_gte=(self.stx_pnt, D(km=7))).filter(point__distance_lte=(self.stx_pnt, D(km=20)))\n dist_qs = (qs1, qs2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L249_C12", "label": "dist_qs =", "type": "assigned_variable", "loc": [249, 249], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L248_C8", "vector": [14, 3, 0.6401, 0.0026, 3, 0.82, 0.0, 536, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "dist_qs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " dist_qs = (qs1,)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L251_C12", "label": "qs2 = filter()", "type": "assigned_variable", "loc": [251, 251], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L248_C8", "vector": [14, 3, 0.6452, 0.0026, 3, 0.82, 0.5, 595, 3, 1, 0, 0, 526, 10, 4], "semantic": {"name": "qs2", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs2 = SouthTexasCityFt.objects.filter(point__distance_gte=(self.stx_pnt, D(km=7))).filter(point__distance_lte=(self.stx_pnt, D(km=20)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L252_C12", "label": "dist_qs =", "type": "assigned_variable", "loc": [252, 252], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L248_C8", "vector": [14, 3, 0.6478, 0.0026, 3, 0.82, 1.0, 536, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "dist_qs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " dist_qs = (qs1, qs2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L254_C8", "label": "for qs", "type": "for", "loc": [254, 256], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "vector": [6, 2, 0.6555, 0.0077, 2, 0.68, 0.375, 251, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for qs in dist_qs:\n cities = self.get_names(qs)\n self.assertEqual(cities, ['Bellaire', 'Pearland', 'West University Place'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L255_C12", "label": "cities = get_names()", "type": "assigned_variable", "loc": [255, 255], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L254_C8", "vector": [14, 3, 0.6555, 0.0026, 3, 0.36, 0.0, 884, 3, 1, 0, 0, 21, 10, 1], "semantic": {"name": "cities", "arg_names": [], "import_names": [], "rhs_call_name": "get_names", "annotation": ""}, "snippet": " cities = self.get_names(qs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L256_C12", "label": "assertEqual()", "type": "expression", "loc": [256, 256], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L254_C8", "vector": [8, 3, 0.6581, 0.0026, 3, 0.36, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(cities, ['Bellaire', 'Pearland', 'West University Place'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L259_C8", "label": "z = get()", "type": "assigned_variable", "loc": [259, 259], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "vector": [14, 2, 0.6658, 0.0026, 2, 0.68, 0.5, 859, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "z", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " z = SouthTexasZipcode.objects.get(name='77005')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L260_C8", "label": "qs = filter()", "type": "assigned_variable", "loc": [260, 260], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "vector": [14, 2, 0.6684, 0.0026, 2, 0.68, 0.625, 251, 3, 1, 0, 0, 526, 10, 3], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = SouthTexasZipcode.objects.exclude(name='77005').filter(poly__distance_lte=(z.poly, D(m=275)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L261_C8", "label": "assertEqual()", "type": "expression", "loc": [261, 261], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "vector": [8, 2, 0.671, 0.0026, 2, 0.68, 0.75, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(['77025', '77401'], self.get_names(qs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L263_C8", "label": "qs = filter()", "type": "assigned_variable", "loc": [263, 263], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "vector": [14, 2, 0.6761, 0.0026, 2, 0.68, 0.875, 251, 3, 1, 0, 0, 526, 10, 3], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = SouthTexasZipcode.objects.exclude(name='77005').filter(poly__distance_lte=(z.poly, D(m=300)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L264_C8", "label": "assertEqual()", "type": "expression", "loc": [264, 264], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "vector": [8, 2, 0.6787, 0.0026, 2, 0.68, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(['77002', '77025', '77401'], self.get_names(qs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "label": "test05_geodetic_distance_lookups", "type": "function", "loc": [266, 327], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [2, 1, 0.7622, 0.1594, 1, 0.12, 0.6923, 113, 0, 1, 0, 0, 0, 0, 32], "semantic": {"name": "test05_geodetic_distance_lookups", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test05_geodetic_distance_lookups(self):\n \"Testing distance lookups on geodetic coordinate systems.\"\n # Line is from Canberra to Sydney. Query is for all other cities within\n # a 100km of that line (which should exclude only Hobart & Adelaide).\n line = GEOSGeometry('LINESTRING(144.9630 -37.8143,151.2607 -33.8870)', 4326)\n dist_qs = AustraliaCity.objects.filter(point__distance_lte=(line, D(km=100)))\n\n if oracle or connection.ops.geography:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L267_C8", "label": "expression", "type": "expression", "loc": [267, 267], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [8, 2, 0.6864, 0.0026, 2, 0.07, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing distance lookups on geodetic coordinate systems.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L270_C8", "label": "line = GEOSGeometry()", "type": "assigned_variable", "loc": [270, 270], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [14, 2, 0.6941, 0.0026, 2, 0.07, 0.0625, 373, 3, 2, 0, 0, 958, 10, 1], "semantic": {"name": "line", "arg_names": [], "import_names": [], "rhs_call_name": "GEOSGeometry", "annotation": ""}, "snippet": " line = GEOSGeometry('LINESTRING(144.9630 -37.8143,151.2607 -33.8870)', 4326)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L271_C8", "label": "dist_qs = filter()", "type": "assigned_variable", "loc": [271, 271], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [14, 2, 0.6967, 0.0026, 2, 0.07, 0.125, 536, 3, 1, 0, 0, 526, 10, 2], "semantic": {"name": "dist_qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " dist_qs = AustraliaCity.objects.filter(point__distance_lte=(line, D(km=100)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L273_C8", "label": "if", "type": "if", "loc": [273, 288], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [4, 2, 0.7211, 0.0411, 2, 0.07, 0.1875, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle or connection.ops.geography:\n # Oracle and PostGIS 1.5 can do distance lookups on arbitrary geometries.\n self.assertEqual(9, dist_qs.count())\n self.assertEqual(['Batemans Bay', 'Canberra', 'Hillsdale',\n 'Melbourne', 'Mittagong', 'Shellharbour',\n 'Sydney', 'Thirroul', 'Wollongong'],\n self.get_names(dist_qs))\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L275_C12", "label": "assertEqual()", "type": "expression", "loc": [275, 275], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L273_C8", "vector": [8, 3, 0.7069, 0.0026, 3, 0.11, 0.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(9, dist_qs.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L276_C12", "label": "assertEqual()", "type": "expression", "loc": [276, 279], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L273_C8", "vector": [8, 3, 0.7134, 0.0103, 3, 0.11, 0.3333, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(['Batemans Bay', 'Canberra', 'Hillsdale',\n 'Melbourne', 'Mittagong', 'Shellharbour',\n 'Sydney', 'Thirroul', 'Wollongong'],\n self.get_names(dist_qs))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L284_C12", "label": "assertRaises()", "type": "expression", "loc": [284, 284], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L273_C8", "vector": [8, 3, 0.7301, 0.0026, 3, 0.11, 0.6667, 11, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, dist_qs.count)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L288_C12", "label": "if", "type": "if", "loc": [288, 288], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L273_C8", "vector": [4, 3, 0.7404, 0.0026, 3, 0.11, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if spatialite: return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Return_L288_C27", "label": "return", "type": "return", "loc": [288, 288], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L288_C12", "vector": [13, 4, 0.7404, 0.0026, 4, 0.13, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if spatialite: return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L291_C8", "label": "assertRaises()", "type": "expression", "loc": [291, 292], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [8, 2, 0.7494, 0.0051, 2, 0.07, 0.25, 11, 3, 3, 0, 0, 0, 0, 3], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, len,\n AustraliaCity.objects.filter(point__distance_lte=('POINT(5 23)', D(km=100), 'spheroid', '4')))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L295_C8", "label": "assertRaises()", "type": "expression", "loc": [295, 296], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [8, 2, 0.7596, 0.0051, 2, 0.07, 0.3125, 11, 3, 3, 0, 0, 0, 0, 2], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, len,\n AustraliaCity.objects.filter(point__distance_lte=('POINT(5 23)',)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L299_C8", "label": "hobart = get()", "type": "assigned_variable", "loc": [299, 299], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [14, 2, 0.7686, 0.0026, 2, 0.07, 0.375, 118, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "hobart", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " hobart = AustraliaCity.objects.get(name='Hobart')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L300_C8", "label": "qs = filter()", "type": "assigned_variable", "loc": [300, 300], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [14, 2, 0.7712, 0.0026, 2, 0.07, 0.4375, 251, 3, 1, 0, 0, 526, 10, 3], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = AustraliaCity.objects.exclude(name='Hobart').filter(point__distance_lte=(hobart.point, D(mi=550)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L301_C8", "label": "cities = get_names()", "type": "assigned_variable", "loc": [301, 301], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [14, 2, 0.7738, 0.0026, 2, 0.07, 0.5, 884, 3, 1, 0, 0, 21, 10, 1], "semantic": {"name": "cities", "arg_names": [], "import_names": [], "rhs_call_name": "get_names", "annotation": ""}, "snippet": " cities = self.get_names(qs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L302_C8", "label": "assertEqual()", "type": "expression", "loc": [302, 302], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [8, 2, 0.7763, 0.0026, 2, 0.07, 0.5625, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(cities, ['Batemans Bay', 'Canberra', 'Melbourne'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L306_C8", "label": "wollongong = get()", "type": "assigned_variable", "loc": [306, 306], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [14, 2, 0.7866, 0.0026, 2, 0.07, 0.625, 863, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "wollongong", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " wollongong = AustraliaCity.objects.get(name='Wollongong')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L307_C8", "label": "d1, d2 =", "type": "assigned_variable", "loc": [307, 307], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [14, 2, 0.7892, 0.0026, 2, 0.07, 0.6875, 915, 0, 0, 0, 0, 0, 8, 2], "semantic": {"name": "d1, d2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " d1, d2 = D(yd=19500), D(nm=400) # Yards (~17km) & Nautical miles."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L310_C8", "label": "gq1 = Q()", "type": "assigned_variable", "loc": [310, 310], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [14, 2, 0.7969, 0.0026, 2, 0.07, 0.75, 696, 3, 1, 0, 0, 928, 10, 1], "semantic": {"name": "gq1", "arg_names": [], "import_names": [], "rhs_call_name": "Q", "annotation": ""}, "snippet": " gq1 = Q(point__distance_lte=(wollongong.point, d1))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L311_C8", "label": "gq2 = Q()", "type": "assigned_variable", "loc": [311, 311], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [14, 2, 0.7995, 0.0026, 2, 0.07, 0.8125, 848, 3, 1, 0, 0, 928, 10, 1], "semantic": {"name": "gq2", "arg_names": [], "import_names": [], "rhs_call_name": "Q", "annotation": ""}, "snippet": " gq2 = Q(point__distance_gte=(wollongong.point, d2))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L312_C8", "label": "qs1 = filter()", "type": "assigned_variable", "loc": [312, 312], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [14, 2, 0.8021, 0.0026, 2, 0.07, 0.875, 811, 3, 1, 0, 0, 526, 10, 2], "semantic": {"name": "qs1", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs1 = AustraliaCity.objects.exclude(name='Wollongong').filter(gq1 | gq2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L317_C8", "label": "if", "type": "if", "loc": [317, 323], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [4, 2, 0.8226, 0.018, 2, 0.07, 0.9375, 0, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if postgis:\n gq3 = Q(point__distance_lte=(wollongong.point, d1, 'spheroid'))\n gq4 = Q(point__distance_gte=(wollongong.point, d2, 'spheroid'))\n qs2 = AustraliaCity.objects.exclude(name='Wollongong').filter(gq3 | gq4)\n querysets = [qs1, qs2]\n else:\n querysets = [qs1]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L318_C12", "label": "gq3 = Q()", "type": "assigned_variable", "loc": [318, 318], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L317_C8", "vector": [14, 3, 0.8175, 0.0026, 3, 0.54, 0.0, 927, 3, 1, 0, 0, 928, 10, 1], "semantic": {"name": "gq3", "arg_names": [], "import_names": [], "rhs_call_name": "Q", "annotation": ""}, "snippet": " gq3 = Q(point__distance_lte=(wollongong.point, d1, 'spheroid'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L319_C12", "label": "gq4 = Q()", "type": "assigned_variable", "loc": [319, 319], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L317_C8", "vector": [14, 3, 0.8201, 0.0026, 3, 0.54, 0.25, 118, 3, 1, 0, 0, 928, 10, 1], "semantic": {"name": "gq4", "arg_names": [], "import_names": [], "rhs_call_name": "Q", "annotation": ""}, "snippet": " gq4 = Q(point__distance_gte=(wollongong.point, d2, 'spheroid'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L320_C12", "label": "qs2 = filter()", "type": "assigned_variable", "loc": [320, 320], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L317_C8", "vector": [14, 3, 0.8226, 0.0026, 3, 0.54, 0.5, 595, 3, 1, 0, 0, 526, 10, 2], "semantic": {"name": "qs2", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs2 = AustraliaCity.objects.exclude(name='Wollongong').filter(gq3 | gq4)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L321_C12", "label": "querysets =", "type": "assigned_variable", "loc": [321, 321], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L317_C8", "vector": [14, 3, 0.8252, 0.0026, 3, 0.54, 0.75, 569, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "querysets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " querysets = [qs1, qs2]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L323_C12", "label": "querysets =", "type": "assigned_variable", "loc": [323, 323], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L317_C8", "vector": [14, 3, 0.8303, 0.0026, 3, 0.54, 1.0, 569, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "querysets", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " querysets = [qs1]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L325_C8", "label": "for qs", "type": "for", "loc": [325, 327], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "vector": [6, 2, 0.838, 0.0077, 2, 0.07, 1.0, 251, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for qs in querysets:\n cities = self.get_names(qs)\n self.assertEqual(cities, ['Adelaide', 'Hobart', 'Shellharbour', 'Thirroul'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L326_C12", "label": "cities = get_names()", "type": "assigned_variable", "loc": [326, 326], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L325_C8", "vector": [14, 3, 0.838, 0.0026, 3, 0.4, 0.0, 884, 3, 1, 0, 0, 21, 10, 1], "semantic": {"name": "cities", "arg_names": [], "import_names": [], "rhs_call_name": "get_names", "annotation": ""}, "snippet": " cities = self.get_names(qs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L327_C12", "label": "assertEqual()", "type": "expression", "loc": [327, 327], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L325_C8", "vector": [8, 3, 0.8406, 0.0026, 3, 0.4, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(cities, ['Adelaide', 'Hobart', 'Shellharbour', 'Thirroul'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L329_C4", "label": "test06_area", "type": "function", "loc": [329, 338], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [2, 1, 0.8573, 0.0257, 1, 0.12, 0.7692, 335, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "test06_area", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test06_area(self):\n \"Testing the `area` GeoQuerySet method.\"\n # Reference queries:\n # SELECT ST_Area(poly) FROM distapp_southtexaszipcode;\n area_sq_m = [5437908.90234375, 10183031.4389648, 11254471.0073242, 9881708.91772461]\n # Tolerance has to be lower for Oracle and differences\n # with GEOS 3.0.0RC4\n tol = 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L330_C8", "label": "expression", "type": "expression", "loc": [330, 330], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L329_C4", "vector": [8, 2, 0.8483, 0.0026, 2, 0.3, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `area` GeoQuerySet method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L333_C8", "label": "area_sq_m =", "type": "assigned_variable", "loc": [333, 333], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L329_C4", "vector": [14, 2, 0.856, 0.0026, 2, 0.3, 0.3333, 796, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "area_sq_m", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " area_sq_m = [5437908.90234375, 10183031.4389648, 11254471.0073242, 9881708.91772461]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L336_C8", "label": "tol =", "type": "assigned_variable", "loc": [336, 336], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L329_C4", "vector": [14, 2, 0.8638, 0.0026, 2, 0.3, 0.6667, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L337_C8", "label": "for i, z", "type": "for", "loc": [337, 338], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L329_C4", "vector": [6, 2, 0.8676, 0.0051, 2, 0.3, 1.0, 930, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "i, z", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, z in enumerate(SouthTexasZipcode.objects.area()):\n self.assertAlmostEqual(area_sq_m[i], z.area.sq_m, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L338_C12", "label": "assertAlmostEqual()", "type": "expression", "loc": [338, 338], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L337_C8", "vector": [8, 3, 0.8689, 0.0026, 3, 0.45, 0.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(area_sq_m[i], z.area.sq_m, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "label": "test07_length", "type": "function", "loc": [340, 358], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [2, 1, 0.8972, 0.0488, 1, 0.12, 0.8462, 607, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test07_length", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test07_length(self):\n \"Testing the `length` GeoQuerySet method.\"\n # Reference query (should use `length_spheroid`).\n # SELECT ST_length_spheroid(ST_GeomFromText('<wkt>', 4326) 'SPHEROID[\"WGS 84\",6378137,298.257223563, AUTHORITY[\"EPSG\",\"7030\"]]');\n len_m1 = 473504.769553813\n len_m2 = 4617.668\n\n if spatialite:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L341_C8", "label": "expression", "type": "expression", "loc": [341, 341], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "vector": [8, 2, 0.8766, 0.0026, 2, 0.34, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `length` GeoQuerySet method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L344_C8", "label": "len_m1 =", "type": "assigned_variable", "loc": [344, 344], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "vector": [14, 2, 0.8843, 0.0026, 2, 0.34, 0.2, 230, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "len_m1", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " len_m1 = 473504.769553813"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L345_C8", "label": "len_m2 =", "type": "assigned_variable", "loc": [345, 345], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "vector": [14, 2, 0.8869, 0.0026, 2, 0.34, 0.4, 689, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "len_m2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " len_m2 = 4617.668"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L347_C8", "label": "if", "type": "if", "loc": [347, 354], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "vector": [4, 2, 0.901, 0.0206, 2, 0.34, 0.6, 0, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if spatialite:\n # Does not support geodetic coordinate systems.\n self.assertRaises(ValueError, Interstate.objects.length)\n else:\n qs = Interstate.objects.length()\n if oracle: tol = 2\n else: tol = 5\n self.assertAlmostEqual(len_m1, qs[0].length.m, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L349_C12", "label": "assertRaises()", "type": "expression", "loc": [349, 349], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L347_C8", "vector": [8, 3, 0.8972, 0.0026, 3, 0.82, 0.0, 11, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, Interstate.objects.length)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L351_C12", "label": "qs = length()", "type": "assigned_variable", "loc": [351, 351], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L347_C8", "vector": [14, 3, 0.9023, 0.0026, 3, 0.82, 0.3333, 251, 3, 0, 0, 0, 221, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "length", "annotation": ""}, "snippet": " qs = Interstate.objects.length()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L352_C12", "label": "if", "type": "if", "loc": [352, 353], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L347_C8", "vector": [4, 3, 0.9062, 0.0051, 3, 0.82, 0.6667, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle: tol = 2\n else: tol = 5"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L352_C23", "label": "tol =", "type": "assigned_variable", "loc": [352, 352], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L352_C12", "vector": [14, 4, 0.9049, 0.0026, 4, 0.39, 0.0, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle: tol = 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L353_C18", "label": "tol =", "type": "assigned_variable", "loc": [353, 353], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L352_C12", "vector": [14, 4, 0.9075, 0.0026, 4, 0.39, 1.0, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " else: tol = 5"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L354_C12", "label": "assertAlmostEqual()", "type": "expression", "loc": [354, 354], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L347_C8", "vector": [8, 3, 0.91, 0.0026, 3, 0.82, 1.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(len_m1, qs[0].length.m, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L357_C8", "label": "i10 = get()", "type": "assigned_variable", "loc": [357, 357], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "vector": [14, 2, 0.9177, 0.0026, 2, 0.34, 0.8, 325, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "i10", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " i10 = SouthTexasInterstate.objects.length().get(name='I-10')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L358_C8", "label": "assertAlmostEqual()", "type": "expression", "loc": [358, 358], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "vector": [8, 2, 0.9203, 0.0026, 2, 0.34, 1.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(len_m2, i10.length.m, 2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L361_C4", "label": "test08_perimeter", "type": "function", "loc": [361, 373], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [2, 1, 0.9434, 0.0334, 1, 0.12, 0.9231, 219, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test08_perimeter", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test08_perimeter(self):\n \"Testing the `perimeter` GeoQuerySet method.\"\n # Reference query:\n # SELECT ST_Perimeter(distapp_southtexaszipcode.poly) FROM distapp_southtexaszipcode;\n perim_m = [18404.3550889361, 15627.2108551001, 20632.5588368978, 17094.5996143697]\n if oracle: tol = 2\n else: tol = 7\n for i, z in enumerate(SouthTexasZipcode.objects.perimeter()):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L362_C8", "label": "expression", "type": "expression", "loc": [362, 362], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L361_C4", "vector": [8, 2, 0.9306, 0.0026, 2, 0.7, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `perimeter` GeoQuerySet method.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L365_C8", "label": "perim_m =", "type": "assigned_variable", "loc": [365, 365], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L361_C4", "vector": [14, 2, 0.9383, 0.0026, 2, 0.7, 0.25, 953, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "perim_m", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " perim_m = [18404.3550889361, 15627.2108551001, 20632.5588368978, 17094.5996143697]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L366_C8", "label": "if", "type": "if", "loc": [366, 367], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L361_C4", "vector": [4, 2, 0.9422, 0.0051, 2, 0.7, 0.5, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle: tol = 2\n else: tol = 7"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L366_C19", "label": "tol =", "type": "assigned_variable", "loc": [366, 366], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L366_C8", "vector": [14, 3, 0.9409, 0.0026, 3, 0.73, 0.0, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if oracle: tol = 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L367_C14", "label": "tol =", "type": "assigned_variable", "loc": [367, 367], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L366_C8", "vector": [14, 3, 0.9434, 0.0026, 3, 0.73, 1.0, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " else: tol = 7"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L368_C8", "label": "for i, z", "type": "for", "loc": [368, 369], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L361_C4", "vector": [6, 2, 0.9473, 0.0051, 2, 0.7, 0.75, 930, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "i, z", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, z in enumerate(SouthTexasZipcode.objects.perimeter()):\n self.assertAlmostEqual(perim_m[i], z.perimeter.m, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L369_C12", "label": "assertAlmostEqual()", "type": "expression", "loc": [369, 369], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L368_C8", "vector": [8, 3, 0.9486, 0.0026, 3, 0.92, 0.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(perim_m[i], z.perimeter.m, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L372_C8", "label": "for i, c", "type": "for", "loc": [372, 373], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L361_C4", "vector": [6, 2, 0.9576, 0.0051, 2, 0.7, 1.0, 787, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "i, c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, c in enumerate(SouthTexasCity.objects.perimeter(model_att='perim')):\n self.assertEqual(0, c.perim.m)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L373_C12", "label": "assertEqual()", "type": "expression", "loc": [373, 373], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L372_C8", "vector": [8, 3, 0.9589, 0.0026, 3, 0.77, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(0, c.perim.m)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "label": "test09_measurement_null_fields", "type": "function", "loc": [375, 384], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "vector": [2, 1, 0.9756, 0.0257, 1, 0.12, 1.0, 914, 0, 1, 0, 0, 0, 0, 7], "semantic": {"name": "test09_measurement_null_fields", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test09_measurement_null_fields(self):\n \"Testing the measurement GeoQuerySet methods on fields with NULL values.\"\n # Creating SouthTexasZipcode w/NULL value.\n SouthTexasZipcode.objects.create(name='78212')\n # Performing distance/area queries against the NULL PolygonField,\n # and ensuring the result of the operations is None.\n htown = SouthTexasCity.objects.get(name='Downtown Houston')\n z = SouthTexasZipcode.objects.distance(htown.point).area().get(name='78212')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L376_C8", "label": "expression", "type": "expression", "loc": [376, 376], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "vector": [8, 2, 0.9666, 0.0026, 2, 0.55, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the measurement GeoQuerySet methods on fields with NULL values.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L378_C8", "label": "create()", "type": "expression", "loc": [378, 378], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "vector": [8, 2, 0.9717, 0.0026, 2, 0.55, 0.2, 316, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " SouthTexasZipcode.objects.create(name='78212')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L381_C8", "label": "htown = get()", "type": "assigned_variable", "loc": [381, 381], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "vector": [14, 2, 0.9794, 0.0026, 2, 0.55, 0.4, 968, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "htown", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " htown = SouthTexasCity.objects.get(name='Downtown Houston')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L382_C8", "label": "z = get()", "type": "assigned_variable", "loc": [382, 382], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "vector": [14, 2, 0.982, 0.0026, 2, 0.55, 0.6, 859, 3, 1, 0, 0, 607, 10, 3], "semantic": {"name": "z", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " z = SouthTexasZipcode.objects.distance(htown.point).area().get(name='78212')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L383_C8", "label": "assertEqual()", "type": "expression", "loc": [383, 383], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "vector": [8, 2, 0.9846, 0.0026, 2, 0.55, 0.8, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(None, z.distance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L384_C8", "label": "assertEqual()", "type": "expression", "loc": [384, 384], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "vector": [8, 2, 0.9871, 0.0026, 2, 0.55, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(None, z.area)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L386_C0", "label": "suite", "type": "function", "loc": [386, 389], "level": 0, "parent": null, "vector": [2, 0, 0.9961, 0.0103, 0, 0.66, 1.0, 425, 0, 0, 1, 0, 0, 0, 3], "semantic": {"name": "suite", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def suite():\n s = unittest.TestSuite()\n s.addTest(unittest.makeSuite(DistanceTest))\n return s"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L387_C4", "label": "s = TestSuite()", "type": "assigned_variable", "loc": [387, 387], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L386_C0", "vector": [14, 1, 0.9949, 0.0026, 1, 0.16, 0.0, 553, 3, 0, 0, 0, 75, 10, 1], "semantic": {"name": "s", "arg_names": [], "import_names": [], "rhs_call_name": "TestSuite", "annotation": ""}, "snippet": " s = unittest.TestSuite()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L388_C4", "label": "addTest()", "type": "expression", "loc": [388, 388], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L386_C0", "vector": [8, 1, 0.9974, 0.0026, 1, 0.16, 0.5, 786, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "addTest", "arg_names": [], "import_names": [], "rhs_call_name": "addTest", "annotation": ""}, "snippet": " s.addTest(unittest.makeSuite(DistanceTest))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98686:Return_L389_C4", "label": "return", "type": "return", "loc": [389, 389], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L386_C0", "vector": [13, 1, 1.0, 0.0026, 1, 0.16, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return s"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Return_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L34_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L35_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L35_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L36_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L38_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L39_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L39_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L40_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L51_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L52_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L51_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L53_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L51_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L54_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L80_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L81_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L81_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L81_C40"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L81_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L82_C18"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L80_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L83_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L80_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L84_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L80_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L85_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L85_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L86_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L89_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L90_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L90_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L90_C51"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L90_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L91_C18"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L89_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L93_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L93_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L94_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L94_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L94_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L94_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L95_C22"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L89_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L98_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L89_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L99_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L99_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L102_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L99_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L104_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L127_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L127_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L128_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L127_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L130_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L127_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L131_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L127_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L132_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L136_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L136_C19"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L136_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L137_C14"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L140_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L141_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L142_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L143_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L147_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L148_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L148_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L148_C19"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L148_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L149_C14"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L153_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L154_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L157_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L154_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L160_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L154_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L161_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L161_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L163_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L154_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L167_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L154_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L168_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L173_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L173_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L176_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L173_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L180_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L173_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L186_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L173_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L190_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L197_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L198_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L198_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L199_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L146_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L200_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L200_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L202_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L200_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L203_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L203_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L204_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L208_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L211_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L211_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L212_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L218_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L222_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L229_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L230_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L231_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L233_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L233_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L234_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L233_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L235_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L233_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L236_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L236_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L237_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L240_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L244_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L248_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L248_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L249_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L248_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L251_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L248_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L252_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L254_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L254_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L255_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L254_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L256_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L259_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L260_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L261_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L263_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L239_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L264_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L267_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L270_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L271_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L273_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L273_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L275_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L273_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L276_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L273_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L284_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L273_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L288_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L288_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Return_L288_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L291_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L295_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L299_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L300_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L301_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L302_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L306_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L307_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L310_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L311_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L312_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L317_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L317_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L318_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L317_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L319_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L317_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L320_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L317_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L321_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L317_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L323_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L266_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L325_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L325_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L326_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L325_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L327_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L329_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L329_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L330_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L329_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L333_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L329_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L336_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L329_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L337_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L337_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L338_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L341_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L344_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L345_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L347_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L347_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L349_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L347_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L351_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L347_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L352_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L352_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L352_C23"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L352_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L353_C18"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L347_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L354_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L357_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L340_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L358_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L361_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L361_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L362_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L361_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L365_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L361_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L366_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L366_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L366_C19"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:If_L366_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L367_C14"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L361_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L368_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L368_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L369_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L361_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L372_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:For_L372_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L373_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L376_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L378_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L381_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L382_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L383_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L375_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L384_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L386_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Assign_L387_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L386_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Expr_L388_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98686:FunctionDef_L386_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98686:Return_L389_C4"}] |
from django.contrib.gis.db import models
class City(models.Model):
name = models.CharField(max_length=30)
point = models.PointField(geography=True)
objects = models.GeoManager()
def __unicode__(self): return self.name
class Zipcode(models.Model):
code = models.CharField(max_length=10)
poly = models.PolygonField(geography=True)
objects = models.GeoManager()
def __unicode__(self): return self.code
class County(models.Model):
name = models.CharField(max_length=25)
state = models.CharField(max_length=20)
mpoly = models.MultiPolygonField(geography=True)
objects = models.GeoManager()
def __unicode__(self): return ' County, '.join([self.name, self.state])
| ajibawa-2023/Python-Code-Large/train/row_98687 | 20 | 20 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98687:ImportFrom_L1_C0", "label": "from django.contrib.gis.db import models", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.05, 0.05, 0, 0.66, 0.0, 964, 0, 1, 0, 0, 964, 0, 0], "semantic": {"name": "django.contrib.gis.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L3_C0", "label": "City", "type": "class", "loc": [3, 7], "level": 0, "parent": null, "vector": [3, 0, 0.25, 0.25, 0, 0.66, 0.3333, 801, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "City", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class City(models.Model):\n name = models.CharField(max_length=30)\n point = models.PointField(geography=True)\n objects = models.GeoManager()\n def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L4_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [4, 4], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L3_C0", "vector": [14, 1, 0.2, 0.05, 1, 0.84, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=30)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L5_C4", "label": "point = PointField()", "type": "assigned_variable", "loc": [5, 5], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L3_C0", "vector": [14, 1, 0.25, 0.05, 1, 0.84, 0.3333, 16, 3, 1, 0, 0, 260, 10, 1], "semantic": {"name": "point", "arg_names": [], "import_names": [], "rhs_call_name": "PointField", "annotation": ""}, "snippet": " point = models.PointField(geography=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L6_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [6, 6], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L3_C0", "vector": [14, 1, 0.3, 0.05, 1, 0.84, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:FunctionDef_L7_C4", "label": "__unicode__", "type": "function", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L3_C0", "vector": [2, 1, 0.35, 0.05, 1, 0.84, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Return_L7_C27", "label": "return", "type": "return", "loc": [7, 7], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:FunctionDef_L7_C4", "vector": [13, 2, 0.35, 0.05, 2, 0.19, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L9_C0", "label": "Zipcode", "type": "class", "loc": [9, 13], "level": 0, "parent": null, "vector": [3, 0, 0.55, 0.25, 0, 0.66, 0.6667, 220, 0, 1, 0, 0, 996, 0, 3], "semantic": {"name": "Zipcode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Zipcode(models.Model):\n code = models.CharField(max_length=10)\n poly = models.PolygonField(geography=True)\n objects = models.GeoManager()\n def __unicode__(self): return self.code"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L10_C4", "label": "code = CharField()", "type": "assigned_variable", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L9_C0", "vector": [14, 1, 0.5, 0.05, 1, 0.7, 0.0, 44, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "code", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " code = models.CharField(max_length=10)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L11_C4", "label": "poly = PolygonField()", "type": "assigned_variable", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L9_C0", "vector": [14, 1, 0.55, 0.05, 1, 0.7, 0.3333, 365, 3, 1, 0, 0, 736, 10, 1], "semantic": {"name": "poly", "arg_names": [], "import_names": [], "rhs_call_name": "PolygonField", "annotation": ""}, "snippet": " poly = models.PolygonField(geography=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L12_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L9_C0", "vector": [14, 1, 0.6, 0.05, 1, 0.7, 0.6667, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:FunctionDef_L13_C4", "label": "__unicode__", "type": "function", "loc": [13, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L9_C0", "vector": [2, 1, 0.65, 0.05, 1, 0.7, 1.0, 318, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.code"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Return_L13_C27", "label": "return", "type": "return", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:FunctionDef_L13_C4", "vector": [13, 2, 0.65, 0.05, 2, 0.12, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return self.code"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L15_C0", "label": "County", "type": "class", "loc": [15, 20], "level": 0, "parent": null, "vector": [3, 0, 0.875, 0.3, 0, 0.66, 1.0, 381, 0, 1, 0, 0, 996, 0, 5], "semantic": {"name": "County", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class County(models.Model):\n name = models.CharField(max_length=25)\n state = models.CharField(max_length=20)\n mpoly = models.MultiPolygonField(geography=True)\n objects = models.GeoManager()\n def __unicode__(self): return ' County, '.join([self.name, self.state])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L16_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L15_C0", "vector": [14, 1, 0.8, 0.05, 1, 0.32, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=25)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L17_C4", "label": "state = CharField()", "type": "assigned_variable", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L15_C0", "vector": [14, 1, 0.85, 0.05, 1, 0.32, 0.25, 688, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "state", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " state = models.CharField(max_length=20)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L18_C4", "label": "mpoly = MultiPolygonField()", "type": "assigned_variable", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L15_C0", "vector": [14, 1, 0.9, 0.05, 1, 0.32, 0.5, 634, 3, 1, 0, 0, 682, 10, 1], "semantic": {"name": "mpoly", "arg_names": [], "import_names": [], "rhs_call_name": "MultiPolygonField", "annotation": ""}, "snippet": " mpoly = models.MultiPolygonField(geography=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L19_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L15_C0", "vector": [14, 1, 0.95, 0.05, 1, 0.32, 0.75, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:FunctionDef_L20_C4", "label": "__unicode__", "type": "function", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L15_C0", "vector": [2, 1, 1.0, 0.05, 1, 0.32, 1.0, 318, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return ' County, '.join([self.name, self.state])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98687:Return_L20_C27", "label": "return", "type": "return", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98687:FunctionDef_L20_C4", "vector": [13, 2, 1.0, 0.05, 2, 0.36, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self): return ' County, '.join([self.name, self.state])"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Return_L7_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:FunctionDef_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Return_L13_C27"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:FunctionDef_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98687:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98687:Return_L20_C27"}] |
"""
Tests for geography support in PostGIS 1.5+
"""
import os
from django.contrib.gis import gdal
from django.contrib.gis.measure import D
from django.test import TestCase
from models import City, County, Zipcode
class GeographyTest(TestCase):
def test01_fixture_load(self):
"Ensure geography features loaded properly."
self.assertEqual(8, City.objects.count())
def test02_distance_lookup(self):
"Testing GeoQuerySet distance lookup support on non-point geography fields."
z = Zipcode.objects.get(code='77002')
cities1 = list(City.objects
.filter(point__distance_lte=(z.poly, D(mi=500)))
.order_by('name')
.values_list('name', flat=True))
cities2 = list(City.objects
.filter(point__dwithin=(z.poly, D(mi=500)))
.order_by('name')
.values_list('name', flat=True))
for cities in [cities1, cities2]:
self.assertEqual(['Dallas', 'Houston', 'Oklahoma City'], cities)
def test03_distance_method(self):
"Testing GeoQuerySet.distance() support on non-point geography fields."
# `GeoQuerySet.distance` is not allowed geometry fields.
htown = City.objects.get(name='Houston')
qs = Zipcode.objects.distance(htown.point)
def test04_invalid_operators_functions(self):
"Ensuring exceptions are raised for operators & functions invalid on geography fields."
# Only a subset of the geometry functions & operator are available
# to PostGIS geography types. For more information, visit:
# http://postgis.refractions.net/documentation/manual-1.5/ch08.html#PostGIS_GeographyFunctions
z = Zipcode.objects.get(code='77002')
# ST_Within not available.
self.assertRaises(ValueError, City.objects.filter(point__within=z.poly).count)
# `@` operator not available.
self.assertRaises(ValueError, City.objects.filter(point__contained=z.poly).count)
# Regression test for #14060, `~=` was never really implemented for PostGIS.
htown = City.objects.get(name='Houston')
self.assertRaises(ValueError, City.objects.get, point__exact=htown.point)
def test05_geography_layermapping(self):
"Testing LayerMapping support on models with geography fields."
# There is a similar test in `layermap` that uses the same data set,
# but the County model here is a bit different.
if not gdal.HAS_GDAL: return
from django.contrib.gis.utils import LayerMapping
# Getting the shapefile and mapping dictionary.
shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))
co_shp = os.path.join(shp_path, 'counties', 'counties.shp')
co_mapping = {'name' : 'Name',
'state' : 'State',
'mpoly' : 'MULTIPOLYGON',
}
# Reference county names, number of polygons, and state names.
names = ['Bexar', 'Galveston', 'Harris', 'Honolulu', 'Pueblo']
num_polys = [1, 2, 1, 19, 1] # Number of polygons for each.
st_names = ['Texas', 'Texas', 'Texas', 'Hawaii', 'Colorado']
lm = LayerMapping(County, co_shp, co_mapping, source_srs=4269, unique='name')
lm.save(silent=True, strict=True)
for c, name, num_poly, state in zip(County.objects.order_by('name'), names, num_polys, st_names):
self.assertEqual(4326, c.mpoly.srid)
self.assertEqual(num_poly, len(c.mpoly))
self.assertEqual(name, c.name)
self.assertEqual(state, c.state)
def test06_geography_area(self):
"Testing that Area calculations work on geography columns."
from django.contrib.gis.measure import A
# SELECT ST_Area(poly) FROM geogapp_zipcode WHERE code='77002';
ref_area = 5439084.70637573
tol = 5
z = Zipcode.objects.area().get(code='77002')
self.assertAlmostEqual(z.area.sq_m, ref_area, tol)
| ajibawa-2023/Python-Code-Large/train/row_98688 | 53 | 87 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.023, 0.0345, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nTests for geography support in PostGIS 1.5+\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Import_L4_C0", "label": "os import os", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.046, 0.0115, 0, 0.66, 0.1667, 688, 0, 1, 0, 0, 688, 0, 0], "semantic": {"name": "os", "arg_names": [], "import_names": ["os"], "rhs_call_name": "", "annotation": ""}, "snippet": "import os"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:ImportFrom_L5_C0", "label": "from django.contrib.gis import gdal", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0575, 0.0115, 0, 0.66, 0.3333, 735, 0, 1, 0, 0, 735, 0, 0], "semantic": {"name": "django.contrib.gis", "arg_names": [], "import_names": ["gdal"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis import gdal"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:ImportFrom_L6_C0", "label": "from django.contrib.gis.measure import D", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.069, 0.0115, 0, 0.66, 0.5, 844, 0, 1, 0, 0, 844, 0, 0], "semantic": {"name": "django.contrib.gis.measure", "arg_names": [], "import_names": ["D"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.measure import D"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:ImportFrom_L7_C0", "label": "from django.test import TestCase", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0805, 0.0115, 0, 0.66, 0.6667, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.test", "arg_names": [], "import_names": ["TestCase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.test import TestCase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:ImportFrom_L8_C0", "label": "from models import City, County, Zipcode", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.092, 0.0115, 0, 0.66, 0.8333, 495, 0, 3, 0, 0, 495, 0, 0], "semantic": {"name": "models", "arg_names": [], "import_names": ["City", "County", "Zipcode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from models import City, County, Zipcode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "label": "GeographyTest", "type": "class", "loc": [10, 87], "level": 0, "parent": null, "vector": [3, 0, 0.5575, 0.8966, 0, 0.66, 1.0, 810, 0, 6, 0, 0, 3, 0, 39], "semantic": {"name": "GeographyTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GeographyTest(TestCase):\n\n def test01_fixture_load(self):\n \"Ensure geography features loaded properly.\"\n self.assertEqual(8, City.objects.count())\n\n def test02_distance_lookup(self):\n \"Testing GeoQuerySet distance lookup support on non-point geography fields.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L12_C4", "label": "test01_fixture_load", "type": "function", "loc": [12, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "vector": [2, 1, 0.1494, 0.0345, 1, 0.2, 0.0, 101, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test01_fixture_load", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test01_fixture_load(self):\n \"Ensure geography features loaded properly.\"\n self.assertEqual(8, City.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L13_C8", "label": "expression", "type": "expression", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L12_C4", "vector": [8, 2, 0.1494, 0.0115, 2, 0.54, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Ensure geography features loaded properly.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L14_C8", "label": "assertEqual()", "type": "expression", "loc": [14, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L12_C4", "vector": [8, 2, 0.1609, 0.0115, 2, 0.54, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(8, City.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L16_C4", "label": "test02_distance_lookup", "type": "function", "loc": [16, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "vector": [2, 1, 0.2529, 0.1494, 1, 0.2, 0.2, 46, 0, 1, 0, 0, 0, 0, 12], "semantic": {"name": "test02_distance_lookup", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test02_distance_lookup(self):\n \"Testing GeoQuerySet distance lookup support on non-point geography fields.\"\n z = Zipcode.objects.get(code='77002')\n cities1 = list(City.objects\n .filter(point__distance_lte=(z.poly, D(mi=500)))\n .order_by('name')\n .values_list('name', flat=True))\n cities2 = list(City.objects"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L17_C8", "label": "expression", "type": "expression", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L16_C4", "vector": [8, 2, 0.1954, 0.0115, 2, 0.18, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing GeoQuerySet distance lookup support on non-point geography fields.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L18_C8", "label": "z = get()", "type": "assigned_variable", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L16_C4", "vector": [14, 2, 0.2069, 0.0115, 2, 0.18, 0.25, 859, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "z", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " z = Zipcode.objects.get(code='77002')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L19_C8", "label": "cities1 = list()", "type": "assigned_variable", "loc": [19, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L16_C4", "vector": [14, 2, 0.2356, 0.046, 2, 0.18, 0.5, 302, 3, 1, 0, 0, 430, 10, 5], "semantic": {"name": "cities1", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " cities1 = list(City.objects\n .filter(point__distance_lte=(z.poly, D(mi=500)))\n .order_by('name')\n .values_list('name', flat=True))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L23_C8", "label": "cities2 = list()", "type": "assigned_variable", "loc": [23, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L16_C4", "vector": [14, 2, 0.2816, 0.046, 2, 0.18, 0.75, 798, 3, 1, 0, 0, 430, 10, 5], "semantic": {"name": "cities2", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " cities2 = list(City.objects\n .filter(point__dwithin=(z.poly, D(mi=500)))\n .order_by('name')\n .values_list('name', flat=True))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L27_C8", "label": "for cities", "type": "for", "loc": [27, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L16_C4", "vector": [6, 2, 0.3161, 0.023, 2, 0.18, 1.0, 884, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "cities", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for cities in [cities1, cities2]:\n self.assertEqual(['Dallas', 'Houston', 'Oklahoma City'], cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L28_C12", "label": "assertEqual()", "type": "expression", "loc": [28, 28], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L27_C8", "vector": [8, 3, 0.3218, 0.0115, 3, 0.26, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(['Dallas', 'Houston', 'Oklahoma City'], cities)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L30_C4", "label": "test03_distance_method", "type": "function", "loc": [30, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "vector": [2, 1, 0.3678, 0.0575, 1, 0.2, 0.4, 305, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test03_distance_method", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test03_distance_method(self):\n \"Testing GeoQuerySet.distance() support on non-point geography fields.\"\n # `GeoQuerySet.distance` is not allowed geometry fields.\n htown = City.objects.get(name='Houston')\n qs = Zipcode.objects.distance(htown.point)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L31_C8", "label": "expression", "type": "expression", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L30_C4", "vector": [8, 2, 0.3563, 0.0115, 2, 0.65, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing GeoQuerySet.distance() support on non-point geography fields.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L33_C8", "label": "htown = get()", "type": "assigned_variable", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L30_C4", "vector": [14, 2, 0.3793, 0.0115, 2, 0.65, 0.5, 968, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "htown", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " htown = City.objects.get(name='Houston')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L34_C8", "label": "qs = distance()", "type": "assigned_variable", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L30_C4", "vector": [14, 2, 0.3908, 0.0115, 2, 0.65, 1.0, 251, 3, 1, 0, 0, 145, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "distance", "annotation": ""}, "snippet": " qs = Zipcode.objects.distance(htown.point)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "label": "test04_invalid_operators_functions", "type": "function", "loc": [36, 49], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "vector": [2, 1, 0.4885, 0.1609, 1, 0.2, 0.6, 592, 0, 1, 0, 0, 0, 0, 7], "semantic": {"name": "test04_invalid_operators_functions", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test04_invalid_operators_functions(self):\n \"Ensuring exceptions are raised for operators & functions invalid on geography fields.\"\n # Only a subset of the geometry functions & operator are available\n # to PostGIS geography types. For more information, visit:\n # http://postgis.refractions.net/documentation/manual-1.5/ch08.html#PostGIS_GeographyFunctions\n z = Zipcode.objects.get(code='77002')\n # ST_Within not available.\n self.assertRaises(ValueError, City.objects.filter(point__within=z.poly).count)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L37_C8", "label": "expression", "type": "expression", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "vector": [8, 2, 0.4253, 0.0115, 2, 0.36, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Ensuring exceptions are raised for operators & functions invalid on geography fields.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L41_C8", "label": "z = get()", "type": "assigned_variable", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "vector": [14, 2, 0.4713, 0.0115, 2, 0.36, 0.2, 859, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "z", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " z = Zipcode.objects.get(code='77002')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L43_C8", "label": "assertRaises()", "type": "expression", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "vector": [8, 2, 0.4943, 0.0115, 2, 0.36, 0.4, 11, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, City.objects.filter(point__within=z.poly).count)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L45_C8", "label": "assertRaises()", "type": "expression", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "vector": [8, 2, 0.5172, 0.0115, 2, 0.36, 0.6, 11, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, City.objects.filter(point__contained=z.poly).count)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L48_C8", "label": "htown = get()", "type": "assigned_variable", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "vector": [14, 2, 0.5517, 0.0115, 2, 0.36, 0.8, 968, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "htown", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " htown = City.objects.get(name='Houston')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L49_C8", "label": "assertRaises()", "type": "expression", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "vector": [8, 2, 0.5632, 0.0115, 2, 0.36, 1.0, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(ValueError, City.objects.get, point__exact=htown.point)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "label": "test05_geography_layermapping", "type": "function", "loc": [51, 78], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "vector": [2, 1, 0.7414, 0.3218, 1, 0.2, 0.8, 439, 0, 1, 0, 0, 0, 0, 13], "semantic": {"name": "test05_geography_layermapping", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test05_geography_layermapping(self):\n \"Testing LayerMapping support on models with geography fields.\"\n # There is a similar test in `layermap` that uses the same data set,\n # but the County model here is a bit different.\n if not gdal.HAS_GDAL: return\n from django.contrib.gis.utils import LayerMapping\n\n # Getting the shapefile and mapping dictionary."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L52_C8", "label": "expression", "type": "expression", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "vector": [8, 2, 0.5977, 0.0115, 2, 0.36, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing LayerMapping support on models with geography fields.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:If_L55_C8", "label": "if", "type": "if", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "vector": [4, 2, 0.6322, 0.0115, 2, 0.36, 0.0909, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not gdal.HAS_GDAL: return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Return_L55_C30", "label": "return", "type": "return", "loc": [55, 55], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:If_L55_C8", "vector": [13, 3, 0.6322, 0.0115, 3, 0.13, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not gdal.HAS_GDAL: return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:ImportFrom_L56_C8", "label": "from django.contrib.gis.utils import LayerMapping", "type": "import", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "vector": [1, 2, 0.6437, 0.0115, 2, 0.36, 0.1818, 917, 0, 1, 0, 0, 917, 0, 0], "semantic": {"name": "django.contrib.gis.utils", "arg_names": [], "import_names": ["LayerMapping"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.gis.utils import LayerMapping"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L59_C8", "label": "shp_path = realpath()", "type": "assigned_variable", "loc": [59, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "vector": [14, 2, 0.6782, 0.0115, 2, 0.36, 0.2727, 782, 3, 1, 0, 0, 45, 10, 3], "semantic": {"name": "shp_path", "arg_names": [], "import_names": [], "rhs_call_name": "realpath", "annotation": ""}, "snippet": " shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L60_C8", "label": "co_shp = join()", "type": "assigned_variable", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "vector": [14, 2, 0.6897, 0.0115, 2, 0.36, 0.3636, 329, 3, 3, 0, 0, 933, 10, 1], "semantic": {"name": "co_shp", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " co_shp = os.path.join(shp_path, 'counties', 'counties.shp')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L61_C8", "label": "co_mapping =", "type": "assigned_variable", "loc": [61, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "vector": [14, 2, 0.7184, 0.046, 2, 0.36, 0.4545, 918, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "co_mapping", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " co_mapping = {'name' : 'Name',\n 'state' : 'State',\n 'mpoly' : 'MULTIPOLYGON',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L67_C8", "label": "names =", "type": "assigned_variable", "loc": [67, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "vector": [14, 2, 0.7701, 0.0115, 2, 0.36, 0.5455, 382, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "names", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " names = ['Bexar', 'Galveston', 'Harris', 'Honolulu', 'Pueblo']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L68_C8", "label": "num_polys =", "type": "assigned_variable", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "vector": [14, 2, 0.7816, 0.0115, 2, 0.36, 0.6364, 632, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "num_polys", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " num_polys = [1, 2, 1, 19, 1] # Number of polygons for each."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L69_C8", "label": "st_names =", "type": "assigned_variable", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "vector": [14, 2, 0.7931, 0.0115, 2, 0.36, 0.7273, 569, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "st_names", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " st_names = ['Texas', 'Texas', 'Texas', 'Hawaii', 'Colorado']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L71_C8", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "vector": [14, 2, 0.8161, 0.0115, 2, 0.36, 0.8182, 376, 3, 5, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(County, co_shp, co_mapping, source_srs=4269, unique='name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L72_C8", "label": "save()", "type": "expression", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "vector": [8, 2, 0.8276, 0.0115, 2, 0.36, 0.9091, 928, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save(silent=True, strict=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L74_C8", "label": "for c, name, num_poly, state", "type": "for", "loc": [74, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "vector": [6, 2, 0.8736, 0.0575, 2, 0.36, 1.0, 934, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "c, name, num_poly, state", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c, name, num_poly, state in zip(County.objects.order_by('name'), names, num_polys, st_names):\n self.assertEqual(4326, c.mpoly.srid)\n self.assertEqual(num_poly, len(c.mpoly))\n self.assertEqual(name, c.name)\n self.assertEqual(state, c.state)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L75_C12", "label": "assertEqual()", "type": "expression", "loc": [75, 75], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L74_C8", "vector": [8, 3, 0.8621, 0.0115, 3, 0.29, 0.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(4326, c.mpoly.srid)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L76_C12", "label": "assertEqual()", "type": "expression", "loc": [76, 76], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L74_C8", "vector": [8, 3, 0.8736, 0.0115, 3, 0.29, 0.3333, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(num_poly, len(c.mpoly))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L77_C12", "label": "assertEqual()", "type": "expression", "loc": [77, 77], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L74_C8", "vector": [8, 3, 0.8851, 0.0115, 3, 0.29, 0.6667, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(name, c.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L78_C12", "label": "assertEqual()", "type": "expression", "loc": [78, 78], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L74_C8", "vector": [8, 3, 0.8966, 0.0115, 3, 0.29, 1.0, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(state, c.state)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "label": "test06_geography_area", "type": "function", "loc": [80, 87], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "vector": [2, 1, 0.9598, 0.092, 1, 0.2, 1.0, 168, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "test06_geography_area", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test06_geography_area(self):\n \"Testing that Area calculations work on geography columns.\"\n from django.contrib.gis.measure import A\n # SELECT ST_Area(poly) FROM geogapp_zipcode WHERE code='77002';\n ref_area = 5439084.70637573\n tol = 5\n z = Zipcode.objects.area().get(code='77002')\n self.assertAlmostEqual(z.area.sq_m, ref_area, tol)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L81_C8", "label": "expression", "type": "expression", "loc": [81, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "vector": [8, 2, 0.931, 0.0115, 2, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing that Area calculations work on geography columns.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:ImportFrom_L82_C8", "label": "from django.contrib.gis.measure import A", "type": "import", "loc": [82, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "vector": [1, 2, 0.9425, 0.0115, 2, 0.66, 0.2, 844, 0, 1, 0, 0, 844, 0, 0], "semantic": {"name": "django.contrib.gis.measure", "arg_names": [], "import_names": ["A"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.gis.measure import A"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L84_C8", "label": "ref_area =", "type": "assigned_variable", "loc": [84, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "vector": [14, 2, 0.9655, 0.0115, 2, 0.66, 0.4, 462, 1, 0, 0, 0, 0, 2, 0], "semantic": {"name": "ref_area", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ref_area = 5439084.70637573"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L85_C8", "label": "tol =", "type": "assigned_variable", "loc": [85, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "vector": [14, 2, 0.977, 0.0115, 2, 0.66, 0.6, 422, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "tol", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tol = 5"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L86_C8", "label": "z = get()", "type": "assigned_variable", "loc": [86, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "vector": [14, 2, 0.9885, 0.0115, 2, 0.66, 0.8, 859, 3, 1, 0, 0, 607, 10, 2], "semantic": {"name": "z", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " z = Zipcode.objects.area().get(code='77002')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L87_C8", "label": "assertAlmostEqual()", "type": "expression", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "vector": [8, 2, 1.0, 0.0115, 2, 0.66, 1.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(z.area.sq_m, ref_area, tol)"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:If_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:If_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Return_L55_C30"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:ImportFrom_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L74_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L75_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L74_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L76_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L74_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L77_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:For_L74_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L81_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:ImportFrom_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Assign_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98688:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98688:Expr_L87_C8"}] |
from django.contrib.gis.db import models
class State(models.Model):
name = models.CharField(max_length=20)
objects = models.GeoManager()
class County(models.Model):
name = models.CharField(max_length=25)
state = models.ForeignKey(State)
mpoly = models.MultiPolygonField(srid=4269) # Multipolygon in NAD83
objects = models.GeoManager()
class CountyFeat(models.Model):
name = models.CharField(max_length=25)
poly = models.PolygonField(srid=4269)
objects = models.GeoManager()
class City(models.Model):
name = models.CharField(max_length=25)
population = models.IntegerField()
density = models.DecimalField(max_digits=7, decimal_places=1)
dt = models.DateField()
point = models.PointField()
objects = models.GeoManager()
class Interstate(models.Model):
name = models.CharField(max_length=20)
length = models.DecimalField(max_digits=6, decimal_places=2)
path = models.LineStringField()
objects = models.GeoManager()
# Same as `City` above, but for testing model inheritance.
class CityBase(models.Model):
name = models.CharField(max_length=25)
population = models.IntegerField()
density = models.DecimalField(max_digits=7, decimal_places=1)
point = models.PointField()
objects = models.GeoManager()
class ICity1(CityBase):
dt = models.DateField()
class ICity2(ICity1):
dt_time = models.DateTimeField(auto_now=True)
# Mapping dictionaries for the models above.
co_mapping = {'name' : 'Name',
'state' : {'name' : 'State'}, # ForeignKey's use another mapping dictionary for the _related_ Model (State in this case).
'mpoly' : 'MULTIPOLYGON', # Will convert POLYGON features into MULTIPOLYGONS.
}
cofeat_mapping = {'name' : 'Name',
'poly' : 'POLYGON',
}
city_mapping = {'name' : 'Name',
'population' : 'Population',
'density' : 'Density',
'dt' : 'Created',
'point' : 'POINT',
}
inter_mapping = {'name' : 'Name',
'length' : 'Length',
'path' : 'LINESTRING',
}
| ajibawa-2023/Python-Code-Large/train/row_98689 | 39 | 66 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98689:ImportFrom_L1_C0", "label": "from django.contrib.gis.db import models", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0152, 0.0152, 0, 0.66, 0.0, 964, 0, 1, 0, 0, 964, 0, 0], "semantic": {"name": "django.contrib.gis.db", "arg_names": [], "import_names": ["models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.db import models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L3_C0", "label": "State", "type": "class", "loc": [3, 5], "level": 0, "parent": null, "vector": [3, 0, 0.0606, 0.0455, 0, 0.66, 0.0833, 110, 0, 0, 0, 0, 996, 0, 2], "semantic": {"name": "State", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class State(models.Model):\n name = models.CharField(max_length=20)\n objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L4_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [4, 4], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L3_C0", "vector": [14, 1, 0.0606, 0.0152, 1, 0.01, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=20)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L5_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [5, 5], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L3_C0", "vector": [14, 1, 0.0758, 0.0152, 1, 0.01, 1.0, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L7_C0", "label": "County", "type": "class", "loc": [7, 11], "level": 0, "parent": null, "vector": [3, 0, 0.1364, 0.0758, 0, 0.66, 0.1667, 381, 0, 0, 0, 0, 996, 0, 4], "semantic": {"name": "County", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class County(models.Model):\n name = models.CharField(max_length=25)\n state = models.ForeignKey(State)\n mpoly = models.MultiPolygonField(srid=4269) # Multipolygon in NAD83\n objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L8_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L7_C0", "vector": [14, 1, 0.1212, 0.0152, 1, 0.24, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=25)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L9_C4", "label": "state = ForeignKey()", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L7_C0", "vector": [14, 1, 0.1364, 0.0152, 1, 0.24, 0.3333, 688, 3, 1, 0, 0, 140, 10, 1], "semantic": {"name": "state", "arg_names": [], "import_names": [], "rhs_call_name": "ForeignKey", "annotation": ""}, "snippet": " state = models.ForeignKey(State)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L10_C4", "label": "mpoly = MultiPolygonField()", "type": "assigned_variable", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L7_C0", "vector": [14, 1, 0.1515, 0.0152, 1, 0.24, 0.6667, 634, 3, 1, 0, 0, 682, 10, 1], "semantic": {"name": "mpoly", "arg_names": [], "import_names": [], "rhs_call_name": "MultiPolygonField", "annotation": ""}, "snippet": " mpoly = models.MultiPolygonField(srid=4269) # Multipolygon in NAD83"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L11_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L7_C0", "vector": [14, 1, 0.1667, 0.0152, 1, 0.24, 1.0, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L13_C0", "label": "CountyFeat", "type": "class", "loc": [13, 16], "level": 0, "parent": null, "vector": [3, 0, 0.2197, 0.0606, 0, 0.66, 0.25, 130, 0, 0, 0, 0, 996, 0, 3], "semantic": {"name": "CountyFeat", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CountyFeat(models.Model):\n name = models.CharField(max_length=25)\n poly = models.PolygonField(srid=4269)\n objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L14_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L13_C0", "vector": [14, 1, 0.2121, 0.0152, 1, 0.68, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=25)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L15_C4", "label": "poly = PolygonField()", "type": "assigned_variable", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L13_C0", "vector": [14, 1, 0.2273, 0.0152, 1, 0.68, 0.5, 365, 3, 1, 0, 0, 736, 10, 1], "semantic": {"name": "poly", "arg_names": [], "import_names": [], "rhs_call_name": "PolygonField", "annotation": ""}, "snippet": " poly = models.PolygonField(srid=4269)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L16_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L13_C0", "vector": [14, 1, 0.2424, 0.0152, 1, 0.68, 1.0, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "label": "City", "type": "class", "loc": [18, 24], "level": 0, "parent": null, "vector": [3, 0, 0.3182, 0.1061, 0, 0.66, 0.3333, 801, 0, 0, 0, 0, 996, 0, 6], "semantic": {"name": "City", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class City(models.Model):\n name = models.CharField(max_length=25)\n population = models.IntegerField()\n density = models.DecimalField(max_digits=7, decimal_places=1)\n dt = models.DateField()\n point = models.PointField()\n objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L19_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "vector": [14, 1, 0.2879, 0.0152, 1, 0.74, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=25)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L20_C4", "label": "population = IntegerField()", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "vector": [14, 1, 0.303, 0.0152, 1, 0.74, 0.2, 518, 3, 0, 0, 0, 877, 10, 1], "semantic": {"name": "population", "arg_names": [], "import_names": [], "rhs_call_name": "IntegerField", "annotation": ""}, "snippet": " population = models.IntegerField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L21_C4", "label": "density = DecimalField()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "vector": [14, 1, 0.3182, 0.0152, 1, 0.74, 0.4, 830, 3, 2, 0, 0, 888, 10, 1], "semantic": {"name": "density", "arg_names": [], "import_names": [], "rhs_call_name": "DecimalField", "annotation": ""}, "snippet": " density = models.DecimalField(max_digits=7, decimal_places=1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L22_C4", "label": "dt = DateField()", "type": "assigned_variable", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "vector": [14, 1, 0.3333, 0.0152, 1, 0.74, 0.6, 455, 3, 0, 0, 0, 847, 10, 1], "semantic": {"name": "dt", "arg_names": [], "import_names": [], "rhs_call_name": "DateField", "annotation": ""}, "snippet": " dt = models.DateField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L23_C4", "label": "point = PointField()", "type": "assigned_variable", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "vector": [14, 1, 0.3485, 0.0152, 1, 0.74, 0.8, 16, 3, 0, 0, 0, 260, 10, 1], "semantic": {"name": "point", "arg_names": [], "import_names": [], "rhs_call_name": "PointField", "annotation": ""}, "snippet": " point = models.PointField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L24_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [24, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "vector": [14, 1, 0.3636, 0.0152, 1, 0.74, 1.0, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L26_C0", "label": "Interstate", "type": "class", "loc": [26, 30], "level": 0, "parent": null, "vector": [3, 0, 0.4242, 0.0758, 0, 0.66, 0.4167, 128, 0, 0, 0, 0, 996, 0, 4], "semantic": {"name": "Interstate", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Interstate(models.Model):\n name = models.CharField(max_length=20)\n length = models.DecimalField(max_digits=6, decimal_places=2)\n path = models.LineStringField()\n objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L27_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [27, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L26_C0", "vector": [14, 1, 0.4091, 0.0152, 1, 0.52, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=20)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L28_C4", "label": "length = DecimalField()", "type": "assigned_variable", "loc": [28, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L26_C0", "vector": [14, 1, 0.4242, 0.0152, 1, 0.52, 0.3333, 221, 3, 2, 0, 0, 888, 10, 1], "semantic": {"name": "length", "arg_names": [], "import_names": [], "rhs_call_name": "DecimalField", "annotation": ""}, "snippet": " length = models.DecimalField(max_digits=6, decimal_places=2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L29_C4", "label": "path = LineStringField()", "type": "assigned_variable", "loc": [29, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L26_C0", "vector": [14, 1, 0.4394, 0.0152, 1, 0.52, 0.6667, 358, 3, 0, 0, 0, 237, 10, 1], "semantic": {"name": "path", "arg_names": [], "import_names": [], "rhs_call_name": "LineStringField", "annotation": ""}, "snippet": " path = models.LineStringField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L30_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [30, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L26_C0", "vector": [14, 1, 0.4545, 0.0152, 1, 0.52, 1.0, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L33_C0", "label": "CityBase", "type": "class", "loc": [33, 38], "level": 0, "parent": null, "vector": [3, 0, 0.5379, 0.0909, 0, 0.66, 0.5, 652, 0, 0, 0, 0, 996, 0, 5], "semantic": {"name": "CityBase", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CityBase(models.Model):\n name = models.CharField(max_length=25)\n population = models.IntegerField()\n density = models.DecimalField(max_digits=7, decimal_places=1)\n point = models.PointField()\n objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L34_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [34, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L33_C0", "vector": [14, 1, 0.5152, 0.0152, 1, 0.22, 0.0, 57, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = models.CharField(max_length=25)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L35_C4", "label": "population = IntegerField()", "type": "assigned_variable", "loc": [35, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L33_C0", "vector": [14, 1, 0.5303, 0.0152, 1, 0.22, 0.25, 518, 3, 0, 0, 0, 877, 10, 1], "semantic": {"name": "population", "arg_names": [], "import_names": [], "rhs_call_name": "IntegerField", "annotation": ""}, "snippet": " population = models.IntegerField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L36_C4", "label": "density = DecimalField()", "type": "assigned_variable", "loc": [36, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L33_C0", "vector": [14, 1, 0.5455, 0.0152, 1, 0.22, 0.5, 830, 3, 2, 0, 0, 888, 10, 1], "semantic": {"name": "density", "arg_names": [], "import_names": [], "rhs_call_name": "DecimalField", "annotation": ""}, "snippet": " density = models.DecimalField(max_digits=7, decimal_places=1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L37_C4", "label": "point = PointField()", "type": "assigned_variable", "loc": [37, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L33_C0", "vector": [14, 1, 0.5606, 0.0152, 1, 0.22, 0.75, 16, 3, 0, 0, 0, 260, 10, 1], "semantic": {"name": "point", "arg_names": [], "import_names": [], "rhs_call_name": "PointField", "annotation": ""}, "snippet": " point = models.PointField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L38_C4", "label": "objects = GeoManager()", "type": "assigned_variable", "loc": [38, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L33_C0", "vector": [14, 1, 0.5758, 0.0152, 1, 0.22, 1.0, 550, 3, 0, 0, 0, 665, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "GeoManager", "annotation": ""}, "snippet": " objects = models.GeoManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L40_C0", "label": "ICity1", "type": "class", "loc": [40, 41], "level": 0, "parent": null, "vector": [3, 0, 0.6136, 0.0303, 0, 0.66, 0.5833, 158, 0, 0, 0, 0, 652, 0, 1], "semantic": {"name": "ICity1", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ICity1(CityBase):\n dt = models.DateField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L41_C4", "label": "dt = DateField()", "type": "assigned_variable", "loc": [41, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L40_C0", "vector": [14, 1, 0.6212, 0.0152, 1, 0.83, 0.0, 455, 3, 0, 0, 0, 847, 10, 1], "semantic": {"name": "dt", "arg_names": [], "import_names": [], "rhs_call_name": "DateField", "annotation": ""}, "snippet": " dt = models.DateField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L43_C0", "label": "ICity2", "type": "class", "loc": [43, 44], "level": 0, "parent": null, "vector": [3, 0, 0.6591, 0.0303, 0, 0.66, 0.6667, 258, 0, 0, 0, 0, 158, 0, 1], "semantic": {"name": "ICity2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ICity2(ICity1):\n dt_time = models.DateTimeField(auto_now=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L44_C4", "label": "dt_time = DateTimeField()", "type": "assigned_variable", "loc": [44, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L43_C0", "vector": [14, 1, 0.6667, 0.0152, 1, 0.57, 0.0, 958, 3, 1, 0, 0, 789, 10, 1], "semantic": {"name": "dt_time", "arg_names": [], "import_names": [], "rhs_call_name": "DateTimeField", "annotation": ""}, "snippet": " dt_time = models.DateTimeField(auto_now=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L47_C0", "label": "co_mapping =", "type": "assigned_variable", "loc": [47, 50], "level": 0, "parent": null, "vector": [14, 0, 0.7348, 0.0606, 0, 0.66, 0.75, 918, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "co_mapping", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "co_mapping = {'name' : 'Name',\n 'state' : {'name' : 'State'}, # ForeignKey's use another mapping dictionary for the _related_ Model (State in this case).\n 'mpoly' : 'MULTIPOLYGON', # Will convert POLYGON features into MULTIPOLYGONS.\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L52_C0", "label": "cofeat_mapping =", "type": "assigned_variable", "loc": [52, 54], "level": 0, "parent": null, "vector": [14, 0, 0.803, 0.0455, 0, 0.66, 0.8333, 671, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "cofeat_mapping", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "cofeat_mapping = {'name' : 'Name',\n 'poly' : 'POLYGON',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L56_C0", "label": "city_mapping =", "type": "assigned_variable", "loc": [56, 61], "level": 0, "parent": null, "vector": [14, 0, 0.8864, 0.0909, 0, 0.66, 0.9167, 698, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "city_mapping", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "city_mapping = {'name' : 'Name',\n 'population' : 'Population',\n 'density' : 'Density',\n 'dt' : 'Created',\n 'point' : 'POINT',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L63_C0", "label": "inter_mapping =", "type": "assigned_variable", "loc": [63, 66], "level": 0, "parent": null, "vector": [14, 0, 0.9773, 0.0606, 0, 0.66, 1.0, 167, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "inter_mapping", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "inter_mapping = {'name' : 'Name',\n 'length' : 'Length',\n 'path' : 'LINESTRING',\n }"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L35_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L40_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98689:ClassDef_L43_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98689:Assign_L44_C4"}] |
import os
from decimal import Decimal
from django.utils import unittest
from django.utils.copycompat import copy
from django.contrib.gis.gdal import DataSource
from django.contrib.gis.tests.utils import mysql
from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError, InvalidDecimal, MissingForeignKey
from models import City, County, CountyFeat, Interstate, ICity1, ICity2, State, city_mapping, co_mapping, cofeat_mapping, inter_mapping
shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))
city_shp = os.path.join(shp_path, 'cities', 'cities.shp')
co_shp = os.path.join(shp_path, 'counties', 'counties.shp')
inter_shp = os.path.join(shp_path, 'interstates', 'interstates.shp')
# Dictionaries to hold what's expected in the county shapefile.
NAMES = ['Bexar', 'Galveston', 'Harris', 'Honolulu', 'Pueblo']
NUMS = [1, 2, 1, 19, 1] # Number of polygons for each.
STATES = ['Texas', 'Texas', 'Texas', 'Hawaii', 'Colorado']
class LayerMapTest(unittest.TestCase):
def test01_init(self):
"Testing LayerMapping initialization."
# Model field that does not exist.
bad1 = copy(city_mapping)
bad1['foobar'] = 'FooField'
# Shapefile field that does not exist.
bad2 = copy(city_mapping)
bad2['name'] = 'Nombre'
# Nonexistent geographic field type.
bad3 = copy(city_mapping)
bad3['point'] = 'CURVE'
# Incrementing through the bad mapping dictionaries and
# ensuring that a LayerMapError is raised.
for bad_map in (bad1, bad2, bad3):
try:
lm = LayerMapping(City, city_shp, bad_map)
except LayerMapError:
pass
else:
self.fail('Expected a LayerMapError.')
# A LookupError should be thrown for bogus encodings.
try:
lm = LayerMapping(City, city_shp, city_mapping, encoding='foobar')
except LookupError:
pass
else:
self.fail('Expected a LookupError')
def test02_simple_layermap(self):
"Test LayerMapping import of a simple point shapefile."
# Setting up for the LayerMapping.
lm = LayerMapping(City, city_shp, city_mapping)
lm.save()
# There should be three cities in the shape file.
self.assertEqual(3, City.objects.count())
# Opening up the shapefile, and verifying the values in each
# of the features made it to the model.
ds = DataSource(city_shp)
layer = ds[0]
for feat in layer:
city = City.objects.get(name=feat['Name'].value)
self.assertEqual(feat['Population'].value, city.population)
self.assertEqual(Decimal(str(feat['Density'])), city.density)
self.assertEqual(feat['Created'].value, city.dt)
# Comparing the geometries.
pnt1, pnt2 = feat.geom, city.point
self.assertAlmostEqual(pnt1.x, pnt2.x, 6)
self.assertAlmostEqual(pnt1.y, pnt2.y, 6)
def test03_layermap_strict(self):
"Testing the `strict` keyword, and import of a LineString shapefile."
# When the `strict` keyword is set an error encountered will force
# the importation to stop.
try:
lm = LayerMapping(Interstate, inter_shp, inter_mapping)
lm.save(silent=True, strict=True)
except InvalidDecimal:
# No transactions for geoms on MySQL; delete added features.
if mysql: Interstate.objects.all().delete()
else:
self.fail('Should have failed on strict import with invalid decimal values.')
# This LayerMapping should work b/c `strict` is not set.
lm = LayerMapping(Interstate, inter_shp, inter_mapping)
lm.save(silent=True)
# Two interstate should have imported correctly.
self.assertEqual(2, Interstate.objects.count())
# Verifying the values in the layer w/the model.
ds = DataSource(inter_shp)
# Only the first two features of this shapefile are valid.
valid_feats = ds[0][:2]
for feat in valid_feats:
istate = Interstate.objects.get(name=feat['Name'].value)
if feat.fid == 0:
self.assertEqual(Decimal(str(feat['Length'])), istate.length)
elif feat.fid == 1:
# Everything but the first two decimal digits were truncated,
# because the Interstate model's `length` field has decimal_places=2.
self.assertAlmostEqual(feat.get('Length'), float(istate.length), 2)
for p1, p2 in zip(feat.geom, istate.path):
self.assertAlmostEqual(p1[0], p2[0], 6)
self.assertAlmostEqual(p1[1], p2[1], 6)
def county_helper(self, county_feat=True):
"Helper function for ensuring the integrity of the mapped County models."
for name, n, st in zip(NAMES, NUMS, STATES):
# Should only be one record b/c of `unique` keyword.
c = County.objects.get(name=name)
self.assertEqual(n, len(c.mpoly))
self.assertEqual(st, c.state.name) # Checking ForeignKey mapping.
# Multiple records because `unique` was not set.
if county_feat:
qs = CountyFeat.objects.filter(name=name)
self.assertEqual(n, qs.count())
def test04_layermap_unique_multigeometry_fk(self):
"Testing the `unique`, and `transform`, geometry collection conversion, and ForeignKey mappings."
# All the following should work.
try:
# Telling LayerMapping that we want no transformations performed on the data.
lm = LayerMapping(County, co_shp, co_mapping, transform=False)
# Specifying the source spatial reference system via the `source_srs` keyword.
lm = LayerMapping(County, co_shp, co_mapping, source_srs=4269)
lm = LayerMapping(County, co_shp, co_mapping, source_srs='NAD83')
# Unique may take tuple or string parameters.
for arg in ('name', ('name', 'mpoly')):
lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique=arg)
except:
self.fail('No exception should be raised for proper use of keywords.')
# Testing invalid params for the `unique` keyword.
for e, arg in ((TypeError, 5.0), (ValueError, 'foobar'), (ValueError, ('name', 'mpolygon'))):
self.assertRaises(e, LayerMapping, County, co_shp, co_mapping, transform=False, unique=arg)
# No source reference system defined in the shapefile, should raise an error.
if not mysql:
self.assertRaises(LayerMapError, LayerMapping, County, co_shp, co_mapping)
# Passing in invalid ForeignKey mapping parameters -- must be a dictionary
# mapping for the model the ForeignKey points to.
bad_fk_map1 = copy(co_mapping); bad_fk_map1['state'] = 'name'
bad_fk_map2 = copy(co_mapping); bad_fk_map2['state'] = {'nombre' : 'State'}
self.assertRaises(TypeError, LayerMapping, County, co_shp, bad_fk_map1, transform=False)
self.assertRaises(LayerMapError, LayerMapping, County, co_shp, bad_fk_map2, transform=False)
# There exist no State models for the ForeignKey mapping to work -- should raise
# a MissingForeignKey exception (this error would be ignored if the `strict`
# keyword is not set).
lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique='name')
self.assertRaises(MissingForeignKey, lm.save, silent=True, strict=True)
# Now creating the state models so the ForeignKey mapping may work.
co, hi, tx = State(name='Colorado'), State(name='Hawaii'), State(name='Texas')
co.save(), hi.save(), tx.save()
# If a mapping is specified as a collection, all OGR fields that
# are not collections will be converted into them. For example,
# a Point column would be converted to MultiPoint. Other things being done
# w/the keyword args:
# `transform=False`: Specifies that no transform is to be done; this
# has the effect of ignoring the spatial reference check (because the
# county shapefile does not have implicit spatial reference info).
#
# `unique='name'`: Creates models on the condition that they have
# unique county names; geometries from each feature however will be
# appended to the geometry collection of the unique model. Thus,
# all of the various islands in Honolulu county will be in in one
# database record with a MULTIPOLYGON type.
lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique='name')
lm.save(silent=True, strict=True)
# A reference that doesn't use the unique keyword; a new database record will
# created for each polygon.
lm = LayerMapping(CountyFeat, co_shp, cofeat_mapping, transform=False)
lm.save(silent=True, strict=True)
# The county helper is called to ensure integrity of County models.
self.county_helper()
def test05_test_fid_range_step(self):
"Tests the `fid_range` keyword and the `step` keyword of .save()."
# Function for clearing out all the counties before testing.
def clear_counties(): County.objects.all().delete()
# Initializing the LayerMapping object to use in these tests.
lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique='name')
# Bad feature id ranges should raise a type error.
clear_counties()
bad_ranges = (5.0, 'foo', co_shp)
for bad in bad_ranges:
self.assertRaises(TypeError, lm.save, fid_range=bad)
# Step keyword should not be allowed w/`fid_range`.
fr = (3, 5) # layer[3:5]
self.assertRaises(LayerMapError, lm.save, fid_range=fr, step=10)
lm.save(fid_range=fr)
# Features IDs 3 & 4 are for Galveston County, Texas -- only
# one model is returned because the `unique` keyword was set.
qs = County.objects.all()
self.assertEqual(1, qs.count())
self.assertEqual('Galveston', qs[0].name)
# Features IDs 5 and beyond for Honolulu County, Hawaii, and
# FID 0 is for Pueblo County, Colorado.
clear_counties()
lm.save(fid_range=slice(5, None), silent=True, strict=True) # layer[5:]
lm.save(fid_range=slice(None, 1), silent=True, strict=True) # layer[:1]
# Only Pueblo & Honolulu counties should be present because of
# the `unique` keyword. Have to set `order_by` on this QuerySet
# or else MySQL will return a different ordering than the other dbs.
qs = County.objects.order_by('name')
self.assertEqual(2, qs.count())
hi, co = tuple(qs)
hi_idx, co_idx = tuple(map(NAMES.index, ('Honolulu', 'Pueblo')))
self.assertEqual('Pueblo', co.name); self.assertEqual(NUMS[co_idx], len(co.mpoly))
self.assertEqual('Honolulu', hi.name); self.assertEqual(NUMS[hi_idx], len(hi.mpoly))
# Testing the `step` keyword -- should get the same counties
# regardless of we use a step that divides equally, that is odd,
# or that is larger than the dataset.
for st in (4,7,1000):
clear_counties()
lm.save(step=st, strict=True)
self.county_helper(county_feat=False)
def test06_model_inheritance(self):
"Tests LayerMapping on inherited models. See #12093."
icity_mapping = {'name' : 'Name',
'population' : 'Population',
'density' : 'Density',
'point' : 'POINT',
'dt' : 'Created',
}
# Parent model has geometry field.
lm1 = LayerMapping(ICity1, city_shp, icity_mapping)
lm1.save()
# Grandparent has geometry field.
lm2 = LayerMapping(ICity2, city_shp, icity_mapping)
lm2.save()
self.assertEqual(6, ICity1.objects.count())
self.assertEqual(3, ICity2.objects.count())
def suite():
s = unittest.TestSuite()
s.addTest(unittest.makeSuite(LayerMapTest))
return s
| ajibawa-2023/Python-Code-Large/train/row_98690 | 148 | 272 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Import_L1_C0", "label": "os import os", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0037, 0.0037, 0, 0.66, 0.0, 688, 0, 1, 0, 0, 688, 0, 0], "semantic": {"name": "os", "arg_names": [], "import_names": ["os"], "rhs_call_name": "", "annotation": ""}, "snippet": "import os"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:ImportFrom_L2_C0", "label": "from decimal import Decimal", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0074, 0.0037, 0, 0.66, 0.0625, 349, 0, 1, 0, 0, 349, 0, 0], "semantic": {"name": "decimal", "arg_names": [], "import_names": ["Decimal"], "rhs_call_name": "", "annotation": ""}, "snippet": "from decimal import Decimal"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:ImportFrom_L4_C0", "label": "from django.utils import unittest", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0147, 0.0037, 0, 0.66, 0.125, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["unittest"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import unittest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:ImportFrom_L5_C0", "label": "from django.utils.copycompat import copy", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0184, 0.0037, 0, 0.66, 0.1875, 125, 0, 1, 0, 0, 125, 0, 0], "semantic": {"name": "django.utils.copycompat", "arg_names": [], "import_names": ["copy"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.copycompat import copy"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:ImportFrom_L7_C0", "label": "from django.contrib.gis.gdal import DataSource", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0257, 0.0037, 0, 0.66, 0.25, 793, 0, 1, 0, 0, 793, 0, 0], "semantic": {"name": "django.contrib.gis.gdal", "arg_names": [], "import_names": ["DataSource"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.gdal import DataSource"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:ImportFrom_L8_C0", "label": "from django.contrib.gis.tests.utils import mysql", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0294, 0.0037, 0, 0.66, 0.3125, 185, 0, 1, 0, 0, 185, 0, 0], "semantic": {"name": "django.contrib.gis.tests.utils", "arg_names": [], "import_names": ["mysql"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.tests.utils import mysql"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:ImportFrom_L9_C0", "label": "from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError, InvalidDecimal\u2026", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0331, 0.0037, 0, 0.66, 0.375, 741, 0, 4, 0, 0, 741, 0, 0], "semantic": {"name": "django.contrib.gis.utils.layermapping", "arg_names": [], "import_names": ["LayerMapping", "LayerMapError", "InvalidDecimal", "MissingForeignKey"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError, InvalidDecimal, MissingForeignKey"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:ImportFrom_L11_C0", "label": "from models import City, County, CountyFeat\u2026", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0404, 0.0037, 0, 0.66, 0.4375, 495, 0, 11, 0, 0, 495, 0, 0], "semantic": {"name": "models", "arg_names": [], "import_names": ["City", "County", "CountyFeat", "Interstate", "ICity1", "ICity2", "State", "city_mapping", "co_mapping", "cofeat_mapping", "inter_mapping"], "rhs_call_name": "", "annotation": ""}, "snippet": "from models import City, County, CountyFeat, Interstate, ICity1, ICity2, State, city_mapping, co_mapping, cofeat_mapping, inter_mapping"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L13_C0", "label": "shp_path = realpath()", "type": "assigned_variable", "loc": [13, 13], "level": 0, "parent": null, "vector": [14, 0, 0.0478, 0.0037, 0, 0.66, 0.5, 782, 3, 1, 0, 0, 45, 10, 3], "semantic": {"name": "shp_path", "arg_names": [], "import_names": [], "rhs_call_name": "realpath", "annotation": ""}, "snippet": "shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L14_C0", "label": "city_shp = join()", "type": "assigned_variable", "loc": [14, 14], "level": 0, "parent": null, "vector": [14, 0, 0.0515, 0.0037, 0, 0.66, 0.5625, 2, 3, 3, 0, 0, 933, 10, 1], "semantic": {"name": "city_shp", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": "city_shp = os.path.join(shp_path, 'cities', 'cities.shp')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L15_C0", "label": "co_shp = join()", "type": "assigned_variable", "loc": [15, 15], "level": 0, "parent": null, "vector": [14, 0, 0.0551, 0.0037, 0, 0.66, 0.625, 329, 3, 3, 0, 0, 933, 10, 1], "semantic": {"name": "co_shp", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": "co_shp = os.path.join(shp_path, 'counties', 'counties.shp')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L16_C0", "label": "inter_shp = join()", "type": "assigned_variable", "loc": [16, 16], "level": 0, "parent": null, "vector": [14, 0, 0.0588, 0.0037, 0, 0.66, 0.6875, 930, 3, 3, 0, 0, 933, 10, 1], "semantic": {"name": "inter_shp", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": "inter_shp = os.path.join(shp_path, 'interstates', 'interstates.shp')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L19_C0", "label": "NAMES =", "type": "assigned_variable", "loc": [19, 19], "level": 0, "parent": null, "vector": [14, 0, 0.0699, 0.0037, 0, 0.66, 0.75, 927, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "NAMES", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "NAMES = ['Bexar', 'Galveston', 'Harris', 'Honolulu', 'Pueblo']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L20_C0", "label": "NUMS =", "type": "assigned_variable", "loc": [20, 20], "level": 0, "parent": null, "vector": [14, 0, 0.0735, 0.0037, 0, 0.66, 0.8125, 197, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "NUMS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "NUMS = [1, 2, 1, 19, 1] # Number of polygons for each."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L21_C0", "label": "STATES =", "type": "assigned_variable", "loc": [21, 21], "level": 0, "parent": null, "vector": [14, 0, 0.0772, 0.0037, 0, 0.66, 0.875, 716, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "STATES", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "STATES = ['Texas', 'Texas', 'Texas', 'Hawaii', 'Colorado']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "label": "LayerMapTest", "type": "class", "loc": [23, 267], "level": 0, "parent": null, "vector": [3, 0, 0.5331, 0.9007, 0, 0.66, 0.9375, 535, 0, 8, 0, 0, 878, 0, 99], "semantic": {"name": "LayerMapTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class LayerMapTest(unittest.TestCase):\n\n def test01_init(self):\n \"Testing LayerMapping initialization.\"\n\n # Model field that does not exist.\n bad1 = copy(city_mapping)\n bad1['foobar'] = 'FooField'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "label": "test01_init", "type": "function", "loc": [25, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "vector": [2, 1, 0.1489, 0.1176, 1, 0.17, 0.0, 64, 0, 1, 0, 0, 0, 0, 7], "semantic": {"name": "test01_init", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test01_init(self):\n \"Testing LayerMapping initialization.\"\n\n # Model field that does not exist.\n bad1 = copy(city_mapping)\n bad1['foobar'] = 'FooField'\n\n # Shapefile field that does not exist."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L26_C8", "label": "expression", "type": "expression", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "vector": [8, 2, 0.0956, 0.0037, 2, 0.77, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing LayerMapping initialization.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L29_C8", "label": "bad1 = copy()", "type": "assigned_variable", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "vector": [14, 2, 0.1066, 0.0037, 2, 0.77, 0.125, 743, 3, 1, 0, 0, 739, 10, 1], "semantic": {"name": "bad1", "arg_names": [], "import_names": [], "rhs_call_name": "copy", "annotation": ""}, "snippet": " bad1 = copy(city_mapping)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L30_C8", "label": "assign", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "vector": [14, 2, 0.1103, 0.0037, 2, 0.77, 0.25, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " bad1['foobar'] = 'FooField'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L33_C8", "label": "bad2 = copy()", "type": "assigned_variable", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "vector": [14, 2, 0.1213, 0.0037, 2, 0.77, 0.375, 611, 3, 1, 0, 0, 739, 10, 1], "semantic": {"name": "bad2", "arg_names": [], "import_names": [], "rhs_call_name": "copy", "annotation": ""}, "snippet": " bad2 = copy(city_mapping)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L34_C8", "label": "assign", "type": "assigned_variable", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "vector": [14, 2, 0.125, 0.0037, 2, 0.77, 0.5, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " bad2['name'] = 'Nombre'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L37_C8", "label": "bad3 = copy()", "type": "assigned_variable", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "vector": [14, 2, 0.136, 0.0037, 2, 0.77, 0.625, 138, 3, 1, 0, 0, 739, 10, 1], "semantic": {"name": "bad3", "arg_names": [], "import_names": [], "rhs_call_name": "copy", "annotation": ""}, "snippet": " bad3 = copy(city_mapping)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L38_C8", "label": "assign", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "vector": [14, 2, 0.1397, 0.0037, 2, 0.77, 0.75, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " bad3['point'] = 'CURVE'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L42_C8", "label": "for bad_map", "type": "for", "loc": [42, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "vector": [6, 2, 0.1654, 0.0257, 2, 0.77, 0.875, 806, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "bad_map", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for bad_map in (bad1, bad2, bad3):\n try:\n lm = LayerMapping(City, city_shp, bad_map)\n except LayerMapError:\n pass\n else:\n self.fail('Expected a LayerMapError.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L43_C12", "label": "try", "type": "try", "loc": [43, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L42_C8", "vector": [7, 3, 0.1673, 0.0221, 3, 0.51, 0.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n lm = LayerMapping(City, city_shp, bad_map)\n except LayerMapError:\n pass\n else:\n self.fail('Expected a LayerMapError.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L44_C16", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [44, 44], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L43_C12", "vector": [14, 4, 0.1618, 0.0037, 4, 0.4, 0.0, 376, 3, 3, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(City, city_shp, bad_map)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L48_C16", "label": "fail()", "type": "expression", "loc": [48, 48], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L43_C12", "vector": [8, 4, 0.1765, 0.0037, 4, 0.4, 1.0, 364, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "fail", "arg_names": [], "import_names": [], "rhs_call_name": "fail", "annotation": ""}, "snippet": " self.fail('Expected a LayerMapError.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L51_C8", "label": "try", "type": "try", "loc": [51, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "vector": [7, 2, 0.1967, 0.0221, 2, 0.77, 1.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n lm = LayerMapping(City, city_shp, city_mapping, encoding='foobar')\n except LookupError:\n pass\n else:\n self.fail('Expected a LookupError')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L52_C12", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [52, 52], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L51_C8", "vector": [14, 3, 0.1912, 0.0037, 3, 0.68, 0.0, 376, 3, 4, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(City, city_shp, city_mapping, encoding='foobar')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L56_C12", "label": "fail()", "type": "expression", "loc": [56, 56], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L51_C8", "vector": [8, 3, 0.2059, 0.0037, 3, 0.68, 1.0, 364, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "fail", "arg_names": [], "import_names": [], "rhs_call_name": "fail", "annotation": ""}, "snippet": " self.fail('Expected a LookupError')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "label": "test02_simple_layermap", "type": "function", "loc": [58, 80], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "vector": [2, 1, 0.2537, 0.0846, 1, 0.17, 0.1667, 175, 0, 1, 0, 0, 0, 0, 13], "semantic": {"name": "test02_simple_layermap", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test02_simple_layermap(self):\n \"Test LayerMapping import of a simple point shapefile.\"\n # Setting up for the LayerMapping.\n lm = LayerMapping(City, city_shp, city_mapping)\n lm.save()\n\n # There should be three cities in the shape file.\n self.assertEqual(3, City.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L59_C8", "label": "expression", "type": "expression", "loc": [59, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "vector": [8, 2, 0.2169, 0.0037, 2, 0.68, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Test LayerMapping import of a simple point shapefile.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L61_C8", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "vector": [14, 2, 0.2243, 0.0037, 2, 0.68, 0.1667, 376, 3, 3, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(City, city_shp, city_mapping)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L62_C8", "label": "save()", "type": "expression", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "vector": [8, 2, 0.2279, 0.0037, 2, 0.68, 0.3333, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L65_C8", "label": "assertEqual()", "type": "expression", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "vector": [8, 2, 0.239, 0.0037, 2, 0.68, 0.5, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(3, City.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L69_C8", "label": "ds = DataSource()", "type": "assigned_variable", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "vector": [14, 2, 0.2537, 0.0037, 2, 0.68, 0.6667, 263, 3, 1, 0, 0, 717, 10, 1], "semantic": {"name": "ds", "arg_names": [], "import_names": [], "rhs_call_name": "DataSource", "annotation": ""}, "snippet": " ds = DataSource(city_shp)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L70_C8", "label": "layer =", "type": "assigned_variable", "loc": [70, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "vector": [14, 2, 0.2574, 0.0037, 2, 0.68, 0.8333, 556, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "layer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " layer = ds[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "label": "for feat", "type": "for", "loc": [71, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "vector": [6, 2, 0.2776, 0.0368, 2, 0.68, 1.0, 243, 2, 0, 0, 0, 0, 0, 8], "semantic": {"name": "feat", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for feat in layer:\n city = City.objects.get(name=feat['Name'].value)\n self.assertEqual(feat['Population'].value, city.population)\n self.assertEqual(Decimal(str(feat['Density'])), city.density)\n self.assertEqual(feat['Created'].value, city.dt)\n\n # Comparing the geometries.\n pnt1, pnt2 = feat.geom, city.point"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L72_C12", "label": "city = get()", "type": "assigned_variable", "loc": [72, 72], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "vector": [14, 3, 0.2647, 0.0037, 3, 0.58, 0.0, 825, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "city", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " city = City.objects.get(name=feat['Name'].value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L73_C12", "label": "assertEqual()", "type": "expression", "loc": [73, 73], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "vector": [8, 3, 0.2684, 0.0037, 3, 0.58, 0.1667, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(feat['Population'].value, city.population)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L74_C12", "label": "assertEqual()", "type": "expression", "loc": [74, 74], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "vector": [8, 3, 0.2721, 0.0037, 3, 0.58, 0.3333, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(Decimal(str(feat['Density'])), city.density)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L75_C12", "label": "assertEqual()", "type": "expression", "loc": [75, 75], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "vector": [8, 3, 0.2757, 0.0037, 3, 0.58, 0.5, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(feat['Created'].value, city.dt)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L78_C12", "label": "pnt1, pnt2 =", "type": "assigned_variable", "loc": [78, 78], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "vector": [14, 3, 0.2868, 0.0037, 3, 0.58, 0.6667, 187, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "pnt1, pnt2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pnt1, pnt2 = feat.geom, city.point"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L79_C12", "label": "assertAlmostEqual()", "type": "expression", "loc": [79, 79], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "vector": [8, 3, 0.2904, 0.0037, 3, 0.58, 0.8333, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(pnt1.x, pnt2.x, 6)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L80_C12", "label": "assertAlmostEqual()", "type": "expression", "loc": [80, 80], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "vector": [8, 3, 0.2941, 0.0037, 3, 0.58, 1.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(pnt1.y, pnt2.y, 6)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "label": "test03_layermap_strict", "type": "function", "loc": [82, 119], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "vector": [2, 1, 0.3695, 0.1397, 1, 0.17, 0.3333, 163, 0, 1, 0, 0, 0, 0, 20], "semantic": {"name": "test03_layermap_strict", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test03_layermap_strict(self):\n \"Testing the `strict` keyword, and import of a LineString shapefile.\"\n # When the `strict` keyword is set an error encountered will force\n # the importation to stop.\n try:\n lm = LayerMapping(Interstate, inter_shp, inter_mapping)\n lm.save(silent=True, strict=True)\n except InvalidDecimal:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L83_C8", "label": "expression", "type": "expression", "loc": [83, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "vector": [8, 2, 0.3051, 0.0037, 2, 0.01, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `strict` keyword, and import of a LineString shapefile.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L86_C8", "label": "try", "type": "try", "loc": [86, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "vector": [7, 2, 0.329, 0.0294, 2, 0.01, 0.1429, 0, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n lm = LayerMapping(Interstate, inter_shp, inter_mapping)\n lm.save(silent=True, strict=True)\n except InvalidDecimal:\n # No transactions for geoms on MySQL; delete added features.\n if mysql: Interstate.objects.all().delete()\n else:\n self.fail('Should have failed on strict import with invalid decimal values.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L87_C12", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [87, 87], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L86_C8", "vector": [14, 3, 0.3199, 0.0037, 3, 0.75, 0.0, 376, 3, 3, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(Interstate, inter_shp, inter_mapping)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L88_C12", "label": "save()", "type": "expression", "loc": [88, 88], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L86_C8", "vector": [8, 3, 0.3235, 0.0037, 3, 0.75, 0.5, 928, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save(silent=True, strict=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L91_C12", "label": "if", "type": "if", "loc": [91, 91], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L86_C8", "vector": [4, 3, 0.3346, 0.0037, 3, 0.75, 0.0, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if mysql: Interstate.objects.all().delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L91_C22", "label": "delete()", "type": "expression", "loc": [91, 91], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L91_C12", "vector": [8, 4, 0.3346, 0.0037, 4, 0.9, 0.0, 266, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " if mysql: Interstate.objects.all().delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L93_C12", "label": "fail()", "type": "expression", "loc": [93, 93], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L86_C8", "vector": [8, 3, 0.3419, 0.0037, 3, 0.75, 1.0, 364, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "fail", "arg_names": [], "import_names": [], "rhs_call_name": "fail", "annotation": ""}, "snippet": " self.fail('Should have failed on strict import with invalid decimal values.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L96_C8", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [96, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "vector": [14, 2, 0.3529, 0.0037, 2, 0.01, 0.2857, 376, 3, 3, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(Interstate, inter_shp, inter_mapping)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L97_C8", "label": "save()", "type": "expression", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "vector": [8, 2, 0.3566, 0.0037, 2, 0.01, 0.4286, 928, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save(silent=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L100_C8", "label": "assertEqual()", "type": "expression", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "vector": [8, 2, 0.3676, 0.0037, 2, 0.01, 0.5714, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(2, Interstate.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L103_C8", "label": "ds = DataSource()", "type": "assigned_variable", "loc": [103, 103], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "vector": [14, 2, 0.3787, 0.0037, 2, 0.01, 0.7143, 263, 3, 1, 0, 0, 717, 10, 1], "semantic": {"name": "ds", "arg_names": [], "import_names": [], "rhs_call_name": "DataSource", "annotation": ""}, "snippet": " ds = DataSource(inter_shp)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L106_C8", "label": "valid_feats =", "type": "assigned_variable", "loc": [106, 106], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "vector": [14, 2, 0.3897, 0.0037, 2, 0.01, 0.8571, 443, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "valid_feats", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " valid_feats = ds[0][:2]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L107_C8", "label": "for feat", "type": "for", "loc": [107, 119], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "vector": [6, 2, 0.4154, 0.0478, 2, 0.01, 1.0, 243, 2, 0, 0, 0, 0, 0, 10], "semantic": {"name": "feat", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for feat in valid_feats:\n istate = Interstate.objects.get(name=feat['Name'].value)\n\n if feat.fid == 0:\n self.assertEqual(Decimal(str(feat['Length'])), istate.length)\n elif feat.fid == 1:\n # Everything but the first two decimal digits were truncated,\n # because the Interstate model's `length` field has decimal_places=2."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L108_C12", "label": "istate = get()", "type": "assigned_variable", "loc": [108, 108], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L107_C8", "vector": [14, 3, 0.3971, 0.0037, 3, 0.72, 0.0, 360, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "istate", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " istate = Interstate.objects.get(name=feat['Name'].value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L110_C12", "label": "if", "type": "if", "loc": [110, 115], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L107_C8", "vector": [4, 3, 0.4136, 0.0221, 3, 0.72, 0.5, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if feat.fid == 0:\n self.assertEqual(Decimal(str(feat['Length'])), istate.length)\n elif feat.fid == 1:\n # Everything but the first two decimal digits were truncated,\n # because the Interstate model's `length` field has decimal_places=2.\n self.assertAlmostEqual(feat.get('Length'), float(istate.length), 2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L111_C16", "label": "assertEqual()", "type": "expression", "loc": [111, 111], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L110_C12", "vector": [8, 4, 0.4081, 0.0037, 4, 0.87, 0.0, 299, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(Decimal(str(feat['Length'])), istate.length)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L112_C12", "label": "if", "type": "if", "loc": [112, 115], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L110_C12", "vector": [4, 4, 0.4173, 0.0147, 4, 0.87, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif feat.fid == 1:\n # Everything but the first two decimal digits were truncated,\n # because the Interstate model's `length` field has decimal_places=2.\n self.assertAlmostEqual(feat.get('Length'), float(istate.length), 2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L115_C16", "label": "assertAlmostEqual()", "type": "expression", "loc": [115, 115], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L112_C12", "vector": [8, 5, 0.4228, 0.0037, 5, 0.94, 0.0, 448, 3, 3, 0, 0, 0, 0, 3], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(feat.get('Length'), float(istate.length), 2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L117_C12", "label": "for p1, p2", "type": "for", "loc": [117, 119], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L107_C8", "vector": [6, 3, 0.4338, 0.011, 3, 0.72, 1.0, 581, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "p1, p2", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for p1, p2 in zip(feat.geom, istate.path):\n self.assertAlmostEqual(p1[0], p2[0], 6)\n self.assertAlmostEqual(p1[1], p2[1], 6)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L118_C16", "label": "assertAlmostEqual()", "type": "expression", "loc": [118, 118], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L117_C12", "vector": [8, 4, 0.4338, 0.0037, 4, 0.0, 0.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(p1[0], p2[0], 6)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L119_C16", "label": "assertAlmostEqual()", "type": "expression", "loc": [119, 119], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L117_C12", "vector": [8, 4, 0.4375, 0.0037, 4, 0.0, 1.0, 448, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertAlmostEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertAlmostEqual", "annotation": ""}, "snippet": " self.assertAlmostEqual(p1[1], p2[1], 6)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L121_C4", "label": "county_helper", "type": "function", "loc": [121, 132], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "vector": [2, 1, 0.4651, 0.0441, 1, 0.17, 0.5, 58, 0, 2, 0, 0, 0, 0, 8], "semantic": {"name": "county_helper", "arg_names": ["self", "county_feat"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def county_helper(self, county_feat=True):\n \"Helper function for ensuring the integrity of the mapped County models.\"\n for name, n, st in zip(NAMES, NUMS, STATES):\n # Should only be one record b/c of `unique` keyword.\n c = County.objects.get(name=name)\n self.assertEqual(n, len(c.mpoly))\n self.assertEqual(st, c.state.name) # Checking ForeignKey mapping.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L122_C8", "label": "expression", "type": "expression", "loc": [122, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L121_C4", "vector": [8, 2, 0.4485, 0.0037, 2, 0.42, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Helper function for ensuring the integrity of the mapped County models.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L123_C8", "label": "for name, n, st", "type": "for", "loc": [123, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L121_C4", "vector": [6, 2, 0.4688, 0.0368, 2, 0.42, 1.0, 617, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "name, n, st", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name, n, st in zip(NAMES, NUMS, STATES):\n # Should only be one record b/c of `unique` keyword.\n c = County.objects.get(name=name)\n self.assertEqual(n, len(c.mpoly))\n self.assertEqual(st, c.state.name) # Checking ForeignKey mapping.\n\n # Multiple records because `unique` was not set.\n if county_feat:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L125_C12", "label": "c = get()", "type": "assigned_variable", "loc": [125, 125], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L123_C8", "vector": [14, 3, 0.4596, 0.0037, 3, 0.41, 0.0, 411, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " c = County.objects.get(name=name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L126_C12", "label": "assertEqual()", "type": "expression", "loc": [126, 126], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L123_C8", "vector": [8, 3, 0.4632, 0.0037, 3, 0.41, 0.3333, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(n, len(c.mpoly))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L127_C12", "label": "assertEqual()", "type": "expression", "loc": [127, 127], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L123_C8", "vector": [8, 3, 0.4669, 0.0037, 3, 0.41, 0.6667, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(st, c.state.name) # Checking ForeignKey mapping."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L130_C12", "label": "if", "type": "if", "loc": [130, 132], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L123_C8", "vector": [4, 3, 0.4816, 0.011, 3, 0.41, 1.0, 0, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if county_feat:\n qs = CountyFeat.objects.filter(name=name)\n self.assertEqual(n, qs.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L131_C16", "label": "qs = filter()", "type": "assigned_variable", "loc": [131, 131], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L130_C12", "vector": [14, 4, 0.4816, 0.0037, 4, 0.34, 0.0, 251, 3, 1, 0, 0, 526, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = CountyFeat.objects.filter(name=name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L132_C16", "label": "assertEqual()", "type": "expression", "loc": [132, 132], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L130_C12", "vector": [8, 4, 0.4853, 0.0037, 4, 0.34, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(n, qs.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "label": "test04_layermap_unique_multigeometry_fk", "type": "function", "loc": [134, 198], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "vector": [2, 1, 0.6103, 0.239, 1, 0.17, 0.6667, 888, 0, 1, 0, 0, 0, 0, 24], "semantic": {"name": "test04_layermap_unique_multigeometry_fk", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test04_layermap_unique_multigeometry_fk(self):\n \"Testing the `unique`, and `transform`, geometry collection conversion, and ForeignKey mappings.\"\n # All the following should work.\n try:\n # Telling LayerMapping that we want no transformations performed on the data.\n lm = LayerMapping(County, co_shp, co_mapping, transform=False)\n\n # Specifying the source spatial reference system via the `source_srs` keyword."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L135_C8", "label": "expression", "type": "expression", "loc": [135, 135], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [8, 2, 0.4963, 0.0037, 2, 0.74, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Testing the `unique`, and `transform`, geometry collection conversion, and ForeignKey mappings.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L137_C8", "label": "try", "type": "try", "loc": [137, 149], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [7, 2, 0.5257, 0.0478, 2, 0.74, 0.0556, 0, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n # Telling LayerMapping that we want no transformations performed on the data.\n lm = LayerMapping(County, co_shp, co_mapping, transform=False)\n\n # Specifying the source spatial reference system via the `source_srs` keyword.\n lm = LayerMapping(County, co_shp, co_mapping, source_srs=4269)\n lm = LayerMapping(County, co_shp, co_mapping, source_srs='NAD83')\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L139_C12", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [139, 139], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L137_C8", "vector": [14, 3, 0.511, 0.0037, 3, 0.41, 0.0, 376, 3, 4, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(County, co_shp, co_mapping, transform=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L142_C12", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [142, 142], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L137_C8", "vector": [14, 3, 0.5221, 0.0037, 3, 0.41, 0.3333, 376, 3, 4, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(County, co_shp, co_mapping, source_srs=4269)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L143_C12", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [143, 143], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L137_C8", "vector": [14, 3, 0.5257, 0.0037, 3, 0.41, 0.6667, 376, 3, 4, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(County, co_shp, co_mapping, source_srs='NAD83')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L146_C12", "label": "for arg", "type": "for", "loc": [146, 147], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L137_C8", "vector": [6, 3, 0.5386, 0.0074, 3, 0.41, 1.0, 447, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "arg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for arg in ('name', ('name', 'mpoly')):\n lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique=arg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L147_C16", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [147, 147], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L146_C12", "vector": [14, 4, 0.5404, 0.0037, 4, 0.13, 0.0, 376, 3, 5, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique=arg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L149_C12", "label": "fail()", "type": "expression", "loc": [149, 149], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L137_C8", "vector": [8, 3, 0.5478, 0.0037, 3, 0.41, 0.0, 364, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "fail", "arg_names": [], "import_names": [], "rhs_call_name": "fail", "annotation": ""}, "snippet": " self.fail('No exception should be raised for proper use of keywords.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L152_C8", "label": "for e, arg", "type": "for", "loc": [152, 153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [6, 2, 0.5607, 0.0074, 2, 0.74, 0.1111, 658, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "e, arg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for e, arg in ((TypeError, 5.0), (ValueError, 'foobar'), (ValueError, ('name', 'mpolygon'))):\n self.assertRaises(e, LayerMapping, County, co_shp, co_mapping, transform=False, unique=arg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L153_C12", "label": "assertRaises()", "type": "expression", "loc": [153, 153], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L152_C8", "vector": [8, 3, 0.5625, 0.0037, 3, 0.24, 0.0, 11, 3, 7, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(e, LayerMapping, County, co_shp, co_mapping, transform=False, unique=arg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L156_C8", "label": "if", "type": "if", "loc": [156, 157], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [4, 2, 0.5754, 0.0074, 2, 0.74, 0.1667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not mysql:\n self.assertRaises(LayerMapError, LayerMapping, County, co_shp, co_mapping)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L157_C12", "label": "assertRaises()", "type": "expression", "loc": [157, 157], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L156_C8", "vector": [8, 3, 0.5772, 0.0037, 3, 0.5, 0.0, 11, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(LayerMapError, LayerMapping, County, co_shp, co_mapping)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L161_C8", "label": "bad_fk_map1 = copy()", "type": "assigned_variable", "loc": [161, 161], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [14, 2, 0.5919, 0.0037, 2, 0.74, 0.2222, 642, 3, 1, 0, 0, 739, 10, 1], "semantic": {"name": "bad_fk_map1", "arg_names": [], "import_names": [], "rhs_call_name": "copy", "annotation": ""}, "snippet": " bad_fk_map1 = copy(co_mapping); bad_fk_map1['state'] = 'name'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L161_C40", "label": "assign", "type": "assigned_variable", "loc": [161, 161], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [14, 2, 0.5919, 0.0037, 2, 0.74, 0.2778, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " bad_fk_map1 = copy(co_mapping); bad_fk_map1['state'] = 'name'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L162_C8", "label": "bad_fk_map2 = copy()", "type": "assigned_variable", "loc": [162, 162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [14, 2, 0.5956, 0.0037, 2, 0.74, 0.3333, 96, 3, 1, 0, 0, 739, 10, 1], "semantic": {"name": "bad_fk_map2", "arg_names": [], "import_names": [], "rhs_call_name": "copy", "annotation": ""}, "snippet": " bad_fk_map2 = copy(co_mapping); bad_fk_map2['state'] = {'nombre' : 'State'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L162_C40", "label": "assign", "type": "assigned_variable", "loc": [162, 162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [14, 2, 0.5956, 0.0037, 2, 0.74, 0.3889, 0, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " bad_fk_map2 = copy(co_mapping); bad_fk_map2['state'] = {'nombre' : 'State'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L163_C8", "label": "assertRaises()", "type": "expression", "loc": [163, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [8, 2, 0.5993, 0.0037, 2, 0.74, 0.4444, 11, 3, 6, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(TypeError, LayerMapping, County, co_shp, bad_fk_map1, transform=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L164_C8", "label": "assertRaises()", "type": "expression", "loc": [164, 164], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [8, 2, 0.6029, 0.0037, 2, 0.74, 0.5, 11, 3, 6, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(LayerMapError, LayerMapping, County, co_shp, bad_fk_map2, transform=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L169_C8", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [169, 169], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [14, 2, 0.6213, 0.0037, 2, 0.74, 0.5556, 376, 3, 5, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique='name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L170_C8", "label": "assertRaises()", "type": "expression", "loc": [170, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [8, 2, 0.625, 0.0037, 2, 0.74, 0.6111, 11, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(MissingForeignKey, lm.save, silent=True, strict=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L173_C8", "label": "co, hi, tx =", "type": "assigned_variable", "loc": [173, 173], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [14, 2, 0.636, 0.0037, 2, 0.74, 0.6667, 872, 0, 0, 0, 0, 0, 8, 3], "semantic": {"name": "co, hi, tx", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " co, hi, tx = State(name='Colorado'), State(name='Hawaii'), State(name='Texas')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L174_C8", "label": "expression", "type": "expression", "loc": [174, 174], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [8, 2, 0.6397, 0.0037, 2, 0.74, 0.7222, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " co.save(), hi.save(), tx.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L189_C8", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [189, 189], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [14, 2, 0.6949, 0.0037, 2, 0.74, 0.7778, 376, 3, 5, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique='name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L190_C8", "label": "save()", "type": "expression", "loc": [190, 190], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [8, 2, 0.6985, 0.0037, 2, 0.74, 0.8333, 928, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save(silent=True, strict=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L194_C8", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [194, 194], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [14, 2, 0.7132, 0.0037, 2, 0.74, 0.8889, 376, 3, 4, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(CountyFeat, co_shp, cofeat_mapping, transform=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L195_C8", "label": "save()", "type": "expression", "loc": [195, 195], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [8, 2, 0.7169, 0.0037, 2, 0.74, 0.9444, 928, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save(silent=True, strict=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L198_C8", "label": "county_helper()", "type": "expression", "loc": [198, 198], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "vector": [8, 2, 0.7279, 0.0037, 2, 0.74, 1.0, 58, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "county_helper", "arg_names": [], "import_names": [], "rhs_call_name": "county_helper", "annotation": ""}, "snippet": " self.county_helper()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "label": "test05_test_fid_range_step", "type": "function", "loc": [200, 247], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "vector": [2, 1, 0.8217, 0.1765, 1, 0.17, 0.8333, 924, 0, 1, 0, 0, 0, 0, 31], "semantic": {"name": "test05_test_fid_range_step", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test05_test_fid_range_step(self):\n \"Tests the `fid_range` keyword and the `step` keyword of .save().\"\n # Function for clearing out all the counties before testing.\n def clear_counties(): County.objects.all().delete()\n\n # Initializing the LayerMapping object to use in these tests.\n lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique='name')\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L201_C8", "label": "expression", "type": "expression", "loc": [201, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.739, 0.0037, 2, 0.82, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Tests the `fid_range` keyword and the `step` keyword of .save().\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L203_C8", "label": "clear_counties", "type": "function", "loc": [203, 203], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [2, 2, 0.7463, 0.0037, 2, 0.82, 0.0435, 134, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "clear_counties", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clear_counties(): County.objects.all().delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L203_C30", "label": "delete()", "type": "expression", "loc": [203, 203], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L203_C8", "vector": [8, 3, 0.7463, 0.0037, 3, 0.66, 0.0, 266, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " def clear_counties(): County.objects.all().delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L206_C8", "label": "lm = LayerMapping()", "type": "assigned_variable", "loc": [206, 206], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [14, 2, 0.7574, 0.0037, 2, 0.82, 0.087, 376, 3, 5, 0, 0, 373, 10, 1], "semantic": {"name": "lm", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique='name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L209_C8", "label": "clear_counties()", "type": "expression", "loc": [209, 209], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.7684, 0.0037, 2, 0.82, 0.1304, 134, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "clear_counties", "arg_names": [], "import_names": [], "rhs_call_name": "clear_counties", "annotation": ""}, "snippet": " clear_counties()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L210_C8", "label": "bad_ranges =", "type": "assigned_variable", "loc": [210, 210], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [14, 2, 0.7721, 0.0037, 2, 0.82, 0.1739, 994, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "bad_ranges", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " bad_ranges = (5.0, 'foo', co_shp)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L211_C8", "label": "for bad", "type": "for", "loc": [211, 212], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [6, 2, 0.7776, 0.0074, 2, 0.82, 0.2174, 297, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "bad", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for bad in bad_ranges:\n self.assertRaises(TypeError, lm.save, fid_range=bad)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L212_C12", "label": "assertRaises()", "type": "expression", "loc": [212, 212], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L211_C8", "vector": [8, 3, 0.7794, 0.0037, 3, 0.89, 0.0, 11, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(TypeError, lm.save, fid_range=bad)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L215_C8", "label": "fr =", "type": "assigned_variable", "loc": [215, 215], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [14, 2, 0.7904, 0.0037, 2, 0.82, 0.2609, 6, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "fr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fr = (3, 5) # layer[3:5]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L216_C8", "label": "assertRaises()", "type": "expression", "loc": [216, 216], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.7941, 0.0037, 2, 0.82, 0.3043, 11, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "assertRaises", "arg_names": [], "import_names": [], "rhs_call_name": "assertRaises", "annotation": ""}, "snippet": " self.assertRaises(LayerMapError, lm.save, fid_range=fr, step=10)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L217_C8", "label": "save()", "type": "expression", "loc": [217, 217], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.7978, 0.0037, 2, 0.82, 0.3478, 928, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save(fid_range=fr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L221_C8", "label": "qs = all()", "type": "assigned_variable", "loc": [221, 221], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [14, 2, 0.8125, 0.0037, 2, 0.82, 0.3913, 251, 3, 0, 0, 0, 895, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "all", "annotation": ""}, "snippet": " qs = County.objects.all()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L222_C8", "label": "assertEqual()", "type": "expression", "loc": [222, 222], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.8162, 0.0037, 2, 0.82, 0.4348, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(1, qs.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L223_C8", "label": "assertEqual()", "type": "expression", "loc": [223, 223], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.8199, 0.0037, 2, 0.82, 0.4783, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Galveston', qs[0].name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L227_C8", "label": "clear_counties()", "type": "expression", "loc": [227, 227], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.8346, 0.0037, 2, 0.82, 0.5217, 134, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "clear_counties", "arg_names": [], "import_names": [], "rhs_call_name": "clear_counties", "annotation": ""}, "snippet": " clear_counties()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L228_C8", "label": "save()", "type": "expression", "loc": [228, 228], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.8382, 0.0037, 2, 0.82, 0.5652, 928, 3, 3, 0, 0, 0, 0, 2], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save(fid_range=slice(5, None), silent=True, strict=True) # layer[5:]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L229_C8", "label": "save()", "type": "expression", "loc": [229, 229], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.8419, 0.0037, 2, 0.82, 0.6087, 928, 3, 3, 0, 0, 0, 0, 2], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save(fid_range=slice(None, 1), silent=True, strict=True) # layer[:1]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L234_C8", "label": "qs = order_by()", "type": "assigned_variable", "loc": [234, 234], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [14, 2, 0.8603, 0.0037, 2, 0.82, 0.6522, 251, 3, 1, 0, 0, 23, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "order_by", "annotation": ""}, "snippet": " qs = County.objects.order_by('name')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L235_C8", "label": "assertEqual()", "type": "expression", "loc": [235, 235], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.864, 0.0037, 2, 0.82, 0.6957, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(2, qs.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L236_C8", "label": "hi, co = tuple()", "type": "assigned_variable", "loc": [236, 236], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [14, 2, 0.8676, 0.0037, 2, 0.82, 0.7391, 685, 3, 1, 0, 0, 259, 10, 1], "semantic": {"name": "hi, co", "arg_names": [], "import_names": [], "rhs_call_name": "tuple", "annotation": ""}, "snippet": " hi, co = tuple(qs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L237_C8", "label": "hi_idx, co_idx = tuple()", "type": "assigned_variable", "loc": [237, 237], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [14, 2, 0.8713, 0.0037, 2, 0.82, 0.7826, 469, 3, 1, 0, 0, 259, 10, 2], "semantic": {"name": "hi_idx, co_idx", "arg_names": [], "import_names": [], "rhs_call_name": "tuple", "annotation": ""}, "snippet": " hi_idx, co_idx = tuple(map(NAMES.index, ('Honolulu', 'Pueblo')))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L238_C8", "label": "assertEqual()", "type": "expression", "loc": [238, 238], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.875, 0.0037, 2, 0.82, 0.8261, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Pueblo', co.name); self.assertEqual(NUMS[co_idx], len(co.mpoly))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L238_C45", "label": "assertEqual()", "type": "expression", "loc": [238, 238], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.875, 0.0037, 2, 0.82, 0.8696, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Pueblo', co.name); self.assertEqual(NUMS[co_idx], len(co.mpoly))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L239_C8", "label": "assertEqual()", "type": "expression", "loc": [239, 239], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.8787, 0.0037, 2, 0.82, 0.913, 299, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Honolulu', hi.name); self.assertEqual(NUMS[hi_idx], len(hi.mpoly))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L239_C47", "label": "assertEqual()", "type": "expression", "loc": [239, 239], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [8, 2, 0.8787, 0.0037, 2, 0.82, 0.9565, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual('Honolulu', hi.name); self.assertEqual(NUMS[hi_idx], len(hi.mpoly))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L244_C8", "label": "for st", "type": "for", "loc": [244, 247], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "vector": [6, 2, 0.9026, 0.0147, 2, 0.82, 1.0, 93, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "st", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for st in (4,7,1000):\n clear_counties()\n lm.save(step=st, strict=True)\n self.county_helper(county_feat=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L245_C12", "label": "clear_counties()", "type": "expression", "loc": [245, 245], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L244_C8", "vector": [8, 3, 0.9007, 0.0037, 3, 0.88, 0.0, 134, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "clear_counties", "arg_names": [], "import_names": [], "rhs_call_name": "clear_counties", "annotation": ""}, "snippet": " clear_counties()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L246_C12", "label": "save()", "type": "expression", "loc": [246, 246], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L244_C8", "vector": [8, 3, 0.9044, 0.0037, 3, 0.88, 0.5, 928, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm.save(step=st, strict=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L247_C12", "label": "county_helper()", "type": "expression", "loc": [247, 247], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L244_C8", "vector": [8, 3, 0.9081, 0.0037, 3, 0.88, 1.0, 58, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "county_helper", "arg_names": [], "import_names": [], "rhs_call_name": "county_helper", "annotation": ""}, "snippet": " self.county_helper(county_feat=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "label": "test06_model_inheritance", "type": "function", "loc": [249, 267], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "vector": [2, 1, 0.9485, 0.0699, 1, 0.17, 1.0, 325, 0, 1, 0, 0, 0, 0, 8], "semantic": {"name": "test06_model_inheritance", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test06_model_inheritance(self):\n \"Tests LayerMapping on inherited models. See #12093.\"\n icity_mapping = {'name' : 'Name',\n 'population' : 'Population',\n 'density' : 'Density',\n 'point' : 'POINT',\n 'dt' : 'Created',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L250_C8", "label": "expression", "type": "expression", "loc": [250, 250], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "vector": [8, 2, 0.9191, 0.0037, 2, 0.27, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Tests LayerMapping on inherited models. See #12093.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L251_C8", "label": "icity_mapping =", "type": "assigned_variable", "loc": [251, 256], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "vector": [14, 2, 0.932, 0.0221, 2, 0.27, 0.1429, 925, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "icity_mapping", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " icity_mapping = {'name' : 'Name',\n 'population' : 'Population',\n 'density' : 'Density',\n 'point' : 'POINT',\n 'dt' : 'Created',\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L259_C8", "label": "lm1 = LayerMapping()", "type": "assigned_variable", "loc": [259, 259], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "vector": [14, 2, 0.9522, 0.0037, 2, 0.27, 0.2857, 191, 3, 3, 0, 0, 373, 10, 1], "semantic": {"name": "lm1", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm1 = LayerMapping(ICity1, city_shp, icity_mapping)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L260_C8", "label": "save()", "type": "expression", "loc": [260, 260], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "vector": [8, 2, 0.9559, 0.0037, 2, 0.27, 0.4286, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm1.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L263_C8", "label": "lm2 = LayerMapping()", "type": "assigned_variable", "loc": [263, 263], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "vector": [14, 2, 0.9669, 0.0037, 2, 0.27, 0.5714, 225, 3, 3, 0, 0, 373, 10, 1], "semantic": {"name": "lm2", "arg_names": [], "import_names": [], "rhs_call_name": "LayerMapping", "annotation": ""}, "snippet": " lm2 = LayerMapping(ICity2, city_shp, icity_mapping)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L264_C8", "label": "save()", "type": "expression", "loc": [264, 264], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "vector": [8, 2, 0.9706, 0.0037, 2, 0.27, 0.7143, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " lm2.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L266_C8", "label": "assertEqual()", "type": "expression", "loc": [266, 266], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "vector": [8, 2, 0.9779, 0.0037, 2, 0.27, 0.8571, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(6, ICity1.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L267_C8", "label": "assertEqual()", "type": "expression", "loc": [267, 267], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "vector": [8, 2, 0.9816, 0.0037, 2, 0.27, 1.0, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(3, ICity2.objects.count())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L269_C0", "label": "suite", "type": "function", "loc": [269, 272], "level": 0, "parent": null, "vector": [2, 0, 0.9945, 0.0147, 0, 0.66, 1.0, 425, 0, 0, 1, 0, 0, 0, 3], "semantic": {"name": "suite", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def suite():\n s = unittest.TestSuite()\n s.addTest(unittest.makeSuite(LayerMapTest))\n return s"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L270_C4", "label": "s = TestSuite()", "type": "assigned_variable", "loc": [270, 270], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L269_C0", "vector": [14, 1, 0.9926, 0.0037, 1, 0.18, 0.0, 553, 3, 0, 0, 0, 75, 10, 1], "semantic": {"name": "s", "arg_names": [], "import_names": [], "rhs_call_name": "TestSuite", "annotation": ""}, "snippet": " s = unittest.TestSuite()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L271_C4", "label": "addTest()", "type": "expression", "loc": [271, 271], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L269_C0", "vector": [8, 1, 0.9963, 0.0037, 1, 0.18, 0.5, 786, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "addTest", "arg_names": [], "import_names": [], "rhs_call_name": "addTest", "annotation": ""}, "snippet": " s.addTest(unittest.makeSuite(LayerMapTest))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98690:Return_L272_C4", "label": "return", "type": "return", "loc": [272, 272], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L269_C0", "vector": [13, 1, 1.0, 0.0037, 1, 0.18, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return s"}] | [{"f": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L42_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L43_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L43_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L44_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L43_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L48_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L51_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L52_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L51_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L56_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L72_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L73_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L74_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L75_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L79_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L71_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L80_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L83_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L86_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L87_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L86_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L88_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L86_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L91_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L91_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L91_C22"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L86_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L93_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L103_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L106_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L107_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L108_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L107_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L110_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L110_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L111_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L110_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L112_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L112_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L115_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L107_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L117_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L117_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L118_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L117_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L119_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L121_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L121_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L122_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L121_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L123_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L123_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L125_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L123_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L126_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L123_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L127_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L123_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L130_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L130_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L131_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L130_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L132_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L135_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L137_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L139_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L142_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L143_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L146_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L146_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L147_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:Try_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L149_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L152_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L152_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L153_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:If_L156_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L157_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L161_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L161_C40"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L162_C40"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L164_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L169_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L170_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L173_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L174_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L189_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L190_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L194_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L195_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L198_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L201_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L203_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L203_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L203_C30"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L206_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L209_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L210_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L211_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L211_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L212_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L215_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L216_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L217_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L221_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L222_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L223_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L227_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L228_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L229_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L234_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L235_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L236_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L237_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L238_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L238_C45"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L239_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L239_C47"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L200_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L244_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L245_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L246_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:For_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L247_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:ClassDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L250_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L251_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L259_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L260_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L263_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L264_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L266_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L267_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L269_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Assign_L270_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L269_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Expr_L271_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98690:FunctionDef_L269_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98690:Return_L272_C4"}] |
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^geoapp/', include('django.contrib.gis.tests.geoapp.urls')),
)
| ajibawa-2023/Python-Code-Large/train/row_98691 | 2 | 6 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_98691:ImportFrom_L1_C0", "label": "from django.conf.urls.defaults import *", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.1667, 0.1667, 0, 0.66, 0.0, 341, 0, 1, 0, 0, 341, 0, 0], "semantic": {"name": "django.conf.urls.defaults", "arg_names": [], "import_names": ["*"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.conf.urls.defaults import *"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98691:Assign_L3_C0", "label": "urlpatterns = patterns()", "type": "assigned_variable", "loc": [3, 5], "level": 0, "parent": null, "vector": [14, 0, 0.6667, 0.5, 0, 0.66, 1.0, 990, 3, 2, 0, 0, 75, 10, 2], "semantic": {"name": "urlpatterns", "arg_names": [], "import_names": [], "rhs_call_name": "patterns", "annotation": ""}, "snippet": "urlpatterns = patterns('',\n (r'^geoapp/', include('django.contrib.gis.tests.geoapp.urls')),\n )"}] | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.